Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorRenderableLight
Behavior element behavior matching renderable to light intensity.
This behavior is useful for model with an emissive texture where the emissivity intensity should be synchronized to light intensity. A typical example for this is a flashlight where the front side texture lights up if the flashlight is switched on.
To use this behavior add an ECBehaviorDynamicSkin and an ECBehaviorLight to the element class before adding this behavior. Create ECBehaviorRenderableLight behavior and set the dynamic skin and light identifier.
The current light intensity and color can be used for the renderable. If the respective renderable name is not empty string the value is applied. Each one adds an individual renderable if used.
If intensity is applied the renderable is of type DynamicSkinRenderableType.value
with the value set to the light intensity multiplied by an intensity scaling factor. This factor defaults to 1
which roughly equals a light source covered by a diffuse glass panel. Usually emissivity is stronger than the light intensity. The value to use here depends on various physical properties and can go up to 32 to simulate looking straight into an uncovered light source.
If color is applied the renderable is of type DynamicSkinRenderableType.color
with the value set to the light color multiplied component wise by a color scaling factor. This allows tinting textures depending on the light color.
See also:
Multiple ECBehaviorRenderableLight instances can be added to affect individual dynamic skin textures synchronized to individual ECBehaviorLight instances using their identifiers.
Element class properties have the prefix renderableLight.
or renderableLight({id}).
if id is not empty.
Set name of renderable to create for intensity or empty string if not used.
renderableLight.renderableIntensity
or renderableLight({id}).renderableIntensity
<string name='renderableLight.renderableIntensity'>intensityn</string>
Set scale factor to apply to light intensity.
renderableLight.scaleIntensity
or renderableLight({id}).scaleIntensity
<float name='renderableLight.scaleIntensity'>0.5</float>
Set name of renderable to create for color or empty string if not used.
renderableLight.renderableColor
or renderableLight({id}).renderableColor
<string name='renderableLight.renderableColor'>color</string>
Set scale factor to apply component wise to light color.
renderableLight.scaleColor
or renderableLight({id}).scaleColor
<color name='renderableLight.scaleColor' r='0.8' g='0.6' b='0.4'/>
This behavior has no events.
This behavior does not support optional behaviors.
This behavior does not required element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
This example defines an element with a dynamic skin affected by light color.
class MyElement extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorLight light public var ECBehaviorDynamicSkin dynamicSkin public var ECBehaviorRenderableLight renderableLight func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) light = ECBehaviorLight.new(this, collider) dynamicSkin = ECBehaviorDynamicSkin.new(this, collider) renderableLight = ECBehaviorRenderableLight.new(this, dynamicSkin, light) end end
Using element class supporting adding behaviors the behavior can be added like this:
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorLight'/> <behavior type='ECBehaviorDynamicSkin'/> <behavior type='ECBehaviorRenderableLight'> <!-- optional: use dynamic skin with id instead of empty string --> <string name='dynamicSkin'>second</string> <!-- optional: use light with id instead of empty string --> <string name='light'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.renderableColor'>color</string> <string name='.renderableIntensity'>intensity</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorRenderableLight' id='second'/> </elementClass>