Mercator
|
00001 // This file may be redistributed and modified only under the terms of 00002 // the GNU General Public License (See COPYING for details). 00003 // Copyright (C) 2003 Damien McGinnes, Alistair Riddoch 00004 00005 #ifndef MERCATOR_TERRAIN_MOD_H 00006 #define MERCATOR_TERRAIN_MOD_H 00007 00008 #include <Mercator/Effector.h> 00009 00010 #include <wfmath/intersect.h> 00011 #include <wfmath/ball.h> 00012 00013 namespace Mercator { 00014 00015 class Segment; 00016 00020 class TerrainMod : public Effector 00021 { 00022 public: 00023 TerrainMod(); 00024 00025 virtual ~TerrainMod(); 00026 00027 int addToSegment(Segment &) const; 00028 void updateToSegment(Segment &) const; 00029 void removeFromSegment(Segment &) const; 00030 00035 virtual void apply(float &point, int x, int y) const = 0; 00036 00038 virtual TerrainMod *clone() const = 0; 00039 }; 00040 00045 template <template <int> class Shape> 00046 class ShapeTerrainMod : public TerrainMod 00047 { 00048 public: 00052 ShapeTerrainMod(const Shape<2> &s); 00053 virtual ~ShapeTerrainMod(); // {} 00054 00055 virtual bool checkIntersects(const Segment& s) const; 00056 00057 void setShape(const Shape<2> & s); 00058 protected: 00060 Shape<2> m_shape; 00061 }; 00062 00063 00067 template <template <int> class Shape> 00068 class LevelTerrainMod : public ShapeTerrainMod<Shape> 00069 { 00070 public: 00075 LevelTerrainMod(float level, const Shape<2> &s) 00076 : ShapeTerrainMod<Shape>(s), m_level(level) {} 00077 00078 virtual ~LevelTerrainMod(); 00079 00080 virtual void apply(float &point, int x, int y) const; 00081 virtual TerrainMod *clone() const; 00082 00083 void setShape(float level, const Shape<2> & s); 00084 private: 00086 LevelTerrainMod(LevelTerrainMod&); // {} 00087 00088 protected: 00090 float m_level; 00091 }; 00092 00097 template <template <int> class Shape> 00098 class AdjustTerrainMod : public ShapeTerrainMod<Shape> 00099 { 00100 public: 00101 00106 AdjustTerrainMod(float dist, const Shape<2> &s) 00107 : ShapeTerrainMod<Shape>(s), m_dist(dist) {} 00108 00109 virtual ~AdjustTerrainMod(); 00110 00111 virtual void apply(float &point, int x, int y) const; 00112 virtual TerrainMod *clone() const; 00113 00114 void setShape(float dist, const Shape<2> & s); 00115 private: 00117 AdjustTerrainMod(AdjustTerrainMod&); // {} 00118 00119 protected: 00121 float m_dist; 00122 }; 00123 00128 template <template <int> class Shape> 00129 class SlopeTerrainMod : public ShapeTerrainMod<Shape> 00130 { 00131 public: 00132 00139 SlopeTerrainMod(float level, float dx, float dy, const Shape<2> &s) 00140 : ShapeTerrainMod<Shape>(s), m_level(level), m_dx(dx), m_dy(dy) {} 00141 00142 virtual ~SlopeTerrainMod(); 00143 00144 virtual void apply(float &point, int x, int y) const; 00145 virtual TerrainMod *clone() const; 00146 00147 void setShape(float level, float dx, float dy, const Shape<2> & s); 00148 private: 00150 SlopeTerrainMod(SlopeTerrainMod&); // {} 00151 00152 protected: 00154 float m_level; 00156 float m_dx; 00158 float m_dy; 00159 }; 00160 00165 template <template <int> class Shape> 00166 class CraterTerrainMod : public ShapeTerrainMod<Shape> 00167 { 00168 public: 00172 CraterTerrainMod(float level, const Shape<2> &s) 00173 : ShapeTerrainMod<Shape>(s), m_level(level) {} 00174 00175 virtual ~CraterTerrainMod(); 00176 00177 virtual void apply(float &point, int x, int y) const; 00178 virtual TerrainMod *clone() const; 00179 00180 void setShape(float level, const Shape<2> & s); 00181 private: 00183 CraterTerrainMod(CraterTerrainMod&); // {} 00184 00185 protected: 00187 float m_level; 00188 }; 00189 00190 } //namespace Mercator 00191 00192 #endif // MERCATOR_TERRAIN_MOD_H