John Klima's procedural bone animation
by Daniel Buckmaster · in Torque Game Engine · 11/13/2007 (11:45 am) · 8 replies
I've looked up the old forum thread where John Klima mentioned some work he was doing on animating an object's bones by code. I implemented the code he reccomended, and it works really nicely. However, when I exit the mission, I get a debug break in platformmemory.cc saying 'Not an allocated block!' I tracked the problem down to my player's TSShapeInstance being deleted, but I didn't really get anything more useful after that. The next function call is Vector::~Vector() Line 158. From there free() ends up being called, and it breaks the program at line 1037:
Additionlly, but probably unrelated, is my character's animation. In third person view, all is well - I turn procedural anim on, his head starts jerking around like crazy (I hardcoded it for testing so only the head node is affected). Turn it off, it goes back to normal. However, in first person view, after turning it in for the first time, regardless of whether I turn it off again, the player is constantly jumping up and down - the Player itself, not the head node or camera (you can see the shadow on the terrain move). Switch back to 3rd, and the problem goes away.
I'm implementing the animation somewhat differently to John's example, using a custom struct created per player to control when to animate. It may have something to do with that, but I tend to think not. I'll do some more debuggery.
AssertFatal(hdr->flags & Allocated, avar("Not an allocated block!"));hrd->flags is 0, and I can't get any context information on Allocated.Additionlly, but probably unrelated, is my character's animation. In third person view, all is well - I turn procedural anim on, his head starts jerking around like crazy (I hardcoded it for testing so only the head node is affected). Turn it off, it goes back to normal. However, in first person view, after turning it in for the first time, regardless of whether I turn it off again, the player is constantly jumping up and down - the Player itself, not the head node or camera (you can see the shadow on the terrain move). Switch back to 3rd, and the problem goes away.
I'm implementing the animation somewhat differently to John's example, using a custom struct created per player to control when to animate. It may have something to do with that, but I tend to think not. I'll do some more debuggery.
About the author
Studying mechatronic engineering and computer science at the University of Sydney. Game development is probably my most time-consuming hobby!
#2
All you have to do is basically get the transform for the node you're working on from the shape instance (mNodeTransforms) then do your operations on it and store it back.
11/13/2007 (2:24 pm)
@Daniel, don't use SetNodeAnimationState or any of the TSCallback stuff at all, it causes some really crazy issues. Just put your IK code in after the call to animate() (but before render) on the shape instance and work on the transforms there.All you have to do is basically get the transform for the node you're working on from the shape instance (mNodeTransforms) then do your operations on it and store it back.
#3
11/13/2007 (2:55 pm)
Yeah i'm with ross, don't mess with the callback, use the animate function, it's where i do everything.
#4
11/13/2007 (2:56 pm)
Oh and take some time to figure how those integerSets work. they are your friends!!!
#5
11/13/2007 (3:48 pm)
Heh, well, I don't see any need to use the integersets either. Actually, I think it's better to do everything outside the animate(), right after it.
#6
11/14/2007 (4:09 am)
Well if you set all nodes to handsoff, then you can ignore the code inside tsAnimate.animateNodes() but if you need to transition between dsq based motion and your own procedural motion, i see no better (or other) place to handle this than inside animateNodes, by using the integersets and yout own time based interpolation values
#7
Did some more investigating. The crash doesn't happen if I don't touch the procedural animation stuff, and it doesn't happen if the only call I make is to turn the animation off. If I exit with the procedural stuff on, I get the error. If I turn it on then off, then exit, I get a different error :P.
11/18/2007 (4:27 am)
I removed all the node mask stuff, but I'm still getting the 'not an allocated block' error when I exit the mission, something's going wrong when the player shape tries to delete a matrix. What could be causing that?Did some more investigating. The crash doesn't happen if I don't touch the procedural animation stuff, and it doesn't happen if the only call I make is to turn the animation off. If I exit with the procedural stuff on, I get the error. If I turn it on then off, then exit, I get a different error :P.
#8
11/18/2007 (4:42 pm)
Can't wait to hear more, I'd love to hook some PhysX ragdolls up to this for doing death animation.
Torque Owner John Klima
eLeMeNO
no seriously, i plan to have some fresh juicy stuff soon, working on it as we speak.