1 // Copyright (C) 2008 - 2009 Mathias Froehlich - Mathias.Froehlich@web.de
3 // This library is free software; you can redistribute it and/or
4 // modify it under the terms of the GNU Library General Public
5 // License as published by the Free Software Foundation; either
6 // version 2 of the License, or (at your option) any later version.
8 // This library is distributed in the hope that it will be useful,
9 // but WITHOUT ANY WARRANTY; without even the implied warranty of
10 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 // Library General Public License for more details.
13 // You should have received a copy of the GNU General Public License
14 // along with this program; if not, write to the Free Software
15 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 #ifndef BVHTransform_hxx
19 #define BVHTransform_hxx
21 #include "BVHGroup.hxx"
25 class BVHTransform : public BVHGroup {
28 virtual ~BVHTransform();
30 virtual void accept(BVHVisitor& visitor);
32 void setTransform(const BVHTransform& transform);
34 void setToWorldTransform(const SGMatrixd& transform);
35 const SGMatrixd& getToWorldTransform() const
38 void setToLocalTransform(const SGMatrixd& transform);
39 const SGMatrixd& getToLocalTransform() const
42 SGVec3d ptToWorld(const SGVec3d& point) const
43 { return _toWorld.xformPt(point); }
44 SGVec3d ptToLocal(const SGVec3d& point) const
45 { return _toLocal.xformPt(point); }
47 SGVec3d vecToWorld(const SGVec3d& vec) const
48 { return _toWorld.xformVec(vec); }
49 SGVec3d vecToLocal(const SGVec3d& vec) const
50 { return _toLocal.xformVec(vec); }
52 SGLineSegmentd lineSegmentToWorld(const SGLineSegmentd& lineSeg) const
53 { return lineSeg.transform(_toWorld); }
54 SGLineSegmentd lineSegmentToLocal(const SGLineSegmentd& lineSeg) const
55 { return lineSeg.transform(_toLocal); }
57 SGSphered sphereToWorld(const SGSphered& sphere) const
59 SGVec3d center = ptToWorld(sphere.getCenter());
60 double radius = _toWorldAmplification*sphere.getRadius();
61 return SGSphered(center, radius);
63 SGSphered sphereToLocal(const SGSphered& sphere) const
65 SGVec3d center = ptToLocal(sphere.getCenter());
66 double radius = _toLocalAmplification*sphere.getRadius();
67 return SGSphered(center, radius);
71 virtual SGSphered computeBoundingSphere() const;
72 void updateAmplificationFactors();
76 double _toWorldAmplification;
77 double _toLocalAmplification;