fixed some issues

This commit is contained in:
2017-03-20 09:07:18 +01:00
parent 62d4a278e9
commit 7ac8e7bac2
7 changed files with 146 additions and 69 deletions

View File

@@ -38,21 +38,21 @@ void MapView3D::initializeGL() {
// culling, lighting, depth-test, ...
glEnable(GL_DEPTH_TEST);
glShadeModel(GL_SMOOTH);
//glShadeModel(GL_SMOOTH);
glEnable(GL_MULTISAMPLE);
// glEnable(GL_MULTISAMPLE);
// glEnable(GL_LINE_SMOOTH);
glEnable(GL_LIGHTING);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHT1);
//glEnable(GL_LIGHT1);
GLfloat light0_position [] = {+50, 50, +50, 1};
GLfloat light1_position [] = {-50, 50, -50, 1};
// GLfloat light0_position [] = {+50, 50, +50, 1};
// GLfloat light1_position [] = {-50, 50, -50, 1};
glLightfv ( GL_LIGHT0, GL_POSITION, light0_position );
glLightfv ( GL_LIGHT1, GL_POSITION, light1_position );
// glLightfv ( GL_LIGHT0, GL_POSITION, light0_position );
// glLightfv ( GL_LIGHT1, GL_POSITION, light1_position );
GLfloat light_diffuse []={ 0.7, 0.7, 0.7, 1.0 };
glLightfv ( GL_LIGHT0, GL_DIFFUSE, light_diffuse );
@@ -81,6 +81,12 @@ void MapView3D::paintGL() {
glLoadIdentity();
glScalef(+1, -1, +1);
// 3) scale
glScalef(scale.x, scale.y, scale.z);
@@ -93,8 +99,12 @@ void MapView3D::paintGL() {
glTranslatef(center.x, center.z, center.y);
// 0) swap the y axis
glScalef(+1, -1, +1);
//glScalef(+1, -1, +1);
GLfloat light0_position [] = {100, 50, 100, 1};
glLightfv ( GL_LIGHT0, GL_POSITION, light0_position );
GLfloat light1_position [] = {0, 50, 0, 1};
glLightfv ( GL_LIGHT1, GL_POSITION, light1_position );
// // 1) translate into center
@@ -142,10 +152,13 @@ void MapView3D::mouseMoveEvent(QMouseEvent* e) {
float dx = mouse.x - e->x();
float dy = mouse.y - e->y();
if (mouse.btn == 1) {
//rot.z += dx/2.0f; // upward
//rot.x -= dy/2.0f;
rot.z += dx/2.0f; // upward
rot.x -= dy/2.0f;
rot.x += dy/2.0f;
} else if (mouse.btn == 4) {
Point3 vec(-dx / width() * 2 * viewport.size.x, 0, +dy / height() * 2 * viewport.size.y);
//Point3 vec(-dx / width() * 2 * viewport.size.x, 0, +dy / height() * 2 * viewport.size.y);
Point3 vec(-dx / width() * 2 * viewport.size.x, 0, -dy / height() * 2 * viewport.size.y);
vec = vec.rot(rot.x/180*M_PI, rot.y/180*M_PI, rot.z/180*M_PI);
vec /= scale;
center += vec;