Commit 58478b68 by Alisa Jung

compiling. well. iahösrogu a@

parent dd531f25
......@@ -24,94 +24,94 @@ void Box::drawPrimitive(){
glMaterialfv(GL_FRONT, GL_SPECULAR, specularColor);
glMaterialfv(GL_FRONT, GL_SHININESS, shininess);
// //vorne // z-Achse
// // glColor3f(0,0,1);//blau //alt und doof
// GLfloat blue[] = { 0, 0, 1 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, blue);
// glNormal3f(0, 0, 1);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// for (int j = 0; j < tesselation; j++){
// 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 + 1), 0.5);
// glVertex3f(0.5 - dist*i, 0.5 - dist*(j + 1), 0.5);
// }
// }
// glEnd();
// //oben // y-Achse
// GLfloat green[] = { 0, 1, 0 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, green);
// glNormal3f(0, 1, 0);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// 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);
// glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*j);
// glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*(j + 1));
// }
// }
// glEnd();
// //rechts //x-Achse
// GLfloat red[] = { 1, 0, 0 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, red);
// glNormal3f(1, 0, 0);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// 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 + 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, 0.5 - dist*(j + 1));
// }
// }
// glEnd();
// //hinten // z-Achse
// GLfloat yellow[] = { 1, 0.9f, 0 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow);
// glNormal3f(0, 0, -1);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// 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 + 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, 0.5 - dist*j, -0.5);//1
// }
// }
// glEnd();
// //links
// GLfloat cyan[] = { 0, 1, 1 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, cyan);
// glNormal3f(-1, 0, 0);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// 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 + 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, 0.5 - dist*j);
// }
// }
// glEnd();
// //unten //-y
// GLfloat magenta[] = { 1, 0, 1 };
// glMaterialfv(GL_FRONT, GL_DIFFUSE, magenta);
// glNormal3f(0, -1, 0);
// glBegin(GL_QUADS);
// for (int i = 0; i < tesselation; i++){
// 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);
// 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));
// }
// }
// glEnd();
//vorne // z-Achse
// glColor3f(0,0,1);//blau //alt und doof
GLfloat blue[] = { 0, 0, 1 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, blue);
glNormal3f(0, 0, 1);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
for (int j = 0; j < tesselation; j++){
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 + 1), 0.5);
glVertex3f(0.5 - dist*i, 0.5 - dist*(j + 1), 0.5);
}
}
glEnd();
//oben // y-Achse
GLfloat green[] = { 0, 1, 0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, green);
glNormal3f(0, 1, 0);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
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);
glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*j);
glVertex3f(0.5 - dist*i, 0.5, 0.5 - dist*(j + 1));
}
}
glEnd();
//rechts //x-Achse
GLfloat red[] = { 1, 0, 0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, red);
glNormal3f(1, 0, 0);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
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 + 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, 0.5 - dist*(j + 1));
}
}
glEnd();
//hinten // z-Achse
GLfloat yellow[] = { 1, 0.9f, 0 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, yellow);
glNormal3f(0, 0, -1);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
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 + 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, 0.5 - dist*j, -0.5);//1
}
}
glEnd();
//links
GLfloat cyan[] = { 0, 1, 1 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, cyan);
glNormal3f(-1, 0, 0);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
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 + 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, 0.5 - dist*j);
}
}
glEnd();
//unten //-y
GLfloat magenta[] = { 1, 0, 1 };
glMaterialfv(GL_FRONT, GL_DIFFUSE, magenta);
glNormal3f(0, -1, 0);
glBegin(GL_QUADS);
for (int i = 0; i < tesselation; i++){
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);
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));
}
}
glEnd();
}
......@@ -22,3 +22,23 @@ QQuaternion RigidBodyTransformation::getRotation(){
void RigidBodyTransformation::setRotation(QQuaternion 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();
}
......@@ -13,6 +13,8 @@ public:
void setRotation(QQuaternion newRotation);
QQuaternion getRotation();
void drawChild();
private :
//translation
double tx, ty, tz;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment