Table of Contents

,

Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorLight

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.

Instance Counts

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

Element class properties have the prefix light. or light({id}). if id is not empty.

type

Set light type.

color

Set light color.

intensity

Set value.

ambientRatio

Set ambient ratio. Percentage of total light to use as ambient light.

range

Set range im meters. Beyond this range light has no effect.

halfIntensityDistance

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.

spotAngle

Set spot angle in degrees (opening angle).

spotRatio

Set spot ratio as height divided by width. Hence this is the aspect ratio of the spot light.

spotSmoothness

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.

spotExponent

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.

shape

Set shape.

lightSkin

Set path of skin resource to use.

hintMovement

Set movement hint.

hintParameter

Set parameter hint.

hintShadowImportance

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.

activated

Set light active.

castShadows

Set light cast shadows.

position

Set position to attach resource to collider.

orientation

Set orientation to attach resource to collider in degrees.

bone

Set bone to attach resource to. If empty string attach to collider.

trigger

Set trigger activate. If no trigger is set the state of activated property is used.

Events

This behavior provides these events:

lightActivated

Light has been activated.

lightDeactivated

Light has been deactivated.

lightParametersChanged

Light parameters have been changed.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

This behavior does support element class to be persistable (setPersistable). Saves these states:

API Documentation

ECBehaviorLight.

Since DragonScript Module Version 1.0

Use Cases

Element Class Example

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

Behavior Factory

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>

Live Examples