|
楼主 |
发表于 2013-4-4 09:32:52
|
显示全部楼层
本帖最后由 tiantangtl 于 2013-4-4 09:33 编辑
Mooneast 发表于 2013-4-3 17:01
应该是你的方向设置的有问题吧 楼主可以把代码发上来瞧瞧 - osg::ref_ptr<osgViewer::Viewer> viewer=new osgViewer::Viewer;
- osg::ref_ptr<osg::Group> root=new osg::Group;
- osg::ref_ptr<osg::Node> cow=osgDB::readNodeFile("cow.osg");
- root->addChild(cow.get());
-
- osg::ref_ptr<osg::Camera> HUDCamera=new osg::Camera;
- HUDCamera=new osg::Camera;
- HUDCamera->setProjectionResizePolicy(osg::Camera::FIXED);
- HUDCamera->setProjectionMatrix(osg::Matrix::ortho2D(0.0,1280,0.0,1024));
- HUDCamera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
- HUDCamera->setClearMask(GL_DEPTH_BUFFER_BIT);
- HUDCamera->setRenderOrder(osg::Camera::POST_RENDER);
- osg::ref_ptr<osg::Switch> modelroot=new osg::Switch;
- osg::ref_ptr<osg::Geode> gnode=new osg::Geode;
- osg::ref_ptr<osg::Cylinder> cy=new osg::Cylinder;
- osg::ref_ptr<osg::ShapeDrawable> cysd=new osg::ShapeDrawable(cy.get());
- cysd->setColor(osg::Vec4(1.0,0.0,0.0,1.0));
- gnode->addDrawable(cysd.get());;
- osg::ref_ptr<osg::MatrixTransform> btn1=new osg::MatrixTransform;
- btn1->addChild(gnode.get());
- osg::Matrix btnTrans,btnRotate,btnScale;
- btnTrans.makeTranslate(100,100,-100);
- btnRotate=osg::Matrix::rotate(osg::inDegrees(45.0),osg::X_AXIS)*osg::Matrix::rotate(osg::inDegrees(45.0),osg::Z_AXIS);
- btnScale.makeScale(osg::Vec3(50.0,50.0,50.0));
- btn1->setMatrix(btnScale*btnRotate*btnTrans);
- modelroot->addChild(btn1.get());
- HUDCamera->addChild(modelroot.get());
- root->addChild(HUDCamera.get());
- viewer->addEventHandler(new osgViewer::WindowSizeHandler);
- viewer->setSceneData(root.get());
- viewer->realize();
- return viewer->run();
复制代码 |
|