Update addons for changes to proportional edit mode
[blender-addons.git] / light_field_tools / __init__.py
blob17e32c8bb607933434c1af23135bed23020b8b9e
1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 bl_info = {
21 "name": "Light Field Tools",
22 "author": "Aurel Wildfellner",
23 "description": "Tools to create a light field camera and projector",
24 "version": (0, 3, 1),
25 "blender": (2, 64, 0),
26 "location": "View3D > Tool Shelf > Light Field Tools",
27 "url": "http://www.jku.at/cg/",
28 "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
29 "Scripts/Render/Light_Field_Tools",
30 "category": "Render"
34 if "bpy" in locals():
35 import importlib
36 importlib.reload(light_field_tools)
37 else:
38 from . import light_field_tools
41 import bpy
42 from bpy.types import (
43 AddonPreferences,
44 PropertyGroup,
46 from bpy.props import (
47 BoolProperty,
48 FloatProperty,
49 IntProperty,
50 StringProperty,
51 PointerProperty,
55 # global properties for the script, mainly for UI
56 class LightFieldPropertyGroup(PropertyGroup):
57 angle: FloatProperty(
58 name="Angle",
59 # 40 degrees
60 default=0.69813170079,
61 min=0,
62 # 172 degrees
63 max=3.001966313430247,
64 precision=2,
65 subtype='ANGLE',
66 description="Field of view of camera and angle of beam for spotlights"
68 row_length: IntProperty(
69 name="Row Length",
70 default=1,
71 min=1,
72 description="The number of cameras/lights in one row"
74 create_handler: BoolProperty(
75 name="Handler",
76 default=True,
77 description="Creates an empty object, to which the cameras and spotlights are parented to"
79 do_camera: BoolProperty(
80 name="Create Camera",
81 default=True,
82 description="A light field camera is created"
84 animate_camera: BoolProperty(
85 name="Animate Camera",
86 default=True,
87 description="Animates a single camera, so not multiple cameras get created"
89 do_projection: BoolProperty(
90 name="Create Projector",
91 default=False,
92 description="A light field projector is created"
94 texture_path: StringProperty(
95 name="Texture Path",
96 description="From this path textures for the spotlights will be loaded",
97 subtype='DIR_PATH'
99 light_intensity: FloatProperty(
100 name="Light Intensity",
101 default=2,
102 min=0,
103 precision=3,
104 description="Total intensity of all lamps"
106 # blending of the spotlights
107 spot_blend: FloatProperty(
108 name="Blend",
109 default=0,
110 min=0,
111 max=1,
112 precision=3,
113 description="Blending of the spotlights"
115 # spacing in pixels on the focal plane
116 spacing: IntProperty(
117 name="Spacing",
118 default=10,
119 min=0,
120 description="The spacing in pixels between two cameras on the focal plane"
124 # Add-ons Preferences Update Panel
126 # Define Panel classes for updating
127 panels = (
128 light_field_tools.VIEW3D_PT_lightfield_tools,
132 def update_panel(self, context):
133 message = "Light Field Tools: Updating Panel locations has failed"
134 try:
135 for panel in panels:
136 if "bl_rna" in panel.__dict__:
137 bpy.utils.unregister_class(panel)
139 for panel in panels:
140 panel.bl_category = context.preferences.addons[__name__].preferences.category
141 bpy.utils.register_class(panel)
143 except Exception as e:
144 print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
145 pass
148 class LFTPreferences(AddonPreferences):
149 # this must match the addon name, use '__package__'
150 # when defining this in a submodule of a python package.
151 bl_idname = __name__
153 category: StringProperty(
154 name="Tab Category",
155 description="Choose a name for the category of the panel",
156 default="Tools",
157 update=update_panel
160 def draw(self, context):
161 layout = self.layout
163 row = layout.row()
164 col = row.column()
165 col.label(text="Tab Category:")
166 col.prop(self, "category", text="")
169 def register():
170 # register properties
171 # bpy.utils.register_class(LightFieldPropertyGroup)
172 bpy.utils.register_module(__name__)
173 bpy.types.Scene.lightfield = PointerProperty(type=LightFieldPropertyGroup)
176 def unregister():
177 bpy.utils.unregister_module(__name__)
178 del bpy.types.Scene.lightfield
181 if __name__ == "__main__":
182 register()