ManipulatorNode.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: 6743 $                                                       *
00038  *   $Author: moebius $                                                      *
00039  *   $Date: 2009-08-05 11:03:10 +0200 (Mi, 05. Aug 2009) $                   *
00040  *                                                                           *
00041 \*===========================================================================*/
00042 
00043 
00044 
00045 
00046 //=============================================================================
00047 //
00048 //  CLASS ManipulatorNode
00049 //
00050 //=============================================================================
00051 
00052 
00053 #ifndef ACG_MANIPULATOR_NODE_HH
00054 #define ACG_MANIPULATOR_NODE_HH
00055 
00056 
00057 //== INCLUDES =================================================================
00058 
00059 // GMU
00060 #include "BaseNode.hh"
00061 #include "TransformNode.hh"
00062 
00063 // Qt
00064 #include <QEvent>
00065 #include <QMouseEvent>
00066 
00067 
00068 //== NAMESPACES ===============================================================
00069 
00070 namespace ACG {
00071 namespace SceneGraph {
00072 
00073 
00074 //== CLASS DEFINITION =========================================================
00075 
00076 
00082 class ACGDLLEXPORT ManipulatorNode : public TransformNode
00083 {
00084 public:
00085 
00086 
00088   ManipulatorNode( BaseNode* _parent=0,
00089                    const std::string& _name="<ManipulatorNode>" );
00090 
00092   ~ManipulatorNode();
00093 
00094 
00096   ACG_CLASSNAME(ManipulatorNode);
00097 
00098 
00099   //
00100   // METHODS
00101   //
00102 
00103 
00104 
00105   virtual void setIdentity();
00106 
00108   void set_draw_cylinder(bool _b) { draw_cylinder_ = _b; }
00109 
00111   bool draw_cylinder() const { return draw_cylinder_; }
00112 
00115   void set_direction(Vec3d& _v);
00116 
00119   Vec3d direction() const;
00120 
00122   void set_size( double _size) { cylinder_height_ = _size;
00123                                  cylinder_radius_ = _size/10.0;}
00124 
00126   double size() const { return cylinder_height_; }
00127 
00129   void translate(double _s) {
00130     Vec3d rel_dir = rotation().transform_vector(direction_);
00131     TransformNode::translate(_s * rel_dir);
00132   }
00133 
00135   void draw(GLState& _state, unsigned int _drawMode);
00136 
00138   void pick(GLState& _state, PickTarget _target);
00139 
00141   virtual void mouseEvent(GLState& _state, QMouseEvent* _event);
00142 
00146   bool touched() { return touched_; };
00147 
00149   void reset_touched() { touched_ = false; };
00150 
00151 
00152 private:
00153 
00154   void setup_sphere_system(GLState& _state);
00155   void setup_cylinder_system(GLState& _state);
00156 
00157   bool mapToSphere(GLState& _state, const Vec2i& _v2, Vec3d& _v3);
00158   bool hitSphere(GLState& _state, const Vec2i& _v2);
00159   bool mapToCylinder (GLState& _state, const Vec2i& _v2, double& axis_hit);
00160 
00161 
00162 
00163 
00164 
00165   // ELEMENTS
00166   bool               draw_cylinder_;
00167 
00168   Vec3d              direction_;
00169   GLUquadricObj*     cylinder_;
00170   double             cylinder_radius_;
00171   double             cylinder_height_;
00172   int                cylinder_slices_;
00173   int                cylinder_stacks_;
00174 
00175 
00176   bool               cylinder_clicked_;
00177   bool               sphere_clicked_;
00178 
00179   Vec2i              oldPoint2D_;
00180 
00182   bool               touched_;
00183 };
00184 
00185 
00186 //=============================================================================
00187 } // namespace SceneGraph
00188 } // namespace ACG
00189 //=============================================================================
00190 #endif // ACG_MANIPUKATOR_NODE_HH defined
00191 //=============================================================================
00192 

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