mrdoob / three.js

JavaScript 3D Library.
https://threejs.org/
MIT License
102.18k stars 35.34k forks source link

Working on SkeletonAnimation - JSONFormat #2106

Closed codeart1st closed 9 years ago

codeart1st commented 12 years ago

Hey guys, I'm working on SkeletonAnimation, but I don't understand how the bones will stored in JSONFormat.

{
  parent: BXindex,  // -1 for root bone
  pos: [x,y,z],
  rotq: [x,y,z,w], // quaternion
  scl: [x,y,z]
}

To understand it, I started to present the bones as THREE.Lines.

http://www.fiesta-library.bplaced.net/test/webgl_animation_skinning.html

But something is wrong with that.

In the JSONFormat is only one position for each bone. In Blender bones have two positions - tail and head. So how works the Three.js Bones?

stoomm commented 12 years ago

Hi all,

I have take a look with interests on this new exporter, but some bugs appears for me.

Test 1)

Blend file : http://www.stoomm.com/bones/obj/monster.blend Result file : http://www.stoomm.com/bones/obj/monster_bones.js Example : http://www.stoomm.com/bones/my_webgl_animation_skinning1.html

I've got an error and don't understand why.

Test 2)

Collada file : http://www.stoomm.com/bones/obj/test_Collada_DAE.DAE Result file : http://www.stoomm.com/bones/obj/test_bones.js Example : http://www.stoomm.com/bones/my_webgl_animation_skinning2.html

You can see a lot of problems with these animations...

apendua : I tested your version but bones and animations are null.

Thanks a lot for your help :)

poberherr commented 12 years ago

Hey Stom,

I was working on the same thing, maybe my example can help you. I imported md2 to json.

http://134.99.4.82/dev/

You can use the wasd keys space and the arrow keys for the camera. I think my solution is good for me so far, but I'm having issues with "one time play" Animations, you see what you mean when I jump. Let me know if you run about the same probs

Cheers Patrick

On 10/11/2012 12:02 PM, stoomm wrote:

Hi all,

I have take a look with interests on this new exporter, but some bugs appears for me.

Test 1)

Blend file : http://www.stoomm.com/bones/obj/monster.blend Result file : http://www.stoomm.com/bones/obj/monster_bones.js Example : http://www.stoomm.com/bones/my_webgl_animation_skinning1.html

I've got an error and don't understand why.

Test 2)

Collada file : http://www.stoomm.com/bones/obj/test_Collada_DAE.DAE Result file : http://www.stoomm.com/bones/obj/test_bones.js Example : http://www.stoomm.com/bones/my_webgl_animation_skinning2.html

You can see a lot of problems with these animations...

apendua : I tested your version but bones and animations are null.

Thanks a lot for your help :)

— Reply to this email directly or view it on GitHub https://github.com/mrdoob/three.js/issues/2106#issuecomment-9334659.

stoomm commented 12 years ago

Hi Patrick,

Thanks for your answer, but I thinks it's not the same things :) Your example use morphAnimMesh and my problem is with bones and SkinnedMesh :)

apendua commented 12 years ago

@stoomm Please try the version from my blender branch. If the bones are null then you probbably forgot to parent your model to the armature before exporting. Also note that the type of parent should be set to ARMATURE.

stoomm commented 12 years ago

@apendua Thanks for your answer. When I tested, it's with your blender branch but I don't know if I parent the model to the armature ... My blender's skills are very limited ;)

I will try next days and will report the result.

stoomm commented 12 years ago

@apendua I have taken a look. My mesh is parent to the armature. Have you see my blend file ? I think all is ok ...

stoomm commented 11 years ago

Hi all,

After some tests, my models run with the initial exporter :)

1) I have deleted the modifier 2) I have deleted the first and second scene (presents in the two models... ).

Sorry for that and thank for this great feature !

leegrey commented 11 years ago

Hi, I’ve been working on an ‘evening project’ for the last few weeks, using ThreeJS. I’ve been trying very hard to get Skeletal Animations exported from Blender working correctly, in a way I can reproduce. ( ie, rigging a model, animating it, and exporting successfully to ThreeJS ) There seem to be a few quirks / requirements for getting this pipeline to work smoothly.

The main ones that I’ve figured out and gathered from discussion here are:

This last one was pretty frustrating until I figured it out, as the animation would look right in Blender, but be broken in ThreeJS.

It seems like it might be possible to infer the starting and end pose by assuming default untransformed values? At the moment I’m only guessing about how the interpolation works, but it looks like the looping / wrapping interpolation has some undesirable side-effects that can only be avoided with these two bookending keyframes. ( At least in my eperience. )

I haven’t seen any mention of this last ‘tip’ elsewhere, so it seemed worthwhile to mention it here for others who may have hit the same technical barrier.

yazancash commented 7 years ago

i want to understand how "rotq" array of bones working?

rotq: [x,y,z,w], // quaternion

[x, y, z] are angles in Radian? (based on my tests, i guess not)

and what is [w] ? I find it is '1' in most examples.

empaempa commented 7 years ago

Hey! Quaternions is whole different beast than Euler angles but SO much better in every mathematical way. Pick any result from this search to get up to speed.

yazancash commented 7 years ago

i got it, thank you! http://answers.unity3d.com/questions/645903/please-explain-quaternions.html

yazancash commented 7 years ago

in JSON format, is there anyway to store transform/quaternion data in 4x4 matrix ? example

"bones":[
    {
    "parent":0,
    "name":"mixamorig_Hips",
    "matrix4x4":[1.000000, -0.000142, -0.000005, 0.000000, 0.000142, 1.000000, -0.000002, 0.000000, 0.000005, 0.000002, 1.000000, 0.000000,0.000057, 6.098754, 0.036233, 1.000000]
    }

is this possible somehow?