On 12/9/2010 9:35 AM, Igor Galochkin wrote:
Thanks for help!
I am setting the focal lense x and y with the following calls now and it seems
to work fine:
double fovy = 2 * atan(this->_height / 2.0 / dFocalLengthY);
double aspectRatio = this->_nWidth / this->_nHeight * dFocalLengthY /
dFocalLengthX;
double zNear = 0.1, zFar = 100.0;
_viewer.getCamera()->setProjectionMatrix(::osg::Matrix::perspective(fovy,
aspectRatio, zNear, zFar));
You can search the archives for focal length to see some previous discussion.
Focal length alone doesn't determine field of view. Focal length together with
aperture control the field of view (at least, that's the way it works with
telescopes and binoculars).
But i still can't set up the position and rotation of the viewer's camera.
this->_viewer.getCamera()->setReferenceFrame(::osg::Transform::ABSOLUTE_RF);
this->_viewer.getCamera()->setViewMatrix(::osg::Matrix::translate(0.5, 0.3,
0.1));
this does nothing.
Is it possible that you have a camera manipulator that is overwriting your view
matrix?
It looks like viewer needs a camera manipulator or it won't render the scene.
That's incorrect. If you don't attach a camera manipulator, and you set the view
matrix as above, and you unroll the render loop like so:
while( !viewer.done() )
viewer.frame();
...then OSG will render your scene with the view matrix that you specify.
Or can i avoid creating a camera manipulator?
The programmer's answer: You have the source code. If you are getting a camera
manipulator that you didn't create, set a breakpoint in its constructor and
check the call stack to see why OSG is creating it for you.
The short answer: Don't call viewer.run(), because it will create a camera
manipulator for you if you haven't set one. Instead, use the unrolled render loop.
-Paul
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org