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?
Render a Scene Node over/under another
Re: Render a Scene Node over/under another
It's still 3d space. Your moving object is under the static object, put it above 
Re: Render a Scene Node over/under another
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?
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?
Re: Render a Scene Node over/under another
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
Change the camera position. The object stops rendering because it moves out of the camera's field of view (like, behind it).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.
Re: Render a Scene Node over/under another
chronologicaldot wrote:Change the camera position. The object stops rendering because it moves out of the camera's field of view (like, behind it).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.
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);
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
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.
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.
Re: Render a Scene Node over/under another
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: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.
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.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.
I spent 3 days trying to figure out why I couldn't render below that point...