|
AnimationPathManipulator 没有
/** Get the FusionDistanceMode. Used by SceneView for setting up stereo convergence.*/
virtual osgUtil::SceneView::FusionDistanceMode getFusionDistanceMode() const { return osgUtil::SceneView::USE_FUSION_DISTANCE_VALUE; }
/** Get the FusionDistanceValue. Used by SceneView for setting up stereo convergence.*/
virtual float getFusionDistanceValue() const { return _distance; }
这两个函数所以在做动画立体显示的时候总是不真实。
所以我试着重载了这个类,模仿TerrainManipulator写了setDistance这个方法。如下:
void setDistance()
{
osg::Vec3d lookVector(- matrix(2,0),-matrix(2,1),-matrix(2,2));
osg::Vec3d eye(matrix(3,0),matrix(3,1),matrix(3,2));
osg::notify(INFO)<<"eye point "<<eye<<std::endl;
osg::notify(INFO)<<"lookVector "<<lookVector<<std::endl;
if (!_node)
{
_center = eye+ lookVector;
_distance = lookVector.length();
_rotation = matrix.getRotate();
return;
}
// need to reintersect with the terrain
const osg::BoundingSphere& bs = _node->getBound();
float distance = (eye-bs.center()).length() + _node->getBound().radius();
osg::Vec3d start_segment = eye;
osg::Vec3d end_segment = eye + lookVector*distance;
osg::Vec3d ip;
bool hitFound = false;
if (intersect(start_segment, end_segment, ip))
{
notify(INFO) << "Hit terrain ok A"<< std::endl;
_center = ip;
_distance = (eye-ip).length();//设置距离
hitFound = true;
}
把这个函数放在了函数handle中的case:Frame中。
随后问题出现了,聚焦点在一个物体表面跳到另一个表面时(一个远一个近)。即distance变化很大。这样造成场景也立体效果也变化很大。请问有没有解决方案,使变化平滑一点。 |
|