Scripted SimpleMeshMod Plug-ins

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 inMesh = copy mesh --make a copy of the incoming mesh
		for n = 2 to nCopies do --repeat N-1 times 
		(
			local currentMesh = copy inMesh --copy the incoming mesh value
			meshop.moveVert currentMesh #{1..currentMesh.numverts} ([X_Offset,Y_Offset,Z_Offset]*(n-1))
			mesh = mesh + currentMesh --accummulate the moved value into the output mesh
		)
	)
)

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 accummulated into one.

See Also