1 //****************************************************************************// 2 // coordsys.h // 3 // Copyright (C) 2001, 2002 Bruno 'Beosil' Heidelberger // 4 //****************************************************************************// 5 // This library is free software; you can redistribute it and/or modify it // 6 // under the terms of the GNU Lesser General Public License as published by // 7 // the Free Software Foundation; either version 2.1 of the License, or (at // 8 // your option) any later version. // 9 //****************************************************************************// 10 11 #ifndef CAL_TRANSFORM_H 12 #define CAL_TRANSFORM_H 13 14 #include "cal3d/global.h" 15 #include "cal3d/vector.h" 16 #include "cal3d/quaternion.h" 17 18 namespace cal3d 19 { 20 /** 21 * Contains a translation and rotation that describe a coordinate 22 * system or transform. 23 */ 24 class CAL3D_API Transform 25 { 26 public: Transform()27 Transform() { } 28 Transform(const CalVector & translation,const CalQuaternion & rotation)29 Transform(const CalVector& translation, const CalQuaternion& rotation) 30 : m_translation(translation) 31 , m_rotation(rotation) 32 { 33 } 34 ~Transform()35 ~Transform() { } 36 getTranslation()37 const CalVector& getTranslation() const 38 { 39 return m_translation; 40 } 41 getTranslation()42 CalVector& getTranslation() 43 { 44 return m_translation; 45 } 46 getRotation()47 const CalQuaternion& getRotation() const 48 { 49 return m_rotation; 50 } 51 getRotation()52 CalQuaternion& getRotation() 53 { 54 return m_rotation; 55 } 56 setTranslation(const CalVector & translation)57 void setTranslation(const CalVector& translation) 58 { 59 m_translation = translation; 60 } 61 setRotation(const CalQuaternion & rotation)62 void setRotation(const CalQuaternion& rotation) 63 { 64 m_rotation = rotation; 65 } 66 67 /// Sets this coordinate system to the identity rotation and translation. setIdentity()68 void setIdentity() 69 { 70 m_translation.clear(); 71 m_rotation.clear(); 72 } 73 blend(float t,const Transform & end)74 void blend(float t, const Transform& end) 75 { 76 m_translation.blend(t, end.getTranslation()); 77 m_rotation.blend(t, end.getRotation()); 78 } 79 80 bool operator==(const Transform& rhs) const 81 { 82 return m_translation == rhs.m_translation && 83 m_rotation == rhs.m_rotation; 84 } 85 86 bool operator!=(const Transform& rhs) const 87 { 88 return !operator==(rhs); 89 } 90 91 private: 92 CalVector m_translation; 93 CalQuaternion m_rotation; 94 }; 95 } 96 97 typedef cal3d::Transform CalTransform; 98 99 #endif 100