|
发表于 2014-5-13 17:35:18
|
显示全部楼层
你解决了不?我也遇到了这样的问题。
旋转轨迹球前
改变图元顶点位置,并变换轨迹球位置
- osg::ref_ptr<osg::Geode>geode=new osg::Geode;
- osg::ref_ptr<osg::Geometry>geometry=new osg::Geometry;
- _vertexArr->push_back(osg::Vec3(0.0f,0.0f,.0f));
- _vertexArr->push_back(osg::Vec3(2.0f,0.0f,.0f));
- _vertexArr->push_back(osg::Vec3(2.0f,0.0f,2.0f));
- _vertexArr->push_back(osg::Vec3(0.0f,0.0f,2.0f));
- geometry->setVertexArray(_vertexArr);
- geometry->addPrimitiveSet(new osg::DrawArrays(GL_LINE_LOOP,0,_vertexArr->size()));
- geometry->dirtyBound();
- //geometry->setDataVariance(osg::Object::DYNAMIC);
- geometry->setSupportsDisplayList(false);
- //no use at this moment;
- //geometry->setUpdateCallback(new GeometryUpdate);
- geode->addDrawable(geometry.get());
- geode->getOrCreateStateSet()->setMode(GL_LIGHTING,osg::StateAttribute::OFF);
- //set dispaly mode as line mode
- osg::ref_ptr<osg::PolygonMode> polygonMode = new osg::PolygonMode();
- polygonMode->setMode( osg::PolygonMode::FRONT_AND_BACK, osg::PolygonMode::LINE);
- geode->getOrCreateStateSet()->setAttribute( polygonMode.get(),
- osg::StateAttribute::OVERRIDE | osg::StateAttribute::ON );
- return geode;
复制代码
我在EventHandler中不端更改图元坐标的位置,然后就出现这种情况。我猜测是由于包围盒的计算问题。另外我不知道透视投影的视景体是怎么计算的,不过感觉是根据场景的包围盒进行计算得到的。然后我猜测是由于视景体范围的问题。我也不清楚。 |
|