Render a Scene Node over/under another

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
dmb
Posts: 9
Joined: Thu Jun 13, 2013 2:07 pm

Render a Scene Node over/under another

Post by dmb »

I'm attempting to build a 2.5D Engine using an Orthogonal Matrix,

I've managed to get rendering the images down and movement down, but when I have an object that can move it doesn't render over a static object, only under. I've looked at the ISceneNode and ISceneManager api and can't find anything obvious that would let me change rendering order (or z-index for those web inclined). I'm concerned I'm just missing something here.

Is there a way to make an object that moves from key input render/draw over a static object? I've tried having it be later in the list, but that doesn't seem to work.

Could I just create a flag and set depending on whether I want it to render under or over? Or is there something I'm missing?
hendu
Posts: 2600
Joined: Sat Dec 18, 2010 12:53 pm

Re: Render a Scene Node over/under another

Post by hendu »

It's still 3d space. Your moving object is under the static object, put it above :)
dmb
Posts: 9
Joined: Thu Jun 13, 2013 2:07 pm

Re: Render a Scene Node over/under another

Post by dmb »

That would be nice, but with the orthogonal left hand view I can't do any negative values.

I've actually been running into a problem just being able to move anything around the map because any time a x, y, or z value for an object goes below 0 the object just stops rendering.

Would changing the bounding box make a difference there?
mongoose7
Posts: 1227
Joined: Wed Apr 06, 2011 12:13 pm

Re: Render a Scene Node over/under another

Post by mongoose7 »

It's a simple management issue - keep everything in front of the camera. You have control, you have the power.
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: Render a Scene Node over/under another

Post by chronologicaldot »

dmb wrote:I've actually been running into a problem just being able to move anything around the map because any time a x, y, or z value for an object goes below 0 the object just stops rendering.
Change the camera position. The object stops rendering because it moves out of the camera's field of view (like, behind it).
dmb
Posts: 9
Joined: Thu Jun 13, 2013 2:07 pm

Re: Render a Scene Node over/under another

Post by dmb »

chronologicaldot wrote:
dmb wrote:I've actually been running into a problem just being able to move anything around the map because any time a x, y, or z value for an object goes below 0 the object just stops rendering.
Change the camera position. The object stops rendering because it moves out of the camera's field of view (like, behind it).

Is there a way that I can move a camera with a built LH ortho projection matrix such that it shows all negative values? Here's a sample of my camera code:

Code: Select all

//My current Camera
    ICameraSceneNode * camera = smgr->addCameraSceneNode(0, vector3df(2.f, 2.f, 2.f), vector3df(0.f,0.f,0.f));
        //My built matrix.
        matrix4 myMatrix;
    myMatrix.buildProjectionMatrixOrthoLH(200.0f, 150.0f, 800.f, -800.f);
        //Set the matrix to the camera  
    camera->setProjectionMatrix(myMatrix);
 
    //Make the camera active.
    smgr->setActiveCamera(camera);
 
^ This code here Prevents me from rendering any values below 0. Above is fine, but below is not. The second I render anything (normally just boxes) below 0 on any plane be it x, y, or z they just disappear.

The goal is to make it look 2.5D, but its hard to do that on an only positive plane.
chronologicaldot
Competition winner
Posts: 699
Joined: Mon Sep 10, 2012 8:51 am

Re: Render a Scene Node over/under another

Post by chronologicaldot »

Why is the 4th parameter (zFar) of buildProjectionMatrixOrthoLH negative? That should be positive (it's talking about distance from, not coordinate system value). If you look in the code for that (matrix.h, line 1627), you see:
M[14] = (T)(zNear/(zNear-zFar));
Which, given zNear == zFar, you break at line 1609:
_IRRDEBUG_BREAK_IF(zNear==zFar);
So, make zFar positive 800.

Moving on:
So why are trying to render things in the negative range? Even for web-design, negative z-index puts it below the background (and makes it invisible) - which is kind of a cheap trick for things, lol.
Just assign positive values for the different layers: z=0 is the far background, z=1 is background scenery, z=2 is background imagery but nearer to the player, z=3 is second-floor stuff (like in Mario - stuff you can jump on but is still behind the front), z=4 is the final front, and z=5 is where the player usually resides.

atm I wish I could say more, but I have yet to sit and experiment with it myself.
dmb
Posts: 9
Joined: Thu Jun 13, 2013 2:07 pm

Re: Render a Scene Node over/under another

Post by dmb »

chronologicaldot wrote:Why is the 4th parameter (zFar) of buildProjectionMatrixOrthoLH negative? That should be positive (it's talking about distance from, not coordinate system value). If you look in the code for that (matrix.h, line 1627), you see:
M[14] = (T)(zNear/(zNear-zFar));
Which, given zNear == zFar, you break at line 1609:
_IRRDEBUG_BREAK_IF(zNear==zFar);
So, make zFar positive 800.
This actually fixed my problem - but not in the way you suggested. Once I switched the zNear to -800 and the zFar to 800, the image I had set up started rendering properly. Thank you!
chronologicaldot wrote:Moving on:
So why are trying to render things in the negative range? Even for web-design, negative z-index puts it below the background (and makes it invisible) - which is kind of a cheap trick for things, lol.
Just assign positive values for the different layers: z=0 is the far background, z=1 is background scenery, z=2 is background imagery but nearer to the player, z=3 is second-floor stuff (like in Mario - stuff you can jump on but is still behind the front), z=4 is the final front, and z=5 is where the player usually resides.

atm I wish I could say more, but I have yet to sit and experiment with it myself.
Well its just a regular 3D map, just being displayed as if it is 2.5D. So once I switched the zNear and zFar so that they were the proper values, I was able to render below 0,0,0 and so my problem fixed itself.

I spent 3 days trying to figure out why I couldn't render below that point...
Post Reply