|
楼主 |
发表于 2010-5-30 21:28:19
|
显示全部楼层
本帖最后由 sunpent 于 2010-5-30 21:54 编辑
为什么我改用多视景器添加第二个view,通过赋值cameraClient =view2->getCamera(),再使用HUD,设置camera的投影矩阵等等,读出来的图形却并非俯视,而是平视呢?但是通过getViewMatrixAslookat()得到的相机位置却是俯视的?!。。。很不解啊,请教下诸位,谢谢了!问题很可能就在这儿。
- osg::ref_ptr<osgViewer::View> view2= new osgViewer::View;
- viewer->addView(view2.get());
- osg::ref_ptr<osg:ositionAttitudeTransform> pat = new osg:ositionAttitudeTransform;
- pat->addChild( cow.get() );
- view2->setSceneData(pat.get());
- osg::ref_ptr<osg::Camera> cameraClient = new osg::Camera;
- cameraClient = view2->getCamera();
- //pat->setEventCallback( new MyEventCallback(cameraClient.get(),view1.get()) );
- cameraClient->setViewport(new osg::Viewport(10,10, traits->width/2, traits->height/2));
- cameraClient->setReferenceFrame( osg::Transform::ABSOLUTE_RF );
- cameraClient->setProjectionMatrixAsOrtho2D(-30,30,-30,30);
- cameraClient->
- cameraClient->setRenderOrder( osg::Camera:OST_RENDER);
- cameraClient->setClearMask( GL_DEPTH_BUFFER_BIT|GL_COLOR_BUFFER_BIT);
- osg::Vec3 _pos,_cent,_up;
- std:fstream os("eagleeye_Camera.txt");
- os<<"";
- cameraClient->getViewMatrixAsLookAt(_pos,_cent,_up);
- os<<"pos "<<_pos._v[0]<<" "<<_pos._v[1]<<" "<<_pos._v[2]<<std::endl;
- os<<"center "<<_cent._v[0]<<" "<<_cent._v[1]<<" "<<_cent._v[2]<<std::endl;
- os<<"up direction "<<_up._v[0]<<" "<<_up._v[1]<<" "<<_up._v[2]<<std::endl;
- cameraClient->setGraphicsContext(gc.get());
- view2->setCameraManipulator(new osgGA::TrackballManipulator);
复制代码 输出的文本中的信息为:
pos 0 0 0
center 0 0 -1
up direction 0 1 0
再添一句,我现在就是想得到一个俯视的相机cameraClient,在这个cameraClient下漫游器的主相机可以到达的每个点都能够在cameraClient最后显示的视口中有对应的坐标。
那么怎么修改现在cameraClient的投影矩阵呢?。。。 |
|