Question about skin (texturing)swapping on chapter 16
by Jerry Moore · in Torque Game Engine · 03/22/2006 (7:05 pm) · 3 replies
As dumb as this sounds, I am asking one question why doesn't This work? I must be missing something. all I get is one texture in the dynamic field( no cycling of the texture but when I click on the dynamic fieldI get changing numerical value. It works for the traffic light because that was in the book. I have checked to see that the waterfall.dts is in the right folder and the texture I am trying to cycle from start.water.png to third.water.png.
basically I have four textures which are start.water.png, first.water.png, second.water.png, third.water.png.please help.
basically I have four textures which are start.water.png, first.water.png, second.water.png, third.water.png.please help.
$OFF_STATE = 0;
$GREEN_STATE = 1;
$YELLOW_STATE = 2;
$RED_STATE = 3;
datablock ItemData(TrafficLight)
{
category = "VariableSkinItems";
shapeFile = "~/data/shapes/traffic/trafficlight.dts";
DELAY[$OFF_STATE] = 10;
DELAY[$GREEN_STATE] = 15 * 1000;
DELAY[$YELLOW_STATE] = 2 * 1000;
DELAY[$RED_STATE] = 10 * 1000;
SKIN[$OFF_STATE] = "base";
SKIN[$GREEN_STATE] = "green";
SKIN[$YELLOW_STATE] = "yellow";
SKIN[$RED_STATE] = "red";
};
function TrafficLight::onAdd(%theDatablock, %whichLightPole)
{
%whichLightPole.rotate = false;
%whichLightPole.state = $OFF_STATE;
%whichLightPole.setSkinName(%theDatablock.SKIN[$OFF_STATE]);
%theDatablock.schedule(%theDatablock.DELAY[%whichLightPole.state],
"Sequence", %whichLightPole);
}
function TrafficLight::Sequence(%theDatablock, %whichLightPole)
{
%whichLightPole.state++;
if (%whichLightPole.state > $RED_STATE)
%whichLightPole.state = $GREEN_STATE;
%whichLightPole.setSkinName(%theDatablock.SKIN[%whichLightPole.state]);
%theDatablock.schedule(%theDatablock.DELAY[%whichLightPole.state],
"Sequence", %whichLightPole);
}
$START_STATE = 0;
$FIRST_STATE = 1;
$SECOND_STATE = 2;
$THIRD_STATE = 3;
datablock ItemData(WaterFall)
{
category = "VariableSkinItems";
shapeFile = "~/data/shapes/waterfall/waterfall.dts";
DELAY[$START_STATE] = 10;
DELAY[$FIRST_STATE] = 15 * 100;
DELAY[$SECOND_STATE] = 2 * 100;
DELAY[$THIRD_STATE] = 10 * 100;
SKIN[$START_STATE] = "wstart";
SKIN[$FIRST_STATE] = "wfirst";
SKIN[$SECOND_STATE] = "wsecond";
SKIN[$THIRD_STATE] = "wthird";
};
function WaterFall::onAdd(%theDatablock, %whichWaterFall)
{
//%whichWaterFall.rotate = false;
%whichWaterFall.state = $START_STATE;
%whichWaterFall.setSkinName(%theDatablock.SKIN[$START_STATE]);
%theDatablock.schedule(%theDatablock.DELAY[%whichWaterFall.state],
"Sequence", %whichWaterFall);
}
function WaterFall::Sequence(%theDatablock, %whichWaterFall)
{
%whichWaterFall.state++;
if (%whichWaterFall.state > $THIRD_STATE)
%whichWaterFall.state = $FIRST_STATE;
%whichWaterFall.setSkinName(%theDatablock.SKIN[%whichWaterFall.state]);
%theDatablock.schedule(%theDatablock.DELAY[%whichWaterFall.state],
"Sequence", %whichWaterFall);
}
#2
03/23/2006 (7:39 am)
Your texture names all have "w" in front of them in the datablock. do the texture filenames also begin with "w"?
#3
Notice his also:
rename your first texture to base and set the actual model file to point to this file then export again. From what I understand, when Torque loads a shapefile and finds a three part filename starting with 'base', it THEN assumes the file has multiple textures and will allow you to swop them.
I just got into the habit of always naming my textures base.whatever.jpg when I make my models, just in case I later want to change the skin, then I don't have to recompile my shapes.
04/05/2006 (6:19 am)
Well, actually, as I understand it as explained in the second edition of this book, the model's base texture must be called BASE.soemthing.something.Notice his also:
Quote:
SKIN[$OFF_STATE] = "base";
SKIN[$GREEN_STATE] = "green";
SKIN[$YELLOW_STATE] = "yellow";
SKIN[$RED_STATE] = "red";
rename your first texture to base and set the actual model file to point to this file then export again. From what I understand, when Torque loads a shapefile and finds a three part filename starting with 'base', it THEN assumes the file has multiple textures and will allow you to swop them.
I just got into the habit of always naming my textures base.whatever.jpg when I make my models, just in case I later want to change the skin, then I don't have to recompile my shapes.
Torque Owner Dracola
$OFF_STATE = 0; $GREEN_STATE = 1; $YELLOW_STATE = 2; $RED_STATE = 3; datablock ItemData(TrafficLight) { category = "VariableSkinItems"; shapeFile = "~/data/shapes/traffic/trafficlight.dts"; }; $DELAY[$OFF_STATE] = 10; $DELAY[$GREEN_STATE] = 15 * 1000; $DELAY[$YELLOW_STATE] = 2 * 1000; $DELAY[$RED_STATE] = 10 * 1000; $SKIN[$OFF_STATE] = "base"; $SKIN[$GREEN_STATE] = "green"; $SKIN[$YELLOW_STATE] = "yellow"; $SKIN[$RED_STATE] = "red"; function TrafficLight::onAdd(%theDatablock, %whichLightPole) { %whichLightPole.rotate = false; %whichLightPole.state = $OFF_STATE; %whichLightPole.setSkinName($SKIN[$OFF_STATE]); %theDatablock.schedule($DELAY[%whichLightPole.state], "Sequence", %whichLightPole); } function TrafficLight::Sequence(%theDatablock, %whichLightPole) { %whichLightPole.state++; if (%whichLightPole.state > $RED_STATE) %whichLightPole.state = $GREEN_STATE; %whichLightPole.setSkinName($SKIN[%whichLightPole.state]); %theDatablock.schedule($DELAY[%whichLightPole.state], "Sequence", %whichLightPole); }try that and look at you're console to see if you are getting errors.