diff --git a/libs_required/ACG/Scenegraph/TransformNode.cc b/libs_required/ACG/Scenegraph/TransformNode.cc index 440e236369008ac3b0dd4cd0098dc79cb323986e..3a5d764bd7993329afd62c4c783bbfe40d253fcd 100644 --- a/libs_required/ACG/Scenegraph/TransformNode.cc +++ b/libs_required/ACG/Scenegraph/TransformNode.cc @@ -134,6 +134,17 @@ translate(const Vec3d& _v) updateMatrix(); } +//---------------------------------------------------------------------------- + + +void +TransformNode:: +setTranslation(const Vec3d& _v) +{ + translation_ = _v; + updateMatrix(); +} + //---------------------------------------------------------------------------- @@ -154,6 +165,22 @@ rotate(double _angle, const Vec3d& _axis) //---------------------------------------------------------------------------- +void +TransformNode:: +setRotation(const Quaterniond& rotation) +{ + quaternion_ = rotation; + quaternion_.normalize(); + rotation_matrix_ = quaternion_.rotation_matrix(); + inverse_rotation_matrix_ = rotation_matrix_; + inverse_rotation_matrix_.transpose(); + updateMatrix(); +} + + +//---------------------------------------------------------------------------- + + void TransformNode:: scale(const Vec3d& _s) @@ -256,7 +283,7 @@ enter(GLState& _state, const DrawModes::DrawMode& /* _drawmode */ ) if (is2DObject_) ortho2DMode(_state); - + if(isPerSkeletonObject_) perSkeletonMode(_state); } @@ -360,19 +387,19 @@ ortho2DMode(GLState& _state) if (width == 0 || height == 0) return; - + // _state.viewport(0,0,width, height); _state.reset_projection(); - + _state.ortho(-(GLdouble)width/2.0, (GLdouble)width/2.0, -(GLdouble)height/2.0, (GLdouble)height/2.0, 0.01, 20.0); // _state.ortho(0.0, (GLdouble)width, (GLdouble)height, 0.0, 0.01,20.0); - + _state.reset_modelview(); - - _state.lookAt( Vec3d(0.0,0.0,0.0), - Vec3d(0.0,0.0,1.0), + + _state.lookAt( Vec3d(0.0,0.0,0.0), + Vec3d(0.0,0.0,1.0), Vec3d(0.0,-1.0,0.0)); // flip up direction (y-axis) s.t. opengl coordsys matches image coordsys - + _state.scale(scaleFactor2D_, scaleFactor2D_, 1.0); // move image center to window center diff --git a/libs_required/ACG/Scenegraph/TransformNode.hh b/libs_required/ACG/Scenegraph/TransformNode.hh index 498b773584543ebdf48bf0bf06dc04cf01cf1683..2d8f039f492766290c30a5d6a47622b10216a15c 100644 --- a/libs_required/ACG/Scenegraph/TransformNode.hh +++ b/libs_required/ACG/Scenegraph/TransformNode.hh @@ -86,7 +86,7 @@ namespace SceneGraph { specified center. This is the base class for e.g. the TrackballNode and the ManipulatorNode, that only add a GUI for generating the transformations. - + Note that in order for the transformations to apply in each traversal of the scenegraph, one has to call apply_transformation(true) once. @@ -137,10 +137,16 @@ public: /// Add a translation to the current Transformation. void translate(const Vec3d& _v); + /// translation setter + void setTranslation(const Vec3d& _v); + /** Add a rotation to the current Transformation. Assume angle in degree and axis normalized */ void rotate(double _angle, const Vec3d& _axis); + /// rotation setter + void setRotation(const Quaterniond& rotation); + /// Add scaling to the current Transformation. void scale(double _s) { scale(Vec3d(_s, _s, _s)); } @@ -178,12 +184,12 @@ public: const Vec3d& translation() const { return translation_; } /// return scale matrix - const GLMatrixd& scale() const { - return scale_matrix_; + const GLMatrixd& scale() const { + return scale_matrix_; } /// return inverse scale matrix - const GLMatrixd& inverse_scale() const { - return inverse_scale_matrix_; + const GLMatrixd& inverse_scale() const { + return inverse_scale_matrix_; } bool apply_transformation() { return applyTransformation_; } @@ -194,11 +200,11 @@ public: // ortho 2d mode bool is2D(){return is2DObject_;}; void set2D(bool _2d){is2DObject_ = _2d;}; - + bool isPerSkeletonObject(){return isPerSkeletonObject_;}; void setPerSkeletonObject(bool _is){isPerSkeletonObject_ = _is;}; void setPerSkeletonModelView(GLMatrixd _is){perSkeletonModelView_ = _is;}; - + void ortho2DMode(GLState& _state); void perSkeletonMode(GLState& _state); void update2DOffset(ACG::Vec2d _offset){offset_ += _offset;};