Managed Mesh behind Sprite problem

Started by
1 comment, last by Meshboy 17 years ago
Hi! im pretty new to this MDX stuff, but i have completed rendering a 3DS model and it is working correct, i have also created a sprite by using the Direct3D.Sprite,texture and also a rectangle that set the size. My problem is that the sprite is being drawn ontop of the mesh even though i am rendering the model after drawing my sprite. is there something im not thinking of? set z-buffer layers or something, i want to create a background sprite that is behind my rendered mesh model. help please... here is some code... device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1.0f, 0); //setup Cameras SetupCamera(); device.BeginScene(); //Sprite begin sprite.Begin(SpriteFlags.AlphaBlend); sprite.Draw(spriteTexture, new Rectangle(0, 0, 320, 480), new Vector3(0,0,0),new Vector3(0,0,0), Color.White); sprite.End(); DrawMesh(angle / (float)Math.PI, angle / (float)Math.PI * 0.001f, 0 / (float)Math.PI / 4.0f, 0.0f, 0.0f, 0.0f); device.EndScene(); device.Present(); this.Invalidate();
Advertisement
Have you tried changing the Z coordinate? I remember something about getting 2D elements to render behind 3D ones by setting the Z value to around 1.0. If that doesn't work you can try making the sprite render in object space using the SpriteFlags.ObjectSpace flag.

Edit: I know the effect you're looking for is possible using a vertex buffer, so even if this doesn't work, you're not stuck.
thanks, im gona try with the Z-buffer thing, but i really want to use the object objectSpace flag, beacuse i plan to pivit some sprites to get a terrain from it...

if anyone have dont this, i would be thankful for some code...

This topic is closed to new replies.

Advertisement