diff options
Diffstat (limited to 'intern/cycles/blender/addon')
-rw-r--r-- | intern/cycles/blender/addon/__init__.py | 73 | ||||
-rw-r--r-- | intern/cycles/blender/addon/engine.py | 107 | ||||
-rw-r--r-- | intern/cycles/blender/addon/enums.py | 113 | ||||
-rw-r--r-- | intern/cycles/blender/addon/properties.py | 120 | ||||
-rw-r--r-- | intern/cycles/blender/addon/ui.py | 388 | ||||
-rw-r--r-- | intern/cycles/blender/addon/xml.py | 99 |
6 files changed, 900 insertions, 0 deletions
diff --git a/intern/cycles/blender/addon/__init__.py b/intern/cycles/blender/addon/__init__.py new file mode 100644 index 00000000000..0a2e5cee142 --- /dev/null +++ b/intern/cycles/blender/addon/__init__.py @@ -0,0 +1,73 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +bl_info = { + "name": "Cycles Render Engine", + "author": "", + "version": (0,0), + "blender": (2, 5, 6), + "api": 34462, + "location": "Info header, render engine menu", + "description": "Cycles Render Engine integration.", + "warning": "", + "wiki_url": "", + "tracker_url": "", + "category": "Render"} + +import bpy + +from cycles import ui +from cycles import properties +from cycles import xml +from cycles import engine + +class CyclesRender(bpy.types.RenderEngine): + bl_idname = 'CYCLES' + bl_label = "Cycles" + + def __init__(self): + engine.init() + self.session = None + + def __del__(self): + engine.free(self) + + def render(self, scene): + engine.create(self, scene, True) + engine.render(self, scene) + + def draw(self, scene): + if not self.session: + engine.create(self, scene, False) + engine.draw(self, scene) + + def update(self, scene): + engine.update(self, scene) + +def register(): + properties.register() + ui.register() + xml.register() + bpy.utils.register_module(__name__) + +def unregister(): + xml.unregister() + ui.unregister() + properties.unregister() + bpy.utils.unregister_module(__name__) + diff --git a/intern/cycles/blender/addon/engine.py b/intern/cycles/blender/addon/engine.py new file mode 100644 index 00000000000..fb98068766f --- /dev/null +++ b/intern/cycles/blender/addon/engine.py @@ -0,0 +1,107 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import bpy + +def init(): + from cycles import libcycles_blender as lib + import os.path + lib.init(os.path.dirname(__file__)) + +def create(engine, scene, offline): + from cycles import libcycles_blender as lib + data = bpy.data.as_pointer() + scene = scene.as_pointer() + + if not offline and bpy.context.area.type == 'VIEW_3D': + region = bpy.context.region.as_pointer() + v3d = bpy.context.space_data.as_pointer() + rv3d = bpy.context.region_data.as_pointer() + else: + region = 0 + v3d = 0 + rv3d = 0 + + engine.session = lib.create(engine.as_pointer(), data, scene, region, v3d, rv3d) + +def free(engine): + if "session" in dir(engine): + if engine.session: + from cycles import libcycles_blender as lib + lib.free(engine.session) + del engine.session + +def render(engine, scene): + from cycles import libcycles_blender as lib + lib.render(engine.session) + +def update(engine, scene): + from cycles import libcycles_blender as lib + lib.sync(engine.session) + +def draw(engine, scene): + from cycles import libcycles_blender as lib + v3d = bpy.context.space_data.as_pointer() + rv3d = bpy.context.region_data.as_pointer() + region = bpy.context.region + + # draw render image + status, substatus = lib.draw(engine.session, v3d, rv3d) + + # draw text over image + if status != "": + import blf + import bgl + + fontid = 0 # todo, find out how to set this + dim = blf.dimensions(fontid, status) + dim_sub = blf.dimensions(fontid, substatus) + + padding = 5 + + x = (region.width - max(dim[0], dim_sub[0]))*0.5 - padding + y = (region.height - (dim[1] + dim_sub[1] + padding))*0.5 - padding + + bgl.glColor4f(0.0, 0.0, 0.0, 0.5) + bgl.glEnable(bgl.GL_BLEND) + bgl.glBlendFunc(bgl.GL_SRC_ALPHA, bgl.GL_ONE_MINUS_SRC_ALPHA) + bgl.glRectf(x, y, x+max(dim[0], dim_sub[0])+padding+padding, y+dim[1]+dim_sub[1]+padding+padding+2) + bgl.glDisable(bgl.GL_BLEND) + + x = (region.width - dim[0])*0.5 + y = (region.height - (dim[1] + dim_sub[1] + padding))*0.5 + dim_sub[1] + padding + + bgl.glColor3f(0.8, 0.8, 0.8) + blf.position(fontid, x, y, 0) + blf.draw(fontid, status) + + x = (region.width - dim_sub[0])*0.5 + y = (region.height - (dim[1] + dim_sub[1] + padding))*0.5 + + bgl.glColor3f(0.6, 0.6, 0.6) + blf.position(fontid, x, y, 0) + blf.draw(fontid, substatus) + +def available_devices(): + from cycles import libcycles_blender as lib + return lib.available_devices() + +def with_osl(): + from cycles import libcycles_blender as lib + return lib.with_osl() + diff --git a/intern/cycles/blender/addon/enums.py b/intern/cycles/blender/addon/enums.py new file mode 100644 index 00000000000..fd12fa6d5a5 --- /dev/null +++ b/intern/cycles/blender/addon/enums.py @@ -0,0 +1,113 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +devices = ( +("CPU", "CPU", "Processor"), +("GPU", "GPU", "Graphics card (NVidia only)")) + +shading_systems = ( +("GPU_COMPATIBLE", "GPU Compatible", "Restricted shading system compatible with GPU rendering"), +("OSL", "Open Shading Language", "Open Shading Language shading system that only runs on the CPU")) + +displacement_methods = ( +("BUMP", "Bump", "Bump mapping to simulate the appearance of displacement"), +("TRUE", "True", "Use true displacement only, requires fine subdivision"), +("BOTH", "Both", "Combination of displacement and bump mapping")) + +bvh_types = ( +("DYNAMIC_BVH", "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"), +("STATIC_BVH", "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster")) + +response_curves = ( +("None", "None", ""), +("", "Agfa", ""), +("Agfacolor Futura 100", "Futura 100", ""), +("Agfacolor Futura 200", "Futura 200", ""), +("Agfacolor Futura 400", "Futura 400", ""), +("Agfacolor Futura II 100", "Futura II 100", ""), +("Agfacolor Futura II 200", "Futura II 200", ""), +("Agfacolor Futura II 400", "Futura II 400", ""), +("Agfacolor HDC 100 plus", "HDC 100 plus", ""), +("Agfacolor HDC 400 plus", "HDC 400 plus", ""), +("Agfacolor HDC 200 plus", "HDC 200 plus", ""), +("Agfacolor Optima II 100", "Optima II 100", ""), +("Agfacolor Optima II 200", "Optima II 200", ""), +("Agfacolor Ultra 050", "Ultra 050", ""), +("", "Agfa", ""), +("Agfacolor Vista 100", "Vista 100", ""), +("Agfacolor Vista 200", "Vista 200", ""), +("Agfacolor Vista 400", "Vista 400", ""), +("Agfacolor Vista 800", "Vista 800", ""), +("Agfachrome CT Precisa 100", "CT Precisa 100", ""), +("Agfachrome CT Precisa 200", "CT Precisa 200", ""), +("Agfachrome RSX2 050", "Agfachrome RSX2 050", ""), +("Agfachrome RSX2 100", "Agfachrome RSX2 100", ""), +("Agfachrome RSX2 200", "Agfachrome RSX2 200", ""), +("Advantix 100", "Advantix 100", ""), +("Advantix 200", "Advantix 200", ""), +("Advantix 400", "Advantix 400", ""), +("", "Kodak", ""), +("Gold 100", "Gold 100", ""), +("Gold 200", "Gold 200", ""), +("Max Zoom 800", "Max Zoom 800", ""), +("Portra 100T", "Portra 100T", ""), +("Portra 160NC", "Portra 160NC", ""), +("Portra 160VC", "Portra 160VC", ""), +("Portra 800", "Portra 800", ""), +("Portra 400VC", "Portra 400VC", ""), +("Portra 400NC", "Portra 400NC", ""), +("", "Kodak", ""), +("Ektachrome 100 plus", "Ektachrome 100 plus", ""), +("Ektachrome 320T", "Ektachrome 320T", ""), +("Ektachrome 400X", "Ektachrome 400X", ""), +("Ektachrome 64", "Ektachrome 64", ""), +("Ektachrome 64T", "Ektachrome 64T", ""), +("Ektachrome E100S", "Ektachrome E100S", ""), +("Ektachrome 100", "Ektachrome 100", ""), +("Kodachrome 200", "Kodachrome 200", ""), +("Kodachrome 25", "Kodachrome 25", ""), +("Kodachrome 64", "Kodachrome 64", ""), +#("DSCS 3151", "DSCS 3151", ""), +#("DSCS 3152", "DSCS 3152", ""), +#("DSCS 3153", "DSCS 3153", ""), +#("DSCS 3154", "DSCS 3154", ""), +#("DSCS 3155", "DSCS 3155", ""), +#("DSCS 3156", "DSCS 3156", ""), +#("KAI-0311", "KAI-0311", ""), +#("KAF-2001", "KAF-2001", ""), +#("KAF-3000", "KAF-3000", ""), +#("KAI-0372", "KAI-0372", ""), +#("KAI-1010", "KAI-1010", ""), +("", "Fujifilm", ""), +("F-125", "F-125", ""), +("F-250", "F-250", ""), +("F-400", "F-400", ""), +("FCI", "FCI", ""), +("FP2900Z", "FP2900Z", ""), +("", "Eastman", ""), +("Double X Neg 12min", "Double X Neg 12min", ""), +("Double X Neg 6min", "Double X Neg 6min", ""), +("Double X Neg 5min", "Double X Neg 5min", ""), +("Double X Neg 4min", "Double X Neg 4min", ""), +("", "Canon", ""), +("Optura 981111", "Optura 981111", ""), +("Optura 981113", "Optura 981113", ""), +("Optura 981114", "Optura 981114", ""), +("Optura 981111.SLRR", "Optura 981111.SLRR", "") +) + diff --git a/intern/cycles/blender/addon/properties.py b/intern/cycles/blender/addon/properties.py new file mode 100644 index 00000000000..3ec0587d89c --- /dev/null +++ b/intern/cycles/blender/addon/properties.py @@ -0,0 +1,120 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import bpy +from bpy.props import * + +from cycles import enums + +class CyclesRenderSettings(bpy.types.PropertyGroup): + @classmethod + def register(cls): + bpy.types.Scene.cycles = PointerProperty(type=cls, name="Cycles Render Settings", description="Cycles Render Settings") + + cls.device = EnumProperty(name="Device", description="Device to use for rendering", + items=enums.devices, default="CPU") + + cls.shading_system = EnumProperty(name="Shading System", description="Shading system to use for rendering", + items=enums.shading_systems, default="GPU_COMPATIBLE") + + cls.passes = IntProperty(name="Passes", description="Number of passes to render", + default=10, min=1, max=2147483647) + cls.min_bounces = IntProperty(name="Min Bounces", description="Minimum number of bounces", + default=3, min=0, max=1024) + cls.max_bounces = IntProperty(name="Max Bounces", description="Maximum number of bounces", + default=8, min=0, max=1024) + cls.no_caustics = BoolProperty(name="No Caustics", description="Leave out caustics, resulting in a darker image with less noise", + default=False) + cls.blur_caustics = FloatProperty(name="Blur Caustics", description="Blur caustics to reduce noise", + default=0.0, min=0.0, max=1.0) + + cls.exposure = FloatProperty(name="Exposure", description="Image brightness scale", + default=1.0, min=0.0, max=10.0) + cls.response_curve = EnumProperty(name="Response Curve", description="Measured camera film response", + items=enums.response_curves, default="Advantix 400") + + cls.debug_tile_size = IntProperty(name="Tile Size", description="", + default=1024, min=1, max=4096) + cls.debug_min_size = IntProperty(name="Min Size", description="", + default=64, min=1, max=4096) + cls.debug_reset_timeout = FloatProperty(name="Reset timeout", description="", + default=0.1, min=0.01, max=10.0) + cls.debug_cancel_timeout = FloatProperty(name="Cancel timeout", description="", + default=0.1, min=0.01, max=10.0) + cls.debug_text_timeout = FloatProperty(name="Text timeout", description="", + default=1.0, min=0.01, max=10.0) + + cls.debug_bvh_type = EnumProperty(name="BVH Type", description="Choose between faster updates, or faster render", + items=enums.bvh_types, default="DYNAMIC_BVH") + cls.debug_use_spatial_splits = BoolProperty(name="Use Spatial Splits", description="Use BVH spatial splits: longer builder time, faster render", + default=False) + + @classmethod + def unregister(cls): + del bpy.types.Scene.cycles + +class CyclesCameraSettings(bpy.types.PropertyGroup): + @classmethod + def register(cls): + bpy.types.Camera.cycles = PointerProperty(type=cls, name="Cycles Camera Settings", description="Cycles Camera Settings") + + cls.lens_radius = FloatProperty(name="Lens radius", description="Lens radius for depth of field", + default=0.0, min=0.0, max=10.0) + + @classmethod + def unregister(cls): + del bpy.types.Camera.cycles + +class CyclesMaterialSettings(bpy.types.PropertyGroup): + @classmethod + def register(cls): + bpy.types.Material.cycles = PointerProperty(type=cls, name="Cycles Material Settings", description="Cycles Material Settings") + + @classmethod + def unregister(cls): + del bpy.types.Material.cycles + +class CyclesMeshSettings(bpy.types.PropertyGroup): + @classmethod + def register(cls): + bpy.types.Mesh.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles Mesh Settings") + bpy.types.Curve.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles Mesh Settings") + bpy.types.MetaBall.cycles = PointerProperty(type=cls, name="Cycles Mesh Settings", description="Cycles Mesh Settings") + + cls.displacement_method = EnumProperty(name="Displacement Method", description="Method to use for the displacement", + items=enums.displacement_methods, default="BUMP") + cls.use_subdivision = BoolProperty(name="Use Subdivision", description="Subdivide mesh for rendering", + default=False) + cls.dicing_rate = FloatProperty(name="Dicing Rate", description="", default=1.0, min=0.001, max=1000.0) + + @classmethod + def unregister(cls): + del bpy.types.Mesh.cycles + +def register(): + bpy.utils.register_class(CyclesRenderSettings) + bpy.utils.register_class(CyclesCameraSettings) + bpy.utils.register_class(CyclesMaterialSettings) + bpy.utils.register_class(CyclesMeshSettings) + +def unregister(): + bpy.utils.unregister_class(CyclesRenderSettings) + bpy.utils.unregister_class(CyclesCameraSettings) + bpy.utils.unregister_class(CyclesMaterialSettings) + bpy.utils.unregister_class(CyclesMeshSettings) + diff --git a/intern/cycles/blender/addon/ui.py b/intern/cycles/blender/addon/ui.py new file mode 100644 index 00000000000..2c4f24db2c5 --- /dev/null +++ b/intern/cycles/blender/addon/ui.py @@ -0,0 +1,388 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +import bpy + +from cycles import enums +from cycles import engine + +class CyclesButtonsPanel(): + bl_space_type = "PROPERTIES" + bl_region_type = "WINDOW" + bl_context = "render" + + @classmethod + def poll(cls, context): + rd = context.scene.render + return rd.engine == 'CYCLES' + +class CyclesRender_PT_integrator(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Integrator" + + def draw(self, context): + layout = self.layout + + scene = context.scene + cycles = scene.cycles + + split = layout.split() + + col = split.column() + col.prop(cycles, "passes") + col.prop(cycles, "no_caustics") + + col = split.column() + col = col.column(align=True) + col.prop(cycles, "max_bounces") + col.prop(cycles, "min_bounces") + + #row = col.row() + #row.prop(cycles, "blur_caustics") + #row.active = not cycles.no_caustics + +class CyclesRender_PT_film(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Film" + + def draw(self, context): + layout = self.layout + + scene = context.scene + cycles = scene.cycles + + split = layout.split() + + split.prop(cycles, "exposure") + split.prop(cycles, "response_curve", text="") + +class CyclesRender_PT_debug(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Debug" + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + + scene = context.scene + cycles = scene.cycles + + split = layout.split() + + col = split.column() + + sub = col.column(align=True) + sub.prop(cycles, "debug_bvh_type", text="") + sub.prop(cycles, "debug_use_spatial_splits") + + sub = col.column(align=True) + sub.prop(cycles, "debug_tile_size") + sub.prop(cycles, "debug_min_size") + + col = split.column(align=True) + col.prop(cycles, "debug_cancel_timeout") + col.prop(cycles, "debug_reset_timeout") + col.prop(cycles, "debug_text_timeout") + +class Cycles_PT_post_processing(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Post Processing" + bl_options = {'DEFAULT_CLOSED'} + + def draw(self, context): + layout = self.layout + + rd = context.scene.render + + split = layout.split() + + col = split.column() + col.prop(rd, "use_compositing") + col.prop(rd, "use_sequencer") + + col = split.column() + col.prop(rd, "dither_intensity", text="Dither", slider=True) + +class Cycles_PT_camera(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Cycles" + bl_context = "data" + + @classmethod + def poll(cls, context): + return context.camera + + def draw(self, context): + layout = self.layout + + camera = context.camera + cycles = camera.cycles + + layout.prop(cycles, "lens_radius") + +class Cycles_PT_context_material(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Surface" + bl_context = "material" + bl_options = {'HIDE_HEADER'} + + @classmethod + def poll(cls, context): + return (context.material or context.object) and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + mat = context.material + ob = context.object + slot = context.material_slot + space = context.space_data + + if ob: + row = layout.row() + + row.template_list(ob, "material_slots", ob, "active_material_index", rows=2) + + col = row.column(align=True) + col.operator("object.material_slot_add", icon='ZOOMIN', text="") + col.operator("object.material_slot_remove", icon='ZOOMOUT', text="") + + col.menu("MATERIAL_MT_specials", icon='DOWNARROW_HLT', text="") + + if ob.mode == 'EDIT': + row = layout.row(align=True) + row.operator("object.material_slot_assign", text="Assign") + row.operator("object.material_slot_select", text="Select") + row.operator("object.material_slot_deselect", text="Deselect") + + split = layout.split(percentage=0.65) + + if ob: + split.template_ID(ob, "active_material", new="material.new") + row = split.row() + + if slot: + row.prop(slot, "link", text="") + else: + row.label() + elif mat: + split.template_ID(space, "pin_id") + split.separator() + +class Cycles_PT_mesh_displacement(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Displacement" + bl_context = "data" + + @classmethod + def poll(cls, context): + return context.mesh or context.curve or context.meta_ball + + def draw(self, context): + layout = self.layout + + mesh = context.mesh + curve = context.curve + mball = context.meta_ball + + if mesh: + cycles = mesh.cycles + elif curve: + cycles = curve.cycles + elif mball: + cycles = mball.cycles + + layout.prop(cycles, "displacement_method", text="Method") + layout.prop(cycles, "use_subdivision"); + layout.prop(cycles, "dicing_rate"); + +def find_node(material, nodetype): + if material and material.node_tree: + ntree = material.node_tree + + for node in ntree.nodes: + if type(node) is not bpy.types.NodeGroup and node.type == nodetype: + return node + + return None + +def find_node_input(node, name): + for input in node.inputs: + if input.name == name: + return input + + return None + +def panel_node_draw(layout, id, output_type, input_name): + if not id.node_tree: + layout.prop(id, "use_nodes") + return + + ntree = id.node_tree + + node = find_node(id, output_type) + if not node: + layout.label(text="No output node.") + + input = find_node_input(node, input_name) + layout.template_node_view(id, ntree, node, input); + +class CyclesLamp_PT_lamp(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Surface" + bl_context = "data" + + @classmethod + def poll(cls, context): + return context.lamp and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + mat = context.lamp + panel_node_draw(layout, mat, 'OUTPUT_LAMP', 'Surface') + +class CyclesWorld_PT_surface(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Surface" + bl_context = "world" + + @classmethod + def poll(cls, context): + return context.world and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + mat = context.world + panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Surface') + +class CyclesWorld_PT_volume(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Volume" + bl_context = "world" + + @classmethod + def poll(cls, context): + return context.world and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + layout.active = False + + mat = context.world + panel_node_draw(layout, mat, 'OUTPUT_WORLD', 'Volume') + +class CyclesMaterial_PT_surface(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Surface" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + mat = context.material + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface') + +class CyclesMaterial_PT_volume(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Volume" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + layout.active = False + + mat = context.material + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Volume') + +class CyclesMaterial_PT_displacement(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Displacement" + bl_context = "material" + + @classmethod + def poll(cls, context): + return context.material and CyclesButtonsPanel.poll(context) + + def draw(self, context): + layout = self.layout + + mat = context.material + panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement') + +class CyclesMaterial_PT_settings(CyclesButtonsPanel, bpy.types.Panel): + bl_label = "Settings" + bl_context = "material" + bl_options = {'DEFAULT_CLOSED'} + + @classmethod + def poll(cls, context): + # return context.material and CyclesButtonsPanel.poll(context) + return False + + def draw(self, context): + layout = self.layout + + mat = context.material + + row = layout.row() + row.label(text="Light Group:") + row.prop(mat, "light_group", text="") + +def draw_device(self, context): + scene = context.scene + layout = self.layout + + if scene.render.engine == "CYCLES": + cycles = scene.cycles + + if 'cuda' in engine.available_devices(): + layout.prop(cycles, "device") + if cycles.device == 'CPU' and engine.with_osl(): + layout.prop(cycles, "shading_system") + +def get_panels(): + return [ + bpy.types.RENDER_PT_render, + bpy.types.RENDER_PT_output, + bpy.types.RENDER_PT_encoding, + bpy.types.RENDER_PT_dimensions, + bpy.types.RENDER_PT_stamp, + bpy.types.WORLD_PT_context_world, + bpy.types.DATA_PT_context_mesh, + bpy.types.DATA_PT_vertex_groups, + bpy.types.DATA_PT_shape_keys, + bpy.types.DATA_PT_uv_texture, + bpy.types.DATA_PT_vertex_colors, + bpy.types.DATA_PT_custom_props_mesh, + bpy.types.DATA_PT_context_camera, + bpy.types.DATA_PT_camera, + bpy.types.DATA_PT_camera_display, + bpy.types.DATA_PT_custom_props_camera, + bpy.types.DATA_PT_context_lamp, + bpy.types.DATA_PT_custom_props_lamp, + bpy.types.TEXTURE_PT_context_texture] + +def register(): + bpy.types.RENDER_PT_render.append(draw_device) + + for panel in get_panels(): + panel.COMPAT_ENGINES.add('CYCLES') + +def unregister(): + bpy.types.RENDER_PT_render.remove(draw_device) + + for panel in get_panels(): + panel.COMPAT_ENGINES.remove('CYCLES') + diff --git a/intern/cycles/blender/addon/xml.py b/intern/cycles/blender/addon/xml.py new file mode 100644 index 00000000000..4d1b43d4d95 --- /dev/null +++ b/intern/cycles/blender/addon/xml.py @@ -0,0 +1,99 @@ +# +# Copyright 2011, Blender Foundation. +# +# This program is free software; you can redistribute it and/or +# modify it under the terms of the GNU General Public License +# as published by the Free Software Foundation; either version 2 +# of the License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software Foundation, +# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. +# + +# XML exporter for generating test files, not intended for end users + +import os +import bpy +import io_utils +import xml.etree.ElementTree as etree +import xml.dom.minidom as dom + +def strip(root): + root.text = None + root.tail = None + + for elem in root: + strip(elem) + +def write(node, fname): + strip(node) + + s = etree.tostring(node) + s = dom.parseString(s).toprettyxml() + + f = open(fname, "w") + f.write(s) + +class ExportCyclesXML(bpy.types.Operator, io_utils.ExportHelper): + '''''' + bl_idname = "export_mesh.cycles_xml" + bl_label = "Export Cycles XML" + + filename_ext = ".xml" + + @classmethod + def poll(cls, context): + return context.active_object != None + + def execute(self, context): + filepath = bpy.path.ensure_ext(self.filepath, ".xml") + + # get mesh + scene = context.scene + object = context.object + + if not object: + raise Exception("No active object") + + mesh = object.create_mesh(scene, True, 'PREVIEW') + + if not mesh: + raise Exception("No mesh data in active object") + + # generate mesh node + nverts = "" + verts = "" + P = "" + + for v in mesh.vertices: + P += "%f %f %f " % (v.co[0], v.co[1], v.co[2]) + + for i, f in enumerate(mesh.faces): + nverts += str(len(f.vertices)) + " " + + for v in f.vertices: + verts += str(v) + " " + verts += " " + + node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P}) + + # write to file + write(node, filepath) + + return {'FINISHED'} + +def register(): + pass + +def unregister(): + pass + +if __name__ == "__main__": + register() + |