A SimpleMeshMod plug-in is a geometry modifier that can change the topology of the incoming mesh and output the modified result. Available in 3ds Max 2016 and higher.
Examples of similar modifiers are Mirror and Symmetry.
These kinds of modifiers require a modifyMesh
handler. The internal mesh
value contains the modifier's TriMesh. It is set to the incoming TriMesh value and can be set to a new TriMesh value to produce the modified output.
The internal owningNode
value contains the node the modifier is applied to. If the modifier is instanced across multiple nodes, only one of them will be accessible.
The SimpleMeshMod plug-in operates similarly to a scripted Geometry plug-in, but instead of creating a new Geometry object, it operates on the incoming TriMesh on the Modifier Stack.
A scripted Simple Mesh Modifier plug-in is declared by specifying the <superclass>
as simpleMeshMod
.
SCRIPT
plugin simpleMeshMod TestCloneModifier
name:"TestCloneMod"
classID:#(0x3a4087e9, 0x2c2fdff7)
category:"MXS Help"
(
parameters main rollout:params
(
nCopies ui:spn_nCopies default:2 type:#integer animatable:true
X_Offset ui:spn_X_Offset default:10 type:#float animatable:true
Y_Offset ui:spn_Y_Offset default:10 type:#float animatable:true
Z_Offset ui:spn_Z_Offset default:10 type:#float animatable:true
)
rollout params "Parameters"
(
spinner spn_nCopies "# Copies:" range:[1, 1000, 1] type:#integer
spinner spn_X_Offset "X Offset:" range:[-1000, 1000, 1] type:#float
spinner spn_Y_Offset "Y Offset:" range:[-1000, 1000, 1] type:#float
spinner spn_Z_Offset "Z Offset:" range:[-1000, 1000, 1] type:#float
)
on modifyMesh do
(
local workingMesh = copy mesh --make a copy of the incoming mesh
local offsetValue = [X_Offset,Y_Offset,Z_Offset]
-- First copy is the incoming mesh. We attach additional transformed meshes to that.
for n = 2 to nCopies do --repeat N-1 times
(
meshop.moveVert workingMesh #all offsetValue -- repeatedly move the copy
meshop.attach mesh workingMesh --accummulate the moved mesh into the output mesh
)
free workingMesh -- Free data associated with mesh. Reduces memory consumption
)
)
The above example implements a simple linear clone modifier. It contains four parameters - the number of copies to create and the offset along each of the three axes.
The on modifyMesh do
handler is called whenever the modifier's output requires an update. The internal mesh
value is set to the incoming TriMesh from the stack. The script creates a local copy of this TriMesh. Then it loops N-1 times, copies the TriMesh copy again and moves all its vertices according to the offset values multiplied by the number of copies minus 1. Finally, the resulting offset copy of the incoming mesh is added to the internal mesh value. At the end of the handler, the mesh value contains the original TriMesh plus all the copies accumulated into one.
There are pre-defined locals you can access in the modifyMesh
handler:
transform
- the transform of the owning node (owningNode
parameter)inverseTransform
- inverse of the transform boundingBox
- the modifier context's bounding box In addition, the simpleMod plug-in type exposes the following locals inherited from parent classes:
From scripted SimpleMod:
extent
min
max
center
From the base scripted plug-in class:
this
version
loading
delegate
(always undefined
for simpleMeshMod)