Пример #1
0
def _saveSceneShots(sceneName, shots):
    sceneFile = os.path.join(ScenesPath(), sceneName + SCENE_EXT)
    xScene = ParseXMLWithIncludes(sceneFile)

    # save user camera position per scene
    userFile = ProjectFile() + '.user'
    if fileutil.exists(userFile):
        xUser = ParseXMLWithIncludes(userFile)
    else:
        xUser = cElementTree.Element('user')
    if sceneFile in Scene.cache:
        cameraData = Scene.cache[sceneFile].cameraData()
        if cameraData:
            for xSub in xUser:
                if xSub.tag == 'scene' and xSub.attrib['name'] == sceneName:
                    xSub.attrib['camera'] = ','.join([str(x) for x in cameraData])
                    break
            else:
                cElementTree.SubElement(xUser, 'scene', {'name': sceneName, 'camera': ','.join([str(x) for x in cameraData])})
    with fileutil.edit(userFile) as fh:
        fh.write(toPrettyXml(xUser))

    # remove old shots
    r = []
    for xShot in xScene:
        r.append(xShot)
    for s in r:
        xScene.remove(s)

    targets = []
    for shot in shots:
        if shot.sceneName == sceneName:
            targets.append(shot)

    for shot in targets:
        xShot = cElementTree.SubElement(xScene, 'Shot', {'name': shot.name, 'scene': sceneName, 'start': str(shot.start), 'end': str(shot.end), 'enabled': str(shot.enabled), 'speed': str(shot.speed),
                                                         'preroll': str(shot.preroll)})
        for curveName in shot.curves:
            xChannel = cElementTree.SubElement(xShot, 'Channel', {'name': curveName, 'mode': 'hermite'})
            data = []
            for key in shot.curves[curveName]:
                data.append(str(key.inTangent.x))
                data.append(str(key.inTangent.y))
                data.append(str(key.point().x))
                data.append(str(key.point().y))
                data.append(str(key.outTangent.x))
                data.append(str(key.outTangent.y))
                data.append(str(int(key.tangentBroken)))
                data.append(str(key.tangentMode))
            xChannel.text = ','.join(data)
        for texName in shot.textures:
            cElementTree.SubElement(xShot, 'Texture', {'name': texName, 'path': shot.textures[texName]})

    with fileutil.edit(sceneFile) as fh:
        fh.write(toPrettyXml(xScene))
Пример #2
0
    def saveToProject(self):
        project = currentProjectFilePath()
        root = parseXMLWithIncludes(project)

        xModels = cElementTree.SubElement(root, 'Models')
        for model in self._models:
            model.saveToElementTree(xModels)

        with project.edit() as fh:
            fh.write(toPrettyXml(root))
Пример #3
0
    def saveState(self):
        gSettings.setValue('TimerStartTime', self.__start)
        gSettings.setValue('TimerEndTime', self.__end)
        gSettings.setValue('TimerTime', self.__time)

        project = ProjectFile()
        if not project or not fileutil.exists(project):
            # legacy project or no project open
            gSettings.setValue('TimerMinTime', self.__minTime)
            gSettings.setValue('TimerMaxTime', self.__maxTime)
            gSettings.setValue('TimerBPS', self.__BPS)
            return
        root = cElementTree.Element('Project')
        root.attrib['TimerMinTime'] = str(self.__minTime)
        root.attrib['TimerMaxTime'] = str(self.__maxTime)
        root.attrib['TimerBPS'] = str(self.__BPS)
        with fileutil.edit(project, 'w') as fh:
            fh.write(toPrettyXml(root))
Пример #4
0
    def saveState(self):
        # save user camera position per scene
        userFile = currentProjectFilePath().ensureExt('user')
        if userFile.exists():
            xUser = parseXMLWithIncludes(userFile)
        else:
            xUser = cElementTree.Element('user')

        xMod = xUser.find('Modeler')
        if xMod is None:
            xMod = cElementTree.SubElement(xUser, 'Modeler')

        if not self._currentModel is None:
            xMod.set('CurrentModel', str(self._models.models.index(self._currentModel)))

        xMod.set('CameraTransform', ','.join(map(str, self._cameraTransform[:])))
        xMod.set('CameraPivot', ','.join(map(str, self._cameraPivot[:])))

        with userFile.edit() as fh:
            fh.write(toPrettyXml(xUser))