|
大家好,最近发现updateCalculatedNearFar 在osg:: Projection下似乎有点问题,整个场景里只有一个物体,却被cull掉了。
我在osg:: Projection下加了一个ShapeDrawable,当ShapeDrawable的坐标是负值时, 物体可以显示出来。为正值时显示不出来,但是如果坐标值减去球的半径小于0,也可以显示出来,如
osg::Vec3 position(0.1,0.1,0.1);
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(position,0.1)));
可以显示出来
完整的代码如下,坐标值减去半径值大于0,什么也显示不出来,调试发现updateCalculatedNearFar 时物体被cull掉了。
osg::Node* createScene()
{
osg::Geode* geode=new osg::Geode;
osg::Vec3 position(0.2,0.2,0.2);
geode->addDrawable(new osg::ShapeDrawable(new osg::Sphere(position,0.1)));
osg:: PositionAttitudeTransform * tran = new osg:: PositionAttitudeTransform;
tran->setReferenceFrame(osg::Transform::ABSOLUTE_RF);
tran->setPosition(osg::Vec3(5,5,0));
tran->addChild(geode);
osg:: Projection* ProjectionMatrix = new osg:: Projection;
ProjectionMatrix->setMatrix(osg::Matrix:: ortho2D(0,10,0,10));
ProjectionMatrix->addChild(tran);
return ProjectionMatrix;
}
int _tmain(int argc, _TCHAR* argv[])
{
osgViewer::Viewer viewer;
viewer.setSceneData(createScene());
return viewer.run();
}
我怎样才能把物体显示出来呢,各位帮帮忙啊,谢了先。forest
[ 本帖最后由 array 于 2008-10-30 10:43 编辑 ] |
|