Commit d310c456 authored by Jan Möbius's avatar Jan Möbius

Coordsysnode with rotation matrix support

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@11131 383ad7c9-94d9-4d36-a494-682f7c89f535
parent dec50683
......@@ -56,6 +56,7 @@
#include <iostream>
//== NAMESPACES ===============================================================
namespace ACG {
......@@ -218,7 +219,6 @@ void
CoordinateSystemNode::
draw(GLState& _state , const DrawModes::DrawMode& /*_drawMode*/)
{
// Push Modelview-Matrix
_state.push_modelview_matrix();
......@@ -228,9 +228,15 @@ draw(GLState& _state , const DrawModes::DrawMode& /*_drawMode*/)
glEnable(GL_COLOR_MATERIAL);
glShadeModel(GL_SMOOTH);
// Translate to right position
_state.translate(position_);
// Koordinatensystem zeichnen
// Apply rotation matrix
GLMatrixd modelview = _state.modelview();
modelview *= rotation_;
_state.set_modelview(modelview);
// Draw coordsys
drawCoordsys(_state);
glColor4fv(lastBaseColor.data());
......@@ -254,6 +260,17 @@ position() {
return position_;
}
void CoordinateSystemNode::rotation(const Matrix4x4d & _rotation)
{
rotation_ = _rotation;
}
Matrix4x4d CoordinateSystemNode::rotation()
{
return rotation_;
}
void
CoordinateSystemNode::
size(const double _size) {
......@@ -280,9 +297,14 @@ CoordinateSystemNode::pick(GLState& _state, PickTarget _target)
// Push Modelview-Matrix
_state.push_modelview_matrix();
// Translate to current position of the coordsys
// Translate to right position
_state.translate(position_);
// Apply rotation matrix
GLMatrixd modelview = _state.modelview();
modelview *= rotation_;
_state.set_modelview(modelview);
// Koordinatensystem zeichnen
drawCoordsysPick(_state);
......
......@@ -71,7 +71,7 @@ namespace SceneGraph {
/** \class Node for displaying coordinate systems
CoordinateSystemNode renders A coordinate system.
CoordinateSystemNode renders a coordinate system.
**/
......@@ -85,7 +85,7 @@ public:
* @param _name Name of this Node
*/
CoordinateSystemNode( BaseNode* _parent=0,
std::string _name="<TextNode>")
std::string _name="<TextNode>")
: BaseNode(_parent, _name),
coordsysSize_(1.0)
{};
......@@ -111,22 +111,31 @@ public:
/// set position of the coordsys
void position(const Vec3d& _pos);
/// Get current position
/// Get current position of the coordinate system;
Vec3d position();
/// Get current rotation of the coordinate system;
Matrix4x4d rotation();
/// Set the rotation of the coordinate system;
void rotation(const Matrix4x4d & _rotation);
/// set size of the coordsys ( Size is length of one of the axis )
void size(const double _size);
/// Get current size
double size();
private:
void drawCoordsys(GLState& _state);
void drawCoordsysPick(GLState& _state);
/// 3d position of the coordsys origin
Vec3d position_;
/// Orientation of coordsys
Matrix4x4d rotation_;
/// Size of the coordsys
double coordsysSize_;
......
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