Changeset 5516
- Timestamp:
- May 15, 2015, 12:31:44 AM (9 years ago)
- Location:
- nanovis/branches/1.2
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
nanovis/branches/1.2/OrientationIndicator.cpp
r5498 r5516 10 10 #include <GL/glu.h> 11 11 12 #include <vrmath/Vector3f.h> 13 12 14 #include "OrientationIndicator.h" 13 15 16 using namespace vrmath; 14 17 using namespace nv; 15 18 … … 18 21 _visible(true), 19 22 _lineWidth(1.f), 20 _quadric(gluNewQuadric()) 23 _quadric(gluNewQuadric()), 24 _position(0,0,0), 25 _scale(1,1,1) 21 26 { 22 27 } … … 37 42 return; 38 43 44 glMatrixMode(GL_MODELVIEW); 45 glPushMatrix(); 46 glTranslatef(_position.x, _position.y, _position.z); 47 float scale = _scale.x; 48 if (scale == 0 || _scale.y < scale) scale = _scale.y; 49 if (scale == 0 || _scale.z < scale) scale = _scale.z; 50 glScalef(scale, scale, scale); 51 39 52 glPushAttrib(GL_ENABLE_BIT | GL_LINE_BIT); 40 53 … … 48 61 glLineWidth(_lineWidth); 49 62 glDisable(GL_LIGHTING); 50 glColor3f(1, 0, 0); 51 glBegin(GL_LINES); 52 glVertex3f(0, 0, 0); 53 glVertex3f(0.5f, 0, 0); 54 glEnd(); 55 glColor3f(0, 1, 0); 56 glBegin(GL_LINES); 57 glVertex3f(0, 0, 0); 58 glVertex3f(0, 0.5f, 0); 59 glEnd(); 60 glColor3f(0, 0, 1); 61 glBegin(GL_LINES); 62 glVertex3f(0, 0, 0); 63 glVertex3f(0, 0, 0.5f); 64 glEnd(); 63 if (_scale.x > 0) { 64 glColor3f(1, 0, 0); 65 glBegin(GL_LINES); 66 glVertex3f(0, 0, 0); 67 glVertex3f(0.5f, 0, 0); 68 glEnd(); 69 } 70 if (_scale.y > 0) { 71 glColor3f(0, 1, 0); 72 glBegin(GL_LINES); 73 glVertex3f(0, 0, 0); 74 glVertex3f(0, 0.5f, 0); 75 glEnd(); 76 } 77 if (_scale.z > 0) { 78 glColor3f(0, 0, 1); 79 glBegin(GL_LINES); 80 glVertex3f(0, 0, 0); 81 glVertex3f(0, 0, 0.5f); 82 glEnd(); 83 } 65 84 } 66 85 break; … … 72 91 glEnable(GL_LIGHTING); 73 92 glEnable(GL_LIGHT0); 93 glEnable(GL_NORMALIZE); 74 94 75 95 // X 76 glColor3f(1, 0, 0); 77 glPushMatrix(); 78 glRotatef(90, 0, 1, 0); 79 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 80 glPopMatrix(); 96 if (_scale.x > 0) { 97 glColor3f(1, 0, 0); 98 glPushMatrix(); 99 glRotatef(90, 0, 1, 0); 100 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 101 glPopMatrix(); 81 102 82 glPushMatrix(); 83 glTranslatef(0.3, 0., 0.); 84 glRotatef(90, 0, 1, 0); 85 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 86 glPopMatrix(); 103 glPushMatrix(); 104 glTranslatef(0.3, 0., 0.); 105 glRotatef(90, 0, 1, 0); 106 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 107 glPopMatrix(); 108 } 87 109 88 110 // Y 89 glColor3f(0, 1, 0); 90 glPushMatrix(); 91 glRotatef(-90, 1, 0, 0); 92 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 93 glPopMatrix(); 111 if (_scale.y > 0) { 112 glColor3f(0, 1, 0); 113 glPushMatrix(); 114 glRotatef(-90, 1, 0, 0); 115 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 116 glPopMatrix(); 94 117 95 glPushMatrix(); 96 glTranslatef(0., 0.3, 0.); 97 glRotatef(-90, 1, 0, 0); 98 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 99 glPopMatrix(); 118 glPushMatrix(); 119 glTranslatef(0., 0.3, 0.); 120 glRotatef(-90, 1, 0, 0); 121 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 122 glPopMatrix(); 123 } 100 124 101 125 // Z 102 glColor3f(0, 0, 1); 103 glPushMatrix(); 104 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 105 glPopMatrix(); 126 if (_scale.z > 0) { 127 glColor3f(0, 0, 1); 128 glPushMatrix(); 129 gluCylinder(qobj, 0.01, 0.01, 0.3, segments, 1); 130 glPopMatrix(); 106 131 107 glPushMatrix(); 108 glTranslatef(0., 0., 0.3); 109 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 110 glPopMatrix(); 132 glPushMatrix(); 133 glTranslatef(0., 0., 0.3); 134 gluCylinder(qobj, 0.02, 0.0, 0.06, segments, 1); 135 glPopMatrix(); 136 } 111 137 } 112 138 break; … … 116 142 117 143 glPopAttrib(); 144 glPopMatrix(); 118 145 } -
nanovis/branches/1.2/OrientationIndicator.h
r5498 r5516 5 5 * Author: Leif Delgass <ldelgass@purdue.edu> 6 6 */ 7 #ifndef ORIENTATION_INDICATOR_H 8 #define ORIENTATION_INDICATOR_H 7 #ifndef NV_ORIENTATION_INDICATOR_H 8 #define NV_ORIENTATION_INDICATOR_H 9 10 #include <vrmath/Vector3f.h> 9 11 10 12 namespace nv { 13 11 14 class OrientationIndicator 12 15 { … … 34 37 } 35 38 39 void setPosition(const vrmath::Vector3f& pos) 40 { 41 _position = pos; 42 } 43 44 void setScale(const vrmath::Vector3f& scale) 45 { 46 _scale = scale; 47 } 48 36 49 private: 37 50 Representation _rep; … … 39 52 float _lineWidth; 40 53 void *_quadric; 54 55 vrmath::Vector3f _position; 56 vrmath::Vector3f _scale; 41 57 }; 58 42 59 } 43 60
Note: See TracChangeset
for help on using the changeset viewer.