示例#1
0
    def execute(self, context):
        VRayExporter = context.scene.vray.Exporter

        selectedNodeTree = VRayExporter.ntreeListIndex
        if selectedNodeTree == -1:
            return {'CANCELLED'}

        ntree = bpy.data.node_groups[selectedNodeTree]

        outputNode = NodesExport.GetOutputNode(ntree)
        if not outputNode:
            return {'CANCELLED'}

        exportPath = BlenderUtils.GetFullFilepath(VRayExporter.ntreeExportDirectory)
        exportPath = PathUtils.CreateDirectory(exportPath)

        fileName = "%s.vrscene" % LibUtils.CleanString(ntree.name)

        outputFilepath = os.path.normpath(os.path.join(exportPath, fileName))

        debug.PrintInfo('Exporting "%s" to: "%s"' % (ntree.name, outputFilepath))

        o = VRayStream.VRaySimplePluginExporter(outputFilepath)

        exporter = _vray_for_blender.init(
            engine  = 0,
            context = bpy.context.as_pointer(),
            scene   = bpy.context.scene.as_pointer(),
            data    = bpy.data.as_pointer(),

            mainFile     = o.output,
            objectFile   = o.output,
            envFile      = o.output,
            geometryFile = o.output,
            lightsFile   = o.output,
            materialFile = o.output,
            textureFile  = o.output,

            drSharePath = "",
        )

        for sock in outputNode.inputs:
            conNode = NodesExport.GetConnectedNode(ntree, sock)
            if conNode:
                _vray_for_blender.exportNode(
                    ntree.as_pointer(),
                    conNode.as_pointer(),
                    sock.as_pointer()
                )

        _vray_for_blender.exit(exporter)

        return {'FINISHED'}
示例#2
0
    def execute(self, context):
        VRayExporter = context.scene.vray.Exporter

        selectedNodeTree = VRayExporter.ntreeListIndex
        if selectedNodeTree == -1:
            return {'CANCELLED'}

        ntree = bpy.data.node_groups[selectedNodeTree]

        outputNode = NodesExport.GetOutputNode(ntree)
        if not outputNode:
            return {'CANCELLED'}

        exportPath = BlenderUtils.GetFullFilepath(
            VRayExporter.ntreeExportDirectory)
        exportPath = PathUtils.CreateDirectory(exportPath)

        fileName = "%s.vrscene" % LibUtils.CleanString(ntree.name)

        outputFilepath = os.path.normpath(os.path.join(exportPath, fileName))

        debug.PrintInfo('Exporting "%s" to: "%s"' %
                        (ntree.name, outputFilepath))

        o = VRayStream.VRaySimplePluginExporter(outputFilepath)

        exporter = _vray_for_blender.init(
            engine=0,
            context=bpy.context.as_pointer(),
            scene=bpy.context.scene.as_pointer(),
            data=bpy.data.as_pointer(),
            mainFile=o.output,
            objectFile=o.output,
            envFile=o.output,
            geometryFile=o.output,
            lightsFile=o.output,
            materialFile=o.output,
            textureFile=o.output,
            drSharePath="",
        )

        for sock in outputNode.inputs:
            conNode = NodesExport.GetConnectedNode(ntree, sock)
            if conNode:
                _vray_for_blender.exportNode(ntree.as_pointer(),
                                             conNode.as_pointer(),
                                             sock.as_pointer())

        _vray_for_blender.exit(exporter)

        return {'FINISHED'}
示例#3
0
def WriteConnectedNode(_unused_, nodetree, nodeSocket):
    connectedNode = GetConnectedNode(nodetree, nodeSocket)
    if connectedNode:
        return _vray_for_blender.exportNode(
            nodetree.as_pointer(),
            connectedNode.as_pointer(),
            nodeSocket.as_pointer()
        )
示例#4
0
文件: preset.py 项目: JuhaW/vb30
    def execute(self, context):
        if not self.asset_name:
            self.report({'ERROR'}, "Asset name is not set!")
            return {'CANCELLED'}

        presetsPath       = PathUtils.CreateDirectory(os.path.join(SysUtils.GetUserConfigDir(), "presets"))
        userNodeAssetPath = PathUtils.CreateDirectory(os.path.join(presetsPath, self.asset_type))

        fileName = "%s.vrscene" % LibUtils.CleanString(bpy.path.display_name(self.asset_name))

        outputFilepath = os.path.normpath(os.path.join(userNodeAssetPath, fileName))

        # Create exporter (output)
        o = VRayStream.VRaySimplePluginExporter(outputFilepath)

        exporter = _vray_for_blender.init(
            engine  = 0,
            context = bpy.context.as_pointer(),
            scene   = bpy.context.scene.as_pointer(),
            data    = bpy.data.as_pointer(),

            mainFile     = o.output,
            objectFile   = o.output,
            envFile      = o.output,
            geometryFile = o.output,
            lightsFile   = o.output,
            materialFile = o.output,
            textureFile  = o.output,

            drSharePath = "",
        )

        # Get selected nodes
        ntree        = context.space_data.edit_tree
        selectedNode = context.selected_nodes[0]

        if selectedNode.bl_idname == 'VRayNodeRenderChannels':
            pluginNames = []

            for inSock in selectedNode.inputs:
                pluginNames.append(NodesExport.WriteConnectedNode(None, ntree, inSock))

            pluginName = "List(%s)" % ",".join(pluginNames)

        else:
            if selectedNode.bl_idname == 'VRayNodeOutputMaterial':
                selectedNode = NodesExport.GetConnectedNode(ntree, selectedNode.inputs['Material'])

            pluginName = _vray_for_blender.exportNode(
                ntree.as_pointer(),
                selectedNode.as_pointer(),
                None
            )

        # Write fake Asset node
        o.set('MAIN', 'Asset', self.asset_type.capitalize())
        o.writeHeader()
        o.writeAttibute(self.asset_type, pluginName)
        o.writeFooter()
        o.done()

        _vray_for_blender.exit(exporter)

        return {'FINISHED'}
    def execute(self, context):
        if not self.asset_name:
            self.report({'ERROR'}, "Asset name is not set!")
            return {'CANCELLED'}

        presetsPath       = PathUtils.CreateDirectory(os.path.join(SysUtils.GetUserConfigDir(), "presets"))
        userNodeAssetPath = PathUtils.CreateDirectory(os.path.join(presetsPath, self.asset_type))

        fileName = "%s.vrscene" % LibUtils.CleanString(bpy.path.display_name(self.asset_name))

        outputFilepath = os.path.normpath(os.path.join(userNodeAssetPath, fileName))

        # Create exporter (output)
        o = VRayStream.VRaySimplePluginExporter(outputFilepath)

        exporter = _vray_for_blender.init(
            engine  = 0,
            context = bpy.context.as_pointer(),
            scene   = bpy.context.scene.as_pointer(),
            data    = bpy.data.as_pointer(),

            mainFile     = o.output,
            objectFile   = o.output,
            envFile      = o.output,
            geometryFile = o.output,
            lightsFile   = o.output,
            materialFile = o.output,
            textureFile  = o.output,

            drSharePath = "",
        )

        # Get selected nodes
        ntree        = context.space_data.edit_tree
        selectedNode = context.selected_nodes[0]

        if selectedNode.bl_idname == 'VRayNodeRenderChannels':
            pluginNames = []

            for inSock in selectedNode.inputs:
                pluginNames.append(NodesExport.WriteConnectedNode(None, ntree, inSock))

            pluginName = "List(%s)" % ",".join(pluginNames)

        else:
            if selectedNode.bl_idname == 'VRayNodeOutputMaterial':
                selectedNode = NodesExport.GetConnectedNode(ntree, selectedNode.inputs['Material'])

            pluginName = _vray_for_blender.exportNode(
                ntree.as_pointer(),
                selectedNode.as_pointer(),
                None
            )

        # Write fake Asset node
        o.set('MAIN', 'Asset', self.asset_type.capitalize())
        o.writeHeader()
        o.writeAttibute(self.asset_type, pluginName)
        o.writeFooter()
        o.done()

        _vray_for_blender.exit(exporter)

        return {'FINISHED'}