Notifications
Clear all

[Closed] Scripted MeshObjects?

Im trying to create a meshobject to display custom meshes…

Heres what I have so far, however It is not displaying my box.
Is there any examples of these around, as the maxscript help only has one paragraph on these…



plugin SimpleObject InstanceObject
	name:"Instance"
	category:"Extended Primitives"
	classID:#(0x3ce8d374, 0x73f033e9)
( 
	local mInstanceMesh
	-- when creating the object
	tool create 
	( 
		on mousePoint click do 
		(
			--nodeTM.translation = gridPoint
			--print nodeTM.translation
			mInstanceMesh = createInstance box length:10 width:10 height:10 mapCoords:false 
			mInstanceMesh.mesh				
			#stop 
		
		)
	) 
)


5 Replies

For a second I almost believed you. There are 3 (THREE!) fully working scripted simpleObject plugin examples in the help.

Go read again!

argh ok thanks

doing a search reveals alot more info

cheers!

Ok im ttrying to create a instance object of sorts.

Basically I want to replace mesh with a copy of an object in the scene…

heres the code ive got, however I have some querys…

“mesh” is this somthing fixed in the scripted plugin? Ive tryed renaming this but it stoped working…

So create the object, then select it and goto modifier panel, select pickmesh and click on a mesh object.

what I want to happen is for that picked mesh to become the instancemesh mesh…


 plugin SimpleObject InstanceObject
 	name:"Instance"
 	category:"Extended Primitives"
 	classID:#(0x3ce8d374, 0x73f033e9)
 ( 
 	local	width = 10
 	local	depth = 10
 	local	height = 10
 		
 	parameters main rollout:params
 	(
 		paramInstanceMesh type:#node ui:pickInstanceNode --default:0
 	)
 	
 	rollout params "Instance Parameters"
 	(
 		local uiX = 5
 		local uiY = 5
 		pickbutton pickInstanceNode "pick Mesh" pos:[uiX,uiY]
 		
 		on pickInstanceNode picked val do
 		(
 			mesh = copy val
 		)
 	)
 	
 	-- when creating the object
 	tool create 
 	( 
 		on mousePoint click do 
 		(
 			nodeTM.translation = gridPoint
 			#stop 
 		)
 	) 
 	
 	on buildMesh do
 	(
 		print "oi"
 		
 		setMesh mesh verts:#([0,0,0],[width,0,0],[width,depth,0],[0,depth,0]) faces:#([3,2,1], [1,4,3])
 		extrudeFace mesh #(1,2) (height * 0.5) 40 dir:#common
 		extrudeFace mesh #(1,2) (height * 0.5) 50 dir:#common
 	)
 	
 )
 
 
 
plugin SimpleObject InstanceObject
	 name:"Instance"
	 category:"Extended Primitives"
	 classID:#(0x3ce8d374, 0x73f033e9)
 ( 
	local theMesh = undefined --variable to hold the TriMesh value to display
		 
	 parameters main rollout:params
	 (
		 paramInstanceMesh type:#node --holds the node that was picked
	 )
	 
	--filter function to avoid picking anything but geometry (that is not a target object)
	fn filterGeom obj = superclassof obj == GeometryClass and classof obj != TargetObject
	 rollout params "Instance Parameters"
	 (
		 local uiX = 5
		 local uiY = 5
		 pickbutton pickInstanceNode "pick Mesh" pos:[uiX,uiY] filter:filterGeom  --filtered pick
		 on pickInstanceNode picked val do --if picked a geometry object,
		(
			if isValidNode val do
			(
				paramInstanceMesh = val --if picked, store the node in the paramblock
				theMesh = paramInstanceMesh.mesh --set the mesh to the TriMesh of the picked object
			)	
		)	
	 )
	 
	 tool create 
	 ( 
		 on mousePoint click do 
		 (
			 nodeTM.translation = gridPoint
			 #stop 
		 )
	 ) 
	 
	 on buildMesh do
	 (
		--if the TriMesh is valid, set the MESH variable of the plugin using the SETMESH method
		--both the MESH variable and the SETMESH method are specially exposed by simpleObject
		 if theMesh != undefined do  setMesh mesh theMesh 
	 )
	
	on Load do 
	(
		--when loading the plugin, make sure the node that was stored is still there
		--and grab its mesh into the variable to update the plugin correctly
		if isValidNode paramInstanceMesh do 
				theMesh = paramInstanceMesh.mesh
	)
 )

This is very similar to the Mesher Compound, BUT

  1. it takes the mesh from the stack BEFORE the transforms and Space Warps
  2. does not animate if the source mesh is animated – it takes a static snapshot of it

You can keep on expanding this, esp. UI-wise

thanks, looks great!

ill look at this further at work

cheers!