mirror of
https://github.com/H-uru/korman.git
synced 2025-07-15 10:54:18 +00:00
CI and other modifier improvements
These were picked over from the larger basic physics commit. I don't want to hold up better modifier stuff while waiting on more physics code.
This commit is contained in:
@ -95,16 +95,13 @@ class Exporter:
|
|||||||
|
|
||||||
def _export_actor(self, so, bo):
|
def _export_actor(self, so, bo):
|
||||||
"""Exports a Coordinate Interface if we need one"""
|
"""Exports a Coordinate Interface if we need one"""
|
||||||
empty = bo.type in {"CAMERA", "EMPTY", "LAMP"}
|
if self.mgr.has_coordiface(bo):
|
||||||
childobj = bo.parent is not None
|
|
||||||
|
|
||||||
if empty or childobj:
|
|
||||||
self._export_coordinate_interface(so, bo)
|
self._export_coordinate_interface(so, bo)
|
||||||
|
|
||||||
# If this object has a parent, then we will need to go upstream and add ourselves to the
|
# If this object has a parent, then we will need to go upstream and add ourselves to the
|
||||||
# parent's CoordinateInterface... Because life just has to be backwards.
|
# parent's CoordinateInterface... Because life just has to be backwards.
|
||||||
if childobj:
|
parent = bo.parent
|
||||||
parent = bo.parent
|
if parent is not None:
|
||||||
if parent.plasma_object.enabled:
|
if parent.plasma_object.enabled:
|
||||||
print(" Attaching to parent SceneObject '{}'".format(parent.name))
|
print(" Attaching to parent SceneObject '{}'".format(parent.name))
|
||||||
|
|
||||||
@ -120,6 +117,8 @@ class Exporter:
|
|||||||
def _export_coordinate_interface(self, so, bo):
|
def _export_coordinate_interface(self, so, bo):
|
||||||
"""Ensures that the SceneObject has a CoordinateInterface"""
|
"""Ensures that the SceneObject has a CoordinateInterface"""
|
||||||
if not so.coord:
|
if not so.coord:
|
||||||
|
print(" Exporting CoordinateInterface")
|
||||||
|
|
||||||
ci = self.mgr.find_create_key(bo, plCoordinateInterface)
|
ci = self.mgr.find_create_key(bo, plCoordinateInterface)
|
||||||
so.coord = ci
|
so.coord = ci
|
||||||
ci = ci.object
|
ci = ci.object
|
||||||
|
@ -151,12 +151,16 @@ class ExportManager:
|
|||||||
return key
|
return key
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def get_location(self, bl_obj):
|
def get_location(self, bl):
|
||||||
"""Returns the Page Location of a given Blender Object"""
|
"""Returns the Page Location of a given Blender Object"""
|
||||||
return self._pages[bl_obj.plasma_object.page]
|
return self._pages[bl.plasma_object.page]
|
||||||
|
|
||||||
def get_scene_node(self, location):
|
def get_scene_node(self, location=None, bl=None):
|
||||||
"""Gets a Plasma Page's plSceneNode key"""
|
"""Gets a Plasma Page's plSceneNode key"""
|
||||||
|
assert (location is not None) ^ (bl is not None)
|
||||||
|
|
||||||
|
if location is None:
|
||||||
|
location = self._pages[bl.plasma_object.page]
|
||||||
return self._nodes[location].key
|
return self._nodes[location].key
|
||||||
|
|
||||||
def get_textures_page(self, layer):
|
def get_textures_page(self, layer):
|
||||||
@ -167,6 +171,18 @@ class ExportManager:
|
|||||||
else:
|
else:
|
||||||
return layer.key.location
|
return layer.key.location
|
||||||
|
|
||||||
|
def has_coordiface(self, bo):
|
||||||
|
if bo.type in {"CAMERA", "EMPTY", "LAMP"}:
|
||||||
|
return True
|
||||||
|
if bo.parent is not None:
|
||||||
|
return True
|
||||||
|
|
||||||
|
for mod in bo.plasma_modifiers.modifiers:
|
||||||
|
if mod.enabled:
|
||||||
|
if mod.requires_actor:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def sanity_check_object_pages(self, age, objects):
|
def sanity_check_object_pages(self, age, objects):
|
||||||
"""Ensure all objects are in valid pages and create the Default page if used"""
|
"""Ensure all objects are in valid pages and create the Default page if used"""
|
||||||
|
|
||||||
|
@ -111,7 +111,7 @@ class MeshConverter:
|
|||||||
# TODO: RunTime lights (requires libHSPlasma feature)
|
# TODO: RunTime lights (requires libHSPlasma feature)
|
||||||
|
|
||||||
# If this object has a CI, we don't need xforms here...
|
# If this object has a CI, we don't need xforms here...
|
||||||
if self._mgr.find_key(bo, plCoordinateInterface) is not None:
|
if self._mgr.has_coordiface(bo):
|
||||||
geospan.localToWorld = hsMatrix44()
|
geospan.localToWorld = hsMatrix44()
|
||||||
geospan.worldToLocal = hsMatrix44()
|
geospan.worldToLocal = hsMatrix44()
|
||||||
else:
|
else:
|
||||||
@ -270,7 +270,7 @@ class MeshConverter:
|
|||||||
if crit not in self._dspans[location]:
|
if crit not in self._dspans[location]:
|
||||||
# AgeName_[District_]_Page_RenderLevel_Crit[Blend]Spans
|
# AgeName_[District_]_Page_RenderLevel_Crit[Blend]Spans
|
||||||
# Just because it's nice to be consistent
|
# Just because it's nice to be consistent
|
||||||
node = self._mgr.get_scene_node(location)
|
node = self._mgr.get_scene_node(location=location)
|
||||||
name = "{}_{:08X}_{:X}{}".format(node.name, crit.render_level.level, crit.criteria, crit.span_type)
|
name = "{}_{:08X}_{:X}{}".format(node.name, crit.render_level.level, crit.criteria, crit.span_type)
|
||||||
dspan = self._mgr.add_object(pl=plDrawableSpans, name=name, loc=location)
|
dspan = self._mgr.add_object(pl=plDrawableSpans, name=name, loc=location)
|
||||||
|
|
||||||
|
@ -22,7 +22,7 @@ def _fetch_modifiers():
|
|||||||
items = []
|
items = []
|
||||||
|
|
||||||
mapping = modifiers.modifier_mapping()
|
mapping = modifiers.modifier_mapping()
|
||||||
for i in mapping.keys():
|
for i in sorted(mapping.keys()):
|
||||||
items.append(("", i, ""))
|
items.append(("", i, ""))
|
||||||
items.extend(mapping[i])
|
items.extend(mapping[i])
|
||||||
#yield ("", i, "")
|
#yield ("", i, "")
|
||||||
|
@ -28,6 +28,11 @@ class PlasmaModifierProperties(bpy.types.PropertyGroup):
|
|||||||
def enabled(self):
|
def enabled(self):
|
||||||
return self.display_order >= 0
|
return self.display_order >= 0
|
||||||
|
|
||||||
|
@property
|
||||||
|
def requires_actor(self):
|
||||||
|
"""Indicates if this modifier requires the object to be a movable actor"""
|
||||||
|
return False
|
||||||
|
|
||||||
# Guess what?
|
# Guess what?
|
||||||
# You can't register properties on a base class--Blender isn't smart enough to do inheritance,
|
# You can't register properties on a base class--Blender isn't smart enough to do inheritance,
|
||||||
# you see... So, we'll store our definitions in a dict and make those properties on each subclass
|
# you see... So, we'll store our definitions in a dict and make those properties on each subclass
|
||||||
|
@ -33,3 +33,7 @@ class PlasmaSpawnPoint(PlasmaModifierProperties):
|
|||||||
# place the avatar can show up." Nice to have a simple one to get started with.
|
# place the avatar can show up." Nice to have a simple one to get started with.
|
||||||
spawn = exporter.mgr.add_object(pl=plSpawnModifier, bl=bo, name=self.display_name)
|
spawn = exporter.mgr.add_object(pl=plSpawnModifier, bl=bo, name=self.display_name)
|
||||||
so.addModifier(spawn.key)
|
so.addModifier(spawn.key)
|
||||||
|
|
||||||
|
@property
|
||||||
|
def requires_actor(self):
|
||||||
|
return True
|
||||||
|
@ -73,10 +73,7 @@ class PlasmaModifiersPanel(ModifierButtonsPanel, bpy.types.Panel):
|
|||||||
row = layout.row(align=True)
|
row = layout.row(align=True)
|
||||||
exicon = "TRIA_DOWN" if modifier.show_expanded else "TRIA_RIGHT"
|
exicon = "TRIA_DOWN" if modifier.show_expanded else "TRIA_RIGHT"
|
||||||
row.prop(modifier, "show_expanded", text="", icon=exicon, emboss=False)
|
row.prop(modifier, "show_expanded", text="", icon=exicon, emboss=False)
|
||||||
if hasattr(modifier, "bl_icon"):
|
row.label(text=modifier.bl_label, icon=getattr(modifier, "bl_icon", "NONE"))
|
||||||
row.label(icon=modifier.bl_icon)
|
|
||||||
else:
|
|
||||||
row.label(text=modifier.bl_label)
|
|
||||||
row.prop(modifier, "display_name", text="")
|
row.prop(modifier, "display_name", text="")
|
||||||
|
|
||||||
row.operator("object.plasma_modifier_move_up", text="", icon="TRIA_UP").active_modifier = modifier.display_order
|
row.operator("object.plasma_modifier_move_up", text="", icon="TRIA_UP").active_modifier = modifier.display_order
|
||||||
|
Reference in New Issue
Block a user