Mercator
Effector.h
1 // This file may be redistributed and modified only under the terms of
2 // the GNU General Public License (See COPYING for details).
3 // Copyright (C) 2010 Alistair Riddoch
4 
5 #ifndef MERCATOR_EFFECTOR_H
6 #define MERCATOR_EFFECTOR_H
7 
8 #include <wfmath/axisbox.h>
9 #include <wfmath/polygon.h>
10 
11 #include <string>
12 
13 namespace Mercator
14 {
15 
16 class Segment;
17 class Shader;
18 
25 class Effector
26 {
27  public:
28  class Context {
29  public:
30  Context();
31 
32  virtual ~Context();
33 
34  const std::string & id() { return m_id; }
35 
36  void setId(const std::string &);
37  protected:
38  std::string m_id;
39  };
40 
41  Context * context() const { return m_context; }
42 
43  void setContext(Context *);
44 
46  const WFMath::AxisBox<2> & bbox() const
47  {
48  return m_box;
49  }
50 
51  virtual ~Effector() = 0;
52 
53  virtual bool checkIntersects(const Segment& s) const = 0;
54 
55  virtual int addToSegment(Segment &) const = 0;
56  virtual void updateToSegment(Segment &) const = 0;
57  virtual void removeFromSegment(Segment &) const = 0;
58 
59  protected:
61  Effector();
62 
64  Effector(const Effector &);
65 
67  Effector & operator=(const Effector &);
68 
70  WFMath::AxisBox<2> m_box;
71 
74 };
75 
77 typedef float (*effector_func)(float height, float mod);
78 
79 float set(float, float);
80 float max(float, float);
81 float min(float, float);
82 float sum(float, float);
83 float dif(float, float);
84 
85 }
86 
87 #endif // of MERCATOR_EFFECTOR_H
Device which effects a change in the terrain.
Definition: Effector.h:25
Definition: Area.cpp:20
Definition: Effector.h:28
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:36
const WFMath::AxisBox< 2 > & bbox() const
Accessor for the bounding box of the geometric shape.
Definition: Effector.h:46
WFMath::AxisBox< 2 > m_box
The bounding box of the geometric shape.
Definition: Effector.h:70
Context * m_context
The application context of this effector.
Definition: Effector.h:73
Effector()
Constructor.
Definition: Effector.cpp:28
Effector & operator=(const Effector &)
Assignment.
Definition: Effector.cpp:38