Class T2DSceneManager

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type T2DSceneManager = class(TCastleSceneManager)

Description

Scene manager best suited for 2D worlds.

Features:

  • By default creates a camera positioned at (0, 0, 500), looking along the -Z direction, with "up" vector in +Y. This is nice when your world is (mostly) flat and positioned on the Z = 0 plane.

  • The camera TUniversalCamera.NavigationType is ntNone, which means that no automatic way to move camera in the world is possible, you want to program your own movement for 2D.

  • Sets 2D projection. By default (see CalculateProjection) our visible X range is [0..window width in pixels], visible Y is [0..window height in pixels].

    Such projection is set regardless of the viewpoints defined in MainScene (this is unlike ancestor TCastleSceneManager, that sets projection using a flexible algorithm that takes into account VRML/X3D viewpoints in MainScene).

  • Sets Transparent = True by default, which means that background underneath will be visible. Useful for 2D games where you usually have an image or another background underneath, like TCastleImage or TCastleSimpleBackground.

Hierarchy

Overview

Fields

Public internal const DefaultProjectionSpan = 1000.0;
Public internal const DefaultCameraZ = DefaultProjectionSpan / 2;

Methods

Protected function CalculateProjection: TProjection; override;
Public constructor Create(AOwner: TComponent); override;
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;

Properties

Public property ProjectionAutoSize: boolean read FProjectionAutoSize write FProjectionAutoSize default true;
Public property ProjectionHeight: Single read FProjectionHeight write FProjectionHeight default 0;
Public property ProjectionWidth: Single read FProjectionWidth write FProjectionWidth default 0;
Public property CurrentProjectionWidth: Single read FCurrentProjectionWidth;
Public property CurrentProjectionHeight: Single read FCurrentProjectionHeight;
Public property ProjectionSpan: Single read FProjectionSpan write FProjectionSpan default DefaultProjectionSpan;
Public property ProjectionOriginCenter: boolean read FProjectionOriginCenter write FProjectionOriginCenter default false;
Published property Transparent default true;

Description

Fields

Public internal const DefaultProjectionSpan = 1000.0;
 
Public internal const DefaultCameraZ = DefaultProjectionSpan / 2;
 

Methods

Protected function CalculateProjection: TProjection; override;
 
Public constructor Create(AOwner: TComponent); override;
 
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;
 

Properties

Public property ProjectionAutoSize: boolean read FProjectionAutoSize write FProjectionAutoSize default true;

When ProjectionAutoSize is True, the size of the world visible in our viewport depends on scene manager size. ProjectionHeight and ProjectionWidth are ignored then.

When ProjectionAutoSize is False, ProjectionHeight and ProjectionWidth are used to determine the world visible in our viewport. If one of them is zero, the other is automatically adjusted to follow aspect ratio of viewport size. If both of them are zero, projection is automatically calculated just as if ProjectionAutoSize was True.

In all cases, CurrentProjectionWidth and CurrentProjectionHeight can be checked to see actual projection dimensions.

Public property ProjectionHeight: Single read FProjectionHeight write FProjectionHeight default 0;
 
Public property ProjectionWidth: Single read FProjectionWidth write FProjectionWidth default 0;
 
Public property CurrentProjectionWidth: Single read FCurrentProjectionWidth;
 
Public property CurrentProjectionHeight: Single read FCurrentProjectionHeight;
 
Public property ProjectionSpan: Single read FProjectionSpan write FProjectionSpan default DefaultProjectionSpan;
 
Public property ProjectionOriginCenter: boolean read FProjectionOriginCenter write FProjectionOriginCenter default false;

Where is the (0,0) world point with respect to the viewport. If False, the (0,0) is in the left-bottom corner, which matches the typical 2D drawing coordinates used throughout our engine. If True, the (0,0) is in the middle of the viewport.

Published property Transparent default true;
 

Generated by PasDoc 0.14.0.