Arrow.cpp
Go to the documentation of this file.
1 
28  /*
29  * PointCloud.cpp
30  *
31  * Created on: 02.09.2008
32  * Author: twiemann
33  */
34 
35 #include "lvr2/display/Arrow.hpp"
36 #include <GL/glut.h>
37 
38 namespace lvr2
39 {
40 
42  color = 0;
43 }
44 
46  this->color = color;
47 }
48 
49 void Arrow::setPosition(double x, double y, double z, double roll, double pitch, double yaw) {
50  this->m_position.x = x;
51  this->m_position.y = y;
52  this->m_position.z = z;
53  this->roll = roll;
54  this->pitch = pitch;
55  this->yaw = yaw;
56 
57  double rot[3];
58  double pos[3];
59  rot[0] = roll; //pitch; //x-axis
60  rot[1] = pitch; //y-axis
61  rot[2] = yaw; //z-axis
62  pos[0] = m_position.x;
63  pos[1] = m_position.y;
64  pos[2] = m_position.z;
65 
66  // Quat quat(rot, pos);
67 
68  float alignxf[16];
69  EulerToMatrix(pos, rot, alignxf);
70 
71  // quat.getMatrix(alignxf);
73 }
74 
76  // TODO Auto-generated destructor stub
77 }
78 
79 void Arrow::render() {
80  // float radius = 30.0f;
81  // float length = 150.0f;
82  // int nbSubdivisions = 4;
83 
84  glPushMatrix();
85  glMultMatrixf(m_transformation.getData());
86  glMultMatrixf(rotation.getData());
87  if(m_showAxes) glCallList(m_axesListIndex);
88 
89  glDisable(GL_LIGHTING);
90  glDisable(GL_BLEND);
91 
92  switch (color) {
93  case 0: glColor4f(1.0f, 0.0f, 0.0f, 1.0f); break;
94  case 1: glColor4f(0.0f, 1.0f, 0.0f, 1.0f); break;
95  default: glColor4f(0.0f, 0.0f, 1.0f, 1.0f); break;
96  }
97 
98  glRotated(90.0, 0.0, 1.0, 0.0);
99 
100  GLUquadric* quadric = gluNewQuadric();
101  // gluCylinder (quadric, radius, 0, length, nbSubdivisions, 1 );
102  //
103  // glBindTexture(GL_TEXTURE_2D, theTexture);
104  //
105  // glEnable(GL_TEXTURE_2D);
106  glBegin(GL_QUADS);
107 
108  float xLength = 50;
109  float yLength = 30;
110  float zLength = 80;
111 
112  glColor4f(0.0f, 1.0f, 1.0f, 1.0f);
113  glVertex3f( xLength, yLength,-zLength);
114  glVertex3f(-xLength, yLength,-zLength);
115  glVertex3f(-xLength, yLength, zLength);
116  glVertex3f( xLength, yLength, zLength);
117 
118  glColor4f(1.0f, 1.0f, 0.0f, 1.0f);
119  glVertex3f( xLength,-yLength, zLength);
120  glVertex3f(-xLength,-yLength, zLength);
121  glVertex3f(-xLength,-yLength,-zLength);
122  glVertex3f( xLength,-yLength,-zLength);
123 
124  // front and back
125  glColor4f(0.0f, 1.0f, 0.0f, 1.0f);
126  glVertex3f(xLength, yLength, zLength);
127  glVertex3f(-xLength, yLength, zLength);
128  glVertex3f(-xLength,-yLength, zLength);
129  glVertex3f( xLength,-yLength, zLength);
130 
131  glColor4f(0.0f, 0.0f, 1.0f, 1.0f);
132  glVertex3f( xLength,-yLength,-zLength);
133  glVertex3f(-xLength,-yLength,-zLength);
134  glVertex3f(-xLength, yLength,-zLength);
135  glVertex3f( xLength, yLength,-zLength);
136 
137  glColor4f(1.0f, 0.0f, 0.0f, 1.0f);
138  glVertex3f(-xLength, yLength, zLength);
139  glVertex3f(-xLength, yLength,-zLength);
140  glVertex3f(-xLength,-yLength,-zLength);
141  glVertex3f(-xLength,-yLength, zLength);
142 
143  glVertex3f( xLength, yLength,-zLength);
144  glVertex3f( xLength, yLength, zLength);
145  glVertex3f( xLength,-yLength, zLength);
146  glVertex3f( xLength,-yLength,-zLength);
147 
148  glEnd();
149  // glDisable(GL_TEXTURE_2D);
150 
151 
152  glDisable(GL_LIGHTING);
153  gluDeleteQuadric ( quadric );
154  glPopMatrix();
155  glPopAttrib();
156  glEnable(GL_BLEND);
157 }
158 
159 } // namespace lvr2
lvr2::EulerToMatrix
void EulerToMatrix(const double *rPos, const double *rPosTheta, float *alignxf)
Definition: Arrow.hpp:76
lvr2::Matrix4
A 4x4 matrix class implementation for use with the provided vertex types.
Definition: Matrix4.hpp:64
Arrow.hpp
lvr2::color
Definition: DataStruct.hpp:81
lvr2::Arrow::yaw
double yaw
Definition: Arrow.hpp:68
lvr2::BaseVector::x
CoordT x
Definition: BaseVector.hpp:65
lvr2::Renderable::m_transformation
Matrix4< Vec > m_transformation
Definition: Renderable.hpp:164
lvr2::BaseVector::y
CoordT y
Definition: BaseVector.hpp:66
scripts.normalize_multiple.filename
filename
Definition: normalize_multiple.py:60
lvr2::Arrow::roll
double roll
Definition: Arrow.hpp:65
lvr2::Renderable::m_axesListIndex
int m_axesListIndex
Definition: Renderable.hpp:150
lvr2::Renderable
Definition: Renderable.hpp:65
lvr2::Arrow::setPosition
void setPosition(double x, double y, double z, double roll, double pitch, double yaw)
Definition: Arrow.cpp:49
lvr2::Arrow::Arrow
Arrow(string filename)
Definition: Arrow.cpp:41
lvr2::Arrow::render
virtual void render()
Definition: Arrow.cpp:79
lvr2::Renderable::m_showAxes
bool m_showAxes
Definition: Renderable.hpp:143
lvr2::Arrow::color
int color
Definition: Arrow.hpp:69
lvr2::BaseVector::z
CoordT z
Definition: BaseVector.hpp:67
lvr2
Definition: BaseBufferManipulators.hpp:39
lvr2::Arrow::rotation
Matrix4< BaseVector< float > > rotation
Definition: Arrow.hpp:70
lvr2::Renderable::m_position
Vec m_position
Definition: Renderable.hpp:162
lvr2::Arrow::~Arrow
virtual ~Arrow()
Definition: Arrow.cpp:75
lvr2::Arrow::pitch
double pitch
Definition: Arrow.hpp:68
lvr2::Matrix4::getData
ValueType * getData()
Returns the internal data array. Unsafe. Will probably removed in one of the next versions.
Definition: Matrix4.hpp:513


lvr2
Author(s): Thomas Wiemann , Sebastian Pütz , Alexander Mock , Lars Kiesow , Lukas Kalbertodt , Tristan Igelbrink , Johan M. von Behren , Dominik Feldschnieders , Alexander Löhr
autogenerated on Wed Mar 2 2022 00:37:22