Game Development Community

SetSkinName Limits?

by Juan Aramburu · in Torque Game Engine · 06/01/2006 (8:19 pm) · 14 replies

Is there a limit as to how many times you can call the setSkinName() method on a StaticShape?

I have a trigger surrounding the ShapeBase, so that when the counter reaches a predetermined value, that setSkinName() is called. The values are 0, 15, and 30 for red, base, and blue, respectively. If a player is on the red team, the counter decrements; if on the blue team, it increments. The problem is that setSkinName() does not seem to work after one change.

For example, if I (a player on the red team) approach one shape that is currently neutral (value is 15, skin is base), when the onTickTrigger() decrements the trigger value 'til it reaches 0, setSkinName("red") is called & the texture correctly changes to the red one. However, once a blue team player comes along (only object inside trigger area) and the onTickTrigger() increments the trigger 'til it gets to 30, setSkinName("base") is called when it gets to 15, however, the red texture stays showing. And once the value ticks to 30, setSkinName("blue") is called, yet it still remains showing the red texture.

#1
06/16/2006 (2:40 am)
Bump.
#2
06/16/2006 (4:35 am)
There is no limit that I can personnally think of. Are you 100% sure you make the call from the correct side (server) and on the correct object ?
#3
07/12/2006 (6:45 pm)
Bump.

Single player mode.

Files are in:
~/data/shapes/rocks/
- rock1.dts
- base.rock1.jpg
- red.rock1.jpg
- blue.rock1.jpg

rock1.dts has base.rock1.jpg set as the texture in milkshape (1.7.8)

Trigger is named RockTrigger1

After starting up a mission, I do these manually in the console:

---------------------------
-> echo(RockTrigger1.getSkinName());
[returns nothing]

-> RockTrigger1.setSkinName("blue");
[says: mapping blue to index X]
skin is visually changed to blue

-> echo(RockTrigger1.getSkinName());
[returns blue]

-> RockTrigger1.setSkinName("red");
[says: mapping red to index X]
skin is NOT visually changed to red

-> echo(RockTrigger1.getSkinName());
[returns red]

-----------------------------

and yes, red.rock1.jpg is red, while blue.rock1.jpg is blue.

Like I said, it only seems to work one time. Please help.....
#4
07/12/2006 (7:17 pm)
Try changing it to red first.
that could identify whether it's a problem with red or a problem with order of ops..

i'll bet it's something besides the ordering.
i'm using the multi-skins-per-model resource, which basically relies on the standard skin-setting stuff,
and changed skins on a single object lots and lots and lots of times in a row.
#5
07/12/2006 (7:52 pm)
I can change to red or blue initially.

Also, I meant to say RockMarker1, instead of RockTrigger1.

RockMarker1 is a StaticShape, with a 'RockMarkerData' datablock, which is defined as:

datablock StaticShapeData(RockMarkerData) {
  shapeFile = "~/data/shapes/rocks/rock1.dts";
  
  skin="base";
  category = "ControlPointMarkers";
};
#6
07/12/2006 (8:47 pm)
Huh, weird.
i dunno, maybe someone else has an idea..

the .dts itself uses "base.rock1.jpg", right ?

like, when you load it up without including the skin="base" parameter, it uses base.rock1.jpg ?
#7
07/13/2006 (8:51 am)
Yes, base is used in the dts, hex editor confirms it

img297.imageshack.us/img297/830/bsr4ot.jpg
I tried to act like it had a nice name when I posted this thread even though the real name is in there...

I think the skin field in the datablock means nothing.
#8
07/13/2006 (8:59 am)
So,
this seems a little obvious, but,
your dts is using base.shittyRock.jpg, but you're trying to replace it with red.rock1.jpg ?
or was "rock1" just um, editing your filenames for posting on the forums? ;)
#9
07/13/2006 (9:05 am)
Quote:or was "rock1" just um, editing your filenames for posting on the forums? ;)

You got it.
#10
07/13/2006 (9:11 am)
So I did a little debugging:

basically why nothing is changed is because of this (my comments in bold):

//setskinname sets the skinning mask bit dirty, which goes through the packupdate/unpackupdate
//til we get here:

//TSShapeInstance::reSkin(), this is inside a for that loops through all materials:

const char* pName = pMatList->mMaterialNames[j];

bool replacedRoot = makeSkinPath(pathName, NAME_BUFFER_LENGTH, resourcePath,
                          pName, defaultBaseName, newBaseName);

//...and eventually (multiple ifs in-between, but they all do this):

pMatList->setMaterial(j, pathName);

static bool makeSkinPath(char* buffer, U32 bufferLength, const char* resourcePath,
                         const char* oldSkin, const char* oldRoot, const char* newRoot) {

//...
      dStrcpy(buffer, oldRoot);    //[b]this copies defaultBaseName ('base') to the buffer[/b]
      dStrcat(buffer, ".");
      rootStart = dStrstr(oldSkin, buffer);  //[b]this sees if the defaultBaseName is part of the[/b]
                                             // [b]current skin[/b]
      if (rootStart == NULL) {
         replacedRoot = false;   //[b]this flag changes everything[/b]
      }
//...

   if (replacedRoot) {                             //[b]this moves the NEW skin name into the buffer[/b]
      // Then the pre-root part of the old name:
      dsize_t rootStartPos = rootStart - oldSkin;
      if (rootStartPos != 0) {
         dStrncat(buffer, oldSkin, rootStartPos);
      }
      // Then the new root:
      dStrcat(buffer, newRoot);
      dStrcat(buffer, ".");
      // Then the post-root part of the old name:
      dStrcat(buffer, oldSkin + rootStartPos + oldRootLen + 1);
   }
   else {
      // Then the old name:                                 [b]This says, just use the old skin[/b]
      dStrcat(buffer, oldSkin);
   }

So the problem is, if the new skin name doesn't contain "base.", nothing gets changed (I think?)
#11
07/13/2006 (9:42 am)
Huh.



well i just tried it in the stock TGE 1.4 demo and it worked fine, so don't think there's any need to modify the engine to get this to work. i'd recommend keep looking in your model & script & images.

elenzil.com/gg/setskintest/w000base.jpgelenzil.com/gg/setskintest/w000red.jpgelenzil.com/gg/setskintest/w000blue.jpg
here's the milkshape file and other source files i used:setskintest.zip

- you'll have to figure out where to put them in your torque folder heirarchy, but it's not hard.
start with flag.cs. note these files are for the stock TGE 1.4 *demo*, not the SDK.
#12
07/13/2006 (9:51 am)
Thanks, I'll try your stuff out. If it does work, then I'll know it's not the engine.
#13
07/13/2006 (10:15 am)
Didn't work...

and I'm gonna confess...I've been working with TSE, but it seems no one ever visits those forums, so most things I just come to TGE (though I have both). So it must be a TSE-specific thing...

However, it did work in TGE....
#14
07/13/2006 (10:31 am)
Weird.
maybe try your rock in tge ?