Start Page » DragonScript Scripting Language » Abstraction Layers: How you want to build your Game » Behavior Elements » ECBehaviorOutline
Example usage of outline.* skin texture properties.
Adds outline support to components.
Renders outline around a component.
This is done by creating a new component resource. The model and rig of the existing component is assigned to the new component. The new component resource is attached to an existing collider using rig attachment mode. This makes the new component deform the same way as the existing component. The new component is thus a kind of “copy” of the existing component.
Then an outline skin is assigned to the new component and all textures it contains. This replaces every texture in the new component with the outline skin.
The outline skin is set by the user. To work properly it has to use the outline.*
skin texture properties to render the outline and solidity
with value 0
to hide everything but the outline.
A typical outline skin looks like this:
<?xml version='1.0' encoding='UTF-8'?> <skin> <texture name='material'> <value property='solidity'>0</value> <color property='outline.color' r='0' g='0' b='0' a='1' renderable='color'/> <value property='outline.thickness' renderable='thickness'>0.005</value> <value property='outline.thickness.screen'>1</value> <color property='outline.emissivity' r='0' g='0' b='0' a='1' renderable='color'/> <value property='outline.emissivity.intensity' renderable='intensity'>4</value> </texture> </skin>
By default the skin /shareddata/materials/outlined.deskin
is used which is provided by the shared DragonScript Module data and provides tintable and emissive outlines.
The emissivity is optional and allows to make the outline glow in the dark. Using renderable color
is also optional but recommended. This allows this behavior to change the outline color using a dynamic skin.
This set up allows to add an outline skin to any ECBehaviorComponent without the need to create skins with built-in support for outline rendering. If you want to use outline for all objects by default better build it into their skins which is faster.
This behavior can be also used to add outer skins in general to an ECBehaviorComponent. You have to adjust the outline skin to achieve the desired result.
This is an effect type behavior and starts out invisible. Use setVisible() to switch the outline on and off. Typically this is done in response to game events or by other behaviors managing outline parameters.
Multiple instances of ECBehaviorOutline can be used for example to create different outlines to switch on and off or to add multiple outline skins to a single ECBehaviorComponent. Keep in mind though that each instance of ECBehaviorOutline creates a new component and dynamic skin resource which can impact performance if the used model has high polygon count. Use the behavior identifier to tell them apart.
Element class properties have the prefix outline.
or outline(id).
if id is not empty.
Path to skin to use to render the outline.
outline.skin
or outline(id).skin
/shareddata/materials/outlined.deskin
*.deskin
(all skin modules)<string name='outline.skin'>outline.deskin</string>
Path to model to use instead of the model of the dependency component
outline.model
or outline(id).model
null
*.demodel
(all model modules)<string name='outline.model'>outline.demodel</string>
Path to rig to use instead of the rig of the dependency component. If null uses the dependency component rig.
outline.rig
or outline(id).rig
null
*.derig
(all rig modules)<string name='outline.rig'>outline.derig</string>
Color of the outline. For this property to have any effect the used skin requires to have a renderable named color
.
outline.color
or outline(id).color
(0, 0, 0)
<color name='outline.color' r='1' g='0' b='0'/>
Emissivity intensity of the outline. For this property to have any effect the used skin requires to have a renderable named intensity
.
outline.intensity
or outline(id).intensity
0
<float name='outline.intensity'>4</float>
Thickness of the outline. The measurement unit of this value depends on the outline type in the used skin. For this property to have any effect the used skin requires to have a renderable named thickness
.
outline.thickness
or outline(id).thickness
0.005
<float name='outline.thickness'>0.005</float>
This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace outline
with outline(id)
.
Set one or more outline parameters.
Parameter | Value | Description |
---|---|---|
visible | true,false | Show outline |
color | 3-component color | Set outline color |
intensity | float | Set outline intensity |
thickness | float | Set outline thickness |
This is an example of using this action:
<action name='outline.set'> <parameter name='visible'>true</parameter> </action>
Check one or more outline parameters. Action succeeds if all parameter value matches their respective outline parameter otherwise action fails. This action is typically used as first action in a sequence to run the sequence only if a outline parameter matches (or not).
Parameter | Value | Description |
---|---|---|
visible | true,false | Outline is visible 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='outline.check'> <parameter name='visible'>true</parameter> </action> <!-- actions here run only if outline is visible --> </sequence>
This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace outline
with outline(id)
.
Check one or more outline parameters. Conditions returns true if all parameter value match their respective outline parameter. This condition is typically used to run an action or sequence of actions as long as outline conditions are true.
Parameter | Value | Description |
---|---|---|
outline.visible | true,false | Outline is visible or not |
This is an example of using this condition:
<action name='myAction' id='doing something'> <parameter name='outline.visible'>true</parameter> <condition>outline.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 outline
with outline(id)
.
Outline is now visible.
Outline is now invisible.
This behavior does support element class to be persistable (setPersistable).
Since DragonScript Module Version 1.1
class ExampleElementClass extends BehaviorElementClass public var ECBehaviorComponent component public var ECBehaviorCollider collider public var ECBehaviorOutline outline public func new() super("ExampleElement") // add required behaviors component and collider component = ECBehaviorComponent.new(this) collider = ECBehaviorCollider.new(this, component) // create outline behavior and set parameters. the outline will be colored red // and has a thickness of 0.0075 using a custom ''outline.deskin" skin outline = ECBehaviorOutline.new(this, component, collider) outline.getSkin().setPath(''outline.deskin") outline.getColor().setColor(Color.red) outline.getThickness().setValue(0.0075) 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='ECBehaviorComponent'/> <behavior type='ECBehaviorCollider'/> <behavior type='ECBehaviorOutline'> <!-- optional: use component with id instead of empty string --> <string name='component'>second</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> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.model'>outline.demodel</string> </behavior> <!-- for adding multiple behaviors use unique identifiers --> <behavior type='ECBehaviorOutline' id='second'/> </elementClass>