Three.js importing a character with skeleton from 3ds max

953 views Asked by At
  1. I exported a rigged character from 3ds max in SEA3D format
  2. Loaded in Three.js
  3. Bone rotations have initial values. When I set these XYZ values to 0,0,0 my model looks completely messed up

Model bones from blender all have initial values of 0, 0, 0

All messed up

I have already tried to first export the model to FBX format, import in blender and then export to JSON format. It worked! Unfortunately this created other problems and too many steps to follow. Also Sea3d format is much smaller than JSON and I successfuly use this format throughout my project.

Also I tried using SEA3D Studio http://sea3d.poonya.com/studio/ to set "Inverse Bind Matrix" rotations to 0, 0, 0 for each bone which helped with initial positions but not with axles order.

If my knowledge about matrices would be more than 0 I'd make a script which would reset every model on load but that's something I need help with OR help with exporting from 3ds max so initial rotation values are 0 and axles are in correct order

1

There are 1 answers

0
Pawel On

After countless trial and error experiments to interrupt setting initial rotation values for bones I found that editing this piece of code in SEA3D loader did the job.

THREE.SEA3D.prototype.flipMatrix = function(mtx) {
    var mtx_data = THREE.SEA3D.BUFFER0.copy( mtx );

    mtx.setPosition( THREE.SEA3D.VECZERO ); 
    mtx.multiplyMatrices( THREE.SEA3D.BUFFER1.makeRotationAxis( THREE.SEA3D.VECBUF0.set(0, 0, 1), THREE.Math.degToRad( 180 ) ), mtx );      
    mtx.makeRotationFromQuaternion( THREE.SEA3D.QUABUF0.setFromRotationMatrix( mtx ) ); 

    var pos = THREE.SEA3D.VECBUF0.setFromMatrixPosition( mtx_data );
    pos.z = -pos.z;
    mtx.setPosition(pos);

    return mtx;
}

exactly this line:

mtx.makeRotationFromQuaternion( THREE.SEA3D.QUABUF0.setFromRotationMatrix( mtx ) ); 

should be changed to:

mtx.makeRotationFromQuaternion( new THREE.Quaternion(0, 0, 0, 1) ); 

This is not a solution but a workaround, so if you have a real solution(how to properly export it from 3ds max or process it after loading) then don't hesitate to post it!