View Full Version : Changing Materials throught a Ctrl
ZeroCartin 06-08-2007, 05:57 AM Well, ive been workin on a rig for a character of mine, and i wanted to be able to change the entire shader of a couple of objects with just switching "on" or "off" on an attribute on a controller object. For example:
if (Ctrl.Shader = 1)
object1.shader = dilectricshapenode
else
object1.shader = blinn1;
For example. *i know the code doesnt make sense, lol, just for reference*
Ive been watching the script editor when i assign a shader to an object, but the code there doesnt seem to work on the Expression editor... any ideas?
|
|
marckury
10-03-2007, 07:05 PM
im searching the same, with an attribute can say when attrb is 0 assign this shader when its 1 assign that... I have tested some things but nothing works.... :(
If you're not using a GUI, you're going to have to use a scriptJob in combination with mel scripts. **Edit: Make sure you read the docs on scriptJobs, they can be dangerous.
So this:
scriptJob -attributeChange mySphere.customAttribute shaderChangingProcedure;
And in your procedure, just do an if/else statement querying the value of mySphere.customAttribute
yep the script job is the way to go.
as well, another way would be to plug all the shaders through a layered shader
and use the driven key to switch the layerOpacity based on your ctrl.shader
Segmoria
10-05-2007, 01:13 PM
As Norb already pointed out, you could also use a simple GUI for this.
Something like this:
{
window -h 30 -w 40;
columnLayout;
checkBox -label "Toggle material"
-cc "if (`checkBox -q -v checkbox1`==0) hyperShade -assign matBlue; else hyperShade -assign matGreen;" checkbox1;
showWindow;
}
CGTalk Moderation
10-05-2007, 01:13 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2013, Jelsoft Enterprises Ltd.