Custom Shape Mod
by Duncan Gray · 04/03/2005 (9:43 am) · 84 comments
Download Code File
This resource still works in TGE 1.51 if you copy/past from the included pdf file.
This mod involves applying scaling factors to vertices according to the bone nodes to which they are attached. Basically you select a bone, select a scaling factor for x,y,z and those scaling factors get stored in a vector list which is instanced for each character/vehicle/shape. Additionally, the scaling is fully ghosted on the clients making it possible for each player to enter the game with his own unique character proportions, visible to all other players.
It's thus also possible to dynamically scale body proportions while mid game. So if a player bumps his head, you can make his head swell up etc.
The idea is to let the user scale his character proportions which then get saved in prefs. When he joins a game, his details get sent to the server which then ghosts the character settings to all the clients.
It's not only of use for characters. The mod is done mostly in shapebase.cc which is the base class for all shapes. Therefore, in theory, you can make trees, vehicles etc and scale sections of the shape as long as you place a "bone" in that area and assign a vertex group to the bone. You will then be able to select that bone and scale the participating verticies dynamically, at run time, from script which can add a whole new element to your game.
[Edit]
Updated the readme.txt with notes about TGE 1.4
[edit]
For a solution to the "floating above ground" problem, go here
SCREENSHOTS
[edit]
I also made an update, in the shapebase.cc section, use the following rather than the version in the pdf
That will let you do server script based (or console) scaling by issuing the setScalePerBone(bla) command.
You don't need all the guiplayerview changes if you only want to scale from server script. Example, when a player spawns, give a random 30% scale change to relevant body parts so that all players look a little different from each other.
This resource still works in TGE 1.51 if you copy/past from the included pdf file.
This mod involves applying scaling factors to vertices according to the bone nodes to which they are attached. Basically you select a bone, select a scaling factor for x,y,z and those scaling factors get stored in a vector list which is instanced for each character/vehicle/shape. Additionally, the scaling is fully ghosted on the clients making it possible for each player to enter the game with his own unique character proportions, visible to all other players.
It's thus also possible to dynamically scale body proportions while mid game. So if a player bumps his head, you can make his head swell up etc.
The idea is to let the user scale his character proportions which then get saved in prefs. When he joins a game, his details get sent to the server which then ghosts the character settings to all the clients.
It's not only of use for characters. The mod is done mostly in shapebase.cc which is the base class for all shapes. Therefore, in theory, you can make trees, vehicles etc and scale sections of the shape as long as you place a "bone" in that area and assign a vertex group to the bone. You will then be able to select that bone and scale the participating verticies dynamically, at run time, from script which can add a whole new element to your game.
[Edit]
Updated the readme.txt with notes about TGE 1.4
[edit]
For a solution to the "floating above ground" problem, go here
SCREENSHOTS
[edit]
I also made an update, in the shapebase.cc section, use the following rather than the version in the pdf
ConsoleMethod( ShapeBase, setScalePerBone, void, 6, 6, "ShapeBase.setScalePerBone( x, y, z , bone-index )" )
{
argc;
Point3F scale;
S32 boneNdx = dAtoi(argv[5]);
TSShapeInstance* si = object->getShapeInstance();
scale.set(strtod(argv[2],(char **)NULL),strtod(argv[3],(char **)NULL),strtod(argv[4],(char **)NULL));
si->setScalePerBone( scale, boneNdx );
char DNA[20];
dSprintf(DNA,sizeof(DNA) ,"%03u %1.2f %1.2f %1.2f" ,boneNdx,scale.x,scale.y,scale.z);
object->setDNA(DNA);
}That will let you do server script based (or console) scaling by issuing the setScalePerBone(bla) command.
You don't need all the guiplayerview changes if you only want to scale from server script. Example, when a player spawns, give a random 30% scale change to relevant body parts so that all players look a little different from each other.
About the author
#2
The log says "starter.fps/client/scripts/optionsDlg.cs (49): PlayerView::setModel - wrong number of arguments."
[quote]Note: I
04/03/2005 (11:48 am)
I just finished adding this to the engine, and it crashes when I load the options dialog.The log says "starter.fps/client/scripts/optionsDlg.cs (49): PlayerView::setModel - wrong number of arguments."
[quote]Note: I
#3
04/03/2005 (10:09 pm)
Hi Robert, I emailed them to you. I will update the zip file to include them when I have a chance.
#4
04/03/2005 (11:37 pm)
This is indeed a very interesting resource...
#5
04/04/2005 (9:36 am)
Duncan - this Looks very interesting. Hope you have time to update the zip file soon>
#6
04/04/2005 (10:33 am)
Cool resource. Thanks for posting it.
#7
Here is a link showing the mod in action.
04/04/2005 (1:46 pm)
I have not worked on this since December but I checked and the zip file does contain the guiPlayerView.cc files, so it should all be working fine. It compiles and runs clean on my system so I guess if you have problems it may just require some minor debugging on your part.Here is a link showing the mod in action.
#8
I will let you know if it come from the ressource or not.
04/13/2005 (2:03 am)
Got it working nicely with the PlayerView. But it crash at mission load (invalid packet). I will let you know if it come from the ressource or not.
#9
Once that's in, it work perfectly. Again great ressource.
04/13/2005 (5:27 am)
Ok, fault was mine I somewhat forgot the change in shapeBase.cc for unpack. Once that's in, it work perfectly. Again great ressource.
#10
04/13/2005 (1:42 pm)
Thanks Claude
#11
04/14/2005 (10:50 am)
I have an idea for a possible use for this mod, mind if I adapt it and use it in my MMORPG tutorials?
#12
Just give credit where credit is due so that good karma and pleasant thoughts comes my way.
04/14/2005 (2:19 pm)
Help yourself Dreamer. This mod has many uses far beyond what I provided here and I would expect imaginative people to adapt it to their needs. Just give credit where credit is due so that good karma and pleasant thoughts comes my way.
#13
It's coming from GuiPlayerView::FindNode
Thats about all the information I can get from my Back Trace.
My implementation consisted of downloading your resource, copying the engine directory over my current one (I checked and we didn't have any conflicting files), then copying the optionsdlg.gui and optionsdlg.cs to their respective places.
Any help here would be greatly appreciated.
*update*
NM I'm a little blind today... Found this in the OptionsDlg.cs
p.s. Yes I completely cleared all of my .dso's
04/15/2005 (9:46 am)
Ok I've implemented this resource and am getting a segfault as soon as I hit the options button on my main menu.It's coming from GuiPlayerView::FindNode
Thats about all the information I can get from my Back Trace.
My implementation consisted of downloading your resource, copying the engine directory over my current one (I checked and we didn't have any conflicting files), then copying the optionsdlg.gui and optionsdlg.cs to their respective places.
Any help here would be greatly appreciated.
*update*
NM I'm a little blind today... Found this in the OptionsDlg.cs
%playerModel = $userMods @"/data/shapes/player"; PlayerView.setModel(%playerModel @ "/player.dts", "", %playerModel @ "/player_forward.dsq" );My orc ain't sittin there anymore :)
p.s. Yes I completely cleared all of my .dso's
#14
In tsShape.h
The findName function looks like this in tsShape.cc
If your player shape has different bone names to the ones I provided in the OptionsDlg.cs findThisNode function calls, then you need to change the OptionsDlg.cs to match your shape. Check between lines 58-80 in OptionsDlg.cs
If thats the cause then a more long term solution would be to make the findName method more robust.
It could also be that the findName method, on NOT finding a match, returns a negative number to my U32 method in GuiPlayerView.cc as shown below
04/15/2005 (1:55 pm)
I recall having a similar segfault when I swopped player models during testing. I don't know if your segfault has the same cause but here goes.In tsShape.h
S32 findNode(const char * name) const { return findNode(findName(name)); }The findName function looks like this in tsShape.cc
S32 TSShape::findName(const char * name) const
{
for (S32 i=0; i<names.size(); i++)
if (!dStricmp(name,names[i]))
return i;
return -1;
}Those are both original TGE source so if it's giving you a segfault I assume it must be getting a name which does not exist in it's node list or a NULL.If your player shape has different bone names to the ones I provided in the OptionsDlg.cs findThisNode function calls, then you need to change the OptionsDlg.cs to match your shape. Check between lines 58-80 in OptionsDlg.cs
If thats the cause then a more long term solution would be to make the findName method more robust.
It could also be that the findName method, on NOT finding a match, returns a negative number to my U32 method in GuiPlayerView.cc as shown below
U32 GuiPlayerView::findNode( const char *name )
{
TSShape* shape = mModel->getShape();
return shape->findNode(name); //"Bip01 Pelvis" etc
}In which case it should be made a S32 which would solve the segfault but you would still need to match the bone names to your player model to get any real joy.
#15
The included pdf lists some minor but VITAL script changes which pass your player settings to the server. Check and implement the instructions on the last page of the pdf.
At the bottom of the OptionsDlg.cs file is the following note.
04/15/2005 (2:44 pm)
IMPORTANT - to everyone implementing this mod The included pdf lists some minor but VITAL script changes which pass your player settings to the server. Check and implement the instructions on the last page of the pdf.
At the bottom of the OptionsDlg.cs file is the following note.
//IMPORTANT !! // mainmenu.cs calls the options screen as a dialog. // You MUST change it to a set canvas call as shown below // Change the command string of your options button on the mainmenu as below // // command = "Canvas.setContent(optionsDlg);";Make sure to do that or your GUI may/will crash/hang when you exit the Options Dialog screen
#16
I had already fixed the segfault problem, but yes you are right, it was getting an invalid filename.
As to your other part about SetContent, I'm not noticing any issues with the Canvas.PushDialog rather than Canvas.SetContent, but thanks for the heads up, that type of thing always tends to keep me up for 3-4 days while I track down the problem.
04/15/2005 (11:25 pm)
@Duncan, thanx for the reply but what I meant by "My orc ain't sittin there anymore :)" was simply, "I moved my orc to a different location. doh!"I had already fixed the segfault problem, but yes you are right, it was getting an invalid filename.
As to your other part about SetContent, I'm not noticing any issues with the Canvas.PushDialog rather than Canvas.SetContent, but thanks for the heads up, that type of thing always tends to keep me up for 3-4 days while I track down the problem.
#17
Here is my log.
I say random because this doesn't happen everytime, maybe one in 5-10.
04/18/2005 (3:29 pm)
I have found a randomly occuring error, after I enter the game and change something say my players Head size, and the mission changes to the next mission, I get the infamous (You cannot play this mission due to incorrect version of starter.fps), in the console log I get invalid packet!.Here is my log.
Connection error: Invalid packet GameBase::unpackUpdate(). Issuing Disconnect packet.
I say random because this doesn't happen everytime, maybe one in 5-10.
#18
I'm not that familiar with the finer details of the pack-unpack process. i.e. is it possible that the client will try to unpack something which the server has not packed... perhaps the server "SkinMask" got reset when the game restarted, but the client still thinks it needs to unpack something.
Perhaps it's a question for the engine forums. Sorry I can't be of more help this time but if you solve the problem please post the solution here for others to see.
04/18/2005 (5:12 pm)
I have not had that error myself but then for my purposes, I only setup the character at game start as I have not had the need to adjust scale mid game. In theory it should make no difference. I have also been busy with other projects so perhaps have not used the mod sufficiently to see this error.I'm not that familiar with the finer details of the pack-unpack process. i.e. is it possible that the client will try to unpack something which the server has not packed... perhaps the server "SkinMask" got reset when the game restarted, but the client still thinks it needs to unpack something.
Perhaps it's a question for the engine forums. Sorry I can't be of more help this time but if you solve the problem please post the solution here for others to see.
#19
I tracked my invalid packet problem, it's not quite what I was thinking.
It appears that at least in my particular instance, that $Pref::Player::DNA is always NULL, what I have been seeing as changes are happening client side only, this means that the server is updating DNA to a NULL value at the SendDNA command, and for some reason takes it's sweet time about sending the update to the client, thus causing the issue.
Now all I've got to figure out is WHY that value isn't being created, any hints on where to look that I may have possibly hosed up?
Looking through my entire code base it does appear that there is no place in any script or GUI that creates this value. Maybe I deleted it by accident when adjusting your code to use the various player models that I have.
04/18/2005 (11:18 pm)
Ok brace yourself for this...I tracked my invalid packet problem, it's not quite what I was thinking.
It appears that at least in my particular instance, that $Pref::Player::DNA is always NULL, what I have been seeing as changes are happening client side only, this means that the server is updating DNA to a NULL value at the SendDNA command, and for some reason takes it's sweet time about sending the update to the client, thus causing the issue.
Now all I've got to figure out is WHY that value isn't being created, any hints on where to look that I may have possibly hosed up?
Looking through my entire code base it does appear that there is no place in any script or GUI that creates this value. Maybe I deleted it by accident when adjusting your code to use the various player models that I have.
#20
If it shows the DNA string then you know it got saved ok. If not...
getDNA eventually calls getScalePerBoneList in tsShapeInstance.cc
getScalePerBoneList calls Con::setVariable to set the $Pref::Player::DNA value
(2) In your serverCmdSetDNA function (last page of pdf) , also try printing the %DNA string received by the server from the client.
(3) Also to help with debugging things, try searching through the pdf and it should tell you what files to locate stuff in.
(4) Most likely cause... did you place the serverCmdSetDNA function in one of the server scripts? If it's in a client script it could explain the phenomena your are experiencing.
04/19/2005 (1:13 am)
(1) Try printing/logging $Pref::Player::DNA in function OptClose() at the bottom of OptionsDlg.cs straight after PlayerView.getDNA();If it shows the DNA string then you know it got saved ok. If not...
getDNA eventually calls getScalePerBoneList in tsShapeInstance.cc
getScalePerBoneList calls Con::setVariable to set the $Pref::Player::DNA value
(2) In your serverCmdSetDNA function (last page of pdf) , also try printing the %DNA string received by the server from the client.
(3) Also to help with debugging things, try searching through the pdf and it should tell you what files to locate stuff in.
(4) Most likely cause... did you place the serverCmdSetDNA function in one of the server scripts? If it's in a client script it could explain the phenomena your are experiencing.

Torque Owner Jorgen Ewelonn