Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
G
grapa_alisa
Project
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Alisa Jung
grapa_alisa
Commits
070fb195
Commit
070fb195
authored
Nov 21, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
cylinder and cone
parent
e41ab5d8
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
60 additions
and
13 deletions
+60
-13
myglwidget.cpp
helloqube/myglwidget.cpp
+42
-7
scenegraph.cpp
helloqube/scenegraph.cpp
+18
-6
No files found.
helloqube/myglwidget.cpp
View file @
070fb195
...
...
@@ -172,10 +172,10 @@ void MyGLWidget::paintGL(){
Primitive
*
p
=
(
*
i
)
->
getChild
();
int
tesselation
=
p
->
getTesselation
();
Primitive
::
Type
type
=
p
->
getType
();
qDebug
()
<<
"draw type "
<<
type
;
if
(
type
==
Primitive
::
Type
::
SPHERE
){
drawSphere
(
tesselation
);
}
else
if
(
type
==
Primitive
::
Type
::
BOX
){
}
else
if
(
type
==
Primitive
::
Type
::
BOX
){
drawBox
(
tesselation
);
}
else
if
(
type
==
Primitive
::
Type
::
CYLINDER
){
drawCylinder
(
tesselation
);
...
...
@@ -336,8 +336,6 @@ void MyGLWidget::drawSphere(int tesselation){
GLUquadric
*
q
=
gluNewQuadric
();
// gluQuadricDrawStyle(q, GLU_FILL);
gluSphere
(
q
,
0.5
,
tesselation
,
tesselation
);
glEnd
();
}
...
...
@@ -346,8 +344,6 @@ void MyGLWidget::drawBox(int tesselation){
double
qubeWidth
=
1.0
;
double
dist
=
qubeWidth
/
(
double
)
tesselation
;
//4.1.1 Unit Qube + Tesselation + Diffuse Material
...
...
@@ -449,11 +445,50 @@ void MyGLWidget::drawBox(int tesselation){
}
void
MyGLWidget
::
drawCylinder
(
int
tesselation
){
//Todo
qDebug
(
"draw cylinder"
);
GLfloat
specularColor
[]
=
{
0.3
,
0.5
,
0.5
};
GLfloat
shininess
[]
=
{
120
};
//specular exponent
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
GLfloat
cylinderColor
[]
=
{
0.8
,
0.2
,
0.5
};
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
cylinderColor
);
glNormal3f
(
0
,
0
,
1
);
glBegin
(
GL_LINE_LOOP
);
GLUquadric
*
quadric
=
gluNewQuadric
();
gluQuadricDrawStyle
(
quadric
,
GLU_FILL
);
gluCylinder
(
quadric
,
0.5
,
0.5
,
1
,
tesselation
,
tesselation
);
gluQuadricOrientation
(
quadric
,
GLU_INSIDE
);
gluDisk
(
quadric
,
0.0
,
0.5
,
tesselation
,
1
);
glTranslatef
(
0
,
0
,
1
);
gluQuadricOrientation
(
quadric
,
GLU_OUTSIDE
);
gluDisk
(
quadric
,
0.0
,
0.5
,
tesselation
,
1
);
gluDeleteQuadric
(
quadric
);
glEnd
();
}
void
MyGLWidget
::
drawCone
(
int
tesselation
){
qDebug
(
"draw cone"
);
GLfloat
specularColor
[]
=
{
0.3
,
0.5
,
0.5
};
GLfloat
shininess
[]
=
{
120
};
//specular exponent
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
GLfloat
coneColor
[]
=
{
0.8
,
0.8
,
0
};
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
coneColor
);
glNormal3f
(
0
,
0
,
1
);
glBegin
(
GL_LINE_LOOP
);
GLUquadric
*
quadric
=
gluNewQuadric
();
gluQuadricDrawStyle
(
quadric
,
GLU_FILL
);
gluCylinder
(
quadric
,
0.5
,
0
,
1
,
tesselation
,
1
);
gluQuadricOrientation
(
quadric
,
GLU_INSIDE
);
gluDisk
(
quadric
,
0.0
,
0.5
,
tesselation
,
1
);
gluQuadricOrientation
(
quadric
,
GLU_OUTSIDE
);
gluDeleteQuadric
(
quadric
);
glEnd
();
}
void
MyGLWidget
::
drawTorus
(
int
tesselation
){
...
...
helloqube/scenegraph.cpp
View file @
070fb195
...
...
@@ -45,18 +45,30 @@ RigidBodyTransformation* SceneGraph::addBox(int tesselation){
}
RigidBodyTransformation
*
SceneGraph
::
addCylinder
(
int
tesselation
){
qDebug
(
"TODO add cylinder to scenegraph"
);
return
addBox
(
1
);
nextCylName
=
"Cylinder "
+
cylIndex
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextCylName
,
tesselation
+
2
,
Primitive
::
Type
::
CYLINDER
);
idCounter
++
;
cylIndex
++
;
qDebug
(
"added Cylinder to scenegraph"
);
return
addPrimitive
(
p
);
}
RigidBodyTransformation
*
SceneGraph
::
addCone
(
int
tesselation
){
qDebug
(
"TODO add cone to scenegraph"
);
return
addBox
(
tesselation
);
nextConeName
=
"Cone "
+
coneIndex
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextConeName
,
tesselation
+
2
,
Primitive
::
Type
::
CONE
);
idCounter
++
;
coneIndex
++
;
return
addPrimitive
(
p
);
}
RigidBodyTransformation
*
SceneGraph
::
addTorus
(
int
tesselation
){
qDebug
(
"TODO add torus to scenegraph"
);
return
addBox
(
1
);
nextTorusName
=
"Torus "
+
torusIndex
;
Primitive
*
p
=
new
Primitive
(
idCounter
,
nextTorusName
,
tesselation
,
Primitive
::
Type
::
TORUS
);
idCounter
++
;
torusIndex
++
;
return
addPrimitive
(
p
);
}
RigidBodyTransformation
*
SceneGraph
::
addPrimitive
(
Primitive
*
p
){
...
...
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