-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTerrain.h
49 lines (37 loc) · 850 Bytes
/
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
#pragma once
#include <random>
#include "Mesh.h"
#include "Camera.h"
//#include "NoiseGraph.h"
#include "ThreadManager.h"
class Terrain :
public Mesh
{
public:
Terrain();
virtual void init();
virtual void update(ThreadManager&);
virtual void Draw();
void onUpdateMap()
{
_updateState = 1;
}
bool isInit() { return _updateState & 1; }
void setPos(int x, int z, int xOff, int zOff, float* heightmap);
bool isPos(int xOff, int zOff);
~Terrain();
private:
float getRandomMult(float x, float z);
void _gen(int xOff, int zOff, int x, int z, int xMid, int zMid);
void _save();
bool _load();
void getVecPos(vec3& pos, unsigned& x, unsigned& z);
unsigned _length;
unsigned _depth;
int _xOff, _zOff;
vector<Mesh::unnormalizedVertex> _unVec;
float* _heightmap;
mutex safeguard;
int _updateState;
unsigned _updatePos;
};