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
Old 06 June 2007   #1
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?
 
Old 10 October 2007   #2
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.... :(
 
Old 10 October 2007   #3
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.
 
Old 10 October 2007   #4
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
 
Old 10 October 2007   #5
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;
}

__________________

 
Old 10 October 2007   #6
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 05:20 PM.


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