Notifications
Clear all

[Closed] Animated material, changing keys

Hi,

I have an animated grandient ramp, 2 keys. What I want to do is to make some random timing on it.

So my thinking is to select 1st key, and add some random value to it, and then select 2nd key and add the same random value. Very simple.

I wanted to use this command:

selectKeys <controller> [ <interval> | <time> ]

But since I have no controller, how can I select my animated map?

2 Replies

to get access to keys you have to know a subanim (or controller) that holds these keys.
every max key has ‘time’ parameter. it’s a ‘get’ and ‘set’ parameter.

example:

m = meditmaterials[1] = Standard()
 g = m.diffusemap = Gradient_Ramp ()
 animate on
 (
 	at time 0 g.amount = 0
 	at time 100 g.amount = 1
 )
 
 keys = meditmaterials[1].diffusemap.amount.controller.keys
 
 for k in keys do k.time = random 0 100
 format "keys: %
" meditmaterials[1].diffusemap.amount.controller.keys

here is a example for ramp middle color:


g.gradient_ramp.flag__3.color.controller = Bezier_Color()
animate on
(
	at time 0 g.gradient_ramp.flag__3.color = green
	at time 100 g.gradient_ramp.flag__3.color = yellow
)
keys = meditmaterials[1].diffusemap.gradient_ramp.flag__3.color.controller.keys

for k in keys do k.time = random 0 100
sortkeys meditmaterials[1].diffusemap.gradient_ramp.flag__3.color.controller

format "keys: %
" meditmaterials[1].diffusemap.gradient_ramp.flag__3.color.controller.keys