infinite terrain experiments
[shady.git] / terrain.hpp
blob1046fe73b361362648c9c65f6fb0606e1e776d94
2 #ifndef SHADY_TERRAIN_HPP
3 #define SHADY_TERRAIN_HPP
5 #include "transform.hpp"
7 #include <vector>
9 class terrain{
11 public:
13 terrain(int res, float size, float height);
14 ~terrain();
16 void generate(int randres, float divisor, float power, int seed);
18 void drawGl() const;
20 void generateVertices();
22 void drawVertices(vec pos) const;
24 float heightAt(float x, float y) const;
26 private:
28 struct Vertex {
30 vec pos;
32 vec normal;
36 int res;
37 float size;
38 float height;
40 float ** data;
42 float xVal(int x, int y) const;
43 float yVal(int x, int y) const;
44 float zVal(int x, int y) const;
46 void drawGlVertex(int x, int y) const;
48 static void setVertexArray(Vertex * vert);
50 enum ToCenter {
51 X0 = 1,
52 X1 = 2,
53 Y0 = 4,
54 Y1 = 8,
55 None
58 void addRect(std::vector<unsigned short> & d, int x0, int x1, int y0, int y1, vec pos, ToCenter tc) const;
60 bool isSubdivided(int x0, int x1, int y0, int y1, vec pos) const;
62 Vertex * vertices;
66 #endif // SHADY_TERRAIN_HPP