-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathHeightMap2D.h
61 lines (45 loc) · 1.38 KB
/
HeightMap2D.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
#ifndef HEIGHTMAP2D_H
#define HEIGHTMAP2D_H
#include "PenjinTypes.h"
#include "Sprite.h"
#include "Vector2df.h"
#include "Vector2di.h"
#include "Colour.h"
#include <vector>
enum InterpolationMode
{
imMedian=0,
imHighest,
imLowest
};
class HeightMap2D
{
public:
HeightMap2D();
~HeightMap2D();
void clear();
void clearImages();
void loadImage(CRstring imageFile, const Colour& noCollisionColour);
void addChunks(const vector<int>& chunks);
uint getChunkSize() const {return chunkSize;};
InterpolationMode getInterpolationMode() const {return imMode;};
void generateHeightMap(CRuint newChunkSize, const InterpolationMode& newMode);
int getHeight(CRint posX) const;
int chunkCount() const {return map.size();};
template <class T, class K>
Vector2df hitTest(const T* const object, const K& objVel, CRuint stepSize) const;
template <class T, class K, class L>
Vector2df hitTest(const T* const object, const K* const objPos, const L& objVel, CRuint stepSize) const;
Vector2df position;
int getTotalWidth() const;
int getTotalHeight() const;
void render();
private:
void flushCache(vector<int>& cache);
vector<pair<Sprite*,Colour> > images;
vector<int> map;
InterpolationMode imMode;
uint chunkSize;
};
#include "HeightMap2D.inl"
#endif