User Tools

Site Tools


dragengine:modules:dragonscript:behavior_outline

This is an old revision of the document!


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.

Instance Counts

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. To use multiple instances use code like this in your subclass constructor:

class MyElement extends BehaviorElementClass
  public var ECBehaviorComponent component
  public var ECBehaviorCollider collider
  
  public func new()
    component = ECBehaviorComponent.new(this)
    collider = ECBehaviorCollider.new(this, component)
    ECBehaviorOutline.new(this, component, collider)
    ECBehaviorOutline.new(this, component, collider, "secondOutline")
  end
end

Element Class Properties

Element class properties have the prefix outline{(id)}..

skin

Path to skin to use to render the outline.

  • Full name: “outline{(id)}.skin”
  • Type ECPSkin
  • Default Value “/shareddata/materials/outlined.deskin”
  • Example (*.deeclass)
    <string name='outline.skin'>outline.deskin</string>

model

Path to model to use instead of the model of the dependency component

  • Full name: “outline{(id)}.model”
  • Type ECPModel
  • Default value null
  • Example (*.deeclass)
    <string name='outline.model'>outline.demodel</string>

rig

Path to rig to use instead of the rig of the dependency component. If null uses the dependency component rig.

  • Full name: “outline{(id)}.rig”
  • Type ECPRig
  • Default value null
  • Example (*.deeclass)
    <string name='outline.rig'>outline.derig</string>

color

Color of the outline. For this property to have any effect the used skin requires to have a renderable named “color”.

  • Full name: “outline{(id)}.color”
  • Type ECPColor
  • Default value white (1, 1, 1)
  • Example (*.deeclass)
    <color name='outline.color' r='1' g='0' b='0'/>

intensity

Emissivity intensity of the outline. For this property to have any effect the used skin requires to have a renderable named “intensity”.

  • Full name: “outline{(id)}.intensity”
  • Type ECPFloat
  • Minimum Value 0
  • Default value 0
  • Example (*.deeclass)
    <float name='outline.intensity'>4</float>

thickness

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”.

  • Full name: “outline{(id)}.thickness”
  • Type ECPFloat
  • Minimum Value 0
  • Default value 0.005
  • Example (*.deeclass)
    <float name='outline.thickness'>0.005</float>

Required Behaviors

Optional Behaviors

Thie behavior does not support optional behaviors.

Persistency

This behavior does support element class to be persistable (setPersistable). Saves color, intensity and visiblity state.

API Documentation

ECBehaviorOutline Since API 1.1

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_outline.1590282292.txt.gz · Last modified: 2020/05/24 01:04 by dragonlord