[Bf-extensions-cvs] [65741d7] master: Light Field Tools: Update panel Rename, cleanup, fixes
lijenstina
noreply at git.blender.org
Fri May 5 23:50:01 CEST 2017
Commit: 65741d7430102d5f2745ce30997c9549567c7e25
Author: lijenstina
Date: Fri May 5 23:48:24 2017 +0200
Branches: master
https://developer.blender.org/rBA65741d7430102d5f2745ce30997c9549567c7e25
Light Field Tools: Update panel Rename, cleanup, fixes
Bumped version to 0.3.1
As a part of the task T50726:
Update the Panel rename code to more generic one
Pep8 cleanup
Replace star imports
Consistent property definitions
Add the missing property deletion on unregister
Fix crashes with missing brackets around CANCELLED
Add an name to the generated Empty handler
Update wiki link
===================================================================
M light_field_tools/__init__.py
M light_field_tools/light_field_tools.py
===================================================================
diff --git a/light_field_tools/__init__.py b/light_field_tools/__init__.py
index a552318..66c7d61 100644
--- a/light_field_tools/__init__.py
+++ b/light_field_tools/__init__.py
@@ -21,11 +21,11 @@ bl_info = {
"name": "Light Field Tools",
"author": "Aurel Wildfellner",
"description": "Tools to create a light field camera and projector",
- "version": (0, 3, 0),
+ "version": (0, 3, 1),
"blender": (2, 64, 0),
"location": "View3D > Tool Shelf > Light Field Tools",
"url": "http://www.jku.at/cg/",
- "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
"Scripts/Render/Light_Field_Tools",
"category": "Render"
}
@@ -39,11 +39,21 @@ else:
import bpy
-from bpy.props import *
+from bpy.types import (
+ AddonPreferences,
+ PropertyGroup,
+ )
+from bpy.props import (
+ BoolProperty,
+ FloatProperty,
+ IntProperty,
+ StringProperty,
+ PointerProperty,
+ )
# global properties for the script, mainly for UI
-class LightFieldPropertyGroup(bpy.types.PropertyGroup):
+class LightFieldPropertyGroup(PropertyGroup):
angle = FloatProperty(
name="Angle",
# 40 degrees
@@ -52,91 +62,120 @@ class LightFieldPropertyGroup(bpy.types.PropertyGroup):
# 172 degrees
max=3.001966313430247,
precision=2,
- subtype = 'ANGLE',
- description="Field of view of camera and angle of beam for spotlights")
+ subtype='ANGLE',
+ description="Field of view of camera and angle of beam for spotlights"
+ )
row_length = IntProperty(
name="Row Length",
default=1,
min=1,
- description="The number of cameras/lights in one row")
+ description="The number of cameras/lights in one row"
+ )
create_handler = BoolProperty(
name="Handler",
default=True,
- description="Creates an empty object, to which the cameras and spotlights are parented to")
+ description="Creates an empty object, to which the cameras and spotlights are parented to"
+ )
do_camera = BoolProperty(
name="Create Camera",
default=True,
- description="A light field camera is created")
+ description="A light field camera is created"
+ )
animate_camera = BoolProperty(
name="Animate Camera",
default=True,
- description="Animates a single camera, so not multiple cameras get created")
+ description="Animates a single camera, so not multiple cameras get created"
+ )
do_projection = BoolProperty(
name="Create Projector",
default=False,
- description="A light field projector is created")
+ description="A light field projector is created"
+ )
texture_path = StringProperty(
name="Texture Path",
description="From this path textures for the spotlights will be loaded",
- subtype='DIR_PATH')
+ subtype='DIR_PATH'
+ )
light_intensity = FloatProperty(
name="Light Intensity",
default=2,
min=0,
precision=3,
- description="Total intensity of all lamps")
+ description="Total intensity of all lamps"
+ )
# blending of the spotlights
- spot_blend = FloatProperty(
+ spot_blend = FloatProperty(
name="Blend",
default=0,
min=0,
max=1,
precision=3,
- description="Blending of the spotlights")
+ description="Blending of the spotlights"
+ )
# spacing in pixels on the focal plane
spacing = IntProperty(
name="Spacing",
default=10,
min=0,
- description="The spacing in pixels between two cameras on the focal plane")
+ description="The spacing in pixels between two cameras on the focal plane"
+ )
+
+
+# Add-ons Preferences Update Panel
+
+# Define Panel classes for updating
+panels = (
+ light_field_tools.VIEW3D_OT_lightfield_tools,
+ )
+
-## Addons Preferences Update Panel
def update_panel(self, context):
+ message = "Light Field Tools: Updating Panel locations has failed"
try:
- bpy.utils.unregister_class(light_field_tools.VIEW3D_OT_lightfield_tools)
- except:
+ for panel in panels:
+ if "bl_rna" in panel.__dict__:
+ bpy.utils.unregister_class(panel)
+
+ for panel in panels:
+ panel.bl_category = context.user_preferences.addons[__name__].preferences.category
+ bpy.utils.register_class(panel)
+
+ except Exception as e:
+ print("\n[{}]\n{}\n\nError:\n{}".format(__name__, message, e))
pass
- light_field_tools.VIEW3D_OT_lightfield_tools.bl_category = context.user_preferences.addons[__name__].preferences.category
- bpy.utils.register_class(light_field_tools.VIEW3D_OT_lightfield_tools)
-class LFTPreferences(bpy.types.AddonPreferences):
+
+class LFTPreferences(AddonPreferences):
# this must match the addon name, use '__package__'
# when defining this in a submodule of a python package.
bl_idname = __name__
- category = bpy.props.StringProperty(
+ category = StringProperty(
name="Tab Category",
description="Choose a name for the category of the panel",
default="Tools",
- update=update_panel)
+ update=update_panel
+ )
def draw(self, context):
-
layout = self.layout
+
row = layout.row()
col = row.column()
col.label(text="Tab Category:")
col.prop(self, "category", text="")
+
def register():
# register properties
- bpy.utils.register_class(LightFieldPropertyGroup)
- bpy.types.Scene.lightfield = bpy.props.PointerProperty(type=LightFieldPropertyGroup)
+ # bpy.utils.register_class(LightFieldPropertyGroup)
bpy.utils.register_module(__name__)
+ bpy.types.Scene.lightfield = PointerProperty(type=LightFieldPropertyGroup)
def unregister():
bpy.utils.unregister_module(__name__)
+ del bpy.types.Scene.lightfield
if __name__ == "__main__":
diff --git a/light_field_tools/light_field_tools.py b/light_field_tools/light_field_tools.py
index fcc967b..f32f0a9 100644
--- a/light_field_tools/light_field_tools.py
+++ b/light_field_tools/light_field_tools.py
@@ -17,12 +17,16 @@
# ##### END GPL LICENSE BLOCK #####
import bpy
-from bpy.props import *
-
+from bpy.types import (
+ Operator,
+ Panel,
+ )
import os
-import math
-
-import mathutils
+from math import (
+ degrees, tan,
+ radians,
+ )
+from mathutils import Vector
__bpydoc__ = """
Light Field Tools
@@ -82,17 +86,17 @@ TODO:
* Restore view after primary camera is changed.
* Apply object matrix to normals.
* Allign to normals, somehow,....
-* StringPropertie with PATH tag, for proper ui.
+* StringProperties with PATH tag, for proper ui.
"""
-class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
- """Create a lightfield rig based on the active object/mesh"""
- bl_idname="object.create_lightfield_rig"
- bl_label="Create a light field rig based on the active object/mesh"
+class OBJECT_OT_create_lightfield_rig(Operator):
+ bl_idname = "object.create_lightfield_rig"
+ bl_label = "Create a light field rig"
+ bl_description = "Create a lightfield rig based on the active object/mesh"
bl_options = {'REGISTER'}
- layer0 = [True] + [False]*19
+ layer0 = [True] + [False] * 19
numSamples = 0
baseObject = None
@@ -100,10 +104,9 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
verts = []
imagePaths = []
-
def arrangeVerts(self):
"""Sorts the vertices as described in the usage part of the doc."""
- #FIXME get mesh with applied modifer stack
+ # FIXME get mesh with applied modifer stack
scene = bpy.context.scene
mesh = self.baseObject.data
verts = []
@@ -118,18 +121,19 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
def key_x(v):
return v[0][0]
+
def key_y(v):
return v[0][1]
+
verts.sort(key=key_y)
sorted_verts = []
for i in range(0, len(verts), row_length):
- row = verts[i:i+row_length]
+ row = verts[i: i + row_length]
row.sort(key=key_x)
sorted_verts.extend(row)
return sorted_verts
-
def createCameraAnimated(self):
scene = bpy.context.scene
@@ -150,7 +154,7 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
# set as primary camera
scene.camera = cam
- ### animate ###
+ # animate
scene.frame_current = 0
for frame, vert in enumerate(self.verts):
@@ -165,8 +169,7 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
# set anim render props
scene.frame_current = 0
scene.frame_start = 0
- scene.frame_end = self.numSamples-1
-
+ scene.frame_end = self.numSamples - 1
def createCameraMultiple(self):
scene = bpy.context.scene
@@ -193,14 +196,12 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
if scene.lightfield.create_handler:
cam.parent = self.handler
-
def createCamera(self):
if bpy.context.scene.lightfield.animate_camera:
self.createCameraAnimated()
else:
self.createCameraMultiple()
-
def getImagePaths(self):
path = bpy.context.scene.lightfield.texture_path
if not os.path.isdir(path):
@@ -209,16 +210,15 @@ class OBJECT_OT_create_lightfield_rig(bpy.types.Operator):
if not len(files) == self.numSamples:
return False
files.sort()
- self.image
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list