mrdoob / three.js

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

using animation by colladaloader #623

Closed 6ert closed 12 years ago

6ert commented 13 years ago

Hello world, in order to get an exported animation from 3ds max - opencollada rendered in webgl - three - by using ColladaLoader() (from your examplecode webgl_collada.html) I ran into unexpected behaviour using .dae files see: http://www.weberforschen.de/cms/fileadmin/js/colladaloader.zip

Usecase1 - demom.dae Trying a model I found on the net using skin controller and animated bones on about 30 keyframes, then exporting it by opencollada - 3ds max 2010, loaded by THREE ColladaLoader() - Animation is showing fine!

Usecase2 - koi_skin_anim.dae I tried to rebuild the scene in 3ds max 2010. (structure is slightly more expensive in size) The scene is rendered fine by THREE.WebGLRenderer() but missing animation. Debugging the js didnt show me differences in walking through parsing the dae, nor getting error messages by exceptions or anything else...

Questions:

greets - 6ert

mrdoob commented 13 years ago

Thanks a lot for sharing the files. Having files to tests with is always priceless!

I've done some tweaks in the ColladaLoader.

https://github.com/mrdoob/three.js/commit/81d338e915d569271daaca40b156f46fda96acb5

With the latest version U1 now also show the textures. U2 shows the geometry and textures but no animation (does it have animation?)

6ert commented 13 years ago

Yes - U1 and U2 have keyframed bones animation. Maybe my description wasnt detailed enough:

talking about the 'animation' tagged section in .dae, both of the exported usecases are identical in structure. (I investigated the source of the collada by xml editor)

loading the scenes by ColladaLoader() and rendering by WebGLRenderer() U1 shows geometry, images, animation U2 shows geometry, images, no animation

No error messages, no debugging hints to see any differences between the two

mrdoob commented 13 years ago

@timknip: Any ideas?

timknip commented 13 years ago

Looking at it... but need add some (temporary) debug code to ColladaLoader to find out what's going sour here. Will report my findings later.

Big NOTE: Current skinning/animation is a ugly hack: the skinned animation now is 'transformed' to a simple bunch of morph-targets. That's because at time of writing ColladaLoader three.js only allowed for 2 bones per vertex AND I didn't understand howto implement :-) Anyway: this might also be cause of problem.

timknip commented 13 years ago

Think the problem is related to how geometry is defined:

A:

<geometry>
  <mesh>
    <triangles />
  </mesh>
</geometry>
<geometry>
  <mesh>
    <triangles />
  </mesh>
</geometry>
<geometry>
  <mesh>
    <triangles />
  </mesh>
</geometry>

B:

<geometry>
  <mesh>
    <triangles />
    <triangles />
    <triangles />
    ...
  </mesh>
</geometry>

A works, B doesn't.... investigating further...

timknip commented 13 years ago

Hmmm... kind of complex to solve. Will take some time.

@6ert So: stuff will work with pattern A. Not sure how to accomplish it from within MAX, but think its got to do with how the 'skin geometry' is defined (ie: A means 'separate object', whilst B means 'grouped objects'). Maybe 'exploding' or 'ungrouping' will do the trick. Could you experiment a bit, trying to get pattern A instead of B? Just check the library_geometries element in the COLLADA xml. I'll try fix this coming days.

6ert commented 13 years ago

@timknip the separated 'skin geometry' actually is a multi/sub object texturematerial assigned to a solid mesh in 3ds max. removing the material results in an untextured mesh, which is showing animation! (so youre right on your assumption) but maybe the collada parser simply gets confused about the material nodes needing additional subdecisions? nevertheless - thanks for spending your time...

timknip commented 13 years ago

@6ert The problem lies in the skin's "vertex weights" and "joints". With the multi/sub texture material assigned some indexing goes sour. Anyway: for the moment try to workaround the issue (don't use multi/sub materials).

The issue is on my TODO, but as said: its kind of hell to fix (albeit possible of course). As soon as I find some time I'll fix... Keep an eye on this issue.

mrdoob commented 13 years ago

Solved by @6ert himself here: https://github.com/mrdoob/three.js/issues/746

I guess @timknip will know if it's been fixed in a proper way :)

simoncarre commented 12 years ago

Hi, I've read all topics of @6ert and his demonstration on his website, but I've still a problem: I create a very simple animation (with 3DS max 2012, auto-key animation & OpenCollada exporter) here: http://www.simoncarre.fr/webGL/ThreeJS/tests/models/test4.dae

But when I load this collada on three.js scene (the monster scene), the skin table is empty so I dont have any animation... How create or initialize this table or just how animate my .dae object :)

My test file here : http://www.simoncarre.fr/webGL/ThreeJS/tests/test4.php

Thanks !

6ert commented 12 years ago

several issues: 1.colladaloader in current version doesnt support all kind of animation: I got errormessages on nodes 'transform' and 'rotation' in your model. Im not quite sure on this subject, but my example scene uses bone animation which works for me. 2.You are using three.js r46 which is using several patches preventing my fixes to ColladaLoader.js in r45 to work see my last comment on https://github.com/mrdoob/three.js/issues/746 Maybe I find some time to fix ColladaLoader in current version...

simoncarre commented 12 years ago

Hi I update my work on this link: http://www.simoncarre.fr/webGL/ThreeJS/tests/test4.php I think the problem is not with r46 because the monster move without problems. It's a problem with my collada file when I work on 3DS max. I've apply a modifier 'skin' on my teapot et now I've a good skin table on three.js. But now, it's a problem with my keyframes on 3DS... The 'morphTargetInfluences' table is empty, I dont have my differents keyframes. Can you say me how create a good object with 3DS ? (type of modifiers to apply, how use keyframes...)

Thanks for your help :) (and sorry for my bad english...)

6ert commented 12 years ago

on r46: The monster scene doesnt use MSO (multi sub object) texture. On such a model you wont get the problems mentioned above - its just acting fine. My patch to three r45 is related to that MSO problem and its based on indexing material morphTargets (see ColladaLoader.js). In r46 we got several patches from third site against material indexing, which makes my patch useless. So avoid using MSO in your 3dsmax scene and youre on the safe side.

on keyframes: i gave the model in 3dsmax a skin modifier, which is acting on bones from biped tools. using bones in such a context seams to be essential on ColladaLoader. so I guess what youre doing is to put some 'handmade' skeleton system into your skin, which will not be recognized. (Console says on your scene: tranlastion, rotation is no property of object)

conclusion: try a model without MSO and using skin modifier on biped skeleton

simoncarre commented 12 years ago

Thanks ! The problem was really on my biped skeleton... I have changed that ;)