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