Hi Fred, OSG does compute the correct near/far values for pre-render cameras, assuming it is enabled for it. As you can tell, the main problem is getting access to the computed projection matrix. What I have done to get the computed near/far values from camera nodes is to attach a cull callback to the camera that retrieves the computed projection matrix from the cull visitor after the camera has been traversed. The cull callback function looks something like this:
void MyCullCallback::operator()(osg::Node* node, osg::NodeVisitor* nv) { if (nv->getVisitorType() == osg::NodeVisitor::CULL_VISITOR) { osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv); if(cv) { traverse(node,nv); cv->computeNearPlane(); if (cv->getComputeNearFarMode() && cv->getCalculatedFarPlane() >= cv->getCalculatedNearPlane()) { osgUtil::CullVisitor::value_type znear = cv->getCalculatedNearPlane(); osgUtil::CullVisitor::value_type zfar = cv->getCalculatedFarPlane(); //Do something with znear/zfar values } return; } } traverse(node,nv); } This works really well for my application. I think every time I've encountered some tricky problem like this, cull callbacks were the solution. I don't know what I would do without them :) Cheers, Farshid On Mon, Jun 3, 2013 at 9:00 AM, Fred Smith <osgfo...@tevs.eu> wrote: > Robert, > > Sorry to further fill in this thread with a question - but couldn't it be > that the OSG indeed correctly calculates the near/far values for my > pre_render camera, and that I simply just do not know (yet) a proper way to > correctly retrieve the projection matrix? I see the CullVisitor calculates > the near/far values, maybe I should hook into this and grab the values from > there? > Any hint is appreciated really, and again sorry for the verbose thread. > > Cheers, > Fred > > ------------------ > Read this topic online here: > http://forum.openscenegraph.org/viewtopic.php?p=54407#54407 > > > > > > _______________________________________________ > osg-users mailing list > osg-users@lists.openscenegraph.org > http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org >
_______________________________________________ osg-users mailing list osg-users@lists.openscenegraph.org http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org