|
楼主 |
发表于 2010-10-6 09:46:31
|
显示全部楼层
谢谢了!
我的HUD也是这样写的,但是总是覆盖写的四边形,是不是我的四边形写的不是地方啊?下面是我的HUD和main函数的一部分,你看有怎么修改。
osg::ref_ptr<osg::Camera> createHUDmap()
{
osg::ref_ptr<osg::Camera> camera = new osg::Camera() ;
//设置投影矩阵
camera->setProjectionMatrix(osg::Matrix:rtho2D(0,1440,0,900));
//设置视图矩阵,同时确保不被场景中其他图形位置变换影响,使用绝对帧引用
camera->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
camera->setViewMatrix(osg::Matrix::identity());
//清除深度缓存
camera->setClearMask(GL_DEPTH_BUFFER_BIT);
//设置渲染顺序为POST
camera->setRenderOrder(osg::Camera:OST_RENDER);
//设置为不接收事件,始终不得到焦点
camera->setAllowEventFocus(false);
osg::ref_ptr<osg::Geode> geode = new osg::Geode() ;
osg::ref_ptr<osg::StateSet> stateset = geode->getOrCreateStateSet() ;
//关闭光照
stateset->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
//关闭深度测试
stateset->setMode(GL_DEPTH_TEST,osg::StateAttribute::OFF);
osg::ref_ptr<osg:rawPixels> bitmap=new osg::DrawPixels;
bitmap->setPosition(osg::Vec3(0,0,0));
bitmap->setImage(osgDB::readImageFile("fangzi.png"));
geode->addDrawable(bitmap.get());
camera->addChild(geode.get());
return camera.get() ;
}
四边形函数是createfour();
main函数为
………………
viewer->addView(view.get());
view->getCamera()->setViewport( new osg::Viewport(0,0,600,600));
view->getCamera()->setGraphicsContext(gc.get());
osg::ref_ptr<osg::Group> root = new osg::Group;
root->addChild(createHUDmap());
root->addChild(createfour());
view->setSceneData(root.get());
……………… |
|