Showing the changes to interface/src/Util.cpp (1 of 3 files). Show all
Unified · Split
| @@ -65,46 +65,47 @@ float angle_to(glm::vec3 head_pos, glm::vec3 source_pos, float render_yaw, float · 64 unmodified lines | |||
| 65 | return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180.0f / PIf + render_yaw + head_yaw; | 65 | return atan2(head_pos.x - source_pos.x, head_pos.z - source_pos.z) * 180.0f / PIf + render_yaw + head_yaw; |
| 66 | } | 66 | } |
| 67 | 67 | ||
| 68 | void render_vector(glm::vec3 * vec) | 68 | // Draw a 3D vector floating in space |
| 69 | void drawVector(glm::vec3 * vector) | ||
| 69 | { | 70 | { |
| 70 | // Show edge of world | ||
| 71 | glDisable(GL_LIGHTING); | 71 | glDisable(GL_LIGHTING); |
| 72 | glColor4f(1.0, 1.0, 1.0, 1.0); | 72 | glEnable(GL_POINT_SMOOTH); |
| 73 | glLineWidth(1.0); | 73 | glPointSize(3.0); |
| 74 | glBegin(GL_LINES); | 74 | glLineWidth(2.0); |
| 75 | |||
| 75 | // Draw axes | 76 | // Draw axes |
| 77 | glBegin(GL_LINES); | ||
| 76 | glColor3f(1,0,0); | 78 | glColor3f(1,0,0); |
| 77 | glVertex3f(-1,0,0); | 79 | glVertex3f(0,0,0); |
| 78 | glVertex3f(1,0,0); | 80 | glVertex3f(1,0,0); |
| 79 | glColor3f(0,1,0); | 81 | glColor3f(0,1,0); |
| 80 | glVertex3f(0,-1,0); | 82 | glVertex3f(0,0,0); |
| 81 | glVertex3f(0, 1, 0); | 83 | glVertex3f(0, 1, 0); |
| 82 | glColor3f(0,0,1); | 84 | glColor3f(0,0,1); |
| 83 | glVertex3f(0,0,-1); | 85 | glVertex3f(0,0,0); |
| 84 | glVertex3f(0, 0, 1); | 86 | glVertex3f(0, 0, 1); |
| 85 | // Draw vector | 87 | glEnd(); |
| 88 | |||
| 89 | // Draw the vector itself | ||
| 90 | glBegin(GL_LINES); | ||
| 86 | glColor3f(1,1,1); | 91 | glColor3f(1,1,1); |
| 87 | glVertex3f(0,0,0); | 92 | glVertex3f(0,0,0); |
| 88 | glVertex3f(vec->x, vec->y, vec->z); | 93 | glVertex3f(vector->x, vector->y, vector->z); |
| 89 | // Draw marker dots for magnitude | ||
| 90 | glEnd(); | 94 | glEnd(); |
| 91 | float particleAttenuationQuadratic[] = { 0.0f, 0.0f, 2.0f }; // larger Z = smaller particles | ||
| 92 | float particleAttenuationConstant[] = { 1.0f, 0.0f, 0.0f }; | ||
| 93 | |||
| 94 | glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particleAttenuationQuadratic ); | ||
| 95 | 95 | ||
| 96 | glEnable(GL_POINT_SMOOTH); | 96 | // Draw spheres for magnitude |
| 97 | glPointSize(10.0); | 97 | glPushMatrix(); |
| 98 | glBegin(GL_POINTS); | ||
| 99 | glColor3f(1,0,0); | 98 | glColor3f(1,0,0); |
| 100 | glVertex3f(vec->x,0,0); | 99 | glTranslatef(vector->x,0,0); |
| 100 | glutSolidSphere(0.02, 10, 10); | ||
| 101 | glColor3f(0,1,0); | 101 | glColor3f(0,1,0); |
| 102 | glVertex3f(0,vec->y,0); | 102 | glTranslatef(-vector->x, vector->y, 0); |
| 103 | glutSolidSphere(0.02, 10, 10); | ||
| 103 | glColor3f(0,0,1); | 104 | glColor3f(0,0,1); |
| 104 | glVertex3f(0,0,vec->z); | 105 | glTranslatef(0, -vector->y, vector->z); |
| 105 | glEnd(); | 106 | glutSolidSphere(0.02, 10, 10); |
| 107 | glPopMatrix(); | ||
| 106 | 108 | ||
| 107 | glPointParameterfvARB( GL_POINT_DISTANCE_ATTENUATION_ARB, particleAttenuationConstant ); | ||
| 108 | } | 109 | } |
| 109 | 110 | ||
| 110 | void render_world_box() | 111 | void render_world_box() |
| @@ -184,7 +185,6 @@ void drawtext(int x, int y, float scale, float rotate, float thick, int mono, · 73 unmodified lines | |||
| 184 | 185 | ||
| 185 | } | 186 | } |
| 186 | 187 | ||
| 187 | |||
| 188 | void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec, | 188 | void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, glm::vec3 vec, |
| 189 | float r, float g, float b) | 189 | float r, float g, float b) |
| 190 | { | 190 | { |
| @@ -209,7 +209,7 @@ void drawvec3(int x, int y, float scale, float rotate, float thick, int mono, gl · 18 unmodified lines | |||
| 209 | } | 209 | } |
| 210 | glPopMatrix(); | 210 | glPopMatrix(); |
| 211 | 211 | ||
| 212 | } | 212 | } |
| 213 | 213 | ||
| 214 | void drawGroundPlaneGrid(float size) | 214 | void drawGroundPlaneGrid(float size) |
| 215 | { | 215 | { |