render 3D primitive,
Members - Reputation: 56
Posted 28 August 2011 - 05:45 AM
spriteBatch.Draw(rockTexture, rockPosition, null, Color.White,
rockRotation, rockCenter, 1.0f, SpriteEffects.None, 0.0f);
spriteBatch.Draw(shipTexture, shipPosition, null, Color.White,
shipRotation, shipCenter, 1.0f, SpriteEffects.None, 0.0f);
thease instruction to Draw function,the 3D primitive can not be displayed why?have you can fix the problem?
Members - Reputation: 475
Posted 01 September 2011 - 11:28 AM
To render 3d content you use shaders, and to use a shader you have to manually set the necessary settings and parameters of the graphics device for it to work, the SpriteBatch instead is not a shader, it uses a shader inside, but abstracts you from all those settings.
If you use 3d graphics only, many settings will be in a default state that you do not need to change for 3d content, however the sprite batch changes them and does not restore them to their original state unless you tell it to, if I'm not wrong this is done by setting the following parameter on the begin call of the SpriteBatch
By default this is set to None, which does not restore original settings after the end call. If you are only going to render 2d though, you want it set to none, changing render states is expensive and should be done as less as possible.
LinkedIn profile: http://ar.linkedin.com/pub/andres-ricardo-chamarra/2a/28a/272
Members - Reputation: 220
Posted 05 April 2012 - 06:43 PM
So, inside the draw method, set :
GraphicsDevice.DepthStencilState = DepthStencilState.Default;
And if your not already, you should draw any 2d sprites AFTER you draw your 3d models/primitives. So put the spriteBatch.Draw() after the call to base.Draw() in your draw method.