Starshatter_Open
Open source Starshatter engine
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros
Terrain.h
Go to the documentation of this file.
1 /* Project Starshatter 4.5
2  Destroyer Studios LLC
3  Copyright © 1997-2005. All Rights Reserved.
4 
5  SUBSYSTEM: Stars.exe
6  FILE: Terrain.h
7  AUTHOR: John DiCamillo
8 
9 
10  OVERVIEW
11  ========
12  Test pseudo-random terrain heightfield, based on Solid
13 */
14 
15 #ifndef Terrain_h
16 #define Terrain_h
17 
18 #include "Types.h"
19 #include "Graphic.h"
20 #include "Geometry.h"
21 #include "Bitmap.h"
22 #include "Text.h"
23 
24 // +--------------------------------------------------------------------+
25 
26 class Projector;
27 class Scene;
28 class TerrainApron;
29 class TerrainClouds;
30 class TerrainLayer;
31 class TerrainPatch;
32 class TerrainRegion;
33 class Water;
34 
35 // +--------------------------------------------------------------------+
36 
37 struct Vec3B
38 {
39  Vec3B() { }
40  Vec3B(BYTE a, BYTE b, BYTE c) : x(a), y(b), z(c) { }
41 
42  BYTE x, y, z;
43 };
44 
45 // +--------------------------------------------------------------------+
46 
47 class Terrain
48 {
49 public:
51  virtual ~Terrain();
52 
53  virtual void Activate(Scene& scene);
54  virtual void Deactivate(Scene& scene);
55 
56  virtual void SelectDetail(Projector* proj);
57  virtual void BuildTerrain();
58  virtual void BuildNormals();
59 
60  virtual void ExecFrame(double seconds);
61 
62  double Height(double x, double y) const;
63 
64  const Vec3B* Normals() const { return terrain_normals; }
66  double FogFade() const { return fog_fade; }
67 
72  Bitmap* TileTexture(int n) { return tiles[n]; }
73  Bitmap* CloudTexture(int n) { return cloud_texture[n]; }
74  Bitmap* ShadeTexture(int n) { return shade_texture[n]; }
75  Bitmap* DetailTexture(int n) { return noise_texture[n]; }
76  Water* GetWater(int level) { return water[level]; }
78 
79  bool IsFirstPatch(TerrainPatch* p) const;
80 
81  static int DetailLevel() { return detail_level; }
82  static void SetDetailLevel(int detail);
83 
84 protected:
91  int nclouds;
92 
99  Bitmap* tiles[256];
103 
106 
108  double scale;
109  double mtnscale;
113  double fog_fade;
114 
115  static int detail_level;
116 };
117 
118 #endif Terrain_h
119