How to key R,G,B of diffuse Mat

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

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
JokerMartini's picture

I'm trying to make it more streamline

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

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

JokerMartini's picture

slowly getting closer I believe.

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)

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Anubis's picture

Hmm...

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? :)

my recent MAXScripts RSS (archive here)

Anubis's picture

try this

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

my recent MAXScripts RSS (archive here)

JokerMartini's picture

Great

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

John Martini
Digital Artist
http://www.JokerMartini.com (new site)

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.