DI-Guy C++ SDK Reference  13.0
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyCharacterGroup.h
Go to the documentation of this file.
1 
2 /*********************************************************************
3  ** Copyright (c) 1992-2014 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 
36 /****************************************************************************/
37 class BDI_DECLSPEC_diguy diguyCharacterGroup
38 {
39 
40 public:
41 
42  /*l
43  *b Returns:
44  **
45  ** name of the group; this value will never be NULL
46  **
47  *b Callable From:
48  **
49  *- - C++
50  *- - Script
51  */
52  const char* get_name();
53 
54  /*l
55  *b Description:
56  **
57  ** This function sets the name of this object.
58  **
59  *b Returns:
60  **
61  ** 0 on success, -1 on failure
62  **
63  *b Callable From:
64  **
65  *- - C++
66  *- - Script
67  */
68  int set_name(const char* name);
69 
70  /*l
71  *b Description:
72  **
73  ** Adds the passed character to the group if not already in it.
74  **
75  *b Returns:
76  **
77  ** 0 if the character is now a part of the group, -1 if not
78  **
79  *b Callable From:
80  **
81  *- - C++
82  *- - Script
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  *b Callable From:
96  **
97  *- - C++
98  *- - Script
99  */
100  int add_all_characters_as_members();
101 
102  /*l
103  *b Description:
104  **
105  ** Removes the passed character from the group if it
106  ** is a member.
107  **
108  *b Returns:
109  **
110  ** 0 if the character was part of the group and removed;
111  ** -1 if not
112  **
113  *b Callable From:
114  **
115  *- - C++
116  *- - Script
117  */
118  int remove_member(diguyCharacter* character);
119 
120  /*l
121  *b Description:
122  **
123  ** Removes all members of the group.
124  **
125  *b Returns:
126  **
127  ** Always return 0.
128  **
129  *b Callable From:
130  **
131  *- - C++
132  *- - Script
133  */
134  int remove_all_members();
135 
136  /*l
137  *b Description:
138  **
139  ** The function can be used to check if a specific character is in
140  ** this group.
141  **
142  ** Also see diguyCharacter::is_group_member().
143  **
144  *b Returns:
145  **
146  ** 1 if the passed character is a member of the group;
147  ** 0 if not
148  **
149  *b Callable From:
150  **
151  *- - C++
152  *- - Script
153  */
154  int is_member(diguyCharacter* character);
155 
156  /*l
157  *b Returns:
158  **
159  ** number of member characters in group
160  **
161  *b Callable From:
162  **
163  *- - C++
164  *- - Script
165  */
166  int get_num_members();
167 
168  /*l
169  *b Returns:
170  **
171  ** group member at specified index; NULL if no character
172  ** at specified index
173  **
174  *b Callable From:
175  **
176  *- - C++
177  *- - Script
178  */
179  diguyCharacter* get_member_at_index(int index);
180 
181  /*l
182  *b Returns:
183  **
184  ** index of member, or -1 if not found
185  **
186  *b Callable From:
187  **
188  *- - C++
189  *- - Script
190  */
191  int get_index_of_member(diguyCharacter* character);
192 
193  /*l
194  *b Description:
195  **
196  ** See diguyFormation for a description of subgroups.
197  **
198  *b Returns:
199  **
200  ** subgroup number within formation of character at index,
201  ** or -1
202  **
203  *b Callable From:
204  **
205  *- - C++
206  *- - Script
207  */
208  int get_subgroup_number(diguyFormation* formation, int index);
209 
210  /*l
211  *b Description:
212  **
213  ** See diguyFormation for a description of subgroups.
214  **
215  *b Returns:
216  **
217  ** index within subgroup, or 0
218  **
219  *b Callable From:
220  **
221  *- - C++
222  *- - Script
223  */
224  int get_index_in_subgroup(diguyFormation* formation, int index);
225 
226 
227  /*l
228  *b Description:
229  **
230  ** Sets whether all characters in group are enabled. Equivalent to
231  ** calling diguyCharacter::set_enabled() for group members.
232  **
233  *b Returns:
234  **
235  ** Always return 0.
236  **
237  *b Callable From:
238  **
239  *- - C++
240  *- - Script
241  */
242  int set_all_members_enabled(int enabled);
243 
244  /*l
245  *b Description:
246  **
247  ** Updates all characters in the group. Equivalent to calling
248  ** diguyCharacter::update() for all group members.
249  **
250  *b Returns:
251  **
252  ** 0 on success, -1 on failure
253  **
254  *b Callable From:
255  **
256  *- - C++
257  *- - Script
258  */
259  int update_all_members(float t);
260 
261 #ifdef CPLUSPLUS_ONLY
262 
263  /*l
264  *b Description:
265  **
266  ** This function draws all members of the group.
267  ** See diguyCharacter::draw().
268  **
269  *b Returns:
270  **
271  ** 0 on success, -1 on failure
272  **
273  *b Callable From:
274  **
275  *- - C++
276  */
277  int draw_all_members();
278 
279  /*l
280  *b Description:
281  **
282  ** This function draws pass 1 of all members of the group.
283  ** See diguyCharacter::draw_pass1().
284  **
285  *b Returns:
286  **
287  ** 0 on success, -1 on failure
288  **
289  *b Callable From:
290  **
291  *- - C++
292  */
293  int draw_pass1_all_members();
294 
295  /*l
296  *b Description:
297  **
298  ** This function draws pass 2 all members of the group.
299  ** See diguyCharacter::draw_pass2().
300  **
301  *b Returns:
302  **
303  ** 0 on success, -1 on failure
304  **
305  *b Callable From:
306  **
307  *- - C++
308  */
309  int draw_pass2_all_members();
310 
311 #endif
312 
313  /*l
314  *b Description:
315  **
316  ** This function sets the current tin time of all characters
317  ** in the group. See diguyCharacter::set_current_tin().
318  **
319  *b Arguments:
320  **
321  *a tin - new value of current tin in seconds
322  **
323  *b Returns:
324  **
325  ** 0 on success, -1 on failure
326  **
327  *b Callable From:
328  **
329  *- - C++
330  *- - Script
331  */
332  int set_all_members_current_tin(float tin);
333 
334  /*l
335  *b Description:
336  **
337  ** This function sets the current tout time of all characters
338  ** in the group. See diguyCharacter::set_current_tout().
339  **
340  *b Arguments:
341  **
342  *a tout - new value of current tout in seconds
343  **
344  *b Returns:
345  **
346  ** 0 on success, -1 on failure
347  **
348  *b Callable From:
349  **
350  *- - C++
351  *- - Script
352  */
353  int set_all_members_current_tout(float tout);
354 
355 
356 /*****************************************************************************/
367  /*l
368  *b Description:
369  **
370  ** This function returns a pointer to the label object of
371  ** the group.
372  **
373  ** Currently group labels are only enabled in DI-Guy Scenario.
374  **
375  *b Returns:
376  **
377  ** pointer to the group's label
378  **
379  *b Callable From:
380  **
381  *- - C++
382  *- - Script
383  */
384  diguyViewLabel* get_label();
385 
386  /*l
387  *b Description:
388  **
389  ** This function sets how high the label of the group will float
390  ** above the group's centroid.
391  **
392  *b Arguments:
393  **
394  *a offset - offset, in meters, of label above group
395  **
396  *b Callable From:
397  **
398  *- - C++
399  *- - Script
400  */
401  void set_label_offset_above_centroid(float offset);
402 
403  /*l
404  *b Returns:
405  **
406  ** how high the label of the group will float above the group centroid
407  **
408  *b Callable From:
409  **
410  *- - C++
411  *- - Script
412  */
413  float get_label_offset_above_centroid();
414 
415 
416 /*****************************************************************************/
422  /*l
423  *b Returns:
424  **
425  ** number of variables the group has
426  **
427  *b Callable From:
428  **
429  *- - C++
430  *- - Script
431  */
432  int get_num_variables();
433 
434  /*l
435  *b Returns:
436  **
437  ** pointer of type diguyVariable; NULL if no
438  ** variable at the specified index
439  **
440  *b Arguments:
441  **
442  *a index - index of the variable; indices start at 0
443  **
444  *b Callable From:
445  **
446  *- - C++
447  *- - Script
448  */
449  diguyVariable* get_variable_at_index(int index);
450 
451  /*l
452  *b Description:
453  **
454  ** This function returns a pointer to the specified variable.
455  **
456  *b Arguments:
457  **
458  *a name - name of variable to be found
459  **
460  *b Returns:
461  **
462  ** pointer of type diguyVariable; NULL if not found
463  **
464  *b Callable From:
465  **
466  *- - C++
467  *- - Script
468  */
469  diguyVariable* find_variable(const char* name);
470 
471  /*l
472  *b Description:
473  **
474  ** This function finds the variable with the given name or
475  ** creates it if it doesn't exist.
476  **
477  *b Arguments:
478  **
479  *a name - name of the variable to find or create
480  **
481  *b Returns:
482  **
483  ** pointer of type diguyVariable; should never be NULL
484  **
485  *b Callable From:
486  **
487  *- - C++
488  *- - Script
489  */
490  diguyVariable* find_or_create_variable(const char* name);
491 
492  /*l
493  *b Description:
494  **
495  ** This function destroys the passed variable.
496  **
497  *b Arguments:
498  **
499  *a variable - pointer to a diguyVariable
500  **
501  *b Returns:
502  **
503  ** 0 on success, -1 on failure
504  **
505  *b Callable From:
506  **
507  *- - C++
508  *- - Script
509  */
510  int destroy_variable(diguyVariable* variable);
511 
512 
513 /****************************************************************************/
514 /****************************************************************************/
515 /****************************************************************************/
519 /****************************************************************************/
520 /****************************************************************************/
521 /****************************************************************************/
522 
523  int translate_all_paths(float tx, float ty, float tz);
524 
525  int rotate_all_paths_about_point(float rz, float rx, float ry,
526  float rotation_pt_x, float rotation_pt_y, float rotation_pt_z);
527 
528  int rotate_all_paths_about_current_waypoint(float rz, float rx, float ry);
529 
530  /*l
531  *b Description:
532  **
533  ** Get the character closest to the specified point.
534  **
535  *b Arguments:
536  **
537  *a x, y, z - position in meters from the origin
538  **
539  *b Returns:
540  **
541  ** pointer to diguyCharacter, or NULL in none found
542  **
543  *b Callable From:
544  **
545  *- - C++
546  *- - Script
547  */
548  diguyCharacter* get_nearest_character_to_point(float x, float y, float z);
549 
550  /*l
551  *b Description:
552  **
553  ** Get the character furthest from the specified point.
554  **
555  *b Arguments:
556  **
557  *a x, y, z - position in meters from the origin
558  **
559  *b Returns:
560  **
561  ** pointer to diguyCharacter, or NULL if none found
562  **
563  *b Callable From:
564  **
565  *- - C++
566  *- - Script
567  */
568  diguyCharacter* get_farthest_character_to_point(float x, float y, float z);
569 
570  /*l
571  *b Description:
572  **
573  ** Get centroid of group (average of character positions).
574  **
575  *b Arguments:
576  **
577  *a x, y, z - position in meters from the origin
578  **
579  *b Returns:
580  **
581  ** 0 on success, -1 on failure
582  **
583  *b Callable From:
584  **
585  *- - C++
586  *- - Script
587  */
588  int get_group_centroid(float* x, float* y, float* z);
589 
590  /*l
591  *b Description:
592  **
593  ** Get minimum enclosing circle of group. Note that this is slower
594  ** than getting the centroid.
595  **
596  *b Arguments:
597  **
598  *a x, y, z - center of circle of group in meters from the origin
599  *a radius - radius of circle
600  **
601  *b Returns:
602  **
603  ** 0 on success, -1 on failure
604  **
605  *b Callable From:
606  **
607  *- - C++
608  *- - Script
609  */
610  int get_group_min_circle(float* x, float* y, float* z, float* radius);
611 
612  /*l
613  *b Description:
614  **
615  ** Send a message to all characters in group. See
616  ** diguyCharacter::agent_accept_message().
617  **
618  *b Arguments:
619  **
620  *a sender - who is sending the message
621  *a message_type - what type of message is being sent
622  *a message - the message string
623  *a message_params - optional parameter string
624  **
625  *b Returns:
626  **
627  ** 0 on success, -1 on failure
628  **
629  *b Callable From:
630  **
631  *- - C++
632  *- - Script
633  */
634  int send_message_to_all_members(const char* sender,
635  const char* message_type,
636  const char* message,
637  const char* message_params = NULL);
638 
639  /*l
640  *b Description:
641  **
642  ** Puts the group into the specified formation, applying
643  ** agent_pursue_character_with_offset() to each character except the
644  ** leader.
645  **
646  *b Arguments:
647  **
648  *a leader - leader; can be NULL
649  *a formation - name of formation
650  *a dir_x - x component of the formation's heading
651  *a dir_y - y component of the formation's heading
652  *a desired_radius - if not given (-1.0), get radius from formation
653  *a require_sort - if 1, group must be resorted; if 0, it may still
654  *a be
655  **
656  *b Returns:
657  **
658  ** 0 on success, -1 on failure
659  **
660  *b Callable From:
661  **
662  *- - C++
663  *- - Script
664  */
665  int apply_formation_to_group_with_dir(diguyCharacter* leader,
666  diguyFormation* formation,
667  float dir_x,
668  float dir_y,
669  float desired_radius = -1.0f,
670  int require_sort = 1);
671 
672  /*l
673  *b Description:
674  **
675  ** Puts the group into the specified formation, applying
676  ** agent_pursue_character_with_offset() to each character except the
677  ** leader.
678  **
679  *b Arguments:
680  **
681  *a leader - leader; can be NULL
682  *a formation - name of formation
683  *a goal_x - x component of the formation's goal point
684  *a goal_y - y component of the formation's goal point
685  *a desired_radius - if not given (-1.0), get radius from formation
686  *a require_sort - if 1, group must be resorted; if 0, it may still
687  *a be
688  **
689  *b Returns:
690  **
691  ** 0 on success, -1 on failure
692  **
693  *b Callable From:
694  **
695  *- - C++
696  *- - Script
697  */
698  int apply_formation_to_group_with_goal(diguyCharacter* leader,
699  diguyFormation* formation,
700  float goal_x,
701  float goal_y,
702  float desired_radius = -1.0f,
703  int require_sort = 1);
704 
705  /*l
706  *b Description:
707  **
708  ** Puts the group into the specified formation, applying
709  ** agent_pursue_character_with_offset() to each character except the
710  ** leader.
711  **
712  *b Arguments:
713  **
714  *a leader - leader; can be NULL
715  *a formation - name of formation
716  *a desired_radius - if not given (-1.0), get radius from formation
717  *a require_sort - if 1, group must be resorted; if 0, it may still
718  *a be
719  **
720  *b Returns:
721  **
722  ** 0 on success, -1 on failure
723  **
724  *b Callable From:
725  **
726  *- - C++
727  *- - Script
728  */
729  int apply_formation_to_group(diguyCharacter* leader,
730  diguyFormation* formation,
731  float desired_radius = -1.0f,
732  int require_sort = 1);
733 
734  /*l
735  *b Description:
736  **
737  ** Returns the last-set formation
738  **
739  *b Returns:
740  **
741  ** The formation or NULL
742  **
743  *b Callable From:
744  **
745  *- - C++
746  *- - Script
747  */
748  diguyFormation* get_current_formation();
749 
750  /*l
751  *b Description:
752  **
753  ** Sorts group relative to the point given. The point should be on
754  ** the left or in the front, depending on what order the formation is
755  ** in. This updates an internal list of sorted group members.
756  **
757  *b Arguments:
758  **
759  *a x - x component of point
760  *a y - y component of point
761  *a z - z component of point
762  *a formation - the formation; pass NULL for no formation
763  *a leader - the leader; pass NULL for no formation leader
764  **
765  *b Returns:
766  **
767  ** 0 on success, -1 on failure
768  **
769  *b Callable From:
770  **
771  *- - C++
772  *- - Script
773  */
774  int sort_group_based_on_pos(float x,
775  float y,
776  float z,
777  diguyFormation* formation = NULL,
778  diguyCharacter* leader = NULL);
779 
780  /*l
781  *b Returns:
782  **
783  ** member of formation-sorted group; NULL if no character at index
784  **
785  *b Callable From:
786  **
787  *- - C++
788  *- - Script
789  */
790  diguyCharacter* get_sorted_member_at_index(int index);
791 
792  /*l
793  *b Returns:
794  **
795  ** number of active members
796  **
797  *b Callable From:
798  **
799  *- - C++
800  *- - Script
801  */
802  int get_num_active_members();
803 
808 #ifdef CPLUSPLUS_ONLY
809 
810  bdiScenarioCharacterGroup* get_scripted_object() {return m_scripted_object;}
811 
812 private:
813 
814  /*l
815  ** A private constructor.
816  */
817  diguyCharacterGroup(bdiScenarioCharacterGroup* scripted_object);
818 
819  /*l
820  ** A private destructor.
821  */
822  virtual ~diguyCharacterGroup();
823 
824  /*l
825  ** A pointer to internal data.
826  */
827  bdiScenarioCharacterGroup* m_scripted_object;
828 
829  friend class bdiScenarioCharacterGroup;
830 
831 #endif
832 
833 };
834 
835 
836 #endif /* __diguyCharacterGroup_H */
837 
838 
839 /*********************************************************************
840  ** Copyright (c) 1992-2014 VT MAK
841  ** All rights reserved.
842  *********************************************************************/
843