Page 1 of 1

Perspective zooming problem

Posted: Fri Feb 04, 2011 3:19 pm
by Amaroker
Hello,

I'm trying to export a 3D scene from a non-Irrlicht program where zooming is performed by changing view width and height (model units). So, I export the position of camera & target, view width & height and near & far values and import into my own program built with Irrlicht.

So in Irrlicht I call buildProjectionMatrixPerspectiveLH where I need to multiply the first parameters (view height and width) with a zoom factor (my camera zooms by changing the field of view, so that's my zoom factor).

The problem is, how can I calculate the equivalent zoom factor? I want the objects in the scene to be rendered as they were in the original program. Well, it's pointing in the right direction but I need to make it zoom properly.

The difference I see is that when the near clipping plane distance is adjusted in the original program it doesn't affect the zoom (rendering using gluPerspective), but in Irrlicht there are visible zoom changes if I modify the near value. It seems like the behaviour of glFrustum, but I can't find glFrustum in Irrlicht source code. Same with gluPerspective. (Maybe someone can explain how perspective works in Irrlicht OpenGL driver? Which part of the source code?).

Any ideas? Thanks for reading...

Posted: Fri Feb 04, 2011 4:29 pm
by hybrid
We simply build the projection matrix on our own. The values are very similar to glFrustum, though.

Posted: Fri Feb 04, 2011 11:23 pm
by Mel
(my camera zooms by changing the field of view, so that's my zoom factor).
Use the FOV setting method of the ICameraSceneNode.

Posted: Mon Feb 07, 2011 2:03 pm
by Amaroker
OK, thanks hybrid. I compared the irrlicht projection matrix with the matrix created by glFrustum and found the difference. Problem solved now.