|
发表于 2011-6-15 17:12:07
|
显示全部楼层
唉,真不容易,参照
http://bbs.osgchina.org/viewthread.php?tid=5595
中wanghuisoftware的方法实现了,不知道楼主要的是不是这个
osg::Matrixd d ;
osg::BoundingSphere bs = m_prtCurNode->getBound();
switch (direction)
{
case MODEL_DIRECTION_TOP:
d.makeLookAt(bs._center+osg::Vec3( 0.0,0.0f,3.5f * bs._radius),bs._center,osg::Vec3(0.0f,1.0f,0.0f));
break;
case MODEL_DIRECTION_BOTTOM:
d.makeLookAt(bs._center-osg::Vec3( 0.0,0.0f,3.5f * bs._radius),bs._center,osg::Vec3(0.0f,1.0f,0.0f));
break;
case MODEL_DIRECTION_FRONT:
d.makeLookAt(bs._center-osg::Vec3( 0.0,3.5f * bs._radius,0.0f),bs._center,osg::Vec3(0.0f,1.0f,1.0f));
break;
case MODEL_DIRECTION_BACK:
d.makeLookAt(bs._center+osg::Vec3( 0.0,3.5f * bs._radius,0.0f),bs._center,osg::Vec3(0.0f,1.0f,1.0f));
break;
case MODEL_DIRECTION_LEFT:
d.makeLookAt(bs._center-osg::Vec3( 3.5f * bs._radius,0.0,0.0f),bs._center,osg::Vec3(0.0f,0.0f,1.0f));
break;
case MODEL_DIRECTION_RIGHT:
d.makeLookAt(bs._center+osg::Vec3( 3.5f * bs._radius,0.0,0.0f),bs._center,osg::Vec3(0.0f,0.0f,1.0f));
break;
}
GetViewer()->getCameraManipulator()->setByInverseMatrix(d); |
|