Commit 4332f836 by Alisa Jung

fertig bis trackball

parent 3ebc80d3
...@@ -95,6 +95,12 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -95,6 +95,12 @@ MainWindow::MainWindow(QWidget *parent)
tesselationSlider->setValue(1); tesselationSlider->setValue(1);
connect(tesselationSlider,SIGNAL(valueChanged(int)),myGLWidget,SLOT(setTessellation(int))); connect(tesselationSlider,SIGNAL(valueChanged(int)),myGLWidget,SLOT(setTessellation(int)));
toolBar->addWidget(tesselationSlider); toolBar->addWidget(tesselationSlider);
//reset Camera button
resetCameraAction = new QAction("Reset Camera",toolBar);
connect(resetCameraAction,SIGNAL(triggered(bool)),myGLWidget,SLOT(resetCamera()));
toolBar->addAction(resetCameraAction);
} }
MainWindow::~MainWindow() MainWindow::~MainWindow()
......
...@@ -47,6 +47,8 @@ private: ...@@ -47,6 +47,8 @@ private:
QAction *shadePhongAction; QAction *shadePhongAction;
QActionGroup *shaderGroup; QActionGroup *shaderGroup;
QAction *resetCameraAction;
//Widgets //Widgets
MyGLWidget *myGLWidget; MyGLWidget *myGLWidget;
......
...@@ -5,6 +5,10 @@ ...@@ -5,6 +5,10 @@
#include <gl/GLU.h> #include <gl/GLU.h>
#include <QDebug> #include <QDebug>
#include <QWheelEvent> #include <QWheelEvent>
#include <QQuaternion>
#include <QMatrix4x4>
#include <math.h>
#include <QVector3D>
class MyGLWidget : public QGLWidget class MyGLWidget : public QGLWidget
{ {
...@@ -28,11 +32,22 @@ protected: ...@@ -28,11 +32,22 @@ protected:
void wheelEvent(QWheelEvent *event); void wheelEvent(QWheelEvent *event);
private: private:
//tesselation slider
int tesselation; int tesselation;
//zoom camera
const double cameraZoomDefault = -5;
double cameraZoom; double cameraZoom;
//translate camera
QPoint clickStartPosition; QPoint clickStartPosition;
bool rightButtonPressed; bool rightButtonPressed;
double translationX, translationY; double tx, ty;
//rotate cube
bool leftButtonPressed;
QQuaternion qubeRotationQuaternion;
QPoint screenCenter;//Center of screen in pixel coordinates
public slots: public slots:
...@@ -42,6 +57,7 @@ public slots: ...@@ -42,6 +57,7 @@ public slots:
void shadeGouraudSlot(); void shadeGouraudSlot();
void shadePhongSlot(); void shadePhongSlot();
void setTessellation(int t); void setTessellation(int t);
void resetCamera();
}; };
#endif // GLWIDGET_H #endif // GLWIDGET_H
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