1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(__INCLUDE_GroundMapsh_INCLUDE__)
22 #define __INCLUDE_GroundMapsh_INCLUDE__
23 
24 #include <landscapemap/HeightMap.h>
25 #include <landscapemap/NapalmMap.h>
26 #include <placement/PlacementShadowDefinition.h>
27 
28 class RandomGenerator;
29 class ScorchedContext;
30 class LandscapeInclude;
31 class LandscapeDefinitionCache;
32 class GroundMaps
33 {
34 public:
35 	GroundMaps(LandscapeDefinitionCache &defnCache);
36 	virtual ~GroundMaps();
37 
38 	// Generates the next level
39 	void generateMaps(
40 		ScorchedContext &context,
41 		ProgressCounter *counter = 0);
42 	void generateObjects(
43 		ScorchedContext &context,
44 		ProgressCounter *counter = 0);
45 
46 	// Height map functions
47 	fixed getHeight(int w, int h);
48 	fixed getInterpHeight(fixed w, fixed h);
49 	FixedVector &getNormal(int w, int h);
50 	void getInterpNormal(fixed w, fixed h, FixedVector &normal);
51 	bool getIntersect(Line &direction, Vector &intersect);
52 
53 	// Napalm map functions
getNapalmHeight(int w,int h)54 	fixed &getNapalmHeight(int w, int h)
55 		{ return nmap_.getNapalmHeight(w, h); }
56 
57 	// Deformable landscape area fns
58 	int getLandscapeWidth();
59 	int getLandscapeHeight();
60 
61 	// Playable landscape area fns
62 	int getArenaWidth();
63 	int getArenaHeight();
64 	int getArenaX();
65 	int getArenaY();
66 
67 	// Actual heightmap
getHeightMap()68 	HeightMap &getHeightMap() { return map_; }
69 
getDeformMap()70 	HeightMap &getDeformMap() { return deformMap_; }
71 
getShadows()72 	std::list<PlacementShadowDefinition::Entry> &getShadows() { return shadows_; }
73 
74 protected:
75 	int arenaX_, arenaY_;
76 	int arenaWidth_, arenaHeight_;
77 	HeightMap map_; // The current level's heightmap
78 	NapalmMap nmap_; // How high napalm is at certain points
79 	HeightMap deformMap_; // How low can this level go
80 	LandscapeDefinitionCache &defnCache_;
81 	std::list<PlacementShadowDefinition::Entry> shadows_;
82 
83 	// Generate levels
84 	void generateHMap(
85 		ScorchedContext &context,
86 		ProgressCounter *counter = 0);
87 	void generateObject(RandomGenerator &generator,
88 		LandscapeInclude &place,
89 		ScorchedContext &context,
90 		unsigned int &playerId,
91 		ProgressCounter *counter = 0);
92 
93 };
94 
95 #endif // __INCLUDE_GroundMapsh_INCLUDE__
96