Move a bone in JME3

Hello,



I would like to move a bone directly via JME and not to used keyframes from blender.

In the tutorial or the wiki I didn’t found any documentation on that.

Does anyone have an idea ?



EDIT : I think I must use the boneanimation → bone track and set manualy the keyframes to it… But if I set a keyframe to a bone, will the bone attached to it get affected too ?



Best regards,



rXp>!<

look at thet TestComplexOgreAnim http://code.google.com/p/jmonkeyengine/source/browse/trunk/engine/src/test/jme3test/model/anim/TestOgreComplexAnim.java



in the simpleUpdate method you have an example on how to do this.

Thank you a lot that was what I’m looking for.

But now I animate my bone with a rotation :

[java]q.fromAnglesAxis(FastMath.PI/180*angle,Vector3f.UNIT_Y);

q.normalize();[/java]

And after the first rotation the bone encounters a gimbal lock



Why is this happening with quaternion ?



Best regards,



rXp>!<

nehon said:
hey, thanks for the French post, but please go on with English, This post can be of use for any users, and i guess there are more users speaking English than French.

for your problem, yes, it's probably a gimbal lock, it's possible with quaternion because you compute it from Euler angles.
What you would need is to interpolate directly with quaternions using the slerp method.
it interpolate between 2 quaternions given a value between 0 and 1.

So you just have to know the starting quaternion and the end quaternion and the duration of the animation, then count time elapsed
normalize it with the direction (to have a value between 0 and 1).
I recommend using a control on your model to do that.

I already noticed some kind of precision loss between Euler angles to quaternion conversion, but I don't know if it's inherent to our implementation or it's a known mathematic fact.

Thank you, I will look into that direction.
I'm sorry for the french text but I wrote in french without noticing it.
I have another strange thing, my bones are not placed correctly.
When I debug the bones, I see the skeleton more smaller than the model and when I move the arm it moves forward and rotate to align itself to the bone. (so it is deformed)

hey, thanks for the French post, but please go on with English, This post can be of use for any users, and i guess there are more users speaking English than French.



for your problem, yes, it’s probably a gimbal lock, it’s possible with quaternion because you compute it from Euler angles.

What you would need is to interpolate directly with quaternions using the slerp method.

it interpolate between 2 quaternions given a value between 0 and 1.



So you just have to know the starting quaternion and the end quaternion and the duration of the animation, then count time elapsed

normalize it with the direction (to have a value between 0 and 1).

I recommend using a control on your model to do that.



I already noticed some kind of precision loss between Euler angles to quaternion conversion, but I don’t know if it’s inherent to our implementation or it’s a known mathematic fact.

Well, bones in JME are not shown as they are in blender for example.

jME Bones are more joints in fact, and the skeleton debugger displays a line between the parent bone and its children.

That’s why you don’t see the extremities bones (head, feet, fingers, etc…), because they have no child.

The other thing is that it assumes that bones are always connected, which is not the case in blender.

However, this does not affect rotations, scale and position computation of bones, but it only affect the debug display of a skeleton.

I don’t really understand your deformation problem though.

Look : This is the model (in the end of an animation) in blender.

http://img838.imageshack.us/img838/871/96216697.png



This is the result in JME :

http://img190.imageshack.us/img190/2951/36978444.png



Weird right ?

Apply all scales and rotations before exporting, also check this:

normen said:
Apply all scales and rotations before exporting, also check this:
https://docs.google.com/leaf?id=0B9hhZie2D-fEYmRkMTYwN2YtMzQ0My00NTM4LThhOTYtZTk1MTRlYTNjYTc3&hl=en

I followed the tutorial step by step except that I didn't set a material/texture. What do you mean by "Apply all scales and rotations" ?

Its a function in blender you can perform on objects.

normen said:
Its a function in blender you can perform on objects.

Oops yes CTRL+A, it worked sorry about that.
Okey so everything seems to work except the rotation itself. But that's probably just me.
I get the Q of origin from the bone and take the Q of rotation and add it to the Q of origin to have the Q of destination.
Then I use the slerp method on those 2 Q.
Does this seem right ?

Best regards,

rXp>!<

Mhh nope, you have to slerp between origin and destination and this is the rotation to use, don’t add it to the origin.

Okey,



So it seems to work. I just need to find a way to know how many seconds it has been since the action has started,

you can stack the tpf each frame, it’s the time spent on each frame.

In the simple update I animate my model and stack the tpf ?

I would create a custom control over the model to do this.