forked from addacsystem/ADDAC-Library
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathADDAC_Flock.cpp
executable file
·155 lines (80 loc) · 2.54 KB
/
ADDAC_Flock.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
/*
* Some hints about what this Class does!
*
*/
#include "ADDAC_Flock.h"
//-----------------------------------------------------------------------ADDAC EMPTY-----------------
ADDAC_Flock::ADDAC_Flock(){ // INITIALIZE CLASS
}
/*! \brief Setup a Flock with four Boids
*/
void ADDAC_Flock::setup(){
boids[0] = ADDAC_Boid();
boids[1] = ADDAC_Boid();
boids[2] = ADDAC_Boid();
boids[3] = ADDAC_Boid();
}
// --------------------------------------------------------------------------- UPDATE -------------------------
//
/*! \brief Update the Flock variables
\param _wrapAround true - the flock will wrapAround | false - the flock will mirror
*/
void ADDAC_Flock::update(bool _wrapAround){
// array.size()??
for (int i = 0; i<4; i++) {
boids[i].update(boids, _wrapAround);
}
}
/*! \brief get Boid XPosition stream
\param _boidNumber boid number (0-4)
*/
float ADDAC_Flock::getBoidPositionX(int _boidNumber){
return boids[_boidNumber].pos.x/maxWidth;
}
/*! \brief get Boid YPosition stream
\param _boidNumber boid number (0-4)
*/
float ADDAC_Flock::getBoidPositionY(int _boidNumber){
return boids[_boidNumber].pos.y/maxHeight;
}
/*! \brief get Boid X and Y Average Position stream
\param _boidNumber boid number (0-4)
*/
float ADDAC_Flock::getBoidPositionM(int _boidNumber){
return ((boids[_boidNumber].pos.y/1000)+(boids[_boidNumber].pos.y/1000))/2;
}
/*! \brief set Separation value
\param _sep separation value (0-1000)
*/
void ADDAC_Flock::setSeparation(float _sep){
for (int i = 0; i<4; i++) {
boids[i].separationV=_sep;
}
}
/*! \brief set Cohesion value
\param _coe Cohesion value (0-1000)
*/
void ADDAC_Flock::setCohesion(float _coe){
for (int i = 0; i<4; i++) {
boids[i].cohesionV=_coe;
}
}
/*! \brief set Align value
\param _ali Align value (0-1000)
*/
void ADDAC_Flock::setAlign(float _ali){
for (int i = 0; i<4; i++) {
boids[i].alignV=_ali;
}
}
/*! \brief set Speed value
\param _speed Align value (0-1)
*/
void ADDAC_Flock::setSpeed(float _speed){
_speed=(_speed*5.0f);
for (int i = 0; i<4; i++) {
boids[i].speedV=_speed;
}
}
// --------------------------------------------------------------------------- END ----------------------------------
//