Steeriously
0.1
Main Page
Namespaces
Classes
Files
File List
All
Classes
Namespaces
Functions
Variables
Typedefs
Enumerations
Pages
include
steeriously
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
52
Agent
(
steer::BehaviorParameters
* params);
53
55
virtual
~Agent
();
56
61
steer::Vector2
getPosition
()
const
{
return
m_agentPosition
; };
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
112
void
setScale
(
steer::Vector2
val)
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
133
steer::Vector2
getVelocity
()
const
{
return
m_velocity
; }
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
184
steer::Vector2
getForce
()
const
{
return
m_steeringForce
; }
185
190
bool
speedMaxedOut
()
const
{
return
m_maxSpeed
*
m_maxSpeed
>=
VectorMath::lengthSquared
(
m_velocity
); }
191
196
float
getSpeed
()
const
{
return
VectorMath::length
(
m_velocity
); }
197
202
float
getSpeedSquared
()
const
{
return
VectorMath::lengthSquared
(
m_velocity
); }
203
208
steer::Vector2
getHeading
()
const
{
return
m_heading
; }
209
215
void
setHeading
(
steer::Vector2
newHeading);
216
222
bool
rotateHeadingToFacePosition
(
steer::Vector2
target);
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
286
float
getDecelerationTweaker
()
const
{
return
m_decelerationTweaker
; };
287
293
void
setWanderTarget
(
const
steer::Vector2
target) {
m_wanderTarget
= target; };
294
299
steer::Vector2
getWanderTarget
()
const
{
return
m_wanderTarget
; };
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
:
447
steer::Vector2
m_agentPosition
;
448
steer::Vector2
m_scale
;
449
bool
m_tag;
450
float
m_boundingRadius
;
451
steer::Vector2
m_steeringForce
;
452
float
m_waypointSeekDistanceSquared
;
453
std::vector<steer::Vector2>
m_feelers
;
454
steer::Vector2
m_velocity
;
455
steer::Vector2
m_heading
;
456
steer::Vector2
m_side
;
457
float
m_mass
;
458
float
m_timeElapsed
;
459
steer::Vector2
m_offset
;
460
float
m_viewDistance
;
461
Uint32
m_deceleration
;
462
float
m_boxLength
;
463
float
m_wallDetectionFeelerLength
;
464
float
m_maxSpeed
;
465
float
m_maxForce
;
466
float
m_maxTurnRate
;
467
steer::Vector2
m_target
;
468
float
m_threatRange
;
469
float
m_decelerationTweaker
;
470
float
m_distanceBuffer
;
471
steer::Vector2
m_wanderTarget
;
472
float
m_wanderJitter
;
473
float
m_wanderRadius
;
474
float
m_wanderDistance
;
475
};
476
}
//end steeriously namespace
477
478
#endif // AGENT_HPP
Generated on Sun Dec 10 2017 18:36:36 for Steeriously by
1.8.2