Commit 5aeebcb0 by Alisa Jung

added cube manipulation

parent 7c902f1c
......@@ -12,8 +12,7 @@ MyGLWidget::MyGLWidget(int index, Controller* c, bool isPerspective, QQuaternion
qubeRotation = QQuaternion();
cameraRotation = initialRotation;
cameraStartRotation = initialRotation;
translatex = 0;
translatey = 0;
cubeTranslation = QVector3D(0,0,0);
camRotCenter = QVector3D(0,0,0);
cameraZoom = cameraZoomDefault;
clickStartPosition = QPoint(0,0);
......@@ -142,7 +141,7 @@ void MyGLWidget::paintGL(){
m.rotate(qubeRotation);
//for cube translation
QMatrix4x4 translateRot1 = QMatrix4x4(1,0,0,translatex,0,1,0,translatey,0,0,1,0,0,0,0,1);
QMatrix4x4 translateRot1 = QMatrix4x4(1,0,0,cubeTranslation.x(),0,1,0,cubeTranslation.y(),0,0,1,cubeTranslation.z(),0,0,0,1);
QMatrix4x4 zoomCameraMatrix = QMatrix4x4(1,0,0,0,0,1,0,0,0,0,1,cameraZoom,0,0,0,1);
......@@ -153,9 +152,6 @@ void MyGLWidget::paintGL(){
// glTranslatef(cameraX,cameraY,0);//TODO anständig machen, kamerarotation fehlt noch.
//stack matrices
// glMultMatrixf(translateRot1.data());//Punkte zurück schieben damit rotation um qube zentrum ist
// glMultMatrixf(m.data());
//So scheint das zumindest für die Kamera zu funktionieren:
......@@ -167,6 +163,12 @@ void MyGLWidget::paintGL(){
glTranslatef(camRotCenter.x(),camRotCenter.y(),camRotCenter.z());
//stack matrices
glMultMatrixf(translateRot1.data());//Punkte zurück schieben damit rotation um qube zentrum ist
glMultMatrixf(m.data());
//tesselation
double qubeWidth = 1.0;
double dist = qubeWidth/(double)tesselation;
......@@ -319,8 +321,7 @@ void MyGLWidget::translateCamera(double xDiff, double yDiff, double zDiff)
}
void MyGLWidget::translateQube(double xDiff, double yDiff){
translatex += xDiff;
translatey += yDiff;
cubeTranslation += cameraRotation.conjugate().rotatedVector(QVector3D(xDiff, yDiff,0));
updateGL();
}
......@@ -399,8 +400,7 @@ void MyGLWidget::setTessellation(int t){
void MyGLWidget::resetCamera(){
qubeRotation = QQuaternion();
translatex = 0;
translatey = 0;
cubeTranslation = QVector3D(0,0,0);
camRotCenter = QVector3D(0,0,0);
cameraZoom = cameraZoomDefault;
cameraRotation = cameraStartRotation;
......
......@@ -70,7 +70,7 @@ private:
//translate camera
QPoint clickStartPosition;
bool rightButtonPressed;
double translatex, translatey;
QVector3D cubeTranslation;
//rotate cube
bool leftButtonPressed;
......
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