DI-Guy SDK Documentation  13.7.1
diguyImpact Class Reference

A class that represents a bullet impact in the world, often used by AIs to make reaction decisions. More...

#include <diguyImpact.h>

Public Member Functions

Accessor functions

Unless otherwise noted all functions in this class section are callable from:

  • C++
  • Script
diguyImpactType get_impact_type ()
 Returns the type of impact; this is based on how the collision was generated. More...
 
const char * get_impact_type_string ()
 Returns: the string version of the type of impact. More...
 
int get_num_hits ()
 Returns: the number of hits made by this impact. More...
 
const char * get_attacker_name ()
 Returns: the name of the attacker. More...
 
diguyCharacterget_attacker ()
 Returns: Returns a pointer to the attacker. More...
 
const char * get_target_name ()
 Returns: the name of the target. More...
 
diguyCharacterget_target ()
 Returns: the diguyCharacter impact target. More...
 
const char * get_hit_link_name ()
 Returns: name of the target character link that was hit; may be NULL if there is no hit target character. More...
 
int get_hit_link_index ()
 Returns: index of the target character link that was hit. More...
 
const char * get_hit_shape_name ()
 Returns: name of the target character shape that was hit; may be NULL if there is no hit target character. More...
 
int get_hit_shape_index ()
 Returns: index of the target character shape that was hit. More...
 
int get_impact_number ()
 Returns: the number of impacts the target character has taken. More...
 
void set_impact_number (int val)
 Sets the impact number. More...
 
void set_impact_been_processed ()
 Sets that the impact has been processed. More...
 
int get_impact_been_processed ()
 Returns: 1 if the impact has been processed, 0 if not. More...
 
float get_x ()
 Returns: the approximate world x coordinate of the impact. More...
 
float get_y ()
 Returns: the approximate world y coordinate of the impact. More...
 
float get_z ()
 Returns: the approximate world z coordinate of the impact. More...
 
void get_location (float *x, float *y, float *z)
 Alternative method for getting the location of the impact. More...
 
float get_impact_radius ()
 Returns: the radius of the impact. More...
 
float get_impact_speed ()
 Returns: the speed of the impact. More...
 
int get_location_in_link_coordinates (float *link_x, float *link_y, float *link_z)
 This function returns the location of the impact in link-relative coordinates. More...
 
void reset ()
 This function resets all of the impact data to default values. More...
 
const char * get_munition_type ()
 This function returns the name of the munition that was fired. More...
 
diguySceneObjectget_hit_scene_object ()
 Returns the hit diguySceneObject. More...
 
float get_normal_x ()
 Returns: approximate normal x coordinate of the impact; may not be valid. More...
 
float get_normal_y ()
 Returns: approximate normal y coordinate of the impact; may not be valid. More...
 
float get_normal_z ()
 Returns: approximate normal z coordinate of the impact; may not be valid. More...
 
void get_impact_normal (float *x, float *y, float *z)
 Alternative method for getting the normal of the impact. More...
 
Experimental DIS Detonation Functions

The following functions are experimental.

They are for accessing data from DIS detonations that result in DI-Guy impacts being generated.

void get_impact_velocity (float *x, float *y, float *z)
 Velocity of projectile at impact. More...
 
int get_is_from_net_detonation ()
 Returns: 1 if impact was generated as a result of a network detonation (e.g. More...
 
int get_DIS_munition_septet_value (int septet_index)
 This function returns the specified part of the DIS septet of the detonation's munition septet. More...
 
int get_DIS_site ()
 Returns: the site id part of the detonation PDU event id; -1 if not set. More...
 
int get_DIS_host ()
 Returns: the host id part of the detonation PDU event id; -1 if not set. More...
 
int get_DIS_event_number ()
 Returns: the event number part of the detonation PDU event id; -1 if not set. More...
 
int get_DIS_munition_number ()
 Returns: the event number part of the detonation PDU munition event id; -1 if not set. More...
 
int get_DIS_detonation_result ()
 Returns: the detonation result of the detonation PDU; -1 if not set. More...
 
int get_DIS_burst_warhead_type ()
 Returns: the warhead type enumeration of the detonation PDU's burst descriptor; -1 if not set. More...
 
int get_DIS_burst_fuze ()
 Returns: the fuze enumeration of the detonation PDU's burst descriptor; -1 if not set. More...
 
int get_DIS_burst_quantity ()
 Returns: the burst quantity of the detonation PDU's burst descriptor; -1 if not set. More...
 
int get_DIS_burst_rate ()
 Returns: the burst rate of the detonation PDU's burst descriptor; -1 if not set. More...
 
Utility Functions for Intersection Functions

The following functions are meant for users who are using diguyScenario::set_fire_weapon_intersection_function() to handle weapon firing in the SDK.

In simple OpenGL environments diguy_default_fire_weapon_intersection_function() in diguy_graphics_ogl.h may give you reasonable results by rendering characters into the back buffer.

Additionally there are a number of intersection programming examples that demonstrate putting the default rendering pipeline into picking mode. Handing the resulting color under the (x, y) impact location in the graphics buffer into diguyScenario::map_color_to_impact() allows you to retrieve an impact structure with much of this information.

These functions are not callable from script.

Example impact function:

int impact_function(diguyImpact* impact,
float from_x,
float from_y,
float from_z,
float to_x,
float to_y,
float to_z,
{
// note the impact already has both the attacker and the munition type
// set when this function is called
glShadeModel(GL_FLAT);
// create narrow frustum
// turn on scissor test
// feed data into diguy camera if you want frustum culling to work
s->set_current_render_mode("intersection");
s->draw();
GLubyte pixel[3];
glReadPixels(x_center, y_center, 1, 1,
GL_RGB,
GL_UNSIGNED_BYTE,
(void *) pixel);
diguyImpact* new_impact = scenario->map_color_to_impact(pixel[0], pixel[1], pixel[2]);
// unpack data in new_impact into the callback object
impact->set_valid_impact();
impact->set_target(new_impact->get_target());
impact->set_hit_link_index(new_impact->get_hit_link_index());
impact->set_hit_shape_index(new_impact->get_hit_shape_index());
return 1;
}
void set_valid_impact ()
 This function sets the impact to be valid. More...
 
void set_target (diguyCharacter *target)
 This function allows for explicitly setting the target character of this impact object. More...
 
void set_location (float x, float y, float z)
 This function allows for explicitly setting the position of this impact object. More...
 
void set_normal (float nx, float ny, float nz)
 This function allows for explicitly setting the normal of this impact object. More...
 
void set_hit_scene_object (diguySceneObject *scene_object)
 Returns the hit scene object. More...
 
void set_hit_link_index (int index)
 This function allows for explicitly setting the link index of this impact object. More...
 
void set_hit_shape_index (int index)
 This function allows for explicitly setting the shape index of this impact object. More...
 

Private Functions

The functions and variables past this point are for internal use only.

No external access to them is expected or necessary.

class bdiScenarioEditorDIGS
 
class bdiPublishedCharacter
 
class bdiScenario
 
class bdiScenarioCharacter
 
class bdiScenarioCrowdWorkManager
 
class diguyCharacter
 
class bdiQGLWidgetDIGS
 
diguyScenariom_scenario
 
diguyImpactType m_impact_type
 
int m_num_hits
 
diguyCharacterm_attacker
 
diguyCharacterm_target
 
diguySceneObjectm_hit_scene_object
 
int m_link_index
 
int m_shape_index
 
int m_impact_number
 
int m_impact_processed
 
float m_location [3]
 
float m_normal [3]
 
float m_impact_speed
 
float m_impact_radius
 
char m_munition_type [128]
 
int m_is_from_net_detonation
 
int m_DIS_munition_septet [7]
 
int m_DIS_site
 
int m_DIS_host
 
int m_DIS_event_number
 
int m_DIS_munition_number
 
int m_DIS_detonation_result
 
int m_DIS_burst_warhead_type
 
int m_DIS_burst_fuze
 
int m_DIS_burst_quantity
 
int m_DIS_burst_rate
 
float m_impact_velocity [3]
 
void set_munition_type (const char *munition_type)
 
 diguyImpact ()
 Private constructors. More...
 
 diguyImpact (diguyScenario *scenario, diguyImpactType impact_type=DIGUY_IMPACT_DIRECT_HIT, int num_hits=0, diguyCharacter *attacker=NULL, diguyCharacter *target=NULL, diguySceneObject *hit_scene_object=NULL, int link_index=-1, int shape_index=-1, float *location=NULL, float *normal=NULL, float impact_speed=0.0f, float radius=0.0f, const char *munition_type=NULL)
 

Detailed Description

A class that represents a bullet impact in the world, often used by AIs to make reaction decisions.

Constructor & Destructor Documentation

diguyImpact::diguyImpact ( )
private

Private constructors.

diguyImpact::diguyImpact ( diguyScenario scenario,
diguyImpactType  impact_type = DIGUY_IMPACT_DIRECT_HIT,
int  num_hits = 0,
diguyCharacter attacker = NULL,
diguyCharacter target = NULL,
diguySceneObject hit_scene_object = NULL,
int  link_index = -1,
int  shape_index = -1,
float *  location = NULL,
float *  normal = NULL,
float  impact_speed = 0.0f,
float  radius = 0.0f,
const char *  munition_type = NULL 
)
private

Member Function Documentation

diguyImpactType diguyImpact::get_impact_type ( )

Returns the type of impact; this is based on how the collision was generated.

Possible values are:

  • DIGUY_IMPACT_DIRECT_HIT
  • DIGUY_IMPACT_NEARBY_DETONATION
  • DIGUY_IMPACT_VEHICLE_COLLISION
  • DIGUY_IMPACT_NO_IMPACT
  • DIGUY_IMPACT_USER_GENERATED

**

Note
NO_IMPACT is generated when a character fires but fails the hit ratio test. The location of the impact is then set to the attacker's position, or if that is unavailable to: (DIGUY_DEFAULT_FLOAT, DIGUY_DEFAULT_FLOAT, DIGUY_DEFAULT_FLOAT).

Returns:

the type of impact

const char* diguyImpact::get_impact_type_string ( )

Returns: the string version of the type of impact.

This is based on how the collision was generated. Possible values are:

  • "direct_hit"
  • "nearby_detonation"
  • "vehicle_collision"
  • "no_impact"
  • "user_generated"
int diguyImpact::get_num_hits ( )

Returns: the number of hits made by this impact.

This includes hits against characters and scene objects.

const char* diguyImpact::get_attacker_name ( )

Returns: the name of the attacker.

This pointer may be NULL if there is no attacker character.

diguyCharacter* diguyImpact::get_attacker ( )

Returns: Returns a pointer to the attacker.

This pointer may be NULL.

const char* diguyImpact::get_target_name ( )

Returns: the name of the target.

This pointer may be NULL if there is no impact target character (e.g., impact is against a scene object).

diguyCharacter* diguyImpact::get_target ( )

Returns: the diguyCharacter impact target.

This pointer may be NULL if there is no impact target character (e.g., impact is against a scene object).

const char* diguyImpact::get_hit_link_name ( )

Returns: name of the target character link that was hit; may be NULL if there is no hit target character.

int diguyImpact::get_hit_link_index ( )

Returns: index of the target character link that was hit.

const char* diguyImpact::get_hit_shape_name ( )

Returns: name of the target character shape that was hit; may be NULL if there is no hit target character.

int diguyImpact::get_hit_shape_index ( )

Returns: index of the target character shape that was hit.

int diguyImpact::get_impact_number ( )

Returns: the number of impacts the target character has taken.

void diguyImpact::set_impact_number ( int  val)

Sets the impact number.

void diguyImpact::set_impact_been_processed ( )

Sets that the impact has been processed.

int diguyImpact::get_impact_been_processed ( )

Returns: 1 if the impact has been processed, 0 if not.

float diguyImpact::get_x ( )

Returns: the approximate world x coordinate of the impact.

float diguyImpact::get_y ( )

Returns: the approximate world y coordinate of the impact.

float diguyImpact::get_z ( )

Returns: the approximate world z coordinate of the impact.

void diguyImpact::get_location ( float *  x,
float *  y,
float *  z 
)

Alternative method for getting the location of the impact.

float diguyImpact::get_impact_radius ( )

Returns: the radius of the impact.

float diguyImpact::get_impact_speed ( )

Returns: the speed of the impact.

int diguyImpact::get_location_in_link_coordinates ( float *  link_x,
float *  link_y,
float *  link_z 
)

This function returns the location of the impact in link-relative coordinates.

The function may fail and return -1 if a link was not hit by the impact.

Parameters
link_x,link_y,link_zlink-relative coordinates are returned in these variables

Returns:

0 on success, -1 on failure

void diguyImpact::reset ( )

This function resets all of the impact data to default values.

const char* diguyImpact::get_munition_type ( )

This function returns the name of the munition that was fired.

This is useful for creating impact callbacks that respond differently to different weapons.

Returns:

the munition type of the impact; may be NULL

diguySceneObject* diguyImpact::get_hit_scene_object ( )

Returns the hit diguySceneObject.

This pointer may be NULL if there is no impact scene object (e.g., impact is against a character).

If the octtree was used to generate the impact, this pointer will be NULL.

Returns:

pointer of type diguySceneObject

float diguyImpact::get_normal_x ( )

Returns: approximate normal x coordinate of the impact; may not be valid.

float diguyImpact::get_normal_y ( )

Returns: approximate normal y coordinate of the impact; may not be valid.

float diguyImpact::get_normal_z ( )

Returns: approximate normal z coordinate of the impact; may not be valid.

void diguyImpact::get_impact_normal ( float *  x,
float *  y,
float *  z 
)

Alternative method for getting the normal of the impact.

void diguyImpact::get_impact_velocity ( float *  x,
float *  y,
float *  z 
)

Velocity of projectile at impact.

May be 0 if no velocity information is available.

int diguyImpact::get_is_from_net_detonation ( )

Returns: 1 if impact was generated as a result of a network detonation (e.g.

a DIS detonation PDU), else 0

int diguyImpact::get_DIS_munition_septet_value ( int  septet_index)

This function returns the specified part of the DIS septet of the detonation's munition septet.

Parameters
septet_indexwhich part of the septet to return; must be between 0 (for 'kind') and 6 (for 'extra')

Returns -1 if septet isn't specified, or on error.

int diguyImpact::get_DIS_site ( )

Returns: the site id part of the detonation PDU event id; -1 if not set.

int diguyImpact::get_DIS_host ( )

Returns: the host id part of the detonation PDU event id; -1 if not set.

int diguyImpact::get_DIS_event_number ( )

Returns: the event number part of the detonation PDU event id; -1 if not set.

int diguyImpact::get_DIS_munition_number ( )

Returns: the event number part of the detonation PDU munition event id; -1 if not set.

int diguyImpact::get_DIS_detonation_result ( )

Returns: the detonation result of the detonation PDU; -1 if not set.

int diguyImpact::get_DIS_burst_warhead_type ( )

Returns: the warhead type enumeration of the detonation PDU's burst descriptor; -1 if not set.

int diguyImpact::get_DIS_burst_fuze ( )

Returns: the fuze enumeration of the detonation PDU's burst descriptor; -1 if not set.

int diguyImpact::get_DIS_burst_quantity ( )

Returns: the burst quantity of the detonation PDU's burst descriptor; -1 if not set.

int diguyImpact::get_DIS_burst_rate ( )

Returns: the burst rate of the detonation PDU's burst descriptor; -1 if not set.

void diguyImpact::set_valid_impact ( )

This function sets the impact to be valid.

It must be called if the impact hits a character.

void diguyImpact::set_target ( diguyCharacter target)

This function allows for explicitly setting the target character of this impact object.

Parameters
x,y,zoverride target of impact

Callable From:

  • C++
void diguyImpact::set_location ( float  x,
float  y,
float  z 
)

This function allows for explicitly setting the position of this impact object.

Parameters
x,y,zoverride position of impact

Callable From:

  • C++
void diguyImpact::set_normal ( float  nx,
float  ny,
float  nz 
)

This function allows for explicitly setting the normal of this impact object.

Parameters
nx,ny,nzoverride normal of impact

Callable From:

  • C++
void diguyImpact::set_hit_scene_object ( diguySceneObject scene_object)

Returns the hit scene object.

This function allows for explicitly setting the scene_object that the impact object hit.

If the octtree was used to generate the impact, this pointer will be NULL.

Parameters
scene_objectpointer to scene object hit

Callable From:

  • C++
void diguyImpact::set_hit_link_index ( int  index)

This function allows for explicitly setting the link index of this impact object.

Callable From:

  • C++
void diguyImpact::set_hit_shape_index ( int  index)

This function allows for explicitly setting the shape index of this impact object.

Callable From:

  • C++
void diguyImpact::set_munition_type ( const char *  munition_type)
private

Friends And Related Function Documentation

friend class bdiScenarioEditorDIGS
friend
friend class bdiPublishedCharacter
friend
friend class bdiScenario
friend
friend class bdiScenarioCharacter
friend
friend class bdiScenarioCrowdWorkManager
friend
friend class diguyCharacter
friend
friend class bdiQGLWidgetDIGS
friend

Member Data Documentation

diguyScenario* diguyImpact::m_scenario
private
diguyImpactType diguyImpact::m_impact_type
private
int diguyImpact::m_num_hits
private
diguyCharacter* diguyImpact::m_attacker
private
diguyCharacter* diguyImpact::m_target
private
diguySceneObject* diguyImpact::m_hit_scene_object
private
int diguyImpact::m_link_index
private
int diguyImpact::m_shape_index
private
int diguyImpact::m_impact_number
private
int diguyImpact::m_impact_processed
private
float diguyImpact::m_location[3]
private
float diguyImpact::m_normal[3]
private
float diguyImpact::m_impact_speed
private
float diguyImpact::m_impact_radius
private
char diguyImpact::m_munition_type[128]
private
int diguyImpact::m_is_from_net_detonation
int diguyImpact::m_DIS_munition_septet[7]
int diguyImpact::m_DIS_site
int diguyImpact::m_DIS_host
int diguyImpact::m_DIS_event_number
int diguyImpact::m_DIS_munition_number
int diguyImpact::m_DIS_detonation_result
int diguyImpact::m_DIS_burst_warhead_type
int diguyImpact::m_DIS_burst_fuze
int diguyImpact::m_DIS_burst_quantity
int diguyImpact::m_DIS_burst_rate
float diguyImpact::m_impact_velocity[3]

The documentation for this class was generated from the following file: