Dynamically Scaling Players, Vehicles, and Objects
by Conrad "Lynx" Wong · 03/11/2003 (1:40 pm) · 25 comments
The attached patch file corrects Torque so that if the scale of a SceneObject is changed on the server, it will pass this change down to the client. Scaling an object and then clicking 'apply' will now also result in immediate rescaling and redrawing of the object.
Players and vehicles collide correctly when rescaled, i.e. a player scaled to 5x normal size will collide at that size against a placed cube, rather than partially penetrating the cube. The scaled player's jump force is scaled somewhat so that a very large player jumps higher and a small player jumps lower than a normal sized player. Run was not touched. Footprint decals are scaled. Mounted images, i.e. weapons will attach to the scaled attach points and are also scaled in appearance so a large player does not appear to be carrying a ridiculously small weapon.
Changes have been tested in fps example.
lagkitten.purrsia.com/torque/scaling.patch
Here is a script example of how you could create a scaled-up player:
// Set up the player
%player = new Player() {
dataBlock = LightMaleHumanArmor;
client = %this;
scale = "5 5 5";
};
MissionCleanup.add(%player);
You can also scale the player, vehicles, or objects in the editor, simply by selecting the player, selecting 'Transform' fields, entering the new scaling values (which are X, Y, and Z respectively), and clicking 'apply'. After this change is applied, scaling changes to these objects will take place immediately instead of requiring the object to be dragged to make transformations show on the client side.
Players and vehicles collide correctly when rescaled, i.e. a player scaled to 5x normal size will collide at that size against a placed cube, rather than partially penetrating the cube. The scaled player's jump force is scaled somewhat so that a very large player jumps higher and a small player jumps lower than a normal sized player. Run was not touched. Footprint decals are scaled. Mounted images, i.e. weapons will attach to the scaled attach points and are also scaled in appearance so a large player does not appear to be carrying a ridiculously small weapon.
Changes have been tested in fps example.
lagkitten.purrsia.com/torque/scaling.patch
Here is a script example of how you could create a scaled-up player:
// Set up the player
%player = new Player() {
dataBlock = LightMaleHumanArmor;
client = %this;
scale = "5 5 5";
};
MissionCleanup.add(%player);
You can also scale the player, vehicles, or objects in the editor, simply by selecting the player, selecting 'Transform' fields, entering the new scaling values (which are X, Y, and Z respectively), and clicking 'apply'. After this change is applied, scaling changes to these objects will take place immediately instead of requiring the object to be dragged to make transformations show on the client side.
#2
03/07/2003 (7:36 pm)
It's possible but it seemed to be working and shots appeared to come from an appropriate point, so I left them alone. I'm hoping Garage Games will supply feedback on how this is supposed to work.
#3
03/12/2003 (6:20 pm)
Cool! I may need this exact functionality.
#4
03/17/2003 (1:49 pm)
Supply feedback? Since you posted your patch as a resource, I was hopeing to get feedback from the community on whether it was working or not ;)
#5
I have tested it with aiPlayers with excellent results. However, the animations on these are fairly basic so I cannot say that the animations scale as well.
03/18/2003 (12:06 pm)
Tim, It works great! But read my post above regarding the scaling of the muzzle transforms...not sure if those are needed--I added them anyway but haven't had a chance to test them.I have tested it with aiPlayers with excellent results. However, the animations on these are fairly basic so I cannot say that the animations scale as well.
#6
03/18/2003 (12:23 pm)
Desmond, are you saying that it worked as is, or that you had to change the muzzle transform code? Seems like all the node transforms would have to be scaled for weapons and other mountable objects to work correctly. Many of them call the same underlying "getNodeTransform" methods though, so maybe Conrad's patch will work as is... I'll try it out shortly.
#7
03/18/2003 (12:36 pm)
Works as is as far as I've tested it..the muzzleTransform parts of the code I posted above were not modified in the resource but I have added them to match the other sections (however, I have not tested them nor have I tested this code with any complicated animations). Perhaps a good test would be the default player model--I just haven't tried it myself :)
#8
I did notice the use of mObjBox in these places, but decided not to change these to 'mScaledBox' unless I saw that they were necessary. Since I didn't notice anything wrong at this point, I decided to leave well enough alone.
I'm hoping that Tim Gift can offer a comment on this, but even if you use the patch exactly as it is, nothing is going to be broken that wasn't already. :)
Oh, Tim, one other thing-- I noticed that both Player and Camera use 'setCompressionPoint' in their writePacketData routines. This means if you have both a player and an external camera in action, say for 3rd person RTS/RPG-style mouse movement, one's compression point will overwrite the other, and position updates will gradually become incorrect.
The fix is to have Player and Camera (and anyone else who wants to set a compression point and use it later in the stream) remember their last set compression points, and restore that when processing an update. I haven't submitted a patch yet because I'm still working on my project's camera in general, but this should be easy to fix.
03/18/2003 (12:59 pm)
Be it noted that I tested this by taking the default player, the Scorched Planet mission, dropping in a scaled-up TSStatic cube and a rifle and some ammo, and then ran around scaled up and down. The weapon mounted correctly on scaled players and shots appeared to be coming from the appropriate locations on the players, so I believed that no further muzzleTransform scaling was necessary.I did notice the use of mObjBox in these places, but decided not to change these to 'mScaledBox' unless I saw that they were necessary. Since I didn't notice anything wrong at this point, I decided to leave well enough alone.
I'm hoping that Tim Gift can offer a comment on this, but even if you use the patch exactly as it is, nothing is going to be broken that wasn't already. :)
Oh, Tim, one other thing-- I noticed that both Player and Camera use 'setCompressionPoint' in their writePacketData routines. This means if you have both a player and an external camera in action, say for 3rd person RTS/RPG-style mouse movement, one's compression point will overwrite the other, and position updates will gradually become incorrect.
The fix is to have Player and Camera (and anyone else who wants to set a compression point and use it later in the stream) remember their last set compression points, and restore that when processing an update. I haven't submitted a patch yet because I'm still working on my project's camera in general, but this should be easy to fix.
#9
03/19/2003 (2:39 pm)
I applied this patch to the head and checked it all in. I did make one change though, I removed the transmission of the transform from the GameBase pack/unpack methods which I believe were not needed.
#10
03/19/2003 (3:35 pm)
Tim, Please explain why you think they're not needed (to help my understanding). Thx
#11
03/20/2003 (10:51 am)
GameBase and ShapeBase make no assumptions about how an object moves or how it's position is updated. All the derived classes take care of updating their position based on their requirements.
#12
03/21/2003 (10:11 am)
Thanks, Tim!
#13
Is there a short how-to or an install guide ?
10/18/2003 (10:46 pm)
Ok... I'll ask the stupid question.... how do you install it into the engine ???Is there a short how-to or an install guide ?
#14
10/18/2003 (10:51 pm)
It's already in, thanks to Tim Gift.
#15
And to use it you just need to add:
Scale = "? ? ?"
to the function GameConnection::createPlayer in the game.cs script ?
10/20/2003 (8:58 am)
Just to clarify... this has been added to the latest release 1.2 ?And to use it you just need to add:
Scale = "? ? ?"
to the function GameConnection::createPlayer in the game.cs script ?
#17
03/04/2005 (2:40 pm)
Seems a scaled up player can't walk up steps correctly, even if the datablock member maxStepHeight is manually scaled to get it to work. I've been tracing through the Player::step function, at the bottom, it looks like stepHeight needs to be greater then pos->z, but this never happens when the player is caled. I haven't figured out why yet.
#18
I tried this, but it had no effect:
$AIPlayer.getDataBlock().scale = "5 5 5";
How do we force the engine to notice the scale change?
09/29/2005 (3:08 pm)
How can I scale the Player (or anything else) dynamically from a script (rather than from the editor)?I tried this, but it had no effect:
$AIPlayer.getDataBlock().scale = "5 5 5";
How do we force the engine to notice the scale change?
#19
$AIPlayer.setScale("5 5 5");
10/03/2005 (11:54 am)
nevermind! Ignore my last post. Answered it myself:$AIPlayer.setScale("5 5 5");
#20
you will run into trouble with animations which make the character horizontal.
for example a death sequence.
the scale is applied to the entire shape after it's been deformed by bones,
so if the bones have animated it to lie flat, you'll get a character of normal 'height'
but exaggerated 'width'.
if that matters to you,
you might check out duncan's custom shape mod:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7368
11/10/2005 (4:16 pm)
note - if you're using this with non-uniform scale (eg to make a player taller but not wider)you will run into trouble with animations which make the character horizontal.
for example a death sequence.
the scale is applied to the entire shape after it's been deformed by bones,
so if the bones have animated it to lie flat, you'll get a character of normal 'height'
but exaggerated 'width'.
if that matters to you,
you might check out duncan's custom shape mod:
www.garagegames.com/index.php?sec=mg&mod=resource&page=view&qid=7368

Torque Owner Desmond Fletcher
fletcher
void Player::getMuzzleTransform(U32 imageSlot,MatrixF* mat)
void Player::getRenderMuzzleTransform(U32 imageSlot,MatrixF* mat)
void Player::getMuzzlePointAI(U32 imageSlot, Point3F* point)