From 0f26deb65ec90d30f408fe36ca508863fa80d010 Mon Sep 17 00:00:00 2001 From: Adam Johnson Date: Sun, 12 Aug 2018 18:49:30 -0400 Subject: [PATCH] Camera transition overrides --- korman/exporter/camera.py | 26 ++++++++++++++++++--- korman/exporter/convert.py | 2 +- korman/properties/prop_camera.py | 25 +++++++++++++++++++- korman/ui/ui_camera.py | 39 ++++++++++++++++++++++++++++++-- 4 files changed, 85 insertions(+), 7 deletions(-) diff --git a/korman/exporter/camera.py b/korman/exporter/camera.py index 420ed79..4b1d907 100644 --- a/korman/exporter/camera.py +++ b/korman/exporter/camera.py @@ -68,12 +68,12 @@ class CameraConverter: if camera_props.fast_run: brain.setFlags(plCameraBrain1.kSpeedUpWhenRunning, True) - def export_camera(self, so, bo, camera_type, camera_props): + def export_camera(self, so, bo, camera_type, camera_props, camera_trans=[]): brain = getattr(self, "_export_{}_camera".format(camera_type))(so, bo, camera_props) - mod = self._export_camera_modifier(so, bo, camera_props) + mod = self._export_camera_modifier(so, bo, camera_props, camera_trans) mod.brain = brain.key - def _export_camera_modifier(self, so, bo, props): + def _export_camera_modifier(self, so, bo, props, trans): mod = self._mgr.find_create_object(plCameraModifier, so=so) # PlasmaMAX allows the user to specify the horizontal OR vertical FOV, but not both. @@ -88,6 +88,26 @@ class CameraConverter: mod.startAnimOnPush = props.start_on_push mod.stopAnimOnPop = props.stop_on_pop mod.resetAnimOnPop = props.reset_on_pop + + for manual_trans in trans: + if not manual_trans.enabled or manual_trans.mode == "auto": + continue + cam_trans = plCameraModifier.CamTrans() + if manual_trans.camera: + cam_trans.transTo = self._mgr.find_create_key(plCameraModifier, bl=manual_trans.camera) + cam_trans.ignore = manual_trans.mode == "ignore" + + trans_info = manual_trans.transition + cam_trans.cutPos = trans_info.pos_cut + cam_trans.cutPOA = trans_info.poa_cut + cam_trans.accel = trans_info.pos_acceleration + cam_trans.decel = trans_info.pos_deceleration + cam_trans.velocity = trans_info.pos_velocity + cam_trans.poaAccel = trans_info.poa_acceleration + cam_trans.poaDecel = trans_info.poa_deceleration + cam_trans.poaVelocity = trans_info.poa_velocity + mod.addTrans(cam_trans) + return mod def _export_circle_camera(self, so, bo, props): diff --git a/korman/exporter/convert.py b/korman/exporter/convert.py index cc526bc..8fcf6d0 100644 --- a/korman/exporter/convert.py +++ b/korman/exporter/convert.py @@ -241,7 +241,7 @@ class Exporter: # Hey, guess what? Blender's camera data is utter crap! # NOTE: Animation export is dependent on camera type, so we'll do that later. camera = bo.data.plasma_camera - self.camera.export_camera(so, bo, camera.camera_type, camera.settings) + self.camera.export_camera(so, bo, camera.camera_type, camera.settings, camera.transitions) def _export_empty_blobj(self, so, bo): self.animation.convert_object_animations(bo, so) diff --git a/korman/properties/prop_camera.py b/korman/properties/prop_camera.py index 93d814a..7420e95 100644 --- a/korman/properties/prop_camera.py +++ b/korman/properties/prop_camera.py @@ -17,6 +17,8 @@ import bpy from bpy.props import * import math +from .. import idprops + camera_types = [("circle", "Circle Camera", "The camera circles a fixed point"), ("follow", "Follow Camera", "The camera follows an object"), ("fixed", "Fixed Camera", "The camera is fixed in one location"), @@ -56,6 +58,26 @@ class PlasmaTransition(bpy.types.PropertyGroup): options=set()) +class PlasmaManualTransition(bpy.types.PropertyGroup): + camera = PointerProperty(name="Camera", + description="Camera to transition to", + type=bpy.types.Object, + poll=idprops.poll_camera_objects, + options=set()) + transition = PointerProperty(type=PlasmaTransition, options=set()) + mode = EnumProperty(name="Transition Mode", + description="Type of transition that should occur between the two cameras", + items=[("ignore", "Ignore Camera", "Ignore this camera and do not transition"), + ("auto", "Auto", "Auto transition as defined by the two cameras' properies"), + ("manual", "Manual", "Manually defined transition")], + default="auto", + options=set()) + enabled = BoolProperty(name="Enabled", + description="Export this transition", + default=True, + options=set()) + + class PlasmaCameraProperties(bpy.types.PropertyGroup): # Point of Attention poa_type = EnumProperty(name="Point of Attention", @@ -217,7 +239,8 @@ class PlasmaCamera(bpy.types.PropertyGroup): items=camera_types, options=set()) settings = PointerProperty(type=PlasmaCameraProperties, options=set()) - transitions = CollectionProperty(type=PlasmaTransition, + transitions = CollectionProperty(type=PlasmaManualTransition, name="Transitions", description="", options=set()) + active_transition_index = IntProperty(options={"HIDDEN"}) diff --git a/korman/ui/ui_camera.py b/korman/ui/ui_camera.py index 56179c9..15d8fc9 100644 --- a/korman/ui/ui_camera.py +++ b/korman/ui/ui_camera.py @@ -14,7 +14,9 @@ # along with Korman. If not, see . import bpy + from .. import helpers +from . import ui_list def _draw_alert_prop(layout, props, the_prop, cam_type, alert_cam="", min=None, max=None, **kwargs): can_alert = not alert_cam or alert_cam == cam_type @@ -220,7 +222,7 @@ class PlasmaCameraViewPanel(CameraButtonsPanel, bpy.types.Panel): class TransitionListUI(bpy.types.UIList): def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0): if item.camera is None: - layout.label("[Default Transition]") + layout.label("[Default Camera]") else: layout.label(item.camera.name, icon="CAMERA_DATA") layout.prop(item, "enabled", text="") @@ -230,4 +232,37 @@ class PlasmaCameraTransitionPanel(CameraButtonsPanel, bpy.types.Panel): bl_label = "Transitions" def draw(self, context): - pass + layout = self.layout + camera = context.camera.plasma_camera + + ui_list.draw_list(layout, "TransitionListUI", "camera", camera, "transitions", + "active_transition_index", rows=3, maxrows=4) + + try: + item = camera.transitions[camera.active_transition_index] + trans = item.transition + except: + pass + else: + layout.separator() + box = layout.box() + box.prop(item, "camera") + box.prop(item, "mode") + + box.separator() + split = box.split() + split.active = item.mode == "manual" + + col = split.column() + col.label("Tracking Transition:") + col.prop(trans, "poa_acceleration", text="Acceleration") + col.prop(trans, "poa_deceleration", text="Deceleration") + col.prop(trans, "poa_velocity", text="Maximum Velocity") + col.prop(trans, "poa_cut") + + col = split.column() + col.label("Position Transition:") + col.prop(trans, "pos_acceleration", text="Acceleration") + col.prop(trans, "pos_deceleration", text="Deceleration") + col.prop(trans, "pos_velocity", text="Maximum Velocity") + col.prop(trans, "pos_cut")