X-Git-Url: http://git.mutantstargoat.com?a=blobdiff_plain;f=src%2Fterrain.h;h=337a03b90b7192a2e8b4610b1461f3a7bf6a969a;hb=HEAD;hp=f2ecd693d8ead7afd2134f4fd3386bdba994476e;hpb=197f20b5d4db937029f7b585be23ee7fe5da66dc;p=demo diff --git a/src/terrain.h b/src/terrain.h index f2ecd69..337a03b 100644 --- a/src/terrain.h +++ b/src/terrain.h @@ -1,8 +1,9 @@ #ifndef TERRAIN_H_ #define TERRAIN_H_ +#include "image.h" + class Camera; -class Image; class Scene; // terrain 8a ftiaxnei skini k taisma renderer @@ -10,6 +11,7 @@ class TerrainTile { private: Mesh *mesh; + friend class Terrain; }; /* parameters needed in terrain generation */ @@ -23,7 +25,8 @@ struct TerrainParams { int tile_usub; int tile_vsub; int num_octaves; /* Perlin noise sums */ - Image *coarse_heightmap; /* mask for low detail heightmap */ + float noise_freq; /* Perlin noise scaling factor */ + Image coarse_heightmap; /* mask for low detail heightmap */ }; class Terrain { @@ -32,13 +35,21 @@ private: mutable Scene *vis_scene; /* set of visible tiles returned by get_visible */ std::vector tiles; - + public: + Material material; + Terrain(); ~Terrain(); + bool init(); + void destroy(); + bool generate(const TerrainParams ¶ms); Scene *get_visible(const Camera *camera) const; + + float get_height(float u, float v) const; + float get_height(const Vec3 &pos) const; /* world coordinates */ }; #endif // TERRAIN_H_ \ No newline at end of file