Browse Source

Implement PanicLinkRegions

This also includes a helper for the manager.add_object god-function that
ensures modifiers are added to the appropriate SceneObject :)
pull/6/head
Adam Johnson 10 years ago
parent
commit
60ced28b77
  1. 27
      korman/exporter/manager.py
  2. 1
      korman/properties/modifiers/__init__.py
  3. 3
      korman/properties/modifiers/logic.py
  4. 58
      korman/properties/modifiers/region.py
  5. 1
      korman/ui/modifiers/__init__.py
  6. 22
      korman/ui/modifiers/region.py

27
korman/exporter/manager.py

@ -61,11 +61,13 @@ class ExportManager:
self._age_info = info self._age_info = info
self.mgr.AddAge(info) self.mgr.AddAge(info)
def add_object(self, pl, name=None, bl=None, loc=None): def add_object(self, pl, name=None, bl=None, loc=None, so=None):
"""Automates adding a converted Blender object to our Plasma Resource Manager""" """Automates adding a converted Blender object to our Plasma Resource Manager"""
assert (bl or loc) assert (bl or loc or so)
if loc: if loc is not None:
location = loc location = loc
elif so is not None:
location = so.key.location
else: else:
location = self._pages[bl.plasma_object.page] location = self._pages[bl.plasma_object.page]
@ -87,11 +89,13 @@ class ExportManager:
elif pl.ClassIndex() in _pool_types: elif pl.ClassIndex() in _pool_types:
node.addPoolObject(pl.key) node.addPoolObject(pl.key)
# Make life easier for folks creating ObjInterfaces if isinstance(pl, plObjInterface):
if isinstance(pl, plObjInterface) and bl is not None: if so is None:
so = self.find_key(bl, plSceneObject) pl.owner = self.find_key(bl, plSceneObject)
if so is not None: else:
pl.owner = so pl.owner = so.key
elif isinstance(pl, plModifier):
so.addModifier(pl.key)
# And we're done! # And we're done!
return pl return pl
@ -100,10 +104,9 @@ class ExportManager:
# BuiltIn.prp # BuiltIn.prp
if bpy.context.scene.world.plasma_age.age_sdl: if bpy.context.scene.world.plasma_age.age_sdl:
builtin = self.create_page(age, "BuiltIn", -2, True) builtin = self.create_page(age, "BuiltIn", -2, True)
pfm = self.add_object(plPythonFileMod, name="VeryVerySpecialPythonFileMod", loc=builtin)
pfm.filename = age
sdl = self.add_object(plSceneObject, name="AgeSDLHook", loc=builtin) sdl = self.add_object(plSceneObject, name="AgeSDLHook", loc=builtin)
sdl.addModifier(pfm.key) pfm = self.add_object(plPythonFileMod, name="VeryVerySpecialPythonFileMod", so=sdl)
pfm.filename = age
# Textures.prp # Textures.prp
if textures: if textures:
@ -196,7 +199,7 @@ class ExportManager:
# This object is in the default page... Init that. # This object is in the default page... Init that.
for loc in self._pages.values(): for loc in self._pages.values():
if not loc.page: if not loc.page:
self.mgr._pages[""] = loc self._pages[""] = loc
break break
else: else:
# need to create default page # need to create default page

1
korman/properties/modifiers/__init__.py

@ -19,6 +19,7 @@ import inspect
from .base import PlasmaModifierProperties from .base import PlasmaModifierProperties
from .logic import * from .logic import *
from .physics import * from .physics import *
from .region import *
class PlasmaModifiers(bpy.types.PropertyGroup): class PlasmaModifiers(bpy.types.PropertyGroup):
def determine_next_id(self): def determine_next_id(self):

3
korman/properties/modifiers/logic.py

@ -31,8 +31,7 @@ class PlasmaSpawnPoint(PlasmaModifierProperties):
def export(self, exporter, bo, so): def export(self, exporter, bo, so):
# Not much to this modifier... It's basically a flag that tells the engine, "hey, this is a # Not much to this modifier... It's basically a flag that tells the engine, "hey, this is a
# 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, so=so, name=self.display_name)
so.addModifier(spawn.key)
@property @property
def requires_actor(self): def requires_actor(self):

58
korman/properties/modifiers/region.py

@ -0,0 +1,58 @@
# This file is part of Korman.
#
# Korman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Korman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
import bpy
from bpy.props import *
from PyHSPlasma import *
from .base import PlasmaModifierProperties
class PlasmaPanicLinkRegion(PlasmaModifierProperties):
pl_id = "paniclink"
bl_category = "Region"
bl_label = "Panic Link"
bl_description = "Panic Link Region"
play_anim = BoolProperty(name="Play Animation",
description="Play the link-out animation when panic linking",
default=True)
exact_bounds = BoolProperty(name="Exact Bounds",
description="Use exact (triangle mesh) bounds -- only use if your mesh is not convex",
default=False)
def created(self, obj):
self.display_name = "{}_PanicLinkRgn".format(obj.name)
def export(self, exporter, bo, so):
# Generate the base physical object
simIface, physical = exporter.physics.generate_physical(bo, so, self.display_name)
if self.exact_bounds:
bounds = "trimesh"
else:
bounds = "hull"
exporter.physics.export(bo, physical, bounds)
# Now setup the region detector properties
physical.memberGroup = plSimDefs.kGroupDetector
physical.reportGroup = 1 << plSimDefs.kGroupAvatar
# Finally, the panic link region proper
reg = exporter.mgr.add_object(plPanicLinkRegion, name=self.display_name, so=so)
reg.playLinkOutAnim = self.play_anim
@property
def requires_actor(self):
return True

1
korman/ui/modifiers/__init__.py

@ -15,3 +15,4 @@
from .logic import * from .logic import *
from .physics import * from .physics import *
from .region import *

22
korman/ui/modifiers/region.py

@ -0,0 +1,22 @@
# This file is part of Korman.
#
# Korman is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# Korman is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with Korman. If not, see <http://www.gnu.org/licenses/>.
def paniclink(modifier, layout, context):
split = layout.split()
col = split.column()
col.prop(modifier, "exact_bounds")
col = split.column()
col.prop(modifier, "play_anim")
Loading…
Cancel
Save