Drag[en]gine Script Module DragonScript  1.21
Dragengine.Scenery.ECBehaviorRenderableCustomColor Class Reference

Behavior element behavior using ECBehaviorCustomColor on ECBehaviorDynamicSkin. More...

Inheritance diagram for Dragengine.Scenery.ECBehaviorRenderableCustomColor:
Dragengine.Scenery.DefaultECBehavior Dragengine.Scenery.ECBehavior Dragengine.Scenery.BehaviorCompatiblePersistency

Classes

class  Instance
 Behavior instance. More...
 

Public Member Functions

ECBehaviorInstance createInstance (BehaviorElement element)
 Create Behavior instance. More...
 
void dispose ()
 Dispose of behavior. More...
 
ECBehaviorCustomColor getCustomColor ()
 Custom color behavior. More...
 
ECBehaviorDynamicSkin getDynamicSkin ()
 Dynamic skin behavior. More...
 
ECPImage getImage ()
 Image to use. More...
 
ECPString getRenderable ()
 Name of renderable to create or empty string if not used. More...
 
ECBehaviorRenderableCanvas getRenderableCanvas ()
 Renderable canvas behavior. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorDynamicSkin dynamicSkin, String renderable)
 Create behavior element class. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorDynamicSkin dynamicSkin, String renderable, String id)
 Create behavior element class. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorDynamicSkin dynamicSkin, String renderable, String id, String prefix)
 Create behavior element class. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorRenderableCanvas renderableCanvas, String pathImage)
 Create behavior element class. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorRenderableCanvas renderableCanvas, String pathImage, String id)
 Create behavior element class. More...
 
ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorRenderableCanvas renderableCanvas, String pathImage, String id, String prefix)
 Create behavior element class. More...
 
- Public Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
void assignInstanceIndex (int instanceIndex)
 Assign instance index. More...
 
String getBehaviorID ()
 Unique identifier of behavior. More...
 
String getID ()
 Identifier. More...
 
int getInstanceIndex ()
 Instance index. More...
 
void loadSupportedData (String identifier, PersistencyEnvironment env, FileReader reader, ECBehaviorInstance instance)
 Load instance data of another behavior. More...
 
bool supportsBehaviorID (String identifier)
 Behavior supports loading instance data of another behavior. More...
 

Protected Member Functions

ECBehaviorRenderableCustomColor new (BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorDynamicSkin dynamicSkin, String renderable, ECBehaviorRenderableCanvas renderableCanvas, String pathImage, String id, String prefix)
 Create behavior element class. More...
 
- Protected Member Functions inherited from Dragengine.Scenery.DefaultECBehavior
DefaultECBehavior new (BehaviorElementClass eclass)
 Create default composeable behavior with empty identifier. More...
 
DefaultECBehavior new (BehaviorElementClass eclass, String id)
 Create default composeable behavior. More...
 
void setBehaviorID (String identifier)
 Set behavior identifier. More...
 
void useClassNameAsBehaviorID ()
 Set behavior identifier to "<class-name>:<identifier>". More...
 
void useFullyQualifiedClassNameAsBehaviorID ()
 Set behavior identifier to "<fully-qualified-class-name>:<identifier>". More...
 

Detailed Description

Behavior element behavior using ECBehaviorCustomColor on ECBehaviorDynamicSkin.

This behavior applies the chosen color of an ECBehaviorCustomColor either directly to a color type renderable or indirectly to a canvas type renderable.

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

Multi Texture Mode (Using Color Type Renderable)

If no ECBehaviorRenderableCanvas is provided a color type renderable is created and the chosen collor assigned to it.

This mode of operation is best used for models using individual textures for each part to colorize. This is the fastest solution.

The following example creates an element class with two custom colors each affecting an individual skin texture:

class MyElement extends BehaviorElementClass
public func new()
var ECBehaviorComponent component = ECBehaviorComponent.new(this)
var ECBehaviorDynamicSkin dynamicSkin = ECBehaviorDynamicSkin.new(this, component)
// add first color tinting texture named "texture1"
var ECBehaviorCustomColor color1 = ECBehaviorCustomColor.new(this, "color1", "Color 1", Color.blue)
ECBehaviorRenderableCustomColor.new(this, "color1", color1, dynamicSkin, "texture1" )
// add second color tinting texture named "texture2"
var ECBehaviorCustomColor color2 = ECBehaviorCustomColor.new(this, "color2", "Color 2", Color.red)
ECBehaviorRenderableCustomColor.new(this, "color2", color2, dynamicSkin, "texture2" )
end
end
ECBehaviorRenderableCustomColor new(BehaviorElementClass eclass, ECBehaviorCustomColor customColor, ECBehaviorDynamicSkin dynamicSkin, String renderable)
Create behavior element class.
Single Texture Mode (Using ECBehaviorRenderableCanvas)

If ECBehaviorRenderableCanvas is provided a CanvasImage is added to the canvas view. The color transform of the CanvasImage is set to the chosen color.

This mode of operation is best used for models with a single texture to colorized in a pixel-precise way. Multiple ECBehaviorCustomColor can then affect the same model texture each colorizing a precisely defined area of the texture.

The image has to be a grayscale image with optional alpha channel. Typically the image contains black-and-white pixels to enable or disable colorizing for in individual image parts but can be full grayscale to apply blending of chosen color. If the image also contains an alpha channel then the grayscale content of the image is multiplied by the color with the alpha channel defining how much the final color affects the result. Hence grayscale image without alpha channel apply flat colorization while grayscale images with alpha channel applied shaded colorization.

The order of adding ECBehaviorRenderableCustomColor to element classes is important. Behaviors added later are layered ontop of behaviors added earlier. This is especially useful for blending custom colors to get good results.

It is recommended to set the background color or image of ECBehaviorRenderableCanvas. This ensures all pixels in the texture are properly set.

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 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 following example creates an element class with two custom colors each applying one layer of tint to a texture with:

class MyElement extends BehaviorElementClass
public func new()
var ECBehaviorComponent component = ECBehaviorComponent.new(this)
var ECBehaviorDynamicSkin dynamicSkin = ECBehaviorDynamicSkin.new(this, component)
// add renderable canvas for texture named "texture"
//
var ECBehaviorRenderableCanvas renderable = ECBehaviorRenderableCanvas.new(this, dynamicSkin)
renderable.getRenderable().setValue("texture")
// the background color is set to white which applies no tinting. hence by default
// the texture is not tinted unless any custom color is not white
renderable.getBackgroundColor().setColor(Color.white)
// set the size of the renderable. this size usually matches the size of the mask
// images assigned to the custom colors
renderable.getSize().setPoint(Point.new(512, 512))
// add first color
var ECBehaviorCustomColor color1 = ECBehaviorCustomColor.new(this, "color1", "Color 1", Color.blue)
ECBehaviorRenderableCustomColor.new(this, "color1", color1, renderable )
// add second color
var ECBehaviorCustomColor color2 = ECBehaviorCustomColor.new(this, "color2", "Color 2", Color.red)
ECBehaviorRenderableCustomColor.new(this, "color2", color2, renderable )
end
end
ECPString getRenderable()
Name of renderable to create or empty string if not used.
Persistency

This behavior does not require the element class to be persistable (setPersistable).

Member Function Documentation

◆ createInstance()

ECBehaviorInstance Dragengine.Scenery.ECBehaviorRenderableCustomColor.createInstance ( BehaviorElement  element)

Create Behavior instance.

Implements Dragengine.Scenery.ECBehavior.

◆ dispose()

void Dragengine.Scenery.ECBehaviorRenderableCustomColor.dispose ( )

Dispose of behavior.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ getCustomColor()

ECBehaviorCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.getCustomColor ( )

Custom color behavior.

◆ getDynamicSkin()

ECBehaviorDynamicSkin Dragengine.Scenery.ECBehaviorRenderableCustomColor.getDynamicSkin ( )

Dynamic skin behavior.

◆ getImage()

ECPImage Dragengine.Scenery.ECBehaviorRenderableCustomColor.getImage ( )

Image to use.

◆ getRenderable()

ECPString Dragengine.Scenery.ECBehaviorRenderableCustomColor.getRenderable ( )

Name of renderable to create or empty string if not used.

◆ getRenderableCanvas()

ECBehaviorRenderableCanvas Dragengine.Scenery.ECBehaviorRenderableCustomColor.getRenderableCanvas ( )

Renderable canvas behavior.

◆ new() [1/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorDynamicSkin  dynamicSkin,
String  renderable 
)

Create behavior element class.

◆ new() [2/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorDynamicSkin  dynamicSkin,
String  renderable,
ECBehaviorRenderableCanvas  renderableCanvas,
String  pathImage,
String  id,
String  prefix 
)
protected

Create behavior element class.

◆ new() [3/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorDynamicSkin  dynamicSkin,
String  renderable,
String  id 
)

Create behavior element class.

◆ new() [4/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorDynamicSkin  dynamicSkin,
String  renderable,
String  id,
String  prefix 
)

Create behavior element class.

◆ new() [5/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorRenderableCanvas  renderableCanvas,
String  pathImage 
)

Create behavior element class.

◆ new() [6/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorRenderableCanvas  renderableCanvas,
String  pathImage,
String  id 
)

Create behavior element class.

◆ new() [7/7]

ECBehaviorRenderableCustomColor Dragengine.Scenery.ECBehaviorRenderableCustomColor.new ( BehaviorElementClass  eclass,
ECBehaviorCustomColor  customColor,
ECBehaviorRenderableCanvas  renderableCanvas,
String  pathImage,
String  id,
String  prefix 
)

Create behavior element class.


The documentation for this class was generated from the following file: