|
|
@ -22,6 +22,7 @@ from .base import PlasmaModifierProperties |
|
|
|
from ...exporter.etlight import _NUM_RENDER_LAYERS |
|
|
|
from ...exporter.etlight import _NUM_RENDER_LAYERS |
|
|
|
from ...exporter import utils |
|
|
|
from ...exporter import utils |
|
|
|
from ...exporter.explosions import ExportError |
|
|
|
from ...exporter.explosions import ExportError |
|
|
|
|
|
|
|
from ... import idprops |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaFadeMod(PlasmaModifierProperties): |
|
|
|
class PlasmaFadeMod(PlasmaModifierProperties): |
|
|
@ -81,7 +82,7 @@ class PlasmaFadeMod(PlasmaModifierProperties): |
|
|
|
mod.farTrans = self.far_trans |
|
|
|
mod.farTrans = self.far_trans |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaFollowMod(PlasmaModifierProperties): |
|
|
|
class PlasmaFollowMod(idprops.IDPropObjectMixin, PlasmaModifierProperties): |
|
|
|
pl_id = "followmod" |
|
|
|
pl_id = "followmod" |
|
|
|
|
|
|
|
|
|
|
|
bl_category = "Render" |
|
|
|
bl_category = "Render" |
|
|
@ -108,8 +109,9 @@ class PlasmaFollowMod(PlasmaModifierProperties): |
|
|
|
("kFollowObject", "Object", "Follow an object"), |
|
|
|
("kFollowObject", "Object", "Follow an object"), |
|
|
|
]) |
|
|
|
]) |
|
|
|
|
|
|
|
|
|
|
|
leader_object = StringProperty(name="Leader Object", |
|
|
|
leader = PointerProperty(name="Leader Object", |
|
|
|
description="Object to follow") |
|
|
|
description="Object to follow", |
|
|
|
|
|
|
|
type=bpy.types.Object) |
|
|
|
|
|
|
|
|
|
|
|
def export(self, exporter, bo, so): |
|
|
|
def export(self, exporter, bo, so): |
|
|
|
fm = exporter.mgr.find_create_object(plFollowMod, so=so, name=self.key_name) |
|
|
|
fm = exporter.mgr.find_create_object(plFollowMod, so=so, name=self.key_name) |
|
|
@ -122,21 +124,21 @@ class PlasmaFollowMod(PlasmaModifierProperties): |
|
|
|
if self.leader_type == "kFollowObject": |
|
|
|
if self.leader_type == "kFollowObject": |
|
|
|
# If this object is following another object, make sure that the |
|
|
|
# If this object is following another object, make sure that the |
|
|
|
# leader has been selected and is a valid SO. |
|
|
|
# leader has been selected and is a valid SO. |
|
|
|
if self.leader_object: |
|
|
|
if self.leader: |
|
|
|
leader_obj = bpy.data.objects.get(self.leader_object, None) |
|
|
|
fm.leader = exporter.mgr.find_create_key(plSceneObject, bl=self.leader) |
|
|
|
if leader_obj is None: |
|
|
|
|
|
|
|
raise ExportError("'{}': Follow's leader object is invalid".format(self.key_name)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
fm.leader = exporter.mgr.find_create_key(plSceneObject, bl=leader_obj) |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
raise ExportError("'{}': Follow's leader object must be selected".format(self.key_name)) |
|
|
|
raise ExportError("'{}': Follow's leader object must be selected".format(self.key_name)) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _idprop_mapping(cls): |
|
|
|
|
|
|
|
return {"leader": "leader_object"} |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def requires_actor(self): |
|
|
|
def requires_actor(self): |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaLightMapGen(PlasmaModifierProperties): |
|
|
|
class PlasmaLightMapGen(idprops.IDPropMixin, PlasmaModifierProperties): |
|
|
|
pl_id = "lightmap" |
|
|
|
pl_id = "lightmap" |
|
|
|
|
|
|
|
|
|
|
|
bl_category = "Render" |
|
|
|
bl_category = "Render" |
|
|
@ -159,8 +161,9 @@ class PlasmaLightMapGen(PlasmaModifierProperties): |
|
|
|
size=_NUM_RENDER_LAYERS, |
|
|
|
size=_NUM_RENDER_LAYERS, |
|
|
|
default=((True,) * _NUM_RENDER_LAYERS)) |
|
|
|
default=((True,) * _NUM_RENDER_LAYERS)) |
|
|
|
|
|
|
|
|
|
|
|
light_group = StringProperty(name="Light Group", |
|
|
|
lights = PointerProperty(name="Light Group", |
|
|
|
description="Group that defines the collection of lights to bake") |
|
|
|
description="Group that defines the collection of lights to bake", |
|
|
|
|
|
|
|
type=bpy.types.Group) |
|
|
|
|
|
|
|
|
|
|
|
uv_map = StringProperty(name="UV Texture", |
|
|
|
uv_map = StringProperty(name="UV Texture", |
|
|
|
description="UV Texture used as the basis for the lightmap") |
|
|
|
description="UV Texture used as the basis for the lightmap") |
|
|
@ -208,6 +211,13 @@ class PlasmaLightMapGen(PlasmaModifierProperties): |
|
|
|
# Mmm... cheating |
|
|
|
# Mmm... cheating |
|
|
|
mat_mgr.export_prepared_layer(layer, lightmap_im) |
|
|
|
mat_mgr.export_prepared_layer(layer, lightmap_im) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _idprop_mapping(cls): |
|
|
|
|
|
|
|
return {"lights": "light_group"} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _idprop_sources(self): |
|
|
|
|
|
|
|
return {"light_group": bpy.data.groups} |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def key_name(self): |
|
|
|
def key_name(self): |
|
|
|
return "{}_LIGHTMAPGEN".format(self.id_data.name) |
|
|
|
return "{}_LIGHTMAPGEN".format(self.id_data.name) |
|
|
@ -317,7 +327,7 @@ class PlasmaShadowCasterMod(PlasmaModifierProperties): |
|
|
|
caster.castFlags |= plShadowCaster.kSelfShadow |
|
|
|
caster.castFlags |= plShadowCaster.kSelfShadow |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaViewFaceMod(PlasmaModifierProperties): |
|
|
|
class PlasmaViewFaceMod(idprops.IDPropObjectMixin, PlasmaModifierProperties): |
|
|
|
pl_id = "viewfacemod" |
|
|
|
pl_id = "viewfacemod" |
|
|
|
|
|
|
|
|
|
|
|
bl_category = "Render" |
|
|
|
bl_category = "Render" |
|
|
@ -340,8 +350,9 @@ class PlasmaViewFaceMod(PlasmaModifierProperties): |
|
|
|
("kFacePlay", "Player", "Face the local player"), |
|
|
|
("kFacePlay", "Player", "Face the local player"), |
|
|
|
("kFaceObj", "Object", "Face an object"), |
|
|
|
("kFaceObj", "Object", "Face an object"), |
|
|
|
]) |
|
|
|
]) |
|
|
|
target_object = StringProperty(name="Target Object", |
|
|
|
target = PointerProperty(name="Target Object", |
|
|
|
description="Object to face") |
|
|
|
description="Object to face", |
|
|
|
|
|
|
|
type=bpy.types.Object) |
|
|
|
|
|
|
|
|
|
|
|
pivot_on_y = BoolProperty(name="Pivot on local Y", |
|
|
|
pivot_on_y = BoolProperty(name="Pivot on local Y", |
|
|
|
description="Swivel only around the local Y axis", |
|
|
|
description="Swivel only around the local Y axis", |
|
|
@ -376,12 +387,8 @@ class PlasmaViewFaceMod(PlasmaModifierProperties): |
|
|
|
if self.follow_mode == "kFaceObj": |
|
|
|
if self.follow_mode == "kFaceObj": |
|
|
|
# If this swivel is following an object, make sure that the |
|
|
|
# If this swivel is following an object, make sure that the |
|
|
|
# target has been selected and is a valid SO. |
|
|
|
# target has been selected and is a valid SO. |
|
|
|
if self.target_object: |
|
|
|
if self.target: |
|
|
|
target_obj = bpy.data.objects.get(self.target_object, None) |
|
|
|
vfm.faceObj = exporter.mgr.find_create_key(plSceneObject, bl=self.target) |
|
|
|
if target_obj is None: |
|
|
|
|
|
|
|
raise ExportError("'{}': Swivel's target object is invalid".format(self.key_name)) |
|
|
|
|
|
|
|
else: |
|
|
|
|
|
|
|
vfm.faceObj = exporter.mgr.find_create_key(plSceneObject, bl=target_obj) |
|
|
|
|
|
|
|
else: |
|
|
|
else: |
|
|
|
raise ExportError("'{}': Swivel's target object must be selected".format(self.key_name)) |
|
|
|
raise ExportError("'{}': Swivel's target object must be selected".format(self.key_name)) |
|
|
|
|
|
|
|
|
|
|
@ -395,12 +402,16 @@ class PlasmaViewFaceMod(PlasmaModifierProperties): |
|
|
|
if self.offset_local: |
|
|
|
if self.offset_local: |
|
|
|
vfm.setFlag(plViewFaceModifier.kOffsetLocal, True) |
|
|
|
vfm.setFlag(plViewFaceModifier.kOffsetLocal, True) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _idprop_mapping(cls): |
|
|
|
|
|
|
|
return {"target": "target_object"} |
|
|
|
|
|
|
|
|
|
|
|
@property |
|
|
|
@property |
|
|
|
def requires_actor(self): |
|
|
|
def requires_actor(self): |
|
|
|
return True |
|
|
|
return True |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaVisControl(PlasmaModifierProperties): |
|
|
|
class PlasmaVisControl(idprops.IDPropObjectMixin, PlasmaModifierProperties): |
|
|
|
pl_id = "visregion" |
|
|
|
pl_id = "visregion" |
|
|
|
|
|
|
|
|
|
|
|
bl_category = "Render" |
|
|
|
bl_category = "Render" |
|
|
@ -412,8 +423,10 @@ class PlasmaVisControl(PlasmaModifierProperties): |
|
|
|
items=[("normal", "Normal", "Objects are only visible when the camera is inside this region"), |
|
|
|
items=[("normal", "Normal", "Objects are only visible when the camera is inside this region"), |
|
|
|
("exclude", "Exclude", "Objects are only visible when the camera is outside this region"), |
|
|
|
("exclude", "Exclude", "Objects are only visible when the camera is outside this region"), |
|
|
|
("fx", "Special FX", "This is a list of objects used for special effects only")]) |
|
|
|
("fx", "Special FX", "This is a list of objects used for special effects only")]) |
|
|
|
softvolume = StringProperty(name="Region", |
|
|
|
soft_region = PointerProperty(name="Region", |
|
|
|
description="Object defining the SoftVolume for this VisRegion") |
|
|
|
description="Object defining the SoftVolume for this VisRegion", |
|
|
|
|
|
|
|
type=bpy.types.Object, |
|
|
|
|
|
|
|
poll=idprops.poll_softvolume_objects) |
|
|
|
replace_normal = BoolProperty(name="Hide Drawables", |
|
|
|
replace_normal = BoolProperty(name="Hide Drawables", |
|
|
|
description="Hides drawables attached to this region", |
|
|
|
description="Hides drawables attached to this region", |
|
|
|
default=True) |
|
|
|
default=True) |
|
|
@ -430,21 +443,31 @@ class PlasmaVisControl(PlasmaModifierProperties): |
|
|
|
exporter.report.msg("[VisRegion] I'm a SoftVolume myself :)", indent=1) |
|
|
|
exporter.report.msg("[VisRegion] I'm a SoftVolume myself :)", indent=1) |
|
|
|
rgn.region = this_sv.get_key(exporter, so) |
|
|
|
rgn.region = this_sv.get_key(exporter, so) |
|
|
|
else: |
|
|
|
else: |
|
|
|
exporter.report.msg("[VisRegion] SoftVolume '{}'", self.softvolume, indent=1) |
|
|
|
if not self.soft_region: |
|
|
|
sv_bo = bpy.data.objects.get(self.softvolume, None) |
|
|
|
raise ExportError("'{}': Visibility Control must have a Soft Volume selected".format(self.key_name)) |
|
|
|
if sv_bo is None: |
|
|
|
sv_bo = self.soft_region |
|
|
|
raise ExportError("'{}': Invalid object '{}' for VisControl soft volume".format(bo.name, self.softvolume)) |
|
|
|
|
|
|
|
sv = sv_bo.plasma_modifiers.softvolume |
|
|
|
sv = sv_bo.plasma_modifiers.softvolume |
|
|
|
|
|
|
|
exporter.report.msg("[VisRegion] SoftVolume '{}'", sv_bo.name, indent=1) |
|
|
|
if not sv.enabled: |
|
|
|
if not sv.enabled: |
|
|
|
raise ExportError("'{}': '{}' is not a SoftVolume".format(bo.name, self.softvolume)) |
|
|
|
raise ExportError("'{}': '{}' is not a SoftVolume".format(self.key_name, sv_bo.name)) |
|
|
|
rgn.region = sv.get_key(exporter) |
|
|
|
rgn.region = sv.get_key(exporter) |
|
|
|
rgn.setProperty(plVisRegion.kIsNot, self.mode == "exclude") |
|
|
|
rgn.setProperty(plVisRegion.kIsNot, self.mode == "exclude") |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _idprop_mapping(cls): |
|
|
|
|
|
|
|
return {"soft_region": "softvolume"} |
|
|
|
|
|
|
|
|
|
|
|
class VisRegion(bpy.types.PropertyGroup): |
|
|
|
|
|
|
|
|
|
|
|
class VisRegion(idprops.IDPropObjectMixin, bpy.types.PropertyGroup): |
|
|
|
enabled = BoolProperty(default=True) |
|
|
|
enabled = BoolProperty(default=True) |
|
|
|
region_name = StringProperty(name="Control", |
|
|
|
control_region = PointerProperty(name="Control", |
|
|
|
description="Object defining a Plasma Visibility Control") |
|
|
|
description="Object defining a Plasma Visibility Control", |
|
|
|
|
|
|
|
type=bpy.types.Object, |
|
|
|
|
|
|
|
poll=idprops.poll_visregion_objects) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@classmethod |
|
|
|
|
|
|
|
def _idprop_mapping(cls): |
|
|
|
|
|
|
|
return {"control_region": "region_name"} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class PlasmaVisibilitySet(PlasmaModifierProperties): |
|
|
|
class PlasmaVisibilitySet(PlasmaModifierProperties): |
|
|
@ -474,7 +497,6 @@ class PlasmaVisibilitySet(PlasmaModifierProperties): |
|
|
|
for region in self.regions: |
|
|
|
for region in self.regions: |
|
|
|
if not region.enabled: |
|
|
|
if not region.enabled: |
|
|
|
continue |
|
|
|
continue |
|
|
|
rgn_bo = bpy.data.objects.get(region.region_name, None) |
|
|
|
if not region.control_region: |
|
|
|
if rgn_bo is None: |
|
|
|
raise ExportError("{}: Not all Visibility Controls are set up properly in Visibility Set".format(bo.name)) |
|
|
|
raise ExportError("{}: Invalid VisControl '{}' in VisSet modifier".format(bo.name, region.region_name)) |
|
|
|
addRegion(exporter.mgr.find_create_key(plVisRegion, bl=region.control_region)) |
|
|
|
addRegion(exporter.mgr.find_create_key(plVisRegion, bl=rgn_bo)) |
|
|
|
|
|
|
|