Show / Hide Table of Contents

Class Camera

Use this in a SceneNode to create a Camera Node. A the Projection and View matrices, generated from a CameraComponent will overwrite calls you made directly on the RenderContext.

Inheritance
System.Object
SceneComponent
Camera
Implements
IComponent
Inherited Members
SceneComponent.Name
SceneComponent.Active
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.ToString()
Namespace: Fusee.Engine.Core.Scene
Assembly: Fusee.Engine.Core.dll
Syntax
public class Camera : SceneComponent, IComponent

Constructors

Camera(ProjectionMethod, Single, Single, Single, RenderLayers)

Creates a new instance of type CameraComponent.

Declaration
public Camera(ProjectionMethod projectionMethod, float zNear, float zFar, float fovY, RenderLayers renderLayer = RenderLayers.All)
Parameters
Type Name Description
ProjectionMethod projectionMethod

The projection method. See ProjectionMethod.

System.Single zNear

The near clipping plane. See ClippingPlanes.

System.Single zFar

The far clipping plane. See ClippingPlanes.

System.Single fovY

The vertical field of view in radians.

RenderLayers renderLayer

The RenderLayers for this camera

Fields

BackgroundColor

The background color for this camera's viewport.

Declaration
public float4 BackgroundColor
Field Value
Type Description
float4

ClearColor

Is true per default. If set to false, the color bit won't be cleared before this camera is rendered. Set this to false if the background color should be transparent.

Declaration
public bool ClearColor
Field Value
Type Description
System.Boolean

ClearDepth

Is true per default. If set to false, the depth bit won't be cleared before this camera is rendered.

Declaration
public bool ClearDepth
Field Value
Type Description
System.Boolean

ClippingPlanes

Distance to the near (x value) and far (y value) clipping planes.

Declaration
public float2 ClippingPlanes
Field Value
Type Description
float2

CustomCameraUpdate

Allows to overwrite the calculation of the projection matrix. E.g. if ProjectionMethod does not contain your desired projection calculation. Is null by default. This delegate enables us to add a custom projection method. If we choose to use this delegate we need to provide a method that calculates a projection matrix and outputs a Viewport in percent in the range [0, 100]. Note that this is optional but if this delegate is not null its out values (Projection matrix and Viewport) will overwrite the ones calculated from the other camera parameters.

Declaration
public CustomCameraUpdate CustomCameraUpdate
Field Value
Type Description
CustomCameraUpdate

Fov

The vertical (y) field of view in radians.

Declaration
public float Fov
Field Value
Type Description
System.Single

FrustumCullingOn

Determines whether frustum culling is enabled for this camera or not. Note that only Meshs with a initialized (non zero-sized) bounding box (BoundingBox) can be culled.

Declaration
public bool FrustumCullingOn
Field Value
Type Description
System.Boolean

Layer

If there is more than one CameraComponent in one scene, the rendered output of the camera with a higher layer will be drawn above the output of a camera with a lower layer.

Declaration
public int Layer
Field Value
Type Description
System.Int32

ProjectionMethod

You can choose from a set of projection methods. At the moment we can choose between perspective and orthographic. This will automatically calculate the correct projection matrix.

Declaration
public ProjectionMethod ProjectionMethod
Field Value
Type Description
ProjectionMethod

RenderLayer

Sets the RenderLayer for this camera.

Declaration
public RenderLayers RenderLayer
Field Value
Type Description
RenderLayers

RenderTexture

The texture given here will be used as render target. If this is not null the output gets rendered into the texture, otherwise to the screen.

Declaration
public IWritableTexture RenderTexture
Field Value
Type Description
IWritableTexture

Scale

Scales the orthographic viewing frustum. Doesn't have an effect if Perspective is used.

Declaration
public float Scale
Field Value
Type Description
System.Single

Viewport

The output is rendered to the section of the application window defined by the Viewport values: The viewport in percent [0, 100]. x: start y: end z: width w: height

Declaration
public float4 Viewport
Field Value
Type Description
float4

Methods

GetProjectionMat(Int32, Int32, out float4)

Calculates and returns the projection matrix.

Declaration
public float4x4 GetProjectionMat(int canvasWidthPx, int canvasHeightPx, out float4 viewport)
Parameters
Type Name Description
System.Int32 canvasWidthPx

The width of the render canvas.

System.Int32 canvasHeightPx

The height of the render canvas.

float4 viewport

The viewport that gets rendered with the resulting projection matrix. Given in pixel. This is used in lower levels to set Viewport(Int32, Int32, Int32, Int32)

Returns
Type Description
float4x4

GetViewportInPx(Int32, Int32)

Returns the viewport in px as float4. x: start pixel in x direction. y: start pixel in y direction. z: width of the viewport. w: height of the viewport.

Declaration
public float4 GetViewportInPx(int canvasWidthPx, int canvasHeightPx)
Parameters
Type Name Description
System.Int32 canvasWidthPx
System.Int32 canvasHeightPx
Returns
Type Description
float4

Implements

IComponent
Generated by DocFX
GitHub Repo
Back to top