{{tag>dragonscript behavior}} [[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorLight** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== 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. * Full name: ''light.type'' or ''light({id}).type'' * Type: enumeration * Allowed Values: ^Value^Description^ |''point''|Point light.| |''spot''|Spot light.| |''projector''|Projector light.| * Default Value: ''point'' * Example (*.deeclass) spot ===== color ===== Set light color. * Full name: ''light.color'' or ''light({id}).color'' * Type: 3-component color * Default Value: (1,1,1) * Example (*.deeclass) ===== intensity ===== Set value. * Full name: ''light.intensity'' or ''light({id}).intensity'' * Type: float * Default Value: 1 * Restriction: At least 0 * Example (*.deeclass) 2.5 ===== ambientRatio ===== Set ambient ratio. Percentage of total light to use as ambient light. * Full name: ''light.ambientRatio'' or ''light({id}).ambientRatio'' * Type: float * Default Value: 0 * Restriction: At least 0 and at most 1. * Example (*.deeclass) 0.2 ===== range ===== Set range im meters. Beyond this range light has no effect. * Full name: ''light.range'' or ''light({id}).range'' * Type: float * Default Value: 10 * Restriction: At least 0 * Example (*.deeclass) 2.5 ===== 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. * Full name: ''light.halfIntensityDistance'' or ''light({id}).halfIntensityDistance'' * Type: float * Default Value: 0.1 * Restriction: At least 0 and at most 1. * Example (*.deeclass) 0.2 ===== spotAngle ===== Set spot angle in degrees (opening angle). * Full name: ''light.spotAngle'' or ''light({id}).spotAngle'' * Type: float * Default Value: 30 * Restriction: At least 0 and at most 179. * Example (*.deeclass) 45 ===== spotRatio ===== Set spot ratio as height divided by width. Hence this is the aspect ratio of the spot light. * Full name: ''light.spotRatio'' or ''light({id}).spotRatio'' * Type: float * Default Value: 1 * Restriction: At least 0 * Example (*.deeclass) 1.5 ===== 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. * Full name: ''light.spotSmoothness'' or ''light({id}).spotSmoothness'' * Type: float * Default Value: 1 * Restriction: At least 0 and at most 1. * Example (*.deeclass) 0.2 ===== 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. * Full name: ''light.spotExponent'' or ''light({id}).spotExponent'' * Type: float * Default Value: 2 * Restriction: At least 0 * Example (*.deeclass) 1.5 ===== shape ===== Set shape. * Full name: ''light.shape'' or ''light({id}).shape'' * Type: string (shape format). See "Shape List Encoding" in CodecPropertyString. * Default Value: empty string * Example (*.deeclass) box:position,0,0.5,0:extends,2,1,0.5 ===== lightSkin ===== Set path of skin resource to use. * Full name: ''light.lightSkin'' or ''light({id}).lightSkin'' * Type: string * Default Value: empty string * Expected File Type: ''*.deskin'' * Example (*.deeclass) spot.deskin ===== hintMovement ===== Set movement hint. * Full name: ''light.hintMovement'' or ''light({id}).hintMovement'' * Type: enumeration * Allowed 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.| * Default Value: ''stationary'' * Example (*.deeclass) dynamic ===== hintParameter ===== Set parameter hint. * Full name: ''light.hintParameter'' or ''light({id}).hintParameter'' * Type: enumeration * Allowed 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.| * Default Value: ''initial'' * Example (*.deeclass) dynamic ===== 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. * Full name: ''light.hintShadowImportance'' or ''light({id}).hintShadowImportance'' * Type: float * Default Value: 100 * Restriction: At least 0 and at most 100 * Example (*.deeclass) 75 ===== activated ===== Set light active. * Full name: ''light.activated'' or ''light({id}).activated'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== castShadows ===== Set light cast shadows. * Full name: ''light.castShadows'' or ''light({id}).castShadows'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== position ===== Set position to attach resource to collider. * Full name: ''light.position'' or ''light({id}).position'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== orientation ===== Set orientation to attach resource to collider in degrees. * Full name: ''light.orientation'' or ''light({id}).orientation'' * Type: 3-component float vector * Default Value: (0,0,0) * Example (*.deeclass) ===== bone ===== Set bone to attach resource to. If empty string attach to collider. * Full name: ''light.bone'' or ''light({id}).bone'' * Type: string * Default Value: empty string * Example (*.deeclass) attach ===== trigger ===== Set trigger activate. If no trigger is set the state of ''activated'' property is used. * Full name: ''light.trigger'' or ''light({id}).trigger'' * Type: string * Default Value: state of ''activated'' * Example (*.deeclass) @switchOnLight & @powerEnabled ====== 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 ====== * [[behavior_collider|ECBehaviorCollider]]. Attach to collider. ====== Persistency ====== This behavior does support element class to be persistable (setPersistable). Saves these states: * activated ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorLight.html,ECBehaviorLight~@#. Since DragonScript Module Version ''1.0'' ====== Use Cases ====== * Add light shining from element. ====== 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: 0 1 0 1 default second first second ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]