Stride

OPEN / CLOSE
  • Features
  • Blog
  • Documentation
  • Community
(icon) Download

  • Discord
  • Facebook
  • Twitter
  • YouTube

LANGUAGE

OPEN / CLOSE
  • English
  • 日本語
    Show / Hide Table of Contents

    CameraComponent Class

    Namespace: Stride.Engine
    Assembly: Stride.Engine.dll

    Describes the camera projection and view.

    System.Object → EntityComponent → ActivableEntityComponent → CameraComponent
    Derived from CameraComponent:

    [DataContract("CameraComponent")]
    [Display("Camera", null, Expand = ExpandRule.Once)]
    [DefaultEntityComponentProcessor(typeof(CameraProcessor))]
    [ComponentOrder(13000)]
    [ObjectFactory(typeof(CameraComponent.Factory))]
    public sealed class CameraComponent : ActivableEntityComponent, IIdentifiable
    Name Description
    Constructors
    CameraComponent()

    Create a new CameraComponent instance.

    CameraComponent(Single, Single)

    Create a new CameraComponent instance with the provided target, near plane and far plane.

    Fields
    DefaultAspectRatio
    DefaultFarClipPlane
    DefaultNearClipPlane
    DefaultOrthographicSize
    DefaultVerticalFieldOfView
    Frustum

    The frustum extracted from the view projection matrix calculated automatically after calling Update() method.

    ProjectionMatrix

    Gets or sets the local projection matrix. See remarks.

    Slot
    ViewMatrix

    Gets or sets the local view matrix. See remarks.

    ViewProjectionMatrix

    The view projection matrix calculated automatically after calling Update() method.

    Properties
    ActuallyUsedAspectRatio

    Gets the last used aspect ratio.

    AspectRatio

    Gets or sets the custom aspect ratio.

    FarClipPlane

    Gets or sets the far plane distance.

    Name
    NearClipPlane

    Gets or sets the near plane distance.

    OrthographicSize

    Gets or sets the height of the orthographic projection.

    Projection

    Gets or sets the projection.

    UseCustomAspectRatio

    Gets or sets a value indicating whether to use a custom AspectRatio. Default is false, meaning that the aspect ratio is calculated from the ratio of the current viewport when rendering.

    UseCustomProjectionMatrix

    Gets or sets a value indicating whether to use custom ProjectionMatrix. Default is false

    UseCustomViewMatrix

    Gets or sets a value indicating whether to use custom ViewMatrix. Default is false

    VerticalFieldOfView

    Gets or sets the vertical field of view in degrees.

    Methods
    Update()

    Calculates the projection matrix and view matrix.

    Update(Nullable<Single>)

    Calculates the projection matrix and view matrix.

    | Improve this Doc View Source

    Constructors


    CameraComponent()

    Create a new CameraComponent instance.

    public CameraComponent()

    CameraComponent(Single, Single)

    Create a new CameraComponent instance with the provided target, near plane and far plane.

    public CameraComponent(float nearClipPlane, float farClipPlane)
    Parameters
    Type Name Description
    System.Single nearClipPlane

    The near plane value

    System.Single farClipPlane

    The far plane value

    | Improve this Doc View Source

    Fields


    DefaultAspectRatio

    public const float DefaultAspectRatio = 1.77777779F
    Field Value
    Type Description
    System.Single

    DefaultFarClipPlane

    public const float DefaultFarClipPlane = 1000F
    Field Value
    Type Description
    System.Single

    DefaultNearClipPlane

    public const float DefaultNearClipPlane = 0.1F
    Field Value
    Type Description
    System.Single

    DefaultOrthographicSize

    public const float DefaultOrthographicSize = 10F
    Field Value
    Type Description
    System.Single

    DefaultVerticalFieldOfView

    public const float DefaultVerticalFieldOfView = 45F
    Field Value
    Type Description
    System.Single

    Frustum

    The frustum extracted from the view projection matrix calculated automatically after calling Update() method.

    public BoundingFrustum Frustum
    Field Value
    Type Description
    BoundingFrustum

    ProjectionMatrix

    Gets or sets the local projection matrix. See remarks.

    public Matrix ProjectionMatrix
    Field Value
    Type Description
    Matrix

    The local projection matrix.

    Remarks

    This value is updated when calling Update() or is directly used when UseCustomViewMatrix is true.


    Slot

    [DataMember(50)]
    public SceneCameraSlotId Slot
    Field Value
    Type Description
    SceneCameraSlotId

    ViewMatrix

    Gets or sets the local view matrix. See remarks.

    public Matrix ViewMatrix
    Field Value
    Type Description
    Matrix

    The local view matrix.

    Remarks

    This value is updated when calling Update() or is directly used when UseCustomViewMatrix is true.


    ViewProjectionMatrix

    The view projection matrix calculated automatically after calling Update() method.

    public Matrix ViewProjectionMatrix
    Field Value
    Type Description
    Matrix
    | Improve this Doc View Source

    Properties


    ActuallyUsedAspectRatio

    Gets the last used aspect ratio.

    public float ActuallyUsedAspectRatio { get; }
    Property Value
    Type Description
    System.Single
    Remarks

    This value is updated when calling Update(). It either holds the aspect ratio of the window that called Update or the manually set aspect ratio AspectRatio if UseCustomAspectRatio is true.


    AspectRatio

    Gets or sets the custom aspect ratio.

    [DataMember(40)]
    public float AspectRatio { get; set; }
    Property Value
    Type Description
    System.Single

    The custom aspect ratio.


    FarClipPlane

    Gets or sets the far plane distance.

    [DataMember(30)]
    public float FarClipPlane { get; set; }
    Property Value
    Type Description
    System.Single

    The far plane distance.


    Name

    [DataMember(-5)]
    [Obsolete("This property is no longer used.")]
    public string Name { get; set; }
    Property Value
    Type Description
    System.String

    NearClipPlane

    Gets or sets the near plane distance.

    [DataMember(20)]
    public float NearClipPlane { get; set; }
    Property Value
    Type Description
    System.Single

    The near plane distance.


    OrthographicSize

    Gets or sets the height of the orthographic projection.

    [DataMember(10)]
    [Display("Orthographic size", null)]
    public float OrthographicSize { get; set; }
    Property Value
    Type Description
    System.Single

    The height of the orthographic projection.


    Projection

    Gets or sets the projection.

    [DataMember(0)]
    public CameraProjectionMode Projection { get; set; }
    Property Value
    Type Description
    CameraProjectionMode

    The projection.


    UseCustomAspectRatio

    Gets or sets a value indicating whether to use a custom AspectRatio. Default is false, meaning that the aspect ratio is calculated from the ratio of the current viewport when rendering.

    [DataMember(35)]
    [Display("Custom aspect ratio", null)]
    public bool UseCustomAspectRatio { get; set; }
    Property Value
    Type Description
    System.Boolean

    The use custom aspect ratio.


    UseCustomProjectionMatrix

    Gets or sets a value indicating whether to use custom ProjectionMatrix. Default is false

    public bool UseCustomProjectionMatrix { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if use custom ProjectionMatrix; otherwise, false.


    UseCustomViewMatrix

    Gets or sets a value indicating whether to use custom ViewMatrix. Default is false

    public bool UseCustomViewMatrix { get; set; }
    Property Value
    Type Description
    System.Boolean

    true if use custom ViewMatrix; otherwise, false.


    VerticalFieldOfView

    Gets or sets the vertical field of view in degrees.

    [DataMember(5)]
    [Display("Field of view", null)]
    [DataMemberRange(1, 179, 1, 10, 0)]
    public float VerticalFieldOfView { get; set; }
    Property Value
    Type Description
    System.Single

    The vertical field of view.

    | Improve this Doc View Source

    Methods


    Update()

    Calculates the projection matrix and view matrix.

    public void Update()

    Update(Nullable<Single>)

    Calculates the projection matrix and view matrix.

    public void Update(float? screenAspectRatio)
    Parameters
    Type Name Description
    System.Nullable<System.Single> screenAspectRatio

    The current screen aspect ratio. If null, use the AspectRatio even if UseCustomAspectRatio is false.


    Inherited Members

    ActivableEntityComponent.Enabled
    EntityComponent.Entity
    EntityComponent.Id
    EntityComponent.EnsureEntity

    Extension Methods

    ComponentBaseExtensions.DisposeBy<T>(T, ICollectorHolder)
    ComponentBaseExtensions.RemoveDisposeBy<T>(T, ICollectorHolder)
    • Improve this Doc
    • View Source
    In This Article

    Back to top

    Copyright © 2019-2021 .NET Foundation and Contributors
    Supported by the .NET Foundation