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