This page has been translated automatically.
Getting Started
Migrating to UNIGINE 2.0
C++ API Migration
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
Usage Examples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Внимание! Эта версия документация УСТАРЕЛА, поскольку относится к более ранней версии SDK! Пожалуйста, переключитесь на самую актуальную документацию для последней версии SDK.
Внимание! Эта версия документации описывает устаревшую версию SDK, которая больше не поддерживается! Пожалуйста, обновитесь до последней версии SDK.

ObjectMeshSkinned Class

This class is used to create or modify skinned meshes.

Skinned meshes are used for bone-based animation.

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.
  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 setBoneChildsTransform().

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.

Source code (UnigineScript)
// define the new ObjectMeshSkinned class instance
ObjectMeshSkinned skinned_mesh;

int init() {
	/* ... */
	// create the new ObjectMeshSkinned mesh based on an existing mesh
	skinned_mesh = new ObjectMeshSkinned("samples/animation/meshes/agent.mesh");

	// add the material and the property to the mesh
	skinned_mesh.setMaterial("mesh_base","*");
	skinned_mesh.setProperty("surface_base","*");
	// add the mesh to the editor
	engine.editor.addNode(node_remove(skinned_mesh));
	
	// set the number of animation layers
	skinned_mesh.setNumLayers(2);

	// load animations from the files
	int animation_1 = skinned_mesh.addAnimation("samples/animation/animations/agent_run.anim");
	int animation_2 = skinned_mesh.addAnimation("samples/animation/animations/agent_punch.anim");

	// 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);

	/* ... */
}

int update() {
	/* ... */
	// get the current time spent in the game
	float time = engine.game.getTime();

	// start each animation playing
	skinned_mesh.setFrame(0,time * 25.0f);
	skinned_mesh.setFrame(1,time * 25.0f);
	/* ... */
}
					

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 instancing flag is enabled by default (see corresponding console commands).

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.

See Also

ObjectMeshSkinned Class

This class inherits from Object

Members


ObjectMeshSkinned (variable v, int dynamic = 0)

An ObjectMeshSkinned constructor. The new ObjectMeshSkinned based on the specified mesh will be created. You can specify either a mesh itself or a path to it.

Arguments

  • variable v - Argument of one of the following types:
    • Mesh mesh - The source mesh.
      Notice
      In this case, the second argument ("dynamic") is not available.
    • string name - The path to the .mesh file.
      Notice
      In this case, you need to specify the second argument ("dynamic").
  • int dynamic - The dynamic flag:
    • 0 - If the mesh vertices are changed in run-time, meshes loaded from the same file will be also changed.
    • 1 - If the mesh vertices are changed in run-time, meshes loaded from the same file won't be changed.
    Notice
    This argument is available only if the first argument is string.

int addAnimation (variable v, string animation = 0)

Loads the additional animation from the external file/mesh.

Arguments

  • variable v - Argument of one of the following types:
    • string name - Path to the animation file.
    • Mesh mesh - Mesh file.
  • string animation - Animation name.

Return value

Animation identifier.

int addEmptySurface (string name, int num_vertices, int num_indices)

Appends a new empty surface to the current mesh.

Arguments

  • string name - Name of the new surface.
  • int num_vertices - Number of the new surface vertices.
  • int num_indices - Number of the new surface indices.

Return value

The number of the appended surface.

int addLayer ()

Adds a new animation layer.

Return value

Identifier of the last added animation layer.

int addMeshSurface (variable v0, variable v1, int surface, int target = -1)

Appends the specified surface of the source mesh to the current mesh. Variables, passed as arguments, can be of the following types:

  • string and Mesh.
  • string and ObjectMeshSkinned.
  • int and ObjectMeshSkinned.

Arguments

  • variable v0 - Argument of one of the following types:
    • string name - Name of the new surface.
    • int dest_surface - Number of the surface to append geometry to.
  • variable v1 - Argument of one of the following types:
    • Mesh mesh - Source mesh to copy the surface from.
    • ObjectMeshSkinned mesh - Source mesh to copy the surface from.
  • int surface - The number of the source mesh surface to be appended.
  • int target - The number of the source surface morph target to be appended.

Return value

The number of the surface, appended to the current mesh.

int addSurfaceTarget (int surface, string name = 0)

Appends the new morph target to the given mesh surface.

Arguments

  • int surface - The number of the surface, to which the morph target will be appended.
  • string name - The name of the new morph target.

Return value

The number of the added morph target.

int addTarget (int surface)

Appends the new morph target to the given mesh surface.

Arguments

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

Return value

The number of the added morph target.

void clearLayer (int layer)

Clears the given animation layer.

Arguments

  • int layer - The animation layer number.

void copyLayer (int layer, int layer_0)

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 layer - The number of the destination layer (counted from 0 to the total number of animation layers).
  • int layer_0 - The number of the source layer (counted from 0 to the total number of animation layers).

int createMesh (string name, int dynamic = 0)

Creates the skinned mesh with the specified parameters.

Arguments

  • string name - Mesh name.
  • int dynamic - Dynamic flag:
    • 0 - If the mesh vertices are changed in run-time, meshes loaded from the same file will be also changed.
    • 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 (string name)

Searches for the animation by the name.

Arguments

  • string name - The name of the animation.

Return value

The animation identifier, if found; otherwise, -1.

int findBone (string name)

Searches for a bone with a given name.

Arguments

  • string name - Name of the bone.

Return value

Bone number.

int findSurfaceTarget (string name, int surface)

Searches for the morph target number by the name.

Arguments

  • string name - The name of the morph target.
  • int surface - The number of the mesh surface.

Return value

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

void flushMesh ()

Flushes the mesh geometry into the video memory.

string getAnimName ()

Returns the name of the current animation.

Return value

The name of the animation.

int getAnimationID (int num)

Returns the animation identifier at the specified position.

Arguments

  • int num - Number of the animation.

Return value

Animation identifier.

string getAnimationName (int animation)

Returns the name of the animation by identifier.

Arguments

  • int animation - Animation identifier.

Return value

Name of the animation.

int getAnimation (int layer)

Returns the animation identifier from the given animation layer.

Arguments

  • int layer - The layer number.

Return value

The animation identifier.

mat4 getBoneBindTransform (int bone)

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

Arguments

  • int bone - The bone number.

Return value

The bind pose bone transformation matrix.

int getBoneChild (int bone, int child)

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.

string getBoneName (int bone)

Returns the name of a given bone.

Arguments

  • int bone - Bone number.

Return value

The name of the bone.

int getBoneParent (int bone)

Returns the number of the parent bone of a given one.

Arguments

  • int bone - Bone, for which the parent will be returned.

Return value

Parent bone number.

mat4 getBoneTransform (int bone)

Returns a transformation matrix of a given bone relatively to the parent object (not considering transformations of the node itself).

Arguments

  • int bone - The number of the bone.

Return value

Transformation matrix.

int getCIndex (int num, int surface)

Returns the coordinate index by its number.

Arguments

  • int num - The number of the index in the index buffer (in range from 0 to the total number of coordinate indices of the given surface).
  • int surface - Number of the mesh surface.

Return value

Coordinate index.

int getFrameFrom (int layer)

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

Arguments

  • int layer - The number of the layer.

Return value

The start frame.

int getFrameTo (int layer)

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

Arguments

  • int layer - The number of the layer.

Return value

The end frame.

float getFrame (int layer)

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

Arguments

  • int layer - The number of the layer.

Return value

The frame number.

mat4 getIBoneBindTransform (int bone)

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(getIBoneTransform()).

Arguments

  • int bone - The number of the bone.

Return value

Inverse transformation matrix.

mat4 getIBoneTransform (int bone)

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

Arguments

  • int bone - The number of the bone.

Return value

The inverse transformation matrix.

mat4 getLayerBoneTransform (int layer, int bone)

Returns a transformation matrix of a given bone relatively to the parent object. 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 - The number of the layer.
  • int bone - The number of the bone.

Return value

The transformation matrix.

float getLayerWeight (int layer)

Returns the vertex weight of the animation layer.

Arguments

  • int layer - The number of the layer.

Return value

The vertex weight.

int getLoop ()

Returns a value indicating if the animation is looped. 1 if the animation is looped; otherwise - 0.

Return value

The loop flag.

string getMeshName ()

Returns the name of the mesh.

Return value

Name of the mesh.

int getMeshSurface (Mesh mesh, int surface, int target = -1)

Copies the specified mesh surface into the source mesh.

Arguments

  • Mesh mesh - The mesh to copy the surface into.
  • int surface - The number of the mesh surface to be copied.
  • int target - The number of the surface morph target to be copied.

Return value

The number of the added mesh surface.

int getMesh (Mesh mesh)

Copies the current mesh into the source mesh.

Arguments

  • Mesh mesh - Source mesh.

Return value

1 if the mesh is copied successfully.

vec3 getNormal (int num, int surface, int target = 0)

Returns a normal vector of a given vertex.

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • int surface - Number of the surface.
  • int target - Number of the surface's morph target.

Return value

Normal vector.

int getNumAnimationBones (int animation)

Returns the number of animation bones.

Arguments

  • int animation - Number of the animation.

Return value

Number of animation bones.

int getNumAnimationFrames (int animation)

Returns the number of animation frames.

Arguments

  • int animation - Number of the animation.

Return value

Number of animation frames.

int getNumAnimations ()

Returns the number of all of the loaded animations.

Return value

Number of animations.

int getNumBoneChildren (int bone)

Returns the number of children for the specified bone.

Arguments

  • int bone - Bone number.

Return value

Number of child bones.

int getNumBoneChilds (int bone)

Returns the number of children for the specified bone.
Warning
The function is deprecated. It is provided to keep your code working until the next release. Please, replace it with getNumBoneChildren().

Arguments

  • int bone - Bone number.

Return value

Number of child bones.

int getNumBones ()

Returns the number of all bones taking part in animation.

Return value

Number of bones in the bind pose.

int getNumCIndices (int surface)

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

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of coordinate indices.

int getNumFrames (int layer)

Returns the number of animation frames for a given layer.

Arguments

  • int layer - The number of the layer.

Return value

The number of animation frames.

int getNumLayers ()

Returns the number of animation layers set for blending.

Return value

Number of animation layers.

int getNumSurfaceTargets (int surface)

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

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of surface morph targets.

int getNumTIndices (int surface)

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

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of triangle indices.

int getNumTangents (int surface)

Returns the number of tangent vectors of the given mesh surface.

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of tangent vectors.

int getNumTargets (int surface)

Returns the amount of the morph targets of the given mesh surface.

Arguments

  • int surface - The number of the mesh surface.

Return value

The amount of morph targets.

int getNumTexCoords0 (int surface)

Returns the number of the first UV map texture coordinates for the given mesh surface.

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of the first UV map texture coordinates.

int getNumTexCoords1 (int surface)

Returns the number of the second UV map texture coordinates for the given mesh surface.

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of the second UV map texture coordinates.

int getNumVertex (int surface)

Returns the number of vertices for the given mesh surface.

Arguments

  • int surface - The number of the mesh surface.

Return value

The number of surface vertices.

vec3 getSkinnedNormal (int num, int index, int surface)

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

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • int index - Coordinate index.
  • int surface - Number of the mesh surface.

Return value

Skinned normal.

quat getSkinnedTangent (int num, int index, int surface)

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

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • int index - Coordinate index.
  • int surface - Number of the mesh surface.

Return value

Skinned tangent.

vec3 getSkinnedVertex (int num, int surface)

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

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • int surface - Number of the mesh surface.

Return value

Vertex coordinates.

float getSpeed ()

Returns a multiplier for animation playback time.

Return value

A multiplier value.

string getSurfaceTargetName (int surface, int target)

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

Arguments

  • int surface - The number of the mesh surface.
  • int target - The number of the surface morph target.

Return value

The name of the surface morph target.

int getTIndex (int num, int surface)

Returns the triangle index for the given mesh surface.

Arguments

  • int num - The number of the index in the index buffer.
  • int surface - The number of the mesh surface.

Return value

The triangle index.

quat getTangent (int num, int surface, int target = 0)

Returns the tangent vector of the given vertex.

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • int surface - Number of the mesh surface.
  • int target - Number of the surface's morph target.

Return value

Tangent vector.

int getTargetIndex (int target, int surface)

Returns the index of the morph target.

Arguments

  • int target - The number of the morph target.
  • int surface - The number of the mesh surface.

Return value

Index of the morph target.

float getTargetWeight (int target, int surface)

Returns the weight of the morph target.

Arguments

  • int target - The number of the morph target.
  • int surface - The number of the mesh surface.

Return value

The weight of the morph target.

vec2 getTexCoord0 (int num, int surface)

Returns the first UV map texture coordinates.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • int surface - The number of the mesh surface.

Return value

The first UV map texture coordinates.

vec2 getTexCoord1 (int num, int surface)

Returns the second UV map texture coordinates.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • int surface - The number of the mesh surface.

Return value

The second UV map texture coordinates.

float getTime ()

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

Return value

Animation time.

vec3 getVertex (int num, int surface, int target = 0)

Returns vertex coordinates.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • int surface - The number of the mesh surface.
  • int target - The number of the surface morph target.

Return value

Vertex coordinates.

mat4 getWorldBoneTransform (int bone)

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.

void importLayer (int layer)

Copies the current bone state to the given animation layer.

Arguments

  • int layer - The number of the animation layer.

void inverseLayer (int layer, int layer_0)

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

Arguments

  • int layer - The number of the destination layer in range from 0 to the total number of animation layers.
  • int layer_0 - The number of the source layer in range from 0 to the total number of animation layers.

int isControlled ()

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

Return value

Controlled flag: 1 if the animation is controlled; otherwise, 0.

int isLayerBoneTransform (int layer, int bone)

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

Arguments

  • int layer - The number of the animation layer.
  • int bone - The number of the bone.

Return value

1 if the bone transformation is applied only to the animation layer; otherwise, 0.

int isLayerEnabled (int layer)

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

Arguments

  • int layer - The number of the animation layer.

Return value

1 if the layer is disabled; otherwise, 0.

int isPlaying ()

Returns playback status.

Return value

1 if animation is playing; otherwise, 0.

int isQuaternion ()

Returns the value indicating if the quaternion skinning mode is used.

Return value

1 if the quaternion skinning mode is used; otherwise, 0.

int isStopped ()

Returns stop status.

Return value

1 if animation is stopped; otherwise, 0.

int isTargetEnabled (int target, int surface)

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

Arguments

  • int target - The morph target number.
  • int surface - The number of the mesh surface.

Return value

1 if the given surface is disabled; otherwise, 0.

void lerpLayer (int layer, int layer_0, int layer_1, float weight)

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

Arguments

  • int layer - The number of the destination layer in range from 0 to the total number of animation layers.
  • int layer_0 - The number of the first source layer in range from 0 to the total number of animation layers.
  • int layer_1 - The number of the second source layer in range from 0 to the total number of animation layers.
  • float weight - The interpolation weight.

int loadMesh (string name)

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

Arguments

  • string name - The path to the .mesh file.

Return value

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

void mulLayer (int layer, int layer_0, int layer_1, float weight = 1.0f)

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

Arguments

  • int layer - The number of the destination layer in range from 0 to the total number of animation layers.
  • int layer_0 - The number of the first source layer in range from 0 to the total number of animation layers.
  • int layer_1 - The number of the second source layer in range from 0 to the total number of animation layers.
  • float weight - The 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 animation.

Arguments

  • int animation - The animation identifier.

void removeLayer (int num)

Removes an animation layer.

Arguments

  • int num - The layer number in a range from 0 to the total number of animation layers.

void removeTarget (int target, int surface)

Removes the morph target.

Arguments

  • int target - The target number in range from 0 to the total number of morph targets.
  • int surface - The number of the mesh surface.

int saveMesh (string name)

Saves the mesh into the .mesh or .anim format.

Arguments

  • string name - The path to the file.

Return value

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

void setAnimName (string name)

Sets the name for the animation.

Arguments

  • string name - The name of the animation.

void setAnimation (int layer, variable v)

Sets the animation parameter (name or id) for the given animation layer.

Arguments

  • int layer - The number of the layer.
  • variable v - The variable of one of the following types:
    • string name - The animation layer name.
    • int animation - The animation identifier.

void setBoneChildrenTransform (int bone, mat4 transform)

Sets transformation for the bone and all of its children (without considering node transformations). Take notice that bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix.

void setBoneChildsTransform (int bone, mat4 transform)

Sets transformation for the bone and all of its children (without considering node transformations). Take notice that bones can be scaled only uniformly.
Warning
The function is deprecated. It is provided to keep your code working until the next release. Please, replace it with setBoneChildrenTransform().

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix.

void setBoneTransform (int bone, mat4 transform)

Sets a transformation matrix for a given bone (without considering node transformations). Take notice that a bone can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix.

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

Sets the coordinate index.

Arguments

  • int num - The number of the index in the index buffer.
  • int index - The index to be set.
  • int surface - The number of the mesh surface.

void setControlled (int c)

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

Arguments

  • int c - Controlled flag: 1 if the animation is controlled by a parent ObjectMeshSkinned; otherwise - 0.

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

Sets a frame for the animation layer.

Arguments

  • int layer - The number of the animation layer.
  • float time - The number of the frame 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 - The start frame. -1 means the first frame of animation.
  • int to - The end frame. -1 means the last animation frame.

Return value

The number of the frame.

void setLayerBoneTransformEnabled (int layer, int bone, int enable)

Enables or disables a layer transformation for a given bone.

Arguments

  • int layer - The number of the animation layer.
  • int bone - The number of the bone.
  • int enable - The flag indicating that a transformation is enabled.

void setLayerBoneTransform (int layer, int bone, 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 done).
Notice
The bone can be scaled only uniformly.

Arguments

  • int layer - The number of the animation layer.
  • int bone - The number of the bone.
  • mat4 transform - The transformation matrix.

void setLayerEnabled (int layer, int enable)

Enables or disables a given animation layer.

Arguments

  • int layer - The number of the animation layer.
  • int enable - The flag indicating that a layer is enabled.

void setLayerWeight (int layer, float weight)

Sets the vertex weight for the animation layer.

Arguments

  • int layer - The number of the animation layer.
  • float weight - The vertex weight.

void setLayer (int layer, int enable, float weight)

Enables the given animation layer.

Arguments

  • int layer - The number of the layer.
  • int enable - The enable flag.
  • float weight - The layer weight.

void setLoop (int mode)

Sets a value indicating if the animation should be looped.

Arguments

  • int mode - 1 is to play the animation in a loop, 0 is to play it only once.

void setMeshName (string name)

Sets a new name to the mesh.

Arguments

  • string name - The name of the mesh.

int setMesh (Mesh mesh)

Copies the source mesh into the current mesh.

Arguments

  • Mesh mesh - The source mesh to be copied.

Return value

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

void setNumLayers (int layers)

Sets the number of animation layers for blending.

Arguments

  • int layers - Number of animation layers.

void setNumTargets (int num, int surface)

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

Arguments

  • int num - Number of animation targets.
  • int surface - Number of the mesh surface.

void setNumTexCoords0 (int num, int surface)

Sets the number of the first texture coordinates for the given mesh surface.

Arguments

  • int num - Number of the first texture coordinates to be set.
  • int surface - Number of the mesh surface.

void setNumTexCoords1 (int num, int surface)

Sets the number of the second texture coordinates for the given mesh surface.

Arguments

  • int num - Number of the second texture coordinates to be set.
  • int surface - Number of the mesh surface.

void setQuaternion (int quaternion)

Sets the quaternion skinning mode.

Arguments

  • int quaternion - Quaternion flag.

void setSpeed (float speed)

Updates a multiplier value for the animation playback time.

Arguments

  • float speed - Multiplier value.

void setSurfaceTransform (mat4 transform, int surface, int target = -1)

Transforms the mesh surface.

Arguments

  • mat4 transform - The transformation matrix.
  • int surface - The number of the mesh surface.
  • int target - The number of the surface morph target.

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

Sets the new triangle index for the given mesh surface.

Arguments

  • int num - The number of the index in the index buffer.
  • int index - The index to be set.
  • int surface - The number of the mesh surface.

void setTangent (int num, quat tangent, int surface, int target = 0)

Sets the new tangent vector for a given vertex.

Arguments

  • int num - Number of the vertex in the vertex buffer.
  • quat tangent - Tangent vector to be set.
  • int surface - Number of the mesh surface.
  • int target - Number of the surface's morph target.

void setTargetEnabled (int target, int enable, int surface)

Enables or disables a given morph target.

Arguments

  • int target - Number of a target.
  • int enable - Enabling flag. 1 to enable the morph target; 0 to disable it.
  • int surface - Number of a surface.

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

Sets an index for the given morph target.

Arguments

  • int target - Number of a target.
  • int index - Target index.
  • int surface - Number of a surface.

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

Sets a weight for a morph target.

Arguments

  • int target - Number of a target.
  • float weight - Target weight.
  • int surface - Surface number.

void setTarget (int target, int enable, int index, float weight, int surface)

Sets all parameters to a given morph target.

Arguments

  • int target - Number of a target.
  • int enable - Enabling flag. 1 to enable the morph target; 0 to disable it.
  • int index - Target index.
  • float weight - Target weight.
  • int surface - Surface number.

void setTexCoord0 (int num, vec2 texcoord, int surface)

Sets new coordinates for the first UV map of the mesh surface.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • vec2 texcoord - Coordinates of the first UV map to be set.
  • int surface - The number of the mesh surface.

void setTexCoord1 (int num, vec2 texcoord, int surface)

Sets new coordinates for the second UV map of the given mesh surface.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • vec2 texcoord - Coordinates of the second UV map to be set.
  • int surface - The number of the mesh surface.

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.

void setVertex (int num, vec3 vertex, int surface, int target = 0)

Sets new coordinates for the given vertex.

Arguments

  • int num - The number of the vertex in the vertex buffer.
  • vec3 vertex - Coordinates of the vertex to be set.
  • int surface - The number of the mesh surface.
  • int target - The number of the surface morph target.

void setWorldBoneChildrenTransform (int bone, mat4 transform)

Sets transformation for the bone and all of its children in the world coordinate space (considering node transformations). Take notice that bones can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix.

void setWorldBoneChildsTransform (int bone, mat4 transform)

Sets transformation for the bone and all of its children in the world coordinate space (considering node transformations). Take notice that bones can be scaled only uniformly.
Warning
The function is deprecated. It is provided to keep your code working until the next release. Please, replace it with setWorldBoneChildrenTransform().

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix.

void setWorldBoneTransform (int bone, mat4 transform)

Applies transformation to a bone in the world coordinate space. Take notice that a bone can be scaled only uniformly.

Arguments

  • int bone - Bone number.
  • mat4 transform - Transformation matrix in the world space.

void stop ()

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

void updateSurfaceBounds (int surface = -1)

Updates mesh bounds.

Arguments

  • int surface - The number of the mesh surface.
    Notice
    Specify -1 to select all surfaces.
Last update: 03.07.2017
Build: ()