DI-Guy SDK Documentation  13.1
diguyCharacterGroup.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2015 VT MAK
4  ** All rights reserved.
5  *********************************************************************/
6 
7 
8 /*********************************************************************
9  **
10  *t diguyCharacterGroup
11  **
12  */
13 
14 #ifndef __diguyCharacterGroup_H
15 #define __diguyCharacterGroup_H
16 
17 
18 #ifdef SWIG
19 %module diguyCharacterGroup
20 #else
21 #define CPLUSPLUS_ONLY
22 #endif
23 
24 #ifdef CPLUSPLUS_ONLY
25 #include <stdio.h>
26 class bdiScenarioCharacterGroup;
27 class diguyCharacter;
28 class diguyVariable;
29 class diguyViewLabel;
30 class diguyFormation;
31 #endif
32 
33 
34 #include <declspec_diguy.h>
35 
42 /****************************************************************************/
43 class BDI_DECLSPEC_diguy diguyCharacterGroup
44 {
45 
46 /*****************************************************************************/
55 public:
56 
57  /*l
58  *b Returns:
59  **
60  ** name of the group; this value will never be NULL
61  */
62  const char* get_name();
63 
64  /*l
65  *b Description:
66  **
67  ** This function sets the name of this object.
68  **
69  *b Returns:
70  **
71  ** 0 on success, -1 on failure
72  */
73  int set_name(const char* name);
74 
75  /*l
76  *b Description:
77  **
78  ** Adds the passed character to the group if not already in it.
79  **
80  *b Returns:
81  **
82  ** 0 if the character is now a part of the group, -1 if not
83  */
84  int add_member(diguyCharacter* character);
85 
86  /*l
87  *b Description:
88  **
89  ** Adds all characters of the scenario as members of the group.
90  **
91  *b Returns:
92  **
93  ** Always return 0.
94  */
95  int add_all_characters_as_members();
96 
97  /*l
98  *b Description:
99  **
100  ** Removes the passed character from the group if it
101  ** is a member.
102  **
103  *b Returns:
104  **
105  ** 0 if the character was part of the group and removed;
106  ** -1 if not
107  */
108  int remove_member(diguyCharacter* character);
109 
110  /*l
111  *b Description:
112  **
113  ** Removes all members of the group.
114  **
115  *b Returns:
116  **
117  ** Always return 0.
118  */
119  int remove_all_members();
120 
121  /*l
122  *b Description:
123  **
124  ** The function can be used to check if a specific character is in
125  ** this group.
126  **
127  ** Also see diguyCharacter::is_group_member().
128  **
129  *b Returns:
130  **
131  ** 1 if the passed character is a member of the group;
132  ** 0 if not
133  */
134  int is_member(diguyCharacter* character);
135 
136  /*l
137  *b Returns:
138  **
139  ** number of member characters in group
140 
141  */
142  int get_num_members();
143 
144  /*l
145  *b Returns:
146  **
147  ** group member at specified index; NULL if no character
148  ** at specified index
149  */
150  diguyCharacter* get_member_at_index(int index);
151 
152  /*l
153  *b Returns:
154  **
155  ** index of member, or -1 if not found
156  */
157  int get_index_of_member(diguyCharacter* character);
158 
159  /*l
160  *b Description:
161  **
162  ** See diguyFormation for a description of subgroups.
163  **
164  *b Returns:
165  **
166  ** subgroup number within formation of character at index,
167  ** or -1
168  */
169  int get_subgroup_number(diguyFormation* formation, int index);
170 
171  /*l
172  *b Description:
173  **
174  ** See diguyFormation for a description of subgroups.
175  **
176  *b Returns:
177  **
178  ** index within subgroup, or 0
179  */
180  int get_index_in_subgroup(diguyFormation* formation, int index);
181 
182 
183  /*l
184  *b Description:
185  **
186  ** Sets whether all characters in group are enabled. Equivalent to
187  ** calling diguyCharacter::set_enabled() for group members.
188  **
189  *b Returns:
190  **
191  ** Always return 0.
192  */
193  int set_all_members_enabled(int enabled);
194 
195  /*l
196  *b Description:
197  **
198  ** Updates all characters in the group. Equivalent to calling
199  ** diguyCharacter::update() for all group members.
200  **
201  *b Returns:
202  **
203  ** 0 on success, -1 on failure
204  */
205  int update_all_members(float t);
206 
207 #ifdef CPLUSPLUS_ONLY
208 
209  /*l
210  *b Description:
211  **
212  ** This function draws all members of the group.
213  ** See diguyCharacter::draw().
214  **
215  *b Returns:
216  **
217  ** 0 on success, -1 on failure
218  **
219  *b Callable From:
220  **
221  *- - C++
222  */
223  int draw_all_members();
224 
225  /*l
226  *b Description:
227  **
228  ** This function draws pass 1 of all members of the group.
229  ** See diguyCharacter::draw_pass1().
230  **
231  *b Returns:
232  **
233  ** 0 on success, -1 on failure
234  **
235  *b Callable From:
236  **
237  *- - C++
238  */
239  int draw_pass1_all_members();
240 
241  /*l
242  *b Description:
243  **
244  ** This function draws pass 2 all members of the group.
245  ** See diguyCharacter::draw_pass2().
246  **
247  *b Returns:
248  **
249  ** 0 on success, -1 on failure
250  **
251  *b Callable From:
252  **
253  *- - C++
254  */
255  int draw_pass2_all_members();
256 
257 #endif
258 
259  /*l
260  *b Description:
261  **
262  ** This function sets the current tin time of all characters
263  ** in the group. See diguyCharacter::set_current_tin().
264  **
265  *b Arguments:
266  **
267  *a tin - new value of current tin in seconds
268  **
269  *b Returns:
270  **
271  ** 0 on success, -1 on failure
272 
273  */
274  int set_all_members_current_tin(float tin);
275 
276  /*l
277  *b Description:
278  **
279  ** This function sets the current tout time of all characters
280  ** in the group. See diguyCharacter::set_current_tout().
281  **
282  *b Arguments:
283  **
284  *a tout - new value of current tout in seconds
285  **
286  *b Returns:
287  **
288  ** 0 on success, -1 on failure
289  */
290  int set_all_members_current_tout(float tout);
291 
292 
293 /*****************************************************************************/
304  /*l
305  *b Description:
306  **
307  ** This function returns a pointer to the label object of
308  ** the group.
309  **
310  ** Currently group labels are only enabled in DI-Guy Scenario.
311  **
312  *b Returns:
313  **
314  ** pointer to the group's label
315 
316  */
317  diguyViewLabel* get_label();
318 
319  /*l
320  *b Description:
321  **
322  ** This function sets how high the label of the group will float
323  ** above the group's centroid.
324  **
325  *b Arguments:
326  **
327  *a offset - offset, in meters, of label above group
328  */
329  void set_label_offset_above_centroid(float offset);
330 
331  /*l
332  *b Returns:
333  **
334  ** how high the label of the group will float above the group centroid
335  */
336  float get_label_offset_above_centroid();
337 
338 
339 /*****************************************************************************/
345  /*l
346  *b Returns:
347  **
348  ** number of variables the group has
349  */
350  int get_num_variables();
351 
352  /*l
353  *b Returns:
354  **
355  ** pointer of type diguyVariable; NULL if no
356  ** variable at the specified index
357  **
358  *b Arguments:
359  **
360  *a index - index of the variable; indices start at 0
361  */
362  diguyVariable* get_variable_at_index(int index);
363 
364  /*l
365  *b Description:
366  **
367  ** This function returns a pointer to the specified variable.
368  **
369  *b Arguments:
370  **
371  *a name - name of variable to be found
372  **
373  *b Returns:
374  **
375  ** pointer of type diguyVariable; NULL if not found
376  */
377  diguyVariable* find_variable(const char* name);
378 
379  /*l
380  *b Description:
381  **
382  ** This function finds the variable with the given name or
383  ** creates it if it doesn't exist.
384  **
385  *b Arguments:
386  **
387  *a name - name of the variable to find or create
388  **
389  *b Returns:
390  **
391  ** pointer of type diguyVariable; should never be NULL
392  */
393  diguyVariable* find_or_create_variable(const char* name);
394 
395  /*l
396  *b Description:
397  **
398  ** This function destroys the passed variable.
399  **
400  *b Arguments:
401  **
402  *a variable - pointer to a diguyVariable
403  **
404  *b Returns:
405  **
406  ** 0 on success, -1 on failure
407  */
408  int destroy_variable(diguyVariable* variable);
409 
410 
411 /****************************************************************************/
412 /****************************************************************************/
413 /****************************************************************************/
417 /****************************************************************************/
418 /****************************************************************************/
419 /****************************************************************************/
420 
421  int translate_all_paths(float tx, float ty, float tz);
422 
423  int rotate_all_paths_about_point(float rz, float rx, float ry,
424  float rotation_pt_x, float rotation_pt_y, float rotation_pt_z);
425 
426  int rotate_all_paths_about_current_waypoint(float rz, float rx, float ry);
427 
428  /*l
429  *b Description:
430  **
431  ** Get the character closest to the specified point.
432  **
433  *b Arguments:
434  **
435  *a x, y, z - position in meters from the origin
436  **
437  *b Returns:
438  **
439  ** pointer to diguyCharacter, or NULL in none found
440  */
441  diguyCharacter* get_nearest_character_to_point(float x, float y, float z);
442 
443  /*l
444  *b Description:
445  **
446  ** Get the character furthest from the specified point.
447  **
448  *b Arguments:
449  **
450  *a x, y, z - position in meters from the origin
451  **
452  *b Returns:
453  **
454  ** pointer to diguyCharacter, or NULL if none found
455  */
456  diguyCharacter* get_farthest_character_to_point(float x, float y, float z);
457 
458  /*l
459  *b Description:
460  **
461  ** Get centroid of group (average of character positions).
462  **
463  *b Arguments:
464  **
465  *a x, y, z - position in meters from the origin
466  **
467  *b Returns:
468  **
469  ** 0 on success, -1 on failure
470  */
471  int get_group_centroid(float* x, float* y, float* z);
472 
473  /*l
474  *b Description:
475  **
476  ** Get minimum enclosing circle of group. Note that this is slower
477  ** than getting the centroid.
478  **
479  *b Arguments:
480  **
481  *a x, y, z - center of circle of group in meters from the origin
482  *a radius - radius of circle
483  **
484  *b Returns:
485  **
486  ** 0 on success, -1 on failure
487  */
488  int get_group_min_circle(float* x, float* y, float* z, float* radius);
489 
490  /*l
491  *b Description:
492  **
493  ** Send a message to all characters in group. See
494  ** diguyCharacter::agent_accept_message().
495  **
496  *b Arguments:
497  **
498  *a sender - who is sending the message
499  *a message_type - what type of message is being sent
500  *a message - the message string
501  *a message_params - optional parameter string
502  **
503  *b Returns:
504  **
505  ** 0 on success, -1 on failure
506  */
507  int send_message_to_all_members(const char* sender,
508  const char* message_type,
509  const char* message,
510  const char* message_params = NULL);
511 
512  /*l
513  *b Description:
514  **
515  ** Puts the group into the specified formation, applying
516  ** agent_pursue_character_with_offset() to each character except the
517  ** leader.
518  **
519  *b Arguments:
520  **
521  *a leader - leader; can be NULL
522  *a formation - name of formation
523  *a dir_x - x component of the formation's heading
524  *a dir_y - y component of the formation's heading
525  *a desired_radius - if not given (-1.0), get radius from formation
526  *a require_sort - if 1, group must be resorted; if 0, it may still
527  *a be
528  **
529  *b Returns:
530  **
531  ** 0 on success, -1 on failure
532  */
533  int apply_formation_to_group_with_dir(diguyCharacter* leader,
534  diguyFormation* formation,
535  float dir_x,
536  float dir_y,
537  float desired_radius = -1.0f,
538  int require_sort = 1);
539 
540  /*l
541  *b Description:
542  **
543  ** Puts the group into the specified formation, applying
544  ** agent_pursue_character_with_offset() to each character except the
545  ** leader.
546  **
547  *b Arguments:
548  **
549  *a leader - leader; can be NULL
550  *a formation - name of formation
551  *a goal_x - x component of the formation's goal point
552  *a goal_y - y component of the formation's goal point
553  *a desired_radius - if not given (-1.0), get radius from formation
554  *a require_sort - if 1, group must be resorted; if 0, it may still
555  *a be
556  **
557  *b Returns:
558  **
559  ** 0 on success, -1 on failure
560 
561  */
562  int apply_formation_to_group_with_goal(diguyCharacter* leader,
563  diguyFormation* formation,
564  float goal_x,
565  float goal_y,
566  float desired_radius = -1.0f,
567  int require_sort = 1);
568 
569  /*l
570  *b Description:
571  **
572  ** Puts the group into the specified formation, applying
573  ** agent_pursue_character_with_offset() to each character except the
574  ** leader.
575  **
576  *b Arguments:
577  **
578  *a leader - leader; can be NULL
579  *a formation - name of formation
580  *a desired_radius - if not given (-1.0), get radius from formation
581  *a require_sort - if 1, group must be resorted; if 0, it may still
582  *a be
583  **
584  *b Returns:
585  **
586  ** 0 on success, -1 on failure
587  */
588  int apply_formation_to_group(diguyCharacter* leader,
589  diguyFormation* formation,
590  float desired_radius = -1.0f,
591  int require_sort = 1);
592 
593  /*l
594  *b Description:
595  **
596  ** Returns the last-set formation
597  **
598  *b Returns:
599  **
600  ** The formation or NULL
601  */
602  diguyFormation* get_current_formation();
603 
604  /*l
605  *b Description:
606  **
607  ** Sorts group relative to the point given. The point should be on
608  ** the left or in the front, depending on what order the formation is
609  ** in. This updates an internal list of sorted group members.
610  **
611  *b Arguments:
612  **
613  *a x - x component of point
614  *a y - y component of point
615  *a z - z component of point
616  *a formation - the formation; pass NULL for no formation
617  *a leader - the leader; pass NULL for no formation leader
618  **
619  *b Returns:
620  **
621  ** 0 on success, -1 on failure
622  */
623  int sort_group_based_on_pos(float x,
624  float y,
625  float z,
626  diguyFormation* formation = NULL,
627  diguyCharacter* leader = NULL);
628 
629  /*l
630  *b Returns:
631  **
632  ** member of formation-sorted group; NULL if no character at index
633  */
634  diguyCharacter* get_sorted_member_at_index(int index);
635 
636  /*l
637  *b Returns:
638  **
639  ** number of active members
640  */
641  int get_num_active_members();
642 
647 #ifdef CPLUSPLUS_ONLY
648 
649  bdiScenarioCharacterGroup* get_scripted_object() {return m_scripted_object;}
650 
651 private:
652 
653  /*l
654  ** A private constructor.
655  */
656  diguyCharacterGroup(bdiScenarioCharacterGroup* scripted_object);
657 
658  /*l
659  ** A private destructor.
660  */
661  virtual ~diguyCharacterGroup();
662 
663  /*l
664  ** A pointer to internal data.
665  */
666  bdiScenarioCharacterGroup* m_scripted_object;
667 
668  friend class bdiScenarioCharacterGroup;
669 
670 #endif
671 
672 };
673 
674 
675 #endif /* __diguyCharacterGroup_H */
676 
677 
678 /*********************************************************************
679  ** Copyright (c) 1992-2015 VT MAK
680  ** All rights reserved.
681  *********************************************************************/
682 
Definition: diguyViewLabel.h:44
A group of DI-Guy characters, useful for organizing your scenarios.
Definition: diguyCharacterGroup.h:39
The class that represents a DI-Guy Entity in the world.
Definition: diguyCharacter.h:78
A class that represents the layout of a group of characters.
Definition: diguyFormation.h:41
static double t
4 Header files and forward declarations
Definition: simple_playback_ogl.cpp:53
Definition: diguyVariable.h:38