== file browser ==
[blender.git] / source / blender / makesdna / DNA_boid_types.h
1 /* 
2  * $Id$
3  *
4  * ***** BEGIN GPL LICENSE BLOCK *****
5  *
6  * This program is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU General Public License
8  * as published by the Free Software Foundation; either version 2
9  * of the License, or (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program; if not, write to the Free Software Foundation,
18  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
19  *
20  * The Original Code is Copyright (C) 2009 by Janne Karhu.
21  * All rights reserved.
22  *
23  * The Original Code is: all of this file.
24  *
25  * Contributor(s): none yet.
26  *
27  * ***** END GPL LICENSE BLOCK *****
28  */
29
30 #ifndef DNA_BOID_TYPES_H
31 #define DNA_BOID_TYPES_H
32
33 /** \file DNA_boid_types.h
34  *  \ingroup DNA
35  */
36
37 #include "DNA_listBase.h"
38
39 typedef enum BoidRuleType {
40         eBoidRuleType_None = 0,
41         eBoidRuleType_Goal,                             /* go to goal assigned object or loudest assigned signal source */
42         eBoidRuleType_Avoid,                    /* get away from assigned object or loudest assigned signal source */
43         eBoidRuleType_AvoidCollision,   /* manoeuver to avoid collisions with other boids and deflector object in near future */
44         eBoidRuleType_Separate,                 /* keep from going through other boids */
45         eBoidRuleType_Flock,                    /* move to center of neighbors and match their velocity */
46         eBoidRuleType_FollowLeader,             /* follow a boid or assigned object */
47         eBoidRuleType_AverageSpeed,             /* maintain speed, flight level or wander*/
48         eBoidRuleType_Fight,                    /* go to closest enemy and attack when in range */
49         //eBoidRuleType_Protect,                /* go to enemy closest to target and attack when in range */
50         //eBoidRuleType_Hide,                   /* find a deflector move to it's other side from closest enemy */
51         //eBoidRuleType_FollowPath,             /* move along a assigned curve or closest curve in a group */
52         //eBoidRuleType_FollowWall,             /* move next to a deflector object's in direction of it's tangent */
53         NUM_BOID_RULE_TYPES
54 } BoidRuleType;
55
56 /* boidrule->flag */
57 #define BOIDRULE_CURRENT                1
58 #define BOIDRULE_IN_AIR                 4
59 #define BOIDRULE_ON_LAND                8
60 typedef struct BoidRule {
61         struct BoidRule *next, *prev;
62         int type, flag;
63         char name[32];
64 } BoidRule;
65 #define BRULE_GOAL_AVOID_PREDICT        1
66 #define BRULE_GOAL_AVOID_ARRIVE         2
67 #define BRULE_GOAL_AVOID_SIGNAL         4
68 typedef struct BoidRuleGoalAvoid {
69         BoidRule rule;
70         struct Object *ob;
71         int options;
72         float fear_factor;      
73
74         /* signals */
75         int signal_id, channels;
76 } BoidRuleGoalAvoid;
77 #define BRULE_ACOLL_WITH_BOIDS          1
78 #define BRULE_ACOLL_WITH_DEFLECTORS     2
79 typedef struct BoidRuleAvoidCollision {
80         BoidRule rule;
81         int options;
82         float look_ahead;
83 } BoidRuleAvoidCollision;
84 #define BRULE_LEADER_IN_LINE            1
85 typedef struct BoidRuleFollowLeader {
86         BoidRule rule;
87         struct Object *ob;
88         float loc[3], oloc[3];
89         float cfra, distance;
90         int options, queue_size;
91 } BoidRuleFollowLeader;
92 typedef struct BoidRuleAverageSpeed {
93         BoidRule rule;
94         float wander, level, speed, rt;
95 } BoidRuleAverageSpeed;
96 typedef struct BoidRuleFight {
97         BoidRule rule;
98         float distance, flee_distance;
99 } BoidRuleFight;
100
101 typedef enum BoidMode {
102         eBoidMode_InAir = 0,
103         eBoidMode_OnLand,
104         eBoidMode_Climbing,
105         eBoidMode_Falling,
106         eBoidMode_Liftoff,
107         NUM_BOID_MODES
108 } BoidMode;
109
110
111 typedef struct BoidData {
112         float health, acc[3];
113         short state_id, mode;
114 } BoidData;
115
116 // planned for near future
117 //typedef enum BoidConditionMode {
118 //      eBoidConditionType_Then = 0,
119 //      eBoidConditionType_And,
120 //      eBoidConditionType_Or,
121 //      NUM_BOID_CONDITION_MODES
122 //} BoidConditionMode;
123 //typedef enum BoidConditionType {
124 //      eBoidConditionType_None = 0,
125 //      eBoidConditionType_Signal,
126 //      eBoidConditionType_NoSignal,
127 //      eBoidConditionType_HealthBelow,
128 //      eBoidConditionType_HealthAbove,
129 //      eBoidConditionType_See,
130 //      eBoidConditionType_NotSee,
131 //      eBoidConditionType_StateTime,
132 //      eBoidConditionType_Touching,
133 //      NUM_BOID_CONDITION_TYPES
134 //} BoidConditionType;
135 //typedef struct BoidCondition {
136 //      struct BoidCondition *next, *prev;
137 //      int state_id;
138 //      short type, mode;
139 //      float threshold, probability;
140 //
141 //      /* signals */
142 //      int signal_id, channels;
143 //} BoidCondition;
144
145 typedef enum BoidRulesetType {
146         eBoidRulesetType_Fuzzy = 0,
147         eBoidRulesetType_Random,
148         eBoidRulesetType_Average,
149         NUM_BOID_RULESET_TYPES
150 } BoidRulesetType;
151 #define BOIDSTATE_CURRENT       1
152 typedef struct BoidState {
153         struct BoidState *next, *prev;
154         ListBase rules;
155         ListBase conditions;
156         ListBase actions;
157         char name[32];
158         int id, flag;
159         
160         /* rules */
161         int ruleset_type;
162         float rule_fuzziness;
163
164         /* signal */
165         int signal_id, channels;
166         float volume, falloff;
167 } BoidState;
168
169 // planned for near future
170 //typedef struct BoidSignal {
171 //      struct BoidSignal *next, *prev;
172 //      float loc[3];
173 //      float volume, falloff;
174 //      int id;
175 //} BoidSignal;
176 //typedef struct BoidSignalDefine {
177 //      struct BoidSignalDefine *next, *prev;
178 //      int id, rt;
179 //      char name[32];
180 //} BoidSignalDefine;
181
182 //typedef struct BoidSimulationData {
183 //      ListBase signal_defines;/* list of defined signals */
184 //      ListBase signals[20];   /* gathers signals from all channels */
185 //      struct KDTree *signaltrees[20];
186 //      char channel_names[20][32];
187 //      int last_signal_id;             /* used for incrementing signal ids */
188 //      int flag;                               /* switches for drawing stuff */
189 //} BoidSimulationData;
190
191 typedef struct BoidSettings {
192         int options, last_state_id;
193
194         float landing_smoothness, height;
195         float banking, pitch;
196
197         float health, aggression;
198         float strength, accuracy, range;
199
200         /* flying related */
201         float air_min_speed, air_max_speed;
202         float air_max_acc, air_max_ave;
203         float air_personal_space;
204
205         /* walk/run related */
206         float land_jump_speed, land_max_speed;
207         float land_max_acc, land_max_ave;
208         float land_personal_space;
209         float land_stick_force;
210
211         struct ListBase states;
212 } BoidSettings;
213
214 /* boidsettings->options */
215 #define BOID_ALLOW_FLIGHT       1
216 #define BOID_ALLOW_LAND         2
217 #define BOID_ALLOW_CLIMB        4
218
219 /* boidrule->options */
220 //#define BOID_RULE_FOLLOW_LINE 1               /* follow leader */
221 //#define BOID_RULE_PREDICT             2               /* goal/avoid */
222 //#define BOID_RULE_ARRIVAL             4               /* goal */
223 //#define BOID_RULE_LAND                        8               /* goal */
224 //#define BOID_RULE_WITH_BOIDS  16              /* avoid collision */
225 //#define BOID_RULE_WITH_DEFLECTORS     32      /* avoid collision */
226
227 #endif