diff --git a/qgroundcontrol.pri b/qgroundcontrol.pri index 005cd5d7ff4bf2c88824d281dc5daf9eab5e2690..1d2eced4ecfdb44d087cf4203846ee52bcb98b1b 100644 --- a/qgroundcontrol.pri +++ b/qgroundcontrol.pri @@ -113,8 +113,7 @@ linux-g++ { -lflite_cmulex \ -lflite \ -lSDL \ - -lSDLmain \ - -lglut + -lSDLmain #-lflite_cmu_us_rms \ #-lflite_cmu_us_slt \ @@ -156,8 +155,7 @@ linux-g++-64 { -lflite_cmulex \ -lflite \ -lSDL \ - -lSDLmain \ - -lglut + -lSDLmain } diff --git a/qgroundcontrol.pro b/qgroundcontrol.pro index 47f53f6cf03d5f801aff779ae27cb385788b9baf..22846765c09b87fb7c76e3e6da82da7180732ecd 100644 --- a/qgroundcontrol.pro +++ b/qgroundcontrol.pro @@ -164,8 +164,7 @@ HEADERS += src/MG.h \ src/ui/map3D/Q3DWidget.h \ src/ui/map3D/CheetahModel.h \ src/ui/map3D/CheetahGL.h \ - src/ui/map3D/QMap3DWidget.h \ - src/ui/map3D/QGCGlut.h + src/ui/map3D/QMap3DWidget.h SOURCES += src/main.cc \ src/Core.cc \ src/uas/UASManager.cc \ diff --git a/src/ui/map3D/Q3DWidget.cc b/src/ui/map3D/Q3DWidget.cc index 1151a15a9e608bc6e50606a70d7a7bb3a7200fed..9cddfcefff758907a6f143a7bcecf92b0aa57300 100755 --- a/src/ui/map3D/Q3DWidget.cc +++ b/src/ui/map3D/Q3DWidget.cc @@ -864,3 +864,157 @@ Q3DWidget::closeEvent(QCloseEvent *) { // exit application } + +void Q3DWidget::wireSphere(double radius, int slices, int stacks) +{ + // Make sure quad object exists + if(!quadObj) quadObj = gluNewQuadric(); + gluQuadricDrawStyle(quadObj, GLU_LINE); + gluQuadricNormals(quadObj, GLU_SMOOTH); + /* If we ever changed/used the texture or orientation state + of quadObj, we'd need to change it to the defaults here + with gluQuadricTexture and/or gluQuadricOrientation. */ + gluSphere(quadObj, radius, slices, stacks); +} + +void Q3DWidget::solidSphere(double radius, int slices, int stacks) +{ + // Make sure quad object exists + if(!quadObj) quadObj = gluNewQuadric(); + gluQuadricDrawStyle(quadObj, GLU_FILL); + gluQuadricNormals(quadObj, GLU_SMOOTH); + /* If we ever changed/used the texture or orientation state + of quadObj, we'd need to change it to the defaults here + with gluQuadricTexture and/or gluQuadricOrientation. */ + gluSphere(quadObj, radius, slices, stacks); +} + +void Q3DWidget::wireCone(double base, double height, int slices, int stacks) +{ + // Make sure quad object exists + if(!quadObj) quadObj = gluNewQuadric(); + gluQuadricDrawStyle(quadObj, GLU_LINE); + gluQuadricNormals(quadObj, GLU_SMOOTH); + /* If we ever changed/used the texture or orientation state + of quadObj, we'd need to change it to the defaults here + with gluQuadricTexture and/or gluQuadricOrientation. */ + gluCylinder(quadObj, base, 0.0, height, slices, stacks); +} + +void Q3DWidget::solidCone(double base, double height, int slices, int stacks) +{ + // Make sure quad object exists + if(!quadObj) quadObj = gluNewQuadric(); + gluQuadricDrawStyle(quadObj, GLU_FILL); + gluQuadricNormals(quadObj, GLU_SMOOTH); + /* If we ever changed/used the texture or orientation state + of quadObj, we'd need to change it to the defaults here + with gluQuadricTexture and/or gluQuadricOrientation. */ + gluCylinder(quadObj, base, 0.0, height, slices, stacks); +} + +void Q3DWidget::drawBox(float size, GLenum type) +{ + static GLfloat n[6][3] = + { + {-1.0, 0.0, 0.0}, + {0.0, 1.0, 0.0}, + {1.0, 0.0, 0.0}, + {0.0, -1.0, 0.0}, + {0.0, 0.0, 1.0}, + {0.0, 0.0, -1.0} + }; + static GLint faces[6][4] = + { + {0, 1, 2, 3}, + {3, 2, 6, 7}, + {7, 6, 5, 4}, + {4, 5, 1, 0}, + {5, 6, 2, 1}, + {7, 4, 0, 3} + }; + GLfloat v[8][3]; + GLint i; + + v[0][0] = v[1][0] = v[2][0] = v[3][0] = -size / 2; + v[4][0] = v[5][0] = v[6][0] = v[7][0] = size / 2; + v[0][1] = v[1][1] = v[4][1] = v[5][1] = -size / 2; + v[2][1] = v[3][1] = v[6][1] = v[7][1] = size / 2; + v[0][2] = v[3][2] = v[4][2] = v[7][2] = -size / 2; + v[1][2] = v[2][2] = v[5][2] = v[6][2] = size / 2; + + for (i = 5; i >= 0; i--) { + glBegin(type); + glNormal3fv(&n[i][0]); + glVertex3fv(&v[faces[i][0]][0]); + glVertex3fv(&v[faces[i][1]][0]); + glVertex3fv(&v[faces[i][2]][0]); + glVertex3fv(&v[faces[i][3]][0]); + glEnd(); + } +} + +void Q3DWidget::wireCube(double size) +{ + drawBox(size, GL_LINE_LOOP); +} + +void Q3DWidget::solidCube(double size) +{ + drawBox(size, GL_QUADS); +} + +void Q3DWidget::doughnut(float r, float R, int nsides, int rings) +{ + int i, j; + GLfloat theta, phi, theta1; + GLfloat cosTheta, sinTheta; + GLfloat cosTheta1, sinTheta1; + GLfloat ringDelta, sideDelta; + + ringDelta = 2.0 * M_PI / rings; + sideDelta = 2.0 * M_PI / nsides; + + theta = 0.0; + cosTheta = 1.0; + sinTheta = 0.0; + for (i = rings - 1; i >= 0; i--) { + theta1 = theta + ringDelta; + cosTheta1 = cos(theta1); + sinTheta1 = sin(theta1); + glBegin(GL_QUAD_STRIP); + phi = 0.0; + for (j = nsides; j >= 0; j--) { + GLfloat cosPhi, sinPhi, dist; + + phi += sideDelta; + cosPhi = cos(phi); + sinPhi = sin(phi); + dist = R + r * cosPhi; + + glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi); + glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi); + glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi); + glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi); + } + glEnd(); + theta = theta1; + cosTheta = cosTheta1; + sinTheta = sinTheta1; + } +} + +void Q3DWidget::wireTorus(double innerRadius, double outerRadius, + int nsides, int rings) +{ + glPushAttrib(GL_POLYGON_BIT); + glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); + doughnut(innerRadius, outerRadius, nsides, rings); + glPopAttrib(); +} + +void Q3DWidget::solidTorus(double innerRadius, double outerRadius, + int nsides, int rings) +{ + doughnut(innerRadius, outerRadius, nsides, rings); +} diff --git a/src/ui/map3D/Q3DWidget.h b/src/ui/map3D/Q3DWidget.h index 5a62f8b0fc1990eae0b3164c3ff237d4af5c905e..756cdcb60eb08a0dbf49c2f0ba86f709b848f42c 100644 --- a/src/ui/map3D/Q3DWidget.h +++ b/src/ui/map3D/Q3DWidget.h @@ -37,6 +37,8 @@ This file is part of the QGROUNDCONTROL project #include #include +//class GLUquadricObj; + enum CameraState { IDLE = 0, @@ -163,6 +165,19 @@ protected: float r2d(float angle); float d2r(float angle); + void Q3DWidget::wireSphere(double radius, int slices, int stacks); + void solidSphere(double radius, int slices, int stacks); + void wireCone(double base, double height, int slices, int stacks); + void solidCone(double base, double height, int slices, int stacks); + void drawBox(float size, GLenum type); + void wireCube(double size); + void solidCube(double size); + void doughnut(float r, float R, int nsides, int rings); + void wireTorus(double innerRadius, double outerRadius, int nsides, int rings); + void solidTorus(double innerRadius, double outerRadius, int nsides, int rings); + + GLUquadricObj* quadObj; + private: // QGLWidget events void initializeGL(void); diff --git a/src/ui/map3D/QGCGlut.h b/src/ui/map3D/QGCGlut.h index 92ecc667b0fc168fcaf6f7457b2181ed9e12d8b9..d7f5851a6f0b6a2c4ed5f9cd74eec526e0eb84ba 100644 --- a/src/ui/map3D/QGCGlut.h +++ b/src/ui/map3D/QGCGlut.h @@ -48,7 +48,10 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc. */ #include -#include "glu.h" +#include "OpenGL/glu.h" + +namespace sgi +{ /* Some files do not define M_PI... */ #ifndef M_PI @@ -597,6 +600,6 @@ glutSolidTetrahedron(void) } /* ENDCENTRY */ - +} #endif // QGCGLUT_H diff --git a/src/ui/map3D/QMap3DWidget.cc b/src/ui/map3D/QMap3DWidget.cc index 6015ac7c99859edec19d7949d80300f7ff1475d9..eeb0b91344108cbdcb20f8a1b74196cd1572e786 100644 --- a/src/ui/map3D/QMap3DWidget.cc +++ b/src/ui/map3D/QMap3DWidget.cc @@ -31,15 +31,10 @@ This file is part of the QGROUNDCONTROL project #include "QMap3DWidget.h" -//#if (defined __APPLE__) & (defined __MACH__) -//#include -//#else -//#include -//#endif #include #include -#include "QGCGlut.h" +//#include "QGCGlut.h" #include "CheetahModel.h" #include "UASManager.h" #include "UASInterface.h" @@ -531,7 +526,15 @@ QMap3DWidget::drawTarget(float x, float y, float z) glTranslatef(targetPosition.x - x, targetPosition.y - y, 0.0f); glColor3f(0.0f, 0.7f, 1.0f); glLineWidth(1.0f); - glutWireSphere(radius, 10, 10); + + // Make sure quad object exists + if(!quadObj) quadObj = gluNewQuadric(); + gluQuadricDrawStyle(quadObj, GLU_LINE); + gluQuadricNormals(quadObj, GLU_SMOOTH); + /* If we ever changed/used the texture or orientation state + of quadObj, we'd need to change it to the defaults here + with gluQuadricTexture and/or gluQuadricOrientation. */ + gluSphere(quadObj, radius, 10, 10); if (expand) {