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
58478b68
Commit
58478b68
authored
Nov 19, 2015
by
Alisa Jung
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
compiling. well. iahösrogu a@
parent
dd531f25
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
112 additions
and
90 deletions
+112
-90
box.cpp
helloqube/box.cpp
+90
-90
rigidbodytransformation.cpp
helloqube/rigidbodytransformation.cpp
+20
-0
rigidbodytransformation.h
helloqube/rigidbodytransformation.h
+2
-0
No files found.
helloqube/box.cpp
View file @
58478b68
...
@@ -24,94 +24,94 @@ void Box::drawPrimitive(){
...
@@ -24,94 +24,94 @@ void Box::drawPrimitive(){
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SPECULAR
,
specularColor
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
glMaterialfv
(
GL_FRONT
,
GL_SHININESS
,
shininess
);
//
//vorne // z-Achse
//vorne // z-Achse
//
// glColor3f(0,0,1);//blau //alt und doof
// glColor3f(0,0,1);//blau //alt und doof
//
GLfloat blue[] = { 0, 0, 1 };
GLfloat
blue
[]
=
{
0
,
0
,
1
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, blue);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
blue
);
//
glNormal3f(0, 0, 1);
glNormal3f
(
0
,
0
,
1
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(0.5 - dist*i, 0.5 - dist*j, 0.5);
glVertex3f
(
0.5
-
dist
*
i
,
0.5
-
dist
*
j
,
0.5
);
//
glVertex3f(0.5 - dist*(i + 1), 0.5 - dist*j, 0.5);
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
j
,
0.5
);
//
glVertex3f(0.5 - dist*(i + 1), 0.5 - dist*(j + 1), 0.5);
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
(
j
+
1
),
0.5
);
//
glVertex3f(0.5 - dist*i, 0.5 - dist*(j + 1), 0.5);
glVertex3f
(
0.5
-
dist
*
i
,
0.5
-
dist
*
(
j
+
1
),
0.5
);
//
}
}
//
}
}
//
glEnd();
glEnd
();
//
//oben // y-Achse
//oben // y-Achse
//
GLfloat green[] = { 0, 1, 0 };
GLfloat
green
[]
=
{
0
,
1
,
0
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, green);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
green
);
//
glNormal3f(0, 1, 0);
glNormal3f
(
0
,
1
,
0
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(0.5 - dist*(i + 1), 0.5, 0.5 - dist*(j + 1));
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
,
0.5
-
dist
*
(
j
+
1
));
//
glVertex3f(0.5 - dist*(i + 1), 0.5, 0.5 - dist*j);
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
,
0.5
-
dist
*
j
);
//
glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*j);
glVertex3f
(
0.5
-
dist
*
i
,
0.5
,
0.5
-
dist
*
j
);
//
glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*(j + 1));
glVertex3f
(
0.5
-
dist
*
i
,
0.5
,
0.5
-
dist
*
(
j
+
1
));
//
}
}
//
}
}
//
glEnd();
glEnd
();
//
//rechts //x-Achse
//rechts //x-Achse
//
GLfloat red[] = { 1, 0, 0 };
GLfloat
red
[]
=
{
1
,
0
,
0
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, red);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
red
);
//
glNormal3f(1, 0, 0);
glNormal3f
(
1
,
0
,
0
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(0.5, 0.5 - dist*i, 0.5 - dist*j);
glVertex3f
(
0.5
,
0.5
-
dist
*
i
,
0.5
-
dist
*
j
);
//
glVertex3f(0.5, 0.5 - dist*(i + 1), 0.5 - dist*j);
glVertex3f
(
0.5
,
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
j
);
//
glVertex3f(0.5, 0.5 - dist*(i + 1), 0.5 - dist*(j + 1));
glVertex3f
(
0.5
,
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
(
j
+
1
));
//
glVertex3f(0.5, 0.5 - dist*i, 0.5 - dist*(j + 1));
glVertex3f
(
0.5
,
0.5
-
dist
*
i
,
0.5
-
dist
*
(
j
+
1
));
//
}
}
//
}
}
//
glEnd();
glEnd
();
//
//hinten // z-Achse
//hinten // z-Achse
//
GLfloat yellow[] = { 1, 0.9f, 0 };
GLfloat
yellow
[]
=
{
1
,
0.9
f
,
0
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
yellow
);
//
glNormal3f(0, 0, -1);
glNormal3f
(
0
,
0
,
-
1
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(0.5 - dist*i, 0.5 - dist*(j + 1), -0.5);//4
glVertex3f
(
0.5
-
dist
*
i
,
0.5
-
dist
*
(
j
+
1
),
-
0.5
);
//4
//
glVertex3f(0.5 - dist*(i + 1), 0.5 - dist*(j + 1), -0.5);//3
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
(
j
+
1
),
-
0.5
);
//3
//
glVertex3f(0.5 - dist*(i + 1), 0.5 - dist*j, -0.5);//2
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
j
,
-
0.5
);
//2
//
glVertex3f(0.5 - dist*i, 0.5 - dist*j, -0.5);//1
glVertex3f
(
0.5
-
dist
*
i
,
0.5
-
dist
*
j
,
-
0.5
);
//1
//
}
}
//
}
}
//
glEnd();
glEnd
();
//
//links
//links
//
GLfloat cyan[] = { 0, 1, 1 };
GLfloat
cyan
[]
=
{
0
,
1
,
1
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, cyan);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
cyan
);
//
glNormal3f(-1, 0, 0);
glNormal3f
(
-
1
,
0
,
0
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(-0.5, 0.5 - dist*i, 0.5 - dist*(j + 1));
glVertex3f
(
-
0.5
,
0.5
-
dist
*
i
,
0.5
-
dist
*
(
j
+
1
));
//
glVertex3f(-0.5, 0.5 - dist*(i + 1), 0.5 - dist*(j + 1));
glVertex3f
(
-
0.5
,
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
(
j
+
1
));
//
glVertex3f(-0.5, 0.5 - dist*(i + 1), 0.5 - dist*j);
glVertex3f
(
-
0.5
,
0.5
-
dist
*
(
i
+
1
),
0.5
-
dist
*
j
);
//
glVertex3f(-0.5, 0.5 - dist*i, 0.5 - dist*j);
glVertex3f
(
-
0.5
,
0.5
-
dist
*
i
,
0.5
-
dist
*
j
);
//
}
}
//
}
}
//
glEnd();
glEnd
();
//
//unten //-y
//unten //-y
//
GLfloat magenta[] = { 1, 0, 1 };
GLfloat
magenta
[]
=
{
1
,
0
,
1
};
//
glMaterialfv(GL_FRONT, GL_DIFFUSE, magenta);
glMaterialfv
(
GL_FRONT
,
GL_DIFFUSE
,
magenta
);
//
glNormal3f(0, -1, 0);
glNormal3f
(
0
,
-
1
,
0
);
//
glBegin(GL_QUADS);
glBegin
(
GL_QUADS
);
//
for (int i = 0; i < tesselation; i++){
for
(
int
i
=
0
;
i
<
tesselation
;
i
++
){
//
for (int j = 0; j < tesselation; j++){
for
(
int
j
=
0
;
j
<
tesselation
;
j
++
){
//
glVertex3f(0.5 - dist*i, -0.5, 0.5 - dist*(j + 1));
glVertex3f
(
0.5
-
dist
*
i
,
-
0.5
,
0.5
-
dist
*
(
j
+
1
));
//
glVertex3f(0.5 - dist*i, -0.5, 0.5 - dist*j);
glVertex3f
(
0.5
-
dist
*
i
,
-
0.5
,
0.5
-
dist
*
j
);
//
glVertex3f(0.5 - dist*(i + 1), -0.5, 0.5 - dist*j);
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
-
0.5
,
0.5
-
dist
*
j
);
//
glVertex3f(0.5 - dist*(i + 1), -0.5, 0.5 - dist*(j + 1));
glVertex3f
(
0.5
-
dist
*
(
i
+
1
),
-
0.5
,
0.5
-
dist
*
(
j
+
1
));
//
}
}
//
}
}
//
glEnd();
glEnd
();
}
}
helloqube/rigidbodytransformation.cpp
View file @
58478b68
...
@@ -22,3 +22,23 @@ QQuaternion RigidBodyTransformation::getRotation(){
...
@@ -22,3 +22,23 @@ QQuaternion RigidBodyTransformation::getRotation(){
void
RigidBodyTransformation
::
setRotation
(
QQuaternion
newRotation
){
void
RigidBodyTransformation
::
setRotation
(
QQuaternion
newRotation
){
rotation
=
newRotation
;
rotation
=
newRotation
;
}
}
void
RigidBodyTransformation
::
drawChild
(){
//should be easily extendable to drawChildren
//set up transform
//for cube rotation
QMatrix4x4
m
=
QMatrix4x4
();
m
.
rotate
(
rotation
);
//for cube translation
QMatrix4x4
translateRot1
=
QMatrix4x4
(
1
,
0
,
0
,
tx
,
0
,
1
,
0
,
ty
,
0
,
0
,
1
,
tz
,
0
,
0
,
0
,
1
);
//stack matrices
glMultMatrixf
(
translateRot1
.
data
());
//Punkte zurück schieben damit rotation um qube zentrum ist
glMultMatrixf
(
m
.
data
());
//maybe a foreach later on?
child
.
drawPrimitive
();
}
helloqube/rigidbodytransformation.h
View file @
58478b68
...
@@ -13,6 +13,8 @@ public:
...
@@ -13,6 +13,8 @@ public:
void
setRotation
(
QQuaternion
newRotation
);
void
setRotation
(
QQuaternion
newRotation
);
QQuaternion
getRotation
();
QQuaternion
getRotation
();
void
drawChild
();
private
:
private
:
//translation
//translation
double
tx
,
ty
,
tz
;
double
tx
,
ty
,
tz
;
...
...
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