User Tools

Site Tools


dragengine:modules:dragonscript:behavior_renderablecustomcolor

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_renderablecustomcolor [2020/12/20 23:09] – [ECBehaviorRenderableCustomColor] dragonlorddragengine:modules:dragonscript:behavior_renderablecustomcolor [2025/03/13 17:12] (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]] >> **ECBehaviorRenderableCustomColor**+[[: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]] >> **ECBehaviorRenderableCustomColor**
 </WRAP> </WRAP>
  
Line 8: Line 8:
  
 ====== ECBehaviorRenderableCustomColor ====== ====== ECBehaviorRenderableCustomColor ======
 +
 +<WRAP center 100%>
 +<WRAP center box 450px>
 +{{youtube>Gte74Jte8A0?medium}}
 +<WRAP centeralign>Behavior in action</WRAP>
 +</WRAP>
 +</WRAP>
  
 Behavior element behavior using [[behavior_customcolor|ECBehaviorCustomColor]] on [[behavior_dynamicskin|ECBehaviorDynamicSkin]]. This behavior applies the chosen color of an [[behavior_customcolor|ECBehaviorCustomColor]] either directly to a color type [[gamedev:renderables|renderable]] or indirectly to a canvas type [[gamedev:renderables|renderable]]. Behavior element behavior using [[behavior_customcolor|ECBehaviorCustomColor]] on [[behavior_dynamicskin|ECBehaviorDynamicSkin]]. This behavior applies the chosen color of an [[behavior_customcolor|ECBehaviorCustomColor]] either directly to a color type [[gamedev:renderables|renderable]] or indirectly to a canvas type [[gamedev:renderables|renderable]].
  
 This behavior differs from using [[gamedev:textureproperties:color_tint|color.tint]] texture property. The [[gamedev:textureproperties:color_tint|color.tint]] texture property colorizes one texture of an object and thus requires models to be split up into individual parts assigned to individual textures. The Single Texture Mode outlined below works similar to this texture property. This behavior though allows to colorize individual pixels of a single texture. Think of adding a tribal tattoo to an actor you would like to colorize independent of the skin tone. This behavior differs from using [[gamedev:textureproperties:color_tint|color.tint]] texture property. The [[gamedev:textureproperties:color_tint|color.tint]] texture property colorizes one texture of an object and thus requires models to be split up into individual parts assigned to individual textures. The Single Texture Mode outlined below works similar to this texture property. This behavior though allows to colorize individual pixels of a single texture. Think of adding a tribal tattoo to an actor you would like to colorize independent of the skin tone.
-====== Multi Texture Mode (Using Color Type Renderable ======+ 
 +See also: 
 +  * [[gamedev:renderables|Dynamic Content using Renderables]] 
 +  * [[gamedev:deigde:editors:skin|IGDE Skin Editor]] 
 + 
 +===== Multi Texture Mode (Color Type Renderable=====
  
 If no [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] is provided a color type [[gamedev:renderables|renderable]] is created and the chosen collor assigned to it. If no [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] is provided a color type [[gamedev:renderables|renderable]] is created and the chosen collor assigned to it.
Line 18: Line 30:
 This mode of operation is best used for models using individual textures for each part to colorize. This is the fastest solution. This mode of operation is best used for models using individual textures for each part to colorize. This is the fastest solution.
  
-====== Single Texture Mode (Using [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]]=====+===== Single Texture Mode (ECBehaviorRenderableCanvas) ====
  
 If [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] is provided a [[gamedev:canvassystem:image|canvas image]] is added to the [[gamedev:canvassystem:view|canvas view]]. The color transform of the [[gamedev:canvassystem:image|canvas image]] is set to the chosen color. If [[behavior_renderablecanvas|ECBehaviorRenderableCanvas]] is provided a [[gamedev:canvassystem:image|canvas image]] is added to the [[gamedev:canvassystem:view|canvas view]]. The color transform of the [[gamedev:canvassystem:image|canvas image]] is set to the chosen color.
Line 32: Line 44:
 The advantage of using this mode is that you can layer any number of custom colors onto a texture easily. The advantage of using this mode is that you can layer any number of custom colors onto a texture easily.
  
-The disadvantage is that graphic modules have to render the [[gamedev:renderables|renderable]] from the canvas view before it can be used for rendering the component. If many elements use this kind of colorizing the GPU memory consumption can be high. Graphic modules know about this and can release dynamic texture content. Nevertheless it is good to keep this in mind.+The disadvantage is that graphic modules have to render the renderable from the canvas view before it can be used for rendering the component. If many elements use this kind of colorizing the GPU memory consumption can be high. Graphic modules know about this and can release dynamic texture content. Nevertheless it is good to keep this in mind.
  
 ====== Instance Counts ====== ====== Instance Counts ======
Line 40: Line 52:
 ====== Element Class Properties ====== ====== Element Class Properties ======
  
-Element class properties have the prefix **renderableCustomColor.** or **renderableCustomColor(id).** if id is not empty.+Element class properties have the prefix ''renderableCustomColor.'' or ''renderableCustomColor(id).'' if id is not empty.
  
 ===== renderable ===== ===== renderable =====
-Name of the [[gamedev:renderables|renderable]] in the component skin to modify. This is used for the Multi Texture Mode. Requires a [[behavior_dynamicskin|ECBehaviorDynamicSkin]] assigned to the ECBehaviorRenderableCustomColor. +Name of the renderable in the component skin to modify. This is used for the Multi Texture Mode. Requires a [[behavior_dynamicskin|ECBehaviorDynamicSkin]] assigned to the ECBehaviorRenderableCustomColor. 
-  * Full name: "renderableCustomColor.renderableor "renderableCustomColor(id).renderable"+  * Full name: ''renderableCustomColor.renderable'' or ''renderableCustomColor(id).renderable''
   * Type: string   * Type: string
-  * Default Value: "" (empty string)+  * Default Value: empty string
   * Example (*.deeclass): <code xml><string name='renderableCustomColor.renderable'>skin</string></code>   * Example (*.deeclass): <code xml><string name='renderableCustomColor.renderable'>skin</string></code>
  
 ===== image ===== ===== image =====
 Image to use for Single Texture Mode. Requires a [[behavior_renderablecanvas||ECBehaviorRenderableCanvas]] assigned to the ECBehaviorRenderableCustomColor. Image can be grayscale for flat mode or grayscale with alpha channel for colorized mode. Image to use for Single Texture Mode. Requires a [[behavior_renderablecanvas||ECBehaviorRenderableCanvas]] assigned to the ECBehaviorRenderableCustomColor. Image can be grayscale for flat mode or grayscale with alpha channel for colorized mode.
-  * Full name: "renderableCustomColor.imageor "renderableCustomColor(id).image" +  * Full name: ''renderableCustomColor.image'' or ''renderableCustomColor(id).image'' 
-  * Type: string (path to image resource)+  * Type: string
   * Default value: empty string   * Default value: empty string
 +  * File Pattern: ''*.webp'', ''*.png'', ''*.jpg'' (all image modules)
   * Example (*.deeclass): <code xml><string name='renderableCustomColor.image'>/content/model/player/colorBodyMask.png</string></code>   * Example (*.deeclass): <code xml><string name='renderableCustomColor.image'>/content/model/player/colorBodyMask.png</string></code>
  
Line 68: Line 81:
 ====== Persistency ====== ====== Persistency ======
  
-This behavior does not use persistency.+This behavior does not required element class to be persistable (setPersistable).
  
 ====== API Documentation ====== ====== API Documentation ======
  
-[[https://developer.dragondreams.ch/docs/dragonscript/scriptapi/latest/classDragengine_1_1Scenery_1_1ECBehaviorRenderablePanel.html|ECBehaviorRenderablePanel]].+#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorRenderablePanel.html,ECBehaviorRenderablePanel~@#.
  
-Since DragonScript Module Version **1.3**+Since DragonScript Module Version ''1.3''
  
 ====== Use Cases ====== ====== Use Cases ======
Line 129: Line 142:
   end   end
 end end
 +</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='ECBehaviorDynamicSkin'/>
 +  <behavior type='ECBehaviorCustomColor'/>
 +  <behavior type='ECBehaviorRenderableCanvas'/>
 +  
 +  <behavior type='ECBehaviorRenderableCustomColor'>
 +    <!-- optional: use custom color with id instead of empty string -->
 +    <string name='customColor'>second</string>
 +    
 +    <!-- optional: use renderable canvas with id instead of empty string -->
 +    <string name='renderableCanvas'>second</string>
 +    
 +    <!-- optional: use dynamic skin with id instead of empty string -->
 +    <string name='dynamicSkin'>second</string>
 +    
 +    <!-- set element properties. omit property prefix if used inside behavior tag -->
 +    <string name='.name'>Color 1</string>
 +  </behavior>
 +  
 +  <!-- for adding multiple behaviors use unique identifiers -->
 +  <behavior type='ECBehaviorRenderableCustomColor' id='second'/>
 +</elementClass>
 </code> </code>
  
dragengine/modules/dragonscript/behavior_renderablecustomcolor.1608505757.txt.gz · Last modified: 2020/12/20 23:09 by dragonlord