PDA

View Full Version : switching textures


bman6200
02-29-2008, 06:49 PM
Hi,

I saw a thread here that talked about switching textures with an expressions connected to a ramp texture, but unfortunatly that thread was closed. I am trying to make a generic character that I will need to import multiple times and have control over each individual character's textures. I have the switching textures set up with this expression.

character.shader=character.texture;
if (character.shader==0)
{
// texture 1
setAttr "ramp_armyAntBody.colorEntryList[0].position" 1;
setAttr "ramp_armyAntBody.colorEntryList[1].position" 1;
setAttr "ramp_armyAntBody.colorEntryList[2].position" 0;
setAttr "ramp_armyAntHead.colorEntryList[0].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[1].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[2].position" 0;
}
else if (character.shader==1)
{
//texture 2
setAttr "ramp_armyAntBody.colorEntryList[0].position" 1;
setAttr "ramp_armyAntBody.colorEntryList[1].position" 0;
setAttr "ramp_armyAntBody.colorEntryList[2].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[0].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[1].position" 0;
setAttr "ramp_armyAntHead.colorEntryList[2].position" 1;
}
else if (character.shader==2)
{
//texture 3
setAttr "ramp_armyAntBody.colorEntryList[0].position" 0;
setAttr "ramp_armyAntBody.colorEntryList[1].position" 1;
setAttr "ramp_armyAntBody.colorEntryList[2].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[0].position" 0;
setAttr "ramp_armyAntHead.colorEntryList[1].position" 1;
setAttr "ramp_armyAntHead.colorEntryList[2].position" 1;
}


This expression works fine for just the original character in it's file. My problem is, if I import the same character a few times, that control will only effect the original character. I am trying to figure a way that each character's texture switching channel would control it's own textures and not the original character. I don't know if I explained that too well...

I appreciate the help,
Jason

Omita
02-29-2008, 08:51 PM
I can't take credit for it, but we do something like that but we created a custom shader that is applied to the texture. The shader code knows to look at the asset name, and in our case pulls the textures to use out of a database.

You might be able to have a model file, and scene file for each character and use a referance for the model, but apply a different texture per scene...

-H

greatPumpkin
03-01-2008, 06:35 PM
the simplest way probably is to include a generic version of your ramp texture in the character rig itself, (looks like you are connecting to it post import?) if it exists in every rig then you don't create the expression on the fly, you just look for that ramp node and set it per character with a mel proc.

something like (in this case you want to name your ramps specifically so you can find them later):

string $switcherRamps[] = `ls -type "ramp" "*characterSwitcher*`;
for($ramp in $siwtcherRamps)
{
// .. your if and else if strcuture goes here..

}

CGTalk Moderation
03-01-2008, 06:35 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.