Game Development Community

Help with direction on player source

by Robert Kelley · in Torque Game Engine · 04/29/2008 (8:33 am) · 6 replies

I recently purchased this pack: (critter pack)
http://www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=13275

Now I have played in the script land of torque for a while, but I am not extremely versatile when it comes to the c++ source. I am trying to find some direction in how to implement the critters in this pack as playable items. It says "However, these models are not replacements for the default Torque biped player model. If you want to use them in stock Torque, you'll have to modify the player C++ source code."

So my question is, how do I implement this? Or atleast where do I start looking? I assume the player.cpp?


Thanks for all your help.

#1
04/29/2008 (10:17 am)
I would think that the pack would have come with the source or instructions on modifying the source. That's surprising that it doesn't.

It sounds like you're going to have to modify the spine so that it matches the skeleton used by this pack. I'm not sure if it would require anything else past this since I don't have it myself, but I can at least talk you through the spine modifications.

Fair Warning: We're going to be getting into the very nitty gritty of Torque here. Be sure to read through the whole post before attempting.

First you need to open up the models and determine what their spine nodes are. These will start from the root and go up to the head.
To give you an idea of what you're looking for these are the spine nodes of the default Torque Skeleton:
"Bip01 Pelvis"
"Bip01 Spine"
"Bip01 Spine1"
"Bip01 Spine2"
"Bip01 Neck"
"Bip01 Head"

After you've figured out what the spine nodes are we can start changing the source code.

First open up player.h, go to around line 30.

struct PlayerData: public ShapeBaseData {
   typedef ShapeBaseData Parent;
   enum Constants {
      RecoverDelayBits = 7,
      JumpDelayBits = 7,
      NumSpineNodes = 6,
      ImpactBits = 3,
      NUM_SPLASH_EMITTERS = 3,
      BUBBLE_EMITTER = 2,
   };

If the skeleton had more, or less, than 6 nodes in the spine then you'll need to change this enum to match whatever is in the skeleton.

Next, open up player.cpp/.cc (extension depends on the engine) and go to around line 340.

// Resolve spine
   spineNode[0] = shape->findNode("Bip01 Pelvis");
   spineNode[1] = shape->findNode("Bip01 Spine");
   spineNode[2] = shape->findNode("Bip01 Spine1");
   spineNode[3] = shape->findNode("Bip01 Spine2");
   spineNode[4] = shape->findNode("Bip01 Neck");
   spineNode[5] = shape->findNode("Bip01 Head");

Here is where the spine is defined, the root of the spine being in the 0 element of the array going in order to the top of it. Just replace the names of the nodes there with the names of the nodes in the skeleton that you're using. Once you've done that recompile and it should work, theoretically of course, again I don't have the pack or know what's in it so I can just give some general direction here.

Now, Torque does check for certain animations to exist when loading a model. If these are not defined then Torque may crash, or it may load the model and just throw up a warning. The names of these animations can be changed within the source code. However, since I don't know the contents of the pack, or the naming convention, let's just wait to cross that bridge until we come to it.

The above steps should get the models working within Torque in a quick and dirty fashion, but making changes like this to the Player class means ALL player models must follow this skeleton structure. Unless these critters are the only Player models in your game then you would be ok. If they're not, then what you would want to do would be to create a new Critter class that inherits from the Player class and make the changes in that class only. That way the two skeletons will be able to coexist. Keep in mind, I'm assuming that works, I haven't actually used two different skeleton structures together in Torque yet, but the theory is sound.

I tried to keep all this as simple as I could. I hope it helps, and doesn't overwhelm you too much. ;)
#2
04/29/2008 (10:55 am)
Thanks. I am going to digest this now and hopefully play with it tonight when I get home. I will keep you posted as to what happens.
#3
04/29/2008 (11:22 am)
What is the spine used for, by the way? I've been using player models that don't use the standard naming convention for spine nodes and they haven't given any major problems.
#4
04/29/2008 (4:18 pm)
This is the information I am looking for correct?


mavlock.googlepages.com/nodes.jpg
#5
04/29/2008 (5:16 pm)
I strongly doubt that any source modifications are needed to do this. Just make sure you have all the action animations, and you should be fine.
#6
04/29/2008 (8:29 pm)
Well I started the inquiry because the guy who made the pack says right on it that you need to modify the player source.

I will test it tomorrow to see what happens. Been a busy night scripting.