|
HUD实现:- osg::ref_ptr<osg::Node> EditIntersectionCommand::getHUDCamera(const osg::ref_ptr<osg::Node>& aNode)
- {
- osg::BoundingSphere sphere = aNode->getBound();
- osg::Vec3d sphereCenter = sphere.center();
- double radius = sphere.radius();
- osg::Camera* camera = new osg::Camera;
- double left = sphereCenter.x() - radius;
- double right = sphereCenter.x() + radius;
- double bottom = sphereCenter.y() - radius;
- double top = sphereCenter.y() + radius;
- //设置透视矩阵
- camera->setProjectionMatrixAsOrtho2D(left, right, bottom, top);
- camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
- //得到默认设置
- camera->setViewMatrix(osg::Matrix::identity());
- //设置背景为透明,否则的话可以设置ClearColor
- camera->setClearMask(GL_DEPTH_BUFFER_BIT);
- //设置渲染顺序,必须在最后渲染
- camera->setRenderOrder(osg::Camera::POST_RENDER);
- camera->addChild(aNode);
- camera->getStateSet()->setMode(GL_LIGHTING, osg::StateAttribute::OFF);
- return camera;
- }
复制代码 但如果Node内的Geometry Z值设为大于零的数,显示不出来,<=0都可以显示出来!跪求解答啊!!!! |
|