{{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]] >> **ECBehaviorCamera**
* [[behaviors_use_cases|Behaviors Explained: By Use-Case]]
* [[behaviors_a_to_z|Behaviors Explained: From A to Z]]
====== ECBehaviorCamera ======
Behavior element behavior adding camera support.
Behavior adds a Camera resource to the the behavior element. Creates a camera attached to the element collider which can be individually modified.
See also:
* [[gamedev:cameratonemap|Camera Tone Mapping]]
====== Instance Counts ======
This behavior can be added multiple times to an element. Use the behavior identifier to tell them apart.
====== Element Class Properties ======
Element class properties have the prefix ''camera.'' or ''camera({id}).'' if id is not empty.
===== position =====
Set position to attach resource to collider.
* Full name: ''camera.position'' or ''camera({id}).position''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== orientation =====
Set orientation to attach resource to collider in degrees.
* Full name: ''camera.orientation'' or ''camera({id}).orientation''
* Type: 3-component float vector
* Default Value: (0,0,0)
* Example (*.deeclass)
===== bone =====
Set bone to attach resource to. If empty string attach to collider.
* Full name: ''camera.bone'' or ''camera({id}).bone''
* Type: string
* Default Value: empty string
* Example (*.deeclass) attach
===== fov =====
Set vertical field of view in degrees for the entire view.
* Full name: ''camera.fov'' or ''camera({id}).fov''
* Type: float
* Default Value: 39.6
* Restriction: At least 0 and at most 180
* Example (*.deeclass) 60
===== fovRatio =====
Set aspect ratio of the horizontal field of view to the vertical field of view.
* Full name: ''camera.fovRatio'' or ''camera({id}).fovRatio''
* Type: float
* Default Value: 1
* Restriction: At least 0.1
* Example (*.deeclass) 1.5
===== imageDistance =====
Set distance to the image plane.
* Full name: ''camera.imageDistance'' or ''camera({id}).imageDistance''
* Type: float
* Default Value: 0.01
* Restriction: At least 0.001
* Example (*.deeclass) 0.1
===== viewDistance =====
Set viewing distance up to which world geometry is rendered.
* Full name: ''camera.viewDistance'' or ''camera({id}).viewDistance''
* Type: float
* Default Value: 200
* Restriction: At least 0.01
* Example (*.deeclass) 500
===== enableHDRR =====
Set enable high definition range rendering (HDRR) if supported.
* Full name: ''camera.enableHDRR'' or ''camera({id}).enableHDRR''
* Type: boolean
* Default Value: true
* Example (*.deeclass) false
===== exposure =====
Set exposure.
* Full name: ''camera.exposure'' or ''camera({id}).exposure''
* Type: float
* Default Value: 1
* Restriction: 0
* Example (*.deeclass) 1.5
===== lowestIntensity =====
Set lowest intensity the eye can adapt to.
* Full name: ''camera.lowestIntensity'' or ''camera({id}).lowestIntensity''
* Type: float
* Default Value: 1
* Restriction: 0
* Example (*.deeclass) 10
===== highestIntensity =====
Set highest intensity the eye can adapt to.
* Full name: ''camera.highestIntensity'' or ''camera({id}).highestIntensity''
* Type: float
* Default Value: 20
* Restriction: 0
* Example (*.deeclass) 25
===== adaptionTime =====
Set adaption time of the eye in seconds.
* Full name: ''camera.adaptionTime'' or ''camera({id}).adaptionTime''
* Type: float
* Default Value: 0.1
* Restriction: 0
* Example (*.deeclass) 25
===== enableGI =====
Set enable global illumination (GI) if supported.
* Full name: ''camera.enableGI'' or ''camera({id}).enableGI''
* Type: boolean
* Default Value: Engine.getDefaultEnableGI()
* Example (*.deeclass) false
===== pathParameters =====
Set path to camera parameters file (''*.decamera'') to use. If not empty path the settings override the manual settings.
* Full name: ''camera.pathParameters'' or ''camera({id}).pathParameters''
* Type: string
* Default Value: empty string
* Example (*.deeclass) default.decamera
====== Events ======
This behavior has no events.
====== Required Behaviors ======
This behavior requires no other behaviors.
====== Optional Behaviors ======
* [[behavior_collider|ECBehaviorCollider]]: Attaches camera to collider if set.
====== Persistency ======
This behavior does require the element class to be persistable (setPersistable).
====== API Documentation ======
#@LinkApiDocDEDS2_HTML~classDragengine_1_1Scenery_1_1ECBehaviorCamera.html,ECBehaviorCamera~@#.
Since DragonScript Module Version **1.0**
====== Use Cases ======
* Attach camera to element which can be rendered to nearby elements (for example weapon scope).
====== Element Class Example ======
This example defines an element which contain a camera.
class MyElement extends BehaviorElementClass
public var ECBehaviorCollider collider
public var ECBehaviorCamera camera
public func new()
collider = ECBehaviorCollider.new(this)
camera = ECBehaviorCamera.new(this, collider)
camera.getAttach().getPosition().setVector(Vector.new(0, 0, 0.1))
camera.getViewDistance().setValue(300)
camera.getPathParameters().setValue("/content/cameras/scope.decamera")
end
end
====== Behavior Factory ======
Using element class supporting adding behaviors the behavior can be added like this:
0 1 4
300
...
====== Live Examples ======
* [[https://github.com/LordOfDragons/deexamples|DEExamples Repository]]