X-Git-Url: https://eleni.mutantstargoat.com/git/?a=blobdiff_plain;f=src%2Fterrain.h;h=337a03b90b7192a2e8b4610b1461f3a7bf6a969a;hb=22347bb45e427ea763295d77da0de0d2ef9c2395;hp=d6f4844c1f9618c2f0a8bc2a3d68706ae87f365e;hpb=54cc76a89b4221fac1b7f4a58259ca0ce836177d;p=demo diff --git a/src/terrain.h b/src/terrain.h index d6f4844..337a03b 100644 --- a/src/terrain.h +++ b/src/terrain.h @@ -1,6 +1,55 @@ #ifndef TERRAIN_H_ #define TERRAIN_H_ +#include "image.h" +class Camera; +class Scene; + +// terrain 8a ftiaxnei skini k taisma renderer +class TerrainTile { +private: + Mesh *mesh; + + friend class Terrain; +}; + +/* parameters needed in terrain generation */ + +struct TerrainParams { + float xsz; /* terrain size in x axis */ + float ysz; /* terrain size in y axis */ + float max_height; /* max height of the heightfield */ + int xtiles; /* number of tiles in x axis */ + int ytiles; /* number of tiles in y axis */ + int tile_usub; + int tile_vsub; + int num_octaves; /* Perlin noise sums */ + float noise_freq; /* Perlin noise scaling factor */ + Image coarse_heightmap; /* mask for low detail heightmap */ +}; + +class Terrain { +private: + TerrainParams params; + 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