Newer
Older
col.prop(obj.pov, "st_u")
col.prop(obj.pov, "st_v")
col.prop(obj.pov, "st_ring")
col.prop(obj.pov, "st_cross")
col.prop(obj.pov, "st_ie")
# col.prop(obj.pov, "st_edit") #?
col.prop(obj.pov, "st_accuracy")
col.prop(obj.pov, "st_max_gradient")
class OBJECT_PT_POV_obj_parametric(PovDataButtonsPanel, Panel):
"""Use this class to define pov parametric surface primitive parameters buttons."""
bl_label = "POV Parametric surface"
COMPAT_ENGINES = {'POVRAY_RENDER'}
# bl_options = {'HIDE_HEADER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
obj = context.object
return (
obj
and obj.pov.object_as == 'PARAMETRIC'
and (engine in cls.COMPAT_ENGINES)
)
def draw(self, context):
layout = self.layout
obj = context.object
col = layout.column()
if obj.pov.object_as == 'PARAMETRIC':
if obj.pov.unlock_parameters == False:
col.prop(
obj.pov,
"unlock_parameters",
text="Exported parameters below",
icon='LOCKED',
)
col.label(text="Minimum U: " + str(obj.pov.u_min))
col.label(text="Minimum V: " + str(obj.pov.v_min))
col.label(text="Maximum U: " + str(obj.pov.u_max))
col.label(text="Minimum V: " + str(obj.pov.v_min))
col.label(text="X Function: " + str(obj.pov.x_eq))
col.label(text="Y Function: " + str(obj.pov.y_eq))
col.label(text="Z Function: " + str(obj.pov.x_eq))
else:
col.prop(
obj.pov,
"unlock_parameters",
text="Edit exported parameters",
icon='UNLOCKED',
)
col.label(text="3D view proxy may get out of synch")
col.active = obj.pov.unlock_parameters
layout.operator(
"pov.parametric_update", text="Update", icon="SCRIPTPLUGINS"
)
col.prop(obj.pov, "u_min", text="Minimum U")
col.prop(obj.pov, "v_min", text="Minimum V")
col.prop(obj.pov, "u_max", text="Maximum U")
col.prop(obj.pov, "v_max", text="Minimum V")
col.prop(obj.pov, "x_eq", text="X Function")
col.prop(obj.pov, "y_eq", text="Y Function")
col.prop(obj.pov, "z_eq", text="Z Function")
class OBJECT_PT_povray_replacement_text(ObjectButtonsPanel, Panel):
"""Use this class to define pov object replacement 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
obj = context.object
Maurice Raybaud
committed
col.label(text="Replace properties with:")
Bastien Montagne
committed
col.prop(obj.pov, "replacement_text", text="")
Maurice Raybaud
committed
###############################################################################
# Add Povray Objects
###############################################################################
class VIEW_MT_POV_primitives_add(Menu):
bl_idname = "VIEW_MT_POV_primitives_add"
bl_label = "Povray"
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
engine = context.scene.render.engine
return engine == 'POVRAY_RENDER'
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.menu(
VIEW_MT_POV_Basic_Shapes.bl_idname, text="Primitives", icon="GROUP"
)
layout.menu(VIEW_MT_POV_import.bl_idname, text="Import", icon="IMPORT")
class VIEW_MT_POV_Basic_Shapes(Menu):
"""Use this class to sort simple primitives menu entries."""
bl_idname = "POVRAY_MT_basic_shape_tools"
bl_label = "Basic_shapes"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator(
"pov.addplane", text="Infinite Plane", icon='MESH_PLANE'
)
layout.operator("pov.addbox", text="Box", icon='MESH_CUBE')
layout.operator("pov.addsphere", text="Sphere", icon='SHADING_RENDERED')
layout.operator(
"pov.addcylinder", text="Cylinder", icon="MESH_CYLINDER"
)
layout.operator("pov.cone_add", text="Cone", icon="MESH_CONE")
layout.operator("pov.addtorus", text="Torus", icon='MESH_TORUS')
layout.operator("pov.addrainbow", text="Rainbow", icon="COLOR")
layout.operator("pov.addlathe", text="Lathe", icon='MOD_SCREW')
layout.operator("pov.addprism", text="Prism", icon='MOD_SOLIDIFY')
layout.operator(
"pov.addsuperellipsoid",
text="Superquadric Ellipsoid",
icon='MOD_SUBSURF',
)
layout.operator(
"pov.addheightfield", text="Height Field", icon="RNDCURVE"
)
layout.operator(
"pov.addspheresweep", text="Sphere Sweep", icon='FORCE_CURVE'
)
layout.operator(
"pov.addblobsphere", text="Blob Sphere", icon='META_DATA'
)
layout.operator(
"pov.addisosurfacebox", text="Isosurface Box", icon="META_CUBE"
)
layout.operator(
"pov.addisosurfacesphere",
text="Isosurface Sphere",
icon="META_BALL",
)
layout.operator(
"pov.addsupertorus", text="Supertorus", icon="SURFACE_NTORUS"
)
layout.label(text="Macro based")
layout.operator(
"pov.addpolygontocircle",
text="Polygon To Circle Blending",
icon="MOD_CAST",
)
layout.operator("pov.addloft", text="Loft", icon="SURFACE_NSURFACE")
Maurice Raybaud
committed
layout.separator()
# Warning if the Add Advanced Objects addon containing
# Add mesh extra objects is not enabled
if not check_add_mesh_extra_objects():
# col = box.column()
layout.label(
text="Please enable Add Mesh: Extra Objects addon", icon="INFO"
)
# layout.separator()
layout.operator(
"preferences.addon_show",
text="Go to Add Mesh: Extra Objects addon",
icon="PREFERENCES",
).module = "add_mesh_extra_objects"
# layout.separator()
Maurice Raybaud
committed
return
else:
layout.operator(
"pov.addparametric", text="Parametric", icon='SCRIPTPLUGINS'
)
class VIEW_MT_POV_import(Menu):
"""Use this class for the import menu."""
bl_idname = "POVRAY_MT_import_tools"
bl_label = "Import"
def draw(self, context):
layout = self.layout
layout.operator_context = 'INVOKE_REGION_WIN'
layout.operator("import_scene.pov", icon="FORCE_LENNARDJONES")
def menu_func_add(self, context):
engine = context.scene.render.engine
if engine == 'POVRAY_RENDER':
self.layout.menu("VIEW_MT_POV_primitives_add", icon="PLUGIN")
def menu_func_import(self, context):
engine = context.scene.render.engine
if engine == 'POVRAY_RENDER':
self.layout.operator("import_scene.pov", icon="FORCE_LENNARDJONES")
##############Nodes
# def find_node_input(node, name):
# for input in node.inputs:
# if input.name == name:
# return input
# def panel_node_draw(layout, id_data, output_type, input_name):
# if not id_data.use_nodes:
# #layout.operator("pov.material_use_nodes", icon='SOUND')#'NODETREE')
# #layout.operator("pov.use_shading_nodes", icon='NODETREE')
# layout.operator("WM_OT_context_toggle", icon='NODETREE').data_path = \
# "material.pov.material_use_nodes"
# return False
# ntree = id_data.node_tree
# node = find_node(id_data, output_type)
# if not node:
# layout.label(text="No output node")
# else:
# input = find_node_input(node, input_name)
# layout.template_node_view(ntree, node, input)
class NODE_MT_POV_map_create(Menu):
bl_idname = "POVRAY_MT_node_map_create"
def draw(self, context):
layout = self.layout
layout.operator("node.map_create")
def menu_func_nodes(self, context):
ob = context.object
if hasattr(ob, 'active_material'):
mat = context.object.active_material
if mat and context.space_data.tree_type == 'ObjectNodeTree':
self.layout.prop(mat.pov, "material_use_nodes")
self.layout.menu(NODE_MT_POV_map_create.bl_idname)
self.layout.operator("wm.updatepreviewkey")
if (
hasattr(mat, 'active_texture')
and context.scene.render.engine == 'POVRAY_RENDER'
):
tex = mat.active_texture
if tex and context.space_data.tree_type == 'TextureNodeTree':
self.layout.prop(tex.pov, "texture_use_nodes")
###############################################################################
# Camera Povray Settings
###############################################################################
class CAMERA_PT_POV_cam_dof(CameraDataButtonsPanel, Panel):
"""Use this class for camera depth of field focal blur buttons."""
bl_label = "POV Aperture"
COMPAT_ENGINES = {'POVRAY_RENDER'}
bl_parent_id = "DATA_PT_camera_dof_aperture"
bl_options = {'HIDE_HEADER'}
# def draw_header(self, context):
# cam = context.camera
# self.layout.prop(cam.pov, "dof_enable", text="")
def draw(self, context):
layout = self.layout
cam = context.camera
layout.use_property_split = True # Active single-column layout
flow = layout.grid_flow(
row_major=True,
columns=0,
even_columns=True,
even_rows=False,
align=False,
)
Campbell Barton
committed
col = flow.column()
col.label(text="F-Stop value will export as")
col.label(
text="POV aperture : "
+ "%.3f" % (1 / cam.dof.aperture_fstop * 1000)
)
Bastien Montagne
committed
col.prop(cam.pov, "dof_samples_min")
col.prop(cam.pov, "dof_samples_max")
Bastien Montagne
committed
col.prop(cam.pov, "dof_confidence")
Maurice Raybaud
committed
class CAMERA_PT_POV_cam_nor(CameraDataButtonsPanel, Panel):
"""Use this class for camera normal perturbation buttons."""
bl_label = "POV Perturbation"
COMPAT_ENGINES = {'POVRAY_RENDER'}
def draw_header(self, context):
cam = context.camera
self.layout.prop(cam.pov, "normal_enable", text="")
def draw(self, context):
layout = self.layout
cam = context.camera
layout.active = cam.pov.normal_enable
layout.prop(cam.pov, "normal_patterns")
layout.prop(cam.pov, "cam_normal")
layout.prop(cam.pov, "turbulence")
layout.prop(cam.pov, "scale")
class CAMERA_PT_POV_replacement_text(CameraDataButtonsPanel, Panel):
"""Use this class for camera text replacement 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
cam = context.camera
Maurice Raybaud
committed
col.label(text="Replace properties with:")
Bastien Montagne
committed
col.prop(cam.pov, "replacement_text", text="")
Maurice Raybaud
committed
Maurice Raybaud
committed
###############################################################################
# Text Povray Settings
###############################################################################
class TEXT_OT_POV_insert(Operator):
"""Use this class to create blender text editor operator to insert pov snippets like other pov IDEs."""
Maurice Raybaud
committed
bl_idname = "text.povray_insert"
bl_label = "Insert"
filepath: bpy.props.StringProperty(name="Filepath", subtype='FILE_PATH')
Maurice Raybaud
committed
@classmethod
def poll(cls, context):
# context.area.type == 'TEXT_EDITOR'
return bpy.ops.text.insert.poll()
def execute(self, context):
if self.filepath and isfile(self.filepath):
file = open(self.filepath, "r")
bpy.ops.text.insert(text=file.read())
# places the cursor at the end without scrolling -.-
# context.space_data.text.write(file.read())
file.close()
return {'FINISHED'}
Maurice Raybaud
committed
def validinsert(ext):
return ext in {".txt", ".inc", ".pov"}
class TEXT_MT_POV_insert(Menu):
"""Use this class to create a menu launcher in text editor for the TEXT_OT_POV_insert operator ."""
Maurice Raybaud
committed
bl_label = "Insert"
bl_idname = "TEXT_MT_POV_insert"
Maurice Raybaud
committed
def draw(self, context):
pov_documents = locate_docpath()
prop = self.layout.operator(
"wm.path_open", text="Open folder", icon='FILE_FOLDER'
)
Maurice Raybaud
committed
prop.filepath = pov_documents
self.layout.separator()
list = []
for root, dirs, files in os.walk(pov_documents):
Maurice Raybaud
committed
list.append(root)
print(list)
self.path_menu(
list,
"text.povray_insert",
# {"internal": True},
filter_ext=validinsert,
)
Maurice Raybaud
committed
class TEXT_PT_POV_custom_code(TextButtonsPanel, Panel):
"""Use this class to create a panel in text editor for the user to decide if he renders text only or adds to 3d scene."""
Campbell Barton
committed
COMPAT_ENGINES = {'POVRAY_RENDER'}
Maurice Raybaud
committed
def draw(self, context):
layout = self.layout
Maurice Raybaud
committed
pov_documents = locate_docpath()
if not pov_documents:
Maurice Raybaud
committed
layout.label(text="Please configure ", icon="INFO")
layout.label(text="default pov include path ")
layout.label(text="in addon preferences")
# layout.separator()
layout.operator(
"preferences.addon_show",
text="Go to Render: Persistence of Vision addon",
icon="PREFERENCES",
).module = "render_povray"
# layout.separator()
Maurice Raybaud
committed
else:
# print(pov_documents)
layout.menu(TEXT_MT_POV_insert.bl_idname)
Maurice Raybaud
committed
if text:
box = layout.box()
box.label(text='Source to render:', icon='RENDER_STILL')
Maurice Raybaud
committed
row = box.row()
row.prop(text.pov, "custom_code", expand=True)
Maurice Raybaud
committed
if text.pov.custom_code in {'3dview'}:
box.operator("render.render", icon='OUTLINER_DATA_ARMATURE')
Maurice Raybaud
committed
if text.pov.custom_code in {'text'}:
rtext = bpy.context.space_data.text
box.operator("text.run", icon='ARMATURE_DATA')
# layout.prop(text.pov, "custom_code")
Maurice Raybaud
committed
elif text.pov.custom_code in {'both'}:
box.operator("render.render", icon='POSE_HLT')
layout.label(text="Please specify declared", icon="INFO")
layout.label(text="items in properties ")
# layout.label(text="")
Maurice Raybaud
committed
layout.label(text="replacement fields")
Maurice Raybaud
committed
###############################################
# Text editor templates from header menu
class TEXT_MT_POV_templates(Menu):
"""Use this class to create a menu for the same pov templates scenes as other pov IDEs."""
# We list templates on file evaluation, we can assume they are static data,
# and better avoid running this on every draw call.
import os
template_paths = [os.path.join(os.path.dirname(__file__), "templates_pov")]
def draw(self, context):
self.path_menu(
self.template_paths, "text.open", props_default={"internal": True}
)
def menu_func_templates(self, context):
# Do not depend on POV being active renderer here...
self.layout.menu("TEXT_MT_POV_templates")
4492
4493
4494
4495
4496
4497
4498
4499
4500
4501
4502
4503
4504
4505
4506
4507
4508
4509
4510
4511
4512
4513
4514
4515
4516
4517
4518
4519
4520
4521
4522
4523
4524
4525
4526
4527
4528
4529
4530
4531
4532
4533
4534
4535
4536
4537
4538
4539
4540
4541
4542
4543
4544
4545
4546
4547
4548
4549
4550
4551
4552
4553
4554
4555
4556
4557
4558
4559
4560
4561
4562
4563
4564
4565
4566
4567
4568
4569
4570
4571
4572
4573
4574
4575
4576
4577
4578
4579
4580
4581
4582
4583
4584
4585
4586
4587
4588
4589
###############################################################################
# Freestyle
###############################################################################
#import addon_utils
#addon_utils.paths()[0]
#addon_utils.modules()
#mod.bl_info['name'] == 'Freestyle SVG Exporter':
bpy.utils.script_paths("addons")
#render_freestyle_svg = os.path.join(bpy.utils.script_paths("addons"), "render_freestyle_svg.py")
render_freestyle_svg = bpy.context.preferences.addons.get('render_freestyle_svg')
#mpath=addon_utils.paths()[0].render_freestyle_svg
#import mpath
#from mpath import render_freestyle_svg #= addon_utils.modules(['Freestyle SVG Exporter'])
#from scripts\\addons import render_freestyle_svg
if check_render_freestyle_svg():
'''
snippetsWIP
import myscript
import importlib
importlib.reload(myscript)
myscript.main()
'''
for member in dir(render_freestyle_svg):
subclass = getattr(render_freestyle_svg, member)
try:
subclass.COMPAT_ENGINES.add('POVRAY_RENDER')
if subclass.bl_idname == "RENDER_PT_SVGExporterPanel":
subclass.bl_parent_id = "RENDER_PT_POV_filter"
subclass.bl_options = {'HIDE_HEADER'}
#subclass.bl_order = 11
print(subclass.bl_info)
except:
pass
#del render_freestyle_svg.RENDER_PT_SVGExporterPanel.bl_parent_id
class RENDER_PT_POV_filter(RenderButtonsPanel, Panel):
"""Use this class to invoke stuff like Freestyle UI."""
bl_label = "Freestyle"
bl_options = {'DEFAULT_CLOSED'}
COMPAT_ENGINES = {'POVRAY_RENDER'}
@classmethod
def poll(cls, context):
with_freestyle = bpy.app.build_options.freestyle
engine = context.scene.render.engine
return(with_freestyle and engine == 'POVRAY_RENDER')
def draw_header(self, context):
#scene = context.scene
rd = context.scene.render
layout = self.layout
if rd.use_freestyle:
layout.prop(
rd, "use_freestyle", text="", icon='LINE_DATA'
)
else:
layout.prop(
rd, "use_freestyle", text="", icon='OUTLINER_OB_IMAGE'
)
def draw(self, context):
rd = context.scene.render
layout = self.layout
layout.active = rd.use_freestyle
layout.use_property_split = True
layout.use_property_decorate = False # No animation.
flow = layout.grid_flow(
row_major=True,
columns=0,
even_columns=True,
even_rows=False,
align=True,
)
flow.prop(rd, "line_thickness_mode", expand=True)
if rd.line_thickness_mode == 'ABSOLUTE':
flow.prop(rd, "line_thickness")
# Warning if the Freestyle SVG Exporter addon is not enabled
if not check_render_freestyle_svg():
# col = box.column()
layout.label(
text="Please enable Freestyle SVG Exporter addon", icon="INFO"
)
# layout.separator()
layout.operator(
"preferences.addon_show",
text="Go to Render: Freestyle SVG Exporter addon",
icon="PREFERENCES",
).module = "render_freestyle_svg"
WORLD_PT_POV_world,
WORLD_MT_POV_presets,
WORLD_OT_POV_add_preset,
WORLD_TEXTURE_SLOTS_UL_POV_layerlist,
#WORLD_TEXTURE_SLOTS_UL_List,
# RenderButtonsPanel,
# ModifierButtonsPanel,
# MaterialButtonsPanel,
# TextureButtonsPanel,
# ObjectButtonsPanel,
# CameraDataButtonsPanel,
# WorldButtonsPanel,
# TextButtonsPanel,
# PovDataButtonsPanel,
DATA_PT_POV_normals,
DATA_PT_POV_texture_space,
DATA_PT_POV_vertex_groups,
DATA_PT_POV_shape_keys,
DATA_PT_POV_uv_texture,
DATA_PT_POV_vertex_colors,
DATA_PT_POV_customdata,
# PovLampButtonsPanel,
LIGHT_PT_POV_preview,
LIGHT_PT_POV_light,
LIGHT_MT_POV_presets,
LIGHT_OT_POV_add_preset,
OBJECT_PT_POV_rainbow,
RENDER_PT_POV_export_settings,
RENDER_PT_POV_render_settings,
RENDER_PT_POV_photons,
RENDER_PT_POV_antialias,
RENDER_PT_POV_radiosity,
RENDER_OT_POV_radiosity_add_preset,
RENDER_PT_POV_media,
MODIFIERS_PT_POV_modifiers,
MATERIAL_PT_POV_sss,
MATERIAL_OT_POV_sss_add_preset,
MATERIAL_PT_POV_activate_node,
MATERIAL_PT_POV_active_node,
MATERIAL_PT_POV_mirror,
MATERIAL_PT_POV_transp,
MATERIAL_PT_POV_reflection,
# MATERIAL_PT_POV_interior,
MATERIAL_PT_POV_fade_color,
MATERIAL_PT_POV_caustics,
MATERIAL_PT_POV_replacement_text,
TEXTURE_MT_POV_specials,
TEXTURE_PT_POV_type,
TEXTURE_PT_POV_preview,
TEXTURE_PT_POV_parameters,
TEXTURE_PT_POV_tex_gamma,
OBJECT_PT_POV_obj_parameters,
OBJECT_PT_POV_obj_sphere,
OBJECT_PT_POV_obj_cylinder,
OBJECT_PT_POV_obj_cone,
OBJECT_PT_POV_obj_superellipsoid,
OBJECT_PT_POV_obj_torus,
OBJECT_PT_POV_obj_supertorus,
OBJECT_PT_POV_obj_parametric,
OBJECT_PT_povray_replacement_text,
VIEW_MT_POV_primitives_add,
VIEW_MT_POV_Basic_Shapes,
VIEW_MT_POV_import,
NODE_MT_POV_map_create,
CAMERA_PT_POV_cam_dof,
CAMERA_PT_POV_cam_nor,
CAMERA_PT_POV_replacement_text,
TEXT_OT_POV_insert,
TEXT_MT_POV_insert,
TEXT_PT_POV_custom_code,
TEXT_MT_POV_templates,
#TEXTURE_PT_POV_povray_texture_slots,
#TEXTURE_UL_POV_texture_slots,
TEXTURE_OT_POV_texture_slot_add,
TEXTURE_OT_POV_texture_slot_remove,
TEXTURE_PT_POV_influence,
)
def register():
# from bpy.utils import register_class
for cls in classes:
register_class(cls)
bpy.types.VIEW3D_MT_add.prepend(menu_func_add)
bpy.types.TOPBAR_MT_file_import.append(menu_func_import)
bpy.types.TEXT_MT_templates.append(menu_func_templates)
bpy.types.RENDER_PT_POV_radiosity.prepend(rad_panel_func)
bpy.types.LIGHT_PT_POV_light.prepend(light_panel_func)
# bpy.types.WORLD_PT_POV_world.prepend(world_panel_func)
# was used for parametric objects but made the other addon unreachable on
# unregister for other tools to use created a user action call instead
# addon_utils.enable("add_mesh_extra_objects", default_set=False, persistent=True)
# bpy.types.TEXTURE_PT_context_texture.prepend(TEXTURE_PT_POV_type)
if not povCentricWorkspace in bpy.app.handlers.load_post:
# print("Adding POV wentric workspace on load handlers list")
bpy.app.handlers.load_post.append(povCentricWorkspace)
if povCentricWorkspace in bpy.app.handlers.load_post:
# print("Removing POV wentric workspace from load handlers list")
bpy.app.handlers.load_post.remove(povCentricWorkspace)
# from bpy.utils import unregister_class
# bpy.types.TEXTURE_PT_context_texture.remove(TEXTURE_PT_POV_type)
# addon_utils.disable("add_mesh_extra_objects", default_set=False)
# bpy.types.WORLD_PT_POV_world.remove(world_panel_func)
bpy.types.LIGHT_PT_POV_light.remove(light_panel_func)
bpy.types.RENDER_PT_POV_radiosity.remove(rad_panel_func)
bpy.types.TEXT_MT_templates.remove(menu_func_templates)
bpy.types.TOPBAR_MT_file_import.remove(menu_func_import)
bpy.types.VIEW3D_MT_add.remove(menu_func_add)
for cls in reversed(classes):
if cls != TEXTURE_PT_context:
unregister_class(cls)