Mesh Class
Mesh Class
Members
Mesh ()
Constructor. Creates an empty mesh.Mesh (const char * arg1)
Arguments
- const char * arg1
Mesh (const Ptr<Mesh> & mesh)
Arguments
- const Ptr<Mesh> & mesh
void setTIndex (int num, int index, int surface)
Updates the given triangle index of the given surface.Arguments
- int num - The index number in the array of triangle indices.
- int index - Index value to be set.
- int surface - The mesh surface number.
BoundSphere getBoundSphere ()
Returns the bounding sphere of a given surface.Return value
Bounding sphere.void sortSurfaces ()
Sorts all surfaces by its name.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. If the passed animation number is -1, the bind pose will be updated to the given array.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 - The animation number. The default value is -1.
- int frame - The animation frame number. The default value is 0.
Return value
Returns 1 if the array of bones' transformations is updated successfully; otherwise, 0.BoundSphere getBoundSphere (int surface)
Returns the bounding sphere of a given surface.Arguments
- int surface - The surface number.
Return value
Bounding sphere.Math::vec3 getVertex (int num, int surface, int target = 0)
Returns an array of vertices of the given surface target.Arguments
- int num
- int surface
- int target
Return value
Array of vertices.int removeIndices (int surface = -1)
Clears the coordinate and triangle indices of the given surface.Arguments
- int surface - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the indices are cleared successfully; otherwise, 0.int addBoxSurface (const char * name, const Math::vec3 & size)
Appends a box surface to the current mesh.Arguments
- const char * name - The surface name.
- const Math::vec3 & size - Box size along the X, Y and Z axes.
Return value
The added surface number.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 - The surface number.
void setBoundSphere (const BoundSphere & bs)
Sets the bounding sphere for the given mesh surface.Arguments
- const BoundSphere & bs - Bounding sphere to be set.
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 - The surface number.
int getNumTangents (int surface, int tangent = 0)
Returns the number of tangents for the given surface target.Arguments
- int surface - The mesh surface number.
- int tangent - The surface target number. The default value is 0.
Return value
Number of tangents.void setWeightCount (int num, int count, int surface)
Sets the number of weights that affect the vertex with the given weight.Arguments
- int num - The weight number in the array of vertex weights.
- int count - Number of weights to be set.
- int surface - The mesh surface number.
void setNumNormals (int size, int surface, int target = 0)
Sets the number of normals for the given surface target.Arguments
- int size - Number of normals to be set.
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
void setNumTexCoords1 (int size, int surface)
Sets the number of the second UV map texture coordinates for the given mesh surface.Arguments
- int size - Number of the second UV map texture coordinates to be set.
- int surface - The mesh surface number.
int createNormals (int surface = -1, int target = -1)
Creates normals for the given surface target.Arguments
- int surface - The mesh surface number. The default value is -1 (all of the mesh surfaces).
- int target - The surface target number. The default value is -1 (all of the surface targets).
Return value
Returns 1 if the normals are created successfully; otherwise, 0.int getNumTVertex (int surface)
Returns the number of triangle vertices for the given mesh surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the triangle vertices.int createTangents (int surface = -1, int target = -1)
Creates tangents for the given surface target.Arguments
- int surface - The mesh surface number. The default value is -1 (all of the mesh surfaces).
- int target - The surface target number. The default value is -1 (all of the surface targets).
Return value
Returns 1 if the tangents are created successfully; otherwise, 0.void addTangent (const Math::quat & tangent, int surface, int target = 0)
Appends a new tangent to the given surface target.Arguments
- const Math::quat & tangent - The tangent to be added.
- int surface - The surface number.
- int target - The surface target number. The default value is 0.
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() function.Arguments
- int animation - The animation number.
- int num - The 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.
int getNumCIndices (int surface)
Returns the number of coordinate indices for the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the coordinate indices.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 - The surface number.
void setWeightBones (int num, const Math::ivec4 & bones, int surface)
Sets the vector of bone indices that affect the vertex with the given weight.Arguments
- int num - The weight number in the array of vertex weights.
- const Math::ivec4 & bones - Vector of the bone indices to be set.
- int surface - The mesh surface number.
Math::mat4 getBoneTransform (int bone)
Returns the transformation matrix for the given bone.Arguments
- int bone - The bone number.
Return value
Transformation matrix.int getNumSurfaceTargets (int surface)
Returns the number of targets for the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of targets.void setTexCoord0 (int num, const Math::vec2 & texcoord, int surface)
Updates the first UV map texture coordinates of the given surface.Arguments
- int num - The number of the texture coordinates in the array of the first UV map texture coordinates.
- const Math::vec2 & texcoord - The first UV map texture coordinates to be set.
- int surface - The mesh surface number.
int getNumVertex (int surface, int target = 0)
Returns the number of vertices for the given surface target.Arguments
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
Return value
Number of the vertices.int addIcosahedronSurface (const char * name, float radius)
Appends a icosahedron surface to the current mesh.Arguments
- const char * name - The surface name.
- float radius - The icosahedron radius.
Return value
The added surface number.int setGeodeticTransform (const Ptr<Geodetic> & geodetic, const Math::dvec3 & geodetic_coords)
Arguments
- const Ptr<Geodetic> & geodetic
- const Math::dvec3 & geodetic_coords
Return value
int getTIndex (int num, int surface)
Returns the triangle index for the given surface by using the index number.Arguments
- int num - The index number in the array of triangle indices.
- int surface - The mesh surface number.
Return value
The triangle index.Math::vec4 getWeightWeights (int num, int surface)
Returns a vector of bone weights that affect the vertex with the given weight.
The vertex weight is characterized by the following values:
- The 4 bone indices;
- The 4 bone weights;
- Number of the weights.
Arguments
- int num - The weight number in the array of vertex weights.
- int surface - The mesh surface number.
Return value
Bone weights associated with the given weight.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 - The mesh surface number.
int getNumTexCoords0 (int surface)
Returns the number of the first UV map texture coordinates for the given mesh surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the first UV map texture coordinates.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 - The mesh 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.Arguments
- const char * name - The surface name.
- float radius - The capsule radius.
- float height - The 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 setBoundBox (const BoundBox & bb)
Sets the bounding box for the given mesh surface.Arguments
- const BoundBox & bb - Bounding box to be set.
const char * getSurfaceName (int surface)
Returns the name of the given surface.Arguments
- int surface - The mesh surface number.
Return value
The surface name.int getNumCVertex (int surface)
Returns the number of coordinate vertices of the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the coordinate vertices.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.Arguments
- int surface - The mesh surface number.
Return value
Returns 1 if indices are copied successfully; otherwise, 0.int addSurfaceTarget (int surface, const char * name = 0)
Appends a target with the given name to the given surface.Arguments
- int surface - The surface number.
- const char * name - Name of the surface target. This argument is empty by default.
Return value
Number of surface targets.void addNormal (const Math::vec3 & normal, int surface, int target = 0)
Appends a normal to the array of normals of the given surface target.Arguments
- const Math::vec3 & normal - Normal to be added.
- int surface - The surface number.
- int target - The surface target number. The default value is 0.
void getAnimationBones (int animation, Vector< short > & bones)
Adds all bones of the given animation to the given array of bones.Arguments
- int animation - The animation number.
- Vector< short > & bones - Array with indices of bones taking part in the animation.
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.Arguments
- const char * v - The name of the new surface added to the current mesh.
- const Ptr<Mesh> & mesh - Source mesh to copy a surface from.
- int surface - The number of the source mesh surface to copy.
- int target - The number of the target of the source mesh surface. The default value is -1 (all of the surface targets).
Return value
Returns the number of the mesh surfaces.void setWeightWeights (int num, const Math::vec4 & weights, int surface)
Sets the vector of bone weights that affect the vertex with the given weight.Arguments
- int num - The weight number in the array of vertex weights.
- const Math::vec4 & weights - Vector of bone weights to be set.
- int surface - The mesh surface number.
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 - The animation number.
- int num - The 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.
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.Arguments
- const char * name - The surface name.
- float width - The plane width.
- float height - The plane height.
- float step - Step of surface subdivision (vertical and horizontal).
Return value
The added surface number.int getNumColors (int surface)
Returns the number of colors set for vertices of the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of colors.int getNumAnimationFrames (int animation)
Returns the number of animation frames for the given animation.Arguments
- int animation - The animation number.
Return value
Number of the animation frames.Math::quat getTangent (int num, int surface, int target = 0)
Returns the tangent for the given vertex of the mesh surface.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
Vertex tangent.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() function.Arguments
- int animation - The animation number.
- int num - Number of the frame in the array of the animation frames.
- Vector< Math::mat4 > & frames - Matrix that includes coordinates, rotation quaternions and scaling vectors of the animation frame.
int getNumBones ()
Returns the total number of mesh bones.Return value
Number of the mesh bones.int save (const char * name)
Saves the mesh under the given name.Arguments
- const char * name - The mesh name.
Return value
Returns 1 if the mesh is saved successfully; otherwise, 0.int getNumWeights (int surface)
Returns the number of weights set for vertices of the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the weights.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 - The mesh surface number. The default value is -1 (all of the mesh surfaces).
- int target - The surface target number. The default value is -1 (all of the surface targets).
Return value
Returns 1 if the transformation matrix is set successfully; otherwise, 0.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 - The mesh surface number.
void setNumTIndices (int size, int surface)
Sets the number of triangle indices for the given surface.Arguments
- int size - Number of triangle indices to be set.
- int surface - Number of the mesh surface.
void setAnimationBones (int animation, const Vector< short > & bones)
Copies bones from the given array to the current array of animation bones.Arguments
- int animation - The animation number.
- const Vector< short > & bones - Array of bones taking part in the animation to be set.
void addTIndex (int index, int surface)
Appends a triangle index to the given mesh surface.Arguments
- int index - The index number in the index buffer.
- int surface - The number of the surface to which the triangle index is added.
void setAnimationName (int animation, const char * name)
Sets a name for the given animation.Arguments
- int animation - The animation number.
- const char * name - The animation name to be set.
void setBoneTransform (int bone, const Math::mat4 & transform)
Sets the transformation matrix for the given bone.Arguments
- int bone - The bone number.
- const Math::mat4 & transform - Transformation matrix to be set.
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 - The mesh surface number.
Return value
Number of the coordinate indices.int addEmptySurface (const char * name, int num_vertex, int num_indices)
Appends a new empty surface to the current mesh.Arguments
- const char * name - The surface name.
- int num_vertex - Number of surface vertices.
- int num_indices - Number of surface indices.
Return value
Number of the mesh surfaces.void setNumAnimationFrames (int animation, int num)
Sets the number of animation frames for the given animation.Arguments
- int animation - The animation number.
- int num - Number of the animation frames to be set.
int addSurface (const char * name = 0)
Append a new surface with the given name to the current mesh.Arguments
- const char * name - The surface name. This argument is empty by default.
Return value
Number of mesh surfaces.int getIndex (int num, int surface)
Returns the coordinate index by using the given number if the coordinate index is equal to the triangle index.Arguments
- int num - The index number in the array of coordinate indices.
- int surface - The mesh surface number.
Return value
The coordinate index.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
The bone number.int findSurface (const char * name)
Searches for the surface number by its name.Arguments
- const char * name - The mesh surface name.
Return value
The mesh surface number, if it is found; otherwise, -1.Math::ivec4 getWeightBones (int num, int surface)
Returns a vector of bone indices that affect the vertex with the given weight.
The vertex weight is characterized by the following values:
- The 4 bone indices;
- The 4 bone weights;
- Number of the weights.
Arguments
- int num - The weight number in the array of vertex weights.
- int surface - The mesh surface number.
Return value
Vector of the bone indices associated with the given weight.void setNormal (int num, const Math::vec3 & normal, int surface, int target = 0)
Updates the vertex normal of the given morph target by using the vertex normal number.To get the total number of normals for the given surface, call the getNumNormals() function.
The normal of the vertex won't be written into the *.mesh file. It will be stored only in memory.
Arguments
- int num - The vertex normal number in the array of normals.
- const Math::vec3 & normal - Normal to be set.
- int surface - The mesh surface number.
- int target - The morph target number.
int createTangents (float angle, const Vector< int > & surfaces)
Creates tangents for the given surface target.Arguments
- float angle - The mesh surface number. The default value is -1 (all of the mesh surfaces).
- const Vector< int > & surfaces - The surface target number. The default value is -1 (all of the surface targets).
Return value
Returns 1 if the tangents are created successfully; otherwise, 0.int getWeightCount (int num, int surface)
Returns the number of weights that affect the vertex with the given weight.
The vertex weight is characterized by the following values:
- The 4 bone indices;
- The 4 bone weights;
- Number of the weights.
Arguments
- int num - The weight number in the array of vertex weights.
- int surface - The mesh surface number.
Return value
Number of weights.void setSurfaceName (int surface, const char * name)
Sets the name for the given mesh surface.Arguments
- int surface - The mesh surface number.
- const char * name - The surface name to be set.
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 - The mesh surface number. The default value is -1 (all of the mesh surfaces).
- int target - The surface target number. The default value is -1 (all of the surface targets).
Return value
Returns 1 if the normals are created successfully; otherwise, 0.void addCIndex (int index, int surface)
Appends a coordinate index to the array of the surface coordinate indices.Arguments
- int index - The index number in the index buffer.
- int surface - The surface number.
int getBoneParent (int bone)
Returns the number of the parent bone of the given one.Arguments
- int bone - The bone number, for which the parent bone will be returned.
Return value
The parent bone number.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 - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the indices are created successfully; otherwise, 0.void setNumSurfaceTargets (int surface, int num)
Sets the number of targets for the given mesh surface.Arguments
- int surface - The mesh surface number.
- int num - Number of the surface targets to be set.
void setSurfaceTargetName (int surface, int target, const char * name)
Sets the name for the given surface target.Arguments
- int surface - The mesh surface number.
- int target - The surface target number.
- const char * name - The surface target name to be set.
void setAnimationFrame (int animation, int num, const Vector< Math::mat4 > & frames)
Updates the animation frame coordinates, rotation quaternions and scaling vectors.Arguments
- int animation - The animation number.
- int num - The 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 setNumTexCoords0 (int size, int surface)
Sets the number of the first UV map texture coordinates for the given mesh surface.Arguments
- int size - Number of the first UV map texture coordinates to be set.
- int surface - The mesh surface number.
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. Mesh local space coordinates are used for this function.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 - The surface number.
- int target - The surface target number.
Return value
Returns 1 if the intersection is found; otherwise, 0.void addVertex (const Math::vec3 & vertex, int surface, int target = 0)
Appends a new vertex with the given coordinates to the mesh surface.Arguments
- const Math::vec3 & vertex - Coordinates of the vertex to be added.
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
void setTexCoord1 (int num, const Math::vec2 & texcoord, int surface)
Updates the second UV map texture coordinates of the given surface.Arguments
- int num - The number of the texture coordinates in the array of the second UV map texture coordinates.
- const Math::vec2 & texcoord - The second UV map texture coordinates to be set.
- int surface - The mesh 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.Arguments
- const char * name - The surface name.
- float radius - The sphere radius.
- int stacks - Number of stacks that divide the sphere radially.
- int slices - Number of slices that divide the sphere horizontally.
Return value
The added surface number.const char * getAnimationName (int animation)
Returns the name of the given animation.Arguments
- int animation - The animation number.
Return value
The animation name.int info (const char * name)
Returns an information about the given mesh.Arguments
- const char * name - The mesh name.
Return value
Returns 1 if the information returned successfully; otherwise, 0.void * getMesh ()
Return value
void setTangent (int num, const Math::quat & tangent, int surface, int target = 0)
Sets the new tangent for the given vertex of the mesh surface.Arguments
- int num - Number of the vertex in the vertex buffer.
- const Math::quat & tangent - Tangent to be set.
- int surface - Number of the mesh surface.
- int target - Number of the surface's morph target.
int flipTangent (int surface = -1)
Flips the sign of the binormal component of the surface tangent space.Arguments
- int surface - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the sign of the binormal component is flipped successfully; otherwise, 0.void setNumColors (int size, int surface)
Sets the number of colors set for vertices of the given surface.Arguments
- int size - Number of colors to be set.
- int surface - The mesh surface number.
Math::vec2 getTexCoord1 (int num, int surface)
Returns the second UV map texture coordinates for the given surface.Arguments
- int num - The number of the texture coordinates in the array of the second UV map texture coordinates.
- int surface - The mesh surface number.
Return value
The second UV map texture coordinates.Math::vec2 getTexCoord0 (int num, int surface)
Returns the first UV map texture coordinates for the given surface.Arguments
- int num - The number of the texture coordinates in the array of the first UV map texture coordinates.
- int surface - The mesh surface number.
Return value
The first UV map texture coordinates.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 - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if bounds are created successfully; otherwise, 0.int load (const char * name)
Loads the mesh with the given name for the current mesh.Arguments
- const char * name - The mesh name.
Return value
Returns 1 if the mesh is loaded successfully; otherwise, 0.int getNumNormals (int surface, int target = 0)
Returns the number of normals for the given surface target.Arguments
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
Return value
Number of normals.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.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 - The index number in the index buffer.
- int surface - The surface number.
int getNumAnimations ()
Returns the total number of mesh animations.Return value
Number of the mesh animations.void setVertex (int num, const Math::vec3 & vertex, int surface, int target = 0)
Sets an array of vertices of the given surface target.Arguments
- int num - The vertex number in the vertex buffer.
- const Math::vec3 & vertex - Vertex coordinates to be set.
- int surface - The mesh surface number.
- int target - The morph target number.
int addMeshSurface (int v, const Ptr<Mesh> & mesh, int surface, int target = -1)
Appends a surface of the source mesh to the current mesh.Arguments
- int v - The name of the new surface added to the current mesh.
- const Ptr<Mesh> & mesh - Source mesh to copy a surface from.
- int surface - The number of the source mesh surface to copy.
- int target - The number of the target of the source mesh surface. The default value is -1 (all of the surface targets).
Return value
Returns the number of the mesh surfaces.const char * getSurfaceTargetName (int surface, int target)
Returns the name of the given surface target.Arguments
- int surface - The mesh surface number.
- int target - The surface target number.
Return value
The surface target name.int getNumTexCoords1 (int surface)
Returns the number of the second UV map texture coordinates for the given mesh surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the second UV map texture coordinates.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 - The mesh surface number.
void setBoneParent (int bone, int parent)
Sets the parent bone for the given one.Arguments
- int bone - The bone number, for which the parent bone should be set.
- int parent - The bone to be set as a parent.
const char * getBoneName (int bone)
Returns the name of the given bone.Arguments
- int bone - The bone number.
Return value
The bone name.int addDodecahedronSurface (const char * name, float radius)
Appends a dodecahedron surface to the current mesh.Arguments
- const char * name - The surface name.
- float radius - The dodecahedron radius.
Return value
The added surface number.void setNumTangents (int size, int surface, int target = 0)
Sets the number of tangents for the given surface target.Arguments
- int size - Number of tangents to be set.
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
void setColor (int num, const Math::vec4 & color, int surface)
Sets the vertex color.To get the total number of colors, call the getNumColors() function.
Arguments
- int num - The vertex color number in the array of vertex colors.
- const Math::vec4 & color - Vertex color to be set.
- int surface - The mesh 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.Arguments
- const char * name - The 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 findSurfaceTarget (int surface, const char * name)
Searches for the surface target number by the target name.Arguments
- int surface - The mesh surface number.
- const char * name - The surface target name.
Return value
The target number, if it exists; otherwise, -1.void clear ()
Clears the mesh (including its bones, animation, surfaces and bounds).int getCIndex (int num, int surface)
Returns the coordinate index by its number.Arguments
- int num - The index number in range from 0 to the total number of coordinate indices of the given surface.
- int surface - The mesh surface number.
Return value
The coordinate index.Math::vec4 getColor (int num, int surface)
Returns the vertex color.To get the total number of colors, call the getNumColors() function.
Arguments
- int num - The vertex color number in the vertex color array.
- int surface - The mesh surface number.
Return value
Vertex color.void setNumVertex (int size, int surface, int target = 0)
Updates the number of vertices for the given surface target.Arguments
- int size - Number of the vertices to be set.
- int surface - The mesh surface number.
- int target - The surface target number. The default value is 0.
void setNumCIndices (int size, int surface)
Sets the number of coordinate indices for the given surface.Arguments
- int size - Number of the coordinate indices to be set.
- int surface - The mesh surface number.
void setCIndex (int num, int index, int surface)
Sets the coordinate index.Arguments
- int num - The index number in range from 0 to the total number of coordinate indices of the given surface.
- int index - The coordinate index to be set.
- int surface - The mesh surface number.
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 number of such the vertices and create indices for them that will be store the corresponding normals, tangents and texture coordinates.Arguments
- int flags - One of the flags used for indices' optimization: BACK_TO_FRONT or VERTEX_CACHE.
- int surface - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the indices are optimized 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. If the passed animation number is -1, the bind pose will be added to the given array. The number of array elements must be equal to the number of animation bones.Arguments
- Vector< Math::mat4 > & transforms - Array of transformation matrices.
- int animation - The animation number. The default value is -1.
- int frame - The animation frame number. The default value is 0.
Return value
Returns 1 if the array of bones' transformations is filled successfully; otherwise, 0.Math::vec3 getNormal (int num, int surface, int target = 0)
Returns the vertex normal of the given morph target by using the vertex normal number.To get the total number of normals, call the getNumNormals() function.
Arguments
- int num - The vertex normal number in the array of normals.
- int surface - The mesh surface number.
- int target - The morph target number.
Return value
Vertex normal.int addBone (const char * name = 0, int parent = -1)
Appends a new mesh bone.Arguments
- const char * name - The bone name. This argument is empty by default.
- int parent - The parent bone number. The default value is -1 (the new bone has no parent bone).
Return value
Number of mesh bones.void setBoneName (int bone, const char * name)
Sets a name for the given bone.Arguments
- int bone - The bone number.
- const char * name - The bone name to be set.
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
The animation number, if it is found; otherwise, -1.int createIntersection (int surface = -1)
Calculates a potentially visible set for the given surface. This function prepares the mesh for working with getIntersection() function.Arguments
- int surface - The surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the potentially visible set is calculated 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 - The mesh surface number. The default value is -1 (all of the mesh surfaces).
Return value
Returns 1 if the axes are flipped successfully; otherwise, 0.void setIndex (int num, int index, int surface)
Updates the index with the specified number.Arguments
- int num - The index number in the array of coordinate indices.
- int index - The index to be set.
- int surface - The 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.Arguments
- const char * name - The surface name.
- float radius - The cylinder radius.
- float height - The 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.BoundBox getBoundBox (int surface)
Returns the bounding box of a given surface.Arguments
- int surface - The surface number.
Return value
Bounding box.BoundBox getBoundBox ()
Returns the bounding box of a given surface.Return value
Bounding box.void sortAnimations ()
Sorts all animations by its name.int getNumSurfaces ()
Returns the total number of mesh surfaces.Return value
Number of the mesh surfaces.int getNumTIndices (int surface)
Returns the number of triangle indices for the given surface.Arguments
- int surface - The mesh surface number.
Return value
Number of the triangle indices.int VERTEX_CACHE
Description
Vertex cache optimization flag.int BACK_TO_FRONT
Description
Flag, which is used for mesh indices optimization. If this flag is set, polygons will be rendered in back-to-front order (from the exterior polygons to the central polygons of the mesh).int NUM_WEIGHTS
Last update: 03.07.2017
Помогите сделать статью лучше
Была ли эта статья полезной?
(или выберите слово/фразу и нажмите Ctrl+Enter