This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
dragengine:modules:dragonscript:behavior_outline [2020/05/24 14:06] – dragonlord | dragengine:modules:dragonscript:behavior_outline [2025/05/04 13:46] (current) – [outline.check] dragonlord | ||
---|---|---|---|
Line 1: | Line 1: | ||
{{tag> | {{tag> | ||
<WRAP youarehere> | <WRAP youarehere> | ||
- | [[: | + | [[: |
</ | </ | ||
+ | |||
+ | * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] | ||
+ | * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] | ||
====== ECBehaviorOutline ====== | ====== ECBehaviorOutline ====== | ||
Line 21: | Line 24: | ||
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. | 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.*" | + | The outline skin is set by the user. To work properly it has to use the '' |
A typical outline skin looks like this: | A typical outline skin looks like this: | ||
Line 38: | Line 41: | ||
</ | </ | ||
- | By default the skin "/ | + | By default the skin '' |
- | The emissivity is optional and allows to make the outline glow in the dark. Using renderable | + | The emissivity is optional and allows to make the outline glow in the dark. Using renderable |
This set up allows to add an outline skin to any [[behavior_component|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 set up allows to add an outline skin to any [[behavior_component|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. | ||
Line 50: | Line 53: | ||
====== Instance Counts ====== | ====== 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. | + | 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. |
- | < | + | |
- | class MultiInstanceClass extends BehaviorElementClass | + | |
- | public var ECBehaviorComponent component | + | |
- | public var ECBehaviorCollider collider | + | |
- | + | ||
- | public func new() super(" | + | |
- | component = ECBehaviorComponent.new(this) | + | |
- | collider = ECBehaviorCollider.new(this, | + | |
- | ECBehaviorOutline.new(this, | + | |
- | ECBehaviorOutline.new(this, | + | |
- | end | + | |
- | end | + | |
- | </ | + | |
====== Element Class Properties ====== | ====== Element Class Properties ====== | ||
- | Element class properties have the prefix | + | Element class properties have the prefix |
===== skin ===== | ===== skin ===== | ||
Path to skin to use to render the outline. | Path to skin to use to render the outline. | ||
- | * Full name: "outline.skin" | + | * Full name: '' |
- | * Type skin path | + | * Type: string |
- | * Default Value "/ | + | * Default Value: '' |
+ | * File Pattern: '' | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== model ===== | ===== model ===== | ||
Path to model to use instead of the model of the dependency component | Path to model to use instead of the model of the dependency component | ||
- | * Full name: "outline.model" | + | * Full name: '' |
- | * Type model path | + | * Type: string |
- | * Default value //null// | + | * Default value: '' |
+ | * FIle Pattern: '' | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== rig ===== | ===== rig ===== | ||
Path to rig to use instead of the rig of the dependency component. If null uses the dependency component rig. | Path to rig to use instead of the rig of the dependency component. If null uses the dependency component rig. | ||
- | * Full name: "outline.rig" | + | * Full name: '' |
- | * Type rig path | + | * Type: String |
- | * Default value //null// | + | * Default value: '' |
+ | * File Pattern: '' | ||
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== color ===== | ===== color ===== | ||
- | Color of the outline. For this property to have any effect the used skin requires to have a renderable named "color". | + | Color of the outline. For this property to have any effect the used skin requires to have a renderable named '' |
- | * Full name: "outline.color" | + | * Full name: '' |
- | * Type color | + | * Type: 3-component |
- | * Default value // | + | * Default value: '' |
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== intensity ===== | ===== intensity ===== | ||
- | Emissivity intensity of the outline. For this property to have any effect the used skin requires to have a renderable named "intensity". | + | Emissivity intensity of the outline. For this property to have any effect the used skin requires to have a renderable named '' |
- | * Full name: "outline.intensity" | + | * Full name: '' |
- | * Type floating point | + | * Type: floating point |
- | * Minimum Value 0 | + | * Default value: '' |
- | * Default value 0 | + | * Restriction: |
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
===== thickness ===== | ===== 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". | + | 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 '' |
- | * Full name: "outline.thickness" | + | * Full name: '' |
- | * Type floating point | + | * Type: floating point |
- | * Minimum Value 0 | + | * Default value: '' |
- | * Default value 0.005 | + | * Restrictions: |
* Example (*.deeclass) <code xml>< | * Example (*.deeclass) <code xml>< | ||
+ | |||
+ | ====== Behavior Tree Actions ====== | ||
+ | |||
+ | This behavior adds these behavior tree actions if behavior tree is present. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== outline.set ===== | ||
+ | |||
+ | Set one or more outline parameters. | ||
+ | |||
+ | ^Parameter^Value^Description^ | ||
+ | |visible|true, | ||
+ | |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: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ===== outline.check ===== | ||
+ | |||
+ | 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, | ||
+ | |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: | ||
+ | <code xml> | ||
+ | < | ||
+ | <action name=' | ||
+ | < | ||
+ | </ | ||
+ | <!-- actions here run only if outline is visible --> | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Behavior Tree Conditions ====== | ||
+ | |||
+ | This behavior adds these behavior tree conditions if behavior tree is present. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== outline.check ===== | ||
+ | |||
+ | 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, | ||
+ | |||
+ | This is an example of using this condition: | ||
+ | <code xml> | ||
+ | <action name=' | ||
+ | < | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== State Machine Actions ====== | ||
+ | |||
+ | Same as [[# | ||
+ | |||
+ | ====== State Machine Conditions ====== | ||
+ | |||
+ | Same as [[# | ||
+ | |||
+ | ====== State Machine Events ====== | ||
+ | |||
+ | This behavior sends these state machine events. If behavior has non-empty identifier replace '' | ||
+ | |||
+ | ===== outline.visible ===== | ||
+ | |||
+ | Outline is now visible. | ||
+ | |||
+ | ===== outline.invisible ===== | ||
+ | |||
+ | Outline is now invisible. | ||
====== Required Behaviors ====== | ====== Required Behaviors ====== | ||
+ | |||
* [[behavior_component|ECBehaviorComponent]] | * [[behavior_component|ECBehaviorComponent]] | ||
* [[behavior_collider|ECBehaviorCollider]] | * [[behavior_collider|ECBehaviorCollider]] | ||
Line 119: | Line 191: | ||
====== Optional Behaviors ====== | ====== Optional Behaviors ====== | ||
- | Thie behavior | + | * [[behavior_behaviortree|ECBehaviorBehaviorTree]]: |
+ | * [[behavior_statemachine|ECBehaviorStateMachine]]: | ||
====== Persistency ====== | ====== Persistency ====== | ||
- | This behavior does support element class to be persistable (setPersistable). Saves color, intensity and visiblity state. | + | This behavior does support element class to be persistable (setPersistable). |
====== API Documentation ====== | ====== API Documentation ====== | ||
- | [[https:// | + | # |
- | Since DragonScript Module Version | + | Since DragonScript Module Version |
====== Use Cases ====== | ====== Use Cases ====== | ||
+ | |||
* Highlight objects player can interact with. Combine this with [[behavior_lookedat|ECBehaviorLookedAt]] using a listening to show/hide the highlight if the player looks at the object. | * Highlight objects player can interact with. Combine this with [[behavior_lookedat|ECBehaviorLookedAt]] using a listening to show/hide the highlight if the player looks at the object. | ||
* Use for Toon-Rendering to draw a black outline on all objects. | * Use for Toon-Rendering to draw a black outline on all objects. | ||
+ | |||
====== Element Class Example ====== | ====== Element Class Example ====== | ||
Line 148: | Line 222: | ||
// create outline behavior and set parameters. the outline will be colored red | // create outline behavior and set parameters. the outline will be colored red | ||
- | // and has a thickness of 0.0075 using a custom | + | // and has a thickness of 0.0075 using a custom |
| | ||
- | | + | |
| | ||
| | ||
Line 156: | Line 230: | ||
end | end | ||
</ | </ | ||
+ | |||
+ | ====== Behavior Factory ====== | ||
+ | |||
+ | Using element class supporting adding behaviors the behavior can be added like this: | ||
+ | <code xml> | ||
+ | <?xml version=' | ||
+ | < | ||
+ | < | ||
+ | < | ||
+ | | ||
+ | < | ||
+ | <!-- optional: use component with id instead of empty string --> | ||
+ | <string name=' | ||
+ | | ||
+ | <!-- optional: use behavior tree with id instead of empty string --> | ||
+ | <string name=' | ||
+ | | ||
+ | <!-- optional: use state machine with id instead of empty string --> | ||
+ | <string name=' | ||
+ | | ||
+ | <!-- set element properties. omit property prefix if used inside behavior tag --> | ||
+ | <string name=' | ||
+ | </ | ||
+ | | ||
+ | <!-- for adding multiple behaviors use unique identifiers --> | ||
+ | < | ||
+ | </ | ||
+ | </ | ||
+ | |||
+ | ====== Live Examples ====== | ||
+ | |||
+ | * [[https:// | ||
+ |