Class TCastleOrthographic

Unit

Declaration

type TCastleOrthographic = class(TComponent)

Description

Subcomponent used in TCastleCamera.Orthographic to set orthographic projection parameters.

Do not create instances of this class yourself, these are automatically created by TCastleCamera.

Hierarchy

  • TObject
  • TPersistent
  • TComponent
  • TCastleOrthographic

Overview

Methods

Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public procedure InternalSetEffectiveSize(const W, H: Single);

Properties

Public property Origin: TVector2 read FOrigin write SetOrigin;
Public property EffectiveWidth: Single read FEffectiveWidth;
Public property EffectiveHeight: Single read FEffectiveHeight;
Published property Width: Single read FWidth write SetWidth default 0;
Published property Height: Single read FHeight write SetHeight default 0;
Published property Scale: Single read FScale write SetScale default 1;
Published property OriginPersistent: TCastleVector2Persistent read FOriginPersistent ;

Description

Methods

Public constructor Create(AOwner: TComponent); override;
 
Public destructor Destroy; override;
 
Public procedure InternalSetEffectiveSize(const W, H: Single);
 

Properties

Public property Origin: TVector2 read FOrigin write SetOrigin;

Additional translation of the camera. The camera movement applied here is always scaled by the calculated orthographic projection width and height.

By default this equals (0,0) which means that TCastleCamera.Position determines what is visible in the left-bottom corner of the viewport. This matches the typical 2D drawing coordinates used throughout our engine. In other words, if the camera is at position (0,0,whatever), then the (0,0) position in 2D is in the left-bottom corner of the scene manager rectangle.

You can change it e.g. to (0.5,0.5) to move the camera to the middle of the viewport. In effect, if the camera is at position (0,0,whatever), then the (0,0) position is in the center of the scene manager rectangle.

Both values of Origin make sense, it depends on the game type and how you prefer to think in 2D coordinates. And how do you want the result to behave when aspect ratio changes:

  • With (0.5,0.5), things will stay "glued" to the center.

  • With (0,0), things will stay "glued" to the left-bottom corner.

Public property EffectiveWidth: Single read FEffectiveWidth;

Currently used projection width and height, calculated following the algorithm described at Width and Height.

Public property EffectiveHeight: Single read FEffectiveHeight;
 
Published property Width: Single read FWidth write SetWidth default 0;

Orthographic projection width and height.

You can leave one or both of them as zero (default) to automatically calculate effective projection width and height (in EffectiveWidth and EffectiveHeight):

  • When both Width and Height are zero, then the effetive projection width and height are based on the viewport width and height. That is, they will follow TCastleViewport.EffectiveWidth and TCastleViewport.EffectiveHeight.

  • When exactly one of Width and Height is non-zero, then it explicitly determines the projection width or height accordingily. This allows to easily display the same piece of the game world, regardless of the viewport size.

    The other size is then calculated to follow the aspect ratio of the viewport control.

  • When both Width and Height are non-zero, then they explicitly determine the minimum projection width and height along the given axis.

    This, again, allows to easily display the same piece of the game world, regardless of the viewport size.

    If the displayed viewport aspect ratio wil be different than given Width and Height ratio, then these value will be treated as minimum values, and they will be adjusted. This follows the X3D OrthoViewpoint.fieldOfView specification.

In alll cases, the resulting size is also multiplied by Scale, by default 1.0.

In all cases, you can read EffectiveWidth and EffectiveHeight to know the actual projection width and height, calculated using the above algorithm.

Published property Height: Single read FHeight write SetHeight default 0;
 
Published property Scale: Single read FScale write SetScale default 1;

Scales the projection size derived from Width and Height.

The effect of this scale is also affected by the Origin. When Origin is zero, this behaves like scaling around left-botttom corner of the viewport. When Origin is (0.5,0.5), this behaves like scaling around the middle of the viewport.

Published property OriginPersistent: TCastleVector2Persistent read FOriginPersistent ;

Origin that can be visually edited in Castle Game Engine Editor, Lazarus and Delphi. Normal user code does not need to deal with this, instead read or write Origin directly.

See also
Origin
Additional translation of the camera.

Generated by PasDoc 0.15.0.