|
我是一个vr开发人员,希望能帮我解答。
我用mfc编程在窗口里加载一个ive模型,我想用我自己已经求出来的p阵(计算机视觉中的方法)来画模型,在opengl中我用
glmatrixmode(GL_MODELVIEW);
glloadmatrix(P);
draw();//画模型
的方法,我想用osg来实现上面opengl的步骤如下,
m_Viewer=new osgViewer::Viewer;
......
osg::ref_ptr<osg::Camera> camera=new osg::Camera;
camera->setGraphicsContext(gc.get());
camera->setViewport(new osg::Viewport(traits->x,traits->y,traits->width,traits->height));
camera->setProjectionMatrixAsOrtho(0.0f,474.0f,0.0f,294.0f,-400.0f,400.0f);
osg::Matrixd ma;
ma.set(785.746/240.0,-73.6669/240.0,-69.8510/240.0,3425.90,236.033/240.0,410.723/240.0,-742.282/240.0,1323.26,0,0,1,0,0.514208/240.0,0.825432/240.0,-0.232922/240.0,14.3600);
//这里是我前面说的已知P阵
camera->setProjectionMatrix(ma);//关键是这里我不清楚这么写对么?我发现和我想要的结果不一样,还是应该写下面的setViewMatrix?或是语句位置不正确?
//m_Viewer->getCamera()->setViewMatrix(ma);
m_Viewer->setThreadingModel(osgViewer::Viewer::SingleThreaded);
m_Viewer->setCamera( camera.get() );
m_Viewer->setCameraManipulator(new osgGA::TrackballManipulator);
......读模型显示
谢谢赐教,万分感谢! |
|