CameraComponentclass

Every scene should have at least one Camera.

objectComponentCameraComponent
Namespace
Sandbox
Assembly
Sandbox.Engine
Declaration
public sealed class Sandbox.CameraComponent : Sandbox.Component

Constructors1

Showing 1 constructors

Methods26

Showing 26 methods

public void AddCommandList(Sandbox.Rendering.CommandList buffer, Sandbox.Rendering.Stage stage, int order = 0)PUBLIC

Add a command list to the render

ParameterTypeDescription
bufferCommandList
stageStage
order = 0int
Returns:void

public System.IDisposable AddHookAfterOpaque(string debugName, int order, System.Action`1<Sandbox.SceneCamera> renderEffect)PUBLICOBSOLETE

Obsolete: Use CommandList

ParameterTypeDescription
debugNamestring
orderint
renderEffectAction<SceneCamera>
Returns:IDisposable

public System.IDisposable AddHookAfterTransparent(string debugName, int order, System.Action`1<Sandbox.SceneCamera> renderEffect)PUBLICOBSOLETE

Obsolete: Use CommandList

ParameterTypeDescription
debugNamestring
orderint
renderEffectAction<SceneCamera>
Returns:IDisposable

public System.IDisposable AddHookAfterUI(string debugName, int order, System.Action`1<Sandbox.SceneCamera> renderEffect)PUBLICOBSOLETE

Obsolete: Use CommandList

ParameterTypeDescription
debugNamestring
orderint
renderEffectAction<SceneCamera>
Returns:IDisposable

public System.IDisposable AddHookBeforeOverlay(string debugName, int order, System.Action`1<Sandbox.SceneCamera> renderEffect)PUBLICOBSOLETE

Obsolete: Use CommandList

ParameterTypeDescription
debugNamestring
orderint
renderEffectAction<SceneCamera>
Returns:IDisposable

public Sandbox.Rect BBoxToScreenPixels(BBox bounds, bool isBehind)PUBLIC

Given a BBox in world space, will return the screen space rect that totally contains the box.

ParameterTypeDescription
boundsBBox
isBehindbool
Returns:Rect

public Matrix CalculateObliqueMatrix(Sandbox.Plane clipPlane)PUBLIC

Calculates a projection matrix with an oblique clip-plane defined in world space.

ParameterTypeDescription
clipPlanePlane
Returns:Matrix

public bool RenderToTexture(Sandbox.Texture target, Sandbox.Rendering.ViewSetup config = null)PUBLIC

Render scene to a texture from this camera's point of view

ParameterTypeDescription
targetTexture
config = nullViewSetup
Returns:bool

public virtual void Reset()PUBLICVIRTUAL

Returns:void

public Ray ScreenNormalToRay(Vector3 normalPosition)PUBLIC

ParameterTypeDescription
normalPositionVector3
Returns:Ray

public Ray ScreenPixelToRay(Vector2 pixelPosition)PUBLIC

ParameterTypeDescription
pixelPositionVector2
Returns:Ray

public Vector3 ScreenToWorld(Vector2 screen)PUBLIC

Convert from screen coords to world coords on the near frustum plane.

ParameterTypeDescription
screenVector2
Returns:Vector3

public void UpdateSceneCamera(Sandbox.SceneCamera camera, bool includeTags = True)PUBLICPER-FRAME

Update a SceneCamera with the settings from this component

ParameterTypeDescription
cameraSceneCamera
includeTags = Truebool
Returns:void

Properties26

Showing 26 properties

public Color Sandbox.CameraComponent.BackgroundColor { get; set; }PUBLICGETSET

The background color of this camera's view if there's no 2D Sky in the scene.

Returns:Color

public System.Nullable`1<Matrix> Sandbox.CameraComponent.CustomProjectionMatrix { get; set; }PUBLICGETSET

Allows specifying a custom projection matrix for this camera

Returns:Nullable<Matrix>

public System.Nullable`1<Vector2> Sandbox.CameraComponent.CustomSize { get; set; }PUBLICGETSET

Allows specifying a custom aspect ratio for this camera. By default (or when null) the camera size is screen size or render target size.

Returns:Nullable<Vector2>

public bool Sandbox.CameraComponent.EnablePostProcessing { get; set; }PUBLICGETSET

Enable or disable post processing for this camera.

Returns:bool

public float Sandbox.CameraComponent.FieldOfView { get; set; }PUBLICGETSET

The field of view of this camera.

Returns:float

public Sandbox.Rendering.HudPainter Sandbox.CameraComponent.Hud { get; set; }PUBLICGETSET

Allows drawing on the camera. This is drawn before the post processing.

Returns:HudPainter

public bool Sandbox.CameraComponent.IsMainCamera { get; set; }PUBLICGETSET

Returns true if this is the main game camera.

Returns:bool

public bool Sandbox.CameraComponent.Orthographic { get; set; }PUBLICGETSET

Whether or not to use orthographic projection instead of perspective.

Returns:bool

public float Sandbox.CameraComponent.OrthographicHeight { get; set; }PUBLICGETSET

The orthographic size for this camera while `Sandbox.CameraComponent.Orthographic` is set to true.

Returns:float

public Sandbox.Rendering.HudPainter Sandbox.CameraComponent.Overlay { get; set; }PUBLICGETSET

Used to draw to the screen. This is drawn on top of everything, so is good for debug overlays etc.

Returns:HudPainter

public Sandbox.GameObject Sandbox.CameraComponent.PostProcessAnchor { get; set; }PUBLICGETSET

If set then we'll trigger post process volumes from this position, instead of the camera's position.

Returns:GameObject

public int Sandbox.CameraComponent.Priority { get; set; }PUBLICGETSET

The priority of this camera. Dictates which camera gets rendered on top of another. Higher means it'll be rendered on top.

Returns:int

public Sandbox.TagSet Sandbox.CameraComponent.RenderExcludeTags { get; set; }PUBLICGETSET

A list of tags that will be checked to exclude specific game objects when rendering this camera.

Returns:TagSet

public Sandbox.TagSet Sandbox.CameraComponent.RenderTags { get; set; }PUBLICGETSET

A list of tags that will be checked to include specific game objects when rendering this camera. If none are set, it will include everything.

Returns:TagSet

public Sandbox.Rect Sandbox.CameraComponent.ScreenRect { get; set; }PUBLICGETSET

The size of the viewport, in screen coordinates

Returns:Rect

public Sandbox.StereoTargetEye Sandbox.CameraComponent.TargetEye { get; set; }PUBLICGETSET

The HMD eye that this camera is targeting. Use `Sandbox.StereoTargetEye.None` for the user's monitor (i.e. the companion window).

Returns:StereoTargetEye

public Vector4 Sandbox.CameraComponent.Viewport { get; set; }PUBLICGETSET

The size of the camera represented on the screen. Normalized between 0 and 1.

Returns:Vector4

public bool Sandbox.CameraComponent.WireframeMode { get; set; }PUBLICGETSET

Render this camera using a wireframe view.

Returns:bool

public float Sandbox.CameraComponent.ZFar { get; set; }PUBLICGETSET

The camera's far clip plane distance. This is the furthest distance this camera will be able to render. This value totally depends on the game you're making. Shorter the better, sensible ranges would be between about 1000 and 30000, but if you want it to be further out you can balance that out by making ZNear larger.

Returns:float

public float Sandbox.CameraComponent.ZNear { get; set; }PUBLICGETSET

The camera's near clip plane distance. This is the closest distance this camera will be able to render. A good value for this is about 5. Below 5 and particularly below 1 you're going to start to see a lot of artifacts like z-fighting.

Returns:float

On this page

Constructorspublic CameraComponent()Methodspublic System.Void AddCommandList(Sandbox.Rendering.CommandList buffer, Sandbox.Rendering.Stage stage, System.Int32 order = 0)public System.IDisposable AddHookAfterOpaque(System.String debugName, System.Int32 order, System.Action`1<Sandbox.SceneCamera> renderEffect)public System.IDisposable AddHookAfterTransparent(System.String debugName, System.Int32 order, System.Action`1<Sandbox.SceneCamera> renderEffect)public System.IDisposable AddHookAfterUI(System.String debugName, System.Int32 order, System.Action`1<Sandbox.SceneCamera> renderEffect)public System.IDisposable AddHookBeforeOverlay(System.String debugName, System.Int32 order, System.Action`1<Sandbox.SceneCamera> renderEffect)public Sandbox.Rect BBoxToScreenPixels(BBox bounds, System.Boolean isBehind)public Matrix CalculateObliqueMatrix(Sandbox.Plane clipPlane)public System.Void ClearCommandLists()public System.Void ClearCommandLists(Sandbox.Rendering.Stage stage)public Sandbox.Frustum GetFrustum()public Sandbox.Frustum GetFrustum(Sandbox.Rect screenRect, Vector3 screenSize)public Sandbox.Frustum GetFrustum(Sandbox.Rect screenRect)public Vector2 PointToScreenNormal(Vector3 worldPosition, System.Boolean isBehind)public Vector2 PointToScreenNormal(Vector3 worldPosition)public Vector2 PointToScreenPixels(Vector3 worldPosition, System.Boolean isBehind)public Vector2 PointToScreenPixels(Vector3 worldPosition)public System.Void RemoveCommandList(Sandbox.Rendering.CommandList buffer, Sandbox.Rendering.Stage stage)public System.Void RemoveCommandList(Sandbox.Rendering.CommandList buffer)public System.Void RenderToBitmap(Sandbox.Bitmap targetBitmap, System.Boolean renderUI)public System.Void RenderToBitmap(Sandbox.Bitmap targetBitmap)public System.Boolean RenderToTexture(Sandbox.Texture target, Sandbox.Rendering.ViewSetup config = null)public virtual System.Void Reset()public Ray ScreenNormalToRay(Vector3 normalPosition)public Ray ScreenPixelToRay(Vector2 pixelPosition)public Vector3 ScreenToWorld(Vector2 screen)public System.Void UpdateSceneCamera(Sandbox.SceneCamera camera, System.Boolean includeTags = True)Propertiespublic Sandbox.CameraComponent.AutoExposureSetup Sandbox.CameraComponent.AutoExposure { get; set; }public Color Sandbox.CameraComponent.BackgroundColor { get; set; }public Sandbox.ClearFlags Sandbox.CameraComponent.ClearFlags { get; set; }public System.Nullable`1<Matrix> Sandbox.CameraComponent.CustomProjectionMatrix { get; set; }public System.Nullable`1<Vector2> Sandbox.CameraComponent.CustomSize { get; set; }public Sandbox.SceneCameraDebugMode Sandbox.CameraComponent.DebugMode { get; set; }public System.Boolean Sandbox.CameraComponent.EnablePostProcessing { get; set; }public System.Single Sandbox.CameraComponent.FieldOfView { get; set; }public Sandbox.CameraComponent.Axis Sandbox.CameraComponent.FovAxis { get; set; }public Sandbox.Rendering.HudPainter Sandbox.CameraComponent.Hud { get; set; }public System.Boolean Sandbox.CameraComponent.IsMainCamera { get; set; }public System.Boolean Sandbox.CameraComponent.Orthographic { get; set; }public System.Single Sandbox.CameraComponent.OrthographicHeight { get; set; }public Sandbox.Rendering.HudPainter Sandbox.CameraComponent.Overlay { get; set; }public Sandbox.GameObject Sandbox.CameraComponent.PostProcessAnchor { get; set; }public System.Int32 Sandbox.CameraComponent.Priority { get; set; }public Matrix Sandbox.CameraComponent.ProjectionMatrix { get; set; }public Sandbox.TagSet Sandbox.CameraComponent.RenderExcludeTags { get; set; }public Sandbox.TagSet Sandbox.CameraComponent.RenderTags { get; set; }public Sandbox.Texture Sandbox.CameraComponent.RenderTarget { get; set; }public Sandbox.Rect Sandbox.CameraComponent.ScreenRect { get; set; }public Sandbox.StereoTargetEye Sandbox.CameraComponent.TargetEye { get; set; }public Vector4 Sandbox.CameraComponent.Viewport { get; set; }public System.Boolean Sandbox.CameraComponent.WireframeMode { get; set; }public System.Single Sandbox.CameraComponent.ZFar { get; set; }public System.Single Sandbox.CameraComponent.ZNear { get; set; }Metadata