| 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 | |
|---|
| 14 | #ifndef OSG_POSITIONATTITUDETRANSFORM |
|---|
| 15 | #define OSG_POSITIONATTITUDETRANSFORM 1 |
|---|
| 16 | |
|---|
| 17 | #include <osg/Group> |
|---|
| 18 | #include <osg/Transform> |
|---|
| 19 | #include <osg/AnimationPath> |
|---|
| 20 | #include <osg/Vec3d> |
|---|
| 21 | #include <osg/Quat> |
|---|
| 22 | |
|---|
| 23 | namespace osg { |
|---|
| 24 | |
|---|
| 25 | /** PositionAttitudeTransform - is a Transform. Sets the coordinate transform |
|---|
| 26 | via a Vec3 position and Quat attitude. |
|---|
| 27 | */ |
|---|
| 28 | class OSG_EXPORT PositionAttitudeTransform : public Transform |
|---|
| 29 | { |
|---|
| 30 | public : |
|---|
| 31 | PositionAttitudeTransform(); |
|---|
| 32 | |
|---|
| 33 | PositionAttitudeTransform(const PositionAttitudeTransform& pat,const CopyOp& copyop=CopyOp::SHALLOW_COPY): |
|---|
| 34 | Transform(pat,copyop), |
|---|
| 35 | _position(pat._position), |
|---|
| 36 | _attitude(pat._attitude), |
|---|
| 37 | _scale(pat._scale), |
|---|
| 38 | _pivotPoint(pat._pivotPoint) {} |
|---|
| 39 | |
|---|
| 40 | |
|---|
| 41 | META_Node(osg, PositionAttitudeTransform); |
|---|
| 42 | |
|---|
| 43 | virtual PositionAttitudeTransform* asPositionAttitudeTransform() { return this; } |
|---|
| 44 | virtual const PositionAttitudeTransform* asPositionAttitudeTransform() const { return this; } |
|---|
| 45 | |
|---|
| 46 | inline void setPosition(const Vec3d& pos) { _position = pos; dirtyBound(); } |
|---|
| 47 | inline const Vec3d& getPosition() const { return _position; } |
|---|
| 48 | |
|---|
| 49 | |
|---|
| 50 | inline void setAttitude(const Quat& quat) { _attitude = quat; dirtyBound(); } |
|---|
| 51 | inline const Quat& getAttitude() const { return _attitude; } |
|---|
| 52 | |
|---|
| 53 | |
|---|
| 54 | inline void setScale(const Vec3d& scale) { _scale = scale; dirtyBound(); } |
|---|
| 55 | inline const Vec3d& getScale() const { return _scale; } |
|---|
| 56 | |
|---|
| 57 | |
|---|
| 58 | inline void setPivotPoint(const Vec3d& pivot) { _pivotPoint = pivot; dirtyBound(); } |
|---|
| 59 | inline const Vec3d& getPivotPoint() const { return _pivotPoint; } |
|---|
| 60 | |
|---|
| 61 | |
|---|
| 62 | virtual bool computeLocalToWorldMatrix(Matrix& matrix,NodeVisitor* nv) const; |
|---|
| 63 | virtual bool computeWorldToLocalMatrix(Matrix& matrix,NodeVisitor* nv) const; |
|---|
| 64 | |
|---|
| 65 | |
|---|
| 66 | protected : |
|---|
| 67 | |
|---|
| 68 | virtual ~PositionAttitudeTransform() {} |
|---|
| 69 | |
|---|
| 70 | Vec3d _position; |
|---|
| 71 | Quat _attitude; |
|---|
| 72 | Vec3d _scale; |
|---|
| 73 | Vec3d _pivotPoint; |
|---|
| 74 | }; |
|---|
| 75 | |
|---|
| 76 | } |
|---|
| 77 | |
|---|
| 78 | #endif |
|---|