This page has been translated automatically.
UnigineScript
The Language
Core Library
Engine Library
Node-Related Classes
GUI-Related Classes
Plugins Library
High-Level Systems
Samples
C++ API
API Reference
Integration Samples
Usage Examples
C++ Plugins
Content Creation
Materials
Unigine Material Library
Tutorials
Warning! This version of documentation is OUTDATED, as it describes an older SDK version! Please switch to the documentation for the latest SDK version.
Warning! This version of documentation describes an old SDK version which is no longer supported! Please upgrade to the latest SDK version.

Unigine::ObjectMeshSkinned Class

Interface for object mesh skinned handling. See also the UnigineScript analog.

To use this class, include the UnigineObjectMeshSkinned.h file.

Unigine::ObjectMeshSkinned Class

Members


static Ptr< ObjectMeshSkinned > create (const NodePtr & node)

ObjectMeshSkinned constructor.

Arguments

  • const NodePtr & node - Node smart pointer.

static Ptr< ObjectMeshSkinned > create (const ObjectPtr & object)

ObjectMeshSkinned constructor.

Arguments

  • const ObjectPtr & object - Object smart pointer.

static Ptr< ObjectMeshSkinned > create (const char * name)

ObjectMeshSkinned constructor.

Arguments

  • const char * name - Path to the skinned mesh file.

virtual int save (const char * name) const =0

Saves a skinned mesh into a specified *.smesh or *.sanim file.

Arguments

  • const char * name - Path to the skinned mesh file.

Return value

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

virtual int addBone (const char * name, int parent) const =0

Appends a new bone to a mesh.

Arguments

  • const char * name - Bone name.
  • int parent - Parent bone number.

Return value

Number of the appended bone.

virtual int addFrame (const mat4 * transforms) const =0

Appends a new frame.

Arguments

  • const mat4 * transforms - Frame transformations pointer.

Return value

Frame number.

virtual int addMeshFrame (Ptr< ObjectMeshSkinned > mesh, int frame) const =0

Copies per-frame transformations from a donor skinned mesh to the current one. Transformations from the specified frame are applied to identical bones found by name.

Arguments

  • Ptr< ObjectMeshSkinned > mesh - Pointer to the skinned mesh to copy a frame from.
  • int frame - Frame number.

Return value

Number of the added frame.

virtual void setSurfaceTransform (const mat4 & transform, int surface) const =0

Applies transformation to a given mesh surface.

Arguments

  • const mat4 & transform - Transformation matrix.
  • int surface - Surface number.

virtual int addMeshSurface (const char * name, Ptr< ObjectMeshSkinned > mesh, int surface) const =0

Appends a new mesh surface to the current mesh.

Arguments

  • const char * name - New surface name.
  • Ptr< ObjectMeshSkinned > mesh - Pointer to the mesh, from which the surface is copied.
  • int surface - Number of the mesh surface to copy geometry from.

Return value

Number of the added mesh surface.

virtual int addMeshSurface (int dest_surface, Ptr< ObjectMeshSkinned > mesh, int surface) const =0

Appends a mesh surface geometry to the existing surface of the current mesh.

Arguments

  • int dest_surface - Destination surface number.
  • Ptr< ObjectMeshSkinned > mesh - Pointer to the mesh, from which surface geometry is copied.
  • int surface - Number of the mesh surface to copy geometry from.

Return value

Mesh surface number, to which new geometry is appended.

virtual int addEmptySurface (const char * name, int num_vertex, int num_indices) const =0

Appends a new surface to the mesh.

Arguments

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

Return value

Number of the appended surface.

virtual void updateSurfaces () const =0

Updates mesh surfaces (resizes them and updates their world position if necessary).

virtual int getNumVertex (int surface) const =0

Returns the number of mesh vertices.

Arguments

  • int surface - Surface number.

Return value

Number of the surface vertices.

virtual void setVertex (int num, const vec3 & xyz, int surface) const =0

Updates coordinates of a given vertex.

Arguments

  • int num - Vertex number.
  • const vec3 & xyz - New vertex coordinates.
  • int surface - Number of the surface to which the vertex belongs.

virtual vec3 getVertex (int num, int surface) const =0

Returns coordinates of a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Vertex coordinates.

virtual void setNormal (int num, const vec3 & normal, int surface) const =0

Update a normal vector for a given vertex.

Arguments

  • int num - Vertex number.
  • const vec3 & normal - New normal vector.
  • int surface - Surface number to which the vertex belongs.

virtual vec3 getNormal (int num, int surface) const =0

Returns the normal vector for a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Normal vector.

virtual void setTangent (int num, const vec4 & tangent, int surface) const =0

Updates a tangent vector for a given vertex.

Arguments

  • int num - Vertex number.
  • const vec4 & tangent - New tangent vector.
  • int surface - Surface number to which the vector belongs.

virtual vec4 getTangent (int num, int surface) const =0

Returns the tangent vector for a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Tangent vector.

virtual void setTexCoord (int num, const vec4 & texcoord, int surface) const =0

Updates texture coordinates of a given vertex.

Arguments

  • int num - Vertex number.
  • const vec4 & texcoord - New texture coordinates.
  • int surface - Surface number to which the vertex belongs.

virtual vec4 getTexCoord (int num, int surface) const =0

Returns texture coordinates of a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Texture coordinates of the vertex.

virtual void setNumWeights (int num, int num_weights, int surface) const =0

Updates the number of bone weights that control a given vertex. Up to 4 bone weights per vertex are supported.

Arguments

  • int num - Vertex number.
  • int num_weights - Number of bone weights to use (up to 4).
  • int surface - Surface number to which the vertex belongs.

virtual int getNumWeights (int num, int surface) const =0

Returns the number of bone weights that control a given vertex. Up to 4 bone weights per vertex are supported.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Number of bone weights.

virtual void setWeights (int num, const vec4 & weights, int surface) const =0

Updates bone weights of a given vertex. Up to 4 bone weights per vertex are supported.

Arguments

  • int num - Vertex number.
  • const vec4 & weights - Bone weights.
  • int surface - Surface number to which the vertex belongs.

virtual vec4 getWeights (int num, int surface) const =0

Returns bone weights of a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Bone weights of the vertex.

virtual void setBones (int num, const ivec4 & bones, int surface) const =0

Updates bone indices used to control a given vertex. Up to 4 bones per vertex are supported.

Arguments

  • int num - Vertex number.
  • const ivec4 & bones - Bone indices.
  • int surface - Surface number to which the vertex belongs.

virtual ivec4 getBones (int num, int surface) const =0

Returns bone indices for a given vertex.

Arguments

  • int num - Vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Bone indices of the vertex.

virtual int getNumIndices (int surface) const =0

Returns a number of vertex indices used in a given mesh surface.

Arguments

  • int surface - Surface number.

Return value

Number of indices.

virtual void setIndex (int num, int index, int surface) const =0

Updates an index of a vertex in the index buffer.

Arguments

  • int num - Index number in the index buffer.
  • int index - New index of the vertex in the vertex buffer.
  • int surface - Surface number.

virtual int getIndex (int num, int surface) const =0

Returns an index of a vertex from the index buffer.

Arguments

  • int num - Index number in the index buffer.
  • int surface - Surface number.

Return value

Index of the vertex in the index buffer.

virtual int getNumCoordinateVertex (int surface) const =0

Returns the number of coordinate vertices in a given surface.

Arguments

  • int surface - Surface number.

Return value

Number of coordinate vertices.

virtual vec3 getCoordinateVertex (int num, int surface) const =0

Returns coordinates of a coordinate vertex.

Arguments

  • int num - Coordinate vertex number.
  • int surface - Surface number to which the vertex belongs.

Return value

Coordinates of the coordinate vertex.

virtual int getCoordinateIndex (int num, int surface) const =0

Returns an index pointing to the coordinate vertex.

Arguments

  • int num - Coordinate vertex number.
  • int surface - Surface number.

Return value

Index number.

virtual int addLayer () const =0

Adds an animation layer.

Return value

Number of the added layer.

virtual void removeLayer (int num) const =0

Removes an animation layer.

Arguments

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

virtual void setNumLayers (int num) const =0

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 num - Number of animation layers (must be greater than 0).

virtual int getNumLayers () const =0

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

Return value

Number of animation layers.

virtual void setLayer (int layer) const =0

Sets the current animation layer. This method should be called when you want to change properties of some layer: set weight and animation.

Arguments

  • int layer - Layer number.

virtual int getLayer () const =0

Returns the current animation layer.

Return value

Current animation layer.

virtual void setWeight (float weight) const =0

Sets a weight for the current animation layer.

Arguments

  • float weight - Blending weight. Note that this weight may be more than 1, however, it is recommended to use values from the range [0; 1] only.

virtual float getWeight () const =0

Returns the current blending weight of the current animation layer.

Return value

Blending weight of the current animation layer.

virtual int addBuffer () const =0

Adds an animation buffer.

Return value

New buffer number.

virtual void removeBuffer (int num) const =0

Removes an animation buffer.

Arguments

  • int num - Buffer number in range from 0 to the total number of animation buffers.

virtual void setNumBuffers (int num) const =0

Allocates a given number of animation buffers.

Arguments

  • int num - Number of animation buffers to be allocated (must be greater than or equal to 0).

virtual int getNumBuffers () const =0

Returns the number of animation buffers.

Return value

Number of animation buffers.

virtual void setBuffer (int buffer, int layer) const =0

Applies bone transformations from a given buffer to a given layer. If layer number is equal to -1, then buffer is applied to the resulting animation.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.
  • int layer - Layer number in range from -1 to the total number of animation layers. -1 means render buffer.

virtual void getBuffer (int buffer, int layer) const =0

Gets bone transformations from a given layer to a given buffer. If layer number is equal to -1, then data is grabbed from the resulting animation.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.
  • int layer - Layer number in range from -1 to the total number of animation layers. -1 means render buffer.

virtual void clearBuffer (int buffer) const =0

Clears a given animation buffer.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.

virtual void copyBuffer (int buffer, int b) const =0

Copies transformations of bones from the source buffer to the destination one.
  • If the destination buffer has more bones than the source one, those bones will have old transformations.
  • If the source buffer has more bones than destination one, those bones will be added to the destination buffer.

Arguments

  • int buffer - Number of the destination buffer in range from 0 to the total number of animation buffers.
  • int b - Number of the source buffer in range from 0 to the total number of animation buffers.

virtual void inverseBuffer (int buffer, int b) const =0

Copies inverse transformations of bones from the source buffer to the destination one. Note that the destination buffer is not cleared before writing to it.

Arguments

  • int buffer - Number of the destination buffer in range from 0 to the total number of animation buffers.
  • int b - Number of the source buffer in range from 0 to the total number of animation buffers.

virtual void lerpBuffer (int buffer, int b0, int b1, float weight) const =0

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

Arguments

  • int buffer - Number of the destination buffer in range from 0 to the total number of animation buffers.
  • int b0 - Number of the first source buffer in range from 0 to the total number of animation buffers.
  • int b1 - Number of the second source buffer in range from 0 to the total number of animation buffers.
  • float weight - Interpolation weight.

virtual void mulBuffer (int buffer, int b0, int b1, float weight) const =0

Copies multiplied bone transformations from two source buffers to the destination buffer.

Arguments

  • int buffer - Number of the destination buffer in range from 0 to the total number of animation buffers.
  • int b0 - Source0 buffer.
  • int b1 - Source1 buffer.
  • float weight - interpolation weight.

virtual int setAnimation (const char * name) const =0

Loads the additional animation from an external file and sets it for the current layer.
  • When setting the animation for the first time, the function loads it from the external file and requires the full path to the file (absolute or relative to the data folder).
  • After loading once, it checks the list of loaded animations and if the name matches, uses the cached one. You can pass only the animation file name without the path when setting the previously loaded animation.

Arguments

  • const char * name - Path to the animation file (absolute or relative to the data folder).

Return value

Returns 1 if the animation is loaded successfully; otherwise, 0.

virtual const char * getAnimation () const =0

Returns the name of the animation used in the current layer.

Return value

Current animation name.

virtual void setAnimationID (int id) const =0

Sets the previously loaded animation by its animation identifier to the current animation layer. This function can be used only if the animation was set once. To get the animation identifier, use the getAnimationId() function.

Arguments

  • int id - Animation identifier in range from -1 to the total number of animations.

virtual int getAnimationID () const =0

Returns the identifier of the animation loaded for the current animation layer. This ID can be used when calling setAnimationID().

Return value

Animation identifier.

virtual int getNumAnimations () const =0

Returns the number of loaded animations.

Return value

Number of loaded animations.

virtual int getNumFrames () const =0

Returns the number of animation frames in the current layer.

Return value

Number of animation frames.

virtual void setFrame (float time, int from, int to) const =0

Sets a frame of the current animation layer.

Arguments

  • float time - Frame number in the
  • int from - Start frame. -1 means the first frame of animation.
  • int to - End frame. -1</> means the last frame of animation.

virtual float getFrameTime () const =0

Returns the frame number (time value passed to the last setFrame() call).

Return value

Frame number.

virtual int getFrameFrom () const =0

Returns the start frame passed to the last setFrame() call.

Return value

Start frame.

virtual int getFrameTo () const =0

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

Return value

End frame.

virtual void getFrame () const =0

Decomposes the current frame from previously set bone transformations.

virtual void clearFrame () const =0

Clears the frame of the current animation layer. This function clears animation transformations of all bones to the bind pose.

virtual int getNumBones () const =0

Returns the number of bones taking part in animation.

Return value

Number of bones.

virtual int findBone (const char * name) const =0

Searches for a bone with a given name.

Arguments

  • const char * name - Bone name.

Return value

Returns bone number if found; otherwise, -1.

virtual const char * getBoneName (int bone) const =0

Returns name of a given bone.

Arguments

  • int bone - Bone number.

Return value

Bone name.

virtual int getBoneParent (int bone) const =0

Returns the number of the parent bone.

Arguments

  • int bone - Bone number.

Return value

Parent bone number.

virtual int getNumBoneChilds (int bone) const =0

Returns the number of child bones.

Arguments

  • int bone - Bone number.

Return value

Number of child bones.

virtual int getBoneChild (int bone, int child) const =0

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.

virtual void setBoneTransform (int bone, const mat4 & transform) const =0

Sets a transformation matrix for a given bone. Notice that a bone can be scaled only uniformly.

Arguments

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

virtual mat4 getBoneTransform (int bone) const =0

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

Arguments

  • int bone - Bone number.

Return value

Transformation matrix.

virtual mat4 getOffsetTransform (int bone) const =0

Returns an offset transformation matrix.

Arguments

  • int bone - Bone number.

Return value

Offset transformation matrix.

virtual void setWorldBoneTransform (int bone, const UNIGINE_MAT4 & transform) const =0

Applies transformation to a given bone in the world space coordinates. Notice that a bone can be scaled only uniformly.

Arguments

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

virtual UNIGINE_MAT4 getWorldBoneTransform (int bone) const =0

Returns the current transformation matrix applied to the bone in the world space coordinate.

Arguments

  • int bone - Bone number.

Return value

World transformation matrix in the world space.

virtual void setFrameBoneTransformEnabled (int bone, int enable) const =0

Sets a frame transformation enabled flag for a given bone.

Arguments

  • int bone - Bone number.
  • int enable - Enabled flag.

virtual void setFrameBoneTransform (int bone, const mat4 & transform) const =0

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 current animation layer (no blending is done). Take notice that a bone can be scaled only uniformly.

Arguments

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

virtual mat4 getFrameBoneTransform (int bone) const =0

eturns 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 current animation layer (no blending is done).

Arguments

  • int bone - Bone number.

Return value

Transformation matrix.

virtual int isFrameBoneTransform (int bone) const =0

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

Arguments

  • int bone - Bone number.

Return value

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

virtual void setBufferBoneTransformEnabled (int buffer, int bone, int enable) const =0

Sets a buffer transformation enabled flag for a given bone.

Arguments

  • int buffer - Buffer number.
  • int bone - Bone number.
  • int enable - Enabled flag.

virtual void setBufferBoneTransform (int buffer, int bone, const mat4 & transform) const =0

Sets a transformation matrix for a given bone from the given animation buffer.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.
  • int bone - Bone number.
  • const mat4 & transform - Transformation matrix.

virtual mat4 getBufferBoneTransform (int buffer, int bone) const =0

Returns a transformation matrix of a given bone from the given animation buffer.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.
  • int bone - Bone number.

Return value

Transformation matrix.

virtual int isBufferBoneTransform (int buffer, int bone) const =0

Returns a value indicating if the bone transformation is applied only to a given bone from the specified animation buffer.

Arguments

  • int buffer - Buffer number in range from 0 to the total number of animation buffers.
  • int bone - Bone number.

Return value

Bone transformation flag: 1 if the bone has been transformed; otherwise, 0.
Last update: 2017-07-03
Build: ()