Hi Andrew,

You will need a separate camera for just rendering the 3D Axis. And implement a 
update callback for the camera.

Something like this:


Code:
class AxisCameraUpdateCallback:public osg::NodeCallback
{
public:
   /** Callback method called by the NodeVisitor when visiting a node.*/
    virtual void operator()(osg::Node* node, osg::NodeVisitor* nv)
    { 
        if(nv->getVisitorType() == osg::NodeVisitor::UPDATE_VISITOR)
        {
            osg::Camera* camera = dynamic_cast<osg::Camera*>(node);
            if(camera && camera->getView()->getNumSlaves() > 0)
            {
                osg::View::Slave* slave = &camera->getView()->getSlave(0);
                if(slave->_camera.get() == camera)
                {
                    osg::Camera* masterCam = camera->getView()->getCamera();
                    osg::Vec3 eye, center, up;
                    masterCam->getViewMatrixAsLookAt(eye, center, up, 30);
                    osg::Matrixd matrix;
                    matrix.makeLookAt(eye-center, osg::Vec3(0, 0, 0), up); // 
always look at (0, 0, 0)
                    camera->setViewMatrix(matrix);
                }
            }
        }

        // note, callback is responsible for scenegraph traversal so
        // they must call traverse(node,nv) to ensure that the
        // scene graph subtree (and associated callbacks) are traversed.
        traverse(node,nv);
    }
};





Code:
m_Camera->setUpdateCallback(new AxisCameraUpdateCallback); // setup update 
callback, so we can update it's view matrix


Cheers,
Jimmy

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





_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to