-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglviewport.h
95 lines (70 loc) · 2.3 KB
/
glviewport.h
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#ifndef GLVIEWPORT_H
#define GLVIEWPORT_H
#include <QtOpenGL>
#include <vector>
#include <QMatrix4x4>
#include <QVector3D>
#include "light.h"
#include "material.h"
namespace jEle {
class ObjectModel;
class GLViewport : public QGLWidget, protected QGLFunctions
{
public:
GLViewport(QWidget *parent);
QColor getBackgroundColor() const;
void setBackgroundColor(QColor&);
Material *getDefaultMaterial() const;
void setDefaultMaterial(Material*);
ObjectModel *getObjectModel() const;
void setObjectModel(ObjectModel*);
void setLights(std::vector<Light*> &lights);
void increaseRotation(double x, double y);
protected:
void initializeGL();
void paintGL();
void resizeGL(int w, int h);
void mousePressEvent(QMouseEvent *);
void mouseReleaseEvent(QMouseEvent *);
void mouseMoveEvent(QMouseEvent *);
void wheelEvent(QWheelEvent *);
private:
void setLight(Light);
void loadPolygonMaterial(Material *material);
void loadTexture(Material *material);
void loadDefaultMaterial();
void loadMaterial(Material *material);
void renderEnvironment();
void renderObject();
void updateCameraView();
void updateCameraProjection();
void initLightProjection();
QMatrix4x4 getLightView(Light);
void getLightView(Light *, GLdouble *);
QVector3D getObjectCenter();
void getDoubleArray(QVector4D, GLdouble a[]);
Light withEyeCoords(Light *);
Material *lastPolygonMaterial;
QColor backgroundColor;
Material *defaultMaterial;
ObjectModel *objectModel;
QMatrix4x4 objectRotation;
double objectShiftX;
double objectShiftY;
double objectScale;
double fieldOfView;
double eyePositionPitch, eyePositionYaw;
QPoint lastMousePos;
bool shiftMode;
QMap<QString, GLuint> textures;
Material ground, wall;
QMatrix4x4 cameraView, cameraProjection, lightProjection;
//Shadow mapping
GLuint shadowMapFB;
GLuint shadowMapTexture;
const GLuint shadowMapSize;
std::vector<Light*> lights;
Light dimLight;
};
}
#endif // GLVIEWPORT_H