ManipulatorNode.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
00053 #ifndef ACG_MANIPULATOR_NODE_HH
00054 #define ACG_MANIPULATOR_NODE_HH
00055
00056
00057
00058
00059
00060 #include "BaseNode.hh"
00061 #include "TransformNode.hh"
00062
00063
00064 #include <QEvent>
00065 #include <QMouseEvent>
00066
00067
00068
00069
00070 namespace ACG {
00071 namespace SceneGraph {
00072
00073
00074
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
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
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 }
00188 }
00189
00190 #endif // ACG_MANIPUKATOR_NODE_HH defined
00191
00192