This is an old revision of the document!
Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorLight
Behavior element behavior adding custom color support.
Custom colors are typically used to allow players to customize the look of their player actor by altering the color of individual body parts. This behavior allows to define custom color slots the player or artist can manipulate. This behavior does not define how custom colors are applied. This is left for other behaviors or game scripts to do.
Custom colors compose of a display name and the currently assigned color. This color can be null to use the assigned default color. An optional list of colors can be used to restrict the colors the player can select. If the list is empty the player can choose the color unrestricted. In addition a display description can be added in case the game developer would like to communicate additional information about the custom color.
This behavior can be used multiple times on an element to add multiple custom colors 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 requires no other behaviors.
This behavior does support these optional 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: 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>