00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef SG_SCALE_TRANSFORM_HXX
00023 #define SG_SCALE_TRANSFORM_HXX
00024
00025 #include <osg/Transform>
00026 #include <simgear/math/SGMath.hxx>
00027
00028 class SGScaleTransform : public osg::Transform {
00029 public:
00030 SGScaleTransform();
00031 SGScaleTransform(const SGScaleTransform&,
00032 const osg::CopyOp& copyop = osg::CopyOp::SHALLOW_COPY);
00033
00034 META_Node(simgear, SGScaleTransform);
00035
00036 void setCenter(const SGVec3f& center)
00037 { setCenter(toVec3d(center)); }
00038 void setCenter(const SGVec3d& center)
00039 { _center = center; dirtyBound(); }
00040 const SGVec3d& getCenter() const
00041 { return _center; }
00042
00043 void setScaleFactor(const SGVec3d& scaleFactor)
00044 {
00045 double boundScale = normI(scaleFactor);
00046 if (_boundScale < boundScale || 5*boundScale < _boundScale) {
00047 _boundScale = boundScale;
00048 dirtyBound();
00049 }
00050 _scaleFactor = scaleFactor;
00051 }
00052 void setScaleFactor(double scaleFactor)
00053 {
00054 double boundScale = fabs(scaleFactor);
00055 if (_boundScale < boundScale || 5*boundScale < _boundScale) {
00056 _boundScale = boundScale;
00057 dirtyBound();
00058 }
00059 _scaleFactor = SGVec3d(scaleFactor, scaleFactor, scaleFactor);
00060 }
00061 const SGVec3d& getScaleFactor() const
00062 { return _scaleFactor; }
00063
00064
00065 virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,
00066 osg::NodeVisitor* nv) const;
00067 virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,
00068 osg::NodeVisitor* nv) const;
00069 virtual osg::BoundingSphere computeBound() const;
00070
00071 private:
00072 SGVec3d _center;
00073 SGVec3d _scaleFactor;
00074 mutable double _boundScale;
00075 };
00076
00077 #endif