possible to add new skins to existing model ? [solved]
by Jeff Yaskus · in Torque 3D Beginner · 12/06/2011 (3:03 pm) · 1 replies
I've been reading through the online documentation and trying to add multiple skins for a robot model.
It has only (1) skin by default and its mapped to "body".
How do I re-map the skins, if its not originall mapped to "base_body" ???
I created new skins and set them up in the material.cs file
The online docs suggest something like this ... but doesnt work;
It has only (1) skin by default and its mapped to "body".
How do I re-map the skins, if its not originall mapped to "base_body" ???
I created new skins and set them up in the material.cs file
singleton Material(robot_high_body)
{
mapTo = "body";
diffuseMap[0] = "art/shapes/actors/gatbot/robot_diffuse.png";
normalMap[0] = "art/shapes/actors/gatbot/robot_normal.png";
specularMap[0] = "art/shapes/actors/gatbot/robot_specular.png";
diffuseColor[0] = "1 1 1 1";
specular[0] = "0 0 0 1";
specularPower[0] = 100;
pixelSpecular[0] = false;
emissive[0] = false;
doubleSided = false;
translucent = false;
translucentBlendOp = "None";
};
// custom skins //
singleton Material(robot_high_body_base : robot_high_body)
{
mapTo = "base_body";
diffuseMap[0] = "art/shapes/actors/gatbot/base_diffuse.png";
};
singleton Material(robot_high_body_redhand : robot_high_body_base)
{
mapTo = "redhand_body";
diffuseMap[0] = "art/shapes/actors/gatbot/redhand_diffuse.png";
};
singleton Material(robot_high_body_blackwolf : robot_high_body_base)
{
mapTo = "blackwolf_body";
diffuseMap[0] = "art/shapes/actors/gatbot/blackwolf_diffuse.png";
};The online docs suggest something like this ... but doesnt work;
%obj.skin = "body=base_body";
About the author
Long time gamer, hacker and programmer. With dreams of making video games -
Torque Owner Jeff Yaskus
jy games
So first I tried to "turn on" the skinning by using the following suggested command;
%obj.setSkinName( "body=base_body");
Then, try to set the skin like thus;
%obj.setSkinName( "base=redhand");
... which didn't work for me.
Thought it needed all the commands at once like ;
%obj.setSkinName( "body=base_body;base=redhand");
But that only half worked - it changed the skin, but to "redhand" and not "redhand_body" ... so it showed up in "prison colors" (bright orange)
SO -- I just hard-coded a solution ... "body=<newSkin>_body" or such.
Works like a charm!
Here is the code I used, when spawning the object as an AIPlayer ... for player spawning, see gameCore:: to see how it does this already for the player.
This code runs from scripts/server/... so its server side.
// Determine which character skins are not already in use %availableSkins = %player.getDatablock().availableSkins; // TAB delimited list of skin names (on Player datablock) // Choose a random, unique skin for this client %count = getWordCount(%availableSkins); %newSkin = getWord(%availableSkins, getRandom(%count)); // fix for robot // if ( %block $= "gatbotPlayerData" ) %newSkin = "body=" @ %newSkin @ "_body"; // this affects the marker only // %taggedSkin = addTaggedString( %newSkin ); %obj.skin = %taggedSkin; // this should change the AIplayer object itself // %player.setSkinName( %newSkin );EDIT:
Found this little tid-bit at the bottom of the Torque Artist Primer;
"Note that since only the most recently applied skin update is stored in the skin field, models that require several material target changes (eg. to separately change the armor, skin and face Materials of a character) should apply them all at once using the semicolon delimited format shown above rather than successive calls to setSkinName. Otherwise when the mission is saved or new clients join the server, only the most recently applied skin update would be used."