Horde3D

Next-Generation Graphics Engine
It is currently 25.11.2024, 03:42

All times are UTC + 1 hour




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: 08.03.2011, 18:51 
Offline

Joined: 08.03.2011, 18:29
Posts: 17
I'm making a game utilizing isometric projection.
Image

Horde3D has support for this with the Camera Parameter OrthoI (Flag for setting up an orthographic frustum instead of a perspective one (default: 0) ). During my tests it turned out that while it looks great and exactly the way I wanted, it is impossible to tell depth this way. Here is an example from wikipedia:
Image

The remedy for this could be provided by tweaking the projection matrix to have something between the isometric and perspective projection that makes the game look like an isometric game, but also offers the benefit of depth perception. This video shows what I mean. Watch the pillars when the camera moves - notice how the top of the pillars move faster than the ground.

My question is, how can I achieve something like this this with Horde3D? There is a function DLL void h3dGetCameraProjMat(H3DNode cameraNode, float *projMat) that allows you to read the projection Matrix, but no possibility to set it (as far as I see). So are there any other parameters that allow me to achieve this effect?


Top
 Profile  
Reply with quote  
PostPosted: 09.03.2011, 01:22 
Offline

Joined: 08.11.2006, 03:10
Posts: 384
Location: Australia
You can use h3dSetupCameraView to set up a standard perspective matrix, or you can set the 6 properties LeftPlaneF/RightPlaneF/BottomPlaneF/TopPlaneF/NearPlaneF/FarPlaneF to set up a custom projection from the planar form. Sorry I don't have a link on converting between matrices and these planes.
It would be handy to just be able to give a float[16] to the camera though ;)


Top
 Profile  
Reply with quote  
PostPosted: 09.03.2011, 10:06 
Offline
Tool Developer

Joined: 13.11.2007, 11:07
Posts: 1150
Location: Germany
Shouldn't be too much of a problem. I already did introduce a h3dSetCameraProjMat in a project but didn't commited it, because it was a quick hack. Currently the onPostUpdate in egCamera.cpp is not implemented in a correct way. I will talk with marciano again about such a possibility.


Top
 Profile  
Reply with quote  
PostPosted: 09.03.2011, 11:17 
Offline

Joined: 08.03.2011, 18:29
Posts: 17
DarkAngel wrote:
You can use h3dSetupCameraView to set up a standard perspective matrix, or you can set the 6 properties LeftPlaneF/RightPlaneF/BottomPlaneF/TopPlaneF/NearPlaneF/FarPlaneF to set up a custom projection from the planar form. Sorry I don't have a link on converting between matrices and these planes.
It would be handy to just be able to give a float[16] to the camera though ;)


I put all those parameters onto keyboard keys to wildly fiddle around with them and I found out that changing H3DCamera::NearPlaneF can be used to warp the image into something similar to isometric projection by making it very large.

In case someone finds this via Google, look up "glFrustum" for the math behind it. It's actually quite simple.


One more question though.
Code:
LeftPlaneF   Coordinate of left plane relative to near plane center (default: -0.055228457)
RightPlaneF   Coordinate of right plane relative to near plane center (default: 0.055228457)
BottomPlaneF   Coordinate of bottom plane relative to near plane center (default: -0.041421354f)
TopPlaneF   Coordinate of top plane relative to near plane center (default: 0.041421354f)
NearPlaneF   Distance of near clipping plane (default: 0.1)
FarPlaneF   Distance of far clipping plane (default: 1000)

Where do those default values come from?


Top
 Profile  
Reply with quote  
PostPosted: 10.03.2011, 15:46 
Offline

Joined: 08.11.2010, 10:46
Posts: 35
polygoff wrote:
One more question though.
Code:
LeftPlaneF Coordinate of left plane relative to near plane center (default: -0.055228457)
RightPlaneF Coordinate of right plane relative to near plane center (default: 0.055228457)
BottomPlaneF Coordinate of bottom plane relative to near plane center (default: -0.041421354f)
TopPlaneF Coordinate of top plane relative to near plane center (default: 0.041421354f)
NearPlaneF Distance of near clipping plane (default: 0.1)
FarPlaneF Distance of far clipping plane (default: 1000)

Where do those default values come from?

From here...
Code:
void CameraNode::setupViewParams( float fov, float aspect, float nearPlane, float farPlane )
{
   float ymax = nearPlane * tanf( degToRad( fov / 2 ) );
   float xmax = ymax * aspect;

   _frustLeft = -xmax;
   _frustRight = xmax;
   _frustBottom = -ymax;
   _frustTop = ymax;
   _frustNear = nearPlane;
   _frustFar = farPlane;
   
   markDirty();
}


It's just a standard formula if you look it up on the net..


Top
 Profile  
Reply with quote  
PostPosted: 10.03.2011, 22:19 
Offline
Engine Developer

Joined: 10.09.2006, 15:52
Posts: 1217
DarkAngel wrote:
You can use h3dSetupCameraView to set up a standard perspective matrix, or you can set the 6 properties LeftPlaneF/RightPlaneF/BottomPlaneF/TopPlaneF/NearPlaneF/FarPlaneF to set up a custom projection from the planar form. Sorry I don't have a link on converting between matrices and these planes.
It would be handy to just be able to give a float[16] to the camera though ;)

We were thinking about this but the downside is that this breaks the graphics API agnostic interface to some degree. D3D and GL have slightly different projection matrices, they are transposed and GL maps z to [-1,1] while D3D maps it to [0,1]. It could be done though if it is explicitly stated that it is the user's responsibility to provide the appropriate matrix.


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 6 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group