Horde3D http://horde3d.org/forums/ |
|
Changing the projection matrix http://horde3d.org/forums/viewtopic.php?f=2&t=1443 |
Page 1 of 1 |
Author: | polygoff [ 08.03.2011, 18:51 ] |
Post subject: | Changing the projection matrix |
I'm making a game utilizing isometric projection. 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: 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? |
Author: | DarkAngel [ 09.03.2011, 01:22 ] |
Post subject: | Re: Changing the projection matrix |
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 |
Author: | Volker [ 09.03.2011, 10:06 ] |
Post subject: | Re: Changing the projection matrix |
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. |
Author: | polygoff [ 09.03.2011, 11:17 ] |
Post subject: | Re: Changing the projection matrix |
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? |
Author: | vikingcode [ 10.03.2011, 15:46 ] |
Post subject: | Re: Changing the projection matrix |
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.. |
Author: | marciano [ 10.03.2011, 22:19 ] |
Post subject: | Re: Changing the projection matrix |
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. |
Page 1 of 1 | All times are UTC + 1 hour |
Powered by phpBB® Forum Software © phpBB Group https://www.phpbb.com/ |