Game Development Reference
In-Depth Information
--disable editing for speed
suspendEditing()
--mesh copy of the passed object
customShapeMesh = snapshotAsMesh baseMesh
--for every triangle in the mesh generate a random set of vertices inside it
numFaces = meshop.getNumFaces customShapeMesh
numVertices = meshop.getNumVerts customShapeMesh
undo off
(
for i=1 to numFaces do
(
--get the coordinates of the three vertices
triVertices = meshop.getVertsUsingFace customShapeMesh i
vertexCoords = #()
for j=1 to numVertices do
(
if(triVertices[j] == true) then
(
vertexCoords[(vertexCoords.count + 1)] = meshOP.getVert customShapeMesh j
)
)
--generate some random points inside the triangle using barycentric coords
for k = 1 to vNumber do
(
aa = random 0.0 1.0
bb = random 0.0 1.0
if(aa+bb > 1.0) then
(
aa = 1-aa
bb = 1-bb
)
cc = 1.0 - aa - bb
tempV = (aa * vertexCoords[1]) + (bb * vertexCoords[2]) + (cc*vertexCoords[3])
append vertices tempV
)
)
--append the customShapeMesh vertices too
for j=1 to numVertices do
(
append vertices (meshOP.getVert customShapeMesh j)
)
)
-------------------
-- continue below
-------------------
Search WWH ::




Custom Search