C++ SDK Reference  12.5
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
diguyImpact.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  *t diguyImpact
30  **
31  *b Link against: libdiguy
32  */
33 
34 #ifndef __diguyImpact_H
35 #define __diguyImpact_H
36 
37 #ifdef SWIG
38 %module diguyImpact
39 #else
40 #define CPLUSPLUS_ONLY
41 #endif
42 
43 #ifdef CPLUSPLUS_ONLY
44 #include <stdio.h> // for NULL
45 class diguyCharacter;
46 class diguyScenario;
47 class diguySceneObject;
48 #endif
49 
50 #include <declspec_diguy.h>
51 #include <diguy_constants.h>
52 #include <diguy_vector_classes.h>
53 
54 /****************************************************************************/
55 class BDI_DECLSPEC_diguy diguyImpact
56 {
57 
58 public:
59 
60 /****************************************************************************/
70  /*l
71  *b Description:
72  **
73  ** Returns the type of impact; this is based on how the collision was
74  ** generated. Possible values are:
75  **
76  *- - DIGUY_IMPACT_DIRECT_HIT
77  *- - DIGUY_IMPACT_NEARBY_DETONATION
78  *- - DIGUY_IMPACT_VEHICLE_COLLISION
79  *- - DIGUY_IMPACT_NO_IMPACT
80  *- - DIGUY_IMPACT_USER_GENERATED
81  **
82  ** Note: NO_IMPACT is generated when a character fires but fails the
83  ** hit ratio test. The location of the impact is then set to the
84  ** attacker's position, or if that is unavailable to:
85  ** (DIGUY_DEFAULT_FLOAT, DIGUY_DEFAULT_FLOAT, DIGUY_DEFAULT_FLOAT).
86  **
87  *b Returns:
88  **
89  ** the type of impact
90  */
91  diguyImpactType get_impact_type();
92 
93  /*l
94  *b Returns:
95  **
96  ** the string version of the type of impact. This is based
97  ** on how the collision was generated. Possible values are:
98  **
99  *- - "direct_hit"
100  *- - "nearby_detonation"
101  *- - "vehicle_collision"
102  *- - "no_impact"
103  *- - "user_generated"
104  */
105  const char* get_impact_type_string();
106 
107  /*l
108  *b Returns:
109  **
110  ** the number of hits made by this impact. This includes hits
111  ** against characters and scene objects.
112  */
113  int get_num_hits();
114 
115  /*l
116  *b Returns:
117  **
118  ** the name of the attacker. This pointer may be NULL if
119  ** there is no attacker character.
120  */
121  const char* get_attacker_name();
122 
123  /*l
124  *b Returns:
125  **
126  ** Returns a pointer to the attacker. This pointer may be NULL.
127  */
128  diguyCharacter* get_attacker();
129 
130  /*l
131  *b Returns:
132  **
133  ** the name of the target. This pointer may be NULL if there
134  ** is no impact target character (e.g., impact is against a scene
135  ** object).
136  */
137  const char* get_target_name();
138 
139  /*l
140  *b Returns:
141  **
142  ** the diguyCharacter impact target. This pointer may be NULL if there is no
143  ** impact target character (e.g., impact is against a scene object).
144  */
145  diguyCharacter* get_target();
146 
147  /*l
148  *b Returns:
149  **
150  ** name of the target character link that was hit; may be NULL if
151  ** there is no hit target character
152  */
153  const char* get_hit_link_name();
154 
155  /*l
156  *b Returns:
157  **
158  ** index of the target character link that was hit
159  */
160  int get_hit_link_index();
161 
162  /*l
163  *b Returns:
164  **
165  ** name of the target character shape that was hit; may be NULL if
166  ** there is no hit target character
167  */
168  const char* get_hit_shape_name();
169 
170  /*l
171  *b Returns:
172  **
173  ** the number of impacts the target character has taken
174  */
175  int get_impact_number();
176 
177  /*l
178  *b Description:
179  **
180  ** Sets the impact number.
181  */
182  void set_impact_number(int val);
183 
184  /*l
185  *b Description:
186  **
187  ** Sets that the impact has been processed.
188  */
189  void set_impact_been_processed();
190 
191  /*l
192  *b Returns:
193  **
194  ** 1 if the impact has been processed, 0 if not
195  */
196  int get_impact_been_processed();
197 
198  /*l
199  *b Returns:
200  **
201  ** the approximate world x coordinate of the impact
202  */
203  float get_x();
204 
205  /*l
206  *b Returns:
207  **
208  ** the approximate world y coordinate of the impact
209  */
210  float get_y();
211 
212  /*l
213  *b Returns:
214  **
215  ** the approximate world z coordinate of the impact
216  */
217  float get_z();
218 
219  /*l
220  *b Description:
221  **
222  ** Alternative method for getting the location of the impact.
223  */
224  void get_location(float* x, float* y, float* z);
225 
226  /*l
227  *b Returns:
228  **
229  ** the radius of the impact
230  */
231  float get_impact_radius();
232 
233  /*l
234  *b Returns:
235  **
236  ** the speed of the impact
237  */
238  float get_impact_speed();
239 
240  /*l
241  *b Description:
242  **
243  ** This function returns the location of the impact in link-relative
244  ** coordinates. The function may fail and return -1 if a link was not
245  ** hit by the impact.
246  **
247  *b Arguments:
248  **
249  *a link_x, link_y, link_z - link-relative coordinates are
250  ** returned in these variables
251  **
252  *b Returns:
253  **
254  ** 0 on success, -1 on failure
255  */
256  int get_location_in_link_coordinates(float* link_x,
257  float* link_y,
258  float* link_z);
259 
260  /*l
261  *b Description:
262  **
263  ** This function resets all of the impact data to default values.
264  */
265  void reset();
266 
267  /*l
268  *b Description:
269  **
270  ** This function returns the name of the munition that was fired. This
271  ** is useful for creating impact callbacks that respond differently to
272  ** different weapons.
273  **
274  *b Returns:
275  **
276  ** the munition type of the impact; may be NULL
277  */
278  const char* get_munition_type();
279 
280  /*l
281  *b Description:
282  **
283  ** Returns the hit diguySceneObject.
284  **
285  ** This pointer may be NULL if there is no impact scene object (e.g.,
286  ** impact is against a character).
287  **
288  ** If the octtree was used to generate the impact, this pointer will
289  ** be NULL.
290  **
291  *b Returns:
292  **
293  ** pointer of type diguySceneObject
294  */
295  diguySceneObject* get_hit_scene_object();
296 
297  /*l
298  *b Returns:
299  **
300  ** approximate normal x coordinate of the impact; may not be valid
301  */
302  float get_normal_x();
303 
304  /*l
305  *b Returns:
306  **
307  ** approximate normal y coordinate of the impact; may not be valid
308  */
309  float get_normal_y();
310 
311  /*l
312  *b Returns:
313  **
314  ** approximate normal z coordinate of the impact; may not be valid
315  */
316  float get_normal_z();
317 
318  /*l
319  *b Description:
320  **
321  ** Alternative method for getting the normal of the impact.
322  */
323  void get_impact_normal(float* x, float* y, float* z);
324 
325 
326 /*****************************************************************************/
334  /*l
335  *b Description:
336  **
337  ** Velocity of projectile at impact. May be 0 if no velocity
338  ** information is available.
339  */
340  void get_impact_velocity(float* x, float* y, float* z);
341 
342  /*l
343  *b Returns:
344  **
345  ** 1 if impact was generated as a result of a network detonation (e.g.
346  ** a DIS detonation PDU), else 0
347  */
348  int get_is_from_net_detonation();
349 
350  /*l
351  *b Description:
352  **
353  ** This function returns the specified part of the DIS septet of the
354  ** detonation's munition septet.
355  **
356  *b Arguments:
357  **
358  *a septet_index - which part of the septet to return; must be between
359  *a 0 (for 'kind') and 6 (for 'extra')
360  **
361  ** Returns -1 if septet isn't specified, or on error.
362  */
363  int get_DIS_munition_septet_value(int septet_index);
364 
365  /*l
366  *b Returns:
367  **
368  ** the site id part of the detonation PDU event id; -1 if not set
369  */
370  int get_DIS_site();
371 
372  /*l
373  *b Returns:
374  **
375  ** the host id part of the detonation PDU event id; -1 if not set
376  */
377  int get_DIS_host();
378 
379  /*l
380  *b Returns:
381  **
382  ** the event number part of the detonation PDU event id; -1 if not set
383  */
384  int get_DIS_event_number();
385 
386  /*l
387  *b Returns:
388  **
389  ** the event number part of the detonation PDU *munition* event id;
390  ** -1 if not set
391  */
392  int get_DIS_munition_number();
393 
394  /*l
395  *b Returns:
396  **
397  ** the detonation result of the detonation PDU; -1 if not set
398  */
399  int get_DIS_detonation_result();
400 
401  /*l
402  *b Returns:
403  **
404  ** the warhead type enumeration of the detonation PDU's burst
405  ** descriptor; -1 if not set
406  */
407  int get_DIS_burst_warhead_type();
408 
409  /*l
410  *b Returns:
411  **
412  ** the fuze enumeration of the detonation PDU's burst descriptor; -1
413  ** if not set
414  */
415  int get_DIS_burst_fuze();
416 
417  /*l
418  *b Returns:
419  **
420  ** the burst quantity of the detonation PDU's burst descriptor; -1 if
421  ** not set
422  */
423  int get_DIS_burst_quantity();
424 
425  /*l
426  *b Returns:
427  **
428  ** the burst rate of the detonation PDU's burst descriptor; -1 if not
429  ** set
430  */
431  int get_DIS_burst_rate();
432 
433 
434 #ifdef CPLUSPLUS_ONLY
435 
436 /*****************************************************************************/
501  /*l
502  *b Description:
503  **
504  ** This function sets the impact to be valid. It must be called if
505  ** the impact hits a character.
506  */
507  void set_valid_impact();
508 
509  /*l
510  *b Description:
511  **
512  ** This function allows for explicitly setting the target character of
513  ** this impact object.
514  **
515  *b Arguments:
516  **
517  *a x, y, z - override target of impact
518  **
519  *b Callable From:
520  **
521  *- - C++
522  */
523  void set_target(diguyCharacter* target);
524 
525  /*l
526  *b Description:
527  **
528  ** This function allows for explicitly setting the position of this
529  ** impact object.
530  **
531  *b Arguments:
532  **
533  *a x, y, z - override position of impact
534  **
535  *b Callable From:
536  **
537  *- - C++
538  */
539  void set_location(float x, float y, float z);
540 
541  /*l
542  *b Description:
543  **
544  ** This function allows for explicitly setting the normal of this
545  ** impact object.
546  **
547  *b Arguments:
548  **
549  *a nx, ny, nz - override normal of impact
550  **
551  *b Callable From:
552  **
553  *- - C++
554  */
555  void set_normal(float nx, float ny, float nz);
556 
557  /*l
558  *b Description:
559  **
560  ** Returns the hit scene object.
561  **
562  ** This function allows for explicitly setting the scene_object that
563  ** the impact object hit.
564  **
565  ** If the octtree was used to generate the impact, this pointer will
566  ** be NULL.
567  **
568  *b Arguments:
569  **
570  *a scene_object - pointer to scene object hit
571  **
572  *b Callable From:
573  **
574  *- - C++
575  */
576  void set_hit_scene_object(diguySceneObject* scene_object);
578  /*l
579  *b Description:
580  **
581  ** This function allows for explicitly setting the link index of this
582  ** impact object.
583  **
584  *b Callable From:
585  **
586  *- - C++
587  */
588  void set_hit_link_index(int index);
589 
590  /*l
591  *b Description:
592  **
593  ** This function allows for explicitly setting the shape index of this
594  ** impact object.
595  **
596  *b Callable From:
597  **
598  *- - C++
599  */
600  void set_hit_shape_index(int index);
601 
602 
603 /****************************************************************************/
604 /****************************************************************************/
610 private:
612  friend class bdiScenarioEditorDIGS;
613  friend class bdiPublishedCharacter;
614  friend class bdiScenario;
615  friend class bdiScenarioCharacter;
616  friend class bdiScenarioCrowdWorkManager;
617  friend class diguyCharacter;
618  friend class bdiQGLWidget;
619 
620  void set_munition_type(const char* munition_type);
621 
622  /*l
623  ** Private constructors.
624  */
629  int num_hits = 0,
630  diguyCharacter* attacker = NULL,
631  diguyCharacter* target = NULL,
632  diguySceneObject* hit_scene_object = NULL,
633  int link_index = -1,
634  int shape_index = -1,
635  float* location = NULL,
636  float* normal = NULL,
637  float impact_speed = 0.0f,
638  float radius = 0.0f,
639  const char* munition_type = NULL);
640 
641  /*
642  * Private data members.
643  */
644  diguyScenario* m_scenario;
645  diguyImpactType m_impact_type;
646  int m_num_hits;
647  diguyCharacter* m_attacker;
648  diguyCharacter* m_target;
649  diguySceneObject* m_hit_scene_object;
650  int m_link_index;
651  int m_shape_index;
652  int m_impact_number;
653  int m_impact_processed;
654  float m_location[3];
655  float m_normal[3];
656  float m_impact_speed;
657  float m_impact_radius;
658  char m_munition_type[128];
659 
660 public:
661  /*
662  * FOR INTERNAL DI-GUY USE ONLY
663  */
664  int m_is_from_net_detonation;
665  int m_DIS_munition_septet[7];
666  int m_DIS_site;
667  int m_DIS_host;
668  int m_DIS_event_number;
669  int m_DIS_munition_number;
670  int m_DIS_detonation_result;
671  int m_DIS_burst_warhead_type;
672  int m_DIS_burst_fuze;
673  int m_DIS_burst_quantity;
674  int m_DIS_burst_rate;
675  float m_impact_velocity[3];
676 private:
677 
678 #endif
679 
680 };
681 
682 
683 /****************************************************************************/
685 class BDI_DECLSPEC_diguy diguyIntersectionResult
686 {
687 public:
688  diguyIntersectionResult() : m_impact_character(NULL), m_impact_scene_object(NULL), m_valid_impact(0)
689  {;}
691  diguyCharacter * m_impact_character;
692  diguySceneObject * m_impact_scene_object;
693  diguyVec3f m_impact_point;
694  diguyVec3f m_impact_normal;
695  int m_valid_impact;
696 };
697 
698 #endif /* __diguyImpact_H */
699