TransformNode.hh
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifndef ACG_TRANSFORM_NODE_HH
00053 #define ACG_TRANSFORM_NODE_HH
00054
00055
00056
00057
00058
00059 #include "BaseNode.hh"
00060 #include "../Math/GLMatrixT.hh"
00061 #include "../Math/VectorT.hh"
00062 #include "../Math/QuaternionT.hh"
00063
00064
00065
00066
00067
00068 namespace ACG {
00069 namespace SceneGraph {
00070
00071
00072
00073
00074
00084 class ACGDLLEXPORT TransformNode : public BaseNode
00085 {
00086 public:
00087
00088
00090 TransformNode( BaseNode* _parent=0,
00091 const std::string& _name="<TransformNode>" );
00092
00094 virtual ~TransformNode(){}
00095
00097 ACG_CLASSNAME(TransformNode);
00098
00099
00101 void enter(GLState& _state, DrawModes::DrawMode _drawmode);
00103 void leave(GLState& _state, DrawModes::DrawMode _drawmode);
00104
00105
00106
00108 void set_center(const Vec3d& _c) { center_ = _c; }
00110 const Vec3d& center() const { return center_; }
00111
00112
00115 void loadIdentity();
00119 virtual void setIdentity();
00120
00121
00122
00123
00124
00125
00127 void translate(const Vec3d& _v);
00128
00131 void rotate(double _angle, const Vec3d& _axis);
00132
00134 void scale(double _s) { scale(Vec3d(_s, _s, _s)); }
00135
00137 void scale(const Vec3d& _s);
00138
00140 void scale(const GLMatrixd& _m);
00141
00142
00143
00144
00145
00147 const GLMatrixd& matrix() const { return matrix_; }
00149 const GLMatrixd& inverse_matrix() const { return inverse_matrix_; }
00150
00152 void rotation(Vec3d& _axis, double& _angle) const {
00153 quaternion_.axis_angle(_axis, _angle);
00154 _angle *= 180.0/M_PI;
00155 }
00157 const GLMatrixd& rotation() const {
00158 return rotation_matrix_;
00159 }
00161 const GLMatrixd& inverse_rotation() const {
00162 return inverse_rotation_matrix_;
00163 }
00164
00165
00167 const Vec3d& translation() const { return translation_; }
00168
00170 const GLMatrixd& scale() const {
00171 return scale_matrix_;
00172 }
00174 const GLMatrixd& inverse_scale() const {
00175 return inverse_scale_matrix_;
00176 }
00177
00178 bool apply_transformation() { return applyTransformation_; }
00179
00180 void apply_transformation(bool _applyTransformation) { applyTransformation_ = _applyTransformation; }
00181
00182
00183 private:
00184
00186 void updateMatrix();
00187
00188
00189
00190 GLMatrixd matrix_, inverse_matrix_;
00191 GLMatrixd rotation_matrix_, inverse_rotation_matrix_, scale_matrix_, inverse_scale_matrix_;
00192 Vec3d center_;
00193 Vec3d translation_;
00194 Quaterniond quaternion_;
00195
00196
00197 bool applyTransformation_;
00198 };
00199
00200
00201
00202 }
00203 }
00204
00205 #endif // ACG_TRANSFORM_NODE_HH
00206