00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019 #include "primitives.h"
00020 #include <qglviewer/qglviewer.h>
00021 #include <cstdlib>
00022
00023 GLUquadricObj* g_quadratic = NULL;
00024
00025 void freePrimitives()
00026 {
00027 if (g_quadratic) {
00028 gluDeleteQuadric(g_quadratic);
00029 g_quadratic = NULL;
00030 }
00031 }
00032
00033 void initPrimitives()
00034 {
00035 if (!g_quadratic) {
00036 g_quadratic = gluNewQuadric();
00037 gluQuadricNormals(g_quadratic, GLU_SMOOTH);
00038
00039 atexit(freePrimitives);
00040 }
00041 }
00042
00043 void drawAxis(float length)
00044 {
00045 QGLViewer::drawAxis(length);
00046 }
00047
00048 void drawArrow(float length, float radius, int nbSubdivisions)
00049 {
00050 QGLViewer::drawArrow(length, radius, nbSubdivisions);
00051 }
00052
00053 void drawGrid(float size, int nbSubdivisions)
00054 {
00055 QGLViewer::drawGrid(size, nbSubdivisions);
00056 }
00057
00058 void drawArrow2D(float len, float head_width, float head_len)
00059 {
00060 glBegin(GL_LINES);
00061 glVertex2f(0, 0);
00062 glVertex2f(len, 0);
00063 glEnd();
00064
00065 glNormal3f(0,0,1);
00066 glBegin(GL_TRIANGLES);
00067 glVertex2f(len, 0);
00068 glVertex2f(len - head_len, 0.5*head_width);
00069 glVertex2f(len - head_len, -0.5*head_width);
00070 glEnd();
00071 }
00072
00073 void drawPoseBox()
00074 {
00075 glPushMatrix();
00076 glScalef(0.5,1,1);
00077 glPushMatrix();
00078 glScalef(1,0.25,0.5);
00079 glTranslatef(-0.5,0.5,0);
00080 glColor3f(1.0, 0.3, 0.3);
00081 drawBox(1, 1, 1);
00082 glPopMatrix();
00083
00084 glPushMatrix();
00085 glScalef(1,0.25,0.5);
00086 glTranslatef(-0.5,-0.5,0);
00087 glColor3f(1.0, 0.1, 0.1);
00088 drawBox(1, 1, 1);
00089 glPopMatrix();
00090
00091 glPushMatrix();
00092 glScalef(1,0.25,0.5);
00093 glTranslatef(+0.5,0.5,0);
00094 glColor3f(0.3, 0.3, 1.0);
00095 drawBox(1, 1, 1);
00096 glPopMatrix();
00097
00098 glPushMatrix();
00099 glScalef(1,0.25,0.5);
00100 glTranslatef(+0.5,-0.5,0);
00101 glColor3f(0.1, 0.1, 1.);
00102 drawBox(1, 1, 1);
00103 glPopMatrix();
00104 glPopMatrix();
00105 }