-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathterrain_map.h
67 lines (54 loc) · 1.47 KB
/
terrain_map.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
#ifndef TERRAIN_MAP_H
#define TERRAIN_MAP_H
#include "LittleOBJLoader.h"
#include "VectorUtils4.h"
#include <string>
#include <map>
#include <jsoncpp/json/json.h>
#include "SimplexNoise.h"
#include "MicroGlut.h"
#include "GL_utilities.h"
#include "VectorUtils4.h"
#include "LittleOBJLoader.h"
#include "LoadTGA.h"
#include "frustum.h"
class TerrainMap
{
public:
TerrainMap(Json::Value settings, vec3 cameraPosition, const Frustum &f);
~TerrainMap();
void update(vec3 cameraPosition, const mat4 &world2view);
void display(const GLuint &program, const mat4 &world2view, const mat4 &projection, vec3 cameraPosition);
bool collision(std::map<std::pair<int, int>, int> points);
private:
std::map<std::pair<int, int>, Model *> chunks;
int terrainWidth = 256;
int terrainHeight = terrainWidth;
Model *GeneratePerlinTerrain(int offsetX, int offsetZ);
vec3 cameraPos;
int cameraChunkX;
int cameraChunkZ;
int CHUNKS = 6;
const int MAX_CHUNK_DISTANCE = 3 * CHUNKS;
Frustum frustum_obj;
// Calculate the number of vertices and triangles
int vertexCount;
int triangleCount;
float amplitude;
float frequency;
float snow;
float rock;
float grass;
float sand;
float water;
float snow_inter;
float rock_inter;
float grass_inter;
float water_to_sand;
float rock_size;
float grass_size;
float sand_size;
SimplexNoise *noise;
std::pair<int, int> getChunk(int x, int z);
};
#endif