Class TCastleOrthographic

Unit

Declaration

type TCastleOrthographic = class(TCastleComponent)

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.

Source: transform/castletransform_camera.inc (line 93).

Hierarchy

Show Additional Members:

Overview

Methods

Protected function GetInternalText: String; virtual;
Protected procedure SetInternalText(const Value: String); virtual;
Protected procedure SetName(const Value: TComponentName); override;
Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;
Public procedure SetTransient;
Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);
Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);
Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);
Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;
Public function NonVisualComponentsCount: Integer;
Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;
Public function ValueIsStreamed: Boolean; virtual;
Public procedure DesignerInfo(const SList: TStrings); virtual;
Public procedure DesignerWarnings(const SList: TStrings); virtual;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override;
Public function EffectiveWidth: Single; deprecated 'use EffectiveRect.Width';
Public function EffectiveHeight: Single; deprecated 'use EffectiveRect.Height';

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;
Public property IsLoading: Boolean read FIsLoading;
Public property Origin: TVector2 read FOrigin write SetOrigin;
Public property EffectiveRect: TFloatRectangle read FEffectiveRect;
Public property Scale: Single read FScale write SetScale default 1; deprecated 'just multiply Width or Height instead of using this';
Public property Stretch: Boolean read FStretch write SetStretch default false; experimental;
Published property Width: Single read FWidth write SetWidth default 0;
Published property Height: Single read FHeight write SetHeight default 0;
Published property OriginPersistent: TCastleVector2Persistent read FOriginPersistent ;

Description

Methods

Protected function GetInternalText: String; virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 575).

Protected procedure SetInternalText(const Value: String); virtual;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 576).

Protected procedure SetName(const Value: TComponentName); override;

This item is declared in ancestor TCastleComponent.

This item has no description.

Source: base/castleclassutils.pas (line 577).

Protected procedure TranslateProperties(const TranslatePropertyEvent: TTranslatePropertyEvent); virtual;

This item is declared in ancestor TCastleComponent.

Enumerate all properties that are possible to translate in this component. E.g. in TCastleLabel it will return TCastleLabel.Caption, in TCastleEdit it will return TCastleEdit.Text and TCastleEdit.Placeholder.

Returns only non-empty properties, thus assuming that if current (by convention, English) text is empty, then there is no point in translating it. Moreover descendants may define boolean properties to exclude particular text from translating, e.g. TCastleLabel.CaptionTranslate, TCastleEdit.TextTranslate, TCastleEdit.PlaceholderTranslate.

It is not recursive (it doesn't enumerate children properties). Use global TranslateProperties procedure to call this on a hierarchy of TComponent.

You usually don't want to call this method (it is called by other engine routines). But you may find it useful to override this, if you define new component.

Source: base/castleclassutils.pas (line 598).

Public procedure SetTransient;

This item is declared in ancestor TCastleComponent.

Ignore this component when serializing parent's TCastleUserInterface.Controls list or TCastleTransform.List, and do not show this component in CGE editor. This simply sets csTransient flag in ComponentStyle.

This is useful for children that are automatically managed by the parent, and should not be modified by user code. For example, TCastleCheckbox is internally composed from TCastleImageControl and TCastleLabel children, but we don't want to serialize or even show these children to user.

Note that if you want to prevent this component from serializing as part of TCastleUserInterface.Controls list or TCastleTransform.List, but you still want it to be visible in CGE editor, then make it a "subcomponent" instead, by SetSubComponent(true).

Note that both csSubComponent and csTransient only disable the component serialization as part of parent's lists enumerated by CustomSerialization (see internal TCastleUserInterface.SerializeChildrenEnumerate , TCastleTransform.SerializeChildrenEnumerate, TCastleTransform.SerializeBehaviorsEnumerate).

If you will make the component published in its own property (which is normal for "subcomponents") then it will be serialized anyway, just as part of it's own property (like TCastleScrollView.ScrollArea). So to really avoid serializing a children component make it csSubComponent and/or csTransient, and do not publish it.

Source: base/castleclassutils.pas (line 663).

Public procedure AddNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Add non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 672).

Public procedure InsertNonVisualComponent(const Index: Integer; const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Insert non-visual component to this component. This is used to organize non-visual components in a tree hierarchy, in CGE designs and editor.

See also
NonVisualComponentsCount
Count of components added by AddNonVisualComponent.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 681).

Public procedure RemoveNonVisualComponent(const NonVisualComponent: TComponent);

This item is declared in ancestor TCastleComponent.

Removes the component previously added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 684).

Public function NonVisualComponentsIndexOf(const NonVisualComponent: TComponent): Integer;

This item is declared in ancestor TCastleComponent.

Index of the previously added non-visual component. Returns -1 if the component was not found.

Source: base/castleclassutils.pas (line 688).

Public function NonVisualComponentsCount: Integer;

This item is declared in ancestor TCastleComponent.

Count of components added by AddNonVisualComponent.

See also
AddNonVisualComponent
Add non-visual component to this component.
NonVisualComponents
Components added by AddNonVisualComponent.
NonVisualComponentsEnumerate
You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do ....

Source: base/castleclassutils.pas (line 695).

Public function NonVisualComponentsEnumerate: TNonVisualComponentsEnumerator;

This item is declared in ancestor TCastleComponent.

You can enumerate current non-visual components using loop like for C in MyComponent.NonVisualComponentsEnumerate do .... Do not call this method in other contexts, it is only useful for "for..in" construction.

See also
AddNonVisualComponent
Add non-visual component to this component.

Source: base/castleclassutils.pas (line 705).

Public function ValueIsStreamed: Boolean; virtual;

This item is declared in ancestor TCastleComponent.

Whether the current value of this object should be written to the stream. This should be True if anything inside this object should be serialized (which means it has non-default value or "stored" specifier indicates that it should be serialized).

This is used by CastleComponentSerialize, which is used in Castle Game Engine for all serialization.

In simple cases, this just says whether the current value of this object equals to some default value.

The default implementation of this class returns True (so always write).

Descendants that override this to sometimes return False (so no need to write) must be very careful: any addition of a new field requires extending this method, otherwise new field may not be saved sometimes (when all other fields are default). Descentants of such classes must also be aware of it. This check must include everything that is inside this object in JSON, including subcomponents and children objects (as done e.g. by TSerializationProcess.ReadWriteList). In practice, overriding this method is only reasonable for simple classes that will not change much in the future, like TCastleVector3Persistent.

The name of this method is consistent with TPropertyEditor.ValueIsStreamed in LCL.

Source: base/castleclassutils.pas (line 739).

Public procedure DesignerInfo(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add information that should be visible at design-time. Call SList.Add for each new line of information.

Source: base/castleclassutils.pas (line 743).

Public procedure DesignerWarnings(const SList: TStrings); virtual;

This item is declared in ancestor TCastleComponent.

Override to add warnings that should be visible at design-time. Call SList.Add for each new warning.

Source: base/castleclassutils.pas (line 747).

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Source: transform/castletransform_camera.inc (line 109).

Public destructor Destroy; override;

This item has no description.

Source: transform/castletransform_camera.inc (line 110).

Public function PropertySections(const PropertyName: String): TPropertySections; override;

This item has no description. Showing description inherited from TCastleComponent.PropertySections.

Section where to show property in the editor.

Source: transform/castletransform_camera.inc (line 111).

Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override;

This item has no description. Showing description inherited from TCastleComponent.CustomSerialization.

Override this method to call various methods of SerializationProcess, which in turn allows to serialize/deserialize things that are not published. This allows to serialize/deserialize with more freedom, e.g. to serialize/deserialize some private field.

Source: transform/castletransform_camera.inc (line 112).

Public function EffectiveWidth: Single; deprecated 'use EffectiveRect.Width';

Warning: this symbol is deprecated: use EffectiveRect.Width

This item has no description.

Source: transform/castletransform_camera.inc (line 146).

Public function EffectiveHeight: Single; deprecated 'use EffectiveRect.Height';

Warning: this symbol is deprecated: use EffectiveRect.Height

This item has no description.

Source: transform/castletransform_camera.inc (line 147).

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;

This item is declared in ancestor TCastleComponent.

Components added by AddNonVisualComponent.

Source: base/castleclassutils.pas (line 698).

Public property IsLoading: Boolean read FIsLoading;

This item is declared in ancestor TCastleComponent.

Is the component during deserialization now.

Note: We can't use csLoading in ComponentState because in Delphi it is not possible to control it from CastleComponentSerialize.

Source: base/castleclassutils.pas (line 711).

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 Camera.Translation 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 TCastleViewport.

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 TCastleViewport.

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.

Source: transform/castletransform_camera.inc (line 140).

Public property EffectiveRect: TFloatRectangle read FEffectiveRect;

Currently used projection dimensions, calculated following the algorithm described at Width and Height, taking into account sizes of the viewport using this camera.

Source: transform/castletransform_camera.inc (line 145).

Public property Scale: Single read FScale write SetScale default 1; deprecated 'just multiply Width or Height instead of using this';

Warning: this symbol is deprecated: just multiply Width or Height instead of using this

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-bottom corner of the viewport. When Origin is (0.5,0.5), this behaves like scaling around the middle of the viewport.

Source: transform/castletransform_camera.inc (line 156).

Public property Stretch: Boolean read FStretch write SetStretch default false; experimental;

Warning: this symbol is experimental.

Allow non-proportional stretch of projection. In effect the Width and Height (if both non-zero) are applied directly, without correcting them to follow aspect ratio of the viewport.

Source: transform/castletransform_camera.inc (line 163).

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 effective 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 accordingly. 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, they determine the projection width and height following the algorithm outlined below. This also allows to easily display the same piece of the game world, regardless of the viewport size.

    • When Stretch = False (default), they determine the minimum projection width and height along the given axis.

      If the displayed viewport aspect ratio will be different than given Width and Height ratio, then these values will be treated as minimum values, and they will be adjusted (one of them will be increased) for the purposes of rendering. You can read the EffectiveWidth, EffectiveHeight to know the adjusted values.

      Note that the Camera.Translation is considered to be relative to unadjusted Width and Height, not to the adjusted EffectiveWidth, EffectiveHeight. In effect, when Origin is zero, the Camera.Translation does not point to the left-bottom of the whole viewport. It points to the left-bottom of the rectangle of aspect ratio Width / Height within the viewport. This way the enlarged viewport shows equal amount of additional space on the left and the right (or bottom and top) of the Width / Height rectangle within.

    • When Stretch = True, these values are used directly, even if it means that aspect ratio of the projection will not reflect the aspect ratio of the viewport on screen.

      This allows to implement some tricks, like Military Projection, https://github.com/castle-engine/castle-engine/issues/290 .

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

You can read EffectiveWidth and EffectiveHeight to learn the actual projection width and height, calculated using the above algorithm.

Source: transform/castletransform_camera.inc (line 236).

Published property Height: Single read FHeight write SetHeight default 0;

This item has no description.

Source: transform/castletransform_camera.inc (line 237).

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.

Source: transform/auto_generated_persistent_vectors/tcastleorthographic_persistent_vectors.inc (line 37).


Generated by PasDoc 0.17.0.snapshot.