Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
3ce833b4
Commit
3ce833b4
authored
Oct 01, 2010
by
pixhawk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Removed dependency from GLUT
parent
564591c1
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
187 additions
and
15 deletions
+187
-15
qgroundcontrol.pri
qgroundcontrol.pri
+2
-4
qgroundcontrol.pro
qgroundcontrol.pro
+1
-2
Q3DWidget.cc
src/ui/map3D/Q3DWidget.cc
+154
-0
Q3DWidget.h
src/ui/map3D/Q3DWidget.h
+15
-0
QGCGlut.h
src/ui/map3D/QGCGlut.h
+5
-2
QMap3DWidget.cc
src/ui/map3D/QMap3DWidget.cc
+10
-7
No files found.
qgroundcontrol.pri
View file @
3ce833b4
...
...
@@ -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
}
...
...
qgroundcontrol.pro
View file @
3ce833b4
...
...
@@ -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
\
...
...
src/ui/map3D/Q3DWidget.cc
View file @
3ce833b4
...
...
@@ -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
);
}
src/ui/map3D/Q3DWidget.h
View file @
3ce833b4
...
...
@@ -37,6 +37,8 @@ This file is part of the QGROUNDCONTROL project
#include <QtOpenGL>
#include <QtGui>
//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
);
...
...
src/ui/map3D/QGCGlut.h
View file @
3ce833b4
...
...
@@ -48,7 +48,10 @@ OpenGL(TM) is a trademark of Silicon Graphics, Inc.
*/
#include <cmath>
#include "glu.h"
#include "OpenGL/glu.h"
namespace
sgi
{
/* Some <math.h> files do not define M_PI... */
#ifndef M_PI
...
...
@@ -597,6 +600,6 @@ glutSolidTetrahedron(void)
}
/* ENDCENTRY */
}
#endif // QGCGLUT_H
src/ui/map3D/QMap3DWidget.cc
View file @
3ce833b4
...
...
@@ -31,15 +31,10 @@ This file is part of the QGROUNDCONTROL project
#include "QMap3DWidget.h"
//#if (defined __APPLE__) & (defined __MACH__)
//#include <GLUT/glut.h>
//#else
//#include <GL/glut.h>
//#endif
#include <QCheckBox>
#include <sys/time.h>
#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.0
f
);
glColor3f
(
0.0
f
,
0.7
f
,
1.0
f
);
glLineWidth
(
1.0
f
);
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
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment