PositionAttitudeTransform 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. /* -*-c++-*- OpenSceneGraph - Copyright (C) 1998-2006 Robert Osfield
  2. *
  3. * This library is open source and may be redistributed and/or modified under
  4. * the terms of the OpenSceneGraph Public License (OSGPL) version 0.0 or
  5. * (at your option) any later version. The full license is in LICENSE file
  6. * included with this distribution, and on the openscenegraph.org website.
  7. *
  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
  11. * OpenSceneGraph Public License for more details.
  12. */
  13. #ifndef OSG_POSITIONATTITUDETRANSFORM
  14. #define OSG_POSITIONATTITUDETRANSFORM 1
  15. #include <osg/Group>
  16. #include <osg/Transform>
  17. #include <osg/AnimationPath>
  18. #include <osg/Vec3d>
  19. #include <osg/Quat>
  20. namespace osg {
  21. /** PositionAttitudeTransform - is a Transform. Sets the coordinate transform
  22. via a Vec3 position and Quat attitude.
  23. */
  24. class OSG_EXPORT PositionAttitudeTransform : public Transform
  25. {
  26. public :
  27. PositionAttitudeTransform();
  28. PositionAttitudeTransform(const PositionAttitudeTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY):
  29. Transform(pat,copyop),
  30. _position(pat._position),
  31. _attitude(pat._attitude),
  32. _scale(pat._scale),
  33. _pivotPoint(pat._pivotPoint) {}
  34. META_Node(osg, PositionAttitudeTransform);
  35. virtual PositionAttitudeTransform* asPositionAttitudeTransform() { return this; }
  36. virtual const PositionAttitudeTransform* asPositionAttitudeTransform() const { return this; }
  37. inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); }
  38. inline const Vec3d& getPosition() const { return _position; }
  39. inline void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); }
  40. inline const Quat& getAttitude() const { return _attitude; }
  41. inline void setScale(const Vec3d& scale) { _scale = scale; dirtyBound(); }
  42. inline const Vec3d& getScale() const { return _scale; }
  43. inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; dirtyBound(); }
  44. inline const Vec3d& getPivotPoint() const { return _pivotPoint; }
  45. virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const;
  46. virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const;
  47. protected :
  48. virtual ~PositionAttitudeTransform() {}
  49. Vec3d _position;
  50. Quat _attitude;
  51. Vec3d _scale;
  52. Vec3d _pivotPoint;
  53. };
  54. }
  55. #endif