2
\$\begingroup\$

So I followed the basic 3D model display tutorial found here: http://msdn.microsoft.com/en-us/library/bb197293%28v=xnagamestudio.31%29.aspx

And while I know this is for XNA 3.1, I can still get the screen to show and the background color to change fine. The model file seems to be accepted in the method below:

protected override void LoadContent()
    {
        // Used to draw textures.
        spriteBatch = new SpriteBatch(GraphicsDevice);

        grudmud = Content.Load<Model>("Models\\Vikings_grudmud");

        aspectRatio = graphics.GraphicsDevice.Viewport.AspectRatio;
    }

The model was created in Blender, so perhaps I'm missing a step in creating a mesh or certain texture for it? I have colored it in Blender and it's a simple blocky humanoid figure. Is there a scaling I should check in Blender so the camera in XNA is not inside the object?

Here's where I actually draw the object and set out some basic properties:

protected override void Draw(GameTime gameTime)
    {
        GraphicsDevice.Clear(Color.Aqua);

        Matrix[] transforms = new Matrix[grudmud.Bones.Count];
        grudmud.CopyAbsoluteBoneTransformsTo(transforms);

        foreach (ModelMesh mesh in grudmud.Meshes) {

            foreach (BasicEffect effect in mesh.Effects) {
                effect.EnableDefaultLighting();
                effect.World = transforms[mesh.ParentBone.Index] *
                    Matrix.CreateRotationY(modelRotation)
                   * Matrix.CreateTranslation(modelPosition);
                effect.View = Matrix.CreateLookAt(cameraPosition, 
                    Vector3.Zero, Vector3.Up);
                effect.Projection = Matrix.CreatePerspectiveFieldOfView(MathHelper.ToRadians(45.0f),
                    aspectRatio, 1.0f, 10000.0f);
                effect.PreferPerPixelLighting = true;
            }

            mesh.Draw();
        }
        base.Draw(gameTime);
    }

The initial camera and player model positions:

Vector3 modelPosition = Vector3.Zero;
    float modelRotation = 0.0f;
    Vector3 cameraPosition = new Vector3(0.0f, 50.0f, 5000.0f);

Under Content project thingy.

I haven't even attempted to implement the face texture yet.

My model in blender, camera and all.

It seems to have a wireframe/mesh, I've just colored in the faces. The model is pretty much centered around the origin.

Am I exporting it wrong? Do I need to specify lighting/camera angles any further?

\$\endgroup\$
7
  • 1
    \$\begingroup\$ what is the position of the camera and the what is the position of the model? \$\endgroup\$ Jul 6, 2013 at 18:24
  • \$\begingroup\$ Looks like the camera is 0, 50, and 5,000 for x,y,z respectively. The Vector3.Zero sets all components to 0 so in theory 0,0,0. \$\endgroup\$
    – A13X
    Jul 6, 2013 at 19:18
  • \$\begingroup\$ Ok, This Must Be A Problem With Loading Your Model Or Just The Model Itself. \$\endgroup\$ Jul 6, 2013 at 20:04
  • \$\begingroup\$ Uhh does anyone know how to unwrap the entire texture/materials of the model so I only need one .tga file? I have one image and the rest of the faces are colored in with "material" according to Blender. \$\endgroup\$
    – A13X
    Jul 7, 2013 at 16:30
  • \$\begingroup\$ Ok, so after editing the sample's .tga texture file to completely black, the model still rendered. Im seriously thinking I am forgetting to add something in blender before exporting as a .fbx but can't seem to figure out what. \$\endgroup\$
    – A13X
    Jul 7, 2013 at 17:24

1 Answer 1

2
\$\begingroup\$

I was having the same problem when following the same tutorial. I took Fibericon's advice and played with the export scale. I had to increase it to 100.0 (from 1.0) for the model to display properly when compiled in XNA. As an alternative, I found decreasing the distance of the camera from 5000.0f to 50.0f made the model visible.

This begs the question why. The suggested export scale based on this help page is 1.0. The scale of my model's objects are all 1.0. My XNA code is identical to the OP's.

Regardless, it's working. Thanks Fibericon!

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .