Drag[en]gine Script Module DragonScript  1.23
Dragengine.Scenery.ECBehaviorComponent Class Reference

Behavior element behavior adding component support. More...

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

Classes

class  Instance
 Behavior instance. More...
 

Public Member Functions

void addTextureReplacement (String name, String pathSkin)
 Helper method to quickly add a texture replacement. More...
 
void addTextureReplacement (String name, String pathSkin, Color tint)
 
void addTextureReplacement (String name, String pathSkin, Vector2 tcScale)
 
void addTextureReplacement (String name, String pathSkin, Vector2 tcScale, Color tint)
 
void dispose ()
 Dispose of behavior. More...
 
ECBehaviorCollider getCollider ()
 Collider behavior. More...
 
ECComposeComponent getComponent ()
 Composeable component for element class. More...
 
Instance instance (BehaviorElement element)
 Get instance in element from owner element class. More...
 
ECBehaviorComponent new (BehaviorElementClass eclass, ECBehaviorCollider collider)
 Create behavior element class. More...
 
ECBehaviorComponent new (BehaviorElementClass eclass, ECBehaviorCollider collider, String id)
 
ECBehaviorComponent new (BehaviorElementClass eclass, ECBehaviorCollider collider, String id, String prefix)
 
void setAllPath (String directory, String model, String skin, String rig, String occlusionMesh, String audioModel)
 Helper method to quickly set model, skin, rig, occlusion mesh and audio model path located in the same directory. More...
 
void setAllPath (String model, String skin, String rig, String occlusionMesh, String audioModel)
 Helper method to quickly set model, skin, rig, occlusion mesh and audio model path. More...
 
void setCommonPath (String directory, String model, String skin, String rig)
 Helper method to quickly set model, skin and rig path located in the same directory. More...
 
void setCommonPath (String model, String skin, String rig)
 Helper method to quickly set model, skin and rig path. 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...
 
- Public Member Functions inherited from Dragengine.Scenery.ECBehavior
ECBehaviorInstance createInstance (BehaviorElement element)
 Create Behavior instance. More...
 

Static Public Member Functions

static ECBehaviorComponent getBehaviorIn (BehaviorElementClass eclass)
 Get behavior in element class or null if absent. More...
 

Protected Member Functions

ECPTextureReplacementList createTextureReplacements (String propertyName)
 Create texture replacements property. 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 adding component support.

Components provide visual appearance to elements. This behavior can be added multiple times to an element. Each instance creates one component attached to the element collider which can be individually modified. To distinguish the components each instance has an identifier which can be used to retrieve a specific instance. The identifier is also used as prefix for element class properties and stub properties if not empty. Hence to use more than one component use code like this in your subclass constructor:

class MyElement extends BehaviorElementClass
public func new()
ECBehaviorComponent.new(this, null)
ECBehaviorComponent.new(this, null, "subComponent")
end
end
ECBehaviorComponent new(BehaviorElementClass eclass, ECBehaviorCollider collider)
Create behavior element class.

You can now define the model to use for both components using the properties "model" for the first component and "subComponent.model" for the second component.

If the ECBehaviorCollider behavior is present in the behavior element before this behavior is added the component is statically attached. In this case the collider is a ColliderVolume and the rig assigned to the component is only used for animation purpose.

If the ECBehaviorCollider behavior is added after this behavior then a ColliderComponent is created. In this case the component is implicitly attached by ECBehaviorCollider and the component rig is used for collision detection. This is required if you intend to use per-bone collisions matching animation state or physical simulations like rag-dolls.

Hence these two use cases are possible depending on the order the behaviors are added:

Use Case 1: Shape Collision

Component is only visual. For collision only static collision shape is used. The component is attached statically to the collider and does not collide. If collider is dynamic physics simulation will be done using collision shape only.

class MyElementClass extends BehaviorElementClass
public func new()
var ECBehaviorCollider collider = ECBehaviorCollider.new(this, null)
// assign collision shape or collision rig to the collider
ECBehaviorComponent.new(this, collider)
end
end
Use Case 2: Component Collision

Component is used for collision detection. If collider is dynamic component bones will be updated by the collider automatically.

class MyElementClass extends BehaviorElementClass
public func new()
var ECBehaviorComponent component = ECBehaviorComponent.new(this, null)
ECBehaviorCollider.new(this, component)
end
end

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

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

Member Function Documentation

◆ addTextureReplacement() [1/4]

void Dragengine.Scenery.ECBehaviorComponent.addTextureReplacement ( String  name,
String  pathSkin 
)

Helper method to quickly add a texture replacement.

Replaces calls like this:

var TextureReplacement replacement = TextureReplacement.new("texture name")
replacement.setPath("/path/to/material.deskin")
replacement.setColorTint(Color.new(1, 0.8, 0.5))
componentBehavior.getComponent().getTextureReplacements().getList().add(replacement)

◆ addTextureReplacement() [2/4]

void Dragengine.Scenery.ECBehaviorComponent.addTextureReplacement ( String  name,
String  pathSkin,
Color  tint 
)

◆ addTextureReplacement() [3/4]

void Dragengine.Scenery.ECBehaviorComponent.addTextureReplacement ( String  name,
String  pathSkin,
Vector2  tcScale 
)

◆ addTextureReplacement() [4/4]

void Dragengine.Scenery.ECBehaviorComponent.addTextureReplacement ( String  name,
String  pathSkin,
Vector2  tcScale,
Color  tint 
)

◆ createTextureReplacements()

ECPTextureReplacementList Dragengine.Scenery.ECBehaviorComponent.createTextureReplacements ( String  propertyName)
protected

Create texture replacements property.

◆ dispose()

void Dragengine.Scenery.ECBehaviorComponent.dispose ( )

Dispose of behavior.

Reimplemented from Dragengine.Scenery.DefaultECBehavior.

◆ getBehaviorIn()

static ECBehaviorComponent Dragengine.Scenery.ECBehaviorComponent.getBehaviorIn ( BehaviorElementClass  eclass)
static

Get behavior in element class or null if absent.

Use this method to check if a particular BehaviorElementClass contains a behavior of type ECBehaviorCollider.

◆ getCollider()

ECBehaviorCollider Dragengine.Scenery.ECBehaviorComponent.getCollider ( )

Collider behavior.

◆ getComponent()

ECComposeComponent Dragengine.Scenery.ECBehaviorComponent.getComponent ( )

Composeable component for element class.

◆ instance()

Instance Dragengine.Scenery.ECBehaviorComponent.instance ( BehaviorElement  element)

Get instance in element from owner element class.

◆ new() [1/3]

ECBehaviorComponent Dragengine.Scenery.ECBehaviorComponent.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider 
)

Create behavior element class.

These values are optional and can be null: collider.

◆ new() [2/3]

ECBehaviorComponent Dragengine.Scenery.ECBehaviorComponent.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
String  id 
)

◆ new() [3/3]

ECBehaviorComponent Dragengine.Scenery.ECBehaviorComponent.new ( BehaviorElementClass  eclass,
ECBehaviorCollider  collider,
String  id,
String  prefix 
)

◆ setAllPath() [1/2]

void Dragengine.Scenery.ECBehaviorComponent.setAllPath ( String  directory,
String  model,
String  skin,
String  rig,
String  occlusionMesh,
String  audioModel 
)

Helper method to quickly set model, skin, rig, occlusion mesh and audio model path located in the same directory.

directory is not required to end with a slash. model, skin, rig, occlusionMesh and audioModel can be relative or absolute path. If absolute directory is not used.

Set path will be:

  • "directory/model" or "model" if model is absolute path
  • "directory/skin" or "skin" if skin is absolute path
  • "directory/rig" or "rig" if rig is absolute path
  • "directory/occlusionMesh" or "occlusionMesh" if occlusionMesh is absolute path
  • "directory/audioModel" or "audioModel" if audioModel is absolute path

If model, skin, rig, occlusionMesh or audioModel are null the respective path is not set.

◆ setAllPath() [2/2]

void Dragengine.Scenery.ECBehaviorComponent.setAllPath ( String  model,
String  skin,
String  rig,
String  occlusionMesh,
String  audioModel 
)

Helper method to quickly set model, skin, rig, occlusion mesh and audio model path.

If model, skin, rig, occlusionMesh or audioModel are null the respective path is not set.

◆ setCommonPath() [1/2]

void Dragengine.Scenery.ECBehaviorComponent.setCommonPath ( String  directory,
String  model,
String  skin,
String  rig 
)

Helper method to quickly set model, skin and rig path located in the same directory.

directory is not required to end with a slash. model, skin and rig can be relative or absolute path. If absolute directory is not used.

Set path will be:

  • "directory/model" or "model" if model is absolute path
  • "directory/skin" or "skin" if skin is absolute path
  • "directory/rig" or "rig" if rig is absolute path

If model, skin or rig are null the respective path is not set.

◆ setCommonPath() [2/2]

void Dragengine.Scenery.ECBehaviorComponent.setCommonPath ( String  model,
String  skin,
String  rig 
)

Helper method to quickly set model, skin and rig path.

If model, skin or rig are null the respective path is not set.


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