{{tag>dragonscript behavior}} [[: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]] >> **ECBehaviorComponent** * [[behaviors_use_cases|Behaviors Explained: By Use-Case]] * [[behaviors_a_to_z|Behaviors Explained: From A to Z]] ====== ECBehaviorComponent ====== Behavior element behavior adding component support. Components provide visual appearance to elements. If the [[behavior_collider|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 [[behavior_collider|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: * [[gamedev:deigde:editors:skin|IGDE Skin Editor]] * [[tools:blenderexportscripts|Blender3D Export Scripts]] ====== Instance Counts ====== 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 ====== Element class properties have the prefix ''component.'' or ''component({id}).'' if id is not empty. ===== model ===== Set path of model resource to use. * Full name: ''component.model'' or ''component({id}).model'' * Type: string * Default Value: empty string * Expected File Type: ''*.demodel'' * Example (*.deeclass) box.demodel ===== skin ===== Set path of skin resource to use. * Full name: ''component.skin'' or ''component({id}).skin'' * Type: string * Default Value: empty string * Expected File Type: ''*.deskin'' * Example (*.deeclass) box.deskin ===== rig ===== Set path of rig resource to use. * Full name: ''component.rig'' or ''component({id}).rig'' * Type: string * Default Value: empty string * Expected File Type: ''*.derig'' * Example (*.deeclass) box.derig ===== occlusionMesh ===== Set path of occlusion mesh resource to use. * Full name: ''component.occlusionMesh'' or ''component({id}).occlusionMesh'' * Type: string * Default Value: empty string * Expected File Type: ''*.deoccmesh'' * Example (*.deeclass) box.deoccmesh ===== audioModel ===== Set path of audio model resource to use. * Full name: ''component.audioModel'' or ''component({id}).audioModel'' * Type: string * Default Value: empty string * Expected File Type: ''*.demodel'' * Example (*.deeclass) box.demodel ===== renderEnvMap ===== Set if component is rendered in environment maps. * Full name: ''component.renderEnvMap'' or ''component({id}).renderEnvMap'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== affectsAudio ===== Set if component is affecting audio. * Full name: ''component.affectsAudio'' or ''component({id}).affectsAudio'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== hintMovement ===== Set movement hint. * Full name: ''component.hintMovement'' or ''component({id}).hintMovement'' * Type: enumeration * 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.| * Default Value: ''stationary'' * Example (*.deeclass) dynamic ===== enableGI ===== Set enable GI in graphic module if supported. * Full name: ''component.enableGI'' or ''component({id}).enableGI'' * Type: boolean * Default Value: true * Example (*.deeclass) false ===== hintGIImportance ===== 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. * Full name: ''component.hintGIImportance'' or ''component({id}).hintGIImportance'' * Type: integer * Default Value: 4 * Restriction: At least 0 and at most 4 * Example (*.deeclass) 3 ===== textureReplacements ===== Set texture replacements. * Full name: ''component.textureReplacements'' or ''component({id}).textureReplacements'' * Type: map * Default Value: 4 * Restriction: At least 0 and at most 4 * Example (*.deeclass) different_material.deskin 90 ====== Events ====== This behavior has no events. ====== Required Behaviors ====== This behavior requires no other behaviors. ====== Optional Behaviors ====== * [[behavior_collider|ECBehaviorCollider]]: Attaches component to collider if set. ====== Persistency ====== This behavior does not require the element class to be persistable (setPersistable). ====== API Documentation ====== #@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorComponent.html,ECBehaviorComponent~@#. Since DragonScript Module Version **1.0** ====== Use Cases ====== * Add visual presence to element. ====== Element Class Example ====== 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 ====== Behavior Factory ====== Using element class supporting adding behaviors the behavior can be added like this: Use Case 1: Shape Collision dynamic 0 1 0 1 0 1 box.demodel Use Case 2: Component Collision. ... second dynamic ====== Live Examples ====== * [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]