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