Steeriously  0.1
 All Classes Namespaces Functions Variables Typedefs Enumerations Pages
Agent.hpp
1 
2 #ifndef AGENT_HPP
3 #define AGENT_HPP
4 
5 #include <vector>
6 
7 #include <steeriously/BehaviorData.hpp>
8 #include <steeriously/Utilities.hpp>
9 #include <steeriously/Vector2.hpp>
10 #include <steeriously/VectorMath.hpp>
11 
12 namespace steer //steeriously namespace
13 {
14 
21  class Agent
22  {
23 
24  public:
25 
30  Agent();
31 
45  Agent(steer::Vector2 position, float radius, steer::Vector2 velocity, steer::Vector2 heading, steer::Vector2 side, float mass, float maxSpeed, float maxForce, float maxTurnRate);
46 
53 
55  virtual ~Agent();
56 
62 
68  void setPosition(steer::Vector2 newPosition) { m_agentPosition = newPosition; };
69 
74  float getBoundingRadius()const { return m_boundingRadius; }
75 
81  void setBoundingRadius(float radius) { m_boundingRadius = radius; };
82 
87  bool taggedInGroup() const { return m_tag; };
88 
93  void Tag() { m_tag = true; };
94 
99  void unTag() { m_tag = false; };
100 
105  steer::Vector2 getScale() const { return m_scale; };
106 
113  {
114  m_boundingRadius *= MaxOf(val.x, val.y) / MaxOf(m_scale.x, m_scale.y);
115  m_scale = val;
116  }
117 
123  void setScale(float val)
124  {
125  m_boundingRadius *= (val / MaxOf(m_scale.x, m_scale.y));
126  m_scale = steer::Vector2(val, val);
127  };
128 
134 
139  float getMass() const { return m_mass; }
140 
145  steer::Vector2 getSide() const { return m_side; }
146 
152  void setSide(const steer::Vector2 side) { m_side = side; }
153 
158  float getMaxSpeed() const { return m_maxSpeed; }
159 
165  void setMaxSpeed(float newSpeed) { m_maxSpeed = newSpeed; }
166 
171  float getMaxForce() const { return m_maxForce; }
172 
178  void setMaxForce(float maxForce) { m_maxForce = maxForce; }
179 
185 
191 
196  float getSpeed() const { return VectorMath::length(m_velocity); }
197 
203 
208  steer::Vector2 getHeading() const { return m_heading; }
209 
215  void setHeading(steer::Vector2 newHeading);
216 
223 
228  float getMaxTurnRate() const { return m_maxTurnRate; }
229 
235  void setMaxTurnRate(float maxTurnRate) { m_maxTurnRate = maxTurnRate; }
236 
241  float getForwardComponent();
242 
247  float getSideComponent();
248 
254  void setTarget(const steer::Vector2 target) { m_target = target; };
255 
260  steer::Vector2 getTarget() const { return m_target; };
261 
267  void setThreatRange(const float range) { m_threatRange = range; };
268 
273  float getThreatRange() const { return m_threatRange; };
274 
280  void setDecelerationTweaker(const float deceleration) { m_decelerationTweaker = deceleration; };
281 
287 
293  void setWanderTarget(const steer::Vector2 target) { m_wanderTarget = target; };
294 
300 
306  void setWanderJitter(const float jitter) { m_wanderJitter = jitter; };
307 
312  float getWanderJitter() const { return m_wanderJitter; };
313 
319  void setWanderRadius(const float radius) { m_wanderRadius = radius; };
320 
325  float getWanderRadius() const { return m_wanderRadius; };
326 
332  void setWanderDistance(const float distance) { m_wanderDistance = distance; };
333 
338  float getWanderDistance() const { return m_wanderDistance; };
339 
345  void setDistanceBuffer(const float buffer) { m_distanceBuffer = buffer; };
346 
351  float getDistanceBuffer() const { return m_distanceBuffer; };
352 
357  void setOffset(const steer::Vector2 offset) { m_offset = offset; };
358 
363  steer::Vector2 getOffset() const { return m_offset; }
364 
369  void createFeelers();
370 
375  float boxLength() const { return m_boxLength; }
376 
382  void setBoxLength(const float length) { m_boxLength = length; }
383 
388  const std::vector<steer::Vector2>& getFeelers() const { return m_feelers; }
389 
395  virtual bool on(steer::behaviorType behavior) = 0;
396 
402  virtual void setSummingMethod(Uint32 sumMethod);
403 
410  virtual bool accumulateForce(steer::Vector2 &startingForce, steer::Vector2 forceToAdd);
411 
416  virtual steer::Vector2 calculateWeightedSum();
417 
422  virtual steer::Vector2 calculatePrioritized();
423 
428  virtual steer::Vector2 Calculate() = 0;
429 
434  float getElapsedTime() { return m_timeElapsed; };
435 
440  float setElapsedTime(float e) { m_timeElapsed = e; };
441 
442  //all data are public
443  //getters/setters provided for anyone that wants them...
444  //Since the whole purpose of this library is to
445  //keep things easy - public data is the best approach
446  public:
449  bool m_tag;
453  std::vector<steer::Vector2> m_feelers;
457  float m_mass;
462  float m_boxLength;
464  float m_maxSpeed;
465  float m_maxForce;
475  };
476 } //end steeriously namespace
477 
478 #endif // AGENT_HPP