Exemple #1
0
def is_sequence_camera(cam_id):
    """
    Check camera is a sequence camera.

    :param int cam_id: The 3DE camera id.

    :rtype: bool
    """
    return tde4.getCameraType(cam_id) == "SEQUENCE"
Exemple #2
0
def correctCameraPath(cameraTmp):
    if tde4.getCameraType(cameraTmp) == 'REF_FRAME':
        return True

    cameraPath = tde4.getCameraPath(cameraTmp).replace('\\', '/')
    shotNameSplited = cameraPath.replace('//', '').split('/')[-1].split(".")

    if len(shotNameSplited) == 3:
        return True
    else:
        shotNameSplited = shotNameSplited[0].split('_')
    return (len(shotNameSplited) >= 2)
Exemple #3
0
 def getInfoCam(self):
     cam = self.cam
     index = self.index
     self.offset = tde4.getCameraFrameOffset(cam)
     self.cameraPath = tde4.getCameraPath(cam).replace('\\', '/')
     self.camType = tde4.getCameraType(cam)
     self.noframes = tde4.getCameraNoFrames(cam)
     self.lens = tde4.getCameraLens(cam)
     self.rez_x = tde4.getCameraImageWidth(cam)
     self.rez_y = tde4.getCameraImageHeight(cam)
     self.model = tde4.getLensLDModel(self.lens)
     self.firstFrame = tde4.getCameraSequenceAttr(cam)[0]
     self.name = "%s_%s_1" % (validName(tde4.getCameraName(cam)), index)
     self.lastFrame = '%d' % (self.firstFrame + self.noframes - 1)
     self.firstFrame = '%d' % self.firstFrame
     self.focal_cm = tde4.getCameraFocalLength(cam, 1)
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".tx\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".ty\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".tz\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".rx\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".ry\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".rz\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".sx\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".sy\");\n")
            f.write("setAttr -lock true (\"trk_marker\" + \"*\" + \".sz\");\n")
            #
            # write cameras...

            cl = tde4.getCameraList()
            index = 1
            for cam in cl:
                camType = tde4.getCameraType(cam)
                noframes = tde4.getCameraNoFrames(cam)
                lens = tde4.getCameraLens(cam)
                if lens != None:
                    name = validName(tde4.getCameraName(cam))
                    if tde4.getCameraStereoOrientation(
                            cam) == 'STEREO_LEFT' and tde4.getCameraStereoMode(
                                cam) != 'STEREO_OFF':
                        name = ShotName + '_trk_camLeft'
                    elif tde4.getCameraStereoOrientation(
                            cam
                    ) == 'STEREO_RIGHT' and tde4.getCameraStereoMode(
                            cam) != 'STEREO_OFF':
                        name = ShotName + '_trk_camRight'
                    else:
                        name = ShotName + '_trk_cam'
def compress(cams, ui=False):
    errors = []
    max_steps = 0
    seq_cams = {}

    for cam in cams:
        cam_name = tde4.getCameraName(cam)

        if tde4.getCameraType(cam) != 'SEQUENCE':
            errors.append(
                'Camera {} is not a Sequence Camera.'.format(cam_name))
            continue

        start, end = tde4.getCameraSequenceAttr(cam)[:2]
        frames = abs(end - start + 1)
        steps = frames + frames / 100 + 2
        max_steps += steps
        seq_cams[cam] = {
            'name': cam_name,
            'start': start,
            'end': end,
            'frames': frames,
            'steps': steps
        }

    if cams:
        if ui:
            tde4.postProgressRequesterAndContinue(TITLE, 'Please wait...',
                                                  max_steps, 'Ok')
        else:
            print(TITLE)
    else:
        errors.append('Please choose a camera.')

    steps_done = 0

    for cam in seq_cams:
        cam_name = seq_cams[cam]['name']
        msg = 'Exporting: {} (starting)'.format(cam_name)
        if ui:
            tde4.updateProgressRequester(steps_done, msg)
        else:
            print('  0% ' + msg)
        start = seq_cams[cam]['start']
        end = seq_cams[cam]['end']
        frames = seq_cams[cam]['frames']
        steps = seq_cams[cam]['steps']
        path = tde4.getCameraPath(cam)

        if tde4.getPreferenceValue('ICOMPRESS_BCFILE_IN_DIR') == '1':
            # save buffer in project directory
            project_dir = os.path.dirname(tde4.getProjectPath())
            if project_dir:
                # we have a project directory, it's safe to save
                target_path = os.path.join(project_dir, os.path.basename(path))
            else:
                # no project directory, alert the user
                target_path = ''
                errors.append(
                    'Can not save buffer to project directory. Project is not saved.'
                )
        elif tde4.getPreferenceValue('ICOMPRESS_BCFILE_IN_DIR') == '2':
            # save buffer in custom directory
            custom_dir = tde4.getPreferenceValue('ICOMPRESS_CUSTOM_DIR')
            target_path = os.path.join(custom_dir, os.path.basename(path))
        else:
            # default behavior, save buffer in image path
            target_path = path

        if not path:
            errors.append(
                ("Couldn't process camera {} because it doesn't have "
                 'any Footage loaded.').format(cam_name))
            steps_done += steps
            continue

        gamma = tde4.getCamera8BitColorGamma(cam)
        softclip = tde4.getCamera8BitColorSoftclip(cam)
        black, white = tde4.getCamera8BitColorBlackWhite(cam)
        exr = tde4.getCameraImportEXRDisplayWindowFlag(cam)
        sxr = tde4.getCameraImportSXRRightEyeFlag(cam)
        if sxr == 1:
            sxr2 = " -import_sxr_right_eye "
        else:
            sxr2 = " "
        if exr == 1:
            exr2 = " -import_exr_display_window "
        else:
            exr2 = " "
        proc_err = None

        # makeBCFile exits cleanly even if it errored, so we have to parse
        # its errors manually.
        proc = subprocess.Popen(
            (os.path.join(tde4.get3DEInstallPath(), 'bin',
                          'makeBCFile'), '-source', path, '-start', str(start),
             '-end', str(end), '-out', os.path.dirname(target_path), sxr2,
             exr2, '-black', str(black), '-white', str(white), '-gamma',
             str(gamma), '-softclip', str(softclip)),
            stdout=subprocess.PIPE,
            universal_newlines=True)

        for line in iter(proc.stdout.readline, ''):
            line = line.rstrip()

            if line.startswith('Error'):
                proc_err = line
                continue
            elif line.endswith('image files processed'):
                frame = int(line.split('/', 1)[0])
                msg = 'Exporting: {} ({}/{})'.format(cam_name, frame, frames)
                if ui:
                    tde4.updateProgressRequester(steps_done + frame + 1, msg)
                else:
                    print('{: 3d}% {}'.format(
                        100 * (steps_done + frame + 1) / max_steps, msg))

        if proc_err:
            errors.append(
                "Couldn't create Buffer Compression File for Camera {}.".
                format(cam_name))
            errors.append('Message >>    {}'.format(proc_err))
            steps_done += steps
            continue

        msg = 'Exporting: {} (finishing)'.format(cam_name)
        if ui:
            tde4.updateProgressRequester(steps_done + frames + 2, msg)
        else:
            print('{: 3d}% {}'.format(
                100 * (steps_done + frames + 2) / max_steps, msg))
        bcompress = ('x'.join(target_path.split('#' * path.count('#'))) +
                     '.3de_bcompress')

        if not os.path.isfile(bcompress):
            errors.append(
                "Couldn't find Buffer Compression File for Camera {}.".format(
                    cam_name))
            steps_done += steps
            continue

        if not tde4.importBufferCompressionFile(cam):
            errors.append(
                "Couldn't import Buffer Compression File for Camera {}.".
                format(cam_name))

        # Change permissions of the Buffer Compression File,
        # to be nice to everyone else who might work on the shot eventually!
        try:
            os.chmod(bcompress, 0o666)
        except OSError:
            errors.append(
                "Couldn't set permissions of Buffer CompressionFile for Camera {}."
                .format(cam_name))

        steps_done += steps

    if ui:
        tde4.unpostProgressRequester()

        if errors:
            req = tde4.createCustomRequester()
            for i, line in enumerate(errors):
                name = 'line{}'.format(i)
                tde4.addLabelWidget(req, name, line, 'ALIGN_LABEL_LEFT')
                tde4.setWidgetOffsets(req, name, 0, 0, 0, 0)
            tde4.postCustomRequester(req, TITLE, 0, 0, 'Ok')

    else:
        print('100% Done.')

        if errors:
            raise RuntimeError('\n'.join(errors))
Exemple #6
0
def main():
    campg = None
    pgl = tde4.getPGroupList()
    for pg in pgl:
        if tde4.getPGroupType(pg) == "CAMERA": campg = pg
    if campg == None:
        tde4.postQuestionRequester("Export Maya...",
                                   "Error, there is no camera point group.",
                                   "Ok")

    #
    # open requester...

    try:
        req = _export_requester_maya
    except (ValueError, NameError, TypeError):
        _export_requester_maya = tde4.createCustomRequester()
        req = _export_requester_maya
        tde4.addFileWidget(req, "file_browser", "Exportfile...", "*.mel")
        tde4.addTextFieldWidget(req, "startframe_field", "Startframe", "1")
        # tde4.addOptionMenuWidget(req,"mode_menu","Orientation","Y-Up", "Z-Up")
        tde4.addToggleWidget(req, "hide_ref_frames", "Hide Reference Frames",
                             0)

    cam = tde4.getCurrentCamera()
    offset = tde4.getCameraFrameOffset(cam)
    tde4.setWidgetValue(req, "startframe_field", str(offset))

    # ret	= tde4.postCustomRequester(req,"Export Maya (MEL-Script)...",600,0,"Ok","Cancel")
    ret = 1

    if ret == 1:
        # yup	= tde4.getWidgetValue(req,"mode_menu")
        # if yup==2: yup = 0
        yup = 1
        # path	= tde4.getWidgetValue(req,"file_browser")
        path = get_mel_filename()['path']
        # frame0	= float(tde4.getWidgetValue(req,"startframe_field"))
        # frame0	-= 1
        framerange = get_frame_range()
        playbackoptions = 'playbackOptions -min {0} -max {1};'
        playbackoptions = playbackoptions.format(framerange['first'],
                                                 framerange['last'])
        frame0 = framerange['first'] - 1

        hide_ref = tde4.getWidgetValue(req, "hide_ref_frames")
        if path != None:
            if not path.endswith('.mel'): path = path + '.mel'
            f = open(path, "w")
            if not f.closed:

                #
                # write some comments...

                f.write("//\n")
                f.write("// Maya/MEL export data written by %s\n" %
                        tde4.get3DEVersion())
                f.write("//\n")
                f.write(
                    "// All lengths are in centimeter, all angles are in degree.\n"
                )
                f.write("//\n\n")

                #
                # write scene group...
                groupname = """// create scene group...
string $sceneGroupName = `group -em -name "mm_{name}"`;
"""

                # f.write("// create scene group...\n")
                # f.write("string $sceneGroupName = `group -em -name \"Scene\"`;\n")
                groupname = groupname.format(
                    name=get_mel_filename()['filename'][:-4])
                f.write(groupname)

                #
                # write cameras...

                cl = tde4.getCameraList()
                index = 1
                for cam in cl:
                    camType = tde4.getCameraType(cam)
                    noframes = tde4.getCameraNoFrames(cam)
                    lens = tde4.getCameraLens(cam)
                    if lens != None:
                        name = validName(tde4.getCameraName(cam))
                        cam_name = 'cam_mm_' + name
                        # name		= "%s_%s_1"%(name,index)
                        # name		= "%s_%s"%(name,index)
                        name = cam_name
                        index += 1
                        fback_w = tde4.getLensFBackWidth(lens)
                        fback_h = tde4.getLensFBackHeight(lens)
                        p_aspect = tde4.getLensPixelAspect(lens)
                        focal = tde4.getCameraFocalLength(cam, 1)
                        lco_x = tde4.getLensLensCenterX(lens)
                        lco_y = tde4.getLensLensCenterY(lens)

                        # convert filmback to inch...
                        fback_w = fback_w / 2.54
                        fback_h = fback_h / 2.54
                        lco_x = -lco_x / 2.54
                        lco_y = -lco_y / 2.54

                        # convert focal length to mm...
                        focal = focal * 10.0

                        # create camera...
                        f.write("\n")
                        f.write("// create camera %s...\n" % name)
                        f.write(
                            "string $cameraNodes[] = `camera -name \"%s\" -hfa %.15f  -vfa %.15f -fl %.15f -ncp 0.01 -fcp 10000 -shutterAngle 180 -ff \"overscan\"`;\n"
                            % (name, fback_w, fback_h, focal))
                        f.write("string $cameraTransform = $cameraNodes[0];\n")
                        f.write("string $cameraShape = $cameraNodes[1];\n")
                        f.write(
                            "xform -zeroTransformPivots -rotateOrder zxy $cameraTransform;\n"
                        )
                        f.write(
                            "setAttr ($cameraShape+\".horizontalFilmOffset\") %.15f;\n"
                            % lco_x)
                        f.write(
                            "setAttr ($cameraShape+\".verticalFilmOffset\") %.15f;\n"
                            % lco_y)
                        f.write("setAttr ($cameraShape+\".renderable\") 1;\n")
                        p3d = tde4.getPGroupPosition3D(campg, cam, 1)
                        p3d = convertZup(p3d, yup)
                        f.write(
                            "xform -translation %.15f %.15f %.15f $cameraTransform;\n"
                            % (p3d[0], p3d[1], p3d[2]))
                        r3d = tde4.getPGroupRotation3D(campg, cam, 1)
                        rot = convertToAngles(r3d)
                        f.write(
                            "xform -rotation %.15f %.15f %.15f $cameraTransform;\n"
                            % rot)
                        f.write("xform -scale 1 1 1 $cameraTransform;\n")
                        """add pipeline attributes to camerashape"""
                        # attribs = add_pipeline_attribs() ### OBSOLETE WAY
                        attribs = add_pipeline_parms()
                        f.write(attribs)

                        # image plane...
                        f.write("\n\n\n\n// create image plane...\n")
                        f.write(
                            "string $imagePlane = `createNode imagePlane`;\n")
                        f.write(
                            "cameraImagePlaneUpdate ($cameraShape, $imagePlane);\n"
                        )
                        f.write(
                            "setAttr ($imagePlane + \".offsetX\") %.15f;\n" %
                            lco_x)
                        f.write(
                            "setAttr ($imagePlane + \".offsetY\") %.15f;\n" %
                            lco_y)

                        if camType == "SEQUENCE":
                            f.write(
                                "setAttr ($imagePlane+\".useFrameExtension\") 1;\n"
                            )
                        else:
                            f.write(
                                "setAttr ($imagePlane+\".useFrameExtension\") 0;\n"
                            )

                        f.write(
                            "expression -n \"frame_ext_expression\" -s ($imagePlane+\".frameExtension=frame\");\n"
                        )
                        path = tde4.getCameraPath(cam)
                        sattr = tde4.getCameraSequenceAttr(cam)
                        path = prepareImagePath(path, sattr[0])
                        f.write(
                            "setAttr ($imagePlane + \".imageName\") -type \"string\" \"%s\";\n"
                            % (path))
                        f.write("setAttr ($imagePlane + \".fit\") 4;\n")
                        f.write(
                            "setAttr ($imagePlane + \".displayOnlyIfCurrent\") 1;\n"
                        )
                        f.write(
                            "setAttr ($imagePlane  + \".depth\") (9000/2);\n")

                        # parent camera to scene group...
                        f.write("\n")
                        f.write("// parent camera to scene group...\n")
                        f.write("parent $cameraTransform $sceneGroupName;\n")

                        if camType == "REF_FRAME" and hide_ref:
                            f.write(
                                "setAttr ($cameraTransform +\".visibility\") 0;\n"
                            )

                        # animate camera...
                        if camType != "REF_FRAME":
                            f.write("\n")
                            f.write("// animating camera %s...\n" % name)
                            f.write(playbackoptions)
                            # f.write("playbackOptions -min %d -max %d;\n"%(1+frame0,noframes+frame0))
                            f.write("\n\n")

                        frame = 1
                        while frame <= noframes:
                            # rot/pos...
                            p3d = tde4.getPGroupPosition3D(campg, cam, frame)
                            p3d = convertZup(p3d, yup)
                            r3d = tde4.getPGroupRotation3D(campg, cam, frame)
                            rot = convertToAngles(r3d)
                            if frame > 1:
                                rot = [
                                    angleMod360(rot0[0], rot[0]),
                                    angleMod360(rot0[1], rot[1]),
                                    angleMod360(rot0[2], rot[2])
                                ]
                            rot0 = rot
                            f.write(
                                "setKeyframe -at translateX -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, p3d[0]))
                            f.write(
                                "setKeyframe -at translateY -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, p3d[1]))
                            f.write(
                                "setKeyframe -at translateZ -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, p3d[2]))
                            f.write(
                                "setKeyframe -at rotateX -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, rot[0]))
                            f.write(
                                "setKeyframe -at rotateY -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, rot[1]))
                            f.write(
                                "setKeyframe -at rotateZ -t %d -v %.15f $cameraTransform; "
                                % (frame + frame0, rot[2]))

                            # focal length...
                            focal = tde4.getCameraFocalLength(cam, frame)
                            focal = focal * 10.0
                            f.write(
                                "setKeyframe -at focalLength -t %d -v %.15f $cameraShape;\n"
                                % (frame + frame0, focal))

                            frame += 1

                #
                # write camera point group...

                f.write("\n")
                f.write("// create camera point group...\n")
                name = "cameraPGroup_%s_1" % validName(
                    tde4.getPGroupName(campg))
                f.write(
                    "string $pointGroupName = `group -em -name  \"%s\" -parent $sceneGroupName`;\n"
                    % name)
                # f.write("$pointGroupName = ($sceneGroupName + \"|\" + $pointGroupName);\n")
                f.write("\n")

                # write points...
                l = tde4.getPointList(campg)
                for p in l:
                    if tde4.isPointCalculated3D(campg, p):
                        name = tde4.getPointName(campg, p)
                        name = "p%s" % validName(name)
                        p3d = tde4.getPointCalcPosition3D(campg, p)
                        p3d = convertZup(p3d, yup)
                        f.write("\n")
                        f.write("// create point %s...\n" % name)
                        f.write(
                            "string $locator = stringArrayToString(`spaceLocator -name %s`, \"\");\n"
                            % name)
                        f.write("$locator = (\"|\" + $locator);\n")
                        f.write("xform -t %.15f %.15f %.15f $locator;\n" %
                                (p3d[0], p3d[1], p3d[2]))
                        f.write("parent $locator $pointGroupName;\n")

                f.write("\n")
                f.write(
                    "xform -zeroTransformPivots -rotateOrder zxy -scale 1.000000 1.000000 1.000000 $pointGroupName;\n"
                )
                f.write("\n")

                #
                # write object/mocap point groups...

                camera = tde4.getCurrentCamera()
                noframes = tde4.getCameraNoFrames(camera)
                pgl = tde4.getPGroupList()
                index = 1
                for pg in pgl:
                    if tde4.getPGroupType(pg) == "OBJECT" and camera != None:
                        f.write("\n")
                        f.write("// create object point group...\n")
                        pgname = "objectPGroup_%s_%d_1" % (validName(
                            tde4.getPGroupName(pg)), index)
                        index += 1
                        f.write(
                            "string $pointGroupName = `group -em -name  \"%s\" -parent $sceneGroupName`;\n"
                            % pgname)
                        f.write(
                            "$pointGroupName = ($sceneGroupName + \"|\" + $pointGroupName);\n"
                        )

                        # write points...
                        l = tde4.getPointList(pg)
                        for p in l:
                            if tde4.isPointCalculated3D(pg, p):
                                name = tde4.getPointName(pg, p)
                                name = "p%s" % validName(name)
                                p3d = tde4.getPointCalcPosition3D(pg, p)
                                p3d = convertZup(p3d, yup)
                                f.write("\n")
                                f.write("// create point %s...\n" % name)
                                f.write(
                                    "string $locator = stringArrayToString(`spaceLocator -name %s`, \"\");\n"
                                    % name)
                                f.write("$locator = (\"|\" + $locator);\n")
                                f.write(
                                    "xform -t %.15f %.15f %.15f $locator;\n" %
                                    (p3d[0], p3d[1], p3d[2]))
                                f.write("parent $locator $pointGroupName;\n")

                        f.write("\n")
                        scale = tde4.getPGroupScale3D(pg)
                        f.write(
                            "xform -zeroTransformPivots -rotateOrder zxy -scale %.15f %.15f %.15f $pointGroupName;\n"
                            % (scale, scale, scale))

                        # animate object point group...
                        f.write("\n")
                        f.write("// animating point group %s...\n" % pgname)
                        frame = 1
                        while frame <= noframes:
                            # rot/pos...
                            p3d = tde4.getPGroupPosition3D(pg, camera, frame)
                            p3d = convertZup(p3d, yup)
                            r3d = tde4.getPGroupRotation3D(pg, camera, frame)
                            rot = convertToAngles(r3d)
                            if frame > 1:
                                rot = [
                                    angleMod360(rot0[0], rot[0]),
                                    angleMod360(rot0[1], rot[1]),
                                    angleMod360(rot0[2], rot[2])
                                ]
                            rot0 = rot
                            f.write(
                                "setKeyframe -at translateX -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[0]))
                            f.write(
                                "setKeyframe -at translateY -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[1]))
                            f.write(
                                "setKeyframe -at translateZ -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[2]))
                            f.write(
                                "setKeyframe -at rotateX -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, rot[0]))
                            f.write(
                                "setKeyframe -at rotateY -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, rot[1]))
                            f.write(
                                "setKeyframe -at rotateZ -t %d -v %.15f $pointGroupName;\n"
                                % (frame + frame0, rot[2]))

                            frame += 1

                    # mocap point groups...
                    if tde4.getPGroupType(pg) == "MOCAP" and camera != None:
                        f.write("\n")
                        f.write("// create mocap point group...\n")
                        pgname = "objectPGroup_%s_%d_1" % (validName(
                            tde4.getPGroupName(pg)), index)
                        index += 1
                        f.write(
                            "string $pointGroupName = `group -em -name  \"%s\" -parent $sceneGroupName`;\n"
                            % pgname)
                        f.write(
                            "$pointGroupName = ($sceneGroupName + \"|\" + $pointGroupName);\n"
                        )

                        # write points...
                        l = tde4.getPointList(pg)
                        for p in l:
                            if tde4.isPointCalculated3D(pg, p):
                                name = tde4.getPointName(pg, p)
                                name = "p%s" % validName(name)
                                p3d = tde4.getPointMoCapCalcPosition3D(
                                    pg, p, camera, 1)
                                p3d = convertZup(p3d, yup)
                                f.write("\n")
                                f.write("// create point %s...\n" % name)
                                f.write(
                                    "string $locator = stringArrayToString(`spaceLocator -name %s`, \"\");\n"
                                    % name)
                                f.write("$locator = (\"|\" + $locator);\n")
                                f.write(
                                    "xform -t %.15f %.15f %.15f $locator;\n" %
                                    (p3d[0], p3d[1], p3d[2]))
                                for frame in range(1, noframes + 1):
                                    p3d = tde4.getPointMoCapCalcPosition3D(
                                        pg, p, camera, frame)
                                    p3d = convertZup(p3d, yup)
                                    f.write(
                                        "setKeyframe -at translateX -t %d -v %.15f $locator; "
                                        % (frame + frame0, p3d[0]))
                                    f.write(
                                        "setKeyframe -at translateY -t %d -v %.15f $locator; "
                                        % (frame + frame0, p3d[1]))
                                    f.write(
                                        "setKeyframe -at translateZ -t %d -v %.15f $locator; "
                                        % (frame + frame0, p3d[2]))
                                f.write("parent $locator $pointGroupName;\n")

                        f.write("\n")
                        scale = tde4.getPGroupScale3D(pg)
                        f.write(
                            "xform -zeroTransformPivots -rotateOrder zxy -scale %.15f %.15f %.15f $pointGroupName;\n"
                            % (scale, scale, scale))

                        # animate mocap point group...
                        f.write("\n")
                        f.write("// animating point group %s...\n" % pgname)
                        frame = 1
                        while frame <= noframes:
                            # rot/pos...
                            p3d = tde4.getPGroupPosition3D(pg, camera, frame)
                            p3d = convertZup(p3d, yup)
                            r3d = tde4.getPGroupRotation3D(pg, camera, frame)
                            rot = convertToAngles(r3d)
                            if frame > 1:
                                rot = [
                                    angleMod360(rot0[0], rot[0]),
                                    angleMod360(rot0[1], rot[1]),
                                    angleMod360(rot0[2], rot[2])
                                ]
                            rot0 = rot
                            f.write(
                                "setKeyframe -at translateX -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[0]))
                            f.write(
                                "setKeyframe -at translateY -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[1]))
                            f.write(
                                "setKeyframe -at translateZ -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, p3d[2]))
                            f.write(
                                "setKeyframe -at rotateX -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, rot[0]))
                            f.write(
                                "setKeyframe -at rotateY -t %d -v %.15f $pointGroupName; "
                                % (frame + frame0, rot[1]))
                            f.write(
                                "setKeyframe -at rotateZ -t %d -v %.15f $pointGroupName;\n"
                                % (frame + frame0, rot[2]))

                            frame += 1

                #
                # global (scene node) transformation...

                p3d = tde4.getScenePosition3D()
                p3d = convertZup(p3d, yup)
                r3d = tde4.getSceneRotation3D()
                rot = convertToAngles(r3d)
                s = tde4.getSceneScale3D()
                f.write(
                    "xform -zeroTransformPivots -rotateOrder zxy -translation %.15f %.15f %.15f -scale %.15f %.15f %.15f -rotation %.15f %.15f %.15f $sceneGroupName;\n\n"
                    %
                    (p3d[0], p3d[1], p3d[2], s, s, s, rot[0], rot[1], rot[2]))

                f.write("\n")
                f.close()
                # tde4.postQuestionRequester("Export Maya...","Project successfully exported.","Ok")
                print '--> successfully exported Maya Mel'
            else:
                tde4.postQuestionRequester("Export Maya...",
                                           "Error, couldn't open file.", "Ok")

    return get_mel_filename()['path']
Exemple #7
0
 def type_(self):
     return tde4.getCameraType(self._cam_id)