-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathterrain.h
66 lines (47 loc) · 1.57 KB
/
terrain.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
#ifndef TERRAIN_H
#define TERRAIN_H
#include <QObject>
#include "shader.h"
#include "camera.h"
#include "modeltexture.h"
#include "filesystem.h"
class Terrain : public QObject
{
Q_OBJECT
public:
Terrain(int gridX, int gridZ, QList<QSharedPointer<Shader>>& shaders, const Camera* camera);
void appendTexture(const QList<QString>& texturePaths, FileSystem* fileSystem);
void loadTexture(QSharedPointer<Shader> shader, const int& lodLevel);
void renderTerrain();
decltype (auto) getTerrainPosition() { return position; }
auto getVertices() -> const QVector<float>& { return vertices; }
private:
struct Texture{
GLuint id;
};
protected:
private:
QVector3D position;
QList<QSharedPointer<Shader>> shaders;
const Camera* camera;
// LOD_TERRAIN
const float NODE_COUNT = 16;
QList<float> VERTEX_COUNTS = {32, 8, 2};
QVector<float> maxDistanceLevels;
QVector<float> hqVertices, mqVertices, lqVertices;
QVector<int> hqIndices, mqIndices, lqIndices;
double hqIndicesPointer = 0, mqIndicesPointer = 0, lqIndicesPointer = 0;
// END_OF_LOD_TERRAIN
const float GRID_SIZE = 256;
//const float VERTEX_COUNT = 128;
int gridX, gridZ;
std::vector<float> xz;
QVector<Texture> textures;
QVector<float> vertices;
QVector<int> indices;
void setTerrainGridXZ(int gridX, int gridZ);
void setMaxDistanceLevels();
void loadVertex(const int& nodeX, const int& nodeZ, const int& lodLevel, QVector<float>& vertices, QVector<int>& indices);
void generateTerrain();
};
#endif // TERRAIN_H