Browse Source

Implement the Filter Transform modifier

This causes an object to be given a plFilterCoordInterface instead of a
plCoordinateInterface. The difference is that plFilterCoordInterface
will reject changes to certain components of an object's transform. This
is useful in certain parenting situations, namely subworlds.
pull/85/head
Adam Johnson 7 years ago
parent
commit
ed5b6d7022
Signed by: Hoikas
GPG Key ID: 0B6515D6FF6F271E
  1. 3
      korman/exporter/convert.py
  2. 43
      korman/properties/modifiers/anim.py
  3. 7
      korman/properties/prop_object.py
  4. 12
      korman/ui/modifiers/anim.py

3
korman/exporter/convert.py

@ -191,7 +191,8 @@ class Exporter:
if so is None:
so = self.mgr.find_create_object(plSceneObject, bl=bl)
if so.coord is None:
ci = self.mgr.add_object(plCoordinateInterface, bl=bl, so=so)
ci_cls = bl.plasma_object.ci_type
ci = self.mgr.add_object(ci_cls, bl=bl, so=so)
# Now we have the "fun" work of filling in the CI
ci.localToWorld = utils.matrix44(bl.matrix_basis)

43
korman/properties/modifiers/anim.py

@ -104,6 +104,49 @@ class AnimGroupObject(idprops.IDPropObjectMixin, bpy.types.PropertyGroup):
return {"child_anim": "object_name"}
class PlasmaAnimationFilterModifier(PlasmaModifierProperties):
pl_id = "animation_filter"
bl_category = "Animation"
bl_label = "Filter Transform"
bl_description = "Filter animation components"
bl_icon = "UNLINKED"
no_rotation = BoolProperty(name="Filter Rotation",
description="Filter rotations",
options=set())
no_transX = BoolProperty(name="Filter X Translation",
description="Filter the X component of translations",
options=set())
no_transY = BoolProperty(name="Filter Y Translation",
description="Filter the Y component of translations",
options=set())
no_transZ = BoolProperty(name="Filter Z Translation",
description="Filter the Z component of translations",
options=set())
def export(self, exporter, bo, so):
# By this point, the object should already have a plFilterCoordInterface
# created by the converter. Let's test that assumption.
coord = so.coord.object
assert isinstance(coord, plFilterCoordInterface)
# Apply filtercoordinterface properties
if self.no_rotation:
coord.filterMask |= plFilterCoordInterface.kNoRotation
if self.no_transX:
coord.filterMask |= plFilterCoordInterface.kNoTransX
if self.no_transY:
coord.filterMask |= plFilterCoordInterface.kNoTransY
if self.no_transZ:
coord.filterMask |= plFilterCoordInterface.kNoTransZ
@property
def requires_actor(self):
return True
class PlasmaAnimationGroupModifier(ActionModifier, PlasmaModifierProperties):
pl_id = "animation_group"
pl_depends = {"animation"}

7
korman/properties/prop_object.py

@ -52,6 +52,13 @@ class PlasmaObject(bpy.types.PropertyGroup):
default=False,
options={"HIDDEN"})
@property
def ci_type(self):
if self.id_data.plasma_modifiers.animation_filter.enabled:
return plFilterCoordInterface
else:
return plCoordinateInterface
@property
def has_animation_data(self):
bo = self.id_data

12
korman/ui/modifiers/anim.py

@ -42,6 +42,18 @@ def animation(modifier, layout, context):
col.prop_search(modifier, "loop_start", action, "pose_markers", icon="PMARKER")
col.prop_search(modifier, "loop_end", action, "pose_markers", icon="PMARKER")
def animation_filter(modifier, layout, context):
split = layout.split()
col = split.column()
col.label("Translation:")
col.prop(modifier, "no_transX", text="Filter X")
col.prop(modifier, "no_transY", text="Filter Y")
col.prop(modifier, "no_transZ", text="Filter Z")
col = split.column()
col.label("Rotation:")
col.prop(modifier, "no_rotation", text="Filter Rotation")
class GroupListUI(bpy.types.UIList):
def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0):

Loading…
Cancel
Save