Browse Source

Export shadow masters

We can finally have avatar shadows in our ages!!! Yes, it really does
deserve all of those exclamation points.
pull/42/head
Adam Johnson 9 years ago
parent
commit
ba93c77260
  1. 18
      korman/exporter/rtlight.py
  2. 29
      korman/properties/prop_lamp.py
  3. 13
      korman/ui/ui_lamp.py

18
korman/exporter/rtlight.py

@ -146,14 +146,16 @@ class LightConverter:
print(" Specular: OFF")
pl_light.specular = hsColorRGBA(0.0, 0.0, 0.0, energy)
# Crazy flags
rtlamp = bl_light.plasma_lamp
if rtlamp.light_group:
has_lg = rtlamp.has_light_group(bo)
if has_lg:
pl_light.setProperty(plLightInfo.kLPHasIncludes, True)
pl_light.setProperty(plLightInfo.kLPIncludesChars, rtlamp.affect_characters)
if rtlamp.cast_shadows:
pl_light.setProperty(plLightInfo.kLPShadowLightGroup, True)
self._export_shadow_master(bo, rtlamp, pl_light)
pl_light.setProperty(plLightInfo.kLPShadowOnly, shadow_only)
if self.mgr.getVer() != pvPrime:
pl_light.setProperty(plLightInfo.kLPShadowLightGroup, has_lg)
# AFAICT ambient lighting is never set in PlasmaMax...
# If you can think of a compelling reason to support it, be my guest.
@ -228,6 +230,16 @@ class LightConverter:
pl_light.projection = layer.key
def _export_shadow_master(self, bo, rtlamp, pl_light):
pClass = plDirectShadowMaster if isinstance(pl_light, plDirectionalLightInfo) else plPointShadowMaster
shadow = self.mgr.find_create_object(pClass, bl=bo)
shadow.attenDist = rtlamp.shadow_falloff
shadow.maxDist = rtlamp.shadow_distance
shadow.minDist = rtlamp.shadow_distance * 0.75
shadow.power = rtlamp.shadow_power / 100.0
shadow.setProperty(plShadowMaster.kSelfShadow, rtlamp.shadow_self)
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])"""

29
korman/properties/prop_lamp.py

@ -17,17 +17,31 @@ import bpy
from bpy.props import *
class PlasmaLamp(bpy.types.PropertyGroup):
light_group = BoolProperty(name="Group Only",
description="This lamp will only affect materials that reference a group this lamp is a member of",
options=set(),
default=True)
affect_characters = BoolProperty(name="Affect Avatars",
description="This lamp affects avatars (can only be disabled if the lamp is \"Group Only\")",
description="This lamp affects avatars",
options=set(),
default=True)
cast_shadows = BoolProperty(name="Cast RT Shadows",
# Shadow settings
cast_shadows = BoolProperty(name="Cast",
description="This lamp casts runtime shadows",
default=True)
shadow_falloff = FloatProperty(name="Falloff",
description="Distance from the Lamp past which we don't cast shadows",
min=5.0, max=50.0, default=10.0,
options=set())
shadow_distance = FloatProperty(name="Fade Distance",
description="Distance at which the shadow has completely faded out",
min=0.0, max=500.0, default=0.0,
options=set())
shadow_power = IntProperty(name="Power",
description="Multiplier for the shadow's intensity",
min=0, max=200, default=100,
options=set(), subtype="PERCENTAGE")
shadow_self = BoolProperty(name="Self-Shadow",
description="This light can cause objects to cast shadows on themselves",
default=False,
options=set())
soft_region = StringProperty(name="Soft Volume",
description="Soft region this light is active inside",
@ -38,3 +52,6 @@ class PlasmaLamp(bpy.types.PropertyGroup):
description="Size of the area for the Area Lamp in the Z direction",
min=0.0, default=200.0,
options=set())
def has_light_group(self, bo):
return bool(bo.users_group)

13
korman/ui/ui_lamp.py

@ -35,15 +35,24 @@ class PlasmaLampPanel(LampButtonsPanel, bpy.types.Panel):
split = layout.split()
col = split.column()
col.prop(rtlamp, "light_group")
col.label("General:")
row = col.row()
row.active = rtlamp.light_group
row.active = rtlamp.has_light_group(context.object)
row.prop(rtlamp, "affect_characters")
col = split.column()
col.label("RT Shadow:")
col.prop(rtlamp, "cast_shadows")
col = col.column()
col.active = rtlamp.cast_shadows
col.prop(rtlamp, "shadow_self")
col.prop(rtlamp, "shadow_power")
col.prop(rtlamp, "shadow_falloff")
col.prop(rtlamp, "shadow_distance")
if not context.object.plasma_modifiers.softvolume.enabled:
layout.separator()
layout.prop_search(rtlamp, "soft_region", bpy.data, "objects")

Loading…
Cancel
Save