-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathterrainwidget.h
More file actions
75 lines (59 loc) · 1.71 KB
/
Copy pathterrainwidget.h
File metadata and controls
75 lines (59 loc) · 1.71 KB
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
#ifndef TERRAINWIDGET_H
#define TERRAINWIDGET_H
#include <QKeyEvent>
#include <QMouseEvent>
#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLShaderProgram>
#include "core.h"
#include "heightfield.h"
class TerrainWidget : public QOpenGLWidget, protected QOpenGLFunctions_3_3_Core
{
Q_OBJECT
public:
TerrainWidget(QWidget* = nullptr);
~TerrainWidget();
void setCamera(const Camera& cam) { camera = cam; };
Camera getCamera() { return camera; }
void setHeightfield(const HeightField& hf, bool centerCamera = true);
void setTexture(const QImage& img);
void setCursorStyle(float radius, const Vector3& color);
void showCursor(const Vector3& worldPos);
void hideCursor();
public slots:
virtual void mousePressEvent(QMouseEvent*);
virtual void mouseMoveEvent(QMouseEvent*);
virtual void mouseReleaseEvent(QMouseEvent*);
virtual void wheelEvent(QWheelEvent* event);
void resetCamera();
signals:
void glInitialized();
void rayQueried(const Ray&);
protected:
virtual void initializeGL();
virtual void resizeGL(int, int);
virtual void paintGL();
void checkGLError();
protected:
// OpenGL render
Box3 terrainBBox;
GLuint meshVAO = 0;
GLuint bufferVerts = 0, bufferIndices = 0;
GLuint numTriangles = 0;
GLuint texId = 0;
GLuint skyboxVAO = 0;
QOpenGLShaderProgram shaderTerrain, shaderSkybox;
// Camera
Camera camera;
bool MoveAt = false;
int x0 = 0, y0 = 0;
Vector3 currentAt = Vector3(0);
Vector3 toAt = Vector3(0);
int stepAt = 0;
// Cursor
bool cursorEnabled;
float cursorRadius;
Vector3 cursorColor;
Vector3 cursorPos;
};
#endif // TERRAINWIDGET_H