Browse Source

Camera transition overrides

pull/105/head
Adam Johnson 6 years ago
parent
commit
0f26deb65e
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 26
      korman/exporter/camera.py
  2. 2
      korman/exporter/convert.py
  3. 25
      korman/properties/prop_camera.py
  4. 39
      korman/ui/ui_camera.py

26
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):

2
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)

25
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"})

39
korman/ui/ui_camera.py

@ -14,7 +14,9 @@
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
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")

Loading…
Cancel
Save