User Tools

Site Tools


dragengine:modules:dragonscript:behavior_outline

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
dragengine:modules:dragonscript:behavior_outline [2020/05/24 14:20] dragonlorddragengine:modules:dragonscript:behavior_outline [2025/03/13 17:13] (current) dragonlord
Line 1: Line 1:
 {{tag>dragonscript behavior}} {{tag>dragonscript behavior}}
 <WRAP youarehere> <WRAP youarehere>
-[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[abstractions#behavior_elementsquick_and_easy_development|Behavior Elements: Quick and Easy Development]] >> **ECBehaviorOutline**+[[:start|Start Page]] >> [[main|DragonScript Scripting Language]] >> [[dragengine:modules:dragonscript:abstractions|Abstraction Layers: How you want to build your Game]] >> [[dragengine:modules:dragonscript:behavior_elements|Behavior Elements]] >> **ECBehaviorOutline**
 </WRAP> </WRAP>
  
Line 24: 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.*skin texture properties to render the outline and "soliditywith value "0to hide everything but the outline.+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: A typical outline skin looks like this:
Line 41: Line 41:
 </code> </code>
  
-By default the skin "/shareddata/materials/outlined.deskinis used which is provided by the shared DragonScript Module data and provides tintable and emissive outlines.+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 "coloris also optional but recommended. This allows this behavior to change the outline color using a dynamic skin.+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 [[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 53: 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. To use multiple instances use code like this in your subclass constructor: +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.
-<code> +
-class MultiInstanceClass extends BehaviorElementClass +
-  public var ECBehaviorComponent component +
-  public var ECBehaviorCollider collider +
-   +
-  public func new() super("MultiInstance"+
-    component = ECBehaviorComponent.new(this) +
-    collider = ECBehaviorCollider.new(this, component) +
-    ECBehaviorOutline.new(this, component, collider) +
-    ECBehaviorOutline.new(this, component, collider, "secondOutline"+
-  end +
-end +
-</code>+
  
 ====== Element Class Properties ====== ====== Element Class Properties ======
  
-Element class properties have the prefix **outline.** or **outline(id).** if id is not empty.+Element class properties have the prefix ''outline.'' or ''outline(id).'' if id is not empty.
  
 ===== skin ===== ===== skin =====
 Path to skin to use to render the outline. Path to skin to use to render the outline.
-  * Full name: "outline.skinor "outline(id).skin" +  * Full name: ''outline.skin'' or ''outline(id).skin'' 
-  * Type skin path +  * Type: string 
-  * Default Value "/shareddata/materials/outlined.deskin"+  * Default Value: ''/shareddata/materials/outlined.deskin'' 
 +  * File Pattern: ''*.deskin'' (all skin modules)
   * Example (*.deeclass) <code xml><string name='outline.skin'>outline.deskin</string></code>   * Example (*.deeclass) <code xml><string name='outline.skin'>outline.deskin</string></code>
  
 ===== 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.modelor "outline(id).model" +  * Full name: ''outline.model'' or ''outline(id).model'' 
-  * Type model path +  * Type: string 
-  * Default value //null//+  * Default value: ''null'' 
 +  * FIle Pattern: ''*.demodel'' (all model modules)
   * Example (*.deeclass) <code xml><string name='outline.model'>outline.demodel</string></code>   * Example (*.deeclass) <code xml><string name='outline.model'>outline.demodel</string></code>
  
 ===== 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.rigor "outline(id).rig" +  * Full name: ''outline.rig'' or ''outline(id).rig'' 
-  * Type rig path +  * Type: String 
-  * Default value //null//+  * Default value: ''null'' 
 +  * File Pattern: ''*.derig'' (all rig modules)
   * Example (*.deeclass) <code xml><string name='outline.rig'>outline.derig</string></code>   * Example (*.deeclass) <code xml><string name='outline.rig'>outline.derig</string></code>
  
 ===== 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 ''color''
-  * Full name: "outline.coloror "outline(id).color" +  * Full name: ''outline.color'' or ''outline(id).color'' 
-  * Type color +  * Type: 3-component color 
-  * Default value //black (0, 0, 0)//+  * Default value: ''(0, 0, 0)''
   * Example (*.deeclass) <code xml><color name='outline.color' r='1' g='0' b='0'/></code>   * Example (*.deeclass) <code xml><color name='outline.color' r='1' g='0' b='0'/></code>
  
 ===== 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 ''intensity''
-  * Full name: "outline.intensityor "outline(id).intensity" +  * Full name: ''outline.intensity'' or ''outline(id).intensity'' 
-  * Type floating point +  * Typefloating point 
-  * Minimum Value +  * Default value: ''0'' 
-  * Default value 0+  * Restriction: At least 0
   * Example (*.deeclass) <code xml><float name='outline.intensity'>4</float></code>   * Example (*.deeclass) <code xml><float name='outline.intensity'>4</float></code>
  
 ===== 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 ''thickness''
-  * Full name: "outline.thicknessor "outline(id).thickness" +  * Full name: ''outline.thickness'' or ''outline(id).thickness'' 
-  * Type floating point +  * Typefloating point 
-  * Minimum Value 0 +  * Default value: ''0.005'' 
-  * Default value 0.005+  * Restrictions: At least 0
   * Example (*.deeclass) <code xml><float name='outline.thickness'>0.005</float></code>   * Example (*.deeclass) <code xml><float name='outline.thickness'>0.005</float></code>
  
 ====== Required Behaviors ====== ====== Required Behaviors ======
 +
   * [[behavior_component|ECBehaviorComponent]]   * [[behavior_component|ECBehaviorComponent]]
   * [[behavior_collider|ECBehaviorCollider]]   * [[behavior_collider|ECBehaviorCollider]]
Line 122: Line 113:
 ====== Optional Behaviors ====== ====== Optional Behaviors ======
  
-Thie behavior does not support optional behaviors.+This behavior does not support optional behaviors.
  
 ====== 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://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorOutline.html|ECBehaviorOutline]].+#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorOutline.html,ECBehaviorOutline~@#.
  
-Since DragonScript Module Version **1.1**+Since DragonScript Module Version ''1.1''
  
 ====== 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 151: Line 144:
            
      // 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 "outline.deskin" skin+     // and has a thickness of 0.0075 using a custom ''outline.deskin" skin
      outline = ECBehaviorOutline.new(this, component, collider)      outline = ECBehaviorOutline.new(this, component, collider)
-     outline.getSkin().setPath("outline.deskin")+     outline.getSkin().setPath(''outline.deskin")
      outline.getColor().setColor(Color.red)      outline.getColor().setColor(Color.red)
      outline.getThickness().setValue(0.0075)      outline.getThickness().setValue(0.0075)
Line 159: Line 152:
 end end
 </code> </code>
 +
 +====== Behavior Factory ======
 +
 +Using element class supporting adding behaviors the behavior can be added like this:
 +<code xml>
 +<?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>
 +    
 +    <!-- 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>
 +</code>
 +
 +====== Live Examples ======
 +
 +  * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]
 +
dragengine/modules/dragonscript/behavior_outline.1590330011.txt.gz · Last modified: 2020/05/24 14:20 by dragonlord