DI-Guy SDK Documentation  13.6
diguyCharacterPoseOverride Class Reference

A class that allows end users to override a character's animation on a joint level. More...

#include <diguyCharacterPoseOverride.h>

Public Member Functions

float * allocate_pose_array ()
 Allocates an array of floats to hold the joint angles for each degree of freedom, or weights to specify how pose angles will affect a character. More...
 
int free_pose_array (float *array)
 Frees an array allocated with allocate_pose_array(). More...
 
int get_num_vars ()
 This function returns the number of the variables representing joint angles. More...
 
char ** allocate_var_names ()
 This function allocates an array of pointer to char**. More...
 
int get_var_names (char **var_names)
 This function fills out the passed array of strings with the list of the names of the variables representing joint angles. More...
 
int free_var_names (char **var_names)
 This function frees the array of strings allocated by allocate_var_names(). More...
 
int get_var_index (const char *varname)
 Get the index of the given variable in the array of pose angles. More...
 
int get_pose_in_radians (float *pose_array)
 This function fills out the passed array of floats with the most recent values passed in a call to set_pose_in_radians(). More...
 
int get_pose_in_quaternions (float *pose_array)
 same as get_pose_in_radians without the eular to quat conversion More...
 
int set_pose_in_radians (float *pose_array, float *weights_array=NULL, float default_weight=1.0f)
 This function specifies the joint angle data that will modify or override the joint angles the character normally computes. More...
 
int set_pose_in_quaternions (float *pose_array, float *weights_array=NULL, float default_weight=1.0f)
 same as set_pose_in_radians without the eular to quat conversion More...
 
float get_default_weight ()
 Get the default weight for pose angles. More...
 
int set_default_weight (float default_weight)
 Set the default weight for pose angles. More...
 
int set_weight_array_modifier (float weight_array_modifier)
 Sets an additional multiplier on the entire weight array. More...
 
float get_weight_array_modifier ()
 Returns the additional multiplier on the entire weight array. More...
 

Private Functions

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

No external access to them is expected or necessary.

bdiPoseOverridem_scripted_object
 
bdiScenarioCharacterm_character
 
class bdiPoseOverride
 
class diguyCharacter
 
class bdiScenarioCharacter
 
bdiPoseOverrideget_scripted_object ()
 
 diguyCharacterPoseOverride (bdiPoseOverride *scripted_object, bdiScenarioCharacter *character)
 
virtual ~diguyCharacterPoseOverride ()
 

Detailed Description

A class that allows end users to override a character's animation on a joint level.

Constructor & Destructor Documentation

diguyCharacterPoseOverride::diguyCharacterPoseOverride ( bdiPoseOverride scripted_object,
bdiScenarioCharacter character 
)
private
virtual diguyCharacterPoseOverride::~diguyCharacterPoseOverride ( )
privatevirtual

Member Function Documentation

float* diguyCharacterPoseOverride::allocate_pose_array ( )

Allocates an array of floats to hold the joint angles for each degree of freedom, or weights to specify how pose angles will affect a character.

The size of the array will be equal to the value returned by get_num_vars().

The allocated array should be freed by calling free_pose_array().

The allocated array will contain uninitialized values.

If the array is to hold weights, each entry in the array should be set to a valid value between 0.0 and 1.0.

If the array is to hold pose angles, each pose variable whose corresponding weight is going to be non-0 should be set to a valid value.

Returns:

pointer to array of floats, NULL if the array cannot be allocated

Callable From:

  • C++

C++ Example:

See example for set_pose_in_radians().

int diguyCharacterPoseOverride::free_pose_array ( float *  array)

Frees an array allocated with allocate_pose_array().

Parameters
arrayarray of pose angles to be freed

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterPoseOverride::get_num_vars ( )

This function returns the number of the variables representing joint angles.

Returns:

an integer representing the number of joint angles

Callable From:

  • C++
  • Script
char** diguyCharacterPoseOverride::allocate_var_names ( )

This function allocates an array of pointer to char**.

(i.e., C-style strings).

This array can then be passed to get_var_names().

It should be freed using the function free_var_names(). The size of the array will be equal to the value returned by get_num_vars().

Returns:

an array of pointers to char*'s (i.e. pointers to strings)

Callable From:

  • C++

C++ Example:

See example for get_var_names().

int diguyCharacterPoseOverride::get_var_names ( char **  var_names)

This function fills out the passed array of strings with the list of the names of the variables representing joint angles.

Parameters
var_namesan array of strings as allocated by allocate_var_names()

Returns:

0 on success, -1 on failure

Callable From:

  • C++

C++ Example:

//
// Create a pose override for character.
//
pose_override = character1->create_pose_override();
//
// Allocate a list of joint angle names and fill it.
// Print the joint angle names, then destroy the array.
//
char** varnames = pose_override->allocate_var_names();
pose_override->get_var_names(varnames);
for (i = 0; i < character1->get_pose_array_size(); i++)
bdi_log_printf(BDI_LOG_INFO, "%s\n", varnames[i]);
pose_override->free_var_names(varnames);
int diguyCharacterPoseOverride::free_var_names ( char **  var_names)

This function frees the array of strings allocated by allocate_var_names().

Parameters
var_namesan array of strings as allocated by allocate_var_names()

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterPoseOverride::get_var_index ( const char *  varname)

Get the index of the given variable in the array of pose angles.

Parameters
varnamethe name of the pose angle variable whose index is desired

Returns:

index of the pose variable, if it exists, -1 if not

Callable From:

  • C++

C++ Example:

See example for set_pose_in_radians().

int diguyCharacterPoseOverride::get_pose_in_radians ( float *  pose_array)

This function fills out the passed array of floats with the most recent values passed in a call to set_pose_in_radians().

Note that this may not be the actual pose of the character; this is only the pose angles for this specific pose override. Other pose overrides, gazing, etc., will also affect the pose of the character. Use the function diguyCharacter::get_pose_in_radians() to read the "real" pose of the character, as computed by the DI-Guy motion engine.

Parameters
pose_arrayarray of floats allocated by allocate_pose_array()

Returns:

0 on success, -1 on failure

Callable From:

  • C++
int diguyCharacterPoseOverride::get_pose_in_quaternions ( float *  pose_array)

same as get_pose_in_radians without the eular to quat conversion

int diguyCharacterPoseOverride::set_pose_in_radians ( float *  pose_array,
float *  weights_array = NULL,
float  default_weight = 1.0f 
)

This function specifies the joint angle data that will modify or override the joint angles the character normally computes.

The replacement data is in pose_array.

If weights array is non-NULL, then each element specifies the proportion of the value on pose array to mix in with the value normally computed by the character. A weight of 0.0 means to ignore the value in pose_array. A weight of 1.0 means fully override the value computed by the character.

If weights_array is NULL, then default_weight will be used for all of the joint angles.

Note that all weights for an Euler triple (e.g. - q.cervical_rz/rx/ry) must be equal to ensure proper interpolation.

Also note that the first six variables that contain the character's overall position and orientation cannot be changed using a pose override. These values must be changed using the functions diguyCharacter::set_position() and diguyCharacter::set_orientation().

Parameters
pose_arraythe array containing the pose angles for this override object
weight_arraythe multiplier used to determine how the new pose_array values are to be combined with the existing pose
default_weightthe value to be used to set the weights if weights_array is NULL

Returns:

0 on success, -1 on failure

Callable From:

  • C++

C++ Example:

//
// Create a pose override for character.
//
pose_override = character1->create_pose_override();
//
// Allocate an array for pose angles.
//
pose_array = pose_override->allocate_pose_array();
for (i=0; i<pose_override->get_num_vars(); i++)
pose_array[i] = 0.0f;
//
// Allocate a weights_array, and initialize it to all 0s.
//
weights_array = pose_override->allocate_pose_array();
for (i=0; i<pose_override->get_num_vars(); i++)
weights_array[i] = 0.0f;
//
// Find the indices of the character's back angles. Set the
// weights for these angles in weights_array to 1.0. This
// means that when we call set_pose_in_radians(), the values
// in pose_array will completely override the original
// data for the back.
//
back_rz_index = pose_override->get_var_index("q.back_rz");
back_rx_index = pose_override->get_var_index("q.back_rx");
back_ry_index = pose_override->get_var_index("q.back_ry");
pose_array[back_rz_index] = 0.57f; // angle measured in radians
pose_array[back_rx_index] = 0.0f; // angle measured in radians
pose_array[back_ry_index] = 0.0f; // angle measured in radians
weights_array[back_rz_index] = 1.0f;
weights_array[back_rx_index] = 1.0f;
weights_array[back_ry_index] = 1.0f;
pose_override->set_pose_in_radians(pose_array,
weights_array,
0.0f);
int diguyCharacterPoseOverride::set_pose_in_quaternions ( float *  pose_array,
float *  weights_array = NULL,
float  default_weight = 1.0f 
)

same as set_pose_in_radians without the eular to quat conversion

float diguyCharacterPoseOverride::get_default_weight ( )

Get the default weight for pose angles.

Returns:

the default pose angle weight

Callable From:

  • C++
  • Script
int diguyCharacterPoseOverride::set_default_weight ( float  default_weight)

Set the default weight for pose angles.

The default weight will be used to set values in a pose's weights array if the array passed in, for instance, set_pose_in_radians(), is NULL.

Parameters
default_weightthe desired default weight

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
int diguyCharacterPoseOverride::set_weight_array_modifier ( float  weight_array_modifier)

Sets an additional multiplier on the entire weight array.

Defaults to 1.0f

Parameters
weight_array_modifierthe desired weight

Returns:

0 on success, -1 on failure

Callable From:

  • C++
  • Script
float diguyCharacterPoseOverride::get_weight_array_modifier ( )

Returns the additional multiplier on the entire weight array.

bdiPoseOverride* diguyCharacterPoseOverride::get_scripted_object ( )
inline

Friends And Related Function Documentation

friend class bdiPoseOverride
friend
friend class diguyCharacter
friend
friend class bdiScenarioCharacter
friend

Member Data Documentation

bdiPoseOverride* diguyCharacterPoseOverride::m_scripted_object
private
bdiScenarioCharacter* diguyCharacterPoseOverride::m_character
private

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