Changing Materials throught a Ctrl

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
  06 June 2007
Changing Materials throught a Ctrl

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?
 
  10 October 2007
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.... :(
 
  10 October 2007
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

Last edited by Norb : 10 October 2007 at 04:55 PM.
 
  10 October 2007
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
 
  10 October 2007
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;
}

__________________

 
  10 October 2007
Thread automatically closed

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.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
Thread Closed share thread



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright 2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 09:34 PM.


Powered by vBulletin
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.