|
发表于 2008-12-31 15:53:33
|
显示全部楼层
您可以看下这段,是osgEphemeris里面的
class MoveWithEyePointTransform : public osg::Transform
{
public:
MoveWithEyePointTransform():_enabled(true) {}
void setCenter( osg::Vec3 center ) { _center = center; }
void enable() { _enabled = true; }
void disable() { _enabled = false; }
bool isEnabled() const { return _enabled; }
virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,osg::NodeVisitor* nv) const
{
if( _enabled )
{
osgUtil::CullVisitor* cv = dynamic_cast<osgUtil::CullVisitor*>(nv);
if (cv)
{
osg::Vec3 eyePointLocal = cv->getEyeLocal();
matrix.preMult(osg::Matrix::translate(
osg::Vec3( eyePointLocal.x(),eyePointLocal.y(),0.0f) - _center));
}
}
return true;
}
private:
bool _enabled;
osg::Vec3 _center;
}; |
|