Search code examples
pythonmayacoordinate-systems3dsmaxeuler-angles

Converting Euler rotation angles from Z-up to Y-up (Max to Maya)


3Ds Max uses a right-handed coordinate system with z-up, Maya uses a right-handed coordinate system with y-up. I have an object rotation vector value in 3Ds Max in Euler angles: max_rotation = [35.0, 35.0, 35.0]. I need a Python script that converts rotation values from 3ds Max to Maya. If I do it manually, exporting the object from Max to Maya, I get a rotation vector like this: [-76.8815155029297, 28.024324417114265, -40.52367782592775]. How can I get similar values using the Python code?


Solution

  • I fear you may have misunderstood what's going on here. There is no difference between Y up, or Z up (both packages support both - just go to the app settings and change accordingly).

    If you are importing a Z up model into a Y up world, just rotate the model by -90 degrees round the X axis.

    Sorry for being old school, but here's some MEL to rotate the objects by 90 degrees (just select the bits imported as part of the model, and then run the following).

    // create a temp parent transform 
    $g = `group`;
    
    // rotate by -90 degrees to get Y up
    setAttr ($g + ".rx") -90;
    
    // select all the children of the group (what you started with).
    select -r `listRelatives -c $g`;
    
    // parent the objects under the world, 
    // which will apply the 90 degree rotation to the object roots.
    parent -world;
    

    If you are trying to convert an animated model from Z up to Y up, group everything, rotate by -90 degrees, and then leave everything the hell alone would be my advice!!

    It is possible to convert all of the animation data, but you're going to have to perform the same operation at a matrix level, and then decompose the matrices back into Eulers/translation/scale/shear. You'll then have to change all of the keyframes in the anim curves (luckily you only need to do this at the topmost level of the imported model, but it's still a faff)