BodyRagdoll Class
The scope of applications for UnigineScript is limited to implementing materials-related logic (material expressions, scriptable materials, brush materials). Do not use UnigineScript as a language for application logic, please consider C#/C++ instead, as these APIs are the preferred ones. Availability of new Engine features in UnigineScript (beyond its scope of applications) is not guaranteed, as the current level of support assumes only fixing critical issues.
Inherits from: | Body |
This class is used to simulate ragdoll bodies. This body automatically generates a ragdoll skeleton, i.e. collision shapes that are bound to the bones and joints that connect them.
See Also#
- A set of UnigineScript API samples located in the <UnigineSDK>/data/samples/physics/ folder:
- ragdoll_00
- ragdoll_01
- ragdoll_02
- ragdoll_03
- ragdoll_04
- ragdoll_05
- ragdoll_06
- ragdoll_07
- ragdoll_10
- ragdoll_11
- ragdoll_12
- ragdoll_13
BodyRagdoll Class
Members
static BodyRagdoll ( ) #
Constructor. Creates a ragdoll with default properties.static BodyRagdoll ( Object object ) #
Constructor. Creates a ragdoll with default properties for a given object.Arguments
- Object object - Object approximated with the new ragdoll.
void setBoneFrameBased ( int bone, int based ) #
Sets a value indicating if bone transformations should be based on skinned animation data or conditioned by physics.Arguments
- int bone - Bone number.
- int based - Positive value to set skinned animation-based transformations, 0 for ragdoll physical animation.
int isBoneFrameBased ( int bone ) #
Returns a value indicating if bone transformations are based on skinned animation data or conditioned by physics.Arguments
- int bone - Bone number.
Return value
Positive value if transformations are based on skinned animation, 0 if they are ragdoll physical animation.string getBoneName ( int bone ) #
Returns the name of a given bone.Arguments
- int bone - Bone number.
Return value
Bone name.int getBoneNumber ( int bone ) #
Checks whether the bone with the given number exists.Arguments
- int bone - The number of the bone.
Return value
Bone number.void setBones ( Node node ) #
Imports a set of bones from a given node.Arguments
- Node node - Node, from which the bones will be imported.
Node getBones ( ) #
Exports a set of bones into a given node.Return value
Node, into which the bones will be exported.int updateBones ( ) #
Updates transformations of all ragdoll bones.Return value
1 if transformations of all ragdoll bones were updated successfully; otherwise, 0.Mat4 getBoneTransform ( int bone ) #
Returns the transformation of animation bone for the current frame.Arguments
- int bone - Bone number.
Return value
Bone transformation matrix.void setFrameBased ( int based ) #
Sets a value indicating if ragdoll bones move according to the animation written in the file.Arguments
- int based - 1 to make the bones move according to the file animation, 0 to make the movements physics-driven.
int isFrameBased ( ) #
Returns a value indicating if ragdoll bones move according to the animation written in the file.Return value
1 if the bones move according to the file animation; otherwise, 0.void setMass ( float mass ) #
Sets a mass of the ragdoll.If g (Earth's gravity) equals to 9.8 m/s
2, and 1 unit equals to 1 m, the mass is measured in kilograms.
Arguments
- float mass - Mass of the ragdoll.
float getMass ( ) #
Returns the mass of the ragdoll.If g (Earth's gravity) equals to 9.8 m/s
2, and 1 unit equals to 1 m, the mass is measured in kilograms.
Return value
Mass of the ragdoll.int getNumBones ( ) #
Returns the number of bones in the ragdoll.Return value
Number of bones.void setRigidity ( float rigidity ) #
Sets rigidity of bones movement, i.e. how much interpolated linear and angular velocities of all bones affect velocities of each separate bone.Arguments
- float rigidity - Rigidity of bones movement. Provided value is saturated in range [0;1]:
- By the value of 0, bones are independent.
- By the value of 1, bones movement is uniform, as interpolated velocity greatly changes velocities of each bone.
float getRigidity ( ) #
Returns the rigidity of bones movement, i.e. how much interpolated linear and angular velocities of all bones affect velocities of each separate bone.Return value
Rigidity of bones movement:- By the value of 0, bones are independent.
- By the value of 1, bones movement is uniform, as interpolated velocity greatly changes velocities of each bone.
int createBones ( float error = 0.2, float threshold = 0.01, int capsule = 0 ) #
Automatically generates a simplified skeleton from the mesh and its bones. Each bone is approximated with a convex hull or a capsule based on given parameters.Arguments
- float error - Permissible error, which is used for creating convex hulls. This is an optional parameter.
- float threshold - Threshold, which is used to detect and discard too small convex hulls. A convex hull, which volume is smaller than an average volume multiplied by the threshold, is discarded. This is an optional parameter.
- int capsule - Approximation shape. By the value of 0, convex hull is used; the value of 1 sets capsule approximation.
Return value
Created bone number.int findBone ( string name ) #
Searches for a bone with a given name.Arguments
- string name - Name of the bone.
Return value
Number of the bone in the list of bones, if it is found; otherwise, -1.Last update:
2021-12-13
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)