[Bf-extensions-cvs] [b4eb3312] master: Turnaround Camera: Cleanup, UI changes
lijenstina
noreply at git.blender.org
Wed Jun 28 11:38:08 CEST 2017
Commit: b4eb33129778efcafb946679b1d2d23932d5535f
Author: lijenstina
Date: Wed Jun 28 11:37:23 2017 +0200
Branches: master
https://developer.blender.org/rBAb4eb33129778efcafb946679b1d2d23932d5535f
Turnaround Camera: Cleanup, UI changes
Bumped version to 0.2.5
Imports as tuples
Consistent property definitions
Use a property group for the scene props
Access through context.scene.turn_camera
Reorder the UI layout
Added the option to clear the camera animations as the
previous run can leave the Dolly Zoom active
===================================================================
M camera_turnaround.py
===================================================================
diff --git a/camera_turnaround.py b/camera_turnaround.py
index 5b655681..afae29e5 100644
--- a/camera_turnaround.py
+++ b/camera_turnaround.py
@@ -1,58 +1,67 @@
-# ***** BEGIN GPL LICENSE BLOCK *****
+# ##### BEGIN GPL LICENSE BLOCK #####
#
+# This program is free software; you can redistribute it and/or
+# modify it under the terms of the GNU General Public License
+# as published by the Free Software Foundation; either version 2
+# of the License, or (at your option) any later version.
#
-# This program is free software; you can redistribute it and/or
-# modify it under the terms of the GNU General Public License
-# as published by the Free Software Foundation; either version 2
-# of the License, or (at your option) any later version.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
#
-# This program is distributed in the hope that it will be useful,
-# but WITHOUT ANY WARRANTY; without even the implied warranty of
-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-# GNU General Public License for more details.
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software Foundation,
+# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
-# You should have received a copy of the GNU General Public License
-# along with this program; if not, write to the Free Software Foundation,
-# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
-#
-# ***** END GPL LICENCE BLOCK *****
+# ##### END GPL LICENSE BLOCK #####
bl_info = {
"name": "Turnaround Camera",
"author": "Antonio Vazquez (antonioya)",
- "version": (0, 2, 4),
+ "version": (0, 2, 5),
"blender": (2, 68, 0),
- "location": "View3D > Toolshelf > Animation > Turnaround camera",
- "description": "Add a camera rotation around selected object.",
- "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/Scripts/Animation/TurnaroundCamera",
+ "location": "View3D > Toolshelf > Turnaround camera",
+ "description": "Add a camera rotation around selected object",
+ "wiki_url": "https://wiki.blender.org/index.php/Extensions:2.6/Py/"
+ "Scripts/Animation/TurnaroundCamera",
"category": "Camera"}
import bpy
-import math
+from math import pi
+from bpy.props import (
+ BoolProperty,
+ EnumProperty,
+ FloatProperty,
+ PointerProperty,
+ )
+from bpy.types import (
+ Operator,
+ Panel,
+ PropertyGroup,
+ )
+
+
# ------------------------------------------------------
# Action class
# ------------------------------------------------------
-
-
-class RunAction(bpy.types.Operator):
+class RunAction(Operator):
bl_idname = "object.rotate_around"
bl_label = "Turnaround"
bl_description = "Create camera rotation around selected object"
- # ------------------------------
- # Execute
- # ------------------------------
def execute(self, context):
# ----------------------
# Save old data
# ----------------------
scene = context.scene
+ turn_camera = scene.turn_camera
selectobject = context.active_object
camera = bpy.data.objects[bpy.context.scene.camera.name]
savedcursor = bpy.context.scene.cursor_location.copy() # cursor position
savedframe = scene.frame_current
- if scene.use_cursor is False:
+ if turn_camera.use_cursor is False:
bpy.ops.view3d.snap_cursor_to_selected()
# -------------------------
@@ -90,59 +99,65 @@ class RunAction(bpy.types.Operator):
myempty.empty_draw_size = 0.1
bpy.context.scene.frame_set(scene.frame_start)
myempty.keyframe_insert(data_path='rotation_euler', frame=scene.frame_start)
+
+ # Clear the Camera Animations if the option is checked
+ if turn_camera.reset_cam_anim:
+ try:
+ if bpy.data.cameras[camera.name].animation_data:
+ bpy.data.cameras[camera.name].animation_data_clear()
+ except Exception as e:
+ print("\n[Camera Turnaround]\nWarning: {}\n".format(e))
+
# Dolly zoom
- if scene.dolly_zoom != "0":
- bpy.data.cameras[camera.name].lens = scene.camera_from_lens
+ if turn_camera.dolly_zoom != "0":
+ bpy.data.cameras[camera.name].lens = turn_camera.camera_from_lens
bpy.data.cameras[camera.name].keyframe_insert('lens', frame=scene.frame_start)
# Calculate rotation XYZ
- if scene.inverse_x:
- ix = -1
- else:
- ix = 1
+ ix = -1 if turn_camera.inverse_x else 1
+ iy = -1 if turn_camera.inverse_y else 1
+ iz = -1 if turn_camera.inverse_z else 1
- if scene.inverse_y:
- iy = -1
- else:
- iy = 1
-
- if scene.inverse_z:
- iz = -1
- else:
- iz = 1
-
- xrot = (math.pi * 2) * scene.camera_revol_x * ix
- yrot = (math.pi * 2) * scene.camera_revol_y * iy
- zrot = (math.pi * 2) * scene.camera_revol_z * iz
+ xrot = (pi * 2) * turn_camera.camera_revol_x * ix
+ yrot = (pi * 2) * turn_camera.camera_revol_y * iy
+ zrot = (pi * 2) * turn_camera.camera_revol_z * iz
# create middle frame
- if scene.back_forw is True:
+ if turn_camera.back_forw is True:
myempty.rotation_euler = (xrot, yrot, zrot)
- myempty.keyframe_insert(data_path='rotation_euler', frame=((scene.frame_end - scene.frame_start) / 2))
+ myempty.keyframe_insert(
+ data_path='rotation_euler',
+ frame=((scene.frame_end - scene.frame_start) / 2)
+ )
# reverse
xrot *= -1
yrot *= -1
zrot = 0
# Dolly zoom
- if scene.dolly_zoom == "2":
- bpy.data.cameras[camera.name].lens = scene.camera_to_lens
- bpy.data.cameras[camera.name].keyframe_insert('lens', frame=((scene.frame_end - scene.frame_start) / 2))
+ if turn_camera.dolly_zoom == "2":
+ bpy.data.cameras[camera.name].lens = turn_camera.camera_to_lens
+ bpy.data.cameras[camera.name].keyframe_insert(
+ 'lens',
+ frame=((scene.frame_end - scene.frame_start) / 2)
+ )
# create last frame
myempty.rotation_euler = (xrot, yrot, zrot)
myempty.keyframe_insert(data_path='rotation_euler', frame=scene.frame_end)
# Dolly zoom
- if scene.dolly_zoom != "0":
- if scene.dolly_zoom == "1":
- bpy.data.cameras[camera.name].lens = scene.camera_to_lens # final
+ if turn_camera.dolly_zoom != "0":
+ if turn_camera.dolly_zoom == "1":
+ bpy.data.cameras[camera.name].lens = turn_camera.camera_to_lens # final
else:
- bpy.data.cameras[camera.name].lens = scene.camera_from_lens # back to init
+ bpy.data.cameras[camera.name].lens = turn_camera.camera_from_lens # back to init
- bpy.data.cameras[camera.name].keyframe_insert('lens', frame=scene.frame_end)
+ bpy.data.cameras[camera.name].keyframe_insert(
+ 'lens', frame=scene.frame_end
+ )
# Track constraint
- if scene.track is True:
+ if turn_camera.track is True:
bpy.context.scene.objects.active = camera
bpy.ops.object.constraint_add(type='TRACK_TO')
bpy.context.object.constraints[-1].track_axis = 'TRACK_NEGATIVE_Z'
@@ -162,61 +177,149 @@ class RunAction(bpy.types.Operator):
bpy.context.scene.frame_set(savedframe)
return {'FINISHED'}
+
+
# ------------------------------------------------------
-# UI Class
+# Define Properties
# ------------------------------------------------------
+class CameraTurnProps(PropertyGroup):
+
+ camera_revol_x = FloatProperty(
+ name='X', min=0, max=25,
+ default=0, precision=2,
+ description='Number total of revolutions in X axis'
+ )
+ camera_revol_y = FloatProperty(
+ name='Y', min=0, max=25,
+ default=0, precision=2,
+ description='Number total of revolutions in Y axis'
+ )
+ camera_revol_z = FloatProperty(
+ name='Z', min=0, max=25,
+ default=1, precision=2,
+ description='Number total of revolutions in Z axis'
+ )
+ inverse_x = BoolProperty(
+ name="-X",
+ description="Inverse rotation",
+ default=False
+ )
+ inverse_y = BoolProperty(
+ name="-Y",
+ description="Inverse rotation",
+ default=False
+ )
+ inverse_z = BoolProperty(
+ name="-Z",
+ description="Inverse rotation",
+ default=False
+ )
+ use_cursor = BoolProperty(
+ name="Use cursor position",
+ description="Use cursor position instead of object origin",
+ default=False
+ )
+ back_forw = BoolProperty(
+ name="Back and forward",
+ description="Create back and forward animation",
+ default=False
+ )
+ dolly_zoom = EnumProperty(
+ items=(
+ ('0', "None", ""),
+ ('1', "Dolly zoom", ""),
+ ('2', "Dolly zoom B/F", "")
+ ),
+ name="Lens Effects",
+ description="Create a camera lens movement"
+ )
+ camera_from_lens = FloatProperty(
+ name="From",
+ min=1, max=500, default=35,
+ precision=3,
+ description="Start lens value"
+
@@ Diff output truncated at 10240 characters. @@
More information about the Bf-extensions-cvs
mailing list