Discussion:
camera standard frustum
Martin
2009-03-09 11:47:46 UTC
Permalink
Hello,

when i create a camera:

osg::ref_ptr< osg::Camera> cam = new osg::Camera();

and I want to get the frustum parameters:

cam->getProjectionMatrixAsFrustum(left,right,bottom,top,znear,zfar);

I dont't get the parameters. It seems that the camera hasn't a projection matrix. Where is the projection matrix define in this situation? When I set my own projection matrix with setProjectionMatrix( ... ) it works fine.

Cheers,

Martin

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8087#8087
Robert Osfield
2009-03-09 12:04:12 UTC
Permalink
Hi Marttin,

osg::Camera always has a projection and view matrix, you can't
disable/remove them.

osg::Camera stores the projection matrix as a 4x4 matrix, which you
can get using Camera::getProjectionMatrix().

When you set the projection matrix using
setProjectionMatrixAsFrustum(...) it does the equivalent of glFrustum,
setting the 4x4 matrix appropriately. The left, right etc parameters
aren't ever stored, it's only the 4x4 matrix. When you do
Camera::getProjectMatrixAsFrusutm(..) it recovers the left, right etc
values from the 4x4 matrix.

As to what might be wrong in your case, we'll it's very likely that
the OSG itself is doing anything wrong as these methods are commonly
used and tested, more likely is that you own expectation are
mismismatched with what is actually happening. You don't say anything
about the wider context of your camera use, or why you think the
values are correct so I can't speculate what the actual problems might
be.

Robert.
Post by Martin
Hello,
osg::ref_ptr< osg::Camera> cam = new osg::Camera();
cam->getProjectionMatrixAsFrustum(left,right,bottom,top,znear,zfar);
I dont't get the parameters. It seems that the camera hasn't a projection matrix. Where is the projection matrix define in this situation? When I set my own projection matrix with setProjectionMatrix( ... ) it works fine.
Cheers,
Martin
------------------
http://forum.openscenegraph.org/viewtopic.php?p=8087#8087
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Martin
2009-03-09 12:06:08 UTC
Permalink
Hello,

I think it works now. It was my mistake. But the near plane is very small. Is it normal?

Thanks

Martin
Post by Martin
Hello,
osg::ref_ptr< osg::Camera> cam = new osg::Camera();
cam->getProjectionMatrixAsFrustum(left,right,bottom,top,znear,zfar);
I dont't get the parameters. It seems that the camera hasn't a projection matrix. Where is the projection matrix define in this situation? When I set my own projection matrix with setProjectionMatrix( ... ) it works fine.
Cheers,
Martin
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8088#8088
Robert Osfield
2009-03-09 12:56:54 UTC
Permalink
Post by Martin
Hello,
I think it works now. It was my mistake. But the near plane is very small. Is it normal?
By default the OSG will compute the near + far planes, during the cull
traversal, to fit the depth range of the objects in the view frustum,
so if your model is small and objects near to you then the near plane
can be quite small. You can disable this update of the nar/far by
doing:

camera->setComputeNearFarMode(osg::CullSettings::DO_NOT_COMPUTE_NEAR_FAR);

Robert.
Tomlinson, Gordon
2009-03-09 13:52:21 UTC
Permalink
Typically it can be yes,

Search the archives/FAQs/ on small feature culling as well, as by
default OSG automatically adjust the near and far plans , you may want
to turn this off , that is if you want to controll the near and far
plans


Gordon
Product Manager 3d
__________________________________________________________
Gordon Tomlinson
Email : gtomlinson @ overwatch.textron.com
__________________________________________________________
(C): (+1) 571-265-2612
(W): (+1) 703-437-7651

"Self defence is not a function of learning tricks
but is a function of how quickly and intensely one
can arouse one's instinct for survival"
- Master Tambo Tetsura

-----Original Message-----
From: osg-users-bounces-***@public.gmane.org
[mailto:osg-users-bounces-***@public.gmane.org] On Behalf Of Martin
Sent: Monday, March 09, 2009 8:06 AM
To: osg-users-***@public.gmane.org
Subject: Re: [osg-users] camera standard frustum

Hello,

I think it works now. It was my mistake. But the near plane is very
small. Is it normal?

Thanks

Martin
Post by Martin
Hello,
osg::ref_ptr< osg::Camera> cam = new osg::Camera();
cam->getProjectionMatrixAsFrustum(left,right,bottom,top,znear,zfar);
I dont't get the parameters. It seems that the camera hasn't a
projection matrix. Where is the projection matrix define in this
situation? When I set my own projection matrix with setProjectionMatrix(
... ) it works fine.
Post by Martin
Cheers,
Martin
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=8088#8088

Loading...