Unigine::Mesh Class
Header: | #include <UnigineMesh.h> |
Mesh class is a container and provides an interface for mesh loading, manipulating and saving.
By using this class, you can create a mesh, add geometry to it (e.g. box, plane, capsule or cylinder surface), add animations and bones (if you want to create a skinned mesh) and then use it to create the following objects:
Also you can get geometry of all of these objects via the Mesh class.
Features of the mesh are listed below:
- Each surface of the mesh supports several morph targets.
- Each surface has a quaternion-based tangent basis for the better loading speed.
- 8-bit vertex colors are supported.
- Each vertex of a surface has 2 sets of indices: coordinate and triangle indices. It improves the loading speed and reduces data duplication.
- Each vertex of a surface has 2 UV sets.
- A bind pose transformation is stored for each mesh (even if there are no animations and animation frames). See also the getBoneTransfroms() method.
The 1st animation frame should not contain the bind pose.
Vertex Data and Indices
Each surface of the mesh consists of triangles, and each triangle has 3 vertices. Thus, for each mesh surface we have:
Total number of vertices = 3 * number of triangles.
If a vertex belongs to several triangles, we have to store several copies of such vertex. Each of these copies would store information about position, normal, binormal, tangent and texture coordinates. In order to reduce data duplication and increase loading speed UNIGINE uses the optimization described below.
There are 2 separate vertex data buffers are used:
- CVertices coordinate buffer, which stores only vertex coordinates.
- TVertices triangle buffer, which stores vertex attributes such as normal, binormal, tangent, color, UV coordinates.
On the picture below, arrows are used to show normals:
The coordinate buffer is an array of coordinate vertices. For example, the coordinate buffer for the surface presented on the picture above is the following:
CB = [C0,C1,C2,C3]
The triangle buffer is an array of triangle vertices. For example, the triangle buffer for the surface presented on the picture above is the following:
TB = [T0,T1,T2,T3,T4,T5]
- Normal
- Binormal
- Tangent
- 1st UV map texture coordinates
- 2nd UV map texture coordinates
- Color
Both the coordinate and triangle vertices have indices. There are 2 index buffers to get proper cvertex and tvertex data for each vertex of mesh surface:
- CIndices buffer — coordinate indices, which are links to CVertices data.
- TIndices buffer — triangle indices, which are links to TVertices data.
Coordinate Indices
Each vertex of a mesh surface has a coordinate index - a number of the corresponding element of the coordinate buffer, where the data is stored. For the given surface the array of the coordinate indices is as follows:
CIndices = [Ci0,Ci1,Ci3,Ci1,Ci2,Ci3]
- The first 3 elements are the coordinate indices of the first (bottom) triangle.
- The second 3 elements are the coordinate indices of the second (top) triangle.
Triangle Indices
Each vertex of a mesh surface also has a triangle index - a number of the corresponding element of the triangle buffer, where the data is stored. For the given surface the array of the triangle indices is as follows:
TIndices = [Ti0,Ti1,Ti5,Ti2,Ti3,Ti4]
- The first 3 elements are the triangle indices of the first (bottom) triangle.
- The second 3 elements are the triangle indices of the second (top) triangle.
See Also
- Article on Mesh File Formats
- Mesh Class Usage Example
Mesh Class
Members
static MeshPtr create()
Constructor. Creates an empty mesh.static MeshPtr create(const char * name)
Constructor. Creates a mesh with the specified name.Arguments
- const char * name - Mesh name.
static MeshPtr create(const Ptr<Mesh> & mesh)
Constructor.Arguments
- const Ptr<Mesh> & mesh - Mesh instance.
void setAnimationBones(int animation, const Vector< short > & bones)
Copies bones from the given array to the current array of animation bones.Arguments
- int animation - Animation number.
- const Vector< short > & bones - Array of bones taking part in the animation to be set.
void getAnimationBones(int animation, Vector< short > & bones)
Adds all bones of the given animation to the given array of bones.Arguments
- int animation - Animation number.
- Vector< short > & bones - Array with indices of bones taking part in the animation.
void setAnimationFrame(int animation, int num, const Vector< Math::vec3 > & xyz, const Vector< Math::quat > & rot, const Vector< Math::vec3 > & scale)
Updates the animation frame coordinates, rotation quaternions and scaling vectors.Arguments
- int animation - Animation number.
- int num - Frame number in the array of the animation frames.
- const Vector< Math::vec3 > & xyz - Array with coordinates of the animation frame.
- const Vector< Math::quat > & rot - Array with rotation quaternions of the animation frame.
- const Vector< Math::vec3 > & scale - Array with scaling vectors of the animation frame.
void setAnimationFrame(int animation, int num, const Vector< Math::mat4 > & frames)
Updates the animation frame coordinates, rotation quaternions and scaling vectors.Arguments
- int animation - Animation number.
- int num - Frame number in the array of the animation frames.
- const Vector< Math::mat4 > & frames - Matrix that includes coordinates, rotation quaternions and scaling vectors of the animation frame.
void getAnimationFrame(int animation, int num, Vector< Math::vec3 > & xyz, Vector< Math::quat > & rot, Vector< Math::vec3 > & scale)
Adds the animation frame coordinates, rotation quaternions and scaling vectors to the given matrix passed to the function as the third argument. The matrix can be set by using the setAnimationFrame() method.Arguments
- int animation - Animation number.
- int num - Frame number in the array of the animation frames.
- Vector< Math::vec3 > & xyz - Array with coordinates of the animation frame.
- Vector< Math::quat > & rot - Array with rotation quaternions of the animation frame.
- Vector< Math::vec3 > & scale - Array with scaling vectors of the animation frame.
void getAnimationFrame(int animation, int num, Vector< Math::mat4 > & frames)
Adds the animation frame coordinates, rotation quaternions and scaling vectors to the given matrix passed to the function as the third argument. The matrix can be set by using the setAnimationFrame() method.Arguments
- int animation - Animation number.
- int num - Frame number in the array of the animation frames.
- Vector< Math::mat4 > & frames - Matrix that includes coordinates, rotation quaternions and scaling vectors of the animation frame.
void setAnimationName(int animation, const char * name)
Sets a name for the given animation.Arguments
- int animation - Animation number.
- const char * name - Animation name to be set.
const char * getAnimationName(int animation)
Returns the name of the given animation.Arguments
- int animation - Animation number.
Return value
Animation name.void setBoneName(int bone, const char * name)
Sets a name for the given bone.Arguments
- int bone - Bone number.
- const char * name - Bone name to be set.
const char * getBoneName(int bone)
Returns the name of the given bone.Arguments
- int bone - Bone number.
Return value
Bone name.void setBoneParent(int bone, int parent)
Sets the parent bone for the given one.Arguments
- int bone - Bone number, for which the parent bone should be set.
- int parent - Bone to be set as a parent.
int getBoneParent(int bone)
Returns the number of the parent bone of the given one.Arguments
- int bone - Bone number, for which the parent bone will be returned.
Return value
Parent bone number.void setBoneTransform(int bone, const Math::mat4 & transform)
Sets the transformation matrix for the given bone.Arguments
- int bone - Bone number.
- const Math::mat4 & transform - Transformation matrix to be set.
Math::mat4 getBoneTransform(int bone)
Returns the transformation matrix for the given bone.Arguments
- int bone - Bone number.
Return value
Transformation matrix.int setBoneTransforms(const Vector< Math::mat4 > & transforms, int animation = -1, int frame = 0)
Updates the array of the world-space transformation matrices for bones of the given animation frame.Arguments
- const Vector< Math::mat4 > & transforms - Array of transformation matrices to be set. Its size must be equal to the number of animation bones.
- int animation - Animation number. The default value is -1.
- int frame - Animation frame number. The default value is 0.
Return value
Returns 1 if the array of bones' transformations is updated successfully; otherwise, 0.int getBoneTransforms(Vector< Math::mat4 > & transforms, int animation = -1, int frame = 0)
Appends the world-space transformation matrices for bones of the given animation frame to the given array.Arguments
- Vector< Math::mat4 > & transforms - Array of transformation matrices.
- int animation - Animation number. The default value is -1.
- int frame - Animation frame number. The default value is 0.
Return value
Returns 1 if the array of bones' transformations is filled successfully; otherwise, 0.void setBoundBox(const BoundBox & bb, int surface)
Sets the bounding box for the given mesh surface.Arguments
- const BoundBox & bb - Bounding box to be set.
- int surface - Mesh surface number.
void setBoundBox(const BoundBox & bb)
Sets the bounding box for the given mesh surface.Arguments
- const BoundBox & bb - Bounding box to be set.
BoundBox getBoundBox(int surface)
Returns the bounding box of the given mesh surface.Arguments
- int surface - Mesh surface number.
Return value
Bounding box.BoundBox getBoundBox()
Returns the bounding box of the given mesh surface.Return value
Bounding box.void setBoundSphere(const BoundSphere & bs)
Sets the bounding sphere for the given mesh surface.Arguments
- const BoundSphere & bs - Bounding sphere to be set.
void setBoundSphere(const BoundSphere & bs, int surface)
Sets the bounding sphere for the given mesh surface.Arguments
- const BoundSphere & bs - Bounding sphere to be set.
- int surface - Mesh surface number.
BoundSphere getBoundSphere()
Returns the bounding sphere of the given surface.Return value
Bounding sphere.BoundSphere getBoundSphere(int surface)
Returns the bounding sphere of the given mesh surface.Arguments
- int surface - Mesh surface number.
Return value
Bounding sphere.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.
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. 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)
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.
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.
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)
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.
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 setIndex(int num, int index, int surface)
Sets both coordinate and triangle indices for the given vertex of the given surface equal to the specified index.Arguments
- int num - Vertex number in the range from 0 to the total number of coordinate indices of the given surface.
To get the total number of coordinate indices for the surface, use the getNumCIndices() method.
- int index - Index to be set in the range from 0 to the total number of coordinate vertices.
To get the total number of coordinate vertices, use the getNumVertex() method.
- int surface - Mesh surface number.
int getIndex(int num, int surface)
Returns the coordinate index of the given vertex of the given surface if the coordinate index is equal to the triangle index.Arguments
- int num - Vertex number in the range from 0 to the total number of coordinate indices of the given surface.
To get the total number of coordinate indices for the surface, use the getNumCIndices() method.
- int surface - Mesh surface number.
Return value
Coordinate index.int getIntersection(const Math::vec3 & p0, const Math::vec3 & p1, Math::vec3 * ret_point, Math::vec3 * ret_normal, int * ret_index, int surface, int target = 0)
Performs the search for the intersection of the given surface target with the given traced line.Arguments
- const Math::vec3 & p0 - Start point coordinates.
- const Math::vec3 & p1 - End point coordinates.
- Math::vec3 * ret_point - Return array to write the intersection point coordinates into.
- Math::vec3 * ret_normal - Return array to write the intersection point normal into.
- int * ret_index - Return array to write the intersection point indices into.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Return value
1 if the intersection is found; otherwise, 0.void * getMesh()
void setNormal(int num, const Math::vec3 & normal, int surface, int target = 0)
Sets 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 normal entries of the given surface target.
To get the total number of vertex normal entries for the surface target, call the getNumNormals() method.
- const Math::vec3 & normal - Normal to be set.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Math::vec3 getNormal(int num, int surface, int target = 0)
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 normal entries of the given surface target.
To get the total number of vertex normal entries for the surface target, call the getNumNormals() method.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Return value
Vertex normal.void setNumAnimationFrames(int animation, int num)
Sets the number of animation frames for the given animation.Arguments
- int animation - Animation number in the range from 0 to the total number of mesh animations.
To get the total number of mesh animations, call the getNumAnimations() method.
- int num - Number of the animation frames to be set.
int getNumAnimationFrames(int animation)
Returns the number of animation frames for the given animation.Arguments
- int animation - Animation number in the range from 0 to the total number of mesh animations.
To get the total number of mesh animations, call the getNumAnimations() method.
Return value
Number of the animation frames.int getNumAnimations()
Returns the total number of mesh animations.Return value
Number of the mesh animations.int getNumBones()
Returns the total number of mesh bones.Return value
Number of the mesh bones.void setNumCIndices(int size, int surface)
Sets the total number of coordinate indices for the given surface.Arguments
- int size - Number of the coordinate indices to be set.
- int surface - Mesh surface number.
int getNumCIndices(int surface)
Returns the total number of coordinate indices for the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of coordinate indices.void setNumColors(int size, int surface)
Sets the total number of vertex color entries for the given surface.Arguments
- int size - Number of vertex color entries to be set.
- int surface - Mesh surface number.
int getNumColors(int surface)
Returns the total number of vertex color entries for the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of vertex color entries.int getNumCVertex(int surface)
Returns the number of coordinate vertices of the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of coordinate vertices.void setNumIndices(int size, int surface)
Sets the number of indices for the given surface: updates the number of coordinate and triangle indices. For example, if you pass 5 as the first argument, the number of the coordinate indices and the number of triangle indices will be set to 5.Arguments
- int size - Number of indices to be set.
- int surface - Mesh surface number.
int getNumIndices(int surface)
Returns the number of coordinate indices of the given surface if the number of the coordinate indices is equal to the number of triangle indices.Arguments
- int surface - Mesh surface number.
Return value
Number of coordinate indices.void setNumNormals(int size, int surface, int target = 0)
Sets the total number of vertex normal entries for the given surface target.Arguments
- int size - Number of vertex normal entries to be set.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
int getNumNormals(int surface, int target = 0)
Returns the total number of vertex normal entries for the given surface target.Arguments
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Return value
Number of vertex normal entries.int getNumSurfaces()
Returns the total number of mesh surfaces.Return value
Number of mesh surfaces.void setNumSurfaceTargets(int surface, int num)
Sets the number of targets for the given mesh surface.Arguments
- int surface - Mesh surface number.
- int num - Number of surface targets to be set.
int getNumSurfaceTargets(int surface)
Returns the number of surface targets for the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of surface targets.void setNumTangents(int size, int surface, int target = 0)
Sets the total number of vertex tangent entries for the given surface target.Arguments
- int size - Number of vertex tangent entries to be set.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
int getNumTangents(int surface, int target = 0)
Returns the total number of vertex tangent entries for the given surface target.Arguments
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Return value
Number of vertex tangent entries.void setNumTexCoords0(int size, int surface)
Sets the total number of the first UV map texture coordinate entries for the given mesh surface.Arguments
- int size - Number of the first UV map texture coordinate entries to be set.
- int surface - Mesh surface number.
int getNumTexCoords0(int surface)
Returns the total number of the first UV map texture coordinate entries for the given mesh surface.Arguments
- int surface - Mesh surface number.
Return value
Total number of the first UV map texture coordinate entries.void setNumTexCoords1(int size, int surface)
Sets the total number of the second UV map texture coordinate entries for the given mesh surface.Arguments
- int size - Number of the second UV map texture coordinates to be set.
- int surface - Mesh surface number.
int getNumTexCoords1(int surface)
Returns the total number of the second UV map texture coordinate entries for the given mesh surface.Arguments
- int surface - Mesh surface number.
Return value
Total number of the second UV map texture coordinate entries.void setNumTIndices(int size, int surface)
Sets the total number of triangle indices for the given surface.Arguments
- int size - Number of triangle indices to be set.
- int surface - Mesh surface number.
int getNumTIndices(int surface)
Returns the total number of triangle indices for the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of triangle indices.int getNumTVertex(int surface)
Returns the number of triangle vertices for the given mesh surface.Arguments
- int surface - Mesh surface number.
Return value
Number of the triangle vertices.void setNumVertex(int size, int surface, int target = 0)
Sets the total number of vertices for the given surface target.Arguments
- int size - Number of the vertices to be set.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
int getNumVertex(int surface, int target = 0)
Returns the total number of vertices for the given surface target.Arguments
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
Return value
Number of the vertices.void setNumWeights(int size, int surface)
Sets the number of weights set for vertices of the given surface.Arguments
- int size - Number of weights to be set.
- int surface - Mesh surface number.
int getNumWeights(int surface)
Returns the number of weights set for vertices of the given surface.Arguments
- int surface - Mesh surface number.
Return value
Number of the weights.int isOwner()
Returns the owner flag. If the pointer is the owner, on its deletion the mesh also will be deleted. Use grab() and release() functions to change ownershipReturn value
Owner flag.void setSurfaceName(int surface, const char * name)
Sets the name for the given mesh surface.Arguments
- int surface - Mesh surface number.
- const char * name - Surface name to be set.
const char * getSurfaceName(int surface)
Returns the name of the given surface.Arguments
- int surface - Mesh surface number.
Return value
Surface name.void setSurfaceTargetName(int surface, int target, const char * name)
Sets the name for the given surface target.Arguments
- int surface - Mesh surface number.
- int target - Surface target number.
- const char * name - Surface target name to be set.
const char * getSurfaceTargetName(int surface, int target)
Returns the name of the given surface target.Arguments
- int surface - Mesh surface number.
- int target - Surface target number.
Return value
Surface target name.int setSurfaceTransform(const Math::mat4 & transform, int surface = -1, int target = -1)
Sets the transformation matrix for the given surface target.Arguments
- const Math::mat4 & transform - Transformation matrix to be set.
- int surface - Mesh surface number. The default value is -1 (apply to all of the mesh surfaces).
If all surfaces are chosen, the transformations of bones and animations will also be recalculated.
- int target - Surface target number. The default value is -1 (apply to all of the surface targets).
Return value
1 if the transformation matrix is set successfully; otherwise, 0.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 target.
To get the total number of vertex tangent entries for the surface target, 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)
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 target.
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 tangent.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.
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)
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.
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.
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)
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.
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 setTIndex(int num, int index, int surface)
Sets the new triangle index for the given vertex of the given surfaceArguments
- int num - Vertex number in the range from 0 to the total number of triangle indices for the given surface.
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.
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)
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.
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.
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)
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.
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 setWeightBones(int num, const Math::ivec4 & bones, int surface)
Sets the vector of bone indices that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- const Math::ivec4 & bones - Vector of the bone indices to be set.
- int surface - Mesh surface number.
Math::ivec4 getWeightBones(int num, int surface)
Returns a vector of bone indices that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- int surface - Mesh surface number.
Return value
Vector of the bone indices associated with the given weight.void setWeightCount(int num, int count, int surface)
Sets the number of weights that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- int count - Number of weights to be set.
- int surface - Mesh surface number.
int getWeightCount(int num, int surface)
Returns the number of weights that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- int surface - Mesh surface number.
Return value
Number of weights.void setWeightWeights(int num, const Math::vec4 & weights, int surface)
Sets the vector of bone weights that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- const Math::vec4 & weights - Vector of bone weights to be set.
- int surface - Mesh surface number.
Math::vec4 getWeightWeights(int num, int surface)
Returns a vector of bone weights that affect the vertex with the given weight.- The 4 bone indices (see setWeightBones() / getWeightBones() methods);
- The 4 bone weights (see setWeightWeights() / getWeightWeights() methods);
- Number of weights (see setWeightCount() / getWeightCount() methods).
Arguments
- int num - Coordinate vertex number in the range from 0 to the total number of vertex weight entries for the given surface.
To get the total number of of vertex weight entries for the given surface, use the getNumWeights() method.
- int surface - Mesh surface number.
Return value
Bone weights associated with the given weight.int addAnimation(const char * name = 0)
Appends an animation with a given name to the current mesh.Arguments
- const char * name - Name of the animation. This argument is empty by default.
Return value
Number of mesh animations.int addBone(const char * name = 0, int parent = -1)
Appends a new mesh bone.Arguments
- const char * name - Bone name. This argument is empty by default.
- int parent - Parent bone number. The default value is -1 (the new bone has no parent bone).
Return value
Number of mesh bones.int addBoxSurface(const char * name, const Math::vec3 & size)
Appends a box surface to the current mesh.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add box surface with the name "box_surface" and the size of the surface is Vec3(1.0, 1.0, 1.0)
mesh->addBoxSurface("box_surface", Math::Vec3(1.0f));
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
Editor *editor = Editor::get();
dynamicMesh->release();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- const Math::vec3 & size - Box size along the X, Y and Z axes.
Return value
Added surface number.int addCapsuleSurface(const char * name, float radius, float height, int stacks, int slices)
Appends a capsule surface to the current mesh. The stacks and slices specify the surface's subdivision.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add capsule surface with the name "capsule_surface".
// the radius of the capsule is 1.0, the height is 2.0,
// stacks and slices are equals to 200 and 100, respectively
mesh->addCapsuleSurface("box_surface", 1.0f, 2.0f, 200, 100);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float radius - Capsule radius.
- float height - Capsule height.
- int stacks - Number of stacks that divide the capsule radially.
- int slices - Number of slices that divide the capsule horizontally.
Return value
The added surface number.void addCIndex(int index, int surface)
Appends a new Coordinate index the array of coordinate indices for the given surface.Arguments
- int index - Coordinate index to be added in the range from 0 to the total number of coordinate vertices.
To get the total number of coordinate vertices for the given surface, use the getNumCVertex() method.
- int surface - Mesh surface number.
void addColor(const Math::vec4 & color, int surface)
Appends the given color to the vertex color array of the given surface.Arguments
- const Math::vec4 & color - Color to be added.
- int surface - Mesh surface number.
int addCylinderSurface(const char * name, float radius, float height, int stacks, int slices)
Appends a cylinder surface to the current mesh. The stacks and slices specify the surface's subdivision.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add cylinder surface with the name "cylinder_surface".
// the radius of the cylinder is 1.0, the height is 2.0,
// stacks and slices are equals to 200 and 100, respectively
mesh->addCylinderSurface("cylinder_surface", 1.0f, 2.0f, 200, 100);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float radius - Cylinder radius.
- float height - Cylinder height.
- int stacks - Number of stacks that divide the cylinder radially.
- int slices - Number of slices that divide the cylinder horizontally.
Return value
The added surface number.int addDodecahedronSurface(const char * name, float radius)
Appends a dodecahedron surface to the current mesh.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add dodecahedron surface with the name "dodecahedron_surface".
// the radius of the dodecahedron is 1.0
mesh->addDodecahedronSurface("dodecahedron_surface", 1.0f);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float radius - Dodecahedron radius.
Return value
The added surface number.int addEmptySurface(const char * name, int num_vertex, int num_indices)
Appends a new empty surface to the current mesh.Arguments
- const char * name - Surface name.
- int num_vertex - Number of surface vertices.
- int num_indices - Number of surface indices.
Return value
Number of the mesh surfaces.int addIcosahedronSurface(const char * name, float radius)
Appends a icosahedron surface to the current mesh.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add icosahedron surface with the name "icosahedron_surface".
// the radius of the icosahedron is 1.0
mesh->addIcosahedronSurface("icosahedron_surface", 1.0f);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float radius - Icosahedron radius.
Return value
Added surface number.void addIndex(int index, int surface)
Appends a given index to the arrays of coordinate and triangle indices for the given surface.Arguments
- int index - Index to be added in the range from 0 to the total number of coordinate vertices for the surface.
To get the total number of coordinate vertices for the surface, use the getNumCVertex() method.
- int surface - Mesh surface number.
int addMeshSurface(const char * v, const Ptr<Mesh> & mesh, int surface, int target = -1)
Appends a surface of the source mesh to the current mesh as a new surface.The following example shows how to add a surface from the one mesh to another.
// create mesh instances
MeshPtr mesh_1 = Mesh::create();
MeshPtr mesh_2 = Mesh::create();
// add Surfaces for the added meshes
mesh_1->addCapsuleSurface("capsule_surface", 1.0f, 2.0f, 200, 100);
mesh_2->addBoxSurface("box_surface", Math::vec3(2.2));
// add the surface from the mesh_2 to the mesh_1 as a new surface
// with the name "new_box_surface"
mesh_1->addMeshSurface("new_box_surface", mesh_2, 0);
// create the ObjectMeshDynamic from the mesh_1 object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh_1);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * v - Name of the new surface added to 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 the target of the source mesh surface. The default value is -1 (all of the surface targets).
Return value
Number of the mesh surfaces.int addMeshSurface(int v, const Ptr<Mesh> & mesh, int surface, int target = -1)
Appends a surface of the source mesh to the existing surface of the current mesh.The following example shows how to add a surface from the one mesh to another.
// create mesh instances
MeshPtr mesh_1 = Mesh::create();
MeshPtr mesh_2 = Mesh::create();
// add Surfaces for the added meshes
mesh_1->addCapsuleSurface("capsule_surface", 1.0f, 2.0f, 200, 100);
mesh_2->addBoxSurface("box_surface", Math::vec3(2.2));
// add the surface from the mesh_2 to the mesh_1 as a new surface
// with the name "new_box_surface"
mesh_1->addMeshSurface(0, mesh_2, 0);
// create the ObjectMeshDynamic from the mesh_1 object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh_1);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh>setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh>setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh>setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh>setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- int v - Number of the existing surface of the current mesh, to which the geometry is added.
- 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 the target of the source mesh surface. The default value is -1 (all of the surface targets).
Return value
Number of mesh surfaces.void addNormal(const Math::vec3 & normal, int surface, int target = 0)
Appends a given normal to the array of normals of the given surface target.Arguments
- const Math::vec3 & normal - Normal to be added.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
int addPlaneSurface(const char * name, float width, float height, float step)
Appends a plane surface to the current mesh. The plane is divided into equal squares whose size is defined by the given step.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add the plane surface with the name "plane_surface".
// the width is 2 and the height is 3
mesh->addPlaneSurface("plane_surface", 2.0f, 3.0f, 1.0f);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear. You could see that the plane divided each 1 unit to equal squares.
Arguments
- const char * name - Surface name.
- float width - Plane width.
- float height - Plane height.
- float step - Step of surface subdivision (vertical and horizontal).
Return value
Added surface number.int addPrismSurface(const char * name, float size_0, float size_1, float height, int sides)
Appends a prism surface to the current mesh.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add the prism surface with the name "prism_surface".
// the radius of the top is 1.0f, of the bottom is 2.0f
// the height of the prism is 3.0f, and it has 4 sides
mesh->addPrismSurface("prism_surface", 1.0f, 2.0f, 3.0f, 4);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float size_0 - Radius of the circle circumscribed about the top prism base.
- float size_1 - Radius of the circle circumscribed about the bottom prism base.
- float height - Height of the prism.
- int sides - Number of the prism faces.
Return value
The added surface number.int addSphereSurface(const char * name, float radius, int stacks, int slices)
Appends a sphere surface to the current mesh. The stacks and slices specify the surface's subdivision.// create a mesh instance
MeshPtr mesh = Mesh::create();
// add the sphere surface with the name "sphere_surface".
// the radius of the sphere is 1.0f
// and it has 200 stacks and 100 slices
mesh->addSphereSurface("sphere_surface", 1.0f, 200, 100);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("Dynamic Mesh");
After adding to the editor, the mesh will appear.
Arguments
- const char * name - Surface name.
- float radius - Sphere radius.
- int stacks - Number of stacks that divide the sphere radially.
- int slices - Number of slices that divide the sphere horizontally.
Return value
Added surface number.int addSurface(const char * name = 0)
Append a new surface with the given name to the current mesh.In the following example, we create a new surface and add vertices and indices to create a plane.
// create a mesh instance
MeshPtr mesh = Mesh::create();
// add a new surface
mesh->addSurface("surface_0");
// add vertices of the plane
mesh->addVertex(Math::vec3(0.0f,0.0f,0.0f),0);
mesh->addVertex(Math::vec3(0.0f,0.0f,1.0f),0);
mesh->addVertex(Math::vec3(0.0f,1.0f,0.0f),0);
mesh->addVertex(Math::vec3(0.0f,1.0f,1.0f),0);
// add indices
mesh->addIndex(0,0);
mesh->addIndex(1,0);
mesh->addIndex(2,0);
mesh->addIndex(3,0);
mesh->addIndex(2,0);
mesh->addIndex(1,0);
// create tangents
mesh->createTangents();
// create mesh bounds
mesh->createBounds(0);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("new_mesh");
Arguments
- const char * name - Surface name. This argument is empty by default.
Return value
Number of mesh surfaces.int addSurfaceTarget(int surface, const char * name = 0)
Appends a target with the given name to the given surface.Arguments
- int surface - Mesh surface number.
- const char * name - Name of the surface target. This argument is empty by default.
Return value
Number of surface targets.void addTangent(const Math::quat & tangent, int surface, int target = 0)
Appends the given tangent to the array of tangents of the specified surface target.Arguments
- const Math::quat & tangent - Tangent to be added.
- int surface - Surface number.
- int target - Surface target number. The default value is 0.
void addTexCoord0(const Math::vec2 & texcoord, int surface)
Appends texture coordinates to the array of the first UV map coordinates of the given mesh surface.Arguments
- const Math::vec2 & texcoord - Coordinates of the first UV map to be added.
- int surface - Mesh surface number.
void addTexCoord1(const Math::vec2 & texcoord, int surface)
Appends texture coordinates to the array of the second UV map coordinates of the given mesh surface.Arguments
- const Math::vec2 & texcoord - Coordinates of the second UV map to be added.
- int surface - Mesh surface number.
void addTIndex(int index, int surface)
Appends an index of a triangle vertex to the array of triangle indices for the given surface.Arguments
- int index - Index number of the vertex in the triangle buffer in the range from 0 to the total number of triangle vertices. To get the total number of triangle vertices for the given surface, use the getNumTVertex() method.
- int surface - Number of the surface to which the triangle index is added.
void addVertex(const Math::vec3 & vertex, int surface, int target = 0)
Appends a new coordinate vertex with the given coordinates to the mesh surface.In the following example, we create a new surface and add 4 vertices to it. We use local coordinates to define a vertex and specify the surface. After that we specify 6 indices to create a plane by using defined vertices.
// create a mesh instance
MeshPtr mesh = Mesh::create();
// add a new surface
mesh->addSurface("surface_0");
// add vertices of the plane
mesh->addVertex(Math::vec3(0.0f,0.0f,0.0f),0);
mesh->addVertex(Math::vec3(0.0f,0.0f,1.0f),0);
mesh->addVertex(Math::vec3(0.0f,1.0f,0.0f),0);
mesh->addVertex(Math::vec3(0.0f,1.0f,1.0f),0);
// add indices
mesh->addIndex(0,0);
mesh->addIndex(1,0);
mesh->addIndex(2,0);
mesh->addIndex(3,0);
mesh->addIndex(2,0);
mesh->addIndex(1,0);
// create tangents
mesh->createTangents();
// create mesh bounds
mesh->createBounds(0);
// create the ObjectMeshDynamic from the Mesh object
ObjectMeshDynamicPtr dynamicMesh = ObjectMeshDynamic::create(mesh);
// add dynamicMesh to the editor as a Node object
dynamicMesh->release();
Editor *editor = Editor::get();
editor->addNode(dynamicMesh->getNode());
// set the position of the mesh
dynamicMesh->setWorldTransform(translate(Math::Vec3(10.0f,10.0f,10.0f)));
// set the material to the mesh
dynamicMesh->setMaterial("mesh_base","*");
// set the property to the mesh
dynamicMesh->setProperty("surface_base","*");
// set the name of the mesh
dynamicMesh->setName("new_mesh");
Arguments
- const Math::vec3 & vertex - Coordinates of the vertex to be added.
- int surface - Mesh surface number.
- int target - Surface target number. The default value is 0.
void clear()
Clears the mesh (including its bones, animation, surfaces and bounds).int createBounds(int surface = -1)
Creates bounds (a bounding box and a bounding sphere) for the given surface. If the default value is used as an argument, the bounds will be created for all of the mesh surfaces.Arguments
- int surface - Mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
1 if bounds are created successfully; otherwise, 0.int createIndices(int surface = -1)
Creates indices for the given surface. If the default value is used as an argument, the indices will be created for all of the mesh surfaces.Arguments
- int surface - Mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
1 if indices are created successfully; otherwise, 0.int createIntersection(int surface = -1)
Calculates a potentially visible set for the given surface. This function prepares the mesh for working with getIntersection() method.Arguments
- int surface - Mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
1 if the potentially visible set is calculated successfully; otherwise, 0.int createNormals(int surface = -1, int target = -1)
Creates normals for the given surface target.Arguments
- int surface - Mesh surface number. The default value is -1 (all of the mesh surfaces).
- int target - Surface target number. The default value is -1 (all of the surface targets).
Return value
1 if the normals are created successfully; otherwise, 0.int createNormals(float angle, int surface = -1, int target = -1)
Creates normals for the given surface target.Arguments
- float angle - Angle between normals used to calculate the mean vertex normal.
- int surface - Mesh surface number. -1 means all of the mesh surfaces.
- int target - Surface target number. -1 means all of the surface targets.
Return value
1 if the normals are created successfully; otherwise, 0.int createTangents(int surface = -1, int target = -1)
Creates tangents for the given surface target.Arguments
- int surface - Mesh surface number. -1 means all of the mesh surfaces.
- int target - Surface target number. -1 means all of the surface targets.
Return value
1 if the tangents are created successfully; otherwise, 0.int createTangents(float angle, const Vector< int > & surfaces)
Creates tangents for all of the surfaces in the list.Arguments
- float angle - Angle between normals used to calculate the mean vertex normal.
- const Vector< int > & surfaces - List of surface numbers, for which tangents are to be created.
Return value
1 if the tangents are created successfully; otherwise, 0.int findAnimation(const char * name)
Searches for the animation by the name and returns its number.Arguments
- const char * name - Name of the animation.
Return value
int findBone(const char * name)
Searches for a bone with a given name and returns its number.Arguments
- const char * name - Name of the bone.
Return value
Bone number.int findSurface(const char * name)
Searches for the surface number by its name.Arguments
- const char * name - Mesh surface name.
Return value
Mesh surface number, if it is found; otherwise, -1.int findSurfaceTarget(int surface, const char * name)
Searches for the surface target number by the morph target name.Arguments
- int surface - Mesh surface number.
- const char * name
Return value
Target number, if exists; otherwise, -1.int flipTangent(int surface = -1)
Flips the sign of the binormal component of the surface tangent space.Arguments
- int surface - Mesh surface number.
Return value
1 if the sign of the binormal component is flipped successfully; otherwise, 0.int flipYZ(int surface = -1)
Flips the Y and Z axes for the given surface:- Y axis becomes equal to -Z
- Z axis becomes equal to Y
Arguments
- int surface - Mesh surface number.
Return value
1 if the axes are flipped successfully; otherwise, 0.void grab()
Sets the owner flag to 1 for the Mesh pointer.int info(const char * name)
Returns an information about the given mesh or animation.Arguments
- const char * name - Mesh or animation name.
Return value
int load(const char * name)
Loads the mesh with the given name for the current mesh.Arguments
- const char * name - Mesh name.
Return value
1 if the mesh is loaded successfully; otherwise, 0.int optimizeIndices(int flags, int surface = -1)
Optimizes indices of the given mesh surface. As polygons are added to a surface, vertices of the adjacent polygons are duplicated (you can get the number of such the vertices by using the getNumTVertex()), because normals, texture coordinates and tangents of such the vertices differ depending on the polygons, to which this vertices belongs. The optimizeIndices() function serves to decrease the number of such vertices and create indices for them that will be stored in the corresponding normals, tangents and texture coordinates.Arguments
- int flags - One of the flags used for indices' optimization: MESH_BACK_TO_FRONT or MESH_VERTEX_CACHE.
- int surface - Mesh surface number.
Return value
1 if the indices are optimized successfully; otherwise, 0.void release()
Sets the owner flag to 0 for the Mesh pointer.int remapCVertex(int surface)
Sets the size of the array of coordinate indices to be equal to the size of the array of triangle indices and increases the size of the vertex buffer to the size of the array of triangle vertices by using the coordinate vertex duplicating.Arguments
- int surface - Mesh surface number.
Return value
1 if indices are copied successfully; otherwise, 0.int removeIndices(int surface = -1)
Clears the coordinate and triangle indices of the given surface.Arguments
- int surface - The mesh surface number. -1 means all of the mesh surfaces.
Return value
1 if the indices were cleared successfully; otherwise, 0.int save(const char * name)
Saves the given mesh.Arguments
- const char * name - Mesh name.