get height, camera + cow movement with keys
[demo] / src / terrain.h
index f2ecd69..db9464d 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 {
@@ -34,11 +37,19 @@ private:
        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