Hello,

 

I came back with this problem of first/third view person.

Paul, following is what I did, and it doesn't give me what I was expecting.

So, can you be more precise regarding "the inverse of the cow's
transformation"?

 

cViewer = new osgViewer::CompositeViewer();

      

osg::ref_ptr<osg::Group> root = new osg::Group;

root->addChild(makeFrustumFromCamera(NULL));

 

root->addChild(mscene->getScene());

// Create View 0 -- Just the loaded model.

{

      osg::ref_ptr<osgViewer::View> view = new osgViewer::View;

cViewer->addView(view.get());

 

      view->setUpViewInWindow(10, 10, 640, 480);

      view->setSceneData(_root.get());

      view->setCameraManipulator(new osgGA::TrackballManipulator);

            

      /*******************/

      //take the inverse of the model's transformation and set it as the
view matrix to see what the model see

      osg::Matrixd proj =
cViewer->getView(0)->getCamera()->getProjectionMatrix();

      osg::Matrixd mv = cViewer->getView(0)->getCamera()->getViewMatrix();

 

      osg::MatrixTransform* mt = new osg::MatrixTransform;

      mt->setMatrix(osg::Matrixd::inverse(mv));

      view->setSceneData(mt);

//this step inverts the wireframe on the view 1!

}

       

// Create view 1 -- Contains the loaded moel, as well as a wireframe frustum
derived from View 0's Camera.

{

osg::ref_ptr<osgViewer::View> view = new osgViewer::View;

      cViewer->addView(view.get());

 

      view->setUpViewInWindow(10, 510, 640, 480);

      view->setSceneData(root.get());

      view->setCameraManipulator(new osgGA::TrackballManipulator);

}

      

// Update the wireframe frustum, we need to find a way to adapt the
mainwindow and not create other instance

while (!cViewer->done()){

root->removeChild(0, 1);

      root->insertChild(0,
makeFrustumFromCamera(cViewer->getView(0)->getCamera()));

 

      cViewer->frame();

}

 

I want to see what the cow see in the view 0.

The view 1 contains a wireframe which starts on the eyes of the model and
shows us the view 0 (view 1 = the third view person)

 

So, from the view 0, I can see the scene (since the eye of the model) but
not the model (view 0 = the first view person).

 

Thanks in advance for your help.

 

Jon 

 

 


  _____  


For a view of what the cow is seeing, take the inverse of the cow's
transformation and set it as the view matrix.

 

Hope that helps,

   -Paul

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

Reply via email to