This page has been translated automatically.
视频教程
界面
要领
高级
实用建议
基础
专业(SIM)
UnigineEditor
界面概述
资源工作流程
版本控制
设置和首选项
项目开发
调整节点参数
Setting Up Materials
设置属性
照明
Sandworm
使用编辑器工具执行特定任务
如何擴展編輯器功能
嵌入式节点类型
Nodes
Objects
Effects
Decals
光源
Geodetics
World Nodes
Sound Objects
Pathfinding Objects
Players
编程
基本原理
搭建开发环境
使用范例
C++
C#
UnigineScript
统一的Unigine着色器语言 UUSL (Unified UNIGINE Shader Language)
Plugins
File Formats
材质和着色器
Rebuilding the Engine Tools
GUI
双精度坐标
应用程序接口
Animations-Related Classes
Containers
Common Functionality
Controls-Related Classes
Engine-Related Classes
Filesystem Functionality
GUI-Related Classes
Math Functionality
Node-Related Classes
Networking Functionality
Pathfinding-Related Classes
Physics-Related Classes
Plugins-Related Classes
IG Plugin
CIGIConnector Plugin
Rendering-Related Classes
VR-Related Classes
创建内容
内容优化
材质
Material Nodes Library
Miscellaneous
Input
Math
Matrix
Textures
Art Samples
Tutorials
注意! 这个版本的文档是过时的,因为它描述了一个较老的SDK版本!请切换到最新SDK版本的文档。
注意! 这个版本的文档描述了一个不再受支持的旧SDK版本!请升级到最新的SDK版本。

Unigine::ObjectMeshSkinned Class

Header: #include <UnigineObjects.h>
Inherits from: Object

This class is used to create or modify skinned meshes.

Creating and Playing Animation#

To add the animation to the ObjectMeshSkinned and play it, do the following:

  1. Set the number of animation layers with the setNumLayers() method. There is only one layer by default.
  2. Enable the layer and set the animation weight for blending by calling the setLayer() function.
  3. Add the animation .anim file by using addAnimation() or setAnimation() functions.

    Notice

    When you import your model with animations from an FBX container, the following path to your *.anim files should be used: <path_to_your_fbx_file>/<file.fbx>/<your_anim_file.anim>

    For example: object->addAnimation("models/soldier/soldier.fbx/run.anim");

    The recommended approach is to use the Component System and provide the guid of the .anim file.

    Source code (C++)
    UGUID guid = FileSystem::getGUID(anim_asset.getRaw());
    int animation_1 = skinned_mesh->addAnimation(mesh,guid.getFileSystemString(), "run");
  4. Play the added animation by calling the setFrame() function for each animation layer.

Blending is performed between all layers. The contribution of each layer depends on its weight. Also, you can optionally define single bone transformations by hand, if needed, using either setBoneTransform() or setBoneTransformWithChildren().

Usage Example

The following example shows how to blend 2 different animations assigned to a mesh. In this example we use the mesh and animations from UNIGINE samples located in <UnigineSDK>/data/samples/animation/meshes and <UnigineSDK>/data/samples/animation/animations folders, respectively. Animations are added by using the addAnimation() function.

Below you'll find an example of using the Component System to access animation assets.

  1. Create a component for controlling loading of animations and generate a property for it.
  2. Assign its property to the target controller node.
  3. Assign desired animation assets to the parameters of the property by using the Editor.

    Assigning animation assets to property parameters via the Editor
  4. Implement logic of creating a skinned mesh with the specified animations. The complete source code:

    SkinnedMeshController.h

    Source code (C++)
    #pragma once
    #include <UnigineComponentSystem.h>
    #include <UnigineObjects.h>
    #include <UnigineStreams.h>
    #include <UnigineLog.h>
    #include <UnigineFileSystem.h>
    #include <UnigineEditor.h>
    #include <UnigineGame.h>
    
    using namespace Unigine;
    class SkinnedMeshController : public ComponentBase
    {
    public:
    	COMPONENT(SkinnedMeshController, ComponentBase);
    
    	COMPONENT_INIT(init);
    	COMPONENT_UPDATE(update);
    	COMPONENT_SHUTDOWN(shutdown);
    
    	PROP_NAME("skinned_controller_property");
    
    	// property parameters for mesh and animation assets
    	PROP_PARAM(File, mesh_asset);
    	PROP_PARAM(File, anim_asset_1);
    	PROP_PARAM(File, anim_asset_2);
    
    protected:
    	void init();
    	void update();
    	void shutdown();
    private:
    // the pointer to the skinned mesh object
    	ObjectMeshSkinnedPtr skinned_mesh;
    };

    SkinnedMeshController.cpp

    Source code (C++)
    #include "SkinnedMeshController.h"
    
    // register the component
    REGISTER_COMPONENT(SkinnedMeshController);
    
    int SkinnedMeshController::init() {
    
    	// get the guid of the mesh asset
    	const char *mesh_path = FileSystem::getGUID(mesh_asset.getRaw()).getFileSystemString();
    
    	// create the new ObjectMeshSkinned mesh based on an existing mesh
    	skinned_mesh = ObjectMeshSkinned::create(mesh_path);
    
    	// set the number of animation layers
    	skinned_mesh->setNumLayers(2);
    
    	// get the guids of the animation assets
    	const char *path_1 = FileSystem::getGUID(anim_asset_1.getRaw()).getFileSystemString();
    	const char *path_2 = FileSystem::getGUID(anim_asset_2.getRaw()).getFileSystemString();
    	
    	// load animations from the files
    	int animation_1 = skinned_mesh->addAnimation(path_1);
    	int animation_2 = skinned_mesh->addAnimation(path_2);
    
    	// enable each layer and set an animation weight
    	skinned_mesh->setLayer(0, 1, 0.7);
    	skinned_mesh->setLayer(1, 1, 0.3);
    
    	// set animations to layers
    	skinned_mesh->setAnimation(0, animation_1);
    	skinned_mesh->setAnimation(1, animation_2);
    
    	return 1;
    }
    
    int SkinnedMeshController::update() {
    	// play each animation
    	skinned_mesh->setFrame(0, Game::getTime() * 25.0f);
    	skinned_mesh->setFrame(1, Game::getTime() * 25.0f);
    	return 1;
    }
    
    int SkinnedMeshController::shutdown() {
    	return 1;
    }

Updating Bone Transformations#

Some of the methods require to update the animation data before the renderer makes its update and actually draws the skinned mesh. Such update allows to get the correct result of blending between the frames and layers.

The execution sequence of updating bone transformations is the following:

  1. Call the method, which sets the update flag. This flag shows that the instance should be updated.
  2. Update the bone transformations by calling proper functions. These functions check the flag and if the flag is set, they calculate the transformations and set the flag to the default value.
  3. During the rendering, the engine performs animations and transformations which were calculated on the previous step or recalculates them, if the update flag has been set. If calculations have been performed, the flag is set to the default value.

If you try to update bone transformations before you set the flag to update, functions will not calculate new transformations and the engine doesn't perform them.

When you change the transformation of the bone, you should notify all skinned meshes which use these bone about these transformations to update the mesh. When you change transformations of a bone, skinned mesh instances get the flag to update. When you use the setFrame() function, you set necessary transformations for the specified skinned mesh.

Instancing#

Surfaces of identical skinned meshes which have the same materials assigned to them and the same number of bones attached to their vertices are automatically instanced and drawn in one draw call.

The data buffers for instanced objects that store bones transformations are limited in size; therefore, if skinned meshes have many bones, only a few meshes can populate the instance data buffer to be drawn in one draw call.

Notice
The higher the number of bones and the more bones are attached to one surface, the less robust instancing will be.

Reusing Animations#

Animations from one character can be used for another.

Animation Frame Masks#

Masks are the simplest way of reusing animations, a couple of words about how they work. To each layer of an ObjectMeshSkinned you can assign some animation and based on its frames it will change bone transformations on this layer. You can use masks to choose which components of the animation frame (position, rotation, scale, their combinations, or all of them) are to be used for each particular layer. In case any component is missing in the mask, the corresponding value will be taken from the T-pose.

As an example let's take eyes animation for these two skeletons:

They have absolutely the same bone hierarchy as well as bone names, only the proportions differ. If we use animation for eyes from the left skeleton for the right one, we'll get the following result:

The initial animation has completely changed the proportions of the second skeleton. We can fix it by setting FRAME_USES_ROTATION mask to eye bones, and FRAME_USES_NONE for the rest of the bones via the setBoneFrameUses() / getBoneFrameUses() methods. Thus, all values except for eyes rotation will be taken from the T-pose :

If the skeletons have different bone names you should first apply retargeting and then use masks. In this case it is not that important to have similar skeletons.

Retargeting#

To reuse animation entirely both source and target skeletons must have similar bone hierarchy and their T-poses differ insignificantly.

This is acceptable and will work fine:

as we have similar bone hierarchies and all bones have similar bases in T-poses, only the proportions differ, but this proportion is almost uniform for all bones.

But we cannot use the following:

Although the hierarchy looks similar, the T-poses differ and bones have different bases.

These limitations can be ignored if you only need to retarget only some subset of the bones (e.g.: retarget bones having different names and then use only masks).

Inverse Kinematics (IK)#

ObjectMeshSkinned supports inverse kinematics (IK) for bone chains (IK chains). Inverse kinematics provide a way to handle joint rotation from the location of an end-effector rather than via direct joint rotation. You provide a location of the effector and the IK Solver attempts to find a rotation so that the final joint coincides with that location as best it can. This can be used to position a character's feet properly on uneven ground, and ensure believable interactions with the world. The tolerance value sets a threshold where the target is considered to have reached its destination position, and when the IK Solver stops iterating.

An IK chain can have an arbitrary length (contain an arbitrary number of bones), it has an auxiliary vector enabling you to control bending direction. You can also set rotation for the last joint of the chain.

Each IK chain has a weight value that can be used to control the impact of the target on the last joint of the chain. This enables you to make smooth transitions from the source animation to required target position of the limb.

To visualize IK chains you can use the following methods: addVisualizeIKChain(), removeVisualizeIKChain(), and clearVisualizeIKChain().

See Also#

  • Mesh class
  • Article on Mesh File Formats
  • Animation sample in C# Component Samples suite
  • Samples located in the <UnigineSDK>/data/samples/animation folder

ObjectMeshSkinned Class

枚举

BONE_SPACE#

Defines which transformation of the bone is to be overridden by the bind node's transformation.
Name说明/描 述
BONE_SPACE_WORLD = 0World coordinates.
BONE_SPACE_OBJECT = 1Coordinates relative to the skinned mesh object.
BONE_SPACE_LOCAL = 2Coordinates relative to the parent bone.

NODE_SPACE#

Defines the type of transformation of the bind node to be used to override the transformation of the specified bone.
Name说明/描 述
NODE_SPACE_WORLD = 0World transformation of the node.
NODE_SPACE_LOCAL = 1Local transformation of the node.

BIND_MODE#

Type of blending of bind node's and bone's transformations.
Name说明/描 述
BIND_MODE_OVERRIDE = 0Replace bone's transformation with the transformation of the bind node.
BIND_MODE_ADDITIVE = 1Bind node's transformation is added to the current transformation of the bone.

FRAME_USES#

Frame components to be used for animation.
Name说明/描 述
FRAME_USES_NONE = 0No frame components are to be used.
FRAME_USES_POSITION = 1 << 0Only position is to be used.
FRAME_USES_ROTATION = 1 << 1Only rotation is to be used.
FRAME_USES_SCALE = 1 << 2Only scale is to be used.
FRAME_USES_ALL = POSITION | ROTATION | SCALEAll frame components are to be used.
FRAME_USES_POSITION_AND_ROTATION = POSITION | ROTATIONOnly position and rotation are to be used.
FRAME_USES_POSITION_AND_SCALE = POSITION | SCALEOnly position and scale are to be used.
FRAME_USES_ROTATION_AND_SCALE = ROTATION | SCALEOnly rotation and scale are to be used.

Members


static ObjectMeshSkinnedPtr create ( const Ptr<Mesh> & mesh ) #

ObjectMeshSkinned constructor.

Arguments

  • const Ptr<Mesh> & mesh - Pointer to Mesh.

static ObjectMeshSkinnedPtr create ( const char * path, bool unique = false ) #

ObjectMeshSkinned constructor.

Arguments

  • const char * path - Path to the skinned mesh file.
  • bool unique - When you create several objects out of a single .mesh file, the instance of the mesh geometry is created. If you then change the source geometry, its instances will be changed as well. To avoid this, set the unique flag to true (1), so a copy of the mesh geometry will be created and changes won't be applied.

int setAnimation ( int layer, int animation ) #

Sets the animation identifier for the given animation layer.

Arguments

  • int layer - Layer number.
  • int animation - Animation identifier.

int setAnimation ( int layer, const char * path ) #

Sets the path to animation for the given animation layer.

Arguments

  • int layer - Layer number.
  • const char * path - Path to animation file.

int getAnimation ( int layer ) const#

Returns the animation identifier from the given animation layer.

Arguments

  • int layer - Layer number.

Return value

Animation identifier.

int getAnimationID ( int num ) const#

Returns the identifier of the animation at the specified position.

Arguments

  • int num - Animation number.

Return value

Animation identifier.

const char * getAnimationPath ( int animation ) const#

Returns the path to a file containing the specified animation.

Arguments

  • int animation - Animation identifier.

Return value

Path to a file containing the specified animation.

void setAnimName ( const char * name ) #

Sets a new path to the animation. Does not update animation immediately using the new path, unlike the setAnimNameForce() method.

Arguments

  • const char * name - Path to the animation.

void setAnimNameForce ( const char * name ) #

Sets the new path to the animation and forces setting this animation for the first animation layer.

Arguments

  • const char * name - Path to the animation file.

const char * getAnimName ( ) const#

Returns the path to the current animation.

Return value

Path to animation.

Math::mat4 getBoneBindTransform ( int bone ) const#

Returns the bind pose bone transformation matrix. Bone transformations are relative.

Arguments

  • int bone - Bone number.

Return value

Bind pose bone transformation matrix.

int getBoneChild ( int bone, int child ) const#

Returns the number of a child of a given bone.

Arguments

  • int bone - Bone number.
  • int child - Child number.

Return value

Number of the child in the collection of all bones.

void setBoneTransformWithChildren ( int bone, const Math::mat4 & transform ) #

Sets transformation for the bone and all of its children (without considering node transformations).
Notice
Bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • const Math::mat4 & transform - Transformation matrix.

const char * getBoneName ( int bone ) const#

Returns the name of the given bone.

Arguments

  • int bone - Bone number.

Return value

Bone name.

int getBoneParent ( int bone ) const#

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, const Math::mat4 & transform ) #

Sets a transformation matrix for a given bone (without considering node transformations).
Notice
Bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • const Math::mat4 & transform - Transformation matrix.

Math::mat4 getBoneTransform ( int bone ) const#

Returns a transformation matrix of a 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.

void setBoneTransforms ( const int * bones, const Math::mat4 * transforms, int num_bones ) #

Sets a transformation matrix for given bones.

Arguments

  • const int * bones - Bone numbers.
  • const Math::mat4 * transforms - Transformation matrices.
  • int num_bones - Number of bones.

void setCIndex ( int num, int index, int surface ) #

Sets the new coordinate index for the given vertex of the given surface.

Arguments

  • int num - Vertex number in the range from 0 to the total number of coordinate indices for the given surface.
    Notice
    To get the total number of coordinate indices for the given surface, use the getNumCIndices() method.
  • int index - Coordinate index to be set in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
  • int surface - Mesh surface number.

int getCIndex ( int num, int surface ) const#

Returns the coordinate index for the given vertex of the given surface.

Arguments

  • int num - Vertex number in the range from 0 to the total number of coordinate indices for the given surface.
    Notice
    To get the total number of coordinate indices for the given surface, use the getNumCIndices() method.
  • int surface - Mesh surface number.

Return value

Coordinate index.

void setColor ( int num, const Math::vec4 & color, int surface ) #

Sets the color for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex color entries of the given surface.
    Notice
    To get the total number of vertex color entries for the surface, call the getNumColors() method.
  • const Math::vec4 & color - Vertex color to be set.
  • int surface - Mesh surface number.

Math::vec4 getColor ( int num, int surface ) const#

Returns the color of the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex color entries of the given surface.
    Notice
    To get the total number of vertex color entries for the surface, call the getNumColors() method.
  • int surface - Mesh surface number.

Return value

Vertex color.

void setControlled ( bool controlled ) #

Sets a value indicating if the animation should be controlled by a parent ObjectMeshSkinned (useful for attaching clothes to a character body).

Arguments

  • bool controlled - Controlled flag: true if the animation is controlled by a parent ObjectMeshSkinned; otherwise - false.

bool isControlled ( ) const#

Returns a value indicating if the animation is controlled by a parent ObjectMeshSkinned.

Return value

true if the animation is controlled by a parent ObjectMeshSkinned; otherwise, false.

float setFrame ( int layer, float frame, int from = -1, int to = -1 ) #

Sets a frame for the given animation layer.

Arguments

  • int layer - Animation layer number.
  • float frame - Frame number in the "from-to" interval. If the float argument is passed, animation is interpolated between nearby frames. 0 means the from frame. For larger values, a residue of a modulo (from-to) is calculated. If a negative value is provided, interpolation will be done from the current frame to the from frame.
  • int from - Start frame. -1 means the first frame of the animation.
  • int to - End frame. -1 means the last frame of the animation.

Return value

The number of the frame.

float getFrame ( int layer ) const#

Returns the frame number passed as the time argument on the last setFrame() call.

Arguments

  • int layer - Animation layer number.

Return value

Frame number.

int getFrameFrom ( int layer ) const#

Returns the start frame passed as the from argument on the last setFrame() call.

Arguments

  • int layer - Animation layer number.

Return value

Start frame.

int getFrameTo ( int layer ) const#

Returns the end frame passed as the to argument on the last setFrame() call.

Arguments

  • int layer - Animation layer number.

Return value

End frame.

Math::mat4 getBoneBindITransform ( int bone ) const#

Returns the inverse bone transformation matrix of the bind pose in the world-space.
Notice
To get the bind pose transformation matrix in the world-space, use the inverse(getBoneITransform()).

Arguments

  • int bone - Bone number.

Return value

Inverse bind pose transformation matrix.

Math::mat4 getBoneITransform ( int bone ) const#

Returns an inverse transformation matrix for a given bone relatively to the parent object.

Arguments

  • int bone - Bone number.

Return value

Inverse transformation matrix.

void setLayer ( int layer, bool enabled, float weight ) #

Enables or disables the given animation layer and sets the value of the weight parameter.

Arguments

  • int layer - Animation layer number.
  • bool enabled - Enable flag. true to enable the layer, false to disable it.
  • float weight - Animation layer weight.

void setBoneLayerTransform ( int layer, int bone, const Math::mat4 & transform ) #

Sets a transformation matrix for a given bone. The difference from the setBoneTransform() function is that this method takes into account only the transformation in the specified animation layer (no blending is performed).
Notice
The bone can be scaled only uniformly.

Arguments

  • int layer - Animation layer number.
  • int bone - Bone number.
  • const Math::mat4 & transform - Bone transformation matrix.

Math::mat4 getBoneLayerTransform ( int layer, int bone ) const#

Returns a transformation matrix of a given bone relatively to the parent object.
Notice
The difference from getBoneTransform() is that this method takes into account only the transformation in the animation layer (no blending is done).

Arguments

  • int layer - Animation layer number.
  • int bone - Bone number.

Return value

Bone transformation matrix.

bool isBoneLayerTransform ( int layer, int bone ) const#

Returns a value indicating if the bone transformation is applied only to the animation layer (no blending is performed).

Arguments

  • int layer - Animation layer number.
  • int bone - Bone number.

Return value

true if the bone transformation is applied only to the animation layer; otherwise, false.

void setBoneLayerTransformEnabled ( int layer, int bone, bool enabled ) #

Enables or disables a layer transformation for a given bone.

Arguments

  • int layer - Animation layer number.
  • int bone - Bone number.
  • bool enabled - Enabled flag: true to enable layer transformation, false to disable it.

void setLayerEnabled ( int layer, bool enabled ) #

Enables or disables a given animation layer.

Arguments

  • int layer - Animation layer number.
  • bool enabled - true to enable the animation layer, false to disable it.

bool isLayerEnabled ( int layer ) const#

Returns a value indicating if a given animation layer is enabled.

Arguments

  • int layer - Animation layer number.

Return value

true if the layer is disabled; otherwise, false.

void setLayerWeight ( int layer, float weight ) #

Sets a weight for the animation layer.

Arguments

  • int layer - Animation layer number.
  • float weight - Animation layer weight.

float getLayerWeight ( int layer ) const#

Returns the weight of the animation layer.

Arguments

  • int layer - Animation layer number.

Return value

Weight of the animation layer.

void setLoop ( bool loop ) #

Sets a value indicating if the animation should be looped.

Arguments

  • bool loop - true is to play the animation in a loop, false is to play it only once.

int isLoop ( ) const#

Returns a value indicating if the animation is looped.

Return value

true if the animation is looped; otherwise - false.

int setMesh ( const Ptr<Mesh> & mesh ) #

Copies the source mesh into the current mesh.
Source code (C++)
// create ObjectMeshSkinned instances 
ObjectMeshSkinnedPtr skinnedMesh = ObjectMeshSkinned::create("soldier.mesh");
ObjectMeshSkinnedPtr skinnedMesh_2 = ObjectMeshSkinned::create("doll.mesh");

// create a Mesh instance
MeshPtr firstMesh = Mesh::create();

// get the mesh of the ObjectMeshSkinned and copy it to the Mesh class instance
skinnedMesh->getMesh(firstMesh);

// put the firstMesh mesh to the skinnedMesh_2 instance
skinnedMesh_2->setMesh(firstMesh);

Arguments

  • const Ptr<Mesh> & mesh - The source mesh to be copied.

Return value

1 if the mesh is copied successfully; otherwise, 0.

int getMesh ( const Ptr<Mesh> & mesh ) const#

Copies the current mesh into the source mesh.
Source code (C++)
// a skinned mesh from which geometry will be obtained
ObjectMeshSkinnedPtr skinnedMesh = ObjectMeshSkinned::create("skinned.mesh");
// create a new mesh
MeshPtr mesh = Mesh::create();
// copy geometry to the created mesh
if (skinnedMesh->getMesh(mesh)) {
	// do something with the obtained mesh
}
else {
	Log::error("Failed to copy a mesh\n");
}

Arguments

  • const Ptr<Mesh> & mesh - Source mesh.

Return value

1 if the mesh is copied successfully; otherwise, 0.

void setMeshName ( const char * name ) #

Sets the path to the mesh. Does not update mesh immediately using the new path, unlike the setMeshNameForce() method

Arguments

  • const char * name - Path to the mesh.

void setMeshNameForce ( const char * path ) #

Sets the new path to the mesh and forces mesh creation using the new path. The new mesh is created from the specified path immediately with the unique flag set to 0.

Arguments

  • const char * path - Path to the mesh file.

const char * getMeshName ( ) const#

Returns the path to the mesh.

Return value

Path to the mesh.

int getMeshSurface ( const Ptr<Mesh> & mesh, int surface, int target = -1 ) const#

Copies the specified mesh surface to the destination mesh.

Arguments

  • const Ptr<Mesh> & mesh - Destination Mesh to copy the surface to.
  • int surface - Number of the mesh surface to be copied.
  • int target - Number of the surface morph target to be copied. The default value is -1 (all morph targets).

Return value

Number of the new added mesh surface.

Math::vec3 getNormal ( int num, int surface, int target = 0 ) const#

Returns the normal for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface target.
    Notice
    Vertex normals are calculated using vertex tangents. To get the total number of vertex tangent entries for the surface target, call the getNumTangents() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex normal.

int getNumAnimationBones ( int animation ) const#

Returns the number of animation bones.

Arguments

  • int animation - Animation number.

Return value

Number of animation bones.

int getNumAnimationFrames ( int animation ) const#

Returns the number of animation frames.

Arguments

  • int animation - Animation number.

Return value

Number of animation frames.

int getNumAnimations ( ) const#

Returns the total number of all loaded animations.

Return value

Number of loaded animations.

int getNumBoneChildren ( int bone ) const#

Returns the number of children for the specified bone.

Arguments

  • int bone - Bone number.

Return value

Number of child bones.

int getNumBones ( ) const#

Returns the number of all bones taking part in animation.

Return value

Number of bones of the skinned mesh.

int getNumCIndices ( int surface ) const#

Returns the number of coordinate indices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of coordinate indices.

int getNumColors ( int surface ) const#

Returns the total number of vertex color entries for the given surface.
Notice
Colors are specified for triangle vertices.

Arguments

  • int surface - Surface number.

Return value

Number of vertex color entries.

int getNumFrames ( int layer ) const#

Returns the number of animation frames for a given layer.

Arguments

  • int layer - Animation layer number.

Return value

Number of animation frames.

void setNumLayers ( int layers ) #

Sets the number of animation layers for blending. For example, when two layers are blended, bone transformations in between the layers are interpolated, and vertex positions can be calculated using the interpolated results. For more details, see the article on Skinned Mesh.

Arguments

  • int layers - Number of animation layers (must be greater than 0).

int getNumLayers ( ) const#

Returns the number of animation layers set for blending. For more details, see the article on Skinned Mesh.

Return value

Number of animation layers.

int getNumSurfaceTargets ( int surface ) const#

Returns the number of surface morph targets for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of surface morph targets.

int getNumTangents ( int surface ) const#

Returns the number of vertex tangent entries of the given mesh surface.
Notice
Tangents are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of surface tangent vectors.

void setNumTargets ( int num, int surface ) #

Sets the number of animation morph targets for the given mesh surface.

Arguments

  • int num - Number of animation morph targets.
  • int surface - Mesh surface number.

int getNumTargets ( int surface ) const#

Returns the total number of morph targets of the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of animation morph targets.

void setNumTexCoords0 ( int num, int surface ) #

Sets the number of the first UV map texture coordinates for the given mesh surface.
Notice
First UV map texture coordinates are specified for triangle vertices.

Arguments

  • int num - Number of the first UV map texture coordinates to be set.
  • int surface - Mesh surface number.

int getNumTexCoords0 ( int surface ) const#

Returns the number of the first UV map texture coordinates for the given mesh surface.
Notice
First UV map texture coordinates are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the first UV map texture coordinates.

void setNumTexCoords1 ( int num, int surface ) #

Sets the number of the second UV map texture coordinates for the given mesh surface.
Notice
Second UV map texture coordinates are specified for triangle vertices.

Arguments

  • int num - Number of the second UV map texture coordinates to be set.
  • int surface - Mesh surface number.

int getNumTexCoords1 ( int surface ) const#

Returns the number of the second UV map texture coordinates for the given mesh surface.
Notice
Second UV map texture coordinates are specified for triangle vertices.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the second UV map texture coordinates.

int getNumTIndices ( int surface ) const#

Returns the number of triangle indices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of triangle indices.

int getNumVertex ( int surface ) const#

Returns the number of coordinate vertices for the given mesh surface.

Arguments

  • int surface - Mesh surface number.

Return value

Number of the surface vertices.

bool isFlushed ( ) const#

Returns a value indicating if vertex data of the mesh was flushed (create/upload operation) to video memory.

Return value

true if vertex data of the mesh was flushed (create/upload operation) to video memory; otherwise, false.

bool isPlaying ( ) const#

Returns playback status.

Return value

true if animation is playing; otherwise, false.

void setQuaternion ( bool quaternion ) #

Enables or disables the dual-quaternion skinning mode. The dual-quaternion model is an accurate, computationally efficient, robust, and flexible method of representing rigid transforms and it is used in skeletal animation. See a Wikipedia article on dual quaternions and a beginners guide to dual-quaternions for more information.

Arguments

  • bool quaternion - true to enable dual-quaternion skinning mode, false to disable it.

bool isQuaternion ( ) const#

Returns the value indicating if the dual-quaternion skinning mode is used. The dual-quaternion model is an accurate, computationally efficient, robust, and flexible method of representing rigid transforms and it is used in skeletal animation. See a Wikipedia article on dual quaternions and a beginners guide to dual-quaternions for more information.

Return value

true if dual-quaternion skinning mode is used; otherwise, false.

Math::vec3 getSkinnedNormal ( int num, int index, int surface ) const#

Returns the skinned normal for the given triangle vertex.
Notice
A skinned normal is a recalculated normal for bones and morph targets used in skinning.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface target.
    Notice
    Vertex normals are calculated using vertex tangents. To get the total number of vertex tangent entries for the surface target, call the getNumTangents() method.
  • int index - Coordinate index of the vertex.
    Notice
    if -1 is passed, the coordinate index will be obtained for the first vertex having its triangle index equal to the specified triangle vertex number.
  • int surface - Mesh surface number.

Return value

Skinned normal.

Math::quat getSkinnedTangent ( int num, int index, int surface ) const#

Returns the skinned tangent vector for the given triangle vertex.
Notice
A skinned tangent vector is a recalculated tangent vector for bones and morph targets used in skinning.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface target.
    Notice
    To get the total number of vertex tangent entries for the surface target, call the getNumTangents() method.
  • int index - Coordinate index of the vertex.
    Notice
    if -1 is passed, the coordinate index will be obtained for the first vertex having its triangle index equal to the specified triangle vertex number.
  • int surface - Mesh surface number.

Return value

Skinned tangent.

Math::vec3 getSkinnedVertex ( int num, int surface ) const#

Returns skinned coordinates of the given coordinate vertex.
Notice
A skinned vertex is a recalculated vertex for bones and morph targets used in skinning.

Arguments

  • int num - Coordinate vertex number in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumVertex() method.
  • int surface - Mesh surface number.

Return value

Vertex coordinates.

void setSpeed ( float speed ) #

Updates a multiplier value for the animation playback time.

Arguments

  • float speed - Playback speed multiplier value.

float getSpeed ( ) const#

Returns a multiplier for animation playback time.

Return value

Playback speed multiplier value.

bool isStopped ( ) const#

Returns stop status.

Return value

true if animation is stopped; otherwise, false.

bool isNeedUpdate ( ) const#

Returns a value indicating if the ObjectMeshSkinned needs to be updated (e.g. after adding new animations).

Return value

true if the skinned mesh needs to be updated; otherwise, false.

const char * getSurfaceTargetName ( int surface, int target ) const#

Returns the name of the morph target for the given mesh surface.

Arguments

  • int surface - Mesh surface number.
  • int target - Morph target number.

Return value

Morph target name.

void setSurfaceTransform ( const Math::mat4 & transform, int surface, int target = -1 ) #

Transforms the given mesh surface target.

Arguments

  • const Math::mat4 & transform - Transformation matrix.
  • int surface - Mesh surface number.
  • int target - Morph target number. The default value is -1 (the transformation will be applied to all morph targets).

void setTangent ( int num, const Math::quat & tangent, int surface, int target = 0 ) #

Sets the new tangent for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface.
    Notice
    To get the total number of vertex tangent entries for the surface, call the getNumTangents() method.
  • const Math::quat & tangent - Tangent to be set.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Math::quat getTangent ( int num, int surface, int target = 0 ) const#

Returns the tangent for the given triangle vertex of the given surface target.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of vertex tangent entries of the given surface.
    Notice
    To get the total number of vertex tangent entries for the surface, call the getNumTangents() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex tangent.

void setTarget ( int target, bool enabled, int index, float weight, int surface ) #

Enables or disables a given morph target and sets all its parameters.

Arguments

  • int target - Morph target number.
  • bool enabled - Enable flag: true to enable the morph target; false to disable it.
  • int index - Target index.
  • float weight - Target weight.
  • int surface - Surface number.

void setTargetEnabled ( int target, bool enabled, int surface ) #

Enables or disables a given morph target.

Arguments

  • int target - Morph target number.
  • bool enabled - true to enable the morph target, false to disable it.
  • int surface - Surface number.

int isTargetEnabled ( int target, int surface ) const#

Returns a value indicating if the given morph target of the given surface is enabled.

Arguments

  • int target - Morph target number.
  • int surface - Mesh surface number.

Return value

1 if the given morph target of the given surface is enabled; otherwise, 0.

void setTargetIndex ( int target, int index, int surface ) #

Sets an index for the given morph target.

Arguments

  • int target - Morph target number.
  • int index - Morph target index.
  • int surface - Mesh surface number.

int getTargetIndex ( int target, int surface ) const#

Returns the index of the morph target. Returns the index of the given morph target.

Arguments

  • int target - Morph target number.
  • int surface - Mesh surface number.

Return value

Index of the given morph target.

void setTargetWeight ( int target, float weight, int surface ) #

Sets a weight for the given animation target.

Arguments

  • int target - Morph target number.
  • float weight - Morph target weight.
  • int surface - Mesh surface number.

float getTargetWeight ( int target, int surface ) const#

Returns the weight of the given morph target.

Arguments

  • int target - Morph target number.
  • int surface - Mesh surface number.

Return value

Morph target weight.

void setTexCoord0 ( int num, const Math::vec2 & texcoord, int surface ) #

Sets first UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of first UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of first UV map texture coordinate entries for the surface, call the getNumTexCoords0() method.
  • const Math::vec2 & texcoord - First UV map texture coordinates to be set.
  • int surface - Mesh surface number.

Math::vec2 getTexCoord0 ( int num, int surface ) const#

Returns first UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of first UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of first UV map texture coordinate entries for the surface, call the getNumTexCoords0() method.
  • int surface - Mesh surface number.

Return value

First UV map texture coordinates.

void setTexCoord1 ( int num, const Math::vec2 & texcoord, int surface ) #

Sets second UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of second UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of second UV map texture coordinate entries for the surface, call the getNumTexCoords1() method.
  • const Math::vec2 & texcoord - Second UV map texture coordinates to be set.
  • int surface - Mesh surface number.

Math::vec2 getTexCoord1 ( int num, int surface ) const#

Returns second UV map texture coordinates for the given triangle vertex of the given surface.

Arguments

  • int num - Triangle vertex number in the range from 0 to the total number of second UV map texture coordinate entries of the given surface.
    Notice
    To get the total number of second UV map texture coordinate entries for the surface, call the getNumTexCoords1() method.
  • int surface - Mesh surface number.

Return value

Second UV map texture coordinates.

void setTime ( float time ) #

Sets the animation time, in animation frames. The time count starts from the zero frame. If the time is set to be between frames, animation is blended. If the time is set outside the animation frame range, the animation is looped.
Notice
The setTime() function corresponds to The Play and Stop options in the editor. In all other cases use setFrame() to set the animation.

Arguments

  • float time - Animation time.

float getTime ( ) const#

Returns the current animation time, in animation frames. The time count starts from the zero frame.

Return value

Animation time.

void setTIndex ( int num, int index, int surface ) #

Sets the new triangle index for the given vertex of the given surface.

Arguments

  • int num - Vertex number in the range from 0 to the total number of triangle indices for the given surface.
    Notice
    To get the total number of triangle indices, use the getNumTIndices() method.
  • int index - Triangle index to be set in the range from 0 to the total number of triangle vertices for the given surface.
    Notice
    To get the total number of triangle vertices for the given surface, use the getNumTVertex() method.
  • int surface - Mesh surface number.

int getTIndex ( int num, int surface ) const#

Returns the triangle index for the given surface by using the index number.

Arguments

  • int num - Vertex number in the range from 0 to the total number of triangle indices for the given surface.
    Notice
    To get the total number of triangle indices for the given surface, use the getNumTIndices() method.
  • int surface - Mesh surface number.

Return value

Triangle index.

void setVertex ( int num, const Math::vec3 & vertex, int surface, int target = 0 ) #

Sets the coordinates of the given coordinate vertex of the given surface target.

Arguments

  • int num - Coordinate vertex number in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
  • const Math::vec3 & vertex - Vertex coordinates to be set.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Math::vec3 getVertex ( int num, int surface, int target = 0 ) const#

Returns coordinates of the given coordinate vertex of the given surface target.

Arguments

  • int num - Coordinate vertex number in the range from 0 to the total number of coordinate vertices for the given surface.
    Notice
    To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
  • int surface - Mesh surface number.
  • int target - Surface target number. The default value is 0.

Return value

Vertex coordinates.

void setBoneWorldTransformWithChildren ( int bone, const Math::Mat4 & transform ) #

Sets the transformation for the given bone and all of its children in the world coordinate space (considering node transformations).
Notice
Bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • const Math::Mat4 & transform - Transformation matrix in the world space.

void setBoneWorldTransform ( int bone, const Math::Mat4 & transform ) #

Sets the transformation for the given bone in the world coordinate space.
Notice
Bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • const Math::Mat4 & transform - Transformation matrix in the world space.

Math::Mat4 getBoneWorldTransform ( int bone ) const#

Returns the current transformation matrix applied to the bone in the world coordinate space (considering node transformations).

Arguments

  • int bone - Bone number.

Return value

Transformation matrix in the world space.

int addAnimation ( const Ptr<Mesh> & mesh, const char * path = 0 ) #

Adds animation from the specified mesh.
Source code (C++)
UGUID guid;
guid.generate();
int animation_1 = skinned_mesh->addAnimation(mesh, guid.getFileSystemString());

Arguments

  • const Ptr<Mesh> & mesh - Mesh containing the animation to be added.
  • const char * path - The parameter is a virtual unique path defining the animation. After loading the animation clip, its internal representation will be identified by the path when using findAnimation, setAnimation, etc. The default 0 value implies that the names of the animation clips will be used.
    Notice
    As the given mesh isn't associated with a file and, therefore, doesn't have path data, the path must be represented by an arbitrary unique string. You can generate a new string and use it as the virtual path for the animation.

Return value

Index of the added animation or -1 if an error has occurred.

int addAnimation ( const char * path ) #

Loads additional animation from the specified external file.

Arguments

  • const char * path - Path to the animation file. The path can be represented by either a path to the file or its GUID, which is the recommended approach. After loading the animation, its internal representation is identified by the path when using findAnimation, setAnimation, etc.
    Notice
    When you import your model with animations from an FBX container, the following path to your *.anim files should be used: <path_to_your_fbx_file>/<file.fbx>/<your_anim_file.anim>

    For example: object->addAnimation("models/soldier/soldier.fbx/run.anim");

Return value

Index of the added animation or -1 if an error has occurred.

int addRetargetedAnimation ( const char * path, const Ptr<BonesRetargeting> & bones_retargeting ) #

Loads additional animation from the specified external file applying the specified bones retargeting settings.

Arguments

  • const char * path - Path to the animation file. The path can be represented by either a path to the file or its GUID, which is the recommended approach. After loading the animation, its internal representation is identified by the path when using findAnimation, setAnimation, etc.
    Notice
    When you import your model with animations from an FBX container, the following path to your *.anim files should be used: <path_to_your_fbx_file>/<file.fbx>/<your_anim_file.anim>

    For example: object->addAnimation("models/soldier/soldier.fbx/run.anim");

  • const Ptr<BonesRetargeting> & bones_retargeting - Instance of the BonesRetargeting class describing retargeting of bones from the skeleton of the specified source mesh to the skeleton of the calling object.

Return value

Index of the added animation or -1 if an error has occurred.

int addRetargetedAnimation ( const Ptr<Mesh> & mesh, const Ptr<BonesRetargeting> & bones_retargeting, const char * path = 0 ) #

Adds animation from the specified mesh applying the specified bones retargeting settings.

Arguments

  • const Ptr<Mesh> & mesh - Source mesh containing the animation to be added.
  • const Ptr<BonesRetargeting> & bones_retargeting - Instance of the BonesRetargeting class describing retargeting of bones from the skeleton of the specified source mesh to the skeleton of the calling object.
  • const char * path - The parameter is a virtual unique path defining the animation. After loading the animation clip, its internal representation will be identified by the path when using findAnimation, setAnimation, etc. The default 0 value implies that the names of the animation clips will be used.
    Notice
    As the given mesh isn't associated with a file and, therefore, doesn't have path data, the path must be represented by an arbitrary unique string. You can generate a new string and use it as the virtual path for the animation.

Return value

Index of the added animation or -1 if an error has occurred.

int addEmptySurface ( const char * name, int num_vertex, int num_indices ) #

Appends a new empty surface to the current mesh.

Arguments

  • const char * name - Name of the new surface.
  • int num_vertex - Number of vertices of the new surface.
  • int num_indices - Number of indices of the new surface.

Return value

Number of the new added surface.

int addLayer ( ) #

Appends a new animation layer to the current mesh.

Return value

Number of the new added animation layer.

int addMeshSurface ( const char * name, const Ptr<ObjectMeshSkinned> & mesh, int surface, int target = -1 ) #

Appends a new mesh surface to the current mesh.

Arguments

  • const char * name - Name of the new surface of the current mesh.
  • const Ptr<ObjectMeshSkinned> & mesh - Mesh pointer to copy a surface from.
  • int surface - Number of mesh surface to copy.
  • int target - Number of mesh target to copy. The default value is -1 (all morph targets will be copied).

Return value

Number of the added mesh surface.

int addMeshSurface ( int dest_surface, const Ptr<ObjectMeshSkinned> & mesh, int surface, int target = -1 ) #

Merges the specified surface from the source ObjectMeshSkinned with the specified destination surface of the mesh.

Arguments

  • int dest_surface - Number of the destination surface, with which a surface from the source ObjectMeshSkinned is to be merged.
  • const Ptr<ObjectMeshSkinned> & mesh - Source ObjectMeshSkinned to copy a surface from.
  • int surface - Number of the source mesh surface to copy.
  • int target - Number of mesh target to merge. The default value is -1 (all morph targets will be merged).

Return value

Number of the destination mesh surface.

int addMeshSurface ( const char * name, const Ptr<Mesh> & mesh, int surface, int target = -1 ) #

Appends a new mesh surface to the current mesh by copying the specified surface from the source mesh.

Arguments

  • const char * name - Name of the new surface of the current mesh.
  • const Ptr<Mesh> & mesh - Source mesh to copy a surface from.
  • int surface - Number of the source mesh surface to copy.
  • int target - Number of mesh target to copy. The default value is -1 (all morph targets will be copied).

Return value

Number of the added mesh surface.

int addSurfaceTarget ( int surface, const char * name = 0 ) #

Appends a new morph target to the given mesh surface.

Arguments

  • int surface - Number of the surface, to which the morph target will be appended.
  • const char * name - Name of the new morph target.

Return value

Number of the new added morph target.

int addSurfaceTarget ( int dest_surface, const Ptr<ObjectMeshSkinned> & src_mesh, int src_surface, int src_target = -1 ) #

Appends a new morph target to the given mesh surface by copying it from the specified surface of the source ObjectMeshSkinned.

Arguments

  • int dest_surface - Number of the surface, to which the morph target will be appended.
  • const Ptr<ObjectMeshSkinned> & src_mesh - Source ObjectMeshSkinned to copy the morph target from.
  • int src_surface - Number of the surface of the source ObjectMeshSkinned to copy the morph target from.
  • int src_target - Number of the morph target to copy. The default value is -1 (all morph targets will be copied).

Return value

Number of the new added morph target.

int addTarget ( int surface ) #

Appends a new empty morph target to the given mesh surface.

Arguments

  • int surface - Number of the surface, to which the morph target will be appended.

Return value

number of the new added morph target.

void clearLayer ( int layer ) #

Clears the given animation layer.

Arguments

  • int layer - Animation layer number.

void copyLayer ( int dest, int src ) #

Copies source layer bones transformations to the destination layer. The copying conditions are the following:

  • If the destination layer has more bones than the source one, it will keep its former transformations.
  • If the source layer has more bones than destination one, those bones will be added to the destination layer.

Arguments

  • int dest - Number of the destination layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int src - Number of the source layer in range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.

int createMesh ( const char * path, bool unique = 0 ) #

Creates a skinned mesh.

Arguments

  • const char * path - Path to the mesh file.
  • bool unique - Dynamic flag:
    • false (0) - If the mesh vertices are changed in run-time, meshes loaded from the same file will be also changed.
    • true (1) - If the mesh vertices are changed in run-time, meshes loaded from the same file won't be changed

Return value

1 if the mesh is created successfully; otherwise - 0.

int findAnimation ( const char * path ) const#

Searches for an animation using the given path.

Arguments

  • const char * path - Path to animation file.
    Notice
    Use the path specified on animation loading.

Return value

Animation number, if found; otherwise, -1.

int findBone ( const char * name ) const#

Searches for a bone with a given name.

Arguments

  • const char * name - Bone name.

Return value

Bone number if found; otherwise, -1.

int findSurfaceTarget ( const char * name, int surface ) const#

Searches for a surface morph target with a given name.

Arguments

  • const char * name - Name of the morph target.
  • int surface - Mesh surface number.

Return value

Number of the morph target, if exists; otherwise, -1.

void flushMesh ( ) #

Flushes mesh geometry to the video memory.

void importLayer ( int layer ) #

Copies the current bone state to the given animation layer.

Arguments

  • int layer - Animation layer number.

void inverseLayer ( int dest, int src ) #

Copies inverse transformations of bones from the source layer to the destination layer.
Notice
Destination layer is not cleared before transformations are written to it.

Arguments

  • int dest - Number of the destination layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int src - Number of the source layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.

void lerpLayer ( int dest, int layer0, int layer1, float weight ) #

Copies interpolated bone transformations from two source layers to a destination layer.
Notice
If there is no bone in one of the source layers, the bone transformation from another one will be copied to the destination layer without interpolation.

Arguments

  • int dest - Number of the destination layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int layer0 - Number of the first source layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int layer1 - Number of the second source layer in range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • float weight - Interpolation weight.

int loadMesh ( const char * path ) #

Loads a new mesh instead of the current mesh from the .mesh file. This function doesn't change the mesh name.

Arguments

  • const char * path - The path to the .mesh file.

Return value

1 if the mesh is loaded successfully; otherwise, 0.

void mergeMeshSurface ( int dest_surface, const Ptr<ObjectMeshSkinned> & src_mesh, int src_surface ) #

Merges the specified surface from the source ObjectMeshSkinned with the specified destination surface of the mesh.

Arguments

  • int dest_surface - Number of the destination surface, with which a surface from the source ObjectMeshSkinned is to be merged.
  • const Ptr<ObjectMeshSkinned> & src_mesh - Source ObjectMeshSkinned to copy a surface from.
  • int src_surface - Number of source mesh surface to merge.

void mulLayer ( int dest, int layer0, int layer1, float weight = 1.0f ) #

Copies multiplied bone transformations from two source layers to the destination layer.

Arguments

  • int dest - Number of the destination layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int layer0 - Number of the first source layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • int layer1 - Number of the second source layer in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.
  • float weight - Interpolation weight.

void play ( ) #

Continues playback of the animation, if it was paused, or starts playback if it was stopped.

void removeAnimation ( int animation ) #

Removes the given animation.

Arguments

  • int animation - Animation number.

void removeLayer ( int layer ) #

Removes an animation layer.

Arguments

  • int layer - Layer number in the range from 0 to the total number of animation layers.
    Notice
    To get the total number of animation layers, use the getNumLayers() method.

void removeTarget ( int target, int surface ) #

Removes the given morph target.

Arguments

  • int target - Target number in the range from 0 to the total number of morph targets.
    Notice
    To get the total number of morph targets for a given surface, use the getNumTargets() method.
  • int surface - Mesh surface number.

int saveMesh ( const char * path ) #

Saves the mesh to .mesh or .anim format.

Arguments

  • const char * path - Path to the file including the file name and extension — *.mesh or *.anim.

Return value

1 if the mesh is saved successfully; otherwise, 0.

void stop ( ) #

Stops animation playback. This function saves the playback position so that playing of the animation can be resumed from the same point.

static int type ( ) #

Returns the type of the node.

Return value

Node type identifier.

void updateSurfaceBounds ( int surface = -1 ) #

Updates mesh surface bounds. This method is to be called to recalculate bounds after changing a mesh surface (e.g. modifying positions of coordinate vertices).

Arguments

  • int surface - Number of the surface to recalculate bound for. The default value is -1 (all surfaces).

void setFPSVisibleCamera ( int camera = -1 ) #

Sets the update rate value when the object is rendered to the viewport. The default value is set to infinity.

Arguments

  • int camera - Update rate value when the object is rendered.

int getFPSVisibleCamera ( ) const#

Returns the update rate value when the object is rendered to the viewport.

Return value

Update rate value when the object is rendered.

void setFPSVisibleShadow ( int shadow = 30 ) #

Sets the update rate value when only object shadows are rendered. The default value is set to 30 fps.

Arguments

  • int shadow - Update rate value when only object shadows are rendered.

int getFPSVisibleShadow ( ) const#

Returns the update rate value when only object shadows are rendered.

Return value

Update rate value when only object shadows are rendered.

void setFPSInvisible ( int invisible = 0 ) #

Sets the update rate value when the object is not rendered at all. The default value is 0 fps.

Arguments

  • int invisible - Update rate value when the object is not rendered at all.

int getFPSInvisible ( ) const#

Returns the update rate value when the object is not rendered at all.

Return value

Update rate value when the object is not rendered at all.

void setUpdateDistanceLimit ( float limit = 200 ) #

Sets the distance from the camera within which the object should be updated. The default value is 200 units.

Arguments

  • float limit - Distance from the camera within which the object should be updated.

float getUpdateDistanceLimit ( ) const#

Returns the distance from the camera within which the object should be updated.

Return value

Distance from the camera within which the object should be updated.

void updateSkinned ( ) #

Forces update of all bone transformations.

Math::mat4 getBoneNotAdditionalBindLocalTransform ( int bone ) const#

Returns the bone transformation relative to the parent bone without taking into account the bound node transformation.

Arguments

Return value

Transformation matrix in the local space.

Math::mat4 getBoneNotAdditionalBindObjectTransform ( int bone ) const#

Returns the bone transformation relative to the parent object without taking into account the bound node transformation.

Arguments

Return value

Transformation matrix in the object space.

Math::Mat4 getBoneNotAdditionalBindWorldTransform ( int bone ) const#

Returns the bone transformation relative to the world origin.

Arguments

Return value

Transformation matrix in the world space without taking into account the bound node transformation.

void setBindNode ( int bone, const Ptr<Node> & node ) #

Sets a new node whose transformation is to be used to control the transformation of the bone with the specified number.

Arguments

  • int bone - Number of the bone to be controlled by the specified node, in the range from 0 to the total number of bones.
  • const Ptr<Node> & node - Node whose transformation is used to control the transformation of the bone.

void removeBindNodeByBone ( int bone ) #

Removes the assigned bind node from the bone with the specified number.

Arguments

void removeBindNodeByNode ( const Ptr<Node> & node ) #

Removes the specified bind node.

Arguments

  • const Ptr<Node> & node - Bind node to be removed.

void removeAllBindNode ( ) #

Removes all assigned bind nodes.

Ptr<Node> getBindNode ( int bone ) const#

Returns the bind node currently assigned to the bone with the specified number.

Arguments

Return value

Node whose transformation is used to control the transformation of the bone if it is assigned; otherwise - nullptr.

void setBindNodeSpace ( int bone, ObjectMeshSkinned::NODE_SPACE space ) #

Sets a new value indicating which transformation of the bind node (World or Local) is to be used to override the transformation of the specified bone.

Arguments

ObjectMeshSkinned::NODE_SPACE getBindNodeSpace ( int bone ) const#

Returns the current value indicating which transformation of the bind node (World or Local) is to be used to override the transformation of the specified bone.

Arguments

Return value

Type of transformation of the bind node to be used to override the transformation of the specified bone, one of the NODE_SPACE* values.

void setBindBoneSpace ( int bone, ObjectMeshSkinned::BONE_SPACE space ) #

Sets a value indicating which transformation of the specified bone is to be overridden by the bind node's transformation.

Arguments

ObjectMeshSkinned::BONE_SPACE getBindBoneSpace ( int bone ) const#

Returns the current value indicating which transformation of the specified bone is to be overridden by the bind node's transformation.

Arguments

Return value

Current type of transformation of the specified bone overridden by the bind node's transformation, one of the BONE_SPACE* values.

void setBindMode ( int bone, ObjectMeshSkinned::BIND_MODE mode ) #

Sets a new type of blending of bind node's and bone's transformations.

Arguments

  • int bone - Number of the bone, in the range from 0 to the total number of bones.
  • ObjectMeshSkinned::BIND_MODE mode - New type of blending of bind node's and bone's transformations:
    • OVERRIDE - replace bone's transformation with the transformation of the node.
    • ADDITIVE - node's transformation is added to the current transformation of the bone.

ObjectMeshSkinned::BIND_MODE getBindMode ( int bone ) const#

Returns the current type of blending of bind node's and bone's transformations.

Arguments

Return value

Current type of blending of bind node's and bone's transformations:
  • OVERRIDE - replace bone's transformation with the transformation of the node.
  • ADDITIVE - node's transformation is added to the current transformation of the bone.

void setBindNodeOffset ( int bone, const Math::Mat4 & offset ) #

Sets a new transformation matrix to be applied to the node's transformation before applying it to bone's transformation. This parameter serves for the purpose of additional correction of the node's transform for the bone's basis.

Arguments

  • int bone - Number of the bone, in the range from 0 to the total number of bones.
  • const Math::Mat4 & offset - Transformation matrix applied to the node's transformation before applying it to bone's transformation.

Math::Mat4 getBindNodeOffset ( int bone ) const#

Returns the current transformation matrix which is applied to the node's transformation before applying it to bone's transformation. This parameter serves for the purpose of additional correction of the node's transform for the bone's basis.

Arguments

Return value

Transformation matrix currently applied to the node's transformation before applying it to bone's transformation.

void addVisualizeBone ( int bone ) #

Adds a bone with the specified number to the list of the bones for which the basis vectors are to be visualized.

Arguments

  • int bone - Number of the bone to be added to the visualizer, in the range from 0 to the total number of bones.

void removeVisualizeBone ( int bone ) #

Removes a bone with the specified number from the list of the bones for which the basis vectors are to be visualized.

Arguments

  • int bone - Number of the bone to be removed from the visualizer, in the range from 0 to the total number of bones.

void clearVisualizeBones ( ) #

Clears the list of the bones for which the basis vectors are to be visualized.

void setVisualizeAllBones ( bool bones ) #

Sets a value indicating if visualization for bones and their basis vectors is enabled. The visualizer can be used for debugging purposes showing positions of bones and their basis vectors for multiple meshes simultaneously.

Arguments

  • bool bones - true to enable visualization of bones and their basis vectors; false — to disable it.

bool isVisualizeAllBones ( ) const#

Returns a value indicating if visualization for bones and their basis vectors is enabled. The visualizer can be used for debugging purposes showing positions of bones and their basis vectors for multiple meshes simultaneously.

Return value

true if visualization for bones and their basis vectors is enabled; otherwise, false.

void setBoneFrameUses ( int layer, int bone, ObjectMeshSkinned::FRAME_USES uses ) #

Sets the value indicating which components of the frame are to be used to animate the specified bone of the given animation layer.

Arguments

ObjectMeshSkinned::FRAME_USES getBoneFrameUses ( int layer, int bone ) const#

Returns the value indicating which components of the frame are to be used to animate the specified bone of the given animation layer.

Arguments

  • int layer - Animation layer number.
  • int bone - Number of the bone, in the range from 0 to the total number of bones.

Return value

Value indicating frame components to be used.

void addVisualizeIKChain ( int chain_id ) #

Adds an IK chain with the specified ID to the list of chains for which the basis vectors are to be visualized.

Arguments

  • int chain_id - IK chain ID.

void removeVisualizeIKChain ( int chain_id ) #

Removes the IK chain with the specified ID from the list of chains for which the basis vectors are to be visualized.

Arguments

  • int chain_id - IK chain ID.

void clearVisualizeIKChain ( ) #

Clears the list of IK chains for which the basis vectors are to be visualized.

int addIKChain ( ) #

Adds a new IK chain to the skinned mesh.

Return value

ID of the added IK chain.

void removeIKChain ( int chain_id ) #

Removes the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

int getNumIKChains ( ) const#

Returns the number of IK chains of the skinned mesh.

Return value

Number of IK chains.

int getIKChain ( int num ) const#

Returns the ID of the IK chain by its number.

Arguments

  • int num - IK chain number.

Return value

IK chain ID.

void setIKChainEnabled ( bool enabled, int chain_id ) #

Sets a value indicating if the IK chain with the specified ID is enabled.

Arguments

  • bool enabled - Set true to enable IK chain with the specified ID, or false - to disable it.
  • int chain_id - IK chain ID.

bool isIKChainEnabled ( int chain_id ) const#

Returns a value indicating if the IK chain with the specified ID is enabled.

Arguments

  • int chain_id - IK chain ID.

Return value

true if the IK chain with the specified ID is enabled; otherwise, false.

void setIKChainWeight ( float weight, int chain_id ) #

Sets a new weight for the IK chain with the specified ID. Weight value defines the impact of the target position on the last joint of the chain.

Arguments

  • float weight - New weight value to be set in the [0.0f, 1.0f] range. Higher values increase the impact.
  • int chain_id - IK chain ID.

float getIKChainWeight ( int chain_id ) const#

Returns the current weight for the IK chain with the specified ID. Weight value defines the impact of the target position on the last joint of the chain.

Arguments

  • int chain_id - IK chain ID.

Return value

Current weight value in the [0.0f, 1.0f] range. Higher values increase the impact.

int addIKChainBone ( int bone, int chain_id ) #

Adds a bone with the specified number to the IK chain with the specified ID.

Arguments

  • int bone - Bone number.
  • int chain_id - IK chain ID.

Return value

Index of the last added bone in the chain.

int getIKChainNumBones ( int chain_id ) const#

Returns the number of bones in the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Number of bones in the IK chain with the specified ID.

void removeIKChainBone ( int bone_num, int chain_id ) #

Removes the bone with the specified number from the IK chain with the specified ID.

Arguments

  • int bone_num - Bone number.
  • int chain_id - IK chain ID.

int getIKChainBone ( int bone_num, int chain_id ) const#

Returns the index of the bone with the specified number (within the chain) from the IK chain with the specified ID.

Arguments

  • int bone_num - Bone number.
  • int chain_id - IK chain ID.

Return value

Number of the bone, in the range from 0 to the total number of bones.

void setIKChainTargetPosition ( const Math::Vec3 & position, int chain_id ) #

Sets new local coordinates of the target position of the IK chain with the specified ID.

Arguments

  • const Math::Vec3 & position - New local coordinates of the target position to be set for the IK chain with the specified ID.
  • int chain_id - IK chain ID.

Math::Vec3 getIKChainTargetPosition ( int chain_id ) const#

Returns the current local coordinates of the target position of the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Local coordinates of the target position of the IK chain with the specified ID.

void setIKChainTargetWorldPosition ( const Math::Vec3 & position, int chain_id ) #

Sets new world coordinates of the target position of the IK chain with the specified ID.

Arguments

  • const Math::Vec3 & position - New world coordinates of the target position to be set for the IK chain with the specified ID.
  • int chain_id - IK chain ID.

Math::Vec3 getIKChainTargetWorldPosition ( int chain_id ) const#

Returns the current world coordinates of the target position of the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

World coordinates of the target position of the IK chain with the specified ID.

void setIKChainUsePoleVector ( bool use, int chain_id ) #

Sets a value indicating if the pole vector is to be used to define the direction of rotation for the joints of the IK chain with the specified ID as they attempt to reach the target.

Arguments

  • bool use - true to use the pole vector for the IK chain with the specified ID; false - not to use.
  • int chain_id - IK chain ID.

bool isIKChainUsePoleVector ( int chain_id ) const#

Returns a value indicating if the pole vector is to be used to define the direction of rotation for the joints of the IK chain with the specified ID as they attempt to reach the target.

Arguments

  • int chain_id - IK chain ID.

Return value

true if the pole vector is to be used for the IK chain with the specified ID; otherwise, false.

void setIKChainPolePosition ( const Math::Vec3 & position, int chain_id ) #

Sets a new pole position (in local coordinates) for the IK chain with the specified ID.

Arguments

  • const Math::Vec3 & position - New pole position (in local coordinates) to be set for the IK chain.
  • int chain_id - IK chain ID.

Math::Vec3 getIKChainPolePosition ( int chain_id ) const#

Returns the current pole position (in local coordinates) for the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Pole position (in local coordinates) for the IK chain.

void setIKChainPoleWorldPosition ( const Math::Vec3 & position, int chain_id ) #

Sets a new pole position (in world coordinates) for the IK chain with the specified ID.

Arguments

  • const Math::Vec3 & position - New pole position (in world coordinates) to be set for the IK chain.
  • int chain_id - IK chain ID.

Math::Vec3 getIKChainPoleWorldPosition ( int chain_id ) const#

Returns the current pole position (in world coordinates) for the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Pole position (in world coordinates) for the IK chain.

void setIKChainUseEffectorRotation ( bool use, int chain_id ) #

Sets a value indicating if the effector rotation is to be used for the IK chain with the specified ID.

Arguments

  • bool use - true to use effector rotation for the IK chain with the specified ID; false - not to use.
  • int chain_id - IK chain ID.

bool isIKChainUseEffectorRotation ( int chain_id ) const#

Returns a value indicating if the effector rotation is to be used for the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

true if the effector rotation is to be used for the IK chain with the specified ID; otherwise, false.

void setIKChainEffectorRotation ( const Math::quat & rotation, int chain_id ) #

Sets the rotation of the end-effector (in local coordinates) of the IK chain with the specified ID.

Arguments

  • const Math::quat & rotation - Quaternion that defines rotation (local coordinates) of the end-effector of the chain.
  • int chain_id - IK chain ID.

Math::quat getIKChainEffectorRotation ( int chain_id ) const#

Returns the current rotation (in local coordinates) of the end-effector of the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Quaternion that defines rotation (local coordinates) of the end-effector of the chain.

void setIKChainEffectorWorldRotation ( const Math::quat & rotation, int chain_id ) #

Sets the rotation of the end-effector (in world coordinates) of the IK chain with the specified ID.

Arguments

  • const Math::quat & rotation - Quaternion that defines rotation (world coordinates) of the end-effector of the chain.
  • int chain_id - IK chain ID.

Math::quat getIKChainEffectorWorldRotation ( int chain_id ) const#

Returns the current rotation (in world coordinates) of the end-effector of the IK chain with the specified ID.

Arguments

  • int chain_id - IK chain ID.

Return value

Quaternion that defines rotation (world coordinates) of the end-effector of the chain.

void setIKChainNumIterations ( int num, int chain_id ) #

Sets the number of iterations to be used for solving the IK chain with the specified ID (number of times the algorithm runs).

Arguments

  • int num - Number of iterations to be used for solving the IK chain with the specified ID.
  • int chain_id - IK chain ID.

int getIKChainNumIterations ( int chain_id ) const#

Returns the number of iterations used for solving the IK chain with the specified ID (number of times the algorithm runs).

Arguments

  • int chain_id - IK chain ID.

Return value

Current number of iterations for the IK chain with the specified ID.

void setIKChainTolerance ( float tolerance, int chain_id ) #

Sets a new tolerance value to be used for the IK chain with the specified ID. This value sets a threshold where the target is considered to have reached its destination position, and when the IK Solver stops iterating.

Arguments

  • float tolerance - Tolerance value to be set for the IK chain.
  • int chain_id - IK chain ID.

float getIKChainTolerance ( int chain_id ) const#

Returns the current tolerance value to be used for the IK chain with the specified ID. This value sets a threshold where the target is considered to have reached its destination position, and when the IK Solver stops iterating.

Arguments

  • int chain_id - IK chain ID.

Return value

Current tolerance value for the IK chain.

void copyBoneTransforms ( const Ptr<ObjectMeshSkinned> & mesh ) #

Copies all bone transformations from the specified source skinned mesh.

Arguments

  • const Ptr<ObjectMeshSkinned> & mesh - Source skinned mesh from which bone transforms are to be copied.
Last update: 2024-04-19
Build: ()