3 * Copyright (C) 2006-2007 Mathias Froehlich
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of the
8 * License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
22 #ifndef SG_SCALE_TRANSFORM_HXX
23 #define SG_SCALE_TRANSFORM_HXX
25 #include <osg/Transform>
26 #include <simgear/math/SGMath.hxx>
28 class SGScaleTransform : public osg::Transform {
32 void setCenter(const SGVec3f& center)
33 { setCenter(toVec3d(center)); }
34 void setCenter(const SGVec3d& center)
35 { _center = center; dirtyBound(); }
36 const SGVec3d& getCenter() const
39 void setScaleFactor(const SGVec3d& scaleFactor)
41 double boundScale = normI(scaleFactor);
42 if (_boundScale < boundScale || 5*boundScale < _boundScale) {
43 _boundScale = boundScale;
46 _scaleFactor = scaleFactor;
48 void setScaleFactor(double scaleFactor)
50 double boundScale = fabs(scaleFactor);
51 if (_boundScale < boundScale || 5*boundScale < _boundScale) {
52 _boundScale = boundScale;
55 _scaleFactor = SGVec3d(scaleFactor, scaleFactor, scaleFactor);
57 const SGVec3d& getScaleFactor() const
58 { return _scaleFactor; }
61 virtual bool computeLocalToWorldMatrix(osg::Matrix& matrix,
62 osg::NodeVisitor* nv) const;
63 virtual bool computeWorldToLocalMatrix(osg::Matrix& matrix,
64 osg::NodeVisitor* nv) const;
65 virtual osg::BoundingSphere computeBound() const;
70 mutable double _boundScale;