Notifications
Clear all

[Closed] Complicate Scripted Shape Plug-ins

Hi, i know maxscript because i use it a lot, but lately i’ve discovered the Scripted plug-ins.
I made a game importer but to represent a system of walls i have imported thousands of objects, which slows Max scene.
In the image you can see one of these objects, is composed by many individual segments, each segment is described by two points, a value and a direction.

My idea is to create a new class as a Scripted plug-in to reduce the amount of objects in the scene only to the minimum necessary, so some information as direction and color (or value of the segment) editable only with class’s Rollout, like editable mesh or edit_normal modifier.

This can be done? I would be happy to put the credits in my script

1 Reply

Hi , i made a modifier plugin only to rappresent a particular objects used into a game file, i need to store a list of vertex with a direction, but the vertices data don’t have faces, i use this solution to rappresent a vast number of point without slow 3dstudio.

I tried Normal modifier, Hair ecc… but didn’t work without faces…

Can i do a Mouse tool to rotate all vertex direction ??? i know the registerRedrawViewsCallback but don’t work in the modifier…

plugin modifier DeploymentModifier
	name:"DeploymentModifier"
	classID:#(0x133067, 0x54374)
	extends:MeshSelect
	replaceUI:false
	version:1
( 
	/*
		MeshSelect is the delegate
		DeploymentModifier is this
	*/
	local NumVerts
	local theNode
	function showLevels =
	(
		format "* DeploymentModifier showLevel()
"
		gw.setTransform(Matrix3 1)
		lenght = 10.0
		for L=1 to 4 do
		(
			level = case L of
			(1: this.level1 ; 2: this.level2 ; 3: this.level3 ; 4: this.level4)
			colore = case L of
			(1: green ; 2: blue ; 3: red ; 4: gray)
			gw.setColor #line colore
			for i=1 to NumVerts where level[i] do
			(
				v = getVert theNode i
				a = this.Direction[i]
				gw.Polyline #(v , v + [sin a , cos a , 0]*lenght) false
				gw.text v (i as string) color:colore
			)
			
		)
		gw.enlargeUpdateRect #whole 
		gw.updateScreen()
	)
	parameters main rollout:params
	(
		Direction type: #angleTab tabSizeVariable:true animatable:false tabSize:0 -- use only the Z rotation because are XY plane
		level1 type:#boolTab tabSizeVariable:true animatable:false tabSize:0 -- bitarray not exist , this i think is the smaller sizeof
		level2 type:#boolTab tabSizeVariable:true animatable:false tabSize:0
		level3 type:#boolTab tabSizeVariable:true animatable:false tabSize:0
		level4 type:#boolTab tabSizeVariable:true animatable:false tabSize:0
	)
	rollout params "Parameters"
	(
		-- the execute ("level"+ l as string) NOT WORK
		fn getLevelarray L = case L of
		(1: level1 ; 2: level2 ; 3: level3 ; 4: level4)
		
		fn printInternalData =
		(
			format "* DeploymentModifier print
"
			for L=1 to 4 do
			(
				levelX = getLevelarray L
				local selected = #{}
				selected.count = NumVerts
				for i=1 to NumVerts do selected[i] = levelX[i]
				format "Level % : %
" L selected
			)
			format "Direction : %
" Direction
		)
		
		fn applyselection L =
		(
			format "* DeploymentModifier apply %
" L
			/* apply selection as boolean array */
			level = 	getLevelarray L
			local selected = getVertSelection $
			for i=1 to NumVerts do level[i] = selected[i]
			/* clean other levels to avoid duplicated index */
			for LL=1 to 4 where LL!=L do
			(
				levelX = getLevelarray LL
				for i in selected do levelX[i]=FALSE
			)
			/* put all missing index into level1 */
			for i=1 to NumVerts do level1[i] = not level2[i] and not level3[i] and not level4[i]
			printInternalData()
		)

		button btnSetLevel1 "Apply to Level1"
		button btnSetLevel2 "Apply to Level2"
		button btnSetLevel3 "Apply to Level3"
		button btnSetLevel4 "Apply to Level4"
		on btnSetLevel1 pressed do applyselection 1
		on btnSetLevel2 pressed do applyselection 2
		on btnSetLevel3 pressed do applyselection 3
		on btnSetLevel4 pressed do applyselection 4
		
		button btnShowDirection "Show"
		on btnShowDirection pressed do showLevels()
	)
	on create do ( clearlistener() ; format "* DeploymentModifier create
")
	on attachedToNode theNode do --2
	(
		format "* DeploymentModifier attach to \"%\"
" theNode.name
		/* inizialize internal data */
		NumVerts = $.numverts
		this.theNode = theNode
		level1.count = level2.count = level3.count = level4.count = Direction.count = NumVerts
		for i=1 to NumVerts do
		(
			level1[i] = TRUE
			level2[i] = level3[i] = level4[i] = FALSE
			Direction[i] = random 0 360
		)
	)   
)

 

fn test =
(
	obj = getnodebyname "Object"
	if obj==undefined then
	(
	verts =	#()
	verts.count = 100
	for i=1 to 10 do for j=1 to 10 do verts[i+(j-1)*10] = [i-1,j-1,0]*10
	obj = mesh faces:#() vertices:verts vertexticks:true name:"Object"
	)

	select obj
	max modify mode
	depmode = obj.modifiers[#DeploymentModifier]
	if depmode!=undefined then deleteModifier obj 1
	depmod = DeploymentModifier()
	addModifier obj depmod
)
test()