Skip to content

Instantly share code, notes, and snippets.

@pezy
Created July 22, 2014 08:52
Show Gist options
  • Save pezy/60daa89e811cf72552ca to your computer and use it in GitHub Desktop.
Save pezy/60daa89e811cf72552ca to your computer and use it in GitHub Desktop.
class CameraUpdateCallback : public osg::NodeCallback {
private:
osg::ref_ptr<osg::Camera> mOtherCam;
public:
CameraUpdateCallback(osg::Camera* otherCam) : mOtherCam(otherCam) { }
osg::ref_ptr<osg::Camera> m_sourceCamera;
void operator()(osg::Node* node, osg::NodeVisitor* nv) {
osg::Camera* cam = static_cast<osg::Camera*>( node );
cam->setViewMatrix(mOtherCam->getViewMatrix() );
cam->setProjectionMatrix(mOtherCam->getProjectionMatrix() );
traverse(node , nv);
}
...
camera->setUpdateCallback( new CameraUpdateCallback( currentView->getCamera() ) );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment