Browse Source

Put FollowMod in the correct order

pull/24/head
Adam Johnson 9 years ago
parent
commit
3c28951b6e
  1. 110
      korman/properties/modifiers/render.py
  2. 12
      korman/ui/modifiers/render.py

110
korman/properties/modifiers/render.py

@ -22,6 +22,61 @@ from .base import PlasmaModifierProperties
from ...exporter import utils from ...exporter import utils
from ...exporter.explosions import ExportError from ...exporter.explosions import ExportError
class PlasmaFollowMod(PlasmaModifierProperties):
pl_id = "followmod"
bl_category = "Render"
bl_label = "Follow"
bl_description = "Follow the movement of the camera, player, or another object"
follow_mode = EnumProperty(name="Mode",
description="Leader's movement to follow",
items=[
("kPositionX", "X Axis", "Follow the leader's X movements"),
("kPositionY", "Y Axis", "Follow the leader's Y movements"),
("kPositionZ", "Z Axis", "Follow the leader's Z movements"),
("kRotate", "Rotation", "Follow the leader's rotation movements"),
],
default={"kPositionX", "kPositionY", "kPositionZ"},
options={"ENUM_FLAG"})
leader_type = EnumProperty(name="Leader Type",
description="Leader to follow",
items=[
("kFollowCamera", "Camera", "Follow the camera"),
("kFollowListener", "Listener", "Follow listeners"),
("kFollowPlayer", "Player", "Follow the local player"),
("kFollowObject", "Object", "Follow an object"),
])
leader_object = StringProperty(name="Leader Object",
description="Object to follow")
def export(self, exporter, bo, so):
fm = exporter.mgr.find_create_object(plFollowMod, so=so, name=self.key_name)
fm.mode = 0
for flag in (getattr(plFollowMod, mode) for mode in self.follow_mode):
fm.mode |= flag
fm.leaderType = getattr(plFollowMod, self.leader_type)
if self.leader_type == "kFollowObject":
# If this object is following another object, make sure that the
# leader has been selected and is a valid SO.
if self.leader_object:
leader_obj = bpy.data.objects.get(self.leader_object, None)
if leader_obj is None:
raise ExportError("'{}': Follow's leader object is invalid".format(self.key_name))
else:
fm.leader = exporter.mgr.find_create_key(plSceneObject, bl=leader_obj)
else:
raise ExportError("'{}': Follow's leader object must be selected".format(self.key_name))
@property
def requires_actor(self):
return True
class PlasmaLightMapGen(PlasmaModifierProperties): class PlasmaLightMapGen(PlasmaModifierProperties):
pl_id = "lightmap" pl_id = "lightmap"
@ -251,58 +306,3 @@ class PlasmaVisibilitySet(PlasmaModifierProperties):
if rgn_bo is None: if rgn_bo is None:
raise ExportError("{}: Invalid VisControl '{}' in VisSet modifier".format(bo.name, region.region_name)) raise ExportError("{}: Invalid VisControl '{}' in VisSet modifier".format(bo.name, region.region_name))
addRegion(exporter.mgr.find_create_key(plVisRegion, bl=rgn_bo)) addRegion(exporter.mgr.find_create_key(plVisRegion, bl=rgn_bo))
class PlasmaFollowMod(PlasmaModifierProperties):
pl_id = "followmod"
bl_category = "Render"
bl_label = "Follow"
bl_description = "Follow the movement of the camera, player, or another object"
follow_mode = EnumProperty(name="Mode",
description="Leader's movement to follow",
items=[
("kPositionX", "X Axis", "Follow the leader's X movements"),
("kPositionY", "Y Axis", "Follow the leader's Y movements"),
("kPositionZ", "Z Axis", "Follow the leader's Z movements"),
("kRotate", "Rotation", "Follow the leader's rotation movements"),
],
default={"kPositionX", "kPositionY", "kPositionZ"},
options={"ENUM_FLAG"})
leader_type = EnumProperty(name="Leader Type",
description="Leader to follow",
items=[
("kFollowCamera", "Camera", "Follow the camera"),
("kFollowListener", "Listener", "Follow listeners"),
("kFollowPlayer", "Player", "Follow the local player"),
("kFollowObject", "Object", "Follow an object"),
])
leader_object = StringProperty(name="Leader Object",
description="Object to follow")
def export(self, exporter, bo, so):
fm = exporter.mgr.find_create_object(plFollowMod, so=so, name=self.key_name)
fm.mode = 0
for flag in (getattr(plFollowMod, mode) for mode in self.follow_mode):
fm.mode |= flag
fm.leaderType = getattr(plFollowMod, self.leader_type)
if self.leader_type == "kFollowObject":
# If this object is following another object, make sure that the
# leader has been selected and is a valid SO.
if self.leader_object:
leader_obj = bpy.data.objects.get(self.leader_object, None)
if leader_obj is None:
raise ExportError("'{}': Follow's leader object is invalid".format(self.key_name))
else:
fm.leader = exporter.mgr.find_create_key(plSceneObject, bl=leader_obj)
else:
raise ExportError("'{}': Follow's leader object must be selected".format(self.key_name))
@property
def requires_actor(self):
return True

12
korman/ui/modifiers/render.py

@ -15,6 +15,12 @@
import bpy import bpy
def followmod(modifier, layout, context):
layout.row().prop(modifier, "follow_mode", expand=True)
layout.prop(modifier, "leader_type")
if modifier.leader_type == "kFollowObject":
layout.prop_search(modifier, "leader_object", bpy.data, "objects", icon="OUTLINER_OB_MESH")
def lightmap(modifier, layout, context): def lightmap(modifier, layout, context):
layout.row(align=True).prop(modifier, "quality", expand=True) layout.row(align=True).prop(modifier, "quality", expand=True)
layout.prop_search(modifier, "light_group", bpy.data, "groups", icon="GROUP") layout.prop_search(modifier, "light_group", bpy.data, "groups", icon="GROUP")
@ -90,9 +96,3 @@ def visregion(modifier, layout, context):
# Other settings # Other settings
layout.prop(modifier, "replace_normal") layout.prop(modifier, "replace_normal")
def followmod(modifier, layout, context):
layout.row().prop(modifier, "follow_mode", expand=True)
layout.prop(modifier, "leader_type")
if modifier.leader_type == "kFollowObject":
layout.prop_search(modifier, "leader_object", bpy.data, "objects", icon="OUTLINER_OB_MESH")

Loading…
Cancel
Save