Animation implementation idea and oddities (Need Help - Repost)
by Aaron Scott Kingston · in Torque 3D Professional · 12/10/2009 (4:09 pm) · 22 replies
I've been advised to post this in the private forums . . .
Here is what we're going for (stealth-based game):
EDIT: Revised idea . . . If in walking/running you can immediately go to crouch & vice-versa.
Anyone played Splinter Cell: Chaos Theory? Same idea so we can control the player's speed via mouse wheel. I realize that a lot of threads in the forums asking about adding a walk animation along with the default run. So my question is this:
Can we change the variable with a script? This is part of our player's script file for loading animations:
So why not change
I can change the player's movement speed easily enough through default.bind.cs:
------------------
I've been playing around with the scripts & here's an update (default.bind.cs). Our player's name is Slater so I'm referencing his .cs file:
-The default sequences are removed.
-It appears that the walk animations are loading but not playing correctly.
-Every time the player moves he uses the jump animation.
Another idea I had is to use a similar system as weapons for moving through animations. Instead of cycling through weapons we cycle through animations. I copied a lot of code from weapon.cs & changed any reference from "Weapon" to "Animation". I know each weapon has its own datablock but how would each animation have its own datablock since it's more abstract? a ScriptObject? SimObject?
------------------
________________________________________
The oddities . . . as you can see I'm using collada files for the animations. I'm have the same problems of a floating crouch_root (and crouch_side stopped working some some reason) and I'm having the same problem of no sounds or footstep decals.
www.torquepowered.com/community/forums/viewthread/104301 - t3d private
www.torquepowered.com/community/forums/viewthread/107071 - t3d private
For the crouch_root height problem I do have the bounding box parented to Bip01 without the Z axis inheritance & I tweaked the bounding box but no go. The crouch_forward & crouch_back work just fine.
The custom character problem might be resolved with the second link but alas, I only have the binary & it looks like an easy fix.
Here is what we're going for (stealth-based game):

EDIT: Revised idea . . . If in walking/running you can immediately go to crouch & vice-versa.
Anyone played Splinter Cell: Chaos Theory? Same idea so we can control the player's speed via mouse wheel. I realize that a lot of threads in the forums asking about adding a walk animation along with the default run. So my question is this:
Can we change the variable with a script? This is part of our player's script file for loading animations:
...
%this.addSequence("./run.DAE", "run");
%this.addSequence("./run_back.DAE", "back");
%this.addSequence("./run_strafeL.DAE", "side");
...So why not change
%this.addSequence("./run.DAE", "run"); to %this.addSequence("./walk.DAE", "run"); to%this.addSequence("./sneak_jog.DAE", "run"); to%this.addSequence("./sneak.DAE", "run");depending on the mouse wheel value & keyboard taps? Can you change the animation file variable with a script function?I can change the player's movement speed easily enough through default.bind.cs:
function moveforwardwalk(%val)
{
$mvForwardAction = %val * $movementSpeed * 0.3;
}
...
moveMap.bind( keyboard, "ctrl w", moveforwardwalk );
...But we'd like to change the animations too.------------------
I've been playing around with the scripts & here's an update (default.bind.cs). Our player's name is Slater so I'm referencing his .cs file:
function removeSequences()
{
SlaterData.removeSequence("root");
SlaterData.removeSequence("run");
SlaterData.removeSequence("back");
SlaterData.removeSequence("side");
}
function WalkAnimOverride()
{
removeSequences();
SlaterData.addSequence("art/shapes/actors/Slater/root.DAE", "root");
SlaterData.addSequence("art/shapes/actors/Slater/walk.DAE", "run");
SlaterData.addSequence("art/shapes/actors/Slater/walk_back.DAE", "back");
SlaterData.addSequence("art/shapes/actors/Slater/walk_side.DAE", "side");
moveforwardwalk();
movebackwardwalk();
moveleftwalk();
moverightwalk();
}
moveMap.bind(keyboard, "alt y", WalkAnimOverride);This is just for testing but here are my findings:-The default sequences are removed.
-It appears that the walk animations are loading but not playing correctly.
-Every time the player moves he uses the jump animation.
Another idea I had is to use a similar system as weapons for moving through animations. Instead of cycling through weapons we cycle through animations. I copied a lot of code from weapon.cs & changed any reference from "Weapon" to "Animation". I know each weapon has its own datablock but how would each animation have its own datablock since it's more abstract? a ScriptObject? SimObject?
------------------
________________________________________
The oddities . . . as you can see I'm using collada files for the animations. I'm have the same problems of a floating crouch_root (and crouch_side stopped working some some reason) and I'm having the same problem of no sounds or footstep decals.
www.torquepowered.com/community/forums/viewthread/104301 - t3d private
www.torquepowered.com/community/forums/viewthread/107071 - t3d private
For the crouch_root height problem I do have the bounding box parented to Bip01 without the Z axis inheritance & I tweaked the bounding box but no go. The crouch_forward & crouch_back work just fine.
The custom character problem might be resolved with the second link but alas, I only have the binary & it looks like an easy fix.
About the author
https://sites.google.com/site/ascottk/home http://www.myspace.com/ascottk http://www.soundclick.com/scottkingston
#2
Here us the Collada crouch_forward animation in the Shape Editor:

crouch_root animation:

Same crouch forward animation sequence:

Same crouch root sequence:

As far as the collada file animations are concerned they are fine. But as a sequence the crouch_root is buggy. Can this be fixed on my end or do I need to submit a bug report?
12/12/2009 (4:10 pm)
Weird crouching problems:Here us the Collada crouch_forward animation in the Shape Editor:

crouch_root animation:

Same crouch forward animation sequence:

Same crouch root sequence:

As far as the collada file animations are concerned they are fine. But as a sequence the crouch_root is buggy. Can this be fixed on my end or do I need to submit a bug report?
#3
So . . .
12/12/2009 (6:32 pm)
. . .- Either I've been working on stealth games for too long & my posts get unnoticed
- Nobody understands the questions
- Nobody has solutions or ideas
- There are solutions but they require source code changes
- Nobody cares
So . . .
switch$($MyResponse)
{
case "TooMuchStealth":
echo("I TYPE IN CAPS & STOMP AROUND IN THE FORUMS!");
case "NobodyUnderstands":
echo("K.I.S.S (Keep It Simple Stupid)! Annunciate & learn how to present ideas in a clear & concise way");
case "NobodyKnows":
echo("It you want to do it right, do it yourself. Share the solution if you deem the community worthy. That is if you figure out a solution");
case "SolutionNeedsSource":
echo("Ask someone who has the solution to create a binary for you . . . kindly ;)");
case "NobodyCares":
echo("Pout while sitting at your computer and cry.");
}
#4
Easy. Just update $mvForward at the end of changePlayerSpeed. eg.
12/12/2009 (6:49 pm)
Quote:receive a signal from the changePlayerSpeed function? If I hold the "w" key for forward movement & scroll the mouse wheel I'd like the speed of the player to change instead of releasing the "w" key in order to update the speed.
Easy. Just update $mvForward at the end of changePlayerSpeed. eg.
function changePlayerSpeed(%val)
{
if (%val < 0)
$movementSpeed -= 0.1;
else if (%val > 0)
$movementSpeed += 0.1;
//keep speed between 0.1 & 1.0, not cycling speed (speed limits)
$movementSpeed = mClamp($movementSpeed, 0.1, 1.0);
// update speed if forward is pressed
if ($mvForwardAction > 0)
$mvForwardAction = $movementSpeed;
}
#5
1. Is the crouch_root animation marked as a blend?
2. Did you use the Collada Import Gui "Adjust Floor" or "Adjust Center" options for the model, or any of the animations?
12/12/2009 (6:53 pm)
On the crouch_root animation being offset....1. Is the crouch_root animation marked as a blend?
2. Did you use the Collada Import Gui "Adjust Floor" or "Adjust Center" options for the model, or any of the animations?
#6
If I do that for backwards, left, & right then those are updated too. Such an easy solution.
As for the crouch_root, this is in the character's .cs:
So should they be a "1"? And should each animation have it's own .cs file?
EDIT: & it's not marked as a blend.
12/12/2009 (7:14 pm)
Awesome! Works great, thanks Chris!If I do that for backwards, left, & right then those are updated too. Such an easy solution.
As for the crouch_root, this is in the character's .cs:
{
baseShape = "art/shapes/actors/Slater/Slater.DAE";
upAxis = "DEFAULT";
unit = "-1";
lodType = "DetectDTS";
singleDetailSize = "2";
ignoreNodeScale = "0";
adjustCenter = "0";
adjustFloor = "0";
forceUpdateMaterials = "0";
canSaveDynamicFields = "1";
loadLights = "0";
};So should they be a "1"? And should each animation have it's own .cs file?
EDIT: & it's not marked as a blend.
#7
No. The 'adjust center' and 'adjust bounds' apply an offset to the whole shape, so it might have explained what was happening if you were doing it for the model, but not for the animations. You're not using those options so nothing to worry about there.
Another question: does your model and/or animations have a mesh called "bounds" at the root level? (ie. did you export everything with a custom bounding box or are you relying on the automatic bounds calculated by the collada loader?
I'm guessing custom bounds because the animation-only files appear to have the same bounding box as the character model. If true, make sure to align the bottom of the bounding box with the feet of the model throughout the animation.
12/12/2009 (9:44 pm)
Quote:So should they be a "1"? And should each animation have it's own .cs file?
No. The 'adjust center' and 'adjust bounds' apply an offset to the whole shape, so it might have explained what was happening if you were doing it for the model, but not for the animations. You're not using those options so nothing to worry about there.
Another question: does your model and/or animations have a mesh called "bounds" at the root level? (ie. did you export everything with a custom bounding box or are you relying on the automatic bounds calculated by the collada loader?
I'm guessing custom bounds because the animation-only files appear to have the same bounding box as the character model. If true, make sure to align the bottom of the bounding box with the feet of the model throughout the animation.
#8
The fix will be in the next update of T3D, but if you absolutely can't wait, you could hack the cached.dts files generated by the collada loader to set the appropriate flag:
1. open the file in a HEX editor and find the list of strings containing the word "ambient".
2. go to the end of the list. The next 32-bit word will be equal to 1 (probably displayed as 01 00 00 00). Skip this word and the next one too.
3. set bit 5 of the next word (ie. OR the first byte in the word with 0x20).
12/12/2009 (10:01 pm)
Quote:The custom character problem might be resolved with the second link but alas, I only have the binary & it looks like an easy fix.
The fix will be in the next update of T3D, but if you absolutely can't wait, you could hack the cached.dts files generated by the collada loader to set the appropriate flag:
1. open the file in a HEX editor and find the list of strings containing the word "ambient".
2. go to the end of the list. The next 32-bit word will be equal to 1 (probably displayed as 01 00 00 00). Skip this word and the next one too.
3. set bit 5 of the next word (ie. OR the first byte in the word with 0x20).
#9
It made no difference if the bounding box was parented to bip01 with or without z-axis inheritance, if there was no bounds in the animation, or if I did not parent the bounds to anything. I get the same result each time (opencollada, max 2010).
12/12/2009 (10:12 pm)
Both model and animations have a custom bounding box, and I made sure it's aligned to the feet.It made no difference if the bounding box was parented to bip01 with or without z-axis inheritance, if there was no bounds in the animation, or if I did not parent the bounds to anything. I get the same result each time (opencollada, max 2010).
#10
With XVI32 . . .
I don't understand the skipping of words.
12/12/2009 (10:41 pm)
Quote:The fix will be in the next update of T3D, but if you absolutely can't wait, you could hack the cached.dts files generated by the collada loader to set the appropriate flag:
1. open the file in a HEX editor and find the list of strings containing the word "ambient".
2. go to the end of the list. The next 32-bit word will be equal to 1 (probably displayed as 01 00 00 00). Skip this word and the next one too.
3. set bit 5 of the next word (ie. OR the first byte in the word with 0x20).
With XVI32 . . .
I don't understand the skipping of words.
#11
I mean to move the cursor forward in the file past those words. In the file you've shown above, the last string in the list is "dummy". So put the cursor here (on the 'y').
Then move the cursor to the start of the next 32-bit word (4-byte boundary, so the last byte of the address is 0,4,8 or C). In this case, the byte address (column on the far left of the GUI) of the next word is 487C. Note that the byte at this address is 01 as I said earlier.
Now move the cursor forward past this word and the next word (ie. move forward a total of 8 bytes, to address 4884 for this file). Set the 5th bit in this byte.
12/12/2009 (11:14 pm)
Quote:I don't understand the skipping of words.
I mean to move the cursor forward in the file past those words. In the file you've shown above, the last string in the list is "dummy". So put the cursor here (on the 'y').
Then move the cursor to the start of the next 32-bit word (4-byte boundary, so the last byte of the address is 0,4,8 or C). In this case, the byte address (column on the far left of the GUI) of the next word is 487C. Note that the byte at this address is 01 as I said earlier.
Now move the cursor forward past this word and the next word (ie. move forward a total of 8 bytes, to address 4884 for this file). Set the 5th bit in this byte.
#12
Anyway I got my footprints back :) Not that footprints are good in a stealth game . . . "Hey! Who forgot to wipe their feet!" . . . Maybe it is a good idea.
Now for the floating crouch_root. It seems that any root that deviates from
the default root, like the crouch_root and our custom sneak_root (to complement the sneak walks & runs), have the floating problem.
12/13/2009 (12:26 am)
Okay, essentially I was looking for that "10" in the hex area after the "X" in the text area then flipping the 5th bit so it looks like "30" in the hex area . . .Anyway I got my footprints back :) Not that footprints are good in a stealth game . . . "Hey! Who forgot to wipe their feet!" . . . Maybe it is a good idea.
Now for the floating crouch_root. It seems that any root that deviates from
the default root, like the crouch_root and our custom sneak_root (to complement the sneak walks & runs), have the floating problem.
#13
12/13/2009 (4:34 pm)
Is it possible to send me the two files (crouch_root animation and base model) so I can take a look?
#14
12/13/2009 (4:42 pm)
I sent the player model & crouch_root (collada) via email . . .
#15
The trouble in your case is that the rest-pose in the character model DAE file is different to the rest-pose in the crouch_root animation DAE. When Torque adds the crouch_root keyframes to the model, it assumes (wrongly) that the rest-poses are the same, and so some nodes are not being animated correctly.
I've put a fix in that will detect this case and generate the appropriate keyframes for nodes that have differing rest transforms so this won't be a problem in the future.
For now....is it possible to re-export your animations such that they all share the same rest-pose as the original character model? I'm not a MAX user so not sure if this makes any sense or not?
12/13/2009 (8:11 pm)
I see the same problem as you. The cause is a bad assumption in the code that adds sequences from external files. Basically, in order to save space/processing time, Torque only stores node transform keyframes for nodes that actually move during an animation.The trouble in your case is that the rest-pose in the character model DAE file is different to the rest-pose in the crouch_root animation DAE. When Torque adds the crouch_root keyframes to the model, it assumes (wrongly) that the rest-poses are the same, and so some nodes are not being animated correctly.
I've put a fix in that will detect this case and generate the appropriate keyframes for nodes that have differing rest transforms so this won't be a problem in the future.
For now....is it possible to re-export your animations such that they all share the same rest-pose as the original character model? I'm not a MAX user so not sure if this makes any sense or not?
#16
I get the idea but not sure how to implement it. I'll play around with the animations & once I find out what works I'll post.
Thanks for looking into this Chris!
12/13/2009 (10:06 pm)
Quote:For now....is it possible to re-export your animations such that they all share the same rest-pose as the original character model? I'm not a MAX user so not sure if this makes any sense or not?
I get the idea but not sure how to implement it. I'll play around with the animations & once I find out what works I'll post.
Thanks for looking into this Chris!
#17
So if anyone who's floating with their root animations, just add some movement to your skeleton's/biped's root/Bip01.
12/13/2009 (11:06 pm)
Okay, I added some up & down movement to Bip01 & that did the trick. So if anyone who's floating with their root animations, just add some movement to your skeleton's/biped's root/Bip01.
#18
12/13/2009 (11:25 pm)
OK - let me know if it is not possible/too hard and perhaps I can generate a new binary for you with the fix included.
#19
Well, there is still the problem of the crouch_side not working. The sequence plays as it should in the shape editor but not in-game.
A new binary is not necessary. Actually the guy I'm collaborating with is not expecting to get the animations into the game yet but I'm doing it to see how the animations look in-game as opposed to seeing it in max. Besides I'm learning more about working with T3D & learning TorqueScript because he may need more help after the animations are done . . . and we may need less/more animations depending on the needs of the game.
EDITED . . .
12/13/2009 (11:49 pm)
Quote:OK - let me know if it is not possible/too hard and perhaps I can generate a new binary for you with the fix included.
Well, there is still the problem of the crouch_side not working. The sequence plays as it should in the shape editor but not in-game.
A new binary is not necessary. Actually the guy I'm collaborating with is not expecting to get the animations into the game yet but I'm doing it to see how the animations look in-game as opposed to seeing it in max. Besides I'm learning more about working with T3D & learning TorqueScript because he may need more help after the animations are done . . . and we may need less/more animations depending on the needs of the game.
EDITED . . .
#20
While swimming: swim_root is stuck in-game, swim_left's Bip01 (base) is not angled to the left like the source animation. swim_right is fine.
crouch_side still does not work
___________________
Is there any way to tell the game the player is crouching? Is there another way of calling the crouch pose? It seems odd $mvTriggerCount2 and $mvTriggerCount3 is added to every time the player crouches and jumps unless it's for saving purposes. The reason is I want to know is I have separate lean animations depending on if the player is crouched or not.
It's understandable that $mvTriggerCount0 and $mvTriggerCount1 needs a counter since it tells the game you fired a weapon.
12/16/2009 (10:05 pm)
New problems, I sent you the files . . .While swimming: swim_root is stuck in-game, swim_left's Bip01 (base) is not angled to the left like the source animation. swim_right is fine.
crouch_side still does not work
___________________
Is there any way to tell the game the player is crouching? Is there another way of calling the crouch pose? It seems odd $mvTriggerCount2 and $mvTriggerCount3 is added to every time the player crouches and jumps unless it's for saving purposes. The reason is I want to know is I have separate lean animations depending on if the player is crouched or not.
//crouching
function doCrouch(%val)
{
$mvTriggerCount3++;
}It's understandable that $mvTriggerCount0 and $mvTriggerCount1 needs a counter since it tells the game you fired a weapon.
Torque Owner Aaron Scott Kingston
function changePlayerSpeed(%val) { %PlayerSpeed = $movementSpeed; if (%val < 0) $movementSpeed = %PlayerSpeed - 0.1; else if (%val > 0) $movementSpeed = %PlayerSpeed + 0.1; //keep speed between 0.1 & 1.0, not cycling speed (speed limits) if ($movementSpeed > 1.0 ) $movementSpeed = 1.0; if ($movementSpeed < 0.1 ) $movementSpeed = 0.1; } moveMap.bind(mouse, "zaxis", changePlayerSpeed);I'm still fairly new to Torque script but this works pretty well. Except how can:
function moveforward(%val) { $mvForwardAction = %val * $movementSpeed; }receive a signal from the changePlayerSpeed function? If I hold the "w" key for forward movement & scroll the mouse wheel I'd like the speed of the player to change instead of releasing the "w" key in order to update the speed.On the event that the mouse wheel is used then changePlayerSpeed() sends a message to moveforward() so the speed updates automatically?