Procedural bone animation
by John Klima · in Torque Game Engine · 08/13/2005 (2:15 pm) · 36 replies
Hi all,
i'm working on a procedural skeletal animator (with ken perlin at NYU). actually its more or less done in java, and i want to port it to torque. what it does is allow the user to set a wide variety of movement parameters at run-time which modify the motion of a bipedal character. it basically allows characters to dance in a reactive way, on the fly, without having to make multitudes of animation sequences.
so, my question is one of approach. i'm not exactly sure the best place to "slip" my code in. i have a character model, it will be an aiPlayer, but it will not have any animation sequences. every frame i calculate and update the bone positions. i see that in tsShapeInstance class i could iterate the bones and set their positions something like this:
however, i'm not sure if tsShapeInstance is the right place to be messing with the bones. what i think i should be doing is replacing the existing animator with my own instance, or subclass the existing animation class to override the dts sequences with my calculated bone transforms.
naturally i'm having a little trouble finding the classes that control the animation of an aiPlayer. any pointers would be greatly appreciated.
thanks,
j
i'm working on a procedural skeletal animator (with ken perlin at NYU). actually its more or less done in java, and i want to port it to torque. what it does is allow the user to set a wide variety of movement parameters at run-time which modify the motion of a bipedal character. it basically allows characters to dance in a reactive way, on the fly, without having to make multitudes of animation sequences.
so, my question is one of approach. i'm not exactly sure the best place to "slip" my code in. i have a character model, it will be an aiPlayer, but it will not have any animation sequences. every frame i calculate and update the bone positions. i see that in tsShapeInstance class i could iterate the bones and set their positions something like this:
for (U32 i=0;i<mShape->nodes.size();i++){
Point3F pos;
pos = mNodeTransforms[i].getPosition();
pos.x++;pos.y++;pos.z++; //just a dumb change
mNodeTransforms[i].setPosition(pos);
}however, i'm not sure if tsShapeInstance is the right place to be messing with the bones. what i think i should be doing is replacing the existing animator with my own instance, or subclass the existing animation class to override the dts sequences with my calculated bone transforms.
naturally i'm having a little trouble finding the classes that control the animation of an aiPlayer. any pointers would be greatly appreciated.
thanks,
j
#22
not quite sure the nature of your issues jordi. if you comment out :
mShapeInstance->setNodeAnimationState(i, mShapeInstance->MaskNodeHandsOff);
you will not be disabling the existing animation system, so your player will behave as it always does. this line of code is what allows you take control of the nodes and do with them what you will.
the code in my updatePuppet function is just demonstrative code, it simply shows how to apply a matrix tranform to a node. your code in this function will be completely different.
09/03/2006 (8:17 pm)
Hey all,not quite sure the nature of your issues jordi. if you comment out :
mShapeInstance->setNodeAnimationState(i, mShapeInstance->MaskNodeHandsOff);
you will not be disabling the existing animation system, so your player will behave as it always does. this line of code is what allows you take control of the nodes and do with them what you will.
the code in my updatePuppet function is just demonstrative code, it simply shows how to apply a matrix tranform to a node. your code in this function will be completely different.
#23
09/04/2006 (6:21 am)
I've tested with a player.dts from starter.fps and the code works fine. Seems to be my player model or it's dsqs :(
#24
09/04/2006 (6:44 am)
It's seems to be my animations since i disabled all animations and the code works now. Must investigate further to see if it's a specific animation...
#25
09/04/2006 (7:54 am)
I think it's the root animation. Not sure why though
#26
09/04/2006 (8:46 am)
Is it possible that I have nodes that are not being changed to HandsOff John? Thanks
#27
09/04/2006 (10:26 am)
Well in torque i suppose anything is possible ;) but if you iterating through all the nodes, all the nodes *should* be disabled.
#28
09/04/2006 (11:05 am)
OK after testin again with the starter.fps example I think it's something to do with if an animation is curretnly running on the nodes when you try to change them to Handsoff (ie like a root animation) then this problem occurs. Did you test this while your player is in a cyclic root animation John. I'm curious to know if this is my problem or does it happen all the time. Thanks
#29
09/04/2006 (11:51 am)
My dts files have only one keyframe animation (neutral pose) and it prolly does not get played prior to setPuppet(). However I do believe I did test this at least minimally, and did not have the issue.
#30
09/04/2006 (12:58 pm)
Going to test it on a fresh install of TGE to see if it works there....
#31
09/04/2006 (5:48 pm)
Seems to have the same problem in a new TGE install too. Thanks for the help anyways. Cheers
#32
09/07/2006 (4:54 am)
Hi again. I'm having more trouble with setPuppet(). When I load a mission now the nodes are always rotating. Even when I make sure I don't call setPuppet or set ispuppet to 1 anywhere in my code. Is this supposed to happen? I have even commented out the rotation part of the updatepuppet method and it still happens. Also deleted the related compliled .dso files and nothing helps.....Need help urgently. Thanks
#33
09/07/2006 (11:05 am)
Well, no of course not. the only way this can happens is if updatePuppet is being called
#34
09/07/2006 (11:52 am)
Sorry John. Stupid question I know but at this stage I'm asking myself every little possible question that could give a reason for this not working. I've searched through all my sdk and game files and can't find a call to updatePuppet anywhere. I'm not questioning the quality of your work John don't worry. Just looking for a solution to my problem here....... Your input is very much appreciated
#35
09/07/2006 (3:57 pm)
Umm okay. the thing you need to do, i think, is start with a fresh install of the SDK, in a seperate folder, and perform the steps above again, in an absolutely clean install. you DONT have to uninstall your current working folder, just make a clean install in a different folder, and perform the steps above
#36
So, how would I go about inheriting the transforms from parents? Tip and hints are good enough, but more code snippets would make you a demi-god ;).
Edit: Erk, didn't realise this was a month old. Apologies for the bump.
10/04/2006 (9:26 am)
Cheers for this code snippet John. Seem to have got it working without too much trouble. However, if I have a 'chain' of nodes linked together the transforms aren't passed down to children of each node. They all rotate independantly, I assume this is how it's supposed to work for now.So, how would I go about inheriting the transforms from parents? Tip and hints are good enough, but more code snippets would make you a demi-god ;).
Edit: Erk, didn't realise this was a month old. Apologies for the bump.
Torque Owner Gary "ChunkyKs" Briggs
Gary (-;