I've been going through several tutorials on how to use XNA and understand a lot thus far. I've got a screen, I've got 2D sprites working, got a shader system operational, so far so good. Now I've hit a wall.
I'm attempting to load a 3D model (FBX Format) I've exported from 3DS. My issue, is the texture system. First, I'm trying to avoid embedding the textures directly into the FBX as I'll be reusing a lot of the textures for different things, no need to load multiple copies of the same texture. I know my texture, even though not embedded, is making it to my XNA classes because I can see it inside the FBX (when saved as ASCII) and get a compiler error if I attempt to move the texture out of its original location. I can also see it compiling the image during a rebuild.
However, if I attempt to render the object, no texture. Loading code:
protected override void LoadContent()
{
objModel = LoadModel("Models/OriginModel");
}
objModel is defined as a Model higher up in the cs file.
My display code:
foreach (ModelMesh mesh in objModel.Meshes)
{
foreach (Effect currentEffect in mesh.Effects)
{
currentEffect.CurrentTechnique = currentEffect.Techniques["TextureNormalMap"];
currentEffect.Parameters["World"].SetValue(objTransforms[mesh.ParentBone.Index] * worldMatrix);
currentEffect.Parameters["View"].SetValue(viewMatrix);
currentEffect.Parameters["Projection"].SetValue(projectionMatrix);
}
}
I've stripped out the matrix transforms and such as they're not causing the issue. TextureNormalMap is my shader I've written that displays a texture with a normal map. This generates a black model. If I however add...
metalTex = Content.Load<Texture2D>("Textures/brushedmetaltexture");
and
currentEffect.Parameters["ColorMap"].SetValue(metalTex);
where needed, I get the texture to display. This is of course, the problem. I have to include the texture in my Content system, causing the image to be compiled twice (which generates a warning..compiled once from the FBX, compiled once from Content). More importantly, I would have to hand-texture all the models again inside the XNA system in order to get them to display, which is what I'm trying to avoid. I've already textured them once in 3DS, do I really need to specify, inside XNA during object load, all the textures again?
So, any ideas on what I'm doing wrong here? What magical step am I skipping? Am I supposed to, somehow, figure out what the texture name is from the FBX file itself and get a pointer to the extracted image to feed into my Texture2D? Is there a different object I should use that includes the texture from the FBX? Do I need to bite the bullet and just go with embedding (which still doesn't work with the above code btw)?
I've been going off of tutorials as I mentioned, but this step seems to be missing, or am I just being daft? I apologize if this seems trivial, but I just can't solve it. Is there some step in the object loading process I'm missing?