Newer
Older
col.prop(raym, "depth")
col.prop(raym, "distance", text="Max Dist")
col.separator()
sub.active = raym.distance > 0.0
sub.label(text="Fade To:")
sub.prop(raym, "fade_to", text="")
col = split.column()
col.label(text="Gloss:")
col.prop(raym, "gloss_factor", text="Amount")
sub = col.column()
sub.active = raym.gloss_factor < 1.0
sub.prop(raym, "gloss_threshold", text="Threshold")
sub.prop(raym, "gloss_samples", text="Noise")
sub.prop(raym, "gloss_anisotropic", text="Anisotropic")
class MATERIAL_PT_POV_transp(MaterialButtonsPanel, Panel):
"""Use this class to define pov material transparency (alpha) buttons."""
bl_label = "Transparency"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return (
check_material(mat)
and (mat.pov.type in {'SURFACE', 'WIRE'})
and (engine in cls.COMPAT_ENGINES)
)
def draw_header(self, context):
mat = context.material
if simple_material(mat):
self.layout.prop(mat.pov, "use_transparency", text="")
def draw(self, context):
layout = self.layout
base_mat = context.material
mat = context.material # FORMERLY active_node_mat(context.material)
rayt = mat.pov_raytrace_transparency
if simple_material(base_mat):
row = layout.row()
row.active = mat.pov.use_transparency
row.prop(mat.pov, "transparency_method", expand=True)
split = layout.split()
split.active = base_mat.pov.use_transparency
col = split.column()
col.prop(mat.pov, "alpha")
row = col.row()
row.active = (base_mat.pov.transparency_method != 'MASK') and (
not mat.pov.use_shadeless
)
row.prop(mat.pov, "specular_alpha", text="Specular")
col = split.column()
col.active = not mat.pov.use_shadeless
col.prop(rayt, "fresnel")
sub = col.column()
sub.active = rayt.fresnel > 0.0
2069
2070
2071
2072
2073
2074
2075
2076
2077
2078
2079
2080
2081
2082
2083
2084
2085
2086
2087
2088
2089
sub.prop(rayt, "fresnel_factor", text="Blend")
if base_mat.pov.transparency_method == 'RAYTRACE':
layout.separator()
split = layout.split()
split.active = base_mat.pov.use_transparency
col = split.column()
col.prop(rayt, "ior")
col.prop(rayt, "filter")
col.prop(rayt, "falloff")
col.prop(rayt, "depth_max")
col.prop(rayt, "depth")
col = split.column()
col.label(text="Gloss:")
col.prop(rayt, "gloss_factor", text="Amount")
sub = col.column()
sub.active = rayt.gloss_factor < 1.0
sub.prop(rayt, "gloss_threshold", text="Threshold")
sub.prop(rayt, "gloss_samples", text="Samples")
class MATERIAL_PT_POV_reflection(MaterialButtonsPanel, Panel):
"""Use this class to define more pov specific reflectivity buttons."""
Maurice Raybaud
committed
bl_label = "POV-Ray Reflection"
bl_parent_id = "MATERIAL_PT_POV_raytrace_mirror"
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
mat = context.material
return (
mat
and mat.pov.type == "SURFACE"
and (engine in cls.COMPAT_ENGINES)
and not (mat.pov.material_use_nodes or mat.use_nodes)
)
def draw(self, context):
layout = self.layout
Maurice Raybaud
committed
col = layout.column()
col.prop(mat.pov, "irid_enable")
if mat.pov.irid_enable:
Maurice Raybaud
committed
col.prop(mat.pov, "irid_amount", slider=True)
col.prop(mat.pov, "irid_thickness", slider=True)
col.prop(mat.pov, "irid_turbulence", slider=True)
Maurice Raybaud
committed
col.prop(mat.pov, "conserve_energy")
col2 = col.split().column()
if not mat.pov_raytrace_mirror.use:
col2.label(text="Please Check Mirror settings :")
col2.active = mat.pov_raytrace_mirror.use
Maurice Raybaud
committed
col2.prop(mat.pov, "mirror_use_IOR")
if mat.pov.mirror_use_IOR:
col2.alignment = 'CENTER'
col2.label(text="The current Raytrace ")
col2.label(text="Transparency IOR is: " + str(mat.pov.ior))
Maurice Raybaud
committed
col2.prop(mat.pov, "mirror_metallic")
'''
#group some native Blender (SSS) and POV (Fade)settings under such a parent panel?
class MATERIAL_PT_POV_interior(MaterialButtonsPanel, Panel):
bl_label = "POV-Ray Interior"
bl_idname = "material.pov_interior"
#bl_parent_id = "material.absorption"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
mat=context.material
ob = context.object
return mat and mat.pov.type == "SURFACE" and (engine in cls.COMPAT_ENGINES) and not (mat.pov.material_use_nodes or mat.use_nodes)
def draw_header(self, context):
mat = context.material
class MATERIAL_PT_POV_fade_color(MaterialButtonsPanel, Panel):
"""Use this class to define pov fading (absorption) color buttons."""
Maurice Raybaud
committed
bl_label = "POV-Ray Absorption"
COMPAT_ENGINES = {'POVRAY_RENDER'}
# bl_parent_id = "material.pov_interior"
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
mat = context.material
return (
mat
and mat.pov.type == "SURFACE"
and (engine in cls.COMPAT_ENGINES)
and not (mat.pov.material_use_nodes or mat.use_nodes)
)
def draw_header(self, context):
mat = context.material
Bastien Montagne
committed
self.layout.prop(mat.pov, "interior_fade_color", text="")
def draw(self, context):
layout = self.layout
mat = context.material
Maurice Raybaud
committed
# layout.active = mat.pov.interior_fade_color
if mat.pov.interior_fade_color != (0.0, 0.0, 0.0):
layout.label(text="Raytrace transparency")
layout.label(text="depth max Limit needs")
layout.label(text="to be non zero to fade")
Maurice Raybaud
committed
pass
class MATERIAL_PT_POV_caustics(MaterialButtonsPanel, Panel):
"""Use this class to define pov caustics buttons."""
bl_label = "Caustics"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
mat = context.material
return (
mat
and mat.pov.type == "SURFACE"
and (engine in cls.COMPAT_ENGINES)
and not (mat.pov.material_use_nodes or mat.use_nodes)
)
def draw_header(self, context):
mat = context.material
Maurice Raybaud
committed
if mat.pov.caustics_enable:
self.layout.prop(
mat.pov, "caustics_enable", text="", icon="PMARKER_SEL"
)
Maurice Raybaud
committed
else:
self.layout.prop(
mat.pov, "caustics_enable", text="", icon="PMARKER"
)
def draw(self, context):
layout = self.layout
mat = context.material
Bastien Montagne
committed
layout.active = mat.pov.caustics_enable
Maurice Raybaud
committed
col = layout.column()
Bastien Montagne
committed
if mat.pov.caustics_enable:
Maurice Raybaud
committed
col.prop(mat.pov, "refraction_caustics")
if mat.pov.refraction_caustics:
col.prop(mat.pov, "refraction_type", text="")
Maurice Raybaud
committed
if mat.pov.refraction_type == "1":
col.prop(mat.pov, "fake_caustics_power", slider=True)
elif mat.pov.refraction_type == "2":
col.prop(mat.pov, "photons_dispersion", slider=True)
col.prop(mat.pov, "photons_dispersion_samples", slider=True)
Bastien Montagne
committed
col.prop(mat.pov, "photons_reflection")
if (
not mat.pov.refraction_caustics
and not mat.pov.photons_reflection
):
col = layout.column()
col.alignment = 'CENTER'
col.label(text="Caustics override is on, ")
col.label(text="but you didn't chose any !")
class MATERIAL_PT_strand(MaterialButtonsPanel, Panel):
"""Use this class to define Blender strand antialiasing buttons."""
bl_label = "Strand"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
mat = context.material
engine = context.scene.render.engine
return (
mat
and (mat.pov.type in {'SURFACE', 'WIRE', 'HALO'})
and (engine in cls.COMPAT_ENGINES)
)
def draw(self, context):
layout = self.layout
mat = context.material # don't use node material
tan = mat.strand
split = layout.split()
col = split.column()
sub = col.column(align=True)
sub.label(text="Size:")
sub.prop(tan, "root_size", text="Root")
sub.prop(tan, "tip_size", text="Tip")
sub.prop(tan, "size_min", text="Minimum")
sub.prop(tan, "use_blender_units")
sub = col.column()
sub.active = not mat.pov.use_shadeless
sub.prop(tan, "use_tangent_shading")
col.prop(tan, "shape")
col = split.column()
col.label(text="Shading:")
col.prop(tan, "width_fade")
ob = context.object
if ob and ob.type == 'MESH':
col.prop_search(
tan, "uv_layer", ob.data, "tessface_uv_textures", text=""
)
else:
col.prop(tan, "uv_layer", text="")
col.separator()
sub = col.column()
sub.active = not mat.pov.use_shadeless
sub.label(text="Surface diffuse:")
sub = col.column()
sub.prop(tan, "blend_distance", text="Distance")
class MATERIAL_PT_POV_replacement_text(MaterialButtonsPanel, Panel):
"""Use this class to define pov custom code declared name field."""
Maurice Raybaud
committed
bl_label = "Custom POV Code"
Campbell Barton
committed
COMPAT_ENGINES = {'POVRAY_RENDER'}
Maurice Raybaud
committed
def draw(self, context):
layout = self.layout
mat = context.material
Maurice Raybaud
committed
col.label(text="Replace properties with:")
Bastien Montagne
committed
col.prop(mat.pov, "replacement_text", text="")
Maurice Raybaud
committed
class TEXTURE_MT_POV_specials(Menu):
"""Use this class to define pov texture slot operations buttons."""
bl_label = "Texture Specials"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw(self, context):
layout = self.layout
layout.operator("texture.slot_copy", icon='COPYDOWN')
layout.operator("texture.slot_paste", icon='PASTEDOWN')
class WORLD_TEXTURE_SLOTS_UL_POV_layerlist(UIList):
"""Use this class to show pov texture slots list.""" # XXX Not used yet
index: bpy.props.IntProperty(name='index')
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname
):
world = context.scene.world # .pov
active_data = world.pov
# tex = context.texture #may be needed later?
# We could write some code to decide which icon to use here...
custom_icon = 'TEXTURE'
# draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
if self.layout_type in {'DEFAULT', 'COMPACT'}:
# You should always start your row layout by a label (icon + text), or a non-embossed text field,
# this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
# We use icon_value of label, as our given icon is an integer value, not an enum ID.
# Note "data" names should never be translated!
if slot:
layout.prop(
item, "texture", text="", emboss=False, icon='TEXTURE'
)
else:
layout.label(text="New", translate=False, icon_value=icon)
# 'GRID' layout type should be as compact as possible (typically a single icon!).
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
class MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist(UIList):
"""Use this class to show pov texture slots list."""
index: bpy.props.IntProperty(name='index')
# foo = random prop
def draw_item(
self, context, layout, data, item, icon, active_data, active_propname
):
ob = data
slot = item
# draw_item must handle the three layout types... Usually 'DEFAULT' and 'COMPACT' can share the same code.
if self.layout_type in {'DEFAULT', 'COMPACT'}:
# You should always start your row layout by a label (icon + text), or a non-embossed text field,
# this will also make the row easily selectable in the list! The later also enables ctrl-click rename.
# We use icon_value of label, as our given icon is an integer value, not an enum ID.
# Note "data" names should never be translated!
if slot:
layout.prop(
item, "texture", text="", emboss=False, icon='TEXTURE'
)
else:
layout.label(text="New", translate=False, icon_value=icon)
# 'GRID' layout type should be as compact as possible (typically a single icon!).
elif self.layout_type in {'GRID'}:
layout.alignment = 'CENTER'
layout.label(text="", icon_value=icon)
2398
2399
2400
2401
2402
2403
2404
2405
2406
2407
2408
2409
2410
2411
2412
2413
2414
2415
2416
2417
2418
2419
2420
2421
2422
2423
2424
2425
2426
2427
2428
2429
2430
2431
2432
2433
2434
2435
2436
2437
2438
2439
2440
2441
2442
2443
2444
# Rewrite an existing class to modify.
# register but not unregistered because
# the modified parts concern only POVRAY_RENDER
class TEXTURE_PT_context(TextureButtonsPanel, Panel):
bl_label = ""
bl_context = "texture"
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'POVRAY_RENDER', 'BLENDER_EEVEE', 'BLENDER_WORKBENCH'}
@classmethod
def poll(cls, context):
return (
(context.scene.texture_context
not in('MATERIAL','WORLD','LIGHT','PARTICLES','LINESTYLE')
or context.scene.render.engine != 'POVRAY_RENDER')
)
def draw(self, context):
layout = self.layout
tex = context.texture
space = context.space_data
pin_id = space.pin_id
use_pin_id = space.use_pin_id
user = context.texture_user
col = layout.column()
if not (use_pin_id and isinstance(pin_id, bpy.types.Texture)):
pin_id = None
if not pin_id:
col.template_texture_user()
if user or pin_id:
col.separator()
if pin_id:
col.template_ID(space, "pin_id")
else:
propname = context.texture_user_property.identifier
col.template_ID(user, propname, new="texture.new")
if tex:
col.separator()
split = col.split(factor=0.2)
split.label(text="Type")
split.prop(tex, "type", text="")
class TEXTURE_PT_POV_context_texture(TextureButtonsPanel, Panel):
"""Use this class to show pov texture context buttons."""
bl_label = ""
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return engine in cls.COMPAT_ENGINES
# if not (hasattr(context, "pov_texture_slot") or hasattr(context, "texture_node")):
return (
context.material
or context.light
or context.texture
or context.line_style
or context.particle_system
or isinstance(context.space_data.pin_id, ParticleSettings)
or context.texture_user
) and (engine in cls.COMPAT_ENGINES)
def draw(self, context):
layout = self.layout
mat = context.view_layer.objects.active.active_material
wld = context.scene.world
layout.prop(scene, "texture_context", expand=True)
if scene.texture_context == 'MATERIAL' and mat is not None:
row.template_list(
"MATERIAL_TEXTURE_SLOTS_UL_POV_layerlist",
"",
mat,
"pov_texture_slots",
mat.pov,
"active_texture_index",
rows=2,
maxrows=16,
type="DEFAULT"
col.operator("pov.textureslotadd", icon='ADD', text='')
col.operator("pov.textureslotremove", icon='REMOVE', text='')
#todo: recreate for pov_texture_slots?
#col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
#col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
if mat.pov_texture_slots:
index = mat.pov.active_texture_index
slot = mat.pov_texture_slots[index]
povtex = slot.texture#slot.name
col.prop(tex, 'use_fake_user', text='')
#layout.label(text='Linked Texture data browser:')
propname = slot.texture_search
# if slot.texture was a pointer to texture data rather than just a name string:
# layout.template_ID(povtex, "texture", new="texture.new")
slot, 'texture_search', bpy.data, 'textures', text='', icon='TEXTURE'
try:
bpy.context.tool_settings.image_paint.brush.texture = bpy.data.textures[slot.texture_search]
bpy.context.tool_settings.image_paint.brush.mask_texture = bpy.data.textures[slot.texture_search]
except KeyError:
# texture not hand-linked by user
pass
if tex:
layout.separator()
split = layout.split(factor=0.2)
split.label(text="Type")
split.prop(tex, "type", text="")
# for i in range(18): # length of material texture slots
# mat.pov_texture_slots.add()
elif scene.texture_context == 'WORLD' and wld is not None:
2532
2533
2534
2535
2536
2537
2538
2539
2540
2541
2542
2543
2544
2545
2546
2547
2548
2549
2550
2551
2552
2553
2554
2555
2556
2557
2558
2559
2560
2561
2562
2563
2564
2565
2566
2567
2568
2569
2570
2571
2572
2573
2574
2575
2576
2577
2578
row = layout.row()
row.template_list(
"WORLD_TEXTURE_SLOTS_UL_POV_layerlist",
"",
wld,
"pov_texture_slots",
wld.pov,
"active_texture_index",
rows=2,
maxrows=16,
type="DEFAULT"
)
col = row.column(align=True)
col.operator("pov.textureslotadd", icon='ADD', text='')
col.operator("pov.textureslotremove", icon='REMOVE', text='')
#todo: recreate for pov_texture_slots?
#col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
#col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
col.separator()
if wld.pov_texture_slots:
index = wld.pov.active_texture_index
slot = wld.pov_texture_slots[index]
povtex = slot.texture#slot.name
tex = bpy.data.textures[povtex]
col.prop(tex, 'use_fake_user', text='')
#layout.label(text='Linked Texture data browser:')
propname = slot.texture_search
# if slot.texture was a pointer to texture data rather than just a name string:
# layout.template_ID(povtex, "texture", new="texture.new")
layout.prop_search(
slot, 'texture_search', bpy.data, 'textures', text='', icon='TEXTURE'
)
try:
bpy.context.tool_settings.image_paint.brush.texture = bpy.data.textures[slot.texture_search]
bpy.context.tool_settings.image_paint.brush.mask_texture = bpy.data.textures[slot.texture_search]
except KeyError:
# texture not hand-linked by user
pass
if tex:
layout.separator()
split = layout.split(factor=0.2)
split.label(text="Type")
split.prop(tex, "type", text="")
# Commented out below is a reminder of what existed in Blender Internal
slot = getattr(context, "texture_slot", None)
node = getattr(context, "texture_node", None)
space = context.space_data
mtl = getattr(context, "material", None)
if mtl != None:
wld = getattr(context, "world", None)
if wld != None:
lgt = getattr(context, "light", None)
if lgt != None:
#idblock = context.particle_system.settings
tex = getattr(context, "texture", None)
if tex != None:
idblock = scene.pov#pov_context_tex_datablock(context)
2609
2610
2611
2612
2613
2614
2615
2616
2617
2618
2619
2620
2621
2622
2623
2624
2625
2626
2627
2628
2629
2630
2631
2632
2633
2634
2635
2636
2637
2638
2639
2640
2641
2642
2643
2644
2645
2646
2647
2648
2649
pin_id = space.pin_id
#spacedependant.use_limited_texture_context = True
if space.use_pin_id and not isinstance(pin_id, Texture):
idblock = id_tex_datablock(pin_id)
pin_id = None
if not space.use_pin_id:
layout.row().prop(spacedependant, "texture_context", expand=True)
pin_id = None
if spacedependant.texture_context == 'OTHER':
if not pin_id:
layout.template_texture_user()
user = context.texture_user
if user or pin_id:
layout.separator()
row = layout.row()
if pin_id:
row.template_ID(space, "pin_id")
else:
propname = context.texture_user_property.identifier
row.template_ID(user, propname, new="texture.new")
if tex:
split = layout.split(factor=0.2)
if tex.use_nodes:
if slot:
split.label(text="Output:")
split.prop(slot, "output_node", text="")
else:
split.label(text="Type:")
split.prop(tex, "type", text="")
return
tex_collection = (pin_id is None) and (node is None) and (spacedependant.texture_context not in ('LINESTYLE','OTHER'))
if tex_collection:
pov = getattr(context, "pov", None)
active_texture_index = getattr(spacedependant, "active_texture_index", None)
print(active_texture_index)
row = layout.row()
row.template_list("TEXTURE_UL_texslots", "", idblock, "texture_slots",
idblock, "active_texture_index", rows=2, maxrows=16, type="DEFAULT")
# row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "texture_slots", world,
# world.texture_slots, world, "active_texture_index", rows=2)
col = row.column(align=True)
col.operator("texture.slot_move", text="", icon='TRIA_UP').type = 'UP'
col.operator("texture.slot_move", text="", icon='TRIA_DOWN').type = 'DOWN'
col.menu("TEXTURE_MT_POV_specials", icon='DOWNARROW_HLT', text="")
if tex_collection:
layout.template_ID(idblock, "active_texture", new="texture.new")
elif node:
layout.template_ID(node, "texture", new="texture.new")
elif idblock:
layout.template_ID(idblock, "texture", new="texture.new")
if pin_id:
layout.template_ID(space, "pin_id")
if tex:
split = layout.split(factor=0.2)
if tex.use_nodes:
if slot:
split.label(text="Output:")
split.prop(slot, "output_node", text="")
else:
split.label(text="Type:")
class TEXTURE_PT_colors(TextureButtonsPanel, Panel):
"""Use this class to show pov color ramps."""
2693
2694
2695
2696
2697
2698
2699
2700
2701
2702
2703
2704
2705
2706
2707
2708
2709
2710
2711
2712
2713
2714
2715
2716
2717
2718
2719
2720
2721
2722
2723
bl_label = "Colors"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw(self, context):
layout = self.layout
tex = context.texture
layout.prop(tex, "use_color_ramp", text="Ramp")
if tex.use_color_ramp:
layout.template_color_ramp(tex, "color_ramp", expand=True)
split = layout.split()
col = split.column()
col.label(text="RGB Multiply:")
sub = col.column(align=True)
sub.prop(tex, "factor_red", text="R")
sub.prop(tex, "factor_green", text="G")
sub.prop(tex, "factor_blue", text="B")
col = split.column()
col.label(text="Adjust:")
col.prop(tex, "intensity")
col.prop(tex, "contrast")
col.prop(tex, "saturation")
col = layout.column()
col.prop(tex, "use_clamp", text="Clamp")
class TEXTURE_OT_POV_texture_slot_add(Operator):
"""Use this class for the add texture slot button."""
bl_idname = "pov.textureslotadd"
bl_label = "Add"
bl_description = "Add texture_slot"
bl_options = {'REGISTER', 'UNDO'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
def execute(self, context):
idblock = pov_context_tex_datablock(context)
tex = bpy.data.textures.new(name='Texture', type='IMAGE')
#tex.use_fake_user = True
#mat = context.view_layer.objects.active.active_material
slot = idblock.pov_texture_slots.add()
slot.name = tex.name
slot.texture = tex.name
slot.texture_search = tex.name
# Switch paint brush and paint brush mask
# to this texture so settings remain contextual
bpy.context.tool_settings.image_paint.brush.texture = tex
bpy.context.tool_settings.image_paint.brush.mask_texture = tex
idblock.pov.active_texture_index = (len(idblock.pov_texture_slots)-1)
#for area in bpy.context.screen.areas:
#if area.type in ['PROPERTIES']:
#area.tag_redraw()
return {'FINISHED'}
class TEXTURE_OT_POV_texture_slot_remove(Operator):
"""Use this class for the remove texture slot button."""
bl_idname = "pov.textureslotremove"
bl_label = "Remove"
bl_description = "Remove texture_slot"
bl_options = {'REGISTER', 'UNDO'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
def execute(self, context):
idblock = pov_context_tex_datablock(context)
#mat = context.view_layer.objects.active.active_material
tex_slot = idblock.pov_texture_slots.remove(idblock.pov.active_texture_index)
if idblock.pov.active_texture_index > 0:
idblock.pov.active_texture_index -= 1
try:
tex = idblock.pov_texture_slots[idblock.pov.active_texture_index].texture
except IndexError:
# No more slots
return {'FINISHED'}
# Switch paint brush to previous texture so settings remain contextual
# if 'tex' in locals(): # Would test is the tex variable is assigned / exists
bpy.context.tool_settings.image_paint.brush.texture = bpy.data.textures[tex]
bpy.context.tool_settings.image_paint.brush.mask_texture = bpy.data.textures[tex]
"""Use this class to show pov texture slots panel."""
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
if not hasattr(context, "pov_texture_slot"):
return False
engine = context.scene.render.engine
return TextureButtonsPanel.poll(cls, context) and (
engine in cls.COMPAT_ENGINES
)
class TEXTURE_PT_POV_type(TextureButtonsPanel, Panel):
"""Use this class to define pov texture type buttons."""
bl_label = "POV Textures"
COMPAT_ENGINES = {'POVRAY_RENDER'}
bl_options = {'HIDE_HEADER'}
Maurice Raybaud
committed
def draw(self, context):
layout = self.layout
tex = context.texture
split.label(text="Pattern")
split.prop(tex.pov, "tex_pattern_type", text="")
# row = layout.row()
# row.template_list("WORLD_TEXTURE_SLOTS_UL_List", "texture_slots", world,
# world.texture_slots, world, "active_texture_index")
class TEXTURE_PT_POV_preview(TextureButtonsPanel, Panel):
"""Use this class to define pov texture preview panel."""
bl_label = "Preview"
COMPAT_ENGINES = {'POVRAY_RENDER'}
bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
if not hasattr(context, "pov_texture_slot"):
tex = context.texture
mat = bpy.context.active_object.active_material
return (
tex
and (tex.pov.tex_pattern_type != 'emulator')
and (engine in cls.COMPAT_ENGINES)
)
def draw(self, context):
tex = context.texture
slot = getattr(context, "pov_texture_slot", None)
idblock = pov_context_tex_datablock(context)
layout = self.layout
# if idblock:
# layout.template_preview(tex, parent=idblock, slot=slot)
if tex.pov.tex_pattern_type != 'emulator':
layout.operator("tex.preview_update")
else:
layout.template_preview(tex, slot=slot)
class TEXTURE_PT_POV_parameters(TextureButtonsPanel, Panel):
"""Use this class to define pov texture pattern buttons."""
bl_label = "POV Pattern Options"
bl_options = {'HIDE_HEADER'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw(self, context):
mat = bpy.context.active_object.active_material
layout = self.layout
tex = context.texture
if tex is not None and tex.pov.tex_pattern_type != 'emulator':
if tex.pov.tex_pattern_type == 'agate':
layout.prop(
tex.pov, "modifier_turbulence", text="Agate Turbulence"
)
if tex.pov.tex_pattern_type in {'spiral1', 'spiral2'}:
layout.prop(tex.pov, "modifier_numbers", text="Number of arms")
if tex.pov.tex_pattern_type == 'tiling':
layout.prop(tex.pov, "modifier_numbers", text="Pattern number")
if tex.pov.tex_pattern_type == 'magnet':
layout.prop(tex.pov, "magnet_style", text="Magnet style")
if tex.pov.tex_pattern_type == 'quilted':
row = layout.row(align=align)
row.prop(tex.pov, "modifier_control0", text="Control0")
row.prop(tex.pov, "modifier_control1", text="Control1")
if tex.pov.tex_pattern_type == 'brick':
col = layout.column(align=align)
row = col.row()
row.prop(tex.pov, "brick_size_x", text="Brick size X")
row.prop(tex.pov, "brick_size_y", text="Brick size Y")
row.prop(tex.pov, "brick_size_z", text="Brick size Z")
row.prop(tex.pov, "brick_mortar", text="Brick mortar")
if tex.pov.tex_pattern_type in {'julia', 'mandel', 'magnet'}:
col = layout.column(align=align)
if tex.pov.tex_pattern_type == 'julia':
row = col.row()
row.prop(tex.pov, "julia_complex_1", text="Complex 1")
row.prop(tex.pov, "julia_complex_2", text="Complex 2")
if (
tex.pov.tex_pattern_type == 'magnet'
and tex.pov.magnet_style == 'julia'
):
row = col.row()
row.prop(tex.pov, "julia_complex_1", text="Complex 1")
row.prop(tex.pov, "julia_complex_2", text="Complex 2")
row = col.row()
if tex.pov.tex_pattern_type in {'julia', 'mandel'}:
row.prop(tex.pov, "f_exponent", text="Exponent")
row.prop(tex.pov, "magnet_type", text="Type")
row.prop(tex.pov, "f_iter", text="Iterations")
row.prop(tex.pov, "f_ior", text="Interior")
row.prop(tex.pov, "f_ior_fac", text="Factor I")
row.prop(tex.pov, "f_eor", text="Exterior")
row.prop(tex.pov, "f_eor_fac", text="Factor E")
layout.label(text="Gradient orientation:")
column_flow = layout.column_flow(columns=3, align=True)
column_flow.prop(tex.pov, "grad_orient_x", text="X")
column_flow.prop(tex.pov, "grad_orient_y", text="Y")
column_flow.prop(tex.pov, "grad_orient_z", text="Z")
if tex.pov.tex_pattern_type == 'pavement':
layout.prop(
tex.pov, "pave_sides", text="Pavement:number of sides"
)
col = layout.column(align=align)
column_flow = col.column_flow(columns=3, align=True)
column_flow.prop(tex.pov, "pave_tiles", text="Tiles")
2930
2931
2932
2933
2934
2935
2936
2937
2938
2939
2940
2941
2942
2943
2944
2945
2946
2947
2948
2949
2950
2951
2952
2953
if tex.pov.pave_sides == '4' and tex.pov.pave_tiles == 6:
column_flow.prop(tex.pov, "pave_pat_35", text="Pattern")
if tex.pov.pave_sides == '6' and tex.pov.pave_tiles == 5:
column_flow.prop(tex.pov, "pave_pat_22", text="Pattern")
if tex.pov.pave_sides == '4' and tex.pov.pave_tiles == 5:
column_flow.prop(tex.pov, "pave_pat_12", text="Pattern")
if tex.pov.pave_sides == '3' and tex.pov.pave_tiles == 6:
column_flow.prop(tex.pov, "pave_pat_12", text="Pattern")
if tex.pov.pave_sides == '6' and tex.pov.pave_tiles == 4:
column_flow.prop(tex.pov, "pave_pat_7", text="Pattern")
if tex.pov.pave_sides == '4' and tex.pov.pave_tiles == 4:
column_flow.prop(tex.pov, "pave_pat_5", text="Pattern")
if tex.pov.pave_sides == '3' and tex.pov.pave_tiles == 5:
column_flow.prop(tex.pov, "pave_pat_4", text="Pattern")
if tex.pov.pave_sides == '6' and tex.pov.pave_tiles == 3:
column_flow.prop(tex.pov, "pave_pat_3", text="Pattern")
if tex.pov.pave_sides == '3' and tex.pov.pave_tiles == 4:
column_flow.prop(tex.pov, "pave_pat_3", text="Pattern")
if tex.pov.pave_sides == '4' and tex.pov.pave_tiles == 3:
column_flow.prop(tex.pov, "pave_pat_2", text="Pattern")
if tex.pov.pave_sides == '6' and tex.pov.pave_tiles == 6:
column_flow.label(text="!!! 5 tiles!")
column_flow.prop(tex.pov, "pave_form", text="Form")
if tex.pov.tex_pattern_type == 'function':
layout.prop(tex.pov, "func_list", text="Functions")
if (
tex.pov.tex_pattern_type == 'function'
and tex.pov.func_list != "NONE"
):
func = None
if tex.pov.func_list in {"f_noise3d", "f_ph", "f_r", "f_th"}:
func = 0
2962
2963
2964
2965
2966
2967
2968
2969
2970
2971
2972
2973
2974
2975
2976
2977
2978
2979
2980
2981
2982
2983
2984
2985
2986
2987
2988
2989
2990
2991
if tex.pov.func_list in {
"f_comma",
"f_crossed_trough",
"f_cubic_saddle",
"f_cushion",
"f_devils_curve",
"f_enneper",
"f_glob",
"f_heart",
"f_hex_x",
"f_hex_y",
"f_hunt_surface",
"f_klein_bottle",
"f_kummer_surface_v1",
"f_lemniscate_of_gerono",
"f_mitre",
"f_nodal_cubic",
"f_noise_generator",
"f_odd",
"f_paraboloid",
"f_pillow",
"f_piriform",
"f_quantum",
"f_quartic_paraboloid",
"f_quartic_saddle",
"f_sphere",
"f_steiners_roman",
"f_torus_gumdrop",
"f_umbrella",
}:
if tex.pov.func_list in {
"f_bicorn",
"f_bifolia",
"f_boy_surface",
"f_superellipsoid",
"f_torus",
}: