Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorLight
Behavior element behavior adding Light resource.
This behavior can be used multiple times on an element to add multiple lights to mainpulate. Use the behavior identifier to tell them apart.
Element class properties have the prefix light. or light({id}). if id is not empty.
Set light type.
light.type or light({id}).typeAllowed Values:
| Value | Description |
|---|---|
point | Point light. |
spot | Spot light. |
projector | Projector light. |
point<string name='light.type'>spot</string>
Set light color.
light.color or light({id}).color<color name='light.color' r='0.8' g='0.6' b='0.4'/>
Set value.
light.intensity or light({id}).intensity<float name='light.intensity'>2.5</float>
Set ambient ratio. Percentage of total light to use as ambient light.
light.ambientRatio or light({id}).ambientRatio<float name='light.ambientRatio'>0.2</float>
Set range im meters. Beyond this range light has no effect.
light.range or light({id}).range<float name='light.range'>2.5</float>
Set half intensity distance relative to range. At this position the light dropped to 50% strength. Allows to shape fall-off curve. A value of 0.1 is natural fall-off. Values larger than 0.1 make light fall off faster near the light source. Values smaller than 0.1 make light fall off faster near the light range.
light.halfIntensityDistance or light({id}).halfIntensityDistance<float name='light.halfIntensityDistance'>0.2</float>
Set spot angle in degrees (opening angle).
light.spotAngle or light({id}).spotAngle<float name='light.spotAngle'>45</float>
Set spot ratio as height divided by width. Hence this is the aspect ratio of the spot light.
light.spotRatio or light({id}).spotRatio<float name='light.spotRatio'>1.5</float>
Set spot smoothness. Percentage distance from border to center where light fall-off begins. A value of 0 produces constant light intensity across the entire spot cone. A value of 1 produces linear fade across the entire spot cone.
light.spotSmoothness or light({id}).spotSmoothness<float name='light.spotSmoothness'>0.2</float>
Set spot exponent. Shape of light fall-off from spot center to spot border. A value of 1 is linear fall-off. Values larger than 0.1 make light fall off faster near the spot center. Values smaller than 0.1 make light fall off faster near the spot border.
light.spotExponent or light({id}).spotExponent<float name='light.spotExponent'>1.5</float>
Set shape.
light.shape or light({id}).shape<string name='light.shape'>box:position,0,0.5,0:extends,2,1,0.5</string>
Set path of skin resource to use.
light.lightSkin or light({id}).lightSkin*.deskin<string name='light.lightSkin'>spot.deskin</string>
Set movement hint.
light.hintMovement or light({id}).hintMovementAllowed Values:
| Value | Description |
|---|---|
stationary | Light remains static for the entire lifetime. |
jittering | Light remains mostly static jittering in a small area. |
dynamic | Light moves around freely. |
stationary<string name='light.hintMovement'>dynamic</string>
Set parameter hint.
light.hintParameter or light({id}).hintParameterAllowed Values:
| Value | Description |
|---|---|
initial | Light parameters never change. |
activation | Light parameters never change except activation. |
flicker | Geometric light parameters never change but others can. |
dynamic | All light parameters can change at will any time. |
initial<string name='light.hintParameter'>dynamic</string>
Set hint shadow importance. Can be used by graphics module to decide which shadows can be reduced in quality or omitted if performance is low. A value of 100 indicates this shadow is important and should always be shown if possible. A value of 0 marks the shadow as unimportant which can be quickly reduced if required.
light.hintShadowImportance or light({id}).hintShadowImportance<float name='light.hintShadowImportance'>75</float>
Set light active.
light.activated or light({id}).activated<boolean name='light.activated'>false</boolean>
Set light cast shadows.
light.castShadows or light({id}).castShadows<boolean name='light.castShadows'>false</boolean>
Set position to attach resource to collider.
light.position or light({id}).position<vector name='light.position' x='0' y='0' z='0.1'/>
Set orientation to attach resource to collider in degrees.
light.orientation or light({id}).orientation<vector name='light.orientation' x='30' y='0' z='0'/>
Set bone to attach resource to. If empty string attach to collider.
light.bone or light({id}).bone<string name='light.bone'>attach</string>
Set trigger activate. If no trigger is set the state of activated property is used.
light.trigger or light({id}).triggeractivated<string name='light.trigger'>@switchOnLight & @powerEnabled</string>
This behavior provides these events:
Light has been activated.
Light has been deactivated.
Light parameters have been changed.
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace light with light(id).
Set one or more light parameters.
| Parameter | Value | Description |
|---|---|---|
| activated | true,false | Activate light |
This is an example of using this action:
<action name='light.set'> <parameter name='activated'>true</parameter> </action>
Check one or more light parameters. Action succeeds if all parameter value matches their respective light parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a light parameter matches (or not).
| Parameter | Value | Description |
|---|---|---|
| activated | true,false | Light is activated or not |
| wait | If present action returns BTResult.running instead of BTResult.failed to wait until the checks are all fulfilled |
This is an example of using this action:
<sequence> <action name='light.check'> <parameter name='activated'>true</parameter> </action> <!-- actions here run only if light is activated --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace light with light(id).
Check one or more light parameters. Conditions returns true if all parameter value match their respective light parameter. This condition is typically used to run an action or sequence of actions as long as light conditions are true.
| Parameter | Value | Description |
|---|---|---|
| light.activated | true,false | Light is activated or not |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='light.activated'>true</parameter> <condition>light.check</condition> </action>
Same as Behavior Tree Actions.
Same as Behavior Tree Conditions.
This behavior sends these state machine events. If behavior has non-empty identifier replace light with light(id).
Light has been activated.
Light has been deactivated.
This behavior requires no other behaviors.
This behavior does support element class to be persistable (setPersistable). Saves these states:
Since DragonScript Module Version 1.0
This example defines an element which contains a light.
class MyElement extends BehaviorElementClass
public var ECBehaviorCollider collider
public var ECBehaviorLight light
func new()
collider = ECBehaviorCollider.new(this, component)
light = ECBehaviorLight.new(this, collider)
light.getLight().getColor().setColor(Color.blue)
light.getAttach().getPosition().setVector(Vector.new(0, 0, 0.3))
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='ECBehaviorCollider'/> <behavior type='ECBehaviorLight'> <!-- optional: set layer mask as list of bits to set. default is '0 1' which means BaseGameApp.WorldLayerBit.default, BaseGameApp.WorldLayerBit.envmap --> <string name='layerMask'>0 1</string> <!-- optional: set shadow layer mask. default is same as 'layerMask' --> <string name='layerMaskShadow'>0 1</string> <!-- optional: use BaseGameApp trigger table. game can add more supported values. default value is 'default' --> <string name='triggerTable'>default</string> <!-- optional: sync trigger with light matching identifier --> <string name='syncTrigger'>second</string> <!-- optional: identifier of ECBehaviorTriggered to synchronize with or empty string to not synchronize. default is empty string. --> <string name='trigger.synchronize'>other</string> <!-- optional: use behavior tree with id instead of empty string --> <string name='behaviorTree'>second</string> <!-- optional: use state machine with id instead of empty string --> <string name='stateMachine'>second</string> <!-- optional: component behaviors not casting shadows. list of behavior identifiers --> <list name='shadowIgnoreComponents'> <string>first</string> <string>second</string> </list> <!-- set element properties. omit property prefix if used inside behavior tag --> <color name='.color' r='0.8' g='0.6' b='0.4'/> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorLight' id='second'/> </elementClass>