Commit 58478b68 by Alisa Jung

compiling. well. iahösrogu a@

parent dd531f25
...@@ -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.9f, 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();
} }
...@@ -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();
}
...@@ -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;
......
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