Bone root (Ragdoll)

Blitz3D Forums/Blitz3D Programming/Bone root (Ragdoll)

Yue(Posted 2013) [#1]


I have a problem, is that when you activate the rag doll effect, the main bone of the mesh (Scene_Root), not going behind the screen, this means that if the character falls from the platform and the camera goes behind the mesh , the character disappears, since the root stay somewhere where you start the rag doll effect.

Any possible help in this regard.

In the picture the bone stayed where this green bucket.

Greetings.


Kryzon(Posted 2013) [#2]
Const INFINITY = 1000000000

MeshCullBox( character, -INFINITY, -INFINITY, -INFINITY, 2*INFINITY, 2*INFINITY, 2*INFINITY )
Just call that once, after loading the animated mesh.


Yasha(Posted 2013) [#3]
the root stay somewhere where you start the rag doll effect.


Actually I'd say the problem is with this. Why isn't the root moving? This is why you'd normally want your root to be centred on the character rather than separated from it - if the root itself is also being controlled by a physics object, you won't have this problem.


Yue(Posted 2013) [#4]
oO?? Thanks Kryzon!!

everything was left running perfectly with the fragment of code that you post.

Now, I had found a little dirty solution that is:


	If PlayerDie% = True Then 
	PositionEntity  BoneRoot,EntityX(Camera\Objetct%),EntityY(Camera\Objetct%),EntityZ(Camera\Objetct%)   
	End If 




Kryzon(Posted 2013) [#5]
Why isn't the root moving? This is why you'd normally want your root to be centred on the character rather than separated from it - if the root itself is also being controlled by a physics object, you won't have this problem.

I'm not sure how the bones react with the physics engine - I'm guessing they keep imitating the physics objects' positions and rotations, while still keeping their parentage to the mesh's node.
If that's the case, then while the bones are imitating the physics objects, if you moved the mesh's node you would get a paradoxal behavior?

I agree that the mesh node should be close to the geometry or skeleton in all cases, as to avoid the problem that the OP had. But a robust solution must be found for this.
I'm not only talking about Blitz3D, but also Unity and other engines. It's something that ocasionally pops in my mind. How to deal with skeletal meshes and their root nodes?

- For some actions like running, jumping etc. I think you can animate your character performing them "in place". That is, if he's running, make him run on the same spot as if on a treadmill. Then in your program you only move this character's mesh node through code, based on keystrokes or gamepad input, while he's animating "in place"; Thus you have him actually walking etc.

- The problem comes with cinematics (cutscenes) or actions that require a more elaborate, non-cyclic animation. Climbing, for instance:



If the character is animated like that, his mesh node becomes separated from the geometry (the geometry and the skeleton are going up, while the mesh node remains still on the ground).
The target is to keep this mesh's node mobile, not static. The couple of ways I thought to address this are:
1) Animate the character as usual, leaving the mesh node static during the sequence. When you're done producing the animation, cut the keyframes from the root bone and paste these keys onto the mesh's node timeline (this all inside the animation software).
The result shouldn't be visually different, and the mesh node would now animate along.

2) Animate the character as usual, leaving the mesh node static during the sequence.
In the game program, when the animation sequence finishes performing, you move the mesh node to where the skeleton is, and since the skeleton would be dragged along with the mesh node, you also move the skeleton's root bone in an inverse manner. That is, if the mesh node moves by XYZ and rotates by ABC, you move the skeleton's root bone by -XYZ and rotate it by -ABC.
The result shouldn't be visually different, and the mesh node would be relocated to be close to the mesh.

#2 should work best for small in-game actions (where there's almost no risk of missing the camera view) such as pulling levers, the climbing above etc. while #1 should work best for big cinematics where the characters walk around, big distances and all.

- Physics and ragdolls are still an unknown to me, I haven't thought of how to "attach" the mesh node to the physics in order for it to follow the skeleton along and not compromise the ragdoll behavior. If anyone has any insight on this I'd love to hear.


Yue(Posted 2013) [#6]
In my case my mesh has 16 bones in the mesh construction'm implemented and affected by the rag doll physics, however, what happens is that in Blender to export the character to make an extra bone, which is not affected by physics and this is amid character legs if this bone will remain an object physical attachment between the legs colliding with both legs, I think something weird at the time of activating the rag doll.

So the problem but still do not understand very well what code solves my friend Krizon.




Kryzon(Posted 2013) [#7]
After sleeping on it I have thought of a better way to blend between cutscenes or elaborate actions and player-controlled actions. By "elaborate actions" I mean actions where the character walks around on his own, without the player controlling him.

So the procedure:
Animate your character as usual and leave the mesh node static.

Keep in mind your skeleton needs a parent bone - that is, one bone at the top of the chain (this is what Yue is probably using). I recommend placing this root bone on the ground, between the character's feet, right on the origin of the world of your scene if you're just exporting a single character.
In your animation software, you also need to place your mesh's pivot point at this same location - so the root bone and mesh pivot point are aligned.
Since this root bone will control the entire skeleton hierarchy, it being on the ground facilitates all sorts of alignment you may want while you're producing animation or programming.
If you're animating several characters together (so it's a cutscene), make sure each character's mesh pivot point starts the animation aligned with their own root bones. So when you're preparing your scene and placing your characters around (you haven't animated anything yet), make sure you preserve the alignment of each mesh's pivot point with its corresponding root bone. Then start animating and at this moment the root bones can move around, with the mesh pivot points remaining static as they should.



Now for the second part.
Take that climbing animation of before, for instance. If at the end of it your program would play the character's idle animation, the skeleton and geometry would snap back to the ground instead of being placed at the new height it just climbed, because in this idle sequence being played the root bone starts at the same position as the mesh's node.
So somehow we'd need to commit the new location of the skeleton to the mesh node.
With this we get this maxim: whenever a cutscene or elaborate animation sequence finishes playing, you realign the character's mesh node with its root bone. Since all of your animation sequences start with the root bone and mesh node aligned, this fixes all scenarios.
If climbingSequence_finished Then 
	PositionEntity( Character\Mesh, EntityX(Character\RootBone,True), EntityY(Character\RootBone,True), EntityZ(Character\RootBone,True), True )
	RotateEntity( Character\Mesh, EntityPitch(Character\RootBone,True), EntityYaw(Character\RootBone,True), EntityRoll(Character\RootBone,True), True )

	currentSequence = IDLE ;or WALKING, or whatever. Change the sequence to something the player will control. 
EndIf



Yue(Posted 2013) [#8]
My Mesh.


Well, you always learn something every day, at this point I have many questions because I do not know everything.

MI mesh is skeletonized as shown in the picture, but the bone in the middle half of the legs appears after export to b3d format.

Although the problem is already solved, I'm stuck on several things if you can not do.

1 * It is possible that after making the rag doll effect, restore the character to the original position. For example a car runs him over but it is not dead, so you stand nevus.

if this is possible, as is done?

A greeting.


Kryzon(Posted 2013) [#9]
I don't know why the exporter creates that extra bone. I read through the script and couldn't find anything responsible for it.

But if you want to restore the character after he goes into ragdoll mode, you need to resort to your code.
How are you "turning on" the ragdoll mode?

I believe somewhere in your code you're attaching each bone to a rigidbody object, and these rigidbody objects are connected to each other with physics joints.
When the character dies, you let the rigidbodies take control of the bones.
To restore the character, you just need to turn off that relationship between bones and rigidbodies, and make your character perform some sequence with Animate().


Yue(Posted 2013) [#10]
Ok no proble with scene_root, i confuse export new root.




Kryzon(Posted 2013) [#11]
To reiterate how important that ground bone is for proper game character skeletons.
I've discovered that Autodesk's MotionBuilder also deals with this root bone between the character's feet, on the ground.



They call it a "Reference" bone, and the documentation goes on to present a couple of uses for it:
HIK Character - Special Nodes


Yue(Posted 2013) [#12]


ok, thanks for the info, the only thing that occurred to me is to put half the mesh soil and main root is in the middle of the character, things to fit properly in B3D physics.