Take the 2-minute tour ×
Game Development Stack Exchange is a question and answer site for professional and independent game developers. It's 100% free, no registration required.

My XNA model renders wrong.

It should render like that:

But it renders like that:

The background doesn't matter. It's just the model that renders wrong.

Here is the drawing code:

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

    DrawModel(model);

    base.Draw(gameTime);
}

private void DrawModel(Model m)
{
    GraphicsDevice.RasterizerState = RasterizerState.CullNone;

    Matrix worldMatrix = Matrix.CreateRotationY(MathHelper.ToRadians(rot))
        * Matrix.CreateTranslation(new Vector3(0,0,0));

    foreach (ModelMesh mesh in m.Meshes)
    {
        foreach (BasicEffect effect in mesh.Effects)
        {
            effect.EnableDefaultLighting();
            effect.World = worldMatrix;
            effect.View = viewMatrix;
            effect.Projection = projectionMatrix;
        }

        mesh.Draw();
    }
}
share|improve this question
    
What do you mean with posting the mesh? The model loading code is this: Model model = Content.Load<Model>("Model"); It looks fine in the model editor. The model is saved in a .fbx file –  user1990950 Mar 1 '13 at 15:36
add comment

1 Answer

up vote 5 down vote accepted

The problem you are describing could be caused by polygons with more than 4 vertices. Please make sure that you have edges in the model as seen in the image below:

share|improve this answer
    
Wow that worked perfectly thanks! –  user1990950 Mar 1 '13 at 16:10
3  
There's a way to automate it in SketchUp. –  Anko Mar 1 '13 at 16:28
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.