DI-Guy SDK Documentation  13.5
diguyChainSimulation Class Reference

wrapper around a chain simulation More...

#include <diguyChainSimulation.h>

Public Member Functions

General Functions

Unless otherwise specified, all functions callable from:

  • C++
  • Script
diguyChainSettingsget_settings ()
 This function returns the chain settings this chain simulation is using. More...
 
int update_settings (const char *settings)
 This function sets the settings this chain simulation will use. More...
 
int do_stabilization_time_runoff (float time_runoff)
 This function runs the simulation forward the specified number of seconds, to let the chain settle into a stable configuration. More...
 
void set_is_frozen (int is_frozen)
 This function can 'freeze' or 'unfreeze' a chain. More...
 
int get_is_frozen ()
 Returns: 1 if chain is frozen, 0 if not. More...
 
int set_chain_mass_connection_character (int chain_mass_index, const char *character_name, const char *link_name=NULL, float link_offset_x=0.0f, float link_offset_y=0.0f, float link_offset_z=0.0f, float connection_smoothing_period=0.1f)
 This function connects a chain mass to a character, or disconnects a chain mass if the passed character_name is NULL. More...
 
int set_chain_mass_position (int chain_mass_index, float mass_x, float mass_y, float mass_z, int fix_mass_position)
 This function sets the position of one chain mass, and optionally fixes it there. More...
 
int set_chain_mass_positions_along_path_shape (diguyPathShape *path_shape, int stretch_to_fit=1)
 This function sets the positions of all chain masses to lie along the passed path shape. More...
 
int set_chain_mass_position_is_fixed (int chain_mass_index, int is_fixed)
 This function can fix or unfix a chain mass in place. More...
 
int get_chain_mass_position_is_fixed (int mass_index)
 Returns: 1 if chain mass is fixed, 0 if not. More...
 
float get_length ()
 Returns: length of the chain. More...
 

Private Functions

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

No external access to them is expected or necessary.

bdiScenarioChainm_scripted_object
 A pointer to internal data. More...
 
class bdiScenarioChain
 
bdiScenarioChainget_scripted_object ()
 
 diguyChainSimulation (bdiScenarioChain *scripted_object)
 A private constructor. More...
 
 ~diguyChainSimulation ()
 A private destructor. More...
 

Detailed Description

wrapper around a chain simulation

Constructor & Destructor Documentation

diguyChainSimulation::diguyChainSimulation ( bdiScenarioChain scripted_object)
private

A private constructor.

diguyChainSimulation::~diguyChainSimulation ( )
private

A private destructor.

Member Function Documentation

diguyChainSettings* diguyChainSimulation::get_settings ( )

This function returns the chain settings this chain simulation is using.

Returns:

object of type diguyChainSettings; will never be NULL

int diguyChainSimulation::update_settings ( const char *  settings)

This function sets the settings this chain simulation will use.

Parameters
settingsname of new settings to use

Returns:

0 on success, -1 on failure

int diguyChainSimulation::do_stabilization_time_runoff ( float  time_runoff)

This function runs the simulation forward the specified number of seconds, to let the chain settle into a stable configuration.

Note that the chain will appear to achieve the new configuration instantly.

Specifying a large amount of time can result in a frame rate hitch.

Parameters
time_runoffhow much time to run off, in seconds

Returns:

0 on success, -1 on failure

void diguyChainSimulation::set_is_frozen ( int  is_frozen)

This function can 'freeze' or 'unfreeze' a chain.

If a chain is frozen, all chain masses will remain in their current positions and will not move until the chain is unfrozen.

A frozen chain requires no simulation time.

Parameters
is_frozenpass 1 to freeze the chain; 0 to unfreeze
int diguyChainSimulation::get_is_frozen ( )

Returns: 1 if chain is frozen, 0 if not.

int diguyChainSimulation::set_chain_mass_connection_character ( int  chain_mass_index,
const char *  character_name,
const char *  link_name = NULL,
float  link_offset_x = 0.0f,
float  link_offset_y = 0.0f,
float  link_offset_z = 0.0f,
float  connection_smoothing_period = 0.1f 
)

This function connects a chain mass to a character, or disconnects a chain mass if the passed character_name is NULL.

As the character moves the chain mass will move with it, dragging adjacent masses along. This allows a firefighter to pick up one end of a hose and drag the hose to a new location, for example.

In each time-step of the scenario a new position for the specified chain mass will be computed based on the position of the character.

When the chain sim is created, and when the scenario is reset, one chain mass will be automatically connected to the chain's character. The index of the mass that will be connected is set by a call to diguyChainSettings::set_index_of_chain_mass_connected_to_character().

Chain masses can be connected to a specific link of the connection character by passing the link's name. If NULL is passed, the connection will be made to the character's "position" link. Note that a non-NULL link name must be used for the link offset arguments to have an effect.

The chain mass can gradually be shifted from its current position to the connection position using the connection_smoothing_period argument. Passing in 0.5, for example, will cause the link to shift to its new connection point within approximately 0.5 seconds, avoiding an abrupt and potentially ugly impulse to the simulation.

Parameters
chain_mass_indexindex of chain mass
character_namename of character to attach to; must not be NULL
link_namename of link to attach to; can be NULL; if so, will attach to character's base position
link_offset_xlink attachment offset in X
link_offset_ylink attachment offset in Y
link_offset_zlink attachment offset in Z
connection_smoothing_periodhow much time to take, in seconds, to gradually shift the chain mass to its new connection point

Returns:

0 on success, -1 on failure

int diguyChainSimulation::set_chain_mass_position ( int  chain_mass_index,
float  mass_x,
float  mass_y,
float  mass_z,
int  fix_mass_position 
)

This function sets the position of one chain mass, and optionally fixes it there.

The passed position is always relative to the chain character's parent, if there is one.

If the fix_mass_position argument is 1, the chain mass will remain fixed in the new position, as if set_chain_mass_position_is_fixed(1) were called.

Parameters
chain_mass_indexindex of chain mass; pass -1 to affect all chain masses
mass_xposition x
mass_yposition y
mass_zposition z
fix_mass_positionpass 1 to fix chain mass in place; 0 to leave it free to move

Returns:

0 on success, -1 on failure

int diguyChainSimulation::set_chain_mass_positions_along_path_shape ( diguyPathShape path_shape,
int  stretch_to_fit = 1 
)

This function sets the positions of all chain masses to lie along the passed path shape.

If the stretch_to_fit argument is 1, chain masses will be spaced along the entire length of the path shape. If the path shape is longer than the nominal length of the chain, the chain will be stretched out. If the path shape is shorter, the chain will be compressed.

Parameters
path_shapepath shape for new chain mass positions
stretch_to_fitpass 1 to stretch chain to take up entire length of path_shape; pass 0 to leave chain at its nominal length

Returns:

0 on success, -1 on failure

int diguyChainSimulation::set_chain_mass_position_is_fixed ( int  chain_mass_index,
int  is_fixed 
)

This function can fix or unfix a chain mass in place.

If it is fixed the chain mass will remain in its current position until it is unfixed.

Fixed chain masses do not require simulation time, so the more masses in a chain that are fixed, the lower the computational load of the chain simulation.

Parameters
chain_mass_indexindex of chain mass; pass -1 to affect all chain masses
is_fixedpass 1 to fix chain mass position; 0 to unfix it

Returns:

0 on success, -1 on failure

int diguyChainSimulation::get_chain_mass_position_is_fixed ( int  mass_index)

Returns: 1 if chain mass is fixed, 0 if not.

float diguyChainSimulation::get_length ( )

Returns: length of the chain.

bdiScenarioChain* diguyChainSimulation::get_scripted_object ( )
inline

Friends And Related Function Documentation

friend class bdiScenarioChain
friend

Member Data Documentation

bdiScenarioChain* diguyChainSimulation::m_scripted_object
private

A pointer to internal data.


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