Engine specific panel's
- All of this is in python and easy to change.
- each panel class has a set() of compatible engines.
- this set is checked for the poll function
- external engines can add themselves to this panels compatible engines
eg.
buttons_world.WORLD_PT_mist.COMPAT_ENGINES.add('POVRAY_RENDER')
I tried doing this by subclassing each panel and replacing only the poll function to reference 'POVRAY_RENDER' but it became fairly complicated and meant registering many of the same panels under different names.
Added mist support to povray.
This commit is contained in:
@@ -64,7 +64,7 @@ def write_pov(filename, scene=None, info_callback = None):
|
||||
|
||||
file.write('light_source {\n')
|
||||
file.write('\t< 0,0,0 >\n')
|
||||
file.write('\tcolor red %.6f green %.6f blue %.6f\n' % color)
|
||||
file.write('\tcolor rgb<%.3g, %.3g, %.3g>\n' % color)
|
||||
|
||||
if lamp.type == 'POINT': # Point Lamp
|
||||
pass
|
||||
@@ -310,7 +310,7 @@ def write_pov(filename, scene=None, info_callback = None):
|
||||
|
||||
float_col = col[0], col[1], col[2], 1-material.alpha, materialString
|
||||
#print material.apl
|
||||
file.write(',\n\t\ttexture { pigment {rgbf<%.6f, %.6f, %.6f, %.6f>}%s}' % float_col)
|
||||
file.write(',\n\t\ttexture { pigment {rgbf<%.3g, %.3g, %.3g, %.3g>}%s}' % float_col)
|
||||
index[0] = idx
|
||||
idx+=1
|
||||
|
||||
@@ -412,6 +412,22 @@ def write_pov(filename, scene=None, info_callback = None):
|
||||
|
||||
bpy.data.remove_mesh(me)
|
||||
|
||||
def exportWorld(world):
|
||||
if not world:
|
||||
return
|
||||
|
||||
mist = world.mist
|
||||
|
||||
if mist.enabled:
|
||||
file.write('\tfog {\n')
|
||||
file.write('\t\tdistance %.6f\n' % mist.depth)
|
||||
file.write('\t\tcolor rgbt<%.3g, %.3g, %.3g, %.3g>\n' % (tuple(world.horizon_color) + (1-mist.intensity,)))
|
||||
#file.write('\t\tfog_offset %.6f\n' % mist.start)
|
||||
#file.write('\t\tfog_alt 5\n')
|
||||
#file.write('\t\tturbulence 0.2\n')
|
||||
#file.write('\t\tturb_depth 0.3\n')
|
||||
file.write('\t\tfog_type 1\n')
|
||||
file.write('\t}\n')
|
||||
|
||||
exportCamera()
|
||||
#exportMaterials()
|
||||
@@ -419,6 +435,7 @@ def write_pov(filename, scene=None, info_callback = None):
|
||||
lamps = [l for l in sel if l.type == 'LAMP']
|
||||
exportLamps(lamps)
|
||||
exportMeshs(sel)
|
||||
exportWorld(scene.world)
|
||||
|
||||
file.close()
|
||||
|
||||
@@ -462,7 +479,8 @@ def write_pov_ini(filename_ini, filename_pov, filename_image):
|
||||
file.close()
|
||||
|
||||
|
||||
class PovrayRenderEngine(bpy.types.RenderEngine):
|
||||
class PovrayRender(bpy.types.RenderEngine):
|
||||
__idname__ = 'POVRAY_RENDER'
|
||||
__label__ = "Povray"
|
||||
DELAY = 0.02
|
||||
def _export(self, scene):
|
||||
@@ -471,6 +489,11 @@ class PovrayRenderEngine(bpy.types.RenderEngine):
|
||||
self.temp_file_in = tempfile.mktemp(suffix='.pov')
|
||||
self.temp_file_out = tempfile.mktemp(suffix='.tga')
|
||||
self.temp_file_ini = tempfile.mktemp(suffix='.ini')
|
||||
'''
|
||||
self.temp_file_in = '/test.pov'
|
||||
self.temp_file_out = '/test.tga'
|
||||
self.temp_file_ini = '/test.ini'
|
||||
'''
|
||||
|
||||
def info_callback(txt):
|
||||
self.update_stats("", "POVRAY: " + txt)
|
||||
@@ -580,4 +603,28 @@ class PovrayRenderEngine(bpy.types.RenderEngine):
|
||||
self._cleanup()
|
||||
|
||||
|
||||
bpy.types.register(PovrayRenderEngine)
|
||||
bpy.types.register(PovrayRender)
|
||||
|
||||
# Use some of the existing buttons.
|
||||
import buttons_scene
|
||||
buttons_scene.SCENE_PT_render.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_scene.SCENE_PT_dimensions.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_scene.SCENE_PT_antialiasing.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_scene.SCENE_PT_output.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
del buttons_scene
|
||||
|
||||
# Use only a subset of the world panels
|
||||
import buttons_world
|
||||
buttons_world.WORLD_PT_preview.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_world.WORLD_PT_context_world.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_world.WORLD_PT_world.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
buttons_world.WORLD_PT_mist.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
del buttons_world
|
||||
|
||||
# Example of wrapping every class 'as is'
|
||||
import buttons_material
|
||||
for member in dir(buttons_material):
|
||||
subclass = getattr(buttons_material, member)
|
||||
try: subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
|
||||
except: pass
|
||||
del buttons_material
|
||||
|
||||
@@ -5,13 +5,15 @@ class MaterialButtonsPanel(bpy.types.Panel):
|
||||
__space_type__ = "BUTTONS_WINDOW"
|
||||
__region_type__ = "WINDOW"
|
||||
__context__ = "material"
|
||||
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
|
||||
|
||||
def poll(self, context):
|
||||
return (context.material != None)
|
||||
return (context.material) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
class MATERIAL_PT_preview(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_preview"
|
||||
__label__ = "Preview"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -22,9 +24,13 @@ class MATERIAL_PT_preview(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_context_material(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_context_material"
|
||||
__show_header__ = False
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def poll(self, context):
|
||||
return (context.object)
|
||||
# An exception, dont call the parent poll func because
|
||||
# this manages materials for all engine types
|
||||
|
||||
return (context.object) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -66,6 +72,7 @@ class MATERIAL_PT_context_material(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_material(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_material"
|
||||
__label__ = "Shading"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -100,6 +107,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_strand"
|
||||
__label__ = "Strand"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -132,6 +140,7 @@ class MATERIAL_PT_strand(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_options(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_options"
|
||||
__label__ = "Options"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -165,6 +174,7 @@ class MATERIAL_PT_options(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_shadows(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_shadows"
|
||||
__label__ = "Shadows"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -190,10 +200,10 @@ class MATERIAL_PT_shadows(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_diffuse(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_diffuse"
|
||||
__label__ = "Diffuse"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and mat.type != 'HALO')
|
||||
return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -234,10 +244,10 @@ class MATERIAL_PT_diffuse(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_specular(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_specular"
|
||||
__label__ = "Specular"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER', 'BLENDER_GAME'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and mat.type != 'HALO')
|
||||
return (context.material.type != 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -278,10 +288,10 @@ class MATERIAL_PT_sss(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_sss"
|
||||
__label__ = "Subsurface Scattering"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
|
||||
return (context.material.type in ('SURFACE', 'WIRE')) and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -317,10 +327,10 @@ class MATERIAL_PT_raymir(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_raymir"
|
||||
__label__ = "Ray Mirror"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
|
||||
return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -361,10 +371,10 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_raytransp"
|
||||
__label__= "Ray Transparency"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and (mat.type == 'SURFACE' or mat.type == 'WIRE'))
|
||||
return (context.material.type in 'SURFACE', 'WIRE') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -405,10 +415,10 @@ class MATERIAL_PT_raytransp(MaterialButtonsPanel):
|
||||
class MATERIAL_PT_halo(MaterialButtonsPanel):
|
||||
__idname__= "MATERIAL_PT_halo"
|
||||
__label__= "Halo"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
mat = context.material
|
||||
return (mat and mat.type == 'HALO')
|
||||
return (context.material.type == 'HALO') and (context.scene.render_data.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -5,14 +5,15 @@ class RenderButtonsPanel(bpy.types.Panel):
|
||||
__space_type__ = "BUTTONS_WINDOW"
|
||||
__region_type__ = "WINDOW"
|
||||
__context__ = "scene"
|
||||
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
|
||||
|
||||
def poll(self, context):
|
||||
rd = context.scene.render_data
|
||||
return (not rd.use_game_engine)
|
||||
return (rd.use_game_engine==False) and (rd.engine in self.COMPAT_ENGINES)
|
||||
|
||||
class SCENE_PT_render(RenderButtonsPanel):
|
||||
__label__ = "Render"
|
||||
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
rd = context.scene.render_data
|
||||
@@ -26,6 +27,7 @@ class SCENE_PT_render(RenderButtonsPanel):
|
||||
class SCENE_PT_layers(RenderButtonsPanel):
|
||||
__label__ = "Layers"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -111,6 +113,7 @@ class SCENE_PT_layers(RenderButtonsPanel):
|
||||
|
||||
class SCENE_PT_shading(RenderButtonsPanel):
|
||||
__label__ = "Shading"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -132,6 +135,7 @@ class SCENE_PT_shading(RenderButtonsPanel):
|
||||
class SCENE_PT_performance(RenderButtonsPanel):
|
||||
__label__ = "Performance"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -174,6 +178,7 @@ class SCENE_PT_performance(RenderButtonsPanel):
|
||||
class SCENE_PT_post_processing(RenderButtonsPanel):
|
||||
__label__ = "Post Processing"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -201,6 +206,7 @@ class SCENE_PT_post_processing(RenderButtonsPanel):
|
||||
|
||||
class SCENE_PT_output(RenderButtonsPanel):
|
||||
__label__ = "Output"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -263,6 +269,7 @@ class SCENE_PT_output(RenderButtonsPanel):
|
||||
class SCENE_PT_encoding(RenderButtonsPanel):
|
||||
__label__ = "Encoding"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
rd = context.scene.render_data
|
||||
@@ -309,6 +316,7 @@ class SCENE_PT_encoding(RenderButtonsPanel):
|
||||
|
||||
class SCENE_PT_antialiasing(RenderButtonsPanel):
|
||||
__label__ = "Anti-Aliasing"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -334,6 +342,7 @@ class SCENE_PT_antialiasing(RenderButtonsPanel):
|
||||
|
||||
class SCENE_PT_dimensions(RenderButtonsPanel):
|
||||
__label__ = "Dimensions"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -373,6 +382,7 @@ class SCENE_PT_dimensions(RenderButtonsPanel):
|
||||
class SCENE_PT_stamp(RenderButtonsPanel):
|
||||
__label__ = "Stamp"
|
||||
__default_closed__ = True
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw_header(self, context):
|
||||
rd = context.scene.render_data
|
||||
|
||||
@@ -5,13 +5,15 @@ class WorldButtonsPanel(bpy.types.Panel):
|
||||
__space_type__ = "BUTTONS_WINDOW"
|
||||
__region_type__ = "WINDOW"
|
||||
__context__ = "world"
|
||||
# COMPAT_ENGINES must be defined in each subclass, external engines can add themselves here
|
||||
|
||||
def poll(self, context):
|
||||
rd = context.scene.render_data
|
||||
return (context.world != None) and (not rd.use_game_engine)
|
||||
return (context.world != None) and (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
|
||||
|
||||
class WORLD_PT_preview(WorldButtonsPanel):
|
||||
__label__ = "Preview"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -21,10 +23,11 @@ class WORLD_PT_preview(WorldButtonsPanel):
|
||||
|
||||
class WORLD_PT_context_world(WorldButtonsPanel):
|
||||
__show_header__ = False
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def poll(self, context):
|
||||
rd = context.scene.render_data
|
||||
return (context.scene != None) and (not rd.use_game_engine)
|
||||
return (not rd.use_game_engine) and (rd.engine in self.COMPAT_ENGINES)
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -42,6 +45,7 @@ class WORLD_PT_context_world(WorldButtonsPanel):
|
||||
|
||||
class WORLD_PT_world(WorldButtonsPanel):
|
||||
__label__ = "World"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw(self, context):
|
||||
layout = self.layout
|
||||
@@ -64,6 +68,7 @@ class WORLD_PT_world(WorldButtonsPanel):
|
||||
|
||||
class WORLD_PT_mist(WorldButtonsPanel):
|
||||
__label__ = "Mist"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -87,6 +92,7 @@ class WORLD_PT_mist(WorldButtonsPanel):
|
||||
|
||||
class WORLD_PT_stars(WorldButtonsPanel):
|
||||
__label__ = "Stars"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
@@ -108,6 +114,7 @@ class WORLD_PT_stars(WorldButtonsPanel):
|
||||
|
||||
class WORLD_PT_ambient_occlusion(WorldButtonsPanel):
|
||||
__label__ = "Ambient Occlusion"
|
||||
COMPAT_ENGINES = set(['BLENDER_RENDER'])
|
||||
|
||||
def draw_header(self, context):
|
||||
layout = self.layout
|
||||
|
||||
@@ -50,6 +50,7 @@ class CONSOLE_MT_console(bpy.types.Menu):
|
||||
layout.column()
|
||||
layout.itemO("console.clear")
|
||||
layout.itemO("console.copy")
|
||||
layout.itemO("console.paste")
|
||||
|
||||
class CONSOLE_MT_report(bpy.types.Menu):
|
||||
__space_type__ = "CONSOLE"
|
||||
|
||||
Reference in New Issue
Block a user