|
|
|
@ -162,9 +162,51 @@ class LightConverter:
|
|
|
|
|
sv_key = sv_mod.get_key(self._exporter()) |
|
|
|
|
pl_light.softVolume = sv_key |
|
|
|
|
|
|
|
|
|
# Is this a projector? |
|
|
|
|
projectors = tuple(self.get_projectors(bl_light)) |
|
|
|
|
if projectors: |
|
|
|
|
self._export_rt_projector(bo, pl_light, projectors) |
|
|
|
|
|
|
|
|
|
# *Sigh* |
|
|
|
|
pl_light.sceneNode = self.mgr.get_scene_node(location=so.key.location) |
|
|
|
|
|
|
|
|
|
def _export_rt_projector(self, bo, pl_light, tex_slots): |
|
|
|
|
mat = self._exporter().mesh.material |
|
|
|
|
slot = tex_slots[0] |
|
|
|
|
|
|
|
|
|
# There is a Material available in the caller, but that is for the parent Mesh. We are a |
|
|
|
|
# projection Lamp with our own faux Material. Unfortunately, Plasma only supports projecting |
|
|
|
|
# one layer. We could exploit the fUnderLay and fOverLay system to export everything, but meh. |
|
|
|
|
if len(tex_slots) > 1: |
|
|
|
|
self._exporter().warn("Only one texture slot can be exported per Lamp. Picking the first one: '{}'".format(slot.name), indent=3) |
|
|
|
|
layer = mat.export_texture_slot(bo, None, None, tex_slots, 0, blend_flags=False) |
|
|
|
|
state = layer.state |
|
|
|
|
|
|
|
|
|
# Colors science'd from PRPs |
|
|
|
|
layer.preshade = hsColorRGBA(0.5, 0.5, 0.5) |
|
|
|
|
layer.runtime = hsColorRGBA(0.5, 0.5, 0.5) |
|
|
|
|
|
|
|
|
|
# Props for projectors... |
|
|
|
|
# Note that we tell the material exporter to (try not to) do any blend flags for us |
|
|
|
|
layer.UVWSrc |= plLayer.kUVWPosition |
|
|
|
|
if bo.data.type == "SPOT": |
|
|
|
|
state.miscFlags |= hsGMatState.kMiscPerspProjection |
|
|
|
|
else: |
|
|
|
|
state.miscFlags |= hsGMatState.kMiscOrthoProjection |
|
|
|
|
state.ZFlags |= hsGMatState.kZNoZWrite |
|
|
|
|
pl_light.setProperty(plLightInfo.kLPMovable, True) |
|
|
|
|
pl_light.setProperty(plLightInfo.kLPCastShadows, False) |
|
|
|
|
|
|
|
|
|
if slot.blend_type == "ADD": |
|
|
|
|
state.blendFlags |= hsGMatState.kBlendAdd |
|
|
|
|
pl_light.setProperty(plLightInfo.kLPOverAll, True) |
|
|
|
|
elif slot.blend_type == "MULTIPLY": |
|
|
|
|
# From PlasmaMAX |
|
|
|
|
state.blendFlags |= hsGMatState.kBlendMult | hsGMatState.kBlendInvertColor | hsGMatState.kBlendInvertFinalColor |
|
|
|
|
pl_light.setProperty(plLightInfo.kLPOverAll, True) |
|
|
|
|
|
|
|
|
|
pl_light.projection = layer.key |
|
|
|
|
|
|
|
|
|
def find_material_light_keys(self, bo, bm): |
|
|
|
|
"""Given a blender material, we find the keys of all matching Plasma RT Lights. |
|
|
|
|
NOTE: We return a tuple of lists: ([permaLights], [permaProjs])""" |
|
|
|
@ -218,6 +260,11 @@ class LightConverter:
|
|
|
|
|
except LookupError: |
|
|
|
|
raise BlenderOptionNotSupportedError("Object ('{}') lamp type '{}'".format(bo.name, bl_light.type)) |
|
|
|
|
|
|
|
|
|
def get_projectors(self, bl_light): |
|
|
|
|
for tex in bl_light.texture_slots: |
|
|
|
|
if tex is not None and tex.texture is not None: |
|
|
|
|
yield tex |
|
|
|
|
|
|
|
|
|
def _is_projection_lamp(self, bl_light): |
|
|
|
|
for tex in bl_light.texture_slots: |
|
|
|
|
if tex is None or tex.texture is None: |
|
|
|
|