Unigine.MeshAnimation Class
MeshAnimation Class
Properties
int NumBones#
The total number of the mesh bones.
Members
MeshAnimation ( ) #
Constructor. Creates an empty mesh.MeshAnimation ( string path ) #
Constructor. Creates a mesh animation using the specified file.Arguments
- string path - Path to the mesh animation file.
MeshAnimation ( MeshAnimation src ) #
Constructor. Creates a mesh animation using the specified source mesh animation.Arguments
- MeshAnimation src - Source mesh animation instance.
void AssignFrom ( MeshAnimation src ) #
Copies the animation data from the source: bones, list of animated bones, and animation frames.Arguments
- MeshAnimation src - Source mesh animation instance.
void Clear ( ) #
Clears the mesh animation data: bones, list of animated bones, and animation frames.int FlipYZ ( ) #
Flips the Y and Z axes for the animation:- Y axis becomes equal to -Z
- Z axis becomes equal to Y
Return value
1 if the axes are flipped successfully; otherwise, 0.int Info ( string path ) #
Returns the information about the specified animation.Arguments
- string path - Path to the file containing animation.
Return value
int Load ( string path ) #
Loads the animation (bone names and bone parent indices) from the specified file.Arguments
- string path - Path to the file containing animation.
Return value
1 if the animation is loaded from the file successfully; otherwise, 0.int Save ( string path ) #
Saves the given animation in the ANIM file format. Creates the given file if it doesn’t exist yet (including subdirectories).Arguments
- string path - Path to a file including the file name and extension to which animation is to be saved (*.anim).
Return value
1 if the animation is saved successfully; otherwise, 0.int FindBone ( string name ) #
Searches for a bone with a given name and returns its number.Arguments
- string name - Name of the bone.
Return value
Bone number.int AddBone ( string name = 0, int parent = -1 ) #
Appends a new mesh bone.Arguments
- string name - Bone name. This argument is empty by default.
- int parent - Parent bone number. The default value is -1 (the new bone has no parent bone).
Return value
Number of mesh bones.void SetBoneName ( int bone, string name ) #
Sets the name for the given bone.Arguments
- int bone - Bone number.
- string name - Bone name.
string GetBoneName ( int bone ) #
Returns the name of the given bone.Arguments
- int bone - Bone number.
Return value
Bone name.void SetBoneParent ( int bone, int parent ) #
Sets the bone specified as the second argument as the parent bone for the bone specified as the first argument.Arguments
- int bone - Number of the bone, for which the parent will be returned.
- int parent - Parent bone number, if the parent exists; otherwise, -1.
int GetBoneParent ( int bone ) #
Returns the number of the parent bone for a given one.Arguments
- int bone - Number of the bone, for which the parent will be returned.
Return value
Parent bone number, if the parent exists; otherwise, -1.void SetBoneTransform ( int bone, mat4 transform ) #
Sets a transformation matrix for the given bone (without considering node transformations).Bones can be scaled only uniformly.
Arguments
- int bone - Bone number.
- mat4 transform - Transformation matrix.
mat4 GetBoneTransform ( int bone ) #
Returns a transformation matrix of the given bone relatively to the parent object (not considering transformations of the Mesh Skinned node itself).Arguments
- int bone - Bone number.
Return value
Transformation matrix.int SetBoneTransforms ( mat4[] transforms ) #
Sets transformation matrices for all bones. The transforms are in the object-space coordinates (not local, i.e. not bound to the parent bone).Arguments
- mat4[] transforms - Transformation matrices in the object-space coordinates.
Return value
1 if transforms are set successfully for bones. The return value of 0 means that the number of transforms did not match the number of bonesint GetBoneTransforms ( mat4[] OUT_transforms ) #
Returns transformation matrices for all bones The transforms are in the object-space coordinates (not local, i.e. not bound to the parent bone).Arguments
- mat4[]
OUT_transforms - Transformation matrices in the object-space coordinates.This output buffer is to be filled by the Engine as a result of executing the method.
int GetNumAnimationBones ( ) #
Returns the total number of mesh animation bones.Return value
Number of the mesh animation bones.short GetAnimationBoneID ( int num ) #
Returns the mesh bone ID for the specified animated bone.Arguments
- int num - Bone index in the list of animated bones.
Return value
Bone ID in the list of mesh bones.void SetAnimationBones ( short[] bone_indices ) #
Copies bones from the given array to the current array of animation bones.Arguments
- short[] bone_indices - Array of bones taking part in the animation to be set.
void GetAnimationBones ( short[] OUT_bone_indices ) #
Adds all bones of the given animation to the given array of bones.Arguments
- short[]
OUT_bone_indices - Array with indices of bones taking part in the animation.This output buffer is to be filled by the Engine as a result of executing the method.
int SetAnimationBoneTransforms ( mat4[] transforms, int frame ) #
Sets transforms for the specified frame. This method applies transformations to all bones in the mesh, then takes transforms for animated bones and writes them into the frame. All transfomrs are object-bound.Arguments
- mat4[] transforms - Animation bone transformation matrix, in the object space.
- int frame - Animation frame.
Return value
0, if the number of transforms doesn't match the number of bones in the mesh.int GetAnimationBoneTransforms ( mat4[] OUT_transforms, int frame ) #
Returns a transformation matrix for the specified frame. If bones are animated, transforms for them are taken from the frame, if bones are not animated, their transforms are taken from the mesh. All transforms are object-bound.Arguments
- mat4[]
OUT_transforms - Animation bone transformation matrix, in the object space.This output buffer is to be filled by the Engine as a result of executing the method.
- int frame - Animation frame.
Return value
Always returns 1, as it always performs correctly.void SetNumFrames ( int num ) #
Sets the number of frames for the animation.Arguments
- int num - Number of the animation frames.
int GetNumFrames ( ) #
Returns the number of frames for the animation.Return value
Number of the animation frames.void SetFrame ( int frame, mat4[] bones ) #
Sets the animation frame transformation matrices. If the number of transforms does not match the number of animated bones, the method won't be applied.Arguments
- int frame - Frame number in the array of the animation frames.
- mat4[] bones - Bones transformation matrices in local space — relevant to the parent bone.
void GetFrame ( int frame, mat4[] OUT_bones ) #
Returns the animation frame transformation matrices.Arguments
- int frame - Frame number in the array of the animation frames.
- mat4[]
OUT_bones - Bones transformation matrices in local space — relevant to the parent bone.This output buffer is to be filled by the Engine as a result of executing the method.
void SetFrame ( int frame, vec3[] xyz, quat[] rot, vec3[] scale ) #
Sets the animation frame coordinates, rotation quaternions and scaling vectors.Arguments
- int frame - Frame number in the array of the animation frames.
- vec3[] xyz - Array with coordinates of the animation frame.
- quat[] rot - Array with rotation quaternions of the animation frame.
- vec3[] scale - Array with scaling vectors of the animation frame.
void GetFrame ( int frame, vec3[] OUT_xyz, quat[] OUT_rot, vec3[] OUT_scale ) #
Returns the animation frame coordinates, rotation quaternions and scaling vectors.Arguments
- int frame - Frame number in the array of the animation frames.
- vec3[]
OUT_xyz - Array with coordinates of the animation frame.This output buffer is to be filled by the Engine as a result of executing the method.
- quat[]
OUT_rot - Array with rotation quaternions of the animation frame.This output buffer is to be filled by the Engine as a result of executing the method.
- vec3[]
OUT_scale - Array with scaling vectors of the animation frame.This output buffer is to be filled by the Engine as a result of executing the method.
Last update:
2024-09-03
Help improve this article
Was this article helpful?
(or select a word/phrase and press Ctrl+Enter)