Exporting Atoms files

Maya

import AtomsMaya


def export_static_mesh(file_path, transform, root_joints,
                       triangulate=True, include_textures=True):
    mel.eval('tcAtomsMeshExporter -fileName "%s" -transform "%s" '
             '-exportRigidGeos 1 -triangulate %d -includeTextures %d'
             % (file_path, transform, int(triangulate),
                int(include_textures)))


def export_skinned_mesh(file_path, transform, skeleton_file, root_joint,
                        triangulate=True, include_textures=True):
    mel.eval('tcAtomsMeshExporter -fileName "%s" -transform %s '
             '-exportSkinnedGeos 1  -triangulate %d -includeTextures %d '
             '-skeletonFile "%s" -rootTransform "%s"'
             % (file_path, transform, int(triangulate),
                int(include_textures), skeleton_file, root_joint[0]))




def export_skeleton_definition(root_joint, file_path, extra_joints):
    cmds.tcAtomsSkeletonDefinitionExporter(rootJoint=root_joint,
                                           fileName=file_path,
                                           extraJoint=extra_joints)











def export_animation(file_path, ground_height, foot_threshold,
                     data_from_scene, format):
    kwflags = dict(fileName=file_path, groundHeight=ground_height,
                   footThreshold=foot_threshold)
    if data_from_scene:
        kwflags['dataFromScene'] = True
    cmds.tcAtomsSkeletonAnimationExporter(format=format, **kwflags)


def export_fbx(file_path, agent_group, ids, start, end):
    cmds.tcAtomsFbxExporter(fileName=file_path, agentGroup=agent_group,
                            agentId=ids, frameStart=start, frameEnd=end)

Houdini

import AtomsHoudini


def export_static_mesh(file_path, transform, root_joint_list,
                       triangulate=True, include_textures=True):
    AtomsHoudini.exportAtomsMesh(str(file_path), str(transform),
                                 [str(x) for x in root_joint_list], False,
                                 triangulate, include_textures, "", "")



def export_skinned_mesh(file_path, transform, skeleton_file,
                        root_joint_list, triangulate=True,
                        include_textures=True):
    AtomsHoudini.exportAtomsMesh(str(file_path), (transform),
                                 [str(x) for x in root_joint_list], True,
                                 triangulate, include_textures,
                                 str(skeleton_file),
                                 str(root_joint_list[0]))


def export_skeleton_definition(root_joint, file_path, extra_joints):
    rj = root_joint
    if not rj.startswith('/obj/'):
        rj = '/obj/' + root_joint

    cmd = 'tcAtomsSkeletonDefinitionExporter -f %s -r %s' % (file_path, rj)
    if extra_joints:
        ejs = []
        for e in extra_joints:
            ejs.append(e if e.startswith('/obj/') else '/obj/' + e)

        cmd += " -e %s" % ','.join(ejs or [])

    res = hou.hscript(cmd)


def export_animation(file_path, ground_height, foot_threshold,
                     foot_down_from_scene, format):
    cmd = ('tcAtomsSkeletonAnimationExporter -f %s -o %s -r %d -g %f -d %d'
            %(file_path, foot_threshold, format, ground_height,
              int(foot_down_from_scene)))
    res = hou.hscript(cmd)
    return res[1] if res[1] else None


def export_fbx(file_path, agent_group, ids, start, end):
    cmd = ('tcAtomsExportFbx -f %s -g %s -i %s -s %d -e %d'
           % (file_path, agent_group, ','.join([str(i) for i in ids]),
              int(start), int(end)))
    res = hou.hscript(cmd)

Copyright © 2017, Toolchefs LTD.