[osg-users] scene snapshot

Gianni Ambrosio g.ambrosio+osg at gmail.com
Wed Aug 30 02:57:59 PDT 2017


Hi Nick,
I'm not sure my scenario is like mine but hope this code snippet may help:


Code:

void setViewTowardsXMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsXPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(-nodeTrackerManipulator->getDistance(), 0.0, 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsYPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, -nodeTrackerManipulator->getDistance(), 0.0)), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZMinus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3d(0.0, 0.0, nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

void setViewTowardsZPlus()
{
   nodeTrackerManipulator->setTransformation(computeEye(osg::Vec3(0.0f, 0.0f, -nodeTrackerManipulator->getDistance())), osg::Vec3d(0.0, 0.0, 0.0), nodeTrackerManipulator->getHomeUpPosition());
}

osg::Vec3d computeEye(const osg::Vec3d& iEye)
{
   osg::Vec3d eye = iEye;
   ...
   double psi, theta, phi;
   graphicObject->getInitialRotation(psi, theta, phi);
   osg::Quat initAttitude = viosg::quatFromBody313(psi, theta, phi);
   eye = initAttitude * graphicObject->getTransformNode()->getAttitude() * eye;
   return eye;
}




Cheers,
Gianni

------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=71564#71564







More information about the osg-users mailing list