Mesh

Functions for dealing with meshes.
NOTE 1: most functions only handle collapsed editable mesh models. Make sure that's what you're passing into them.
NOTE 2: most functions that alter mesh topology (face/vertex count or order) below are NOT SAFE to use with meshes using mapping channels higher than 1.

CleanIsoVerts
Delete any isolated verts in the mesh.
DetachMeshFaces
Detaches faces in the "faces" bitarray, returns new object.
ExplodeMeshElements
Takes each element in an object and detaches it, returns array of objects.
GetAllPolygons
Gets an array of all the polygons in a mesh.
GetAllPolygonsProgress
Same as above, but with a progress bar.
GetAllMeshElements
Gets an array of all the elements in a mesh.
GetClosestVert
Gets the closest vertex on a mesh to a specified point.
GetClosestVerts
Returns the indexes (and distances) to verts on a mesh from a specified point.
GetFacesByNormal
Gets faces based on normal orientation towards a vector
GetMeshElement
Get all the faces that are connected to a single face.
GetVertFaceCache
Returns a cache to use with certain mesh functions.
MeshOKtoModify
Checks that object is a collapsed editable mesh.

CleanIsoVerts:

Delete any isolated verts in the mesh.

Returns:

OK.

Arguments:
%<obj>
The object who's isolated verts should be deleted.

Back to top...


DetachMeshFaces:

Detaches faces in the "faces" bitarray, returns new object.
Note: Both the detached object and original object will have left over, isolated verts after this operation. It's a good idea to run CleanIsoVerts on both objects afterwards.

Returns:

A new object containing the detached faces.

Arguments:
<%obj>
Object that should have faces detached.
<bitArray>
A bitarray describing which faces should be detached.

Back to top...


ExplodeMeshElements:

Takes each element in an object and detaches it.
Note: this function can take a non-trivial amount of time.

Returns:

An array of newly created objects.

Arguments:
<obj>
The object who's elements should be detached. Note: the object is not modified.

Back to top...


GetAllPolygons:

Gets an array of all the polygons in a mesh. Note: This is VERY SLOW, and requires avg_dlx.dlx.

Returns:

An array of bitarrays. Each bitarray describes which faces make up a single polygon. ie:
polyArray = getAllPolygons $
$.selectedFaces = polyArray[1]
will select the first polygon of the currently selected mesh.

Arguments:
<obj>
The object who's polygons are to be retrieved.

Back to top...


GetAllPolygonsProgress:

Works exactly like "GetAllPolygons", only it posts a progress bar while processing.

Returns:

An array of bitarrays. Each bitarray describes which faces make up a single polygon. ie:
polyArray = getAllPolygonsProgress $
$.selectedFaces = polyArray[1]
will select the first polygon of the currently selected mesh.

Arguments:
<obj>
The object who's polygons are to be retrieved.

Back to top...


GetAllMeshElements:

Gets an array of all the elements in a mesh.

Returns:

Returns an array of bitarrays. Each bitarray describes which faces make up a single element.

Arguments:
<obj>
The object who's elements are to be retrieved.
<vertFaceCache>
An up to date vertex-face cache for the passed object. This can be created by calling "getVertFaceCache" on the passed object.

Back to top...


GetClosestVert:

Gets the closest vertex on a mesh to a specified point.

Returns:

The index of the closest vertex on the mesh or undefined on failure.

Arguments:
<meshObj>
The mesh object to compare the point to
<pnt>
A point in world space
[vertMask:undefined]
An option argument to limit the verticies checked in the mesh. This can be one of the following values:
undefined: the entire mesh is checked
a bitarray: only the specified verts are checked
#selection: only the selected verts are checked

Back to top...


GetClosestVerts:

Returns the indexes (and distances) to verts on a mesh from a specified point.
Use GetClosestVert() if you only need the one closest vertex, as it's faster.

Returns:

Returns array, where:

<returnArray[1]>
An array of vertex indexes, where returnArray[1][1] is the closest vertex, and returnArray[1][returnArray[1].count] is the farthest.
<returnArray[2]>
An array of distances from pnt, where returnArray[2][n] corresponds to the distance from vertex returnArray[1][n].

Arguments:
<meshObj>
The mesh object to compare the point to
<pnt>
A point in world space
[vertMask:undefined]
An option argument to limit the verticies checked in the mesh. This can be one of the following values:
undefined: the entire mesh is checked
a bitarray: only the specified verts are checked
#selection: only the selected verts are checked

Back to top...


GetFacesByNormal:

Gets faces based on normal orientation towards a vector.

Returns:

A bitarray describing which faces point towards the given vector.

Arguments:
<obj>
The object who's faces will be retrieved.
<vec>
A world space vector. Faces who's normals point towards this vector will be retrieved.
<angleThreshold>
The amount of variation in degrees that a face's normal can deviate from vec before it is ignored.

Back to top...


GetMeshElement:

Get all the faces that are connected to a single face.

Returns:

Returns a bitarray describing which faces are connected to the specified face.

Arguments:
<obj>
The object who's element will be retrieved.
<faceIdx>
The index of a face.
<vertFaceCache>
An up to date vertex-face cache for the passed object. This can be created by calling "getVertFaceCache" on the passed object.

Back to top...


GetVertFaceCache:

Returns a cache to use with certain mesh functions. This needs to be rebuilt each time mesh topology changes, but it can take a fair amount of time to calculate, so avoid calling this unnecessarily.

Returns:

Return an array of arrays (one for each vertex). Each array holds all the face indicies that the corresponding vertex references.

Arguments:
<obj>
The object who's vertex-face cache should be retrieved.

Back to top...


MeshOKtoModify:

Checks that object is a collapsed editable mesh.

Returns:

True if mesh is a collapsed editable mesh, otherwise false.

Arguments:
<obj>
The object to check.

Back to top...