set cycles scripts as pep8 & make some minor changes.

also update sphinx doc generator.
This commit is contained in:
2011-11-15 02:58:01 +00:00
parent 3442c16c09
commit 747f06d3d2
8 changed files with 126 additions and 50 deletions

View File

@@ -589,6 +589,7 @@ def pycontext2sphinx(BASEPATH):
"active_base": ("ObjectBase", False), "active_base": ("ObjectBase", False),
"active_bone": ("Bone", False), "active_bone": ("Bone", False),
"active_object": ("Object", False), "active_object": ("Object", False),
"active_operator": ("Operator", False),
"active_pose_bone": ("PoseBone", False), "active_pose_bone": ("PoseBone", False),
"armature": ("Armature", False), "armature": ("Armature", False),
"bone": ("Bone", False), "bone": ("Bone", False),
@@ -597,6 +598,7 @@ def pycontext2sphinx(BASEPATH):
"cloth": ("ClothModifier", False), "cloth": ("ClothModifier", False),
"collision": ("CollisionModifier", False), "collision": ("CollisionModifier", False),
"curve": ("Curve", False), "curve": ("Curve", False),
"dynamic_paint": ("DynamicPaintModifier", False),
"edit_bone": ("EditBone", False), "edit_bone": ("EditBone", False),
"edit_image": ("Image", False), "edit_image": ("Image", False),
"edit_object": ("Object", False), "edit_object": ("Object", False),
@@ -635,6 +637,7 @@ def pycontext2sphinx(BASEPATH):
"speaker": ("Speaker", False), "speaker": ("Speaker", False),
"texture": ("Texture", False), "texture": ("Texture", False),
"texture_slot": ("MaterialTextureSlot", False), "texture_slot": ("MaterialTextureSlot", False),
"texture_user": ("ID", False),
"vertex_paint_object": ("Object", False), "vertex_paint_object": ("Object", False),
"visible_bases": ("ObjectBase", True), "visible_bases": ("ObjectBase", True),
"visible_bones": ("Object", True), "visible_bones": ("Object", True),

View File

@@ -16,10 +16,12 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
bl_info = { bl_info = {
"name": "Cycles Render Engine", "name": "Cycles Render Engine",
"author": "", "author": "",
"version": (0,0), "version": (0, 0),
"blender": (2, 6, 0), "blender": (2, 6, 0),
"api": 41670, "api": 41670,
"location": "Info header, render engine menu", "location": "Info header, render engine menu",
@@ -38,6 +40,7 @@ from cycles import xml
from cycles import engine from cycles import engine
from cycles import presets from cycles import presets
class CyclesRender(bpy.types.RenderEngine): class CyclesRender(bpy.types.RenderEngine):
bl_idname = 'CYCLES' bl_idname = 'CYCLES'
bl_label = "Cycles" bl_label = "Cycles"
@@ -46,7 +49,7 @@ class CyclesRender(bpy.types.RenderEngine):
def __init__(self): def __init__(self):
engine.init() engine.init()
self.session = None self.session = None
def __del__(self): def __del__(self):
engine.free(self) engine.free(self)
@@ -64,7 +67,7 @@ class CyclesRender(bpy.types.RenderEngine):
# #
# def preview_render(self): # def preview_render(self):
# pass # pass
# viewport render # viewport render
def view_update(self, context): def view_update(self, context):
if not self.session: if not self.session:
@@ -75,6 +78,7 @@ class CyclesRender(bpy.types.RenderEngine):
def view_draw(self, context): def view_draw(self, context):
engine.draw(self, context.region, context.space_data, context.region_data) engine.draw(self, context.region, context.space_data, context.region_data)
def register(): def register():
properties.register() properties.register()
ui.register() ui.register()
@@ -82,10 +86,10 @@ def register():
presets.register() presets.register()
bpy.utils.register_module(__name__) bpy.utils.register_module(__name__)
def unregister(): def unregister():
xml.unregister() xml.unregister()
ui.unregister() ui.unregister()
properties.unregister() properties.unregister()
presets.unregister() presets.unregister()
bpy.utils.unregister_module(__name__) bpy.utils.unregister_module(__name__)

View File

@@ -16,8 +16,11 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
import bpy import bpy
def init(): def init():
import bcycles import bcycles
import os.path import os.path
@@ -27,7 +30,8 @@ def init():
bcycles.init(path, user_path) bcycles.init(path, user_path)
def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
def create(engine, data, scene, region=0, v3d=0, rv3d=0):
import bcycles import bcycles
data = data.as_pointer() data = data.as_pointer()
@@ -41,18 +45,21 @@ def create(engine, data, scene, region = 0, v3d = 0, rv3d = 0):
engine.session = bcycles.create(engine.as_pointer(), data, scene, region, v3d, rv3d) engine.session = bcycles.create(engine.as_pointer(), data, scene, region, v3d, rv3d)
def free(engine): def free(engine):
if "session" in dir(engine): if hasattr(engine, "session"):
if engine.session: if engine.session:
import bcycles import bcycles
bcycles.free(engine.session) bcycles.free(engine.session)
del engine.session del engine.session
def render(engine): def render(engine):
import bcycles import bcycles
if "session" in dir(engine): if "session" in dir(engine):
bcycles.render(engine.session) bcycles.render(engine.session)
def update(engine, data, scene): def update(engine, data, scene):
import bcycles import bcycles
if scene.render.use_border: if scene.render.use_border:
@@ -61,6 +68,7 @@ def update(engine, data, scene):
else: else:
bcycles.sync(engine.session) bcycles.sync(engine.session)
def draw(engine, region, v3d, rv3d): def draw(engine, region, v3d, rv3d):
import bcycles import bcycles
v3d = v3d.as_pointer() v3d = v3d.as_pointer()
@@ -69,11 +77,12 @@ def draw(engine, region, v3d, rv3d):
# draw render image # draw render image
bcycles.draw(engine.session, v3d, rv3d) bcycles.draw(engine.session, v3d, rv3d)
def available_devices(): def available_devices():
import bcycles import bcycles
return bcycles.available_devices() return bcycles.available_devices()
def with_osl(): def with_osl():
import bcycles import bcycles
return bcycles.with_osl() return bcycles.with_osl()

View File

@@ -16,8 +16,11 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
from cycles import engine from cycles import engine
def get_gpu_device(): def get_gpu_device():
available_devices = engine.available_devices() available_devices = engine.available_devices()
cuda = 'cuda' in available_devices cuda = 'cuda' in available_devices
@@ -28,32 +31,36 @@ def get_gpu_device():
gpu_string = "CUDA GPU" gpu_string = "CUDA GPU"
else: else:
gpu_string = "OpenCL GPU" gpu_string = "OpenCL GPU"
return gpu_string return gpu_string
devices = ( devices = (
("CPU", "CPU", "Processor"), ("CPU", "CPU", "Processor"),
("GPU", get_gpu_device(), "Graphics card")) ("GPU", get_gpu_device(), "Graphics card"),
)
gpu_type = ( gpu_type = (
("CUDA", "CUDA", "NVidia only"), ("CUDA", "CUDA", "NVidia only"),
("OPENCL", "OpenCL (incomplete)", "")) ("OPENCL", "OpenCL (incomplete)", ""),
)
shading_systems = ( shading_systems = (
("GPU_COMPATIBLE", "GPU Compatible", "Restricted shading system compatible with GPU rendering"), ("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")) ("OSL", "Open Shading Language", "Open Shading Language shading system that only runs on the CPU"),
)
displacement_methods = ( displacement_methods = (
("BUMP", "Bump", "Bump mapping to simulate the appearance of displacement"), ("BUMP", "Bump", "Bump mapping to simulate the appearance of displacement"),
("TRUE", "True", "Use true displacement only, requires fine subdivision"), ("TRUE", "True", "Use true displacement only, requires fine subdivision"),
("BOTH", "Both", "Combination of displacement and bump mapping")) ("BOTH", "Both", "Combination of displacement and bump mapping"),
)
bvh_types = ( bvh_types = (
("DYNAMIC_BVH", "Dynamic BVH", "Objects can be individually updated, at the cost of slower render time"), ("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")) ("STATIC_BVH", "Static BVH", "Any object modification requires a complete BVH rebuild, but renders faster"),
)
filter_types = ( filter_types = (
("BOX", "Box", "Box filter"), ("BOX", "Box", "Box filter"),
("GAUSSIAN", "Gaussian", "Gaussian filter")) ("GAUSSIAN", "Gaussian", "Gaussian filter"),
)

View File

@@ -16,9 +16,12 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
from bl_operators.presets import AddPresetBase from bl_operators.presets import AddPresetBase
from bpy.types import Operator from bpy.types import Operator
class AddPresetIntegrator(AddPresetBase, Operator): class AddPresetIntegrator(AddPresetBase, Operator):
'''Add an Integrator Preset''' '''Add an Integrator Preset'''
bl_idname = "render.cycles_integrator_preset_add" bl_idname = "render.cycles_integrator_preset_add"
@@ -41,13 +44,14 @@ class AddPresetIntegrator(AddPresetBase, Operator):
] ]
preset_subdir = "cycles/integrator" preset_subdir = "cycles/integrator"
def register(): def register():
pass pass
def unregister(): def unregister():
pass pass
if __name__ == "__main__": if __name__ == "__main__":
register() register()

View File

@@ -16,6 +16,8 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
import bpy import bpy
from bpy.props import * from bpy.props import *
@@ -23,6 +25,7 @@ import math
from cycles import enums from cycles import enums
class CyclesRenderSettings(bpy.types.PropertyGroup): class CyclesRenderSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -30,7 +33,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
cls.device = EnumProperty(name="Device", description="Device to use for rendering", cls.device = EnumProperty(name="Device", description="Device to use for rendering",
items=enums.devices, default="CPU") items=enums.devices, default="CPU")
cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU", cls.gpu_type = EnumProperty(name="GPU Type", description="Processing system to use on the GPU",
items=enums.gpu_type, default="CUDA") items=enums.gpu_type, default="CUDA")
@@ -101,6 +104,7 @@ class CyclesRenderSettings(bpy.types.PropertyGroup):
def unregister(cls): def unregister(cls):
del bpy.types.Scene.cycles del bpy.types.Scene.cycles
class CyclesCameraSettings(bpy.types.PropertyGroup): class CyclesCameraSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -112,11 +116,12 @@ class CyclesCameraSettings(bpy.types.PropertyGroup):
default=0, min=0, max=100) default=0, min=0, max=100)
cls.aperture_rotation = FloatProperty(name="Aperture Rotation", description="Rotation of blades in aperture", cls.aperture_rotation = FloatProperty(name="Aperture Rotation", description="Rotation of blades in aperture",
default=0, soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE') default=0, soft_min=-math.pi, soft_max=math.pi, subtype='ANGLE')
@classmethod @classmethod
def unregister(cls): def unregister(cls):
del bpy.types.Camera.cycles del bpy.types.Camera.cycles
class CyclesMaterialSettings(bpy.types.PropertyGroup): class CyclesMaterialSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -128,6 +133,7 @@ class CyclesMaterialSettings(bpy.types.PropertyGroup):
def unregister(cls): def unregister(cls):
del bpy.types.Material.cycles del bpy.types.Material.cycles
class CyclesLampSettings(bpy.types.PropertyGroup): class CyclesLampSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -138,6 +144,7 @@ class CyclesLampSettings(bpy.types.PropertyGroup):
def unregister(cls): def unregister(cls):
del bpy.types.Lamp.cycles del bpy.types.Lamp.cycles
class CyclesWorldSettings(bpy.types.PropertyGroup): class CyclesWorldSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -147,6 +154,7 @@ class CyclesWorldSettings(bpy.types.PropertyGroup):
def unregister(cls): def unregister(cls):
del bpy.types.World.cycles del bpy.types.World.cycles
class CyclesVisibilitySettings(bpy.types.PropertyGroup): class CyclesVisibilitySettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -162,6 +170,7 @@ class CyclesVisibilitySettings(bpy.types.PropertyGroup):
def unregister(cls): def unregister(cls):
del bpy.types.Object.cycles_visibility del bpy.types.Object.cycles_visibility
class CyclesMeshSettings(bpy.types.PropertyGroup): class CyclesMeshSettings(bpy.types.PropertyGroup):
@classmethod @classmethod
def register(cls): def register(cls):
@@ -181,6 +190,7 @@ class CyclesMeshSettings(bpy.types.PropertyGroup):
del bpy.types.Curve.cycles del bpy.types.Curve.cycles
del bpy.types.MetaBall.cycles del bpy.types.MetaBall.cycles
def register(): def register():
bpy.utils.register_class(CyclesRenderSettings) bpy.utils.register_class(CyclesRenderSettings)
bpy.utils.register_class(CyclesCameraSettings) bpy.utils.register_class(CyclesCameraSettings)
@@ -189,7 +199,8 @@ def register():
bpy.utils.register_class(CyclesWorldSettings) bpy.utils.register_class(CyclesWorldSettings)
bpy.utils.register_class(CyclesVisibilitySettings) bpy.utils.register_class(CyclesVisibilitySettings)
bpy.utils.register_class(CyclesMeshSettings) bpy.utils.register_class(CyclesMeshSettings)
def unregister(): def unregister():
bpy.utils.unregister_class(CyclesRenderSettings) bpy.utils.unregister_class(CyclesRenderSettings)
bpy.utils.unregister_class(CyclesCameraSettings) bpy.utils.unregister_class(CyclesCameraSettings)
@@ -198,4 +209,3 @@ def unregister():
bpy.utils.unregister_class(CyclesWorldSettings) bpy.utils.unregister_class(CyclesWorldSettings)
bpy.utils.unregister_class(CyclesMeshSettings) bpy.utils.unregister_class(CyclesMeshSettings)
bpy.utils.unregister_class(CyclesVisibilitySettings) bpy.utils.unregister_class(CyclesVisibilitySettings)

View File

@@ -16,6 +16,8 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
import bpy import bpy
from bpy.types import Panel, Menu from bpy.types import Panel, Menu
@@ -23,6 +25,7 @@ from bpy.types import Panel, Menu
from cycles import enums from cycles import enums
from cycles import engine from cycles import engine
class CYCLES_MT_integrator_presets(Menu): class CYCLES_MT_integrator_presets(Menu):
bl_label = "Integrator Presets" bl_label = "Integrator Presets"
preset_subdir = "cycles/integrator" preset_subdir = "cycles/integrator"
@@ -30,16 +33,18 @@ class CYCLES_MT_integrator_presets(Menu):
COMPAT_ENGINES = {'CYCLES'} COMPAT_ENGINES = {'CYCLES'}
draw = Menu.draw_preset draw = Menu.draw_preset
class CyclesButtonsPanel(): class CyclesButtonsPanel():
bl_space_type = "PROPERTIES" bl_space_type = "PROPERTIES"
bl_region_type = "WINDOW" bl_region_type = "WINDOW"
bl_context = "render" bl_context = "render"
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
rd = context.scene.render rd = context.scene.render
return rd.engine == 'CYCLES' return rd.engine == 'CYCLES'
class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel): class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
bl_label = "Integrator" bl_label = "Integrator"
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
@@ -49,7 +54,7 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
scene = context.scene scene = context.scene
cscene = scene.cycles cscene = scene.cycles
row = layout.row(align=True) row = layout.row(align=True)
row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label) row.menu("CYCLES_MT_integrator_presets", text=bpy.types.CYCLES_MT_integrator_presets.bl_label)
row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN") row.operator("render.cycles_integrator_preset_add", text="", icon="ZOOMIN")
@@ -87,7 +92,8 @@ class CyclesRender_PT_integrator(CyclesButtonsPanel, Panel):
#row = col.row() #row = col.row()
#row.prop(cscene, "blur_caustics") #row.prop(cscene, "blur_caustics")
#row.active = not cscene.no_caustics #row.active = not cscene.no_caustics
class CyclesRender_PT_film(CyclesButtonsPanel, Panel): class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
bl_label = "Film" bl_label = "Film"
@@ -99,7 +105,7 @@ class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
split = layout.split() split = layout.split()
col = split.column(); col = split.column()
col.prop(cscene, "film_exposure") col.prop(cscene, "film_exposure")
col.prop(cscene, "film_transparent") col.prop(cscene, "film_transparent")
@@ -109,6 +115,7 @@ class CyclesRender_PT_film(CyclesButtonsPanel, Panel):
if cscene.filter_type != 'BOX': if cscene.filter_type != 'BOX':
sub.prop(cscene, "filter_width", text="Width") sub.prop(cscene, "filter_width", text="Width")
class CyclesRender_PT_performance(CyclesButtonsPanel, Panel): class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
bl_label = "Performance" bl_label = "Performance"
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
@@ -142,6 +149,7 @@ class CyclesRender_PT_performance(CyclesButtonsPanel, Panel):
sub.prop(cscene, "debug_bvh_type", text="") sub.prop(cscene, "debug_bvh_type", text="")
sub.prop(cscene, "debug_use_spatial_splits") sub.prop(cscene, "debug_use_spatial_splits")
class CyclesRender_PT_layers(CyclesButtonsPanel, Panel): class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
bl_label = "Layers" bl_label = "Layers"
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
@@ -178,6 +186,7 @@ class CyclesRender_PT_layers(CyclesButtonsPanel, Panel):
layout.prop(rl, "material_override", text="Material") layout.prop(rl, "material_override", text="Material")
class Cycles_PT_post_processing(CyclesButtonsPanel, Panel): class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
bl_label = "Post Processing" bl_label = "Post Processing"
bl_options = {'DEFAULT_CLOSED'} bl_options = {'DEFAULT_CLOSED'}
@@ -196,6 +205,7 @@ class Cycles_PT_post_processing(CyclesButtonsPanel, Panel):
col = split.column() col = split.column()
col.prop(rd, "dither_intensity", text="Dither", slider=True) col.prop(rd, "dither_intensity", text="Dither", slider=True)
class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel): class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
bl_label = "Depth of Field" bl_label = "Depth of Field"
bl_context = "data" bl_context = "data"
@@ -229,6 +239,7 @@ class CyclesCamera_PT_dof(CyclesButtonsPanel, Panel):
sub.prop(ccam, "aperture_blades", text="Blades") sub.prop(ccam, "aperture_blades", text="Blades")
sub.prop(ccam, "aperture_rotation", text="Rotation") sub.prop(ccam, "aperture_rotation", text="Rotation")
class Cycles_PT_context_material(CyclesButtonsPanel, Panel): class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
bl_label = "Surface" bl_label = "Surface"
bl_context = "material" bl_context = "material"
@@ -277,6 +288,7 @@ class Cycles_PT_context_material(CyclesButtonsPanel, Panel):
split.template_ID(space, "pin_id") split.template_ID(space, "pin_id")
split.separator() split.separator()
class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel): class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
bl_label = "Displacement" bl_label = "Displacement"
bl_context = "data" bl_context = "data"
@@ -300,8 +312,9 @@ class Cycles_PT_mesh_displacement(CyclesButtonsPanel, Panel):
cdata = mball.cycles cdata = mball.cycles
layout.prop(cdata, "displacement_method", text="Method") layout.prop(cdata, "displacement_method", text="Method")
layout.prop(cdata, "use_subdivision"); layout.prop(cdata, "use_subdivision")
layout.prop(cdata, "dicing_rate"); layout.prop(cdata, "dicing_rate")
class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel): class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
bl_label = "Ray Visibility" bl_label = "Ray Visibility"
@@ -311,7 +324,7 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
ob = context.object ob = context.object
return CyclesButtonsPanel.poll(context) and ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP' return CyclesButtonsPanel.poll(context) and ob and ob.type in ('MESH', 'CURVE', 'CURVE', 'SURFACE', 'FONT', 'META') # todo: 'LAMP'
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -330,6 +343,7 @@ class CyclesObject_PT_ray_visibility(CyclesButtonsPanel, Panel):
col.prop(visibility, "transmission") col.prop(visibility, "transmission")
col.prop(visibility, "shadow") col.prop(visibility, "shadow")
def find_node(material, nodetype): def find_node(material, nodetype):
if material and material.node_tree: if material and material.node_tree:
ntree = material.node_tree ntree = material.node_tree
@@ -337,16 +351,18 @@ def find_node(material, nodetype):
for node in ntree.nodes: for node in ntree.nodes:
if hasattr(node, 'type') and node.type == nodetype: if hasattr(node, 'type') and node.type == nodetype:
return node return node
return None return None
def find_node_input(node, name): def find_node_input(node, name):
for input in node.inputs: for input in node.inputs:
if input.name == name: if input.name == name:
return input return input
return None return None
def panel_node_draw(layout, id, output_type, input_name): def panel_node_draw(layout, id, output_type, input_name):
if not id.node_tree: if not id.node_tree:
layout.prop(id, "use_nodes", icon='NODETREE') layout.prop(id, "use_nodes", icon='NODETREE')
@@ -359,10 +375,11 @@ def panel_node_draw(layout, id, output_type, input_name):
layout.label(text="No output node.") layout.label(text="No output node.")
else: else:
input = find_node_input(node, input_name) input = find_node_input(node, input_name)
layout.template_node_view(ntree, node, input); layout.template_node_view(ntree, node, input)
return True return True
class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel): class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
bl_label = "Lamp" bl_label = "Lamp"
bl_context = "data" bl_context = "data"
@@ -401,7 +418,8 @@ class CyclesLamp_PT_lamp(CyclesButtonsPanel, Panel):
layout.label(text="Not supported, interpreted as point lamp.") layout.label(text="Not supported, interpreted as point lamp.")
elif lamp.type == 'HEMI': elif lamp.type == 'HEMI':
layout.label(text="Not supported, interpreted as sun lamp.") layout.label(text="Not supported, interpreted as sun lamp.")
class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel): class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes" bl_label = "Nodes"
bl_context = "data" bl_context = "data"
@@ -417,6 +435,7 @@ class CyclesLamp_PT_nodes(CyclesButtonsPanel, Panel):
if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'): if not panel_node_draw(layout, lamp, 'OUTPUT_LAMP', 'Surface'):
layout.prop(lamp, "color") layout.prop(lamp, "color")
class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel): class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface" bl_label = "Surface"
bl_context = "world" bl_context = "world"
@@ -432,6 +451,7 @@ class CyclesWorld_PT_surface(CyclesButtonsPanel, Panel):
if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'): if not panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Surface'):
layout.prop(world, "horizon_color", text="Color") layout.prop(world, "horizon_color", text="Color")
class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel): class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume" bl_label = "Volume"
bl_context = "world" bl_context = "world"
@@ -440,7 +460,7 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
world = context.world world = context.world
return False # world and world.node_tree and CyclesButtonsPanel.poll(context) return False # world and world.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -449,6 +469,7 @@ class CyclesWorld_PT_volume(CyclesButtonsPanel, Panel):
world = context.world world = context.world
panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume') panel_node_draw(layout, world, 'OUTPUT_WORLD', 'Volume')
class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel): class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
bl_label = "Surface" bl_label = "Surface"
bl_context = "material" bl_context = "material"
@@ -464,6 +485,7 @@ class CyclesMaterial_PT_surface(CyclesButtonsPanel, Panel):
if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'): if not panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Surface'):
layout.prop(mat, "diffuse_color") layout.prop(mat, "diffuse_color")
class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel): class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
bl_label = "Volume" bl_label = "Volume"
bl_context = "material" bl_context = "material"
@@ -472,7 +494,7 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
@classmethod @classmethod
def poll(cls, context): def poll(cls, context):
mat = context.material mat = context.material
return False #mat and mat.node_tree and CyclesButtonsPanel.poll(context) return False # mat and mat.node_tree and CyclesButtonsPanel.poll(context)
def draw(self, context): def draw(self, context):
layout = self.layout layout = self.layout
@@ -485,6 +507,7 @@ class CyclesMaterial_PT_volume(CyclesButtonsPanel, Panel):
layout.prop(cmat, "homogeneous_volume") layout.prop(cmat, "homogeneous_volume")
class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel): class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
bl_label = "Displacement" bl_label = "Displacement"
bl_context = "material" bl_context = "material"
@@ -500,6 +523,7 @@ class CyclesMaterial_PT_displacement(CyclesButtonsPanel, Panel):
mat = context.material mat = context.material
panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement') panel_node_draw(layout, mat, 'OUTPUT_MATERIAL', 'Displacement')
class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel): class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
bl_label = "Settings" bl_label = "Settings"
bl_context = "material" bl_context = "material"
@@ -523,6 +547,7 @@ class CyclesMaterial_PT_settings(CyclesButtonsPanel, Panel):
col = split.column() col = split.column()
col.prop(cmat, "sample_as_light") col.prop(cmat, "sample_as_light")
class CyclesTexture_PT_context(CyclesButtonsPanel, Panel): class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
bl_label = "" bl_label = ""
bl_context = "texture" bl_context = "texture"
@@ -535,7 +560,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
tex = context.texture tex = context.texture
space = context.space_data space = context.space_data
pin_id = space.pin_id pin_id = space.pin_id
use_pin_id = space.use_pin_id; use_pin_id = space.use_pin_id
user = context.texture_user user = context.texture_user
node = context.texture_node node = context.texture_node
@@ -555,7 +580,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
col.template_ID(space, "pin_id") col.template_ID(space, "pin_id")
elif user: elif user:
col.template_ID(user, "texture", new="texture.new") col.template_ID(user, "texture", new="texture.new")
if tex: if tex:
row = split.row() row = split.row()
row.prop(tex, "use_nodes", icon="NODETREE", text="") row.prop(tex, "use_nodes", icon="NODETREE", text="")
@@ -566,6 +591,7 @@ class CyclesTexture_PT_context(CyclesButtonsPanel, Panel):
split.label(text="Type:") split.label(text="Type:")
split.prop(tex, "type", text="") split.prop(tex, "type", text="")
class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel): class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
bl_label = "Nodes" bl_label = "Nodes"
bl_context = "texture" bl_context = "texture"
@@ -581,6 +607,7 @@ class CyclesTexture_PT_nodes(CyclesButtonsPanel, Panel):
tex = context.texture tex = context.texture
panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color') panel_node_draw(layout, tex, 'OUTPUT_TEXTURE', 'Color')
class CyclesTexture_PT_node(CyclesButtonsPanel, Panel): class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
bl_label = "Node" bl_label = "Node"
bl_context = "texture" bl_context = "texture"
@@ -597,6 +624,7 @@ class CyclesTexture_PT_node(CyclesButtonsPanel, Panel):
ntree = node.id_data ntree = node.id_data
layout.template_node_view(ntree, node, None) layout.template_node_view(ntree, node, None)
class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel): class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
bl_label = "Mapping" bl_label = "Mapping"
bl_context = "texture" bl_context = "texture"
@@ -628,6 +656,7 @@ class CyclesTexture_PT_mapping(CyclesButtonsPanel, Panel):
row.prop(mapping, "mapping_y", text="") row.prop(mapping, "mapping_y", text="")
row.prop(mapping, "mapping_z", text="") row.prop(mapping, "mapping_z", text="")
class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel): class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
bl_label = "Color" bl_label = "Color"
bl_context = "texture" bl_context = "texture"
@@ -668,6 +697,7 @@ class CyclesTexture_PT_colors(CyclesButtonsPanel, Panel):
if mapping.use_color_ramp: if mapping.use_color_ramp:
layout.template_color_ramp(mapping, "color_ramp", expand=True) layout.template_color_ramp(mapping, "color_ramp", expand=True)
def draw_device(self, context): def draw_device(self, context):
scene = context.scene scene = context.scene
layout = self.layout layout = self.layout
@@ -686,6 +716,7 @@ def draw_device(self, context):
if cscene.device == 'CPU' and engine.with_osl(): if cscene.device == 'CPU' and engine.with_osl():
layout.prop(cscene, "shading_system") layout.prop(cscene, "shading_system")
def draw_pause(self, context): def draw_pause(self, context):
layout = self.layout layout = self.layout
scene = context.scene scene = context.scene
@@ -697,6 +728,7 @@ def draw_pause(self, context):
cscene = scene.cycles cscene = scene.cycles
layout.prop(cscene, "preview_pause", icon="PAUSE", text="") layout.prop(cscene, "preview_pause", icon="PAUSE", text="")
def get_panels(): def get_panels():
return [ return [
bpy.types.RENDER_PT_render, bpy.types.RENDER_PT_render,
@@ -752,17 +784,18 @@ def get_panels():
bpy.types.PARTICLE_PT_vertexgroups, bpy.types.PARTICLE_PT_vertexgroups,
bpy.types.PARTICLE_PT_custom_props] bpy.types.PARTICLE_PT_custom_props]
def register(): def register():
bpy.types.RENDER_PT_render.append(draw_device) bpy.types.RENDER_PT_render.append(draw_device)
bpy.types.VIEW3D_HT_header.append(draw_pause) bpy.types.VIEW3D_HT_header.append(draw_pause)
for panel in get_panels(): for panel in get_panels():
panel.COMPAT_ENGINES.add('CYCLES') panel.COMPAT_ENGINES.add('CYCLES')
def unregister(): def unregister():
bpy.types.RENDER_PT_render.remove(draw_device) bpy.types.RENDER_PT_render.remove(draw_device)
bpy.types.VIEW3D_HT_header.remove(draw_pause) bpy.types.VIEW3D_HT_header.remove(draw_pause)
for panel in get_panels(): for panel in get_panels():
panel.COMPAT_ENGINES.remove('CYCLES') panel.COMPAT_ENGINES.remove('CYCLES')

View File

@@ -16,6 +16,8 @@
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
# #
# <pep8 compliant>
# XML exporter for generating test files, not intended for end users # XML exporter for generating test files, not intended for end users
import os import os
@@ -24,6 +26,7 @@ from bpy_extras.io_utils import ExportHelper
import xml.etree.ElementTree as etree import xml.etree.ElementTree as etree
import xml.dom.minidom as dom import xml.dom.minidom as dom
def strip(root): def strip(root):
root.text = None root.text = None
root.tail = None root.tail = None
@@ -31,6 +34,7 @@ def strip(root):
for elem in root: for elem in root:
strip(elem) strip(elem)
def write(node, fname): def write(node, fname):
strip(node) strip(node)
@@ -40,6 +44,7 @@ def write(node, fname):
f = open(fname, "w") f = open(fname, "w")
f.write(s) f.write(s)
class ExportCyclesXML(bpy.types.Operator, ExportHelper): class ExportCyclesXML(bpy.types.Operator, ExportHelper):
'''''' ''''''
bl_idname = "export_mesh.cycles_xml" bl_idname = "export_mesh.cycles_xml"
@@ -82,18 +87,19 @@ class ExportCyclesXML(bpy.types.Operator, ExportHelper):
verts += " " verts += " "
node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P}) node = etree.Element('mesh', attrib={'nverts': nverts, 'verts': verts, 'P': P})
# write to file # write to file
write(node, filepath) write(node, filepath)
return {'FINISHED'} return {'FINISHED'}
def register(): def register():
pass pass
def unregister(): def unregister():
pass pass
if __name__ == "__main__": if __name__ == "__main__":
register() register()