diff options
author | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2021-05-27 19:41:55 +0300 |
---|---|---|
committer | Maurice Raybaud <mauriceraybaud@hotmail.fr> | 2021-05-27 19:41:55 +0300 |
commit | e25068ef471c6d6cd5ee64a2eef9b7d672c57029 (patch) | |
tree | 06761f2667d2f875d10ed0fff1af1bc7c20a2bda | |
parent | a885950276ea98dfa6a67c6d035198b59692a658 (diff) |
Revert "POV : fix registering"
This reverts commit a885950276ea98dfa6a67c6d035198b59692a658.
-rwxr-xr-x | render_povray/__init__.py | 14 | ||||
-rwxr-xr-x | render_povray/object_gui.py | 5 | ||||
-rwxr-xr-x | render_povray/object_primitives.py | 2 | ||||
-rwxr-xr-x | render_povray/render.py | 8 | ||||
-rwxr-xr-x | render_povray/render_gui.py | 28 | ||||
-rwxr-xr-x | render_povray/render_properties.py | 4 | ||||
-rwxr-xr-x | render_povray/scenography.py | 15 | ||||
-rwxr-xr-x | render_povray/scenography_gui.py | 66 | ||||
-rwxr-xr-x | render_povray/scenography_properties.py | 125 | ||||
-rwxr-xr-x | render_povray/scripting.py | 11 | ||||
-rwxr-xr-x | render_povray/scripting_gui.py | 2 | ||||
-rwxr-xr-x | render_povray/scripting_properties.py | 6 | ||||
-rwxr-xr-x | render_povray/shading_gui.py | 15 | ||||
-rwxr-xr-x | render_povray/shading_nodes.py | 14 | ||||
-rwxr-xr-x | render_povray/texturing_gui.py | 8 | ||||
-rwxr-xr-x | render_povray/texturing_properties.py | 129 |
16 files changed, 189 insertions, 263 deletions
diff --git a/render_povray/__init__.py b/render_povray/__init__.py index 21de6ff8..f0734c5f 100755 --- a/render_povray/__init__.py +++ b/render_povray/__init__.py @@ -250,8 +250,7 @@ class POV_OT_update_addon(bpy.types.Operator): with tempfile.TemporaryDirectory() as temp_dir_path: temp_zip_path = os.path.join(temp_dir_path, 'master.zip') - # Download zip archive of latest addons master branch commit - # More work needed so we also get the pov presets from addons shared folder. + # Download zip archive of latest addons master branch commit (So we also get presets) # switch this URL back to the BF hosted one as soon as gitweb snapshot gets fixed url = 'https://github.com/blender/blender-addons/archive/refs/heads/master.zip' try: @@ -398,10 +397,7 @@ class PovrayPreferences(bpy.types.AddonPreferences): layout.operator("pov.update_addon", icon='FILE_REFRESH') -classes = ( - POV_OT_update_addon, # already registered as a subclass - PovrayPreferences -) +classes = (POV_OT_update_addon, PovrayPreferences) def register(): @@ -414,7 +410,7 @@ def register(): texturing_properties.register() object_properties.register() scripting_properties.register() - #scenography.register() + scenography.register() render.register() base_ui.register() scripting.register() @@ -426,7 +422,7 @@ def unregister(): scripting.unregister() base_ui.unregister() render.unregister() - #scenography.unregister() + scenography.unregister() scripting_properties.unregister() object_properties.unregister() texturing_properties.unregister() @@ -434,7 +430,7 @@ def unregister(): scenography_properties.unregister() render_properties.unregister() - for cls in classes: + for cls in reversed(classes): unregister_class(cls) diff --git a/render_povray/object_gui.py b/render_povray/object_gui.py index bc7df9f4..9fbf8a8b 100755 --- a/render_povray/object_gui.py +++ b/render_povray/object_gui.py @@ -34,11 +34,8 @@ from bl_ui import properties_data_modifier for member in dir(properties_data_modifier): subclass = getattr(properties_data_modifier, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) del properties_data_modifier diff --git a/render_povray/object_primitives.py b/render_povray/object_primitives.py index fc6bafde..4556f2df 100755 --- a/render_povray/object_primitives.py +++ b/render_povray/object_primitives.py @@ -1769,5 +1769,5 @@ def register(): def unregister(): - for cls in reversed(classes): + for cls in classes: unregister_class(cls) diff --git a/render_povray/render.py b/render_povray/render.py index 7b6e5810..45a94912 100755 --- a/render_povray/render.py +++ b/render_povray/render.py @@ -17,9 +17,7 @@ # #**** END GPL LICENSE BLOCK #**** # <pep8 compliant> - """Wirte the POV file using this file's functions and some from other modules then render it.""" - import bpy import subprocess import os @@ -1809,11 +1807,7 @@ class RunPovTextRender(Operator): return {'FINISHED'} -classes = ( - PovrayRender, - RenderPovTexturePreview, - RunPovTextRender, -) +classes = (PovrayRender, RenderPovTexturePreview, RunPovTextRender) def register(): diff --git a/render_povray/render_gui.py b/render_povray/render_gui.py index 464ba367..018821cb 100755 --- a/render_povray/render_gui.py +++ b/render_povray/render_gui.py @@ -36,38 +36,26 @@ from bl_ui import properties_output for member in dir(properties_output): subclass = getattr(properties_output, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_output from bl_ui import properties_freestyle for member in dir(properties_freestyle): subclass = getattr(properties_freestyle, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): if not (subclass.bl_space_type == 'PROPERTIES' and subclass.bl_context == "render"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') # subclass.bl_parent_id = "RENDER_PT_POV_filter" - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_freestyle from bl_ui import properties_view_layer for member in dir(properties_view_layer): subclass = getattr(properties_view_layer, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_view_layer # Use some of the existing buttons. @@ -452,17 +440,13 @@ if check_render_freestyle_svg(): ''' for member in dir(render_freestyle_svg): subclass = getattr(render_freestyle_svg, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): 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 BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass # del render_freestyle_svg.RENDER_PT_SVGExporterPanel.bl_parent_id @@ -553,10 +537,10 @@ classes = ( def register(): for cls in classes: register_class(cls) - RENDER_PT_POV_radiosity.prepend(rad_panel_func) + bpy.types.RENDER_PT_POV_radiosity.prepend(rad_panel_func) def unregister(): - RENDER_PT_POV_radiosity.remove(rad_panel_func) + bpy.types.RENDER_PT_POV_radiosity.remove(rad_panel_func) for cls in reversed(classes): unregister_class(cls) diff --git a/render_povray/render_properties.py b/render_povray/render_properties.py index 20e9761d..9096c986 100755 --- a/render_povray/render_properties.py +++ b/render_povray/render_properties.py @@ -672,9 +672,7 @@ class RenderPovSettingsScene(PropertyGroup): ) -classes = ( - RenderPovSettingsScene, -) +classes = (RenderPovSettingsScene,) def register(): diff --git a/render_povray/scenography.py b/render_povray/scenography.py index 6c9aed80..4b0c99e3 100755 --- a/render_povray/scenography.py +++ b/render_povray/scenography.py @@ -23,7 +23,7 @@ with world, sky, atmospheric effects such as rainbows or smoke """ import bpy - +from bpy.utils import register_class, unregister_class import os from imghdr import what # imghdr is a python lib to identify image file types from math import atan, pi, sqrt, degrees @@ -832,3 +832,16 @@ def export_smoke(file, smoke_obj_name, smoke_path, comments, global_matrix, writ # file.write(" frequency 0\n") # file.write(" }\n") # file.write("}\n") + + +classes = () + + +def register(): + for cls in classes: + register_class(cls) + + +def unregister(): + for cls in classes: + unregister_class(cls) diff --git a/render_povray/scenography_gui.py b/render_povray/scenography_gui.py index 41e25a21..6eb5aed9 100755 --- a/render_povray/scenography_gui.py +++ b/render_povray/scenography_gui.py @@ -31,12 +31,8 @@ from bl_ui import properties_data_camera for member in dir(properties_data_camera): subclass = getattr(properties_data_camera, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_data_camera # ################################## @@ -54,12 +50,8 @@ from bl_ui import properties_physics_common for member in dir(properties_physics_common): subclass = getattr(properties_physics_common, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_common # Physics Rigid Bodies wrapping every class 'as is' @@ -67,12 +59,8 @@ from bl_ui import properties_physics_rigidbody for member in dir(properties_physics_rigidbody): subclass = getattr(properties_physics_rigidbody, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_rigidbody # Physics Rigid Body Constraint wrapping every class 'as is' @@ -80,12 +68,8 @@ from bl_ui import properties_physics_rigidbody_constraint for member in dir(properties_physics_rigidbody_constraint): subclass = getattr(properties_physics_rigidbody_constraint, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_rigidbody_constraint # Physics Smoke and fluids wrapping every class 'as is' @@ -93,12 +77,8 @@ from bl_ui import properties_physics_fluid for member in dir(properties_physics_fluid): subclass = getattr(properties_physics_fluid, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_fluid # Physics softbody wrapping every class 'as is' @@ -106,12 +86,8 @@ from bl_ui import properties_physics_softbody for member in dir(properties_physics_softbody): subclass = getattr(properties_physics_softbody, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_softbody # Physics Field wrapping every class 'as is' @@ -119,12 +95,8 @@ from bl_ui import properties_physics_field for member in dir(properties_physics_field): subclass = getattr(properties_physics_field, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_field # Physics Cloth wrapping every class 'as is' @@ -132,12 +104,8 @@ from bl_ui import properties_physics_cloth for member in dir(properties_physics_cloth): subclass = getattr(properties_physics_cloth, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_cloth # Physics Dynamic Paint wrapping every class 'as is' @@ -145,24 +113,16 @@ from bl_ui import properties_physics_dynamicpaint for member in dir(properties_physics_dynamicpaint): subclass = getattr(properties_physics_dynamicpaint, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_physics_dynamicpaint from bl_ui import properties_particle for member in dir(properties_particle): # add all "particle" panels from blender subclass = getattr(properties_particle, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_particle @@ -790,10 +750,12 @@ def register(): for cls in classes: register_class(cls) - LIGHT_PT_POV_light.prepend(light_panel_func) + bpy.types.LIGHT_PT_POV_light.prepend(light_panel_func) def unregister(): - LIGHT_PT_POV_light.remove(light_panel_func) + + bpy.types.LIGHT_PT_POV_light.remove(light_panel_func) for cls in reversed(classes): unregister_class(cls) + diff --git a/render_povray/scenography_properties.py b/render_povray/scenography_properties.py index 97c856f6..dd886513 100755 --- a/render_povray/scenography_properties.py +++ b/render_povray/scenography_properties.py @@ -352,128 +352,6 @@ class RenderPovSettingsWorld(PropertyGroup): name="Index for texture_slots", default=0, update=brush_texture_update ) -############################################################################### -# Texture slots (World context) exported as POV texture properties. -############################################################################### - -class WorldTextureSlot(PropertyGroup): - """Declare world texture slot level properties for UI and translated to POV.""" - - bl_idname = ("pov_texture_slots",) - bl_description = ("Texture_slots from Blender-2.79",) - - # Adding a "real" texture datablock as property is not possible - # (or at least not easy through a dynamically populated EnumProperty). - # That's why we'll use a prop_search() UILayout function in texturing_gui.py. - # So we'll assign the name of the needed texture datablock to the below StringProperty. - texture: StringProperty(update=active_texture_name_from_uilist) - # and use another temporary StringProperty to change the linked data - texture_search: StringProperty( - name="", update=active_texture_name_from_search, description="Browse Texture to be linked" - ) - - blend_factor: FloatProperty( - name="Blend", - description="Amount texture affects color progression of the " "background", - soft_min=0.0, - soft_max=1.0, - default=1.0, - ) - - horizon_factor: FloatProperty( - name="Horizon", - description="Amount texture affects color of the horizon", - soft_min=0.0, - soft_max=1.0, - default=1.0, - ) - - object: StringProperty( - name="Object", - description="Object to use for mapping with Object texture coordinates", - default="", - ) - - offset: FloatVectorProperty( - name="Offset", - description=("Fine tune of the texture mapping X, Y and Z locations "), - precision=4, - step=0.1, - soft_min=-100.0, - soft_max=100.0, - default=(0.0, 0.0, 0.0), - options={"ANIMATABLE"}, - subtype="TRANSLATION", - ) - - scale: FloatVectorProperty( - name="Size", - subtype="XYZ", - size=3, - description="Set scaling for the texture’s X, Y and Z sizes ", - precision=4, - step=0.1, - soft_min=-100.0, - soft_max=100.0, - default=(1.0, 1.0, 1.0), - options={"ANIMATABLE"}, - ) - - texture_coords: EnumProperty( - name="Coordinates", - description="Texture coordinates used to map the texture onto the background", - items=( - ("VIEW", "View", "Use view vector for the texture coordinates"), - ( - "GLOBAL", - "Global", - "Use global coordinates for the texture coordinates (interior mist)", - ), - ( - "ANGMAP", - "AngMap", - "Use 360 degree angular coordinates, e.g. for spherical light probes", - ), - ("SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"), - ("EQUIRECT", "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"), - ("TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"), - ("OBJECT", "Object", "Use linked object’s coordinates for texture coordinates"), - ), - default="VIEW", - ) - - use_map_blend: BoolProperty( - name="Blend Map", description="Affect the color progression of the background", default=True - ) - - use_map_horizon: BoolProperty( - name="Horizon Map", description="Affect the color of the horizon", default=False - ) - - use_map_zenith_down: BoolProperty( - name="", description="Affect the color of the zenith below", default=False - ) - - use_map_zenith_up: BoolProperty( - name="Zenith Up Map", description="Affect the color of the zenith above", default=False - ) - - zenith_down_factor: FloatProperty( - name="Zenith Down", - description="Amount texture affects color of the zenith below", - soft_min=0.0, - soft_max=1.0, - default=1.0, - ) - - zenith_up_factor: FloatProperty( - name="Zenith Up", - description="Amount texture affects color of the zenith above", - soft_min=0.0, - soft_max=1.0, - default=1.0, - ) - """ # class WORLD_TEXTURE_SLOTS_UL_layerlist(bpy.types.UIList): @@ -493,7 +371,6 @@ classes = ( RenderPovSettingsCamera, RenderPovSettingsLight, RenderPovSettingsWorld, - WorldTextureSlot, ) @@ -504,14 +381,12 @@ def register(): bpy.types.Camera.pov = PointerProperty(type=RenderPovSettingsCamera) bpy.types.Light.pov = PointerProperty(type=RenderPovSettingsLight) bpy.types.World.pov = PointerProperty(type=RenderPovSettingsWorld) - bpy.types.World.pov_texture_slots = CollectionProperty(type=WorldTextureSlot) def unregister(): del bpy.types.Camera.pov del bpy.types.Light.pov del bpy.types.World.pov - del bpy.types.World.pov_texture_slots for cls in reversed(classes): unregister_class(cls) diff --git a/render_povray/scripting.py b/render_povray/scripting.py index 307573df..02ca6444 100755 --- a/render_povray/scripting.py +++ b/render_povray/scripting.py @@ -25,7 +25,6 @@ load, create or edit""" import bpy from bpy.props import StringProperty, BoolProperty, CollectionProperty from bpy_extras.io_utils import ImportHelper -from bpy.utils import register_class, unregister_class from mathutils import Vector from math import pi @@ -521,16 +520,10 @@ class ImportPOV(bpy.types.Operator, ImportHelper): # obj.location = (0,0,0) return {'FINISHED'} -classes = ( - ImportPOV, -) def register(): - for cls in classes: - register_class(cls) + bpy.utils.register_class(ImportPOV) def unregister(): - for cls in reversed(classes): - unregister_class(cls) - + bpy.utils.unregister_class(ImportPOV) diff --git a/render_povray/scripting_gui.py b/render_povray/scripting_gui.py index c4d2fe01..99006af1 100755 --- a/render_povray/scripting_gui.py +++ b/render_povray/scripting_gui.py @@ -251,6 +251,7 @@ classes = ( def register(): + for cls in classes: register_class(cls) @@ -259,6 +260,7 @@ def register(): def unregister(): + bpy.types.TEXT_MT_templates.remove(menu_func_templates) bpy.types.TOPBAR_MT_file_import.remove(menu_func_import) diff --git a/render_povray/scripting_properties.py b/render_povray/scripting_properties.py index 66bb0191..3e743da3 100755 --- a/render_povray/scripting_properties.py +++ b/render_povray/scripting_properties.py @@ -17,10 +17,10 @@ # ##### END GPL LICENSE BLOCK ##### # <pep8 compliant> +import bpy """Declare pov native file syntax properties controllable in UI hooks and text blocks""" -import bpy from bpy.utils import register_class, unregister_class from bpy.types import PropertyGroup from bpy.props import EnumProperty, PointerProperty @@ -42,9 +42,7 @@ class RenderPovSettingsText(PropertyGroup): ) -classes = ( - RenderPovSettingsText, -) +classes = (RenderPovSettingsText,) def register(): diff --git a/render_povray/shading_gui.py b/render_povray/shading_gui.py index 3d286260..428542c8 100755 --- a/render_povray/shading_gui.py +++ b/render_povray/shading_gui.py @@ -29,16 +29,8 @@ from bl_ui import properties_material for member in dir(properties_material): subclass = getattr(properties_material, member) - try: - # mat=bpy.context.active_object.active_material - # if (mat and mat.pov.type == "SURFACE" - # and not (mat.pov.material_use_nodes or mat.use_nodes)): - # and (engine in cls.COMPAT_ENGINES)) if subclasses were sorted + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_material from .shading_properties import check_material @@ -52,7 +44,8 @@ def simple_material(mat): class MaterialButtonsPanel: - """Use this class to define buttons from the material tab of properties window.""" + """Use this class to define buttons from the material tab of + properties window.""" bl_space_type = 'PROPERTIES' bl_region_type = 'WINDOW' @@ -676,10 +669,12 @@ classes = ( def register(): + for cls in classes: register_class(cls) def unregister(): + for cls in reversed(classes): unregister_class(cls) diff --git a/render_povray/shading_nodes.py b/render_povray/shading_nodes.py index c27014eb..2e8484f9 100755 --- a/render_povray/shading_nodes.py +++ b/render_povray/shading_nodes.py @@ -1995,15 +1995,17 @@ classes = ( def register(): + # from bpy.utils import register_class + bpy.types.NODE_HT_header.append(menu_func_nodes) + nodeitems_utils.register_node_categories("POVRAYNODES", node_categories) for cls in classes: register_class(cls) - nodeitems_utils.register_node_categories("POVRAYNODES", node_categories) - bpy.types.NODE_HT_header.append(menu_func_nodes) + def unregister(): - bpy.types.NODE_HT_header.remove(menu_func_nodes) - nodeitems_utils.unregister_node_categories("POVRAYNODES") + # from bpy.utils import unregister_class + for cls in reversed(classes): unregister_class(cls) - - + nodeitems_utils.unregister_node_categories("POVRAYNODES") + bpy.types.NODE_HT_header.remove(menu_func_nodes) diff --git a/render_povray/texturing_gui.py b/render_povray/texturing_gui.py index c59f5d57..ad889f43 100755 --- a/render_povray/texturing_gui.py +++ b/render_povray/texturing_gui.py @@ -49,12 +49,8 @@ from bl_ui import properties_texture for member in dir(properties_texture): subclass = getattr(properties_texture, member) - try: + if hasattr(subclass, "COMPAT_ENGINES"): subclass.COMPAT_ENGINES.add('POVRAY_RENDER') - except BaseException as e: - print(e.__doc__) - print('An exception occurred: {}'.format(e)) - pass del properties_texture @@ -1228,7 +1224,6 @@ class TEXTURE_PT_POV_tex_gamma(TextureButtonsPanel, Panel): classes = ( WORLD_TEXTURE_SLOTS_UL_POV_layerlist, TEXTURE_MT_POV_specials, - #TEXTURE_PT_context, TEXTURE_PT_POV_context_texture, TEXTURE_PT_colors, TEXTURE_PT_POV_type, @@ -1244,6 +1239,7 @@ classes = ( def register(): + for cls in classes: register_class(cls) diff --git a/render_povray/texturing_properties.py b/render_povray/texturing_properties.py index 6551b8c3..bb89ee02 100755 --- a/render_povray/texturing_properties.py +++ b/render_povray/texturing_properties.py @@ -17,7 +17,6 @@ # ##### END GPL LICENSE BLOCK ##### # <pep8 compliant> - """Declare texturing properties controllable in UI.""" import bpy @@ -463,6 +462,128 @@ class MaterialTextureSlot(PropertyGroup): ############################################################################### +# Texture slots (World context) exported as POV texture properties. +############################################################################### +class WorldTextureSlot(PropertyGroup): + """Declare world texture slot level properties for UI and translated to POV.""" + + bl_idname = ("pov_texture_slots",) + bl_description = ("Texture_slots from Blender-2.79",) + + # Adding a "real" texture datablock as property is not possible + # (or at least not easy through a dynamically populated EnumProperty). + # That's why we'll use a prop_search() UILayout function in ui.py. + # So we'll assign the name of the needed texture datablock to the below StringProperty. + texture: StringProperty(update=active_texture_name_from_uilist) + # and use another temporary StringProperty to change the linked data + texture_search: StringProperty( + name="", update=active_texture_name_from_search, description="Browse Texture to be linked" + ) + + blend_factor: FloatProperty( + name="Blend", + description="Amount texture affects color progression of the " "background", + soft_min=0.0, + soft_max=1.0, + default=1.0, + ) + + horizon_factor: FloatProperty( + name="Horizon", + description="Amount texture affects color of the horizon", + soft_min=0.0, + soft_max=1.0, + default=1.0, + ) + + object: StringProperty( + name="Object", + description="Object to use for mapping with Object texture coordinates", + default="", + ) + + offset: FloatVectorProperty( + name="Offset", + description=("Fine tune of the texture mapping X, Y and Z locations "), + precision=4, + step=0.1, + soft_min=-100.0, + soft_max=100.0, + default=(0.0, 0.0, 0.0), + options={"ANIMATABLE"}, + subtype="TRANSLATION", + ) + + scale: FloatVectorProperty( + name="Size", + subtype="XYZ", + size=3, + description="Set scaling for the texture’s X, Y and Z sizes ", + precision=4, + step=0.1, + soft_min=-100.0, + soft_max=100.0, + default=(1.0, 1.0, 1.0), + options={"ANIMATABLE"}, + ) + + texture_coords: EnumProperty( + name="Coordinates", + description="Texture coordinates used to map the texture onto the background", + items=( + ("VIEW", "View", "Use view vector for the texture coordinates"), + ( + "GLOBAL", + "Global", + "Use global coordinates for the texture coordinates (interior mist)", + ), + ( + "ANGMAP", + "AngMap", + "Use 360 degree angular coordinates, e.g. for spherical light probes", + ), + ("SPHERE", "Sphere", "For 360 degree panorama sky, spherical mapped, only top half"), + ("EQUIRECT", "Equirectangular", "For 360 degree panorama sky, equirectangular mapping"), + ("TUBE", "Tube", "For 360 degree panorama sky, cylindrical mapped, only top half"), + ("OBJECT", "Object", "Use linked object’s coordinates for texture coordinates"), + ), + default="VIEW", + ) + + use_map_blend: BoolProperty( + name="Blend Map", description="Affect the color progression of the background", default=True + ) + + use_map_horizon: BoolProperty( + name="Horizon Map", description="Affect the color of the horizon", default=False + ) + + use_map_zenith_down: BoolProperty( + name="", description="Affect the color of the zenith below", default=False + ) + + use_map_zenith_up: BoolProperty( + name="Zenith Up Map", description="Affect the color of the zenith above", default=False + ) + + zenith_down_factor: FloatProperty( + name="Zenith Down", + description="Amount texture affects color of the zenith below", + soft_min=0.0, + soft_max=1.0, + default=1.0, + ) + + zenith_up_factor: FloatProperty( + name="Zenith Up", + description="Amount texture affects color of the zenith above", + soft_min=0.0, + soft_max=1.0, + default=1.0, + ) + + +############################################################################### # Space properties from removed former Blender Internal ############################################################################### @@ -995,9 +1116,7 @@ class RenderPovSettingsTexture(PropertyGroup): tex_scale_z: FloatProperty(name="Scale Z", description="", min=0.0, max=10000.0, default=1.0) -classes = ( - MaterialTextureSlot, - RenderPovSettingsTexture) +classes = (MaterialTextureSlot, WorldTextureSlot, RenderPovSettingsTexture) def register(): @@ -1005,11 +1124,13 @@ def register(): register_class(cls) bpy.types.Material.pov_texture_slots = CollectionProperty(type=MaterialTextureSlot) + bpy.types.World.pov_texture_slots = CollectionProperty(type=WorldTextureSlot) bpy.types.Texture.pov = PointerProperty(type=RenderPovSettingsTexture) def unregister(): del bpy.types.Texture.pov + del bpy.types.World.pov_texture_slots del bpy.types.Material.pov_texture_slots for cls in reversed(classes): |