Jump to content

  • Log In with Google      Sign In   
  • Create Account

FREE SOFTWARE GIVEAWAY

We have 4 x Pro Licences (valued at $59 each) for 2d modular animation software Spriter to give away in this Thursday's GDNet Direct email newsletter.


Read more in this forum topic or make sure you're signed up (from the right-hand sidebar on the homepage) and read Thursday's newsletter to get in the running!


3D model render sequence


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
5 replies to this topic

#1 stabilize   Members   -  Reputation: 107

Like
0Likes
Like

Posted 19 April 2014 - 06:25 PM

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

 

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

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

 

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, 19 April 2014 - 06:26 PM.


Sponsor:

#2 ekba89   Members   -  Reputation: 479

Like
2Likes
Like

Posted 19 April 2014 - 10:45 PM

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;


#3 cozzie   Members   -  Reputation: 1770

Like
1Likes
Like

Posted 20 April 2014 - 04:51 AM

If that doesn't solve it, maybe you can check if Z buffering is set correctly

#4 stabilize   Members   -  Reputation: 107

Like
0Likes
Like

Posted 20 April 2014 - 11:01 AM

Thanks for the replies :)

 

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

 

@cozzie thanks I will check both :)



#5 stabilize   Members   -  Reputation: 107

Like
0Likes
Like

Posted 20 April 2014 - 11:15 AM

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



#6 ekba89   Members   -  Reputation: 479

Like
1Likes
Like

Posted 20 April 2014 - 12:55 PM


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






Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS