00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef BVHTransform_hxx
00019 #define BVHTransform_hxx
00020
00021 #include "BVHGroup.hxx"
00022
00023 namespace simgear {
00024
00025 class BVHTransform : public BVHGroup {
00026 public:
00027 BVHTransform();
00028 virtual ~BVHTransform();
00029
00030 virtual void accept(BVHVisitor& visitor);
00031
00032 void setTransform(const BVHTransform& transform);
00033
00034 void setToWorldTransform(const SGMatrixd& transform);
00035 const SGMatrixd& getToWorldTransform() const
00036 { return _toWorld; }
00037
00038 void setToLocalTransform(const SGMatrixd& transform);
00039 const SGMatrixd& getToLocalTransform() const
00040 { return _toLocal; }
00041
00042 SGVec3d ptToWorld(const SGVec3d& point) const
00043 { return _toWorld.xformPt(point); }
00044 SGVec3d ptToLocal(const SGVec3d& point) const
00045 { return _toLocal.xformPt(point); }
00046
00047 SGVec3d vecToWorld(const SGVec3d& vec) const
00048 { return _toWorld.xformVec(vec); }
00049 SGVec3d vecToLocal(const SGVec3d& vec) const
00050 { return _toLocal.xformVec(vec); }
00051
00052 SGLineSegmentd lineSegmentToWorld(const SGLineSegmentd& lineSeg) const
00053 { return lineSeg.transform(_toWorld); }
00054 SGLineSegmentd lineSegmentToLocal(const SGLineSegmentd& lineSeg) const
00055 { return lineSeg.transform(_toLocal); }
00056
00057 SGSphered sphereToWorld(const SGSphered& sphere) const
00058 {
00059 SGVec3d center = ptToWorld(sphere.getCenter());
00060 double radius = _toWorldAmplification*sphere.getRadius();
00061 return SGSphered(center, radius);
00062 }
00063 SGSphered sphereToLocal(const SGSphered& sphere) const
00064 {
00065 SGVec3d center = ptToLocal(sphere.getCenter());
00066 double radius = _toLocalAmplification*sphere.getRadius();
00067 return SGSphered(center, radius);
00068 }
00069
00070 private:
00071 virtual SGSphered computeBoundingSphere() const;
00072 void updateAmplificationFactors();
00073
00074 SGMatrixd _toWorld;
00075 SGMatrixd _toLocal;
00076 double _toWorldAmplification;
00077 double _toLocalAmplification;
00078 };
00079
00080 }
00081
00082 #endif