Manual moving node with parent
by Aussiemandias · in Torque 3D Professional · 03/20/2014 (1:00 am) · 28 replies
Hi all, I'm having a problem here with moving my bone transformations. I've got them linked up to a PhysX skeleton right now and it works pretty good, but any bone that I'm not manually setting the transformation for isn't moving.
eg. If I move the head node the neck should follow, as it does in the shape editor.

There's an example. The code I'm using to set this is
Any ideas?
eg. If I move the head node the neck should follow, as it does in the shape editor.

There's an example. The code I'm using to set this is
void RagDoll::processTick(const Move* move)
{
if(isClientObject() && mPhysicsRagdoll)
{
for(int i = 0; i < eRagdollBone::MAX_RAGDOLL_BONES-1; i++)
{
//Check if the bone is on our list of "ragdollable bones"
S32 node = mShapeInstance->getShape()->findNode(eRagdollBoneChar[i]);
if(node != -1)
{
eRagdollBone bone = (eRagdollBone)i;
EulerF rot = mPhysicsRagdoll->getTransform(bone).toEuler();
rot.z += mDegToRad(90.0f); //Need to add a 90degree offset because I set up the physx orientation wrong..
Point3F pos = mPhysicsRagdoll->getTransform(bone).getColumn3F(3);
pos -= getPosition();
mShapeInstance->setNodeAnimationState(node,TSShapeInstance::MaskNodeHandsOff);
mShapeInstance->mNodeTransforms[node].set(rot,pos);
DebugDrawer *ddraw = DebugDrawer::get();
if ( ddraw )
{
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::HEAD).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::UPPER_BODY).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::UPPER_BODY).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::LOWER_BODY).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::LOWER_BODY).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_THIGH).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_THIGH).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_CALF).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_CALF).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::RIGHT_FOOT).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::LOWER_BODY).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::LEFT_THIGH).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::LEFT_THIGH).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::LEFT_CALF).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->drawLine( mPhysicsRagdoll->getTransform(eRagdollBone::LEFT_CALF).getColumn3F(3), mPhysicsRagdoll->getTransform(eRagdollBone::LEFT_FOOT).getColumn3F(3), ColorI(0,255,0,255) );
ddraw->setLastTTL(TickMs);
}
}
}
}
Parent::processTick(move);
}Any ideas?
About the author
#2
//Need to add a 90degree offset because I set up the physx orientation wrong..
This could cause a number of issues with bones and linking. (especially if the child bones are not properly inheriting the offset.)
03/21/2014 (5:34 pm)
Hmm, it sort of looks like you are trying to handle the movement as a morph rather than a true 'move'. I know morphing has been major bugged since forever. The other 'possible' issue, you state in your comment: //Need to add a 90degree offset because I set up the physx orientation wrong..
This could cause a number of issues with bones and linking. (especially if the child bones are not properly inheriting the offset.)
#3
I added this but then my model didn't respond to any node movement at all :(
I am completely stumped. Here's my source code if anyones interested https://dl.dropboxusercontent.com/u/41968/t3d/source.zip
03/24/2014 (12:23 am)
I fixed the 90degree, nothing changed. I also had a look at the shape editor code and the only thing they added was// Mark threads as dirty so they will be re-sorted, in case the user changed // sequence priority or blend flags mModel->setDirty( TSShapeInstance::ThreadDirty );
I added this but then my model didn't respond to any node movement at all :(
I am completely stumped. Here's my source code if anyones interested https://dl.dropboxusercontent.com/u/41968/t3d/source.zip
#4
03/24/2014 (3:42 am)
If i get your code working do i have permission to release the code?
#5
03/24/2014 (9:08 am)
Of course, I think ragdolls would be a great addition to the community.
#6
03/24/2014 (11:07 pm)
Ok ill try and take a look this week sometime, can't promise though as i have heaps of other code to get finished off too.
#7
Sorry mate haven't had a chance to integrate your code yet and fix it up. Just a quick question, what is your end goal for the ragdolls? Do you want just a generic game object that has ragdoll support or are you looking to have it integrated into the player class(obviously this would extend to aiplayer for example)?
Taking a quick look it is currently deriving from StaticShape. Totally off topic but StaticShape would have to be one of the more confusing named classes I have come across in T3D yet.
03/27/2014 (7:00 pm)
@Aussie:Sorry mate haven't had a chance to integrate your code yet and fix it up. Just a quick question, what is your end goal for the ragdolls? Do you want just a generic game object that has ragdoll support or are you looking to have it integrated into the player class(obviously this would extend to aiplayer for example)?
Taking a quick look it is currently deriving from StaticShape. Totally off topic but StaticShape would have to be one of the more confusing named classes I have come across in T3D yet.
#8
You'll notice in the code I get the bone transforms of the players current animation and build the PhysX off that, so it should be seamless. The only bug is the transform node issue and my PhysX in general (joints flinging around, size approximation)
03/28/2014 (4:50 pm)
Generic game object, I was going to spawn one as soon as the player died. You'll notice in the code I get the bone transforms of the players current animation and build the PhysX off that, so it should be seamless. The only bug is the transform node issue and my PhysX in general (joints flinging around, size approximation)
#9
03/28/2014 (6:15 pm)
Ok all good, i got a bit of free time today before the footy starts this arvo so i'll take a look and see what i can do.
#10
03/28/2014 (10:00 pm)
So you are spawning the ragdoll in the player script instead of playing the playDeathAnimation()?
#11
Added to the end of objectBuilderGui.ed.gui
and then I had a custom datablock defined which was just...
And I spawned it in the editor.
03/28/2014 (10:45 pm)
Oh sorry, I made a custom object in the editor which I made using...function RagDollData::create(%data)
{
%obj = new RagDoll()
{
dataBlock = %data;
parentGroup = EWCreatorWindow.objectGroup;
};
return %obj;
}Added to the end of objectBuilderGui.ed.gui
and then I had a custom datablock defined which was just...
// Post thrown projectile
datablock RagDollData(PlayerRagdollData)
{
category = "Ragdolls";
shapeFile = "art/shapes/actors/Soldier/soldier_rigged.DAE";
preload = true;
};And I spawned it in the editor.
#12
03/29/2014 (2:02 am)
That GIF was the most disturbing thing I'd seen all day. Then I watched Hannibal.
#13
It's actually more gruesome watching it within the physx visual debugger, our poor ragdoll is exploding and body parts are flying everywhere. Anyway you will have to leave this with me for awhile, it's going to take a little time to get it all sorted out. I'll update this thread with any progress.
03/29/2014 (4:35 pm)
Quote:That GIF was the most disturbing thing I'd seen all day. Then I watched Hannibalhahaha
It's actually more gruesome watching it within the physx visual debugger, our poor ragdoll is exploding and body parts are flying everywhere. Anyway you will have to leave this with me for awhile, it's going to take a little time to get it all sorted out. I'll update this thread with any progress.
#14
03/29/2014 (9:28 pm)
Yeah if you comment out the FixedJoint part in Px3Ragdoll.cpp you'll notice it wont spazz out, rather fall to the floor. So somethings going wrong with the joints.
#15
03/29/2014 (11:08 pm)
Actually one thing the physics system could really do with is some joint classes (and i don't mean Colorado/Washington style either). I'll add that to my ever growing todo list.
#16
So far I got the tracker (Visage SDK) integrated with Torque, and got it to print tracking data into console, and I've imported a model with full facial bone rig. I'm using the FPS tutorial as base.
The problem I have is similar to Aussiemandias'. How to manualy set nodes to positions I recieved from tracker (like he's doing with Physx). I'm not using PhysX so the code he posted isn't quite what I was loking for.
I appologize if I piggyback onto this topic, but it's the closest and most recent thing I've found on this forum regarding my problem. I'm also willing to help you any way I can.
If needed, I'll make a fork of my project on GitHub.
Thank you for understanding,
Toni
04/24/2014 (5:16 am)
Hi all, I'm new to Torque 3D, but I chose it for my M.Sc. thesis, which is Facial tracking based character animation.So far I got the tracker (Visage SDK) integrated with Torque, and got it to print tracking data into console, and I've imported a model with full facial bone rig. I'm using the FPS tutorial as base.
The problem I have is similar to Aussiemandias'. How to manualy set nodes to positions I recieved from tracker (like he's doing with Physx). I'm not using PhysX so the code he posted isn't quite what I was loking for.
I appologize if I piggyback onto this topic, but it's the closest and most recent thing I've found on this forum regarding my problem. I'm also willing to help you any way I can.
If needed, I'll make a fork of my project on GitHub.
Thank you for understanding,
Toni
#17
04/24/2014 (5:48 pm)
That sounds like a really cool thesis. I can't offer much help, but try checking out this old thread and this follow up. We were messing around with programmatic animation back in the days of TGE. The TSShape classes are relatively unchanged since then so there might be some insights there.
#18
04/25/2014 (1:37 am)
Okay! I think I know what the issue is here - TSShape updates its child nodes in getNodeWorldTransform and you can see it pulls the data from its parent. TSShapeInstance doesn't have anything like that when accessing the node transforms, so I need to just assign the child nodes to have the same position as their parent in the loop (and then run the positioning code again ontop for each child that has a corresponding ragdoll.)
#20
04/27/2014 (10:55 pm)
Sweet!

Torque Owner Richard Ranft
Roostertail Games