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