Animate edit poly modifier verts

Animate edit poly modifier verts

danlane3d
Contributor Contributor
660 Views
5 Replies
Message 1 of 6

Animate edit poly modifier verts

danlane3d
Contributor
Contributor

Hi,

 

How do animate verts in an editpoly modifier with maxscript? My current attempt doesn't set keys even if I set the modifier to animate mode and also wrap it all within an on animate context.

 

Here's my code so far, it matches the vert positions of one object to another but I'd like it to animate the verts:

sourceobj = selection[1]
modifyObject = selection[2]

storedVertPositions = #()

vertCount = polyop.getNumVerts sourceobj
print vertCount

				-- Cache vertex positions in world space
				for i = 1 to vertCount do (
					pos = polyop.getVert sourceobj i
					--append storedVertPositions #(i, pos)
					append storedVertPositions pos
				)
				
				-- add epoly to modified mesh
				ePolyMod = undefined --Edit_Poly ()
				for modify in modifyObject.modifiers where modify.name == "Edit Poly" do ePolyMod =  modify
					
				
				
				
				select modifyObject
				
				max modify mode
				modPanel.setCurrentObject ePolyMod
				
				ePolyMod.enabled = true
				subobjectLevel = 1
				ePolyMod.useSoftSel = off
				ePolyMod.SetSelection #Vertex #{}
				
				
				ePolyMod.animationMode = true
				



			for i = 1 to vertCount do (	

					sourcePos = storedVertPositions[i]
				currentPos = polyop.getVert modifyObject i
				
				diffVector = sourcePos - currentPos
				
				with animate on(
					at time 100
					(
						modifyObject.modifiers[#Edit_Poly].Select #Vertex #{i}
						modifyObject.modifiers[#Edit_Poly].MoveSelection diffVector
						modifyObject.modifiers[#Edit_Poly].Commit()
						modifyObject.modifiers[#Edit_Poly].SetSelection #Vertex #{}
				)
			)
		)	
Thanks for reading 🙂
Cheers
0 Likes
661 Views
5 Replies
Replies (5)
Message 2 of 6

A娘
Advocate
Advocate

for modifier animation, you should use slidertime instead of at time

and you should use setvert method instead of what you did

0 Likes
Message 3 of 6

danlane3d
Contributor
Contributor

Thanks, I'll give that a try.

0 Likes
Message 4 of 6

danlane3d
Contributor
Contributor

I don't think there is a setvert method in the edit poly modifier.

 

0 Likes
Message 5 of 6

A娘
Advocate
Advocate

of course it has , you can't get all interfaces from maxscript reference , just show modifier , and you can see what methods it has

0 Likes
Message 6 of 6

danlane3d
Contributor
Contributor

Well of course 😄

Thanks for the tip, I'll inspect it's methods.

0 Likes