Game Development Reference
In-Depth Information
--restore the z value to zero, this value was previously used to store the angle value!
for k = 1 to polyVertices.count do polyVertices[k].z = 0.0
--should have quads polys and not ngons...
indexVertex = #()
for k=1 to polyVertices.count do
(
append indexVertex (polyOp.createVert voronoiDiagram polyVertices[k])
)
--check for triangle faces
if(indexVertex.count > cutNgons) then
polyop.createPolygon voronoiDiagram indexVertex
)
)
resumeEditing()
return voronoiDiagram
)
To run the scripts and check the results on a base mesh, just execute the following code. The results should be
similar to those shown in Figure 4-7 . The mesh must be placed in the “top” view (y and x coordinates only).
Figure 4-7. Base mesh, Delaunay mesh, and Voronoi diagram
baseMesh = $
outTriMesh = fn_delaunayTriangulation 8 baseMesh
fn_voronoiDiagram outTriMesh 2 baseMesh
Conclusion
This chapter offers an introduction to procedural geometry creation using the tools offered by MAXScript. The
proposed Voronoi diagram computation code is basic and could be improved in a variety of ways. For example, the
bounding edges of the base mesh are not considered or included in the resulting Voronoi diagram mesh. The code
works only for planar base meshes and doesn't work in object space. The reader could improve it by removing the
world space-only limitation and adding the base mesh boundary vertices to the Voronoi mesh to achieve the breaking
surface effect.
 
Search WWH ::




Custom Search