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

Use the new GLPrimitive where possible

git-svn-id: http://www.openflipper.org/svnrepo/OpenFlipper/branches/Free@13039 383ad7c9-94d9-4d36-a494-682f7c89f535
parent 835dac92
......@@ -52,7 +52,8 @@
//== INCLUDES =================================================================
#include "CoordsysNode.hh"
#include "../GL/gl.hh"
#include <ACG/GL/gl.hh>
#include <iostream>
#include <math.h>
......@@ -66,6 +67,22 @@ namespace SceneGraph {
//== IMPLEMENTATION ==========================================================
CoordsysNode::CoordsysNode(BaseNode* _parent, std::string _name, CoordsysMode _mode, ProjectionMode _projectionMode) :
BaseNode(_parent, _name),
mode_(_mode),
projectionMode_(_projectionMode)
{
const double bodyRadius = 0.004;
const double topRadius = 0.01;
const int slices = 10;
const int stacks = 10;
sphere_ = new ACG::GLSphere(slices,stacks);
cylinder_ = new ACG::GLCylinder(slices, stacks, bodyRadius,false,false);
cone_ = new ACG::GLCone(slices, stacks, 0, topRadius , true,false);
}
void
CoordsysNode::
boundingBox(Vec3d& /*_bbMin*/, Vec3d& /*_bbMax*/)
......@@ -93,30 +110,26 @@ void
CoordsysNode::
drawCoordsys( GLState& _state) {
double topRadius = 0.01;
double arrowLength = 0.04;
double bodyRadius = 0.004;
double bodyLength = 0.06;
int slices = 10;
int stacks = 10;
int loops = 10;
double sphereRadius = 0.01;
GLUquadricObj *quadric = gluNewQuadric();
const double topRadius = 0.01;
const double arrowLength = 0.03;
const double bodyRadius = 0.004;
const double bodyLength = 0.06;
const int slices = 10;
const int stacks = 10;
const double sphereRadius = 0.01;
// Origin
glColor3f(0.5, 0.5, 0.5);
gluSphere( quadric, sphereRadius, slices, stacks );
sphere_->draw(_state,sphereRadius);
// X-Axis
glColor3f(1.0, 0.0, 0.0);
_state.push_modelview_matrix ();
_state.rotate (-90, 0, 1, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
// Y-Axis
......@@ -124,10 +137,9 @@ drawCoordsys( GLState& _state) {
_state.push_modelview_matrix ();
_state.rotate (90, 1, 0, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
// Z-Axis
......@@ -135,13 +147,11 @@ drawCoordsys( GLState& _state) {
_state.push_modelview_matrix ();
_state.rotate (180, 0, 1, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
gluDeleteQuadric(quadric);
}
//============================================================================
......@@ -149,41 +159,37 @@ drawCoordsys( GLState& _state) {
void
CoordsysNode::drawCoordsysPick( GLState& _state) {
double topRadius = 0.01;
double arrowLength = 0.04;
double bodyRadius = 0.004;
double bodyLength = 0.06;
int slices = 10;
int stacks = 10;
int loops = 10;
double sphereRadius = 0.01;
GLUquadricObj *quadric = gluNewQuadric();
const double topRadius = 0.01;
const double arrowLength = 0.03;
const double bodyRadius = 0.004;
const double bodyLength = 0.06;
const int slices = 10;
const int stacks = 10;
const double sphereRadius = 0.01;
// Origin
_state.pick_set_name (1);
gluSphere( quadric, sphereRadius, slices, stacks );
sphere_->draw(_state,sphereRadius);
// X-Axis
_state.pick_set_name (2);
_state.push_modelview_matrix ();
_state.rotate (-90, 0, 1, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
// Y-Axis
_state.pick_set_name (3);
_state.push_modelview_matrix ();
_state.rotate (90, 1, 0, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
// Z-Axis
......@@ -191,15 +197,11 @@ CoordsysNode::drawCoordsysPick( GLState& _state) {
_state.push_modelview_matrix ();
_state.rotate (180, 0, 1, 0);
_state.translate ( 0, 0, -bodyLength );
gluCylinder( quadric, bodyRadius, bodyRadius, bodyLength, slices, stacks );
gluDisk( quadric, 0, topRadius, slices, loops );
cylinder_->draw(_state,bodyLength);
_state.translate ( 0, 0, -arrowLength );
gluCylinder( quadric, 0, topRadius, arrowLength, slices, stacks );
cone_->draw(_state,arrowLength);
_state.pop_modelview_matrix ();
gluDeleteQuadric(quadric);
}
......
......@@ -58,6 +58,7 @@
#include "BaseNode.hh"
#include "DrawModes.hh"
#include <ACG/GL/GLPrimitives.hh>
#include <vector>
//== NAMESPACES ===============================================================
......@@ -97,12 +98,11 @@ public:
* @param _parent Define the parent Node this node gets attached to
* @param _name Name of this Node
*/
CoordsysNode( BaseNode* _parent=0,
std::string _name="<TextNode>",
CoordsysMode _mode = SCREENPOS, ProjectionMode _projectionMode = PERSPECTIVE_PROJECTION)
: BaseNode(_parent, _name),
mode_(_mode),
projectionMode_(_projectionMode) {};
CoordsysNode(
BaseNode* _parent = 0,
std::string _name = "<TextNode>",
CoordsysMode _mode = SCREENPOS,
ProjectionMode _projectionMode = PERSPECTIVE_PROJECTION);
/// destructor
~CoordsysNode() {};
......@@ -148,6 +148,11 @@ public:
ProjectionMode projectionMode_;
Vec3f pos3f_;
ACG::GLSphere* sphere_;
ACG::GLCylinder* cylinder_;
ACG::GLCone* cone_;
};
......
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