Browse Source

Implement limited directional lights

pull/42/head
Adam Johnson 9 years ago
parent
commit
9ab6b16ed2
  1. 8
      korman/exporter/rtlight.py
  2. 6
      korman/properties/prop_lamp.py
  3. 37
      korman/ui/ui_lamp.py

8
korman/exporter/rtlight.py

@ -21,6 +21,7 @@ from .explosions import *
from . import utils
_BL2PL = {
"AREA": plLimitedDirLightInfo,
"POINT": plOmniLightInfo,
"SPOT": plSpotLightInfo,
"SUN": plDirectionalLightInfo,
@ -32,6 +33,7 @@ class LightConverter:
def __init__(self, exporter):
self._exporter = weakref.ref(exporter)
self._converter_funcs = {
"AREA": self._convert_area_lamp,
"POINT": self._convert_point_lamp,
"SPOT": self._convert_spot_lamp,
"SUN": self._convert_sun_lamp,
@ -64,6 +66,12 @@ class LightConverter:
else:
raise BlenderOptionNotSupportedError(bl.falloff_type)
def _convert_area_lamp(self, bl, pl):
print(" [LimitedDirLightInfo '{}']".format(bl.name))
pl.width = bl.size
pl.depth = bl.size if bl.shape == "SQUARE" else bl.size_y
pl.height = bl.plasma_lamp.size_height
def _convert_point_lamp(self, bl, pl):
print(" [OmniLightInfo '{}']".format(bl.name))

6
korman/properties/prop_lamp.py

@ -32,3 +32,9 @@ class PlasmaLamp(bpy.types.PropertyGroup):
soft_region = StringProperty(name="Soft Volume",
description="Soft region this light is active inside",
options=set())
# For LimitedDirLights
size_height = FloatProperty(name="Height",
description="Size of the area for the Area Lamp in the Z direction",
min=0.0, default=200.0,
options=set())

37
korman/ui/ui_lamp.py

@ -31,7 +31,7 @@ class PlasmaLampPanel(LampButtonsPanel, bpy.types.Panel):
def draw (self, context):
layout = self.layout
rtlamp = context.object.data.plasma_lamp
rtlamp = context.lamp.plasma_lamp
split = layout.split()
col = split.column()
@ -45,3 +45,38 @@ class PlasmaLampPanel(LampButtonsPanel, bpy.types.Panel):
if not context.object.plasma_modifiers.softvolume.enabled:
layout.prop_search(rtlamp, "soft_region", bpy.data, "objects")
def _draw_area_lamp(self, context):
"""Draw dispatch function for DATA_PT_area"""
if context.scene.render.engine == "PLASMA_GAME":
_plasma_draw_area_lamp(self, context)
else:
self._draw_blender(context)
def _plasma_draw_area_lamp(self, context):
"""Draw function for DATA_PT_area when Korman is active"""
layout = self.layout
lamp = context.lamp
plasma_lamp = lamp.plasma_lamp
col = layout.column()
col.row().prop(lamp, "shape", expand=True)
sub = col.row(align=True)
if lamp.shape == "SQUARE":
sub.prop(lamp, "size")
sub.prop(plasma_lamp, "size_height")
elif lamp.shape == "RECTANGLE":
sub.prop(lamp, "size", text="W")
sub.prop(lamp, "size_y", text="D")
sub.prop(plasma_lamp, "size_height", text="H")
# Swap out the draw functions for the standard Area Shape panel
# TODO: Maybe we should consider standardizing an interface for overriding
# standard Blender panels? This seems like a really useful approach.
from bl_ui import properties_data_lamp
properties_data_lamp.DATA_PT_area._draw_blender = properties_data_lamp.DATA_PT_area.draw
properties_data_lamp.DATA_PT_area.draw = _draw_area_lamp
del properties_data_lamp

Loading…
Cancel
Save