Exemplo n.º 1
0
    def run(self, context):
        # log.debug3("{0} vrconcatNode.run ...", self.id)

        ret = True
        scene = context.get('vrscene')

        if not scene:
            log.error("Cannot concatenate, context has no scene defined !")
            ret = False
        else:
            '''
            if context not in self._outScenes:
                print "add scene to outs"
                self._outScenes[context] = VRScene()

            if context not in self._outPlugins:
                print "init plugins dict"
                self._outPlugins[context] = dict()

            vrs = self._outScenes[context]
            '''
            vrs = VRScene()

            for field in self.getInputs():
                if not field.linked:
                    continue

                '''
                if field.id not in self._outPlugins[context]:
                    self._outPlugins[context][field.id] = None
                '''

                heap = field.heap(context)

                if not heap:
                    print "{0} has no heap".format(field.id)
                    continue

                while heap:
                    token = heap.pop(0)

                    if token.isEmpty():
                        continue

                    plugin = token.value
                    msg = "add {0} {1} to vrscene ({2} {3} / {4} - {5})"
                    msg = msg.format(plugin.getName(), plugin.getType(),
                                     field.fieldId, token.index, token.size,
                                     context.hash)
                    log.debug2(msg, tags=['run'])
                    vrs.add(token.value, scene.renderer)

            ret = self.generateVRScene(context, vrs)

        # log.debug3("{0} vrconcatNode.run: {1}", self.id, ret)
        return ret
Exemplo n.º 2
0
    def concatVRScene(self, context, renderer):
        log.debug('CONCAT {0}', context)

        inputs = ['shapes', 'shaders', 'lights', 'nodes', 'settings', 'others']
        plugins = dict()
        fields = self._inHeap.get(context, dict())

        context = None
        for field in inputs:
            values = [token.value for token in fields.get(field, list())]
            plugins[field] = values
            context = token.context

        scene = context.token.value
        vrs = VRScene()

        for field, plugs in plugins.iteritems():
            vrs.add(plugs, renderer)

        base = os.path.basename(scene)
        path = 'C:/work/scenes/vray/export/{0}'.format(base)
        base = os.path.dirname(path)

        if not os.path.exists(base):
            os.makedirs(base)

        log.debug('EXPORT TO {0}', path)
        vrs.save(path)

        render = self.field('render').value

        if render:
            vrs.render(wait=3)

        if os.path.exists(path):
            log.debug('{0} DONE !')
            self.field('path').push(context, path)
        else:
            log.debug('FAILED !')