Page 1 of 1

Drawing order

Posted: Thu Nov 09, 2006 8:58 pm
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.

Posted: Thu Nov 09, 2006 9:40 pm
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" ???

Posted: Thu Nov 09, 2006 10:29 pm
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.

Posted: Thu Nov 09, 2006 10:47 pm
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