Game Development Community

Efficiency? Multiple skins or multiple .DTS's

by Infinitum3D · in Torque Game Engine · 09/17/2008 (1:02 pm) · 6 replies

I'm using script to load a single .DTS with multiple skins, however each and every skin needs it own datablock and function.

Is this still more efficient than creating multiple .DTS's with their own skins?

I have a simple ambient animated flag. Should I use the script to skin it, or export it "pre-skinned"?

I can do it either way, but I don't want to waste processor resources. I prefer to change the skins in script, so I can add/ remove skins at will.

Comments?

Tony
I3D

#1
09/17/2008 (1:57 pm)
If you're referring to the "mesh hiding" resource,
there is no render-time overhead for meshes which are not currently shown.
#2
09/17/2008 (3:14 pm)
Thanks Orion for responding. Not meshes I'm using a resource by Leslie Young (Xyber) which allows you to set the texture in script. "Change items skin (texture)"

base.item.png
tex1.item.png
tex2.item.png
tex3.item.png etc...

So each .dts has a texture called base.WHATEVER.png, and my textures are named tex1.flag.png, tex2.flag.png, etc.

My datablock uses StaticShapeData(flag1Shape), and loads flag.dts. Flag2Shape, flag3shape, etc all load the same flag.dts and

skin = "tex1";

This way, in my Shapes folder (in the World Editor Creator) it lists flag1, flag2, etc, and each has a different texture.

The only benefit to doing it this way (rather than having dozens of flags with their own texture) is that I only have to export a single .dts and I can skin it in script. BUT, I don't want to use processor ability unnecessarily, so I'm wondering if one way is more of a resource hog than the other.

Tony
#3
09/17/2008 (11:05 pm)
I think the best way to go is reskinning dts's. Granted you have a little more scripting too do, but I think in the long run it pays off. As far as I know it doesn't hog resources. I recently made a target range for the mech starter kit. When a target is shot, it falls down, gets a random skin placed on it and then gets stood back up. I've went along with the mech's gatling gun and shot about 30 targets. There didn't seem to be any dip in performance. Just my 2 cents.
#4
09/18/2008 (5:17 pm)
Thanks, Britt!.

My skinning code works well, but if you could post your "random skin" selection code, I'd greatly appreciate it.

Tony
#5
09/18/2008 (6:13 pm)
function ShootableTarget::damage(%this, %obj, %sourceObject, %position, %damage, %damageType)
{
     %obj.applyDamage(%damage);
   if(%obj.getDamageLevel() >= %obj.maxDamage)        
   {
      %obj.playThread(0,"Spin");                      ////REF: Play Target fall animation
      //warn("Target Hit!!!"); 
      %obj.schedule(5000, "playThread", 0, "Reset");        //warn("Target Resetting...");
      //Random Skin//
         %skin = getRandom(2);                        ////REF: First, get a random number between 0 and 2
         switch(%skin)                                ////REF: Pick a skin to apply based on the random number
         {
            case 0: //Base Skin
               %obj.schedule(2500, "setSkinName", "base"); ////REF: Apply new skin while its hidden from view
               //echo("Target Skin set to Base");
            case 1: //Kork Skin
               %obj.schedule(2500, "setSkinName", "Kork"); ////REF: Apply new skin while its hidden from view
               //echo("Target Sking set to Kork");
            case 2: //Elf Skin
               %obj.schedule(2500, "setSkinName", "Elf"); ////REF: Apply new skin while its hidden from view
               //echo("Target Sking set to Elf");
         }//End Random Skin
   }
}
#6
09/19/2008 (5:26 pm)
Thanks! I'm still not used to the syntax of 'conditionals'. This is a big help. getRandom and a Switch. I think I can handle that.

Tony