mercator  0.4.0
A terrain generation library for the Worldforge system.
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  struct Context {
29  std::string m_id;
30  };
31 
32  Context * context() const { return m_context.get(); }
33 
34  void setContext(std::unique_ptr<Context> context);
35 
37  const WFMath::AxisBox<2> & bbox() const
38  {
39  return m_box;
40  }
41 
42  virtual ~Effector() = 0;
43 
44  virtual bool checkIntersects(const Segment& s) const = 0;
45 
46  protected:
48  Effector();
49 
51  Effector(const Effector &);
52 
54  Effector & operator=(const Effector &);
55 
57  WFMath::AxisBox<2> m_box;
58 
60  std::unique_ptr<Context> m_context;
61 };
62 
64 typedef float (*effector_func)(float height, float mod);
65 
66 float set(float, float);
67 float max(float, float);
68 float min(float, float);
69 float sum(float, float);
70 float dif(float, float);
71 
72 }
73 
74 #endif // of MERCATOR_EFFECTOR_H
Mercator::Segment
Class storing heightfield and other data for a single fixed size square area of terrain defined by fo...
Definition: Segment.h:37
Mercator::Effector::Effector
Effector()
Constructor.
Mercator::Effector
Device which effects a change in the terrain.
Definition: Effector.h:25
Mercator::Effector::m_context
std::unique_ptr< Context > m_context
The application context of this effector.
Definition: Effector.h:60
Mercator::Effector::operator=
Effector & operator=(const Effector &)
Assignment.
Definition: Effector.cpp:25
Mercator::Effector::m_box
WFMath::AxisBox< 2 > m_box
The bounding box of the geometric shape.
Definition: Effector.h:57
Mercator::Effector::bbox
const WFMath::AxisBox< 2 > & bbox() const
Accessor for the bounding box of the geometric shape.
Definition: Effector.h:37
Mercator::Effector::Context
Definition: Effector.h:28