Browse Source

gluunproject example

develop
Robin Thoni 8 years ago
parent
commit
bfc62e723b
2 changed files with 19 additions and 4 deletions
  1. 18
    4
      TheGame/renderwidget.cpp
  2. 1
    0
      TheGame/renderwidget.h

+ 18
- 4
TheGame/renderwidget.cpp View File

1
 #include "renderwidget.h"
1
 #include "renderwidget.h"
2
+#include <GL/glu.h>
2
 #include <QTimer>
3
 #include <QTimer>
3
 #include <math.h>
4
 #include <math.h>
4
 #include <QDebug>
5
 #include <QDebug>
19
     cube->move(Vector3D(0, 1, 0));
20
     cube->move(Vector3D(0, 1, 0));
20
     _engine->addEntity(cube);
21
     _engine->addEntity(cube);
21
     _engine->addEntity(new UGEEntityAxes(_engine));
22
     _engine->addEntity(new UGEEntityAxes(_engine));
22
-    setMouseTracking(false);
23
+    setMouseTracking(true);
23
     setFocusPolicy(Qt::StrongFocus);
24
     setFocusPolicy(Qt::StrongFocus);
24
 }
25
 }
25
 
26
 
42
                 );
43
                 );
43
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
44
     _device->lookAt(center, Vector3D(0.0f, 0.0f, 0.0f));
44
     _engine->draw();
45
     _engine->draw();
46
+//    _device->drawLine(ColorVector3D(Qt::black, 0, 0, 0), ColorVector3D(Qt::black, wx, wy, wz));
45
 }
47
 }
46
 
48
 
47
 void RenderWidget::resizeGL(int width, int height)
49
 void RenderWidget::resizeGL(int width, int height)
67
 
69
 
68
 void RenderWidget::mouseMoveEvent(QMouseEvent *event)
70
 void RenderWidget::mouseMoveEvent(QMouseEvent *event)
69
 {
71
 {
70
-    QPoint diff = event->pos() - _lastPoint;
72
+    if (event->buttons() & Qt::LeftButton) {
73
+        QPoint diff = event->pos() - _lastPoint;
71
 
74
 
72
-    rotate(-diff.x(), -diff.y());
75
+        rotate(-diff.x(), -diff.y());
73
 
76
 
74
-    _lastPoint = event->pos();
77
+        _lastPoint = event->pos();
78
+    }
79
+//    double modelMatrix[16];
80
+//    double projMatrix[16];
81
+//    GLint viewport[4];
82
+//    glGetDoublev(GL_MODELVIEW_MATRIX, modelMatrix);
83
+//    glGetDoublev(GL_PROJECTION_MATRIX, projMatrix);
84
+//    glGetIntegerv(GL_VIEWPORT, viewport);
85
+
86
+//    gluUnProject(event->x(), height() - event->y(), 0, modelMatrix, projMatrix, viewport, &wx, &wy, &wz);
87
+//    qDebug() << event->pos() << wx << wy << wz;
88
+//    update();
75
 }
89
 }
76
 
90
 
77
 void RenderWidget::wheelEvent(QWheelEvent *event)
91
 void RenderWidget::wheelEvent(QWheelEvent *event)

+ 1
- 0
TheGame/renderwidget.h View File

49
 
49
 
50
     bool _reverse;
50
     bool _reverse;
51
 
51
 
52
+//    double wx,wy,wz;
52
 };
53
 };
53
 
54
 
54
 #endif // RENDERWIDGET_H
55
 #endif // RENDERWIDGET_H

Loading…
Cancel
Save