no clue :) just to push it
[demo] / src / terrain.h
index f2ecd69..337a03b 100644 (file)
@@ -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<TerrainTile> tiles;
-       
+
 public:
+       Material material;
+
        Terrain();
        ~Terrain();
 
+       bool init();
+       void destroy();
+
        bool generate(const TerrainParams &params);
        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