Start Page » DragonScript Scripting Language » Behavior Elements: Quick and Easy Development » ECBehaviorComponent
Behavior element behavior adding component support.
Components provide visual appearance to elements.
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: Shape Collision, Component Collision. See element_class_example.
See also:
This behavior can be added multiple times to an element. Each instance creates one component which can be individually modified. Use the behavior identifier to tell them apart.
Element class properties have the prefix component.
or component({id}).
if id is not empty.
Set path of model resource to use.
component.model
or component({id}).model
*.demodel
<string name='component.model'>box.demodel</string>
Set path of skin resource to use.
component.skin
or component({id}).skin
*.deskin
<string name='component.skin'>box.deskin</string>
Set path of rig resource to use.
component.rig
or component({id}).rig
*.derig
<string name='component.rig'>box.derig</string>
Set path of occlusion mesh resource to use.
component.occlusionMesh
or component({id}).occlusionMesh
*.deoccmesh
<string name='component.occlusionMesh'>box.deoccmesh</string>
Set path of audio model resource to use.
component.audioModel
or component({id}).audioModel
*.demodel
<string name='component.audioModel'>box.demodel</string>
Set if component is rendered in environment maps.
component.renderEnvMap
or component({id}).renderEnvMap
<boolean name='component.renderEnvMap'>false</boolean>
Set if component is affecting audio.
component.affectsAudio
or component({id}).affectsAudio
<boolean name='component.affectsAudio'>false</boolean>
Set movement hint.
component.hintMovement
or component({id}).hintMovement
Allowed Values:
Value | Description |
---|---|
stationary | Component remains static for the entire lifetime. |
jittering | Component remains mostly static jittering in a small area. |
dynamic | Component moves around freely. |
stationary
<string name='component.hintMovement'>dynamic</string>
Set enable GI in graphic module if supported.
component.enableGI
or component({id}).enableGI
<boolean name='component.enableGI'>false</boolean>
Set GI important hint. Value is in the range from 0 (very unimportant) to 4 (very important). This hint can be used by the graphic module to improve performance by excluding components with a GI important below a user chosen threashold.
component.hintGIImportance
or component({id}).hintGIImportance
<integer name='component.hintGIImportance'>3</integer>
Set texture replacements.
component.textureReplacements
or component({id}).textureReplacements
Example (*.deeclass)
<map name='component.textureReplacements'> <!-- define texture replacement with unique identifier 'material' --> <map key='material'> <!-- optional: path to skin to replace texture with --> <string key='skin'>different_material.deskin</string> <!-- optional: apply tinting to material. requires color type renderable named 'tint' --> <color key='tint' r='0.5' g='0.8' b='1'/> <!-- optional: transform texture coordinates --> <map key='transform'> <!-- optional: texture coordinate scaling with center of texture as origin --> <vector2 key='scale' x='2' y='2'/> <!-- optional: texture coordinate rotation with center of texture as pivot point --> <float key='rotate'>90</float> <!-- optional: texture coordinate translation --> <vector2 key='translate' x='0.5' y='0'/> </map> </map> </map>
This behavior has no events.
This behavior requires no other behaviors.
This behavior does not require the element class to be persistable (setPersistable).
Since DragonScript Module Version 1.0
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 var ECBehaviorCollider collider public var ECBehaviorComponent component func new() collider = ECBehaviorCollider.new(this, null) // assign collision shape or collision rig to the collider component = 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 var ECBehaviorCollider collider public var ECBehaviorComponent component func new() component = ECBehaviorComponent.new(this, null) collider = ECBehaviorCollider.new(this, component) end end
Using element class supporting adding behaviors the behavior can be added like this:
Use Case 1: Shape Collision
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <behavior type='ECBehaviorCollider'> <!-- no behavior has been added before so no component behavior will be used --> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.physicsType'>dynamic</string> </behavior> <!-- adding the component will detect the previously added collider and use it --> <behavior type='ECBehaviorComponent'> <!-- optional: set layer mask as list of bits to set. default is '0' which means BaseGameApp.WorldLayerBit.default --> <string name='layerMask'>0 1</string> <!-- optional: set render env map layer mask as list of bits to set. default is '1' which means BaseGameApp.WorldLayerBit.envmap . if 'renderEnvMap' is true this layer mask is OR combined with 'layerMask' --> <string name='layerMaskRenderEnvMap'>0 1</string> <!-- optional: set audio layer mask as list of bits to set. default is '2' which means BaseGameApp.WorldLayerBit.audio . if 'affectsAudio' is true this layer mask is OR combined with 'layerMask' --> <string name='layerMaskAffectsAudio'>0 1</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.model'>box.demodel</string> </behavior> </elementClass>
Use Case 2: Component Collision.
<?xml version='1.0' encoding='UTF-8'?> <elementClass name='MyClass' class='GenericBehaviorElement'> <!-- no collider is present yet so component will not use any collider --> <behavior type='ECBehaviorComponent'> ... </behavior> <behavior type='ECBehaviorCollider'> <!-- optional: by default the previously added component is detected and used. to use a different component add one with a different id and use the id here --> <string name='component'>second</string> <!-- set element properties. omit property prefix if used inside behavior tag --> <string name='.physicsType'>dynamic</string> </behavior> </elementClass>