TransformNode.hh

00001 /*===========================================================================*\
00002  *                                                                           *
00003  *                              OpenFlipper                                  *
00004  *      Copyright (C) 2001-2009 by Computer Graphics Group, RWTH Aachen      *
00005  *                           www.openflipper.org                             *
00006  *                                                                           *
00007  *---------------------------------------------------------------------------*
00008  *  This file is part of OpenFlipper.                                        *
00009  *                                                                           *
00010  *  OpenFlipper is free software: you can redistribute it and/or modify      *
00011  *  it under the terms of the GNU Lesser General Public License as           *
00012  *  published by the Free Software Foundation, either version 3 of           *
00013  *  the License, or (at your option) any later version with the              *
00014  *  following exceptions:                                                    *
00015  *                                                                           *
00016  *  If other files instantiate templates or use macros                       *
00017  *  or inline functions from this file, or you compile this file and         *
00018  *  link it with other files to produce an executable, this file does        *
00019  *  not by itself cause the resulting executable to be covered by the        *
00020  *  GNU Lesser General Public License. This exception does not however       *
00021  *  invalidate any other reasons why the executable file might be            *
00022  *  covered by the GNU Lesser General Public License.                        *
00023  *                                                                           *
00024  *  OpenFlipper is distributed in the hope that it will be useful,           *
00025  *  but WITHOUT ANY WARRANTY; without even the implied warranty of           *
00026  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the            *
00027  *  GNU Lesser General Public License for more details.                      *
00028  *                                                                           *
00029  *  You should have received a copy of the GNU LesserGeneral Public          *
00030  *  License along with OpenFlipper. If not,                                  *
00031  *  see <http://www.gnu.org/licenses/>.                                      *
00032  *                                                                           *
00033 \*===========================================================================*/
00034 
00035 /*===========================================================================*\
00036  *                                                                           *
00037  *   $Revision: 8548 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2010-02-12 14:40:13 +0100 (Fr, 12. Feb 2010) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS TransformNode
00049 //
00050 //=============================================================================
00051 
00052 #ifndef ACG_TRANSFORM_NODE_HH
00053 #define ACG_TRANSFORM_NODE_HH
00054 
00055 
00056 //== INCLUDES =================================================================
00057 
00058 
00059 #include "BaseNode.hh"
00060 #include "../Math/GLMatrixT.hh"
00061 #include "../Math/VectorT.hh"
00062 #include "../Math/QuaternionT.hh"
00063 
00064 
00065 //== NAMESPACES  ==============================================================
00066 
00067 
00068 namespace ACG {
00069 namespace SceneGraph {
00070 
00071 
00072 //== CLASS DEFINITION =========================================================
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   //--- set values ---
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   //--- get values ---
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   // ELEMENTS
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 } // namespace SceneGraph
00203 } // namespace ACG
00204 //=============================================================================
00205 #endif // ACG_TRANSFORM_NODE_HH
00206 //=============================================================================

acg pic Project OpenFlipper, ©  Computer Graphics Group, RWTH Aachen. Documentation generated using doxygen .