Drawing order

If you are a new Irrlicht Engine user, and have a newbie-question, this is the forum for you. You may also post general programming questions here.
Post Reply
vnguyen
Posts: 3
Joined: Thu Oct 19, 2006 8:40 pm

Drawing order

Post by vnguyen »

I have 2 objects that I wish to draw one above the other and I would like some advice on how this could be done.

I have
- Sphere --> world pos = 0,0,0
- Cube --> world pos = 0,0,1

So if the camera is at (0,0,5) looking at (0,0,0)
Calling pSceneManager->drawAll() would render the Cube in "front" of the Sphere

Now I wish to render the Cube "behind" the Sphere while keeping all my objects in their respective positions.

In pseudo code, here is what I did

Hide the Sphere
Show the Cube
pSceneManager->drawAll()
Show the Sphere
Hide the Cube
pSceneManager->drawAll()

Now doing that, I would expect the Sphere to be drawn on to of the Cube that is not the case. Can anyone hint on what I've done wrong please.
Acki
Posts: 3496
Joined: Tue Jun 29, 2004 12:04 am
Location: Nobody's Place (Venlo NL)
Contact:

Post by Acki »

First mistake is that the Z axis is not up/down, its front/back !!!
So if you want a node on top of another you'll have to set the Y axis !!!
X -> left/right
Y -> up/down
Z -> front/back

then, your pseudo code is the complete render loop ???
then the second drawAll() erases/overrides the first drawAll() !!!

and finally I don't know what you really want ???
once you say "cube behind sphere" and then "one on top of the other" ???
while(!asleep) sheep++;
IrrExtensions:Image
http://abusoft.g0dsoft.com
try Stendhal a MORPG written in Java
JP
Posts: 4526
Joined: Tue Sep 13, 2005 2:56 pm
Location: UK
Contact:

Post by JP »

By on top i think he means rendered in front of, so he does understand that the z axis is forward/back.

I also wondered if the drawAll would draw over the previous drawing, but if he had only the cube and the sphere in the scene and nothing else would it not work? I wondered if drawAll clears the scene and then redraws, but i guess it's driver->beginScene that does the clearing.

Out of interest, what's the reason for this? Maybe there's some other way round it.
Image Image Image
bitplane
Admin
Posts: 3204
Joined: Mon Mar 28, 2005 3:45 am
Location: England
Contact:

Post by bitplane »

hide both the nodes, do a drawAll, then draw the nodes manually with node->render
you can disable writing to or checking the depth buffer when drawing, just set the ZWriteEnable and ZBuffer flags in the node's material
Submit bugs/patches to the tracker!
Need help right now? Visit the chat room
Post Reply