blob: 5be1c533aac2ff0a102d5b77b68145d8bf768c60 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#ifndef OPENGLSCENE_H
#define OPENGLSCENE_H
#include "point3d.h"
#include <QGraphicsScene>
#include <QTime>
class Model;
class OpenGLScene : public QGraphicsScene
{
Q_OBJECT
public:
OpenGLScene();
void drawBackground(QPainter *painter, const QRectF &rect);
public slots:
void setModel(Model *model);
void enableAutoRotate(bool enabled);
void enableWireframe(bool enabled);
void enableNormals(bool enabled);
void setLightPosition(int pos);
void setModelColor(QRgb color);
void setBackgroundColor(QRgb color);
protected:
void mousePressEvent(QGraphicsSceneMouseEvent *event);
void mouseReleaseEvent(QGraphicsSceneMouseEvent *event);
void mouseMoveEvent(QGraphicsSceneMouseEvent *event);
void wheelEvent(QGraphicsSceneWheelEvent * wheelEvent);
private:
void updateMatrix(qreal delta = 1);
void updateRotation(const QPointF &last, const QPointF ¤t);
bool m_wireframeEnabled;
bool m_normalsEnabled;
bool m_autoRotate;
bool m_rotating;
Point3d m_axis;
float m_angle;
float m_lightPos;
float m_distance;
QRgb m_backgroundColor;
QRgb m_modelColor;
Model *m_model;
QTime m_time;
unsigned int m_lastTime;
unsigned int m_startTime;
qreal m_accumulated;
float m_matrix[4][4];
};
#endif
|