diff --git a/korman/idprops.py b/korman/idprops.py index 40cc474..4d62310 100644 --- a/korman/idprops.py +++ b/korman/idprops.py @@ -127,6 +127,9 @@ def poll_camera_objects(self, value): def poll_drawable_objects(self, value): return value.type == "MESH" and any(value.data.materials) +def poll_dynamic_objects(self, value): + return value.plasma_modifiers.collision.enabled and value.plasma_modifiers.collision.dynamic + def poll_empty_objects(self, value): return value.type == "EMPTY" diff --git a/korman/properties/modifiers/water.py b/korman/properties/modifiers/water.py index 9b39587..7901bc3 100644 --- a/korman/properties/modifiers/water.py +++ b/korman/properties/modifiers/water.py @@ -475,3 +475,38 @@ class PlasmaWaveTexState(PlasmaWaveState, PlasmaModifierProperties): def export(self, exporter, bo, so): waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so) self.convert_wavestate(waveset.state.texState) + + +class PlasmaBuoyObject(bpy.types.PropertyGroup): + buoy_object = PointerProperty(name="Buoy Object", + description="Object that float on water", + options=set(), + type=bpy.types.Object, + poll=idprops.poll_dynamic_objects) + + +class PlasmaWaterBuoyModifier(PlasmaModifierProperties): + pl_depends = {"water_basic"} + pl_id = "water_buoy" + + bl_category = "Water" + bl_label = "Water Buoys" + bl_description = "" + + buoys = CollectionProperty(type=PlasmaBuoyObject) + active_buoy_index = IntProperty(options={"HIDDEN"}) + + def export(self, exporter, bo, so): + if exporter.mgr.getVer() != pvMoul: + exporter.report.warning("Not supported on this version of Plasma", indent=3) + return + else: + exporter.report.port("This will only function on MOUL", indent=3) + + waveset = exporter.mgr.find_create_object(plWaveSet7, name=bo.name, so=so) + waveset.setFlag(plWaveSet7.kHasBuoys, True) + + for i in self.buoys: + if i.buoy_object is None: + raise ExportError("'{}': Buoy Object for '{}' is invalid", self.key_name, i.buoy_object.name) + waveset.addBuoy(exporter.mgr.find_create_key(plSceneObject, bl=i.buoy_object)) diff --git a/korman/ui/modifiers/water.py b/korman/ui/modifiers/water.py index 08313b9..5ce74fd 100644 --- a/korman/ui/modifiers/water.py +++ b/korman/ui/modifiers/water.py @@ -135,3 +135,26 @@ def water_shore(modifier, layout, context): col.prop(modifier, "finger") col.prop(modifier, "edge_opacity") col.prop(modifier, "edge_radius") + + +class BuoyListUI(bpy.types.UIList): + def draw_item(self, context, layout, data, item, icon, active_data, active_property, index=0, flt_flag=0): + if item.buoy_object is None: + layout.label("[No Object Specified]", icon="ERROR") + else: + layout.label(item.buoy_object.name, icon="MOD_CAST") + + +def water_buoy(modifier, layout, context): + ui_list.draw_modifier_list(layout, "BuoyListUI", modifier, "buoys", + "active_buoy_index", name_prefix="Buoy", + name_prop="display_name", rows=2, maxrows=3) + + # Display the active buoy + try: + buoy_ref = modifier.buoys[modifier.active_buoy_index] + except: + pass + else: + layout.alert = buoy_ref.buoy_object is None + layout.prop(buoy_ref, "buoy_object")