ScriptSpot

Forum topic · General Scripting

How to key R,G,B of diffuse Mat

By JokerMartini · 2011-05-03

Description

How do I get the controller property of the diffuse material on the selected object.

I know the simple solution here would be to just do a value change with Animate On but that can be buggy and I don't like doing that.


selfIll = $.material.diffuse.r.controller
newKey = addNewKey selfIll 10 #select
newKey.value = 10

Comments (5)

I'm trying to make it more streamline

JokerMartini · 2011-05-03

How can I access those key values without hard coding that particular key.


cRGB = Color_RGB()
$.mat.diffuse.controller = cRGB

addNewKey cRGB sliderTime #select
theSubCtrls = getXYZControllers cRGB
newKey = selectKeys theSubCtrls slidertime
print newKey
newKey[1].value = 0 --r
newKey[2].value = 1 --g
newKey[3].value = 0 --b

slowly getting closer I believe.

JokerMartini · 2011-05-03


cRGB = Color_RGB()
$.mat.diffuse.controller = cRGB
ctrlRGB = $.mat.diffuse.controller
ctrlRGB.r = (random 0 255)
ctrlRGB.g = (random 0 255)
ctrlRGB.b = (random 0 255)

Hmm...

Anubis · 2011-05-03

you asked for workaround with addNewKey()
but going with "ctrlRGB.r = (random 0 255)"
you back to the "animate on" method --

with animate on at time sliderTime ctrlRGB.r = (random 0 255)

..but if works well, why not? :)

try this

Anubis · 2011-05-03

cRGB = Color_RGB()
$.mat.diffuse.controller = cRGB

addNewKey cRGB 10 #select -- OK
addNewKey cRGB 20 #select -- OK

theSubCtrls = getXYZControllers cRGB --------------
theSubCtrls[1].keys[1].value = 10./255 -- 0.0392157
theSubCtrls[1].keys[2].value = 255./255 -- 1.0

Great

JokerMartini · 2011-05-03

That works great. Thanks Anubis,
I had tried several different ideas and none of them seemed to work.
Your solution how ever is just what i needed.
Thanks