Commit d093f154 by Alisa Jung

rotation-translate-Verschiebung gelöst: verschieben->rotieren->zurückschieben

Specular angemacht. tut.
parent 98dbd7d9
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE QtCreatorProject> <!DOCTYPE QtCreatorProject>
<!-- Written by QtCreator 3.5.1, 2015-11-01T13:07:11. --> <!-- Written by QtCreator 3.5.1, 2015-11-01T21:26:19. -->
<qtcreator> <qtcreator>
<data> <data>
<variable>EnvironmentId</variable> <variable>EnvironmentId</variable>
......
...@@ -98,6 +98,7 @@ MainWindow::MainWindow(QWidget *parent) ...@@ -98,6 +98,7 @@ MainWindow::MainWindow(QWidget *parent)
//reset Camera button //reset Camera button
resetCameraAction = new QAction("Reset Camera",toolBar); resetCameraAction = new QAction("Reset Camera",toolBar);
resetCameraAction->setIcon(QIcon(":/img/cam_home.png"));
connect(resetCameraAction,SIGNAL(triggered(bool)),myGLWidget,SLOT(resetCamera())); connect(resetCameraAction,SIGNAL(triggered(bool)),myGLWidget,SLOT(resetCamera()));
toolBar->addAction(resetCameraAction); toolBar->addAction(resetCameraAction);
......
...@@ -46,7 +46,9 @@ void MyGLWidget::initializeGL() ...@@ -46,7 +46,9 @@ void MyGLWidget::initializeGL()
glClearColor(0.0, 0.0, 0.0, 0.0);//TODO brauch ich das? glClearColor(0.0, 0.0, 0.0, 0.0);//TODO brauch ich das?
glEnable(GL_DEPTH_TEST);//TODO warum genau? glEnable(GL_DEPTH_TEST);//TODO warum genau?
// glEnable(GL_CULL_FACE);//backface culling shadeFlatSlot();//set up flat shading
// glEnable(GL_CULL_FACE);//backface culling.
// glCullFace(GL_BACK);//backface culling // glCullFace(GL_BACK);//backface culling
// glEnable(GL_COLOR_MATERIAL); //Habe ich für glColor3f gebraucht. Wieder raus für Material. //In order to use both color and lighting you must activate openGL color materials // glEnable(GL_COLOR_MATERIAL); //Habe ich für glColor3f gebraucht. Wieder raus für Material. //In order to use both color and lighting you must activate openGL color materials
...@@ -73,24 +75,6 @@ example, the background color. ...@@ -73,24 +75,6 @@ example, the background color.
*/ */
static GLfloat lightPosition[4] = {0.5, 0.0, 2.0, 1.0}; static GLfloat lightPosition[4] = {0.5, 0.0, 2.0, 1.0};
glLightfv(GL_LIGHT0,GL_POSITION,lightPosition);//set Position of light source. glLightfv(GL_LIGHT0,GL_POSITION,lightPosition);//set Position of light source.
//HelloGL Example:
/*
qglClearColor(qtPurple.dark());
logo = new QtLogo(this, 64);
logo->setColor(qtGreen.dark());
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glShadeModel(GL_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_MULTISAMPLE);
static GLfloat lightPosition[4] = { 0.5, 5.0, 7.0, 1.0 };
glLightfv(GL_LIGHT0, GL_POSITION, lightPosition);
*/
} }
void MyGLWidget::paintGL(){ void MyGLWidget::paintGL(){
...@@ -105,20 +89,25 @@ void MyGLWidget::paintGL(){ ...@@ -105,20 +89,25 @@ void MyGLWidget::paintGL(){
double qubeWidth = 1.0; double qubeWidth = 1.0;
double dist = qubeWidth/(double)tesselation; double dist = qubeWidth/(double)tesselation;
QMatrix4x4 translateRot1 = QMatrix4x4(1,0,0,tx,0,1,0,ty,0,0,1,0,0,0,0,1);
QMatrix4x4 translateRot2 = QMatrix4x4(1,0,0,-tx,0,1,0,-ty,0,0,1,0,0,0,0,1);
//for cube rotation //for cube rotation
QMatrix4x4 m = QMatrix4x4(); QMatrix4x4 m = QMatrix4x4();
m.rotate(qubeRotationQuaternion); m.rotate(qubeRotationQuaternion);
glMultMatrixf(translateRot1.data());//Punkte ins zentrum verschieben damit rotation um qube zentrum ist
glMultMatrixf(m.data()); glMultMatrixf(m.data());
glMultMatrixf(translateRot2.data());//Punkte zurück verschieben
//4.1.1 Unit Qube + Tesselation + Diffuse Material //4.1.1 Unit Qube + Tesselation + Diffuse Material
{ {
glBegin(GL_QUADS); glBegin(GL_QUADS);
//TODO später einfügen. GLfloat specularColor[] = {1,1,1};
// GLfloat specularColor[] = {1,1,1}; GLfloat shininess[] = {128};//specular exponent
// GLfloat shininess[] = {100};//specular exponent 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 // glColor3f(0,0,1);//blau
......
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