Game Development Community

Replacing Player Model

by Jason Arthur · in Artist Corner · 04/16/2007 (12:37 pm) · 13 replies

I have been trying unsuccessfully to replace the HumanMaleAvatar model. I have read everything I could find and am still not sure how to do this. Can anyone direct me to a tutorial on how to do this? Thanks.

#1
04/16/2007 (2:01 pm)
Hi Jason,
Are you trying to create a new model from scratch, or do you already have a model that you know works (like the Soldier Pack or Adam/Ava Packs)?

Assuming you have a new model that you know is working, and it has the same bone structure as the standard Torque skeleton, it's as simple as replacing a filename or two. In \server\scripts\player.cs, you'll see this code:
datablock PlayerData(PlayerBody)
{
   renderFirstPerson = false;
   emap = true;
   
   className = Armor;
   shapeFile = "~/data/shapes/player/player.dts";
   cameraMaxDist = 3;
   computeCRC = true;
   ...

Change the shapeFile= line to point to your new model.

At the beginning of that same .cs file, there's a line that reads
// Load dts shapes and merge animations
exec("~/data/shapes/player/player.cs");

That file -- /player/player.cs -- contains definitions for your character's animations, as well as another reference to the model that you'll have to change. Open it up, and change the baseShape= line to point to your new player model. The rest of the entries, with .dsq extensions, are your character's animations. If you leave those alone, then your character will use all of Kork's standard animations.

Hope that helps!

-- John
#2
04/16/2007 (2:34 pm)
John

Thanks for the reply.
I am using the soldier pack model which I have used successfully for my AI players.
The soldier pack model is named player.dts so I swapped it out with the old player.dts file,
so it would seem to me that everything should point to the correct file.
I am not using starter.fps as my base, i am using emaga 6 which came with the book by Kenneth Finney so not all of my folder/file structure is the same.
The reason that I mention this is that in my player/player.cs file I don't find the baseshape= line.
Also, the error that I get in the console log seems to reference the source code:


Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'run'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'back'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'side'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'fall'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'jump'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'standjump'!
Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'land'!
Could not locate texture: control/data/models/avatars/beast/base.lmale
Could not locate texture: control/data/models/avatars/beast/base.lmale

So that is where I am at. I am going to keep working at it, but any additional suggestions would be appreciated.

Thanks.
#3
04/17/2007 (10:20 am)
Still stuck, any suggestions?
#4
04/17/2007 (10:47 am)
The TSShapeConstructor should look something like this.

datablock TSShapeConstructor(PlayerDts)
{
   baseShape = "./player.dts";
   sequence0 = "./player_root.dsq root";
   sequence1 = "./player_forward.dsq run";
   sequence2 = "./player_back.dsq back";
   sequence3 = "./player_side.dsq side";
   sequence4 = "./player_lookde.dsq look";
   sequence5 = "./player_head.dsq head";
   sequence6 = "./player_fall.dsq fall";
   sequence7 = "./player_land.dsq land";
   sequence8 = "./player_jump.dsq jump";
   sequence9  = "./player_diehead.dsq death1";
   sequence10 = "./player_diechest.dsq death2";
   sequence11 = "./player_dieback.dsq death3";
   sequence12 = "./player_diesidelf.dsq death4";
   sequence13 = "./player_diesidert.dsq death5";
   sequence14 = "./player_dieleglf.dsq death6";
   sequence15 = "./player_dielegrt.dsq death7";
   sequence16 = "./player_dieslump.dsq death8";
   sequence17 = "./player_dieknees.dsq death9";
   sequence18 = "./player_dieforward.dsq death10";  
   sequence19 = "./player_diespin.dsq death11";
   sequence20 = "./player_looksn.dsq looksn";
   sequence21 = "./player_lookms.dsq lookms";
   sequence22 = "./player_scoutroot.dsq scoutroot";
   sequence23 = "./player_headside.dsq headside";
   sequence24 = "./player_recoilde.dsq light_recoil";
   sequence25 = "./player_sitting.dsq sitting";
   sequence26 = "./player_celsalute.dsq celsalute";
   sequence27 = "./player_celwave.dsq celwave";
   sequence28 = "./player_standjump.dsq standjump";
   sequence29 = "./player_looknw.dsq looknw";
};

baseShape should be the first line in the constructor.

Also, little known fact, there's a naming convention that goes along with the TSShapeConstructor. Notice how the name given to the shape in the constructor is PlayerDts and the shape file is called player.dts. The name of the given to the shape in the constructor needs to match the name of the shapefile. This is how Torque registers the shape with the constructor. Upper and lower case don't really make a difference.
#5
04/17/2007 (10:59 am)
IN Shapes/Player/
Player.cs contains all the animation names and files.
If you only updated your player but not the player.cs then thats the reason for the errors.

You should copy over the entire soldier pack folder.
#6
04/17/2007 (1:00 pm)
First, thanks for the reply. It always amazes me how helpful people are in these forums.
But here is the problem.
If you look at starter.fps data/shapes/player you have a player.cs file and the associated dsq, dts, and png files.
If you look at emaga 6 (from Kenneth Finney book) data/models/avatars/human and all you have is the dts and png file. No player.cs file, no dsq file. If you look at the emaga6 data/models/avatars/beast folder it is set up just like the player folder from starter.fps(dts file, player.cs file, associated dsq).
I have searched every folder and I can't find the TSShape Constructor and if you look at the error I'm getting in the console log it seems like it references the source code. Is it possible that the animations are coded in the source? and if so any idea how I address that?
I have been working on this Emaga 6 code for about two years and I am close to having a finished product so I dont want to switch to the starter.fps but right now I'm sort of at a loss.
So I guess my question is, if all you have is a dts and png file in your player folder where are the animation names and files? the source code?
#7
04/17/2007 (3:16 pm)
You may have to trace the problem. I've been using starter.fps as a base, and its ~/server/script/player.cs (the actual player datablock) has an exec to '~/data/shapes/player/player.cs', the file with all the animations.

I just skimmed through my copy, and I don't see any reference to animations in the book- at all. Maybe his models had them in the DTS, I dunno. You should be able to just add that exec line (like in the starter.fps's player.cs) to your player.cs, put the file with the sequence info where it should be (with the model, or in a seperate animation folder, where ever you like).

Hope this helps.
#8
04/17/2007 (3:33 pm)
@Jason,
Unfortunately, I've misplaced the CDs from the Finney books, and I don't recall how they were set up.

Basically, you've got two ways of setting up animations. You can embed them in the DTS, or you can make separate DSQ files that contain only the animations. (The second approach is usually the better option, as you can share animations among any shapes that have the same skeletal structure.)

Try opening the DTS in ShowTool, and then pull down the "sequences" dropdown. If there are sequences listed there, they've been embedded in the DTS file. Otherwise, do a search for files containing "DSQ", and see if you can find where they're referenced in Ken's examples.

Another possibility is that the character in Emaga has been designed to work with the animations from Kork. I'm betting it's a standard Torque biped, so you can probably grab Kork's animations, drop them in your new character's folder, and set up your TSShape like Scott's example.

There's a 3DGPAIO forum here, too, and that might be a good place to poke around.

@Scott: Wow, I never knew that! I guess I've been lucky that I didn't get creative with my player model names. =D
#9
04/17/2007 (3:56 pm)
Ok. I deleted the old player DTS file, which should eliminate any problems from embetted animations since the dts file is gone.
Then I inserted the soldier pack dts and associated files and changed my server/player.cs file to match the player.cs file in starter.fps, ran the game, and crashed. But it seemed to get a little further before crashing.
When it crashes and I examine the console log the only new lines are the ones that say:

Warning: (c:\fish beta\engine\game\player.cc @ 290) PlayerData::preload - Unable to find named animation sequence 'run'!

So somehow the animations called for in the source code are not matching up, it appears.
Right now I edited the player file in the game engine and am rebuilding the SDK, so hopefully this will work.

If anyone knows what this warning means your input would be appreciated.

Also, in case this doesnt work, if anyone thinks they can fix this problem and would like to do so for compensation please contact me.
I'll also be checking out the 3dgpaio forum.
Thanks for all the help.
#10
04/17/2007 (4:04 pm)
I believe at the time of Ken's book, dsq fileTypes weren't supported thru Milkshape, which is what generated the baseMale figure he uses to demostrate the playerAvatar, while making Kork the AI... That would explain why there is no Constructor script. You'll need to make one and exe it, like the player example, if you've produced dsq's for your shape. HTH. Make sure the Constructor script has named the forward animation run, like the script, this is the 'final' place to 'name' the sequence. But you're recompiling, so it's hard to say...

The errors look as though they're from not locating the stock SDK sequences in hard code...especially if you're using an old version. You're player needs those to work correctly. name your sequences along those namingConventions and it should work, although that codeBase is quite old at this point, TGE generation wise.
#11
04/17/2007 (4:11 pm)
This may be a stupid question but did you delete all your DSO's after changing scripts?

Adding the soldier model really shouldn't crash the engine if you
1) are using stock TGE and
2) are following the directions to the T

Its got to be a problem with the scripts. The soldier pack should have came with a player.cs to overwrite the stock one, content packs are usually "drag and drop" installs.

I would try a fresh install of TGE (to a new folder) and going step by step, checking your work, figuring out exactly which step it is catching on.

Hope this helps.

- Ed Johnson
#12
04/17/2007 (4:28 pm)
Problem solved!!!!!!

In case anyone wants to know:

I believe the animations were embetted in the original DTS file.
So I inserted the soldier pack DTS and DSQ's but when I changed my server/player.cs file to match the one in starter.fps I mislabeled the path for my exec line.

No stupid questions, just stupid newbies.

Thanks for all the help.
#13
04/18/2007 (6:15 am)
Glad you got it working Jason.

@ John

Yeah, I think that's why it's such a little known thing. I only stumbled upon it by accident about a year or so ago.