ScriptSpot

Forum topic · General Scripting

Scripted modifier for texture controlled animation

By danry · 2012-11-17

Description

Hello! I am new to maxscript and will be very appreciate for advice.
I have interesting idea to make link between texture color on object parameters like position, rotation etc. The texture will be animated and it will create interesting objects movements. For doing that I have this procedure:

1. Create objects
2. Create one planar UVW map for all objects.
3. Volume select modifier with vertex selection level and Texture map for "select by".
4. Scripted modifier that will take Vertex Select Weight for the first vertex and set it to simple float variable.
5. Wire that variable to object parameter with wire or scripted controller.
6. Killer animation ready!))
The problem is with scripted modifier. I only make it work in one frame when button pushed, but it must work every frame like distance in tape helper.

Here the script:

plugin modifier vertexselectectionweight
name:"Vertex Weight Parameter"
classID:#(685315,452281)
version:1
(

parameters main rollout:Roll1
(
amount type:#float ui:spiner default:0
)

rollout Roll1 "vertexselectectionweight" width:162 height:300
(
button but1 "push" pos:[51,37] width:60 height:21 across:2
spinner spiner "Amount: " pos:[26,84] width:114 height:16 range:[0,10000,0] type:#float

on but1 pressed do
( spiner.value = meshop.getVSelectWeight $ 1)
)
)

I hope its understandable)) thanks!

Comments (2)

Anubis · 2012-11-28

Using object names in expresion is bad idea. Use variable and Add Node instead. For example:

-- adding controller to original object...
obj = selection[1]
ctr = obj.position.x_position.controller = \
float_script script:"(meshop.getVSelectWeight obj 1) * 20"
ctr.addNode "obj" obj

Now when you clone that object will need only to change the Node reference in "obj" variable:

-- cloned object...
clonedObj = selection[1]
ctr = clonedObj.position.x_position.controller
ctr.SetNode "obj" clonedObj

danry · 2012-11-19

Ok. I found another way is to make scripted controller with expression:
(meshop.getVSelectWeight $Box001 1)*20

But if I want to clone this object I need to write new name in expression. How to set mesh name in expression automaticaly?