inverse kinematics
by deepscratch · in Torque 3D Professional · 01/10/2011 (12:56 pm) · 10 replies
hi all,
I'm trying to create a kind of inverse kinematics system.
what I've done so far:
1; when the player is created, a ragdoll(invisible) is also created, using the same bones as the rig (same way the physx sdk ragdoll is created).
2; there is a bool that switches the setNodeAnimationState to MaskNodeHandsOff for all the bones, this effectively switches the ragdoll on or off.
3; the spineNode index has been expanded to 18 bones, to allow access to individual limbs(for the IK system).
what its meant to do:
1; physics reactions to blows from bullets, melee attacks, explosions, collisions(shoot an arm and the arm loses player control for a second(single limb ragdoll), then regains control, or flying(full ragdoll) through the air from a blast and regaining control when you hit the ground.)
2; help with foot to terrain alingment (like the Unity3 soldier).
what it does now:
1; if the bool is false, a player is created, and the bones are directed by animations.
2; if the bool is true, a player is created, and the bones are directed by physics.
in either case the player is the control object.
this is where the help is needed. HELP!!
the switch needs to pass from script. right now it can only be set from code, which means player is either a player or a ragdoll at game start.
this is a major step I'm having trouble with,
I've tried a few ways to just pass the switch, and I keep getting a lock-out, ie; no control over animations, and whatever the last action was, sticks(if shooting, at the time of switch, he keeps firing and reloading endlessly) and stays in a weird state between ragdoll and controlled.
if I can just get a simple switch to work from script, the entire system will become workable.
does anyone have any ideas on this? or about a system like this?
any input at all will help,
thanks
I'm trying to create a kind of inverse kinematics system.
what I've done so far:
1; when the player is created, a ragdoll(invisible) is also created, using the same bones as the rig (same way the physx sdk ragdoll is created).
2; there is a bool that switches the setNodeAnimationState to MaskNodeHandsOff for all the bones, this effectively switches the ragdoll on or off.
3; the spineNode index has been expanded to 18 bones, to allow access to individual limbs(for the IK system).
what its meant to do:
1; physics reactions to blows from bullets, melee attacks, explosions, collisions(shoot an arm and the arm loses player control for a second(single limb ragdoll), then regains control, or flying(full ragdoll) through the air from a blast and regaining control when you hit the ground.)
2; help with foot to terrain alingment (like the Unity3 soldier).
what it does now:
1; if the bool is false, a player is created, and the bones are directed by animations.
2; if the bool is true, a player is created, and the bones are directed by physics.
in either case the player is the control object.
this is where the help is needed. HELP!!
the switch needs to pass from script. right now it can only be set from code, which means player is either a player or a ragdoll at game start.
this is a major step I'm having trouble with,
I've tried a few ways to just pass the switch, and I keep getting a lock-out, ie; no control over animations, and whatever the last action was, sticks(if shooting, at the time of switch, he keeps firing and reloading endlessly) and stays in a weird state between ragdoll and controlled.
if I can just get a simple switch to work from script, the entire system will become workable.
does anyone have any ideas on this? or about a system like this?
any input at all will help,
thanks
About the author
email me at medan121@gmail.com
Recent Threads
#2
01/10/2011 (3:26 pm)
I remember doing this once back in the day. MaskNodeHandsOff is an enum value, so you have a few different ways to approach it. I believe I just created a ConsoleMethod on the player object that would set the variable to what you want. Another way would be to exposing the enum table to script, like in this thread: Exposing C++ Enums.
#3
yes, I also thought to use console methods, its the best for the fine scripting.
could you maybe expand an example?
that link looks useful, checking it now.
also, is there a way to refresh the player without deleting him?
01/10/2011 (5:01 pm)
thanks Michael,yes, I also thought to use console methods, its the best for the fine scripting.
could you maybe expand an example?
that link looks useful, checking it now.
also, is there a way to refresh the player without deleting him?
#4
01/10/2011 (7:03 pm)
Do you need to refresh everything about the player, or just the animation state?
#5
01/10/2011 (9:22 pm)
just the animation state, I think,I get a lockup with the last action before the switch occurs, like if shooting, it will go to ragdoll, with a death grip on the trigger, so I believe I need a refresh
#6
an update,
the ragdoll is now being activated and deactivated nicely from script(thanks Michael),
but I am having an issue setting the players world position when the ragdoll is activated.
problem 1; when activated, the player transports to world 0,0,0 does his ragdoll thing, stands up, and you have control.
I need to somehow tell the bones that their initial point in space is not 0,0,0 but infact, the players present position. I have no clue how to pass that position over.
problem 2; when he has stood up, and you move about, and ragdoll gets active again, the player teleports to the exact last position it was, when you stood up. connected to problem 1 I'm sure.
here is where it all happens, if anyone has any idea what how to fix this, please dont be shy.
ideas?
01/13/2011 (1:50 am)
hi,an update,
the ragdoll is now being activated and deactivated nicely from script(thanks Michael),
but I am having an issue setting the players world position when the ragdoll is activated.
problem 1; when activated, the player transports to world 0,0,0 does his ragdoll thing, stands up, and you have control.
I need to somehow tell the bones that their initial point in space is not 0,0,0 but infact, the players present position. I have no clue how to pass that position over.
problem 2; when he has stood up, and you move about, and ragdoll gets active again, the player teleports to the exact last position it was, when you stood up. connected to problem 1 I'm sure.
here is where it all happens, if anyone has any idea what how to fix this, please dont be shy.
void Player::updateRDActive()
{
TSShape* shape = mShapeInstance->getShape();
//mLastPos = getPosition();
Point3F curPos = getPosition();
setPosition(curPos, mRot);
if(!m_interpolatingBones)
{
mPrevToCur = getTransform();
boneInfo& bone = (*mpBones)[mRootBoneNodeIdx];
PhysShape* body = bone.physShape;
MatrixF tr = body->getTransform();
tr.mul(bone.invPivot);
tr.mul(bone.model_inverse_transform);
setTransform(tr);
mPrevToCur.mul(mWorldToObj,MatrixF(mPrevToCur));
}
mCalculatedNones.clear();
mObjBox.minExtents.set( 10E30f, 10E30f, 10E30f);
mObjBox.maxExtents.set(-10E30f,-10E30f,-10E30f);
for (U32 i=0; i < shape->nodes.size(); i++)
{
calcNodeTransform(i);
VectorF pos = mShapeInstance->mNodeTransforms[i].getPosition();
mObjBox.minExtents.setMin(pos);
mObjBox.maxExtents.setMax(pos);
}
}ideas?
#7
01/13/2011 (12:33 pm)
Hi deepscratch, Im just curious what this is about, what is "inverse kinematics"?
#8
in simple layman terms, you can explain inverse kinematics as such:
if you shake someones hand, you are performing forward kinematics, ie; your hand is in control of the shake action.
if someone shakes your hand, you are recieving inverse kinematics, ie; your hand is recieving the control of the shake action.
what I am trying to achieve is a balance between the two, to be the control object, but also to have the control object be influenced by external influences, from which you can recover control, or not, depending on the force of the external influence.
does that make sense?
01/13/2011 (7:33 pm)
hi Novack, nice to see you still around.in simple layman terms, you can explain inverse kinematics as such:
if you shake someones hand, you are performing forward kinematics, ie; your hand is in control of the shake action.
if someone shakes your hand, you are recieving inverse kinematics, ie; your hand is recieving the control of the shake action.
what I am trying to achieve is a balance between the two, to be the control object, but also to have the control object be influenced by external influences, from which you can recover control, or not, depending on the force of the external influence.
does that make sense?
#9
Send updates on your progress :)
01/13/2011 (7:53 pm)
Yeah! really interesting work Deep, thanks for the explanation.Send updates on your progress :)
#10
making progess with this,
the bone capsules now align and update postion with the player bones,
but an interesting problem has appeared.
the player has a character controller capsule.
the bones are physics objects(capsules).
the character controller capsule continuously displaces the bones in its space, two physics objects repel.


the debug gizmos show correct alignment, but you can see the bones are getting displaced by the controller capsule
so any ideas how to disable the controller's capsule collision with these bones?, and only these bones?
thanks.
01/20/2011 (6:14 pm)
hi all,making progess with this,
the bone capsules now align and update postion with the player bones,
but an interesting problem has appeared.
the player has a character controller capsule.
the bones are physics objects(capsules).
the character controller capsule continuously displaces the bones in its space, two physics objects repel.


the debug gizmos show correct alignment, but you can see the bones are getting displaced by the controller capsule
so any ideas how to disable the controller's capsule collision with these bones?, and only these bones?
thanks.
Torque 3D Owner Chris