[Closed] Scripted Material – Animatable param problem – 3dsmax8
I’ve scripted a material with a spinner to control opacity, setting the spinner controller to the delegates opacity controller. Animating it works just fine, but when editing/moving the visible keys the system breaks down and doesn’t actually change the delegate controller. Also I’ve assigned a linear controller to the delegate controller but the scripted spinner, supposedly using the same controller as the delegate, displays a bezier controller in the curve editor.
plugin material testMaterial
name:"Test Material"
classID:#(0x551de4e5, 0x45880130)
extends:standardMaterial replaceUI:true version:1
(
parameters paramParams rollout:paramROLL
(
opacityVal type:#integer animatable:true ui:opacitySPN default:100
)
rollout paramROLL "Params"
(
spinner opacitySPN "Opacity: " type:#integer range:[0,100,100] controller:delegate.opacity.controller
)
on create do
(
delegate.opacity.controller = linear_float()
)
)
You are going about it the wrong way. What you have done is provided a solution where when the HUI is open the slider will be connected to the delegate. What you need to do is connect the parameter in the paramblock to the delegate.
plugin material testMaterial
name:"Test Material"
classID:#(0x551de4e5, 0x45880130)
extends:standardMaterial replaceUI:true version:1
(
parameters paramParams rollout:paramROLL
(
opacityVal type:#integer animatable:true ui:opacitySPN default:100
on opacityVal set val do delegate.opacity.value=val
)
rollout paramROLL "Params"
(
spinner opacitySPN "Opacity: " type:#integer range:[0,100,100]
)
)
Thanks for the thoughts Paul, I started out defining it that way, to no avail. Just setting keys is not a problem it is the moving of keys that is.
Try the code you suggested, I had to remove “value” from “delegate.opacity.value=val” to get it to run, animate the opacity spinner, with animate on goto frame 50 set the value to 0 then at frame 100 set the value to 100, now move the key at frame 50 to 10ish, watch the viewport, moving the key has no effect on the materials behavior it still fades out at 50. This is why I was trying to hook the visible controller to the delegates controller.
Ok I will give it a test a bit later in the day and let you know what I find.
I didnt’ thest my code but I was close.
What you need is an on param get val do handler. What this does is get the value and set it when it is changing. The set handler isn’t needed
plugin material testMaterial
name:"Test Material"
classID:#(0x551de4e5, 0x45880130)
extends:standardMaterial replaceUI:true version:1
(
parameters paramParams rollout:paramROLL
(
opacityVal type:#integer animatable:true ui:opacitySPN default:100
on opacityVal get val do delegate.opacity=val
)
rollout paramROLL "Params"
(
spinner opacitySPN "Opacity: " type:#integer range:[0,100,100]
)
)