{{tag>dragonscript behavior}}
[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorRenderableLight**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== 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 [[behavior_dynamicskin|ECBehaviorDynamicSkin]] and an [[behavior_light|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:
* [[gamedev:renderables|Dynamic Content using Renderables]]
* [[gamedev:deigde:editors:skin|IGDE Skin Editor]]
====== Instance Counts ======
Multiple ECBehaviorRenderableLight instances can be added to affect individual dynamic skin textures synchronized to individual ECBehaviorLight instances using their identifiers.
====== Element Class Properties ======
Element class properties have the prefix ''renderableLight.'' or ''renderableLight({id}).'' if id is not empty.
===== renderableIntensity =====
Set name of renderable to create for intensity or empty string if not used.
* Full name: ''renderableLight.renderableIntensity'' or ''renderableLight({id}).renderableIntensity''
* Type: string
* Default Value: empty string
* Example (*.deeclass) intensityn
===== scaleIntensity =====
Set scale factor to apply to light intensity.
* Full name: ''renderableLight.scaleIntensity'' or ''renderableLight({id}).scaleIntensity''
* Type: float
* Default Value: 1
* Example (*.deeclass) 0.5
===== renderableColor =====
Set name of renderable to create for color or empty string if not used.
* Full name: ''renderableLight.renderableColor'' or ''renderableLight({id}).renderableColor''
* Type: string
* Default Value: empty string
* Example (*.deeclass) color
===== scaleColor =====
Set scale factor to apply component wise to light color.
* Full name: ''renderableLight.scaleColor'' or ''renderableLight({id}).scaleColor''
* Type: 3-component color
* Default Value: (1,1,1)
* Example (*.deeclass)
====== Events ======
This behavior has no events.
====== Required Behaviors ======
* [[behavior_dynamicskin|ECBehaviorDynamicSkin]]
* [[behavior_light|ECBehaviorLight]]
====== Optional Behaviors ======
This behavior does not support optional behaviors.
====== Persistency ======
This behavior does not required element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRenderableLight.html,ECBehaviorRenderableLight~@#.
Since DragonScript Module Version ''1.0''
====== Use Cases ======
* Modify color tint and intensity of a dynamic skin renderable to match a light behavior.
====== Element Class Example ======
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
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
second
second
color
intensity
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]