Model not showing up in game

Hi all:

I'm playing around with the XNA Framework more and starting to make sense of things. I've run through the 3D tutorial and I can see the p1_wedge model just fine. Unfortunately, when I try to make my own model and bring it into the tutorial, I don't see anything. I have a texture for the model as well as the .x file itself that I created in trueSpace 6.6, and I've verified that it compiles ok in the project. I don't get any runtime errors either.

Maybe I've missed something in the documentation... is there a scale of measurement I should be using Are there guidelines for creating 3D models for use in XNA I'd love for that to be in the docs. Anyway, I've uploaded a couple of files to my website for reference:

http://www.spellflight.com/GameModels/SRB.bmp

http://www.spellflight.com/GameModels/SRB.x

If you're using the tutorial, the .x file goes in your Content/Models directory, and the .bmp file goes in your Content/Textures directory.

I've been wanting to make a video game since the days of DirectX 3, but always found the steep learning curve a barrier to entry. Thanks for making XNA, and thanks for your help!



Answer this question

Model not showing up in game

  • lasa

    Assuming you're talking about the Displaying a 3D Model On The Screen tutorial in Help, make this change:

    Vector3 camposition = new Vector3(0.0f, 50.0f, 10.0f);



  • Arun S

    Got my texture problem fixed, yay!

    Turns out that since I was mixing 2D images with 3D models, I had to reset some states in the graphics device. I found the answer on another thread, courtesy of Shawn Hargreaves

    http://blogs.msdn.com/shawnhar/

    So what I did is this:

    //Reset drawing states

    graphics.GraphicsDevice.RenderState.DepthBufferEnable = true;

    graphics.GraphicsDevice.RenderState.AlphaBlendEnable = false;

    graphics.GraphicsDevice.RenderState.AlphaTestEnable = false;

    graphics.GraphicsDevice.SamplerStates[0].AddressU = TextureAddressMode.Wrap;

    graphics.GraphicsDevice.SamplerStates[0].AddressV = TextureAddressMode.Wrap;


  • Mstanglx

    In finding the problem, I just dumped the texture and mesh files into the project folder and changed the location to the texture in the mesh file. The texture showed just fine when I ran it. It can be a bit hard to see. Change the color of the texture and you'll see it.

    As for the other problem, I'm still a relative 3D n00b, so I'm not quite sure what the answer is.



  • rautchetan

    That helped, thanks! I also tried modifying the matrix position:

    matrixPosition = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(15.0f),

    aspectRatio, 1.0f, 20000.0f);

    That moved the model closer as well. It looks like there is a relationship betwen where the camera is and the perspective field of view. Unfortunately I haven't found much information on what that relationship is. Is there a way to tell the units of measurement on the camera position and the field of view Since it seems XNA's documentation is not complete, where can I find general information on the field of view I've been using C# for many years, but I'm new to game programming.

    One last thing: I don't see my texture displayed on the model. I'm wondering if I've done something wrong still. Thanks for your help!


  • Model not showing up in game