Browse Source

Add support for waveset buoys

pull/256/head
Darryl Pogue 3 years ago
parent
commit
08446cc3a3
No known key found for this signature in database
GPG Key ID: CB824715C3E6FD41
  1. 33
      korman/properties/modifiers/water.py
  2. 16
      korman/ui/modifiers/water.py

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

16
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")

Loading…
Cancel
Save