Discussion:
ModelView/Projection Matrices From Camera
Jeremy Moles
2011-07-05 16:01:56 UTC
Permalink
Hey guys, I have a really quick question. I'm trying to debug a piece of
code and what I need is access to the current MV/Proj matrices as
affected by the Viewer's active camera.

I see that they can both be queried from an osg::State object, though
I've never had to interface directly with this.

Does anyone have any quick tricks?
Glenn Waldron
2011-07-05 16:10:48 UTC
Permalink
I usually pull them from the CullVisitor/CullStack during the cull
traversal.
Post by Jeremy Moles
Hey guys, I have a really quick question. I'm trying to debug a piece of
code and what I need is access to the current MV/Proj matrices as
affected by the Viewer's active camera.
I see that they can both be queried from an osg::State object, though
I've never had to interface directly with this.
Does anyone have any quick tricks?
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Paul Martz
2011-07-05 16:38:31 UTC
Permalink
I usually pull them from the CullVisitor/CullStack during the cull traversal.
Right -- During cull you can access these from the CullVisitor:
osg::RefMatrix* view = cv->getModelViewMatrix();
const osg::Camera* cam = cv->getCurrentCamera();
const osg::Matrix& proj = cam->getProjectionMatrix();
const osg::Viewport* vp = cam->getViewport();

If you're trying to get these during draw, you need to get them from osg::State:
const osg::State* state = renderInfo.getState();
const osg::Matrix& view = getModelViewMatrix();
const osg::Matrix& proj = getProjectionMatrix();
const Viewport* vp = getCurrentViewport();

-Paul
Hey guys, I have a really quick question. I'm trying to debug a piece of
code and what I need is access to the current MV/Proj matrices as
affected by the Viewer's active camera.
I see that they can both be queried from an osg::State object, though
I've never had to interface directly with this.
Does anyone have any quick tricks?
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
--
-Paul Martz Skew Matrix Software
http://www.skew-matrix.com/
Jeremy Moles
2011-07-05 19:19:07 UTC
Permalink
Post by Paul Martz
I usually pull them from the CullVisitor/CullStack during the cull traversal.
osg::RefMatrix* view = cv->getModelViewMatrix();
const osg::Camera* cam = cv->getCurrentCamera();
const osg::Matrix& proj = cam->getProjectionMatrix();
const osg::Viewport* vp = cam->getViewport();
const osg::State* state = renderInfo.getState();
const osg::Matrix& view = getModelViewMatrix();
const osg::Matrix& proj = getProjectionMatrix();
const Viewport* vp = getCurrentViewport();
-Paul
Thanks Paul and Glenn. I have a cool example coming demonstrating Signed
Distance Field rendering, particularly as it pertains to text (inspired
by an e-mail from a fellow named John Smith. It's exceptionally cool
stuff, I'm just having trouble understanding the relationship between
the current ViewMatrix and and the algorithm's idea of "scale."

I get decent results with a 1:1 ratio, but there's more to it than that.
Much reading shall take place!
Post by Paul Martz
Hey guys, I have a really quick question. I'm trying to debug a piece of
code and what I need is access to the current MV/Proj matrices as
affected by the Viewer's active camera.
I see that they can both be queried from an osg::State object, though
I've never had to interface directly with this.
Does anyone have any quick tricks?
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
Loading...