Problems importing animation from Maya

Started by xxdaggerxx, March 16, 2018, 11:55:13 am

Previous topic - Next topic


March 16, 2018, 11:55:13 am Last Edit: March 16, 2018, 12:00:37 pm by xxdaggerxx
Hi all, i was able to import my model via OBJ correctly from Maya to Terragen 4.
The position and rotation seems correct.

However when i import my CHAN file to animate my object, i get strange results.

The pivot point of my OBJ objects is animated correctly, rotation and translation are moving correctly.
But the geometry of the object is teleport-ed to a different location.

What's going on?


ok i think i solved it. seems like the Object must be zeroed out and centered in the world in Maya before importing to Terragen..

Now the rotations are all messed up. Translation seem ok. Any solutions to this?


Sounds like a possible rotation order issue. Does Maya provide any options on export to adjust the rotation order?

- Oshyan


I wrote my CHAN exporter in Maya.
But the rotation order is wrong. I can adjust the rotation order in my script. But what is the correct order between Maya and T4?

import maya.cmds as cmds
import math

def dump_camera_channels( cameraName, time ):
    current = time
    shapeName  = cmds.listRelatives(cameraName,shapes=True)[0]
    tx = cmds.getAttr(cameraName+".tx", t=current)
    ty = cmds.getAttr(cameraName+".ty", t=current)
    tz = cmds.getAttr(cameraName+".tz", t=current)
    rx = cmds.getAttr(cameraName+".rx", t=current)
    ry = cmds.getAttr(cameraName+".ry", t=current)
    rz = cmds.getAttr(cameraName+".rz", t=current)

    return str(current) + " " + str(tx) + " " + str(ty) + " " + str(tz) + " " + str(rx*-1) + " " + str(ry*-1) + " " + str(rz*-1)

def export_camera( filename, cameraName, **kwargs ):
    st = 1
    ed = 1
    step = 1
    if 'st' in kwargs:
        st = kwargs['st']
    if 'ed' in kwargs:
        ed = kwargs['ed']
    if 'step' in kwargs:
        step = kwargs['step']
    f = open( filename, 'w')
    for time in xrange(st, ed, step):
        l = dump_camera_channels( cameraName, time )
        f.write(l + "\n")

export_camera( "C:\\DATA\\Projects\\F16 Project\\PRODUCTION\\Maya\\scenes\\Shot1\\test.chan", "nurbsCircle1", st = 1, ed = 189 )


This is probably a Hannes question/answer but try some links in the animation series page...

This one talks of one way to do it...,23384.msg236656.html#msg236656


I am able to export the maya cam via FBX, the rotation and translation works. But cant export object animation via CHAN with out the rotation going bonkers.


I am still unable to solve it, anyone has any advise?


March 25, 2018, 11:49:41 am #7 Last Edit: March 25, 2018, 04:15:10 pm by digitalguru
Just seen this thread and sent you a PM - you should be able to get the script working now.

Quoteok i think i solved it. seems like the Object must be zeroed out and centered in the world in Maya before importing to Terragen..

The only way to export mesh data from Maya to Terragen is via .obj format which is very basic, it basically just stores the vertex positions and some face information and UVs for the mesh. It doesn't store the pivot point of an object, which is why an object to be exported from Maya should be zeroed to the origin before saving out. Then the .chan data can be exported separately and the animation will be correct when applied to the imported .obj in Terragen. This might seem like a faff, but I actually prefer it - once you've imported an .obj into Terragen (and re-set the shaders, which can take a while) - it's imported. Any animation changes can then be updated via a .chan file without having to re-load the object.

QuoteNow the rotations are all messed up. Translation seem ok. Any solutions to this?

Yes. Please try my script again and it will work after creating a World to set up the scene (importing a Micro Export terrain).

The rotation order required by the .chan file in Terragen is different to Maya - I get around this by creating a locator in Maya, changing it's rotation order, parent to object to be exported, baking the keys, then exporting a .chan file from the locator.

My script also deals with the pivot point issue by temporarily resetting the object to be exported to the origin before saving to disk.
Edit: It's important not to freeze the transforms of the object, so it can easily be set back to the world origin.

It's not pretty, but given the limitations of obj as a transfer format, the only way to do it. If we had Alembic as a import/export format all this would be unnecessary, but I suspect that might be a while coming.


Thanks digitalguru!

I manage to get your script to work, thank god for it!

I'll keep you updated if i notice any other issues. Thanks.