User Tools

Site Tools


dragengine:modules:dragonscript:behavior_camera

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:

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)
    <vector name='camera.position' x='0' y='0' z='0.1'/>

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)
    <vector name='camera.orientation' x='30' y='0' z='0'/>

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)
    <string name='camera.bone'>attach</string>

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)
    <float name='camera.fov'>60</value>

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)
    <float name='camera.fovRatio'>1.5</value>

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)
    <float name='camera.imageDistance'>0.1</value>

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)
    <float name='camera.viewDistance'>500</value>

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)
    <float name='camera.enableHDRR'>false</value>

exposure

Set exposure.

  • Full name: camera.exposure or camera({id}).exposure
  • Type: float
  • Default Value: 1
  • Restriction: 0
  • Example (*.deeclass)
    <float name='camera.exposure'>1.5</value>

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)
    <float name='camera.lowestIntensity'>10</value>

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)
    <float name='camera.highestIntensity'>25</value>

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)
    <float name='camera.adaptionTime'>25</value>

enableGI

Set enable global illumination (GI) if supported.

  • Full name: camera.enableGI or camera({id}).enableGI
  • Type: boolean
  • Default Value: Engine.getDefaultEnableGI()
  • Example (*.deeclass)
    <float name='camera.enableGI'>false</value>

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)
    <string name='camera.pathParameters'>default.decamera</string>

Events

This behavior has no events.

Required Behaviors

This behavior requires no other behaviors.

Optional Behaviors

Persistency

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

API Documentation

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:

<?xml version='1.0' encoding='UTF-8'?>
<elementClass name='MyClass' class='GenericBehaviorElement'>
  <behavior type='ECBehaviorCamera'>
    <!-- optional: set layer mask (default empty). list of bits to set. -->
    <string name='layerMask'>0 1 4</string>
 
    <!-- set element properties. omit property prefix if used inside behavior tag -->
    <float name='.viewDistance'>300</float>
  </behavior>
 
  <!-- for adding multiple behaviors use unique identifiers -->
  <behavior type='ECBehaviorCamera' id='second'>
    ...
  </behavior>
</elementClass>

Live Examples

You could leave a comment if you were logged in.
dragengine/modules/dragonscript/behavior_camera.txt · Last modified: 2025/03/12 19:35 by dragonlord