DI-Guy SDK Documentation  13.7
diguyCharacterGroup Class Reference

A group of DI-Guy characters, useful for organizing your scenarios. More...

#include <diguyCharacterGroup.h>

Public Member Functions

General Functions

Unless otherwise specified, all functions callable from:

  • C++
  • Script
const char * get_name ()
 Returns: name of the group; this value will never be NULL. More...
 
int set_name (const char *name)
 This function sets the name of this object. More...
 
int add_member (diguyCharacter *character)
 Adds the passed character to the group if not already in it. More...
 
int add_all_characters_as_members ()
 Adds all characters of the scenario as members of the group. More...
 
int remove_member (diguyCharacter *character)
 Removes the passed character from the group if it is a member. More...
 
int remove_all_members ()
 Removes all members of the group. More...
 
int is_member (diguyCharacter *character)
 The function can be used to check if a specific character is in this group. More...
 
int get_num_members ()
 Returns: number of member characters in group. More...
 
diguyCharacterget_member_at_index (int index)
 Returns: group member at specified index; NULL if no character at specified index. More...
 
int get_index_of_member (diguyCharacter *character)
 Returns: index of member, or -1 if not found. More...
 
int get_subgroup_number (diguyFormation *formation, int index)
 See diguyFormation for a description of subgroups. More...
 
int get_index_in_subgroup (diguyFormation *formation, int index)
 See diguyFormation for a description of subgroups. More...
 
int set_all_members_enabled (int enabled)
 Sets whether all characters in group are enabled. More...
 
int update_all_members (float t)
 Updates all characters in the group. More...
 
int draw_all_members ()
 This function draws all members of the group. More...
 
int draw_pass1_all_members ()
 This function draws pass 1 of all members of the group. More...
 
int draw_pass2_all_members ()
 This function draws pass 2 all members of the group. More...
 
int set_all_members_current_tin (float tin)
 This function sets the current tin time of all characters in the group. More...
 
int set_all_members_current_tout (float tout)
 This function sets the current tout time of all characters in the group. More...
 
Label Functions

The functions in this section control the text, visibility, and colors of group labels.

Currently group labels are only enabled in DI-Guy Scenario.

diguyViewLabelget_label ()
 This function returns a pointer to the label object of the group. More...
 
void set_label_offset_above_centroid (float offset)
 This function sets how high the label of the group will float above the group's centroid. More...
 
float get_label_offset_above_centroid ()
 Returns: how high the label of the group will float above the group centroid. More...
 
Variable Functions
int get_num_variables ()
 Returns: number of variables the group has. More...
 
diguyVariableget_variable_at_index (int index)
 Returns: pointer of type diguyVariable; NULL if no variable at the specified index. More...
 
diguyVariablefind_variable (const char *name)
 This function returns a pointer to the specified variable. More...
 
diguyVariablefind_or_create_variable (const char *name)
 This function finds the variable with the given name or creates it if it doesn't exist. More...
 
int destroy_variable (diguyVariable *variable)
 This function destroys the passed variable. More...
 
Experimental Functions
int translate_all_paths (float tx, float ty, float tz)
 
int rotate_all_paths_about_point (float rz, float rx, float ry, float rotation_pt_x, float rotation_pt_y, float rotation_pt_z)
 
int rotate_all_paths_about_current_waypoint (float rz, float rx, float ry)
 
diguyCharacterget_nearest_character_to_point (float x, float y, float z)
 Get the character closest to the specified point. More...
 
diguyCharacterget_farthest_character_to_point (float x, float y, float z)
 Get the character furthest from the specified point. More...
 
int get_group_centroid (float *x, float *y, float *z)
 Get centroid of group (average of character positions). More...
 
int get_group_min_circle (float *x, float *y, float *z, float *radius)
 Get minimum enclosing circle of group. More...
 
int send_message_to_all_members (const char *sender, const char *message_type, const char *message, const char *message_params=NULL)
 Send a message to all characters in group. More...
 
int apply_formation_to_group_with_dir (diguyCharacter *leader, diguyFormation *formation, float dir_x, float dir_y, float desired_radius=-1.0f, int require_sort=1)
 Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader. More...
 
int apply_formation_to_group_with_goal (diguyCharacter *leader, diguyFormation *formation, float goal_x, float goal_y, float desired_radius=-1.0f, int require_sort=1)
 Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader. More...
 
int apply_formation_to_group (diguyCharacter *leader, diguyFormation *formation, float desired_radius=-1.0f, int require_sort=1)
 Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader. More...
 
diguyFormationget_current_formation ()
 Returns the last-set formation. More...
 
int sort_group_based_on_pos (float x, float y, float z, diguyFormation *formation=NULL, diguyCharacter *leader=NULL)
 Sorts group relative to the point given. More...
 
diguyCharacterget_sorted_member_at_index (int index)
 Returns: member of formation-sorted group; NULL if no character at index. More...
 
int get_num_active_members ()
 Returns: number of active members. More...
 

Private Functions

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

No external access to them is expected or necessary.

bdiScenarioCharacterGroupm_scripted_object
 A pointer to internal data. More...
 
class bdiScenarioCharacterGroup
 
bdiScenarioCharacterGroupget_scripted_object ()
 
 diguyCharacterGroup (bdiScenarioCharacterGroup *scripted_object)
 A private constructor. More...
 
virtual ~diguyCharacterGroup ()
 A private destructor. More...
 

Detailed Description

A group of DI-Guy characters, useful for organizing your scenarios.

Constructor & Destructor Documentation

diguyCharacterGroup::diguyCharacterGroup ( bdiScenarioCharacterGroup scripted_object)
private

A private constructor.

virtual diguyCharacterGroup::~diguyCharacterGroup ( )
privatevirtual

A private destructor.

Member Function Documentation

const char* diguyCharacterGroup::get_name ( )

Returns: name of the group; this value will never be NULL.

int diguyCharacterGroup::set_name ( const char *  name)

This function sets the name of this object.

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::add_member ( diguyCharacter character)

Adds the passed character to the group if not already in it.

Returns:

0 if the character is now a part of the group, -1 if not

int diguyCharacterGroup::add_all_characters_as_members ( )

Adds all characters of the scenario as members of the group.

Returns:

Always return 0.

int diguyCharacterGroup::remove_member ( diguyCharacter character)

Removes the passed character from the group if it is a member.

Returns:

0 if the character was part of the group and removed; -1 if not

int diguyCharacterGroup::remove_all_members ( )

Removes all members of the group.

Returns:

Always return 0.

int diguyCharacterGroup::is_member ( diguyCharacter character)

The function can be used to check if a specific character is in this group.

Also see diguyCharacter::is_group_member().

Returns:

1 if the passed character is a member of the group; 0 if not

int diguyCharacterGroup::get_num_members ( )

Returns: number of member characters in group.

diguyCharacter* diguyCharacterGroup::get_member_at_index ( int  index)

Returns: group member at specified index; NULL if no character at specified index.

int diguyCharacterGroup::get_index_of_member ( diguyCharacter character)

Returns: index of member, or -1 if not found.

int diguyCharacterGroup::get_subgroup_number ( diguyFormation formation,
int  index 
)

See diguyFormation for a description of subgroups.

Returns:

subgroup number within formation of character at index, or -1

int diguyCharacterGroup::get_index_in_subgroup ( diguyFormation formation,
int  index 
)

See diguyFormation for a description of subgroups.

Returns:

index within subgroup, or 0

int diguyCharacterGroup::set_all_members_enabled ( int  enabled)

Sets whether all characters in group are enabled.

Equivalent to calling diguyCharacter::set_enabled() for group members.

Returns:

Always return 0.

int diguyCharacterGroup::update_all_members ( float  t)

Updates all characters in the group.

Equivalent to calling diguyCharacter::update() for all group members.

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::draw_all_members ( )

This function draws all members of the group.

See diguyCharacter::draw().

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterGroup::draw_pass1_all_members ( )

This function draws pass 1 of all members of the group.

See diguyCharacter::draw_pass1().

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterGroup::draw_pass2_all_members ( )

This function draws pass 2 all members of the group.

See diguyCharacter::draw_pass2().

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterGroup::set_all_members_current_tin ( float  tin)

This function sets the current tin time of all characters in the group.

See diguyCharacter::set_current_tin().

Parameters
tinnew value of current tin in seconds

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::set_all_members_current_tout ( float  tout)

This function sets the current tout time of all characters in the group.

See diguyCharacter::set_current_tout().

Parameters
toutnew value of current tout in seconds

Returns:

0 on success, -1 on failure

diguyViewLabel* diguyCharacterGroup::get_label ( )

This function returns a pointer to the label object of the group.

Currently group labels are only enabled in DI-Guy Scenario.

Returns:

pointer to the group's label

void diguyCharacterGroup::set_label_offset_above_centroid ( float  offset)

This function sets how high the label of the group will float above the group's centroid.

Parameters
offsetoffset, in meters, of label above group
float diguyCharacterGroup::get_label_offset_above_centroid ( )

Returns: how high the label of the group will float above the group centroid.

int diguyCharacterGroup::get_num_variables ( )

Returns: number of variables the group has.

diguyVariable* diguyCharacterGroup::get_variable_at_index ( int  index)

Returns: pointer of type diguyVariable; NULL if no variable at the specified index.

Parameters
indexindex of the variable; indices start at 0
diguyVariable* diguyCharacterGroup::find_variable ( const char *  name)

This function returns a pointer to the specified variable.

Parameters
namename of variable to be found

Returns:

pointer of type diguyVariable; NULL if not found

diguyVariable* diguyCharacterGroup::find_or_create_variable ( const char *  name)

This function finds the variable with the given name or creates it if it doesn't exist.

Parameters
namename of the variable to find or create

Returns:

pointer of type diguyVariable; should never be NULL

int diguyCharacterGroup::destroy_variable ( diguyVariable variable)

This function destroys the passed variable.

Parameters
variablepointer to a diguyVariable

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::translate_all_paths ( float  tx,
float  ty,
float  tz 
)
int diguyCharacterGroup::rotate_all_paths_about_point ( float  rz,
float  rx,
float  ry,
float  rotation_pt_x,
float  rotation_pt_y,
float  rotation_pt_z 
)
int diguyCharacterGroup::rotate_all_paths_about_current_waypoint ( float  rz,
float  rx,
float  ry 
)
diguyCharacter* diguyCharacterGroup::get_nearest_character_to_point ( float  x,
float  y,
float  z 
)

Get the character closest to the specified point.

Parameters
x,y,zposition in meters from the origin

Returns:

pointer to diguyCharacter, or NULL in none found

diguyCharacter* diguyCharacterGroup::get_farthest_character_to_point ( float  x,
float  y,
float  z 
)

Get the character furthest from the specified point.

Parameters
x,y,zposition in meters from the origin

Returns:

pointer to diguyCharacter, or NULL if none found

int diguyCharacterGroup::get_group_centroid ( float *  x,
float *  y,
float *  z 
)

Get centroid of group (average of character positions).

Parameters
x,y,zposition in meters from the origin

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::get_group_min_circle ( float *  x,
float *  y,
float *  z,
float *  radius 
)

Get minimum enclosing circle of group.

Note that this is slower than getting the centroid.

Parameters
x,y,zcenter of circle of group in meters from the origin
radiusradius of circle

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::send_message_to_all_members ( const char *  sender,
const char *  message_type,
const char *  message,
const char *  message_params = NULL 
)

Send a message to all characters in group.

See diguyCharacter::agent_accept_message().

Parameters
senderwho is sending the message
message_typewhat type of message is being sent
messagethe message string
message_paramsoptional parameter string

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::apply_formation_to_group_with_dir ( diguyCharacter leader,
diguyFormation formation,
float  dir_x,
float  dir_y,
float  desired_radius = -1.0f,
int  require_sort = 1 
)

Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader.

Parameters
leaderleader; can be NULL
formationname of formation
dir_xx component of the formation's heading
dir_yy component of the formation's heading
desired_radiusif not given (-1.0), get radius from formation
require_sortif 1, group must be resorted; if 0, it may still be

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::apply_formation_to_group_with_goal ( diguyCharacter leader,
diguyFormation formation,
float  goal_x,
float  goal_y,
float  desired_radius = -1.0f,
int  require_sort = 1 
)

Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader.

Parameters
leaderleader; can be NULL
formationname of formation
goal_xx component of the formation's goal point
goal_yy component of the formation's goal point
desired_radiusif not given (-1.0), get radius from formation
require_sortif 1, group must be resorted; if 0, it may still be

Returns:

0 on success, -1 on failure

int diguyCharacterGroup::apply_formation_to_group ( diguyCharacter leader,
diguyFormation formation,
float  desired_radius = -1.0f,
int  require_sort = 1 
)

Puts the group into the specified formation, applying agent_pursue_character_with_offset() to each character except the leader.

Parameters
leaderleader; can be NULL
formationname of formation
desired_radiusif not given (-1.0), get radius from formation
require_sortif 1, group must be resorted; if 0, it may still be

Returns:

0 on success, -1 on failure

diguyFormation* diguyCharacterGroup::get_current_formation ( )

Returns the last-set formation.

Returns:

The formation or NULL

int diguyCharacterGroup::sort_group_based_on_pos ( float  x,
float  y,
float  z,
diguyFormation formation = NULL,
diguyCharacter leader = NULL 
)

Sorts group relative to the point given.

The point should be on the left or in the front, depending on what order the formation is in. This updates an internal list of sorted group members.

Parameters
xx component of point
yy component of point
zz component of point
formationthe formation; pass NULL for no formation
leaderthe leader; pass NULL for no formation leader

Returns:

0 on success, -1 on failure

diguyCharacter* diguyCharacterGroup::get_sorted_member_at_index ( int  index)

Returns: member of formation-sorted group; NULL if no character at index.

int diguyCharacterGroup::get_num_active_members ( )

Returns: number of active members.

bdiScenarioCharacterGroup* diguyCharacterGroup::get_scripted_object ( )
inline

Friends And Related Function Documentation

friend class bdiScenarioCharacterGroup
friend

Member Data Documentation

bdiScenarioCharacterGroup* diguyCharacterGroup::m_scripted_object
private

A pointer to internal data.


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