Commit 7c19d075 authored by Jan Möbius's avatar Jan Möbius

Merge branch 'feature/Transformnode_extensions' into 'master'

adds setters for translation and rotation in TransformNode

See merge request !111
parents 5d94be6f fbfb19f3
......@@ -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
......
......@@ -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;};
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment