Hi!
I want to manually place the camera at a point. For that I
have written the following two functions. The second function returns
a view which is added to the viewer. But the problem is that whatever
values I fill in the osg::Matrix::translate(osg::Vec3(...)), nothing
seems to be happening. The view remains the same...
osg::MatrixTransform* setPosition(osg::Node* scene, osg::BoundingSphere* bs){
osg::MatrixTransform* mTop = new osg::MatrixTransform;
mTop->setName("Top View");
mTop->setMatrix(osg::Matrix::rotate(osg::inDegrees(90.0),osg::Vec3(1.0,0.0,0.0))
* osg::Matrix::translate(osg::Vec3(100.0, 600.0, 0.0))); /*All
changes done here*/
mTop->setMatrix(n);
mTop->addChild(scene);
return mTop;
}
osgViewer::View* createTopView(osg::Node* scene){
osgViewer::View* topView = new osgViewer::View;
osg::BoundingSphere bsh = scene->getBound();
cout << bsh.radius() << endl;
topView->getCamera()->setProjectionMatrixAsPerspective(60.0f,
(double)traits->width/(double)traits->height, 1.0, 1000.0);
topView->getCamera()->setViewport(new osg::Viewport(0, 0,
(traits->width)/5, (traits->height)/5));
topView->getCamera()->setGraphicsContext(gc.get());
topView->getCamera()->setClearColor(osg::Vec4(0.4f, 0.4f, 0.4f, 1.0f));
topView->getCamera()->setClearMask(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
topView->setSceneData(setPosition(scene, &bsh));
return topView;
}
why does it happen so? In the
NPS Tutorials, in the 10th tutorial, there was some code which helped
manually place a camera. In that tutorial, the guy has taken the
inverse of the view matrix. Why? Am I missing something?? :(
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org