diff --git a/korman/properties/modifiers/water.py b/korman/properties/modifiers/water.py index 806883b..4e2bc4f 100644 --- a/korman/properties/modifiers/water.py +++ b/korman/properties/modifiers/water.py @@ -471,3 +471,36 @@ 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(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): + display_name = StringProperty(name="Display Name") + buoy_object = PointerProperty(name="Buoy Object", + description="Object that float on water", + type=bpy.types.Object, + poll=idprops.poll_mesh_objects) + + @classmethod + def _idprop_mapping(cls): + return {"buoy_object": "object_name"} + + +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): + 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".format(self.key_name, i.display_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..203e8bb 100644 --- a/korman/ui/modifiers/water.py +++ b/korman/ui/modifiers/water.py @@ -135,3 +135,19 @@ 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): + layout.prop(item, "display_name", emboss=False, text="", 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 + if modifier.buoys: + buoy = modifier.buoys[modifier.active_buoy_index] + layout.prop(buoy, "buoy_object", icon="MESH_DATA")