3D model render sequence

Started by
4 comments, last by ekba89 9 years, 12 months ago

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

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;
If that doesn't solve it, maybe you can check if Z buffering is set correctly

Crealysm game & engine development: http://www.crealysm.com

Looking for a passionate, disciplined and structured producer? PM me

Thanks for the replies :)

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

@cozzie thanks I will check both :)

@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 :)


@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.

This topic is closed to new replies.

Advertisement