Commit 229da88d by Kai Westerkamp

for Desktop

parent 450e6140
......@@ -23,6 +23,7 @@ void CubeWidget::initializeGL ()
tesselation = 0;
// enable default shading
home();
showFlat();
glEnable(GL_LIGHTING);
......@@ -42,9 +43,11 @@ void CubeWidget::paintGL ( )
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0.0f,0.0f,-3.0f);
glRotated(45,1,0,0);
glRotated(45,0,1,0);
glTranslatef(0.0f,0.0f,-zoom);
QMatrix4x4 mat = QMatrix4x4();
mat.rotate(*rotation);
glMultMatrixf(mat.data());
GLfloat red[] = {1.0,0.0,0.0};
......@@ -67,12 +70,7 @@ void CubeWidget::paintGL ( )
}
}
setMaterial(magenta);
glVertex3f( 0.5f,-0.5f, 0.5f);
glVertex3f(-0.5f,-0.5f, 0.5f);
glVertex3f(-0.5f,-0.5f,-0.5f);
glVertex3f( 0.5f,-0.5f,-0.5f);
for (float x = -0.5; x < 0.5 ; x+= increment) {
for (float y = -0.5; y < 0.5 ; y+= increment ) {
glVertex3f( x+increment, -0.5f,y+increment);
......@@ -132,7 +130,7 @@ void CubeWidget::resizeGL(int width , int height )
glViewport(0, 0, width, height);
glLoadIdentity();
perspective(45.0,1.0*width/height,0.01,5.0);
perspective(45.0,1.0*width/height,0.01,100.0);
glMatrixMode(GL_MODELVIEW);
}
......@@ -193,6 +191,29 @@ void CubeWidget::setTessellation(int t)
qDebug()<<"Tesselation" << t;
}
void CubeWidget::mousePressEvent(QMouseEvent *event ) {}
void CubeWidget::mouseMoveEvent(QMouseEvent *event ) {}
void CubeWidget::wheelEvent(QWheelEvent *event ) {}
void CubeWidget::home()
{
zoom = 3;
rotation = new QQuaternion();
updateGL();
}
void CubeWidget::mousePressEvent(QMouseEvent *event )
{
}
void CubeWidget::mouseMoveEvent(QMouseEvent *event )
{
//http://web.cse.ohio-state.edu/~hwshen/781/Site/Slides_files/trackball.pdf
}
void CubeWidget::wheelEvent(QWheelEvent *event )
{
if(event->delta()<0)
zoom++;
else
zoom--;
updateGL();
}
......@@ -6,6 +6,8 @@
#include <QGLFunctions>
#include <QOpenGLFunctions>
#include <math.h>
#include <QMatrix4x4>
#include <QQuaternion>
......@@ -31,11 +33,15 @@ public slots:
void showFlat();
void showGouraut();
void showPhong();
void home();
void setTessellation(int t );
private:
int tesselation;
int zoom;
QQuaternion *rotation;
QPoint *lastPos;
void perspective(GLdouble fovy, GLdouble aspect, GLdouble zNear, GLdouble zFar);
void setMaterial(GLfloat *color );
};
......
......@@ -60,6 +60,7 @@ MainWindow::MainWindow(QWidget *parent)
connect(aboutAction,SIGNAL(triggered()),this,SLOT(showAboutBox()));
camHome = new QAction(QIcon(":/img/cam_home.png"),"Cam Home", toolBar);
connect(camHome, SIGNAL(triggered(bool)),mainWidget,SLOT(home()));
slider = new QSlider(Qt::Horizontal,toolBar);
slider->setMinimum( 0 );
......
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