• Advertisement
Sign in to follow this  

3D model render sequence

This topic is 1375 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I am currently having issues with my model rendering sequence and am obviously doing something wrong. It is easier to show than explain.

 

kZj4twh.gif

 

[source]public override void Update(GameTime gameTime)
{
    for (int i = 0; i < models.Count; ++i )
    {
        models.Update();
    }
    base.Update(gameTime);
}

public override void Draw(GameTime gameTime)
{
    foreach (BasicModel model in models)
    {
        model.Draw(((ForgottenGame)Game).camera);
    }
    base.Draw(gameTime);
}[/source]

 

That is the code that I use to update and draw each of the models in a list.

 

Im sure there is some math I am missing but not sure how to describe my issue.

 

I am hoping someone can point me in the right direction

 

Thanks

Oli

Edited by stabilize

Share this post


Link to post
Share on other sites
Advertisement

It looks like you have problem with your depth stencil state. If you are using SpriteFonts they might change your render states so you need to reset them before 3D rendering. Try to put the code below just before your rendering.

GraphicsDevice.BlendState = BlendState.Opaque;
GraphicsDevice.DepthStencilState = DepthStencilState.Default;

Share this post


Link to post
Share on other sites

Thanks for the replies :)

 

@ekba89 Do I need to reset the render states every draw cycle?

 

@cozzie thanks I will check both :)

Share this post


Link to post
Share on other sites

@ekba89 Thank you that solved it for me. Well I have commented out the spritebatch stuff for now and will fix it with what you suggested :)

Share this post


Link to post
Share on other sites


@ekba89 Do I need to reset the render states every draw cycle?

 

You might have different render states for different models. So you have to change them depending on what you are trying to do. But for the normal 3D rendering default settings should suffice. If all your models are using default render states you just need to set them once in the beginning of your application. But as I said SpriteBatch changes it before it does its 2D rendering. So if you are using SpriteBatch and some 3D models you need to reset your render states every time before you render your 3D models.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement