Class TCastleViewport

Unit

Declaration

type TCastleViewport = class(TCastleScreenEffects)

Description

Viewport displays a tree of scenes and transformations (TCastleTransform and descendants of it, like TCastleScene). Add the scenes and transformations to Items. See https://castle-engine.io/viewport_and_scenes .

Each viewport has a Camera with a position and orientation. Viewport may have multiple cameras.

Viewport may also have a navigation that allows to move camera by keyboard, mouse and other inputs. You can use any navigation method implemented in the engine (TCastleExamineNavigation, TCastleWalkNavigation, TCastleThirdPersonNavigation) or implement your own (you can create your own descendants of TCastleNavigation, or just move/rotate the camera by calling Viewport.Camera.SetWorldView from anywhere). Just add TCastleNavigation as a child of TCastleViewport.

Viewport may display a background. It may be a solid color, a 3D skybox or a gradient. See Background, BackgroundColor properties and https://castle-engine.io/background . Alternatively, viewport background may be transparent (so other TCastleUserInterface underneath will be visible) if Transparent.

Multiple viewports can display the same world. To do this, simply copy Items reference from one TCastleViewport to another. You can also just create your own TCastleRootTransform instance and then assign it to multiple viewports. This allows e.g. to make a split-screen game (played by 2 people, with 2 viewports, on a single monitor). Or you can show in a 3D FPS game an additional view from some security camera, or from a flying rocket. See https://castle-engine.io/multiple_viewports_to_display_one_world .

Source: scene/castleviewport.pas (line 78).

Hierarchy

Show Additional Members:

Overview

Constants

Public DefaultWidth = 100.0;
Public DefaultHeight = 100.0;
Public DefaultScreenSpaceAmbientOcclusion = false;
Public DefaultScreenSpaceReflections = False;
Public DefaultScreenSpaceReflectionsSurfaceGlossiness = 0.5;
Public DefaultUseGlobalLights = true;
Public DefaultUseGlobalFog = true;
Public DefaultShadowVolumes = true;
Public DefaultBackgroundColor: TVector4 = (X: 0.1; Y: 0.1; Z: 0.1; W: 1);
Public Default2DProjectionFar = CastleTransform.Default2DProjectionFar deprecated 'this default is not used; ProjectionFar in orthographic projection is now automatically adjusted to what you display';
Public Default2DProjectionNear = CastleTransform.Default2DProjectionNear deprecated 'this default is not used; ProjectionNear in orthographic projection is now automatically adjusted to what you display';
Public Default2DCameraZ = CastleTransform.Default2DCameraZ;
Public DefaultPrepareOptions = [prRenderSelf, prRenderClones, prBackground, prBoundingBox, prScreenEffects];
Public DefaultInternalGridAxis = false;

Fields

Protected RenderScreenEffects: Boolean;
Public var CustomRenderingPass: TUserRenderingPass;
Public InternalDesignCamera: TCastleCamera;

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;
Protected function ContainerWidth: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil"';
Protected function ContainerHeight: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil"';
Protected function ContainerRect: TRectangle; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil"';
Protected function ContainerSizeKnown: boolean; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil"';
Protected procedure DoCursorChange; virtual; deprecated 'better override VisibleChange and watch for chCursor in Changes';
Protected procedure DefineProperties(Filer: TFiler); override;
Protected procedure UIScaleChanged; virtual;
Protected procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); virtual;
Protected procedure BeforeSizing; virtual;
Protected procedure DoInternalMouseEnter; virtual;
Protected procedure DoInternalMouseLeave; virtual;
Protected function Theme: TCastleTheme;
Public procedure DesignerInfo(const SList: TStrings); override;
Public procedure DesignerWarnings(const SList: TStrings); override;
Public function GetEnumerator: TEnumerator;
Public procedure InternalSetContainer(const Value: TCastleContainer); virtual;
Public function PreviewPress(const Event: TInputPressRelease): boolean; virtual;
Public function PreviewRelease(const Event: TInputPressRelease): boolean; virtual;
Public function SensorRotation(const X, Y, Z, Angle: Double; const SecondsPassed: Single): boolean; virtual;
Public function SensorTranslation(const X, Y, Z, Length: Double; const SecondsPassed: Single): boolean; virtual;
Public procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); overload; virtual;
Public procedure Resize; virtual;
Public function ControlsCount: Integer;
Public procedure InsertFront(const NewItem: TCastleUserInterface); overload;
Public procedure InsertFrontIfNotExists(const NewItem: TCastleUserInterface);
Public procedure InsertFront(const NewItems: TCastleUserInterfaceList); overload;
Public procedure InsertBack(const NewItem: TCastleUserInterface); overload;
Public procedure InsertBackIfNotExists(const NewItem: TCastleUserInterface);
Public procedure InsertBack(const NewItems: TCastleUserInterfaceList); overload;
Public procedure InsertControl(const Index: Integer; const NewItem: TCastleUserInterface);
Public procedure RemoveControl(const Item: TCastleUserInterface);
Public function IndexOfControl(const Item: TCastleUserInterface): Integer;
Public procedure ClearControls;
Public procedure MoveToFront;
Public function CapturesEventsAtPosition(const Position: TVector2): boolean; virtual;
Public function TooltipExists: Boolean; virtual; deprecated 'use TooltipControl to customize tooltip look';
Public procedure TooltipRender(const TooltipPosition: TVector2); virtual; deprecated 'use TooltipControl to customize tooltip look';
Public procedure SetFocused(const Value: boolean); virtual;
Public function EffectiveRect: TFloatRectangle;
Public function EffectiveWidth: Single;
Public function EffectiveHeight: Single;
Public function EffectiveWidthForChildren: Single;
Public function EffectiveHeightForChildren: Single;
Public function CalculatedWidth: Cardinal; deprecated 'use EffectiveWidth';
Public function CalculatedHeight: Cardinal; deprecated 'use EffectiveHeight';
Public function CalculatedRect: TRectangle; deprecated 'use EffectiveRect';
Public function RenderRect: TFloatRectangle;
Public function RenderRectWithBorder: TFloatRectangle;
Public function ScreenRect: TRectangle; deprecated 'use RenderRect';
Public function ContainerToLocalPosition(ContainerPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2;
Public function LocalToContainerPosition(const LocalPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2;
Public function ParentRect: TFloatRectangle;
Public procedure Anchor(const AHorizontalAnchor: THorizontalPosition; const TranslationX: Single = 0); overload;
Public procedure Anchor( const AHorizontalAnchorSelf, AHorizontalAnchorParent: THorizontalPosition; const TranslationX: Single = 0); overload;
Public procedure Anchor(const AVerticalAnchor: TVerticalPosition; const TranslationY: Single = 0); overload;
Public procedure Anchor( const AVerticalAnchorSelf, AVerticalAnchorParent: TVerticalPosition; const TranslationY: Single = 0); overload;
Public procedure AlignHorizontal( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const X: Single = 0); deprecated 'use Anchor';
Public procedure Align( const ControlPosition: THorizontalPosition; const ContainerPosition: THorizontalPosition; const X: Single = 0); overload; deprecated 'use Anchor';
Public procedure AlignVertical( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const Y: Single = 0); deprecated 'use Anchor';
Public procedure Align( const ControlPosition: TVerticalPosition; const ContainerPosition: TVerticalPosition; const Y: Single = 0); overload; deprecated 'use Anchor';
Public procedure Center; deprecated 'use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control';
Public function UIScale: Single; virtual;
Public procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); virtual;
Public function EffectiveFullSize: Boolean;
Public procedure AddScreenEffect(const Node: TAbstractChildNode);
Public procedure RemoveScreenEffect(const Node: TAbstractChildNode);
Public procedure Render; override;
Public procedure RenderOverChildren; override;
Public procedure PrepareResources;
Protected function CalculateProjection: TProjection; virtual;
Protected procedure InitializeGlobalLights(const GlobalLights: TLightInstancesList); virtual;
Protected procedure InitializeLights(const GlobalLights: TLightInstancesList); deprecated 'use InitializeGlobalLights';
Protected procedure RenderFromViewEverything(const RenderingCamera: TRenderingCamera); virtual;
Protected procedure RenderFromView3D(const Params: TRenderParams); virtual;
Protected procedure RenderOnePass(const Params: TRenderParams; const PassParams: TRenderOnePassParams); virtual;
Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;
Protected function InternalExtraGetScreenEffects( const Index: Integer): TGLSLProgram; override;
Protected function InternalExtraScreenEffectsCount: Integer; override;
Protected function InternalExtraScreenEffectsNeedDepth: Boolean; override;
Protected procedure PointingDevicePressFailed; virtual;
Protected procedure BoundNavigationInfoChanged; virtual;
Protected procedure BoundViewpointChanged; virtual;
Protected procedure RenderWithoutScreenEffects; override;
Protected procedure Loaded; override;
Public constructor Create(AOwner: TComponent); override;
Public destructor Destroy; override;
Public function AllowSuspendForInput: boolean; override;
Public function Press(const Event: TInputPressRelease): boolean; override;
Public function Release(const Event: TInputPressRelease): boolean; override;
Public function Motion(const Event: TInputMotion): boolean; override;
Public procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override;
Public procedure BeforeRender; override;
Public function PropertySections(const PropertyName: String): TPropertySections; override;
Public procedure CustomSerialization(const SerializationProcess: TSerializationProcess); override;
Public function GetMainScene: TCastleScene; deprecated 'use Items.MainScene';
Public procedure AssignDefaultCamera; virtual;
Public function ScreenSpaceAmbientOcclusionAvailable: boolean;
Public function ScreenSpaceReflectionsAvailable: boolean;
Public procedure GLContextOpen; override;
Public procedure GLContextClose; override;
Public function PrepareParams: TPrepareParams; deprecated 'use TCastleViewport.PrepareResources to prepare transforms';
Public function BaseLights: TLightInstancesList; deprecated 'this is internal info, you should not need this; use PrepareParams to get opaque information to pass to TCastleTransform.PrepareResources';
Public function Statistics: TRenderStatistics;
Public function TriangleHit: PTriangle;
Public procedure Setup2D;
Public function PositionToCameraPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const Depth: Single; out PlanePosition: TVector3): Boolean;
Public procedure PositionToRay(const Position: TVector2; const ContainerCoordinates: Boolean; out RayOrigin, RayDirection: TVector3);
Public function PositionToWorldPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const PlaneConstCoord: T3DAxis; const PlaneConstValue: Single; out PlanePosition: TVector3): Boolean; overload;
Public function PositionToWorldPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const PlaneConstValue: Single; out PlanePosition: TVector3): Boolean; overload; deprecated 'use PositionToWorldPlane overload with PlaneConstCoord parameter; this version assumes PlaneConstCoord = 2';
Public function PositionTo2DWorld(const Position: TVector2; const ContainerCoordinates: Boolean): TVector2;
Public function PositionFrom2DWorld(const WorldPosition: TVector2; const ContainerCoordinates: Boolean): TVector2;
Public function PositionFromWorld(const WorldPosition: TVector3): TVector2;
Public procedure PrepareResources(const DisplayProgressTitle: string; const Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; deprecated 'use overload without DisplayProgressTitle: String';
Public procedure PrepareResources(const Item: TCastleTransform; const DisplayProgressTitle: string; Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; deprecated 'use overload without DisplayProgressTitle: String';
Public procedure PrepareResources( const Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload;
Public procedure PrepareResources(const Item: TCastleTransform; Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; virtual;
Public function TransformUnderMouse: TCastleTransform;
Public function TransformHit(const Position: TVector2; const ContainerCoordinates: Boolean; const MaxDistance: Single = 0): TCastleTransform;
Public procedure SetupCamera;
Public function InternalBuildNode(const SaveBaseUrl: String): TX3DRootNode;

Properties

Public property NonVisualComponents [const Index: Integer]: TComponent read GetNonVisualComponents;
Public property IsLoading: Boolean read FIsLoading;
Public property OnVisibleChange: TCastleUserInterfaceChangeEvent read FOnVisibleChange write FOnVisibleChange;
Public property Container: TCastleContainer read FContainer;
Public property OnCursorChange: TNotifyEvent read FOnCursorChange write FOnCursorChange; deprecated 'use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor';
Public property ExclusiveEvents: boolean read FExclusiveEvents write FExclusiveEvents default true; deprecated 'do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always';
Public property Controls [const Index: Integer]: TCastleUserInterface read GetControls write SetControls;
Public property GetExists: Boolean read FExists; deprecated 'use Exists';
Public property GLInitialized: boolean read FGLInitialized default false;
Public property Focused: boolean read FFocused write SetFocused;
Public property Parent: TCastleUserInterface read FParent ;
Public property FloatWidth: Single read FWidth write SetWidth stored false; deprecated 'use Width';
Public property FloatHeight: Single read FHeight write SetHeight stored false; deprecated 'use Height';
Public property AnchorDelta: TVector2 read FTranslation write SetTranslation; deprecated 'use Translation';
Public property Translation: TVector2 read FTranslation write SetTranslation;
Public property KeepInFront: boolean read FKeepInFront write FKeepInFront default false;
Public property BorderColor: TCastleColor read FBorderColor write SetBorderColor;
Public property HasHorizontalAnchor: boolean read FHasHorizontalAnchor write FHasHorizontalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active';
Public property HasVerticalAnchor: boolean read FHasVerticalAnchor write FHasVerticalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active';
Public property HorizontalAnchorDelta: Single read GetHorizontalAnchorDelta write SetHorizontalAnchorDelta default 0; deprecated 'use Translation.X';
Public property VerticalAnchorDelta: Single read GetVerticalAnchorDelta write SetVerticalAnchorDelta default 0; deprecated 'use Translation.Y';
Public property Visible: Boolean read FVisible;
Public property EnableUIScaling: boolean read FEnableUIScaling write SetEnableUIScaling default true;
Public property CapturesEvents: boolean read FCapturesEvents write FCapturesEvents default true;
Public property OnInternalMouseEnter: TUiNotifyEvent read FOnInternalMouseEnter write FOnInternalMouseEnter;
Public property OnInternalMouseLeave: TUiNotifyEvent read FOnInternalMouseLeave write FOnInternalMouseLeave;
Published property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault;
Published property OnUpdate: TUiUpdateEvent read FOnUpdate write FOnUpdate;
Published property OnPress: TUiPressReleaseEvent read FOnPress write FOnPress;
Published property OnRelease: TUiPressReleaseEvent read FOnRelease write FOnRelease;
Published property OnMotion: TUiMotionEvent read FOnMotion write FOnMotion;
Published property OnRender: TUiNotifyEvent read FOnRender write FOnRender;
Published property Exists: boolean read FExists write SetExists default true;
Published property Left: Single read FLeft write SetLeft stored false default 0; deprecated 'use Translation.X';
Published property Bottom: Single read FBottom write SetBottom default 0; deprecated 'use Translation.Y';
Published property FullSize: boolean read FFullSize write SetFullSize default false;
Published property Width: Single read FWidth write SetWidth default DefaultWidth;
Published property Height: Single read FHeight write SetHeight default DefaultHeight;
Published property WidthFraction: Single read FWidthFraction write SetWidthFraction default 0.0;
Published property HeightFraction: Single read FHeightFraction write SetHeightFraction default 0.0;
Published property AutoSizeToChildren: Boolean read FAutoSizeToChildren write SetAutoSizeToChildren default false;
Published property AutoSizeToChildrenPaddingRight: Single read FAutoSizeToChildrenPaddingRight write SetAutoSizeToChildrenPaddingRight default 0;
Published property AutoSizeToChildrenPaddingTop: Single read FAutoSizeToChildrenPaddingTop write SetAutoSizeToChildrenPaddingTop default 0;
Published property HorizontalAnchorSelf: THorizontalPosition read FHorizontalAnchorSelf write SetHorizontalAnchorSelf default hpLeft;
Published property HorizontalAnchorParent: THorizontalPosition read FHorizontalAnchorParent write SetHorizontalAnchorParent default hpLeft;
Published property VerticalAnchorSelf: TVerticalPosition read FVerticalAnchorSelf write SetVerticalAnchorSelf default vpBottom;
Published property VerticalAnchorParent: TVerticalPosition read FVerticalAnchorParent write SetVerticalAnchorParent default vpBottom;
Published property Culling: Boolean read FCulling write SetCulling default false;
Published property ClipChildren: Boolean read FClipChildren write SetClipChildren default false;
Published property Border: TBorder read FBorder;
Published property CustomTheme: TCastleTheme read FCustomTheme write SetCustomTheme;
Published property TooltipControl: TCastleUserInterface read FTooltipControl write SetTooltipControl;
Published property EditorSelectOnHover: Boolean read FEditorSelectOnHover write FEditorSelectOnHover default true;
Published property BorderColorPersistent: TCastleColorPersistent read FBorderColorPersistent ;
Published property TranslationPersistent: TCastleVector2Persistent read FTranslationPersistent ;
Public property ScreenEffectsTimeScale: Single read FScreenEffectsTimeScale write FScreenEffectsTimeScale default 1;
Public property ScreenEffectsEnable: Boolean read FScreenEffectsEnable write FScreenEffectsEnable default true;
Public property Projection: TProjection read FProjection; deprecated 'in most cases, you can instead read Camera parameters, like Camera.Orthographic.EffectiveWidth, Camera.Orthographic.EffectiveHeight';
Public property BackgroundColor: TCastleColor read FBackgroundColor write FBackgroundColor;
Public property ScreenSpaceAmbientOcclusion: boolean read FScreenSpaceAmbientOcclusion write SetScreenSpaceAmbientOcclusion default DefaultScreenSpaceAmbientOcclusion;
Public property ScreenSpaceReflections: Boolean read FScreenSpaceReflections write SetScreenSpaceReflections default DefaultScreenSpaceReflections;
Public property ScreenSpaceReflectionsSurfaceGlossiness: Single read FScreenSpaceReflectionsSurfaceGlossiness write SetScreenSpaceReflectionsSurfaceGlossiness;
Public property OnCameraChanged: TNotifyEvent read FOnCameraChanged write FOnCameraChanged;
Public property MouseRayHit: TRayCollision read GetMouseRayHit;
Public property AvoidNavigationCollisions: TCastleTransform read FAvoidNavigationCollisions write SetAvoidNavigationCollisions;
Public property Paused: boolean read GetPaused write SetPaused default false; deprecated 'use Items.Paused';
Public property Navigation: TCastleNavigation read GetNavigation write SetNavigation stored false; deprecated 'instead of this property: to get, just remember current navigation instance on your side; to set, add it like "MyViewport.InsertBack(MyNavigation)"';
Published property Items: TCastleRootTransform read FItems write SetItems;
Published property Camera: TCastleCamera read FCamera write SetCamera;
Published property ShadowVolumes: boolean read FShadowVolumes write FShadowVolumes default DefaultShadowVolumes;
Published property ShadowVolumesRender: boolean read FShadowVolumesRender write FShadowVolumesRender default false;
Published property Background: TCastleBackground read FBackground write SetBackground;
Published property Fog: TCastleFog read FFog write SetFog;
Published property BackgroundWireframe: boolean read FBackgroundWireframe write FBackgroundWireframe default false;
Published property Transparent: boolean read FTransparent write FTransparent default false;
Published property ClearDepth: boolean read FClearDepth write FClearDepth default true;
Published property UseGlobalLights: boolean read FUseGlobalLights write FUseGlobalLights default DefaultUseGlobalLights; deprecated 'if you need to tweak this, then do not use MainScene; use regular TCastleScene and set CastGlobalLights as needed';
Published property UseGlobalFog: boolean read FUseGlobalFog write FUseGlobalFog default DefaultUseGlobalFog; deprecated 'configure fog by assigning to TCastleViewport.Fog component; leave deprecated MyViewport.Items.MainScene = nil';
Published property ApproximateActivation: boolean read FApproximateActivation write FApproximateActivation default false;
Published property OnProjection: TProjectionEvent read FOnProjection write FOnProjection; deprecated 'adjust projection by changing Camera.ProjectionType and other projection parameters inside Camera';
Published property EnableParentDragging: boolean read FEnableParentDragging write FEnableParentDragging default false;
Published property AutoCamera: Boolean read FAutoCamera write SetAutoCamera default false; deprecated 'it is simpler to set camera at design-time explicitly, or use CameraViewpointForWholeScene to auto-adjust camera; if you want to animate the camera, attach TCastleCamera to a bone transformation exposed by Scene.ExposeTransforms';
Published property OnBoundViewpointChanged: TNotifyEvent read FOnBoundViewpointChanged write FOnBoundViewpointChanged;
Published property OnBoundNavigationInfoChanged: TNotifyEvent read FOnBoundNavigationInfoChanged write FOnBoundNavigationInfoChanged;
Published property PreventInfiniteFallingDown: Boolean read FPreventInfiniteFallingDown write FPreventInfiniteFallingDown default false;
Published property DynamicBatching: Boolean read FDynamicBatching write SetDynamicBatching default false;
Published property OcclusionCulling: boolean read FOcclusionCulling write SetOcclusionCulling default false;
Published property OcclusionSort: TShapeSort read FOcclusionSort write FOcclusionSort default sortAuto;
Published property BlendingSort: TShapeSort read FBlendingSort write FBlendingSort default sortAuto;
Published property OnCustomShapeSort: TShapeSortEvent read FOnCustomShapeSort write FOnCustomShapeSort;
Published property UpdateSoundListener: Boolean read FUpdateSoundListener write FUpdateSoundListener default true;
Published property BackgroundColorPersistent: TCastleColorPersistent read FBackgroundColorPersistent ;

Description

Constants

Public DefaultWidth = 100.0;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 310).

Public DefaultHeight = 100.0;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 311).

Public DefaultScreenSpaceAmbientOcclusion = false;

This item has no description.

Source: scene/castleviewport.pas (line 442).

Public DefaultScreenSpaceReflections = False;

This item has no description.

Source: scene/castleviewport.pas (line 443).

Public DefaultScreenSpaceReflectionsSurfaceGlossiness = 0.5;

This item has no description.

Source: scene/castleviewport.pas (line 444).

Public DefaultUseGlobalLights = true;

This item has no description.

Source: scene/castleviewport.pas (line 445).

Public DefaultUseGlobalFog = true;

This item has no description.

Source: scene/castleviewport.pas (line 446).

Public DefaultShadowVolumes = true;

This item has no description.

Source: scene/castleviewport.pas (line 447).

Public DefaultBackgroundColor: TVector4 = (X: 0.1; Y: 0.1; Z: 0.1; W: 1);

This item has no description.

Source: scene/castleviewport.pas (line 448).

Public Default2DProjectionFar = CastleTransform.Default2DProjectionFar deprecated 'this default is not used; ProjectionFar in orthographic projection is now automatically adjusted to what you display';

Warning: this symbol is deprecated: this default is not used; ProjectionFar in orthographic projection is now automatically adjusted to what you display

referencing deprecated in deprecated

Source: scene/castleviewport.pas (line 450).

Public Default2DProjectionNear = CastleTransform.Default2DProjectionNear deprecated 'this default is not used; ProjectionNear in orthographic projection is now automatically adjusted to what you display';

Warning: this symbol is deprecated: this default is not used; ProjectionNear in orthographic projection is now automatically adjusted to what you display

This item has no description.

Source: scene/castleviewport.pas (line 451).

Public Default2DCameraZ = CastleTransform.Default2DCameraZ;

This item has no description.

Source: scene/castleviewport.pas (line 453).

Public DefaultPrepareOptions = [prRenderSelf, prRenderClones, prBackground, prBoundingBox, prScreenEffects];

This item has no description.

Source: scene/castleviewport.pas (line 454).

Public DefaultInternalGridAxis = false;

This item has no description.

Source: scene/castleviewport.pas (line 457).

Fields

Protected RenderScreenEffects: Boolean;

This item is declared in ancestor TCastleScreenEffects.

Valid only between Render and RenderOverChildren calls. Tells whether we actually use screen effects, thus RenderWithoutScreenEffects renders to texture. Read-only in descendants.

Source: scene/castlescreeneffects.pas (line 107).

Public var CustomRenderingPass: TUserRenderingPass;

Rendering pass, for user purposes. Useful to keep shaders cached when you render the same scene multiple times in the same frame (under different lighting conditions or other things that change shaders). By default this is always 0, the engine doesn't modify this. You can set this field manually.

Source: scene/castleviewport.pas (line 466).

Public InternalDesignCamera: TCastleCamera;

At design-time (in CGE editor), this is the camera used by the editor. Usually use InternalCamera, to automatically pick either design-time camera or runtime Camera.

Source: scene/castleviewport.pas (line 491).

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

Protected function ContainerWidth: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil"';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth" or "Container.PixelsWidth" after checking "Container <> nil"

Container sizes.

Source: ui/castleuicontrols_userinterface.inc (line 261).

Protected function ContainerHeight: Cardinal; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil"';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledHeight" or "Container.PixelsHeight" after checking "Container <> nil"

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 262).

Protected function ContainerRect: TRectangle; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil"';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledRect" or "Container.PixelsRect" after checking "Container <> nil"

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 263).

Protected function ContainerSizeKnown: boolean; virtual; deprecated 'arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil"';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: arrange UI using anchors, FullSize and friends; if you really need container size, use "Container.UnscaledWidth/Height" or "Container.PixelsWidth/Height" after checking "Container <> nil"

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 264).

Protected procedure DoCursorChange; virtual; deprecated 'better override VisibleChange and watch for chCursor in Changes';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: better override VisibleChange and watch for chCursor in Changes

Called when Cursor changed. In TCastleUserInterface class, just calls OnCursorChange.

Source: ui/castleuicontrols_userinterface.inc (line 270).

Protected procedure DefineProperties(Filer: TFiler); override;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 274).

Protected procedure UIScaleChanged; virtual;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 276).

Protected procedure PreferredSize(var PreferredWidth, PreferredHeight: Single); virtual;

This item is declared in ancestor TCastleUserInterface.

Controls that have a preferred size should override this. By default this contains values derived from Width, WidthFraction, Height, HeightFraction, with Border subtracted.

Note that the arguments should be already scaled, i.e. multiplied by UIScale, i.e. expressed in final device pixels.

Note that the returned PreferredWidth and PreferredHeight must not include the space for Border. Border size will be added later.

Source: ui/castleuicontrols_userinterface.inc (line 291).

Protected procedure BeforeSizing; virtual;

This item is declared in ancestor TCastleUserInterface.

Called right before calculating size. This is your only chance to adjust e.g. children size, if you need them to be synchronized with something, and you may use AutoSizeToChildren.

In most use-cases, you rather adjust preferred size by overriding PreferredSize.

Source: ui/castleuicontrols_userinterface.inc (line 300).

Protected procedure DoInternalMouseEnter; virtual;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 302).

Protected procedure DoInternalMouseLeave; virtual;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 303).

Protected function Theme: TCastleTheme;

This item is declared in ancestor TCastleUserInterface.

Theme that should be used by this control. Either CustomTheme or global Theme.

Source: ui/castleuicontrols_userinterface.inc (line 307).

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

This item is declared in ancestor TCastleUserInterface.

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

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

Source: ui/castleuicontrols_userinterface.inc (line 317).

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

This item is declared in ancestor TCastleUserInterface.

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

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

Source: ui/castleuicontrols_userinterface.inc (line 318).

Public function GetEnumerator: TEnumerator;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 319).

Public procedure InternalSetContainer(const Value: TCastleContainer); virtual;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 320).

Public function PreviewPress(const Event: TInputPressRelease): boolean; virtual;

This item is declared in ancestor TCastleUserInterface.

Similar to Press but allows the parent control to preview the event before it is passed to children UI controls.

See also
Press
Override this method to react to user pressing a key, mouse button or mouse wheel.

Source: ui/castleuicontrols_userinterface.inc (line 397).

Public function PreviewRelease(const Event: TInputPressRelease): boolean; virtual;

This item is declared in ancestor TCastleUserInterface.

Similar to Release but allows the parent control to preview the event before it is passed to children UI controls.

See also
Press
Override this method to react to user pressing a key, mouse button or mouse wheel.

Source: ui/castleuicontrols_userinterface.inc (line 403).

Public function SensorRotation(const X, Y, Z, Angle: Double; const SecondsPassed: Single): boolean; virtual;

This item is declared in ancestor TCastleUserInterface.

Rotation detected by 3D sensor. Used for example by 3Dconnexion devices.

Parameters
X
X axis (tilt forward/backwards)
Y
Y axis (rotate)
Z
Z axis (tilt sidewards)
Angle
Angle of rotation (in radians)
SecondsPassed
The time passed since last SensorRotation call. This is necessary because some sensors, e.g. 3Dconnexion, may *not* reported as often as normal Update calls.

Source: ui/castleuicontrols_userinterface.inc (line 418).

Public function SensorTranslation(const X, Y, Z, Length: Double; const SecondsPassed: Single): boolean; virtual;

This item is declared in ancestor TCastleUserInterface.

Translation detected by 3D sensor. Used for example by 3Dconnexion devices.

Parameters
X
X axis (move left/right)
Y
Y axis (move up/down)
Z
Z axis (move forward/backwards)
Length
Length of the vector consisting of the above
SecondsPassed
The time passed since last SensorRotation call. This is necessary because some sensors, e.g. 3Dconnexion, may *not* reported as often as normal Update calls.

Source: ui/castleuicontrols_userinterface.inc (line 430).

Public procedure VisibleChange(const Changes: TCastleUserInterfaceChanges; const ChangeInitiatedByChildren: boolean = false); overload; virtual;

This item is declared in ancestor TCastleUserInterface.

Called always when something important inside this control (or it's children) changed. To be more precise, this is called when something mentioned among the TCastleUserInterfaceChange enumerated items changed.

This is always called with Changes <> [] (non-empty set).

Source: ui/castleuicontrols_userinterface.inc (line 512).

Public procedure Resize; virtual;

This item is declared in ancestor TCastleUserInterface.

Event called when the container (component or window with OpenGL context) size changes.

You can resize/reposition your component here to react to parent size changes. This is called only when the rendering context of the container is initialized, so you can be sure that this is called only between GLContextOpen and GLContextClose.

We also call this once when inserting into the controls list (like TCastleWindow.Controls or TCastleControl.Controls or inside parent TCastleUserInterface), if inserting into the container/parent with already initialized OpenGL context. If inserting into the container/parent without OpenGL context initialized, it will be called later, when OpenGL context will get initialized, right after GLContextOpen.

In other words, this is always called to let the control know the size of the container, if and only if the OpenGL context is initialized.

Source: ui/castleuicontrols_userinterface.inc (line 556).

Public function ControlsCount: Integer;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 587).

Public procedure InsertFront(const NewItem: TCastleUserInterface); overload;

This item is declared in ancestor TCastleUserInterface.

Add child control, at the front of other children.

Source: ui/castleuicontrols_userinterface.inc (line 590).

Public procedure InsertFrontIfNotExists(const NewItem: TCastleUserInterface);

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 591).

Public procedure InsertFront(const NewItems: TCastleUserInterfaceList); overload;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 592).

Public procedure InsertBack(const NewItem: TCastleUserInterface); overload;

This item is declared in ancestor TCastleUserInterface.

Add child control, at the back of other children.

Source: ui/castleuicontrols_userinterface.inc (line 595).

Public procedure InsertBackIfNotExists(const NewItem: TCastleUserInterface);

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 596).

Public procedure InsertBack(const NewItems: TCastleUserInterfaceList); overload;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 597).

Public procedure InsertControl(const Index: Integer; const NewItem: TCastleUserInterface);

This item is declared in ancestor TCastleUserInterface.

Add child control at specified position. It is usually easier to use InsertFront or InsertBack, if possible.

Source: ui/castleuicontrols_userinterface.inc (line 602).

Public procedure RemoveControl(const Item: TCastleUserInterface);

This item is declared in ancestor TCastleUserInterface.

Remove control added by InsertFront or InsertBack.

Note that this method does not free the Item instance. This method merely removes Item from our controls, so that Item is no longer rendered as part of this parent. It is still the caller's responsibility to make sure the Item is freed at some point.

See https://castle-engine.io/modern_pascal#_freeing_classes for description how to free instances in Pascal. As TCastleUserInterface descends from TComponent, a simple and proper solution is often just to create it with some "owner" (like TCastleView.FreeAtStop or Application) that will take care of freeing it.

Source: ui/castleuicontrols_userinterface.inc (line 617).

Public function IndexOfControl(const Item: TCastleUserInterface): Integer;

This item is declared in ancestor TCastleUserInterface.

Index of child control, or -1 if not present.

Source: ui/castleuicontrols_userinterface.inc (line 620).

Public procedure ClearControls;

This item is declared in ancestor TCastleUserInterface.

Remove all child controls added by InsertFront or InsertBack.

Note that, just like RemoveControl, this method does not free the children controls. This method merely removes children controls, so they are no longer rendered as part of the parent. It is still the caller's responsibility to make sure the children controls are freed at some point.

See https://castle-engine.io/modern_pascal#_freeing_classes for description how to free instances in Pascal. As TCastleUserInterface descends from TComponent, a simple and proper solution is often just to create it with some "owner" (like TCastleView.FreeAtStop or Application) that will take care of freeing it.

Source: ui/castleuicontrols_userinterface.inc (line 635).

Public procedure MoveToFront;

This item is declared in ancestor TCastleUserInterface.

Move to become the front-most control within the parent.

This works when this control is a child of another control (has Parent assigned) or when it's a direct child of the container (in which case Parent is not assigned by Container is, which means the control is directly on TCastleContainer.Controls list).

This is ignored if this control is not within any container (so, also not within any parent).

Source: ui/castleuicontrols_userinterface.inc (line 646).

Public function CapturesEventsAtPosition(const Position: TVector2): boolean; virtual;

This item is declared in ancestor TCastleUserInterface.

Does this control capture events under this container position. The default implementation simply checks whether Position is inside RenderRect. It also checks whether CapturesEvents is True.

Always treated like False when Exists returns False, so the implementation of this method only needs to make checks assuming that Exists = True.

Source: ui/castleuicontrols_userinterface.inc (line 660).

Public function TooltipExists: Boolean; virtual; deprecated 'use TooltipControl to customize tooltip look';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use TooltipControl to customize tooltip look

Render a tooltip of this control. If you want to have tooltip for this control detected, you have to override TooltipExists. Then the TooltipRender will be called.

TooltipRender is called in the same way as Render. TooltipRender is always called as a last (front-most) control. Argument TooltipPosition is the left-bottom (in screen space, regardless of UIScaling) suggested position of the tooltip.

It is simplest to descend from TCastleUserInterfaceFont, that implements simple TCastleUserInterfaceFont.Tooltip property and overrides these two methods as necessary.

Source: ui/castleuicontrols_userinterface.inc (line 741).

Public procedure TooltipRender(const TooltipPosition: TVector2); virtual; deprecated 'use TooltipControl to customize tooltip look';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use TooltipControl to customize tooltip look

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 742).

Public procedure SetFocused(const Value: boolean); virtual;

This item is declared in ancestor TCastleUserInterface.

Called when this control becomes or stops being focused, that is: under the mouse cursor and will receive events.

This updates Focused property. This also calls OnInternalMouseEnter / OnInternalMouseLeave.

Source: ui/castleuicontrols_userinterface.inc (line 813).

Public function EffectiveRect: TFloatRectangle;

This item is declared in ancestor TCastleUserInterface.

Control position and size. Use this to base other controls size/position on this control's calculated size/position.

The algorithm that determines control position and size is like this:

The above describes the size of the content and border, summed. The content itself may be a little smaller, when the Border is used. The size of the "content itself" is returned only by RenderRect (in already-scaled coordinates, i.e. using final device pixels).

The anchors (see Anchor) also affect the final position of the control.

Note that some descendants do auto-sizing by default. This means that some of these properties may be ignored, and instead the calculated size (EffectiveWidth, EffectiveHeight) depends on some core values of the control.

For example:

Consult the documentation of each descendant for the exact specification of the size behavior.

This method returns the rectangle in local coordinates (relative to the parent 2D control). The returned rectangle size includes the border size. The returned rectangle size uses "unscaled" coordinates, which means that they correspond to the sizes you set e.g. in TCastleUserInterface.Width, TCastleUserInterface.Height, and translation units you use with e.g. TCastleUserInterface.Anchor.

If you're looking for a way to query the size of the control in final scaled coordinates (in real device pixels), and not relative to the parent position, use RenderRect or RenderRectWithBorder instead.

This method ignores the current value of the Exists method and Exists property, that is: the result of this function assumes that control does exist.

See also
TCastleUserInterface.EffectiveWidth
Calculated width of the control, without UI scaling.
TCastleUserInterface.EffectiveHeight
Calculated height of the control, without UI scaling.

Source: ui/castleuicontrols_userinterface.inc (line 927).

Public function EffectiveWidth: Single;

This item is declared in ancestor TCastleUserInterface.

Calculated width of the control, without UI scaling. Useful if you want to base other controls size/position on this control calculated size.

Unlike the Width property, this is the effective size, not the desired size. So this is already processed by any auto-sizing mechanism (e.g. TCastleImageControl may adjust it's own size to the underlying image, depending on settings), it is changed by FullSize and so on.

It is always equal to just EffectiveRect.Width. It is 0 when EffectiveRect is empty.

See also
EffectiveRect
Control position and size.

Source: ui/castleuicontrols_userinterface.inc (line 943).

Public function EffectiveHeight: Single;

This item is declared in ancestor TCastleUserInterface.

Calculated height of the control, without UI scaling. Useful if you want to base other controls size/position on this control calculated size.

Unlike the Height property, this is the effective size, not the desired size. So this is already processed by any auto-sizing mechanism (e.g. TCastleImageControl may adjust it's own size to the underlying image, depending on settings), it is changed by FullSize and so on.

It is always equal to just EffectiveRect.Height. It is 0 when EffectiveRect is empty.

See also
EffectiveRect
Control position and size.

Source: ui/castleuicontrols_userinterface.inc (line 959).

Public function EffectiveWidthForChildren: Single;

This item is declared in ancestor TCastleUserInterface.

EffectiveWidth without Border size.

Source: ui/castleuicontrols_userinterface.inc (line 962).

Public function EffectiveHeightForChildren: Single;

This item is declared in ancestor TCastleUserInterface.

EffectiveHeight without Border size.

Source: ui/castleuicontrols_userinterface.inc (line 964).

Public function CalculatedWidth: Cardinal; deprecated 'use EffectiveWidth';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use EffectiveWidth

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 966).

Public function CalculatedHeight: Cardinal; deprecated 'use EffectiveHeight';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use EffectiveHeight

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 967).

Public function CalculatedRect: TRectangle; deprecated 'use EffectiveRect';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use EffectiveRect

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 968).

Public function RenderRect: TFloatRectangle;

This item is declared in ancestor TCastleUserInterface.

Position and size of this control, assuming it exists, in container coordinates (in final device pixels). The primary use of this is inside Render. A proper UI control should adjust to draw precisely in this rectangle.

Source: ui/castleuicontrols_userinterface.inc (line 974).

Public function RenderRectWithBorder: TFloatRectangle;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 975).

Public function ScreenRect: TRectangle; deprecated 'use RenderRect';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use RenderRect

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 977).

Public function ContainerToLocalPosition(ContainerPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2;

This item is declared in ancestor TCastleUserInterface.

Convert position relative to container (in final device coordinates, without UI scaling, by default) into position relative to this UI control (in coordinates with UI scaling). Useful e.g. to convert mouse/touch position from TInputPressRelease.Position into position useful for children of this UI control.

The exact definition is that using the result of this to set our child Translation, assuming the child is anchored to the left-bottom (the default state) and child has Left = Bottom = 0, sets child position exactly to the indicated point on the container.

Parameters
ContainerPositionScaled
If True (default) then the container position (the ContainerPosition parameter) is assumed to be in final device pixels, i.e. the window area in X is from 0 to TCastleContainer.Width, in Y from 0 and TCastleContainer.Height. This is useful when the parameter comes e.g. from TInputPressRelease.Position.

If False then the container position (the ContainerPosition parameter) is assumed to be in unscaled device pixels, i.e. the window area in X is from 0 to TCastleContainer.UnscaledWidth, in Y from 0 and TCastleContainer.UnscaledHeight.

Source: ui/castleuicontrols_userinterface.inc (line 1003).

Public function LocalToContainerPosition(const LocalPosition: TVector2; const ContainerPositionScaled: Boolean = true): TVector2;

This item is declared in ancestor TCastleUserInterface.

Convert position relative to this UI control (in coordinates with UI scaling) into relative to container (in final device coordinates, without UI scaling, by default). Reverses ContainerToLocalPosition.

Parameters
ContainerPositionScaled
If True (default) then the container position (the result of this method) is assumed to be in final device pixels, i.e. the window area in X is from 0 to TCastleContainer.Width, in Y from 0 and TCastleContainer.Height.

If False then the container position (the result of this method) is assumed to be in unscaled device pixels, i.e. the window area in X is from 0 to TCastleContainer.UnscaledWidth, in Y from 0 and TCastleContainer.UnscaledHeight.

Source: ui/castleuicontrols_userinterface.inc (line 1022).

Public function ParentRect: TFloatRectangle;

This item is declared in ancestor TCastleUserInterface.

Rectangle filling the parent control (or container), in local coordinates. Since this is in local coordinates, the returned rectangle Left and Bottom are always zero, unless parent has Border (the returned rectangle is shrunk by Parent.Border). This is already scaled by UI scaling.

Source: ui/castleuicontrols_userinterface.inc (line 1030).

Public procedure Anchor(const AHorizontalAnchor: THorizontalPosition; const TranslationX: Single = 0); overload;

This item is declared in ancestor TCastleUserInterface.

Adjust position to align us with the parent horizontally. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position.

Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly.

This utility method sets HorizontalAnchorSelf, HorizontalAnchorParent, Translation.X.

Source: ui/castleuicontrols_userinterface.inc (line 1042).

Public procedure Anchor( const AHorizontalAnchorSelf, AHorizontalAnchorParent: THorizontalPosition; const TranslationX: Single = 0); overload;

This item is declared in ancestor TCastleUserInterface.

Adjust position to align us with the parent horizontally. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position.

Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly.

This utility method sets HorizontalAnchorSelf, HorizontalAnchorParent, Translation.X.

Source: ui/castleuicontrols_userinterface.inc (line 1055).

Public procedure Anchor(const AVerticalAnchor: TVerticalPosition; const TranslationY: Single = 0); overload;

This item is declared in ancestor TCastleUserInterface.

Adjust position to align us to the parent vertically. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position.

Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly.

This utility method sets VerticalAnchorSelf, VerticalAnchorParent, Translation.Y.

Source: ui/castleuicontrols_userinterface.inc (line 1069).

Public procedure Anchor( const AVerticalAnchorSelf, AVerticalAnchorParent: TVerticalPosition; const TranslationY: Single = 0); overload;

This item is declared in ancestor TCastleUserInterface.

Adjust position to align us to the parent vertically. The resulting EffectiveRect and RenderRect and RenderRectWithBorder will immediately reflect the new position.

Note that position set here (anchors, Translation) are ignored when FullSize is set to true. In case of FullSize, the control fills the parent perfectly.

This utility method sets VerticalAnchorSelf, VerticalAnchorParent, Translation.Y.

Source: ui/castleuicontrols_userinterface.inc (line 1082).

Public procedure AlignHorizontal( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const X: Single = 0); deprecated 'use Anchor';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Anchor

Immediately position the control with respect to the parent by adjusting Left. Deprecated, use Align with THorizontalPosition.

Source: ui/castleuicontrols_userinterface.inc (line 1091).

Public procedure Align( const ControlPosition: THorizontalPosition; const ContainerPosition: THorizontalPosition; const X: Single = 0); overload; deprecated 'use Anchor';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Anchor

Immediately position the control with respect to the parent by adjusting Left.

Note that using Anchor is often more comfortable than this method, since you only need to set anchor once (for example, right after creating the control). In contrast, adjusting position using this method will typically need to be repeated at each window on resize, like in TCastleUserInterface.Resize.

Source: ui/castleuicontrols_userinterface.inc (line 1104).

Public procedure AlignVertical( const ControlPosition: TPositionRelative = prMiddle; const ContainerPosition: TPositionRelative = prMiddle; const Y: Single = 0); deprecated 'use Anchor';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Anchor

Immediately position the control with respect to the parent by adjusting Bottom. Deprecated, use Align with TVerticalPosition.

Source: ui/castleuicontrols_userinterface.inc (line 1112).

Public procedure Align( const ControlPosition: TVerticalPosition; const ContainerPosition: TVerticalPosition; const Y: Single = 0); overload; deprecated 'use Anchor';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Anchor

Immediately position the control with respect to the parent by adjusting Bottom.

Note that using Anchor is often more comfortable than this method, since you only need to set anchor once (for example, right after creating the control). In contrast, adjusting position using this method will typically need to be repeated at each window on resize, like in TCastleUserInterface.Resize.

Source: ui/castleuicontrols_userinterface.inc (line 1125).

Public procedure Center; deprecated 'use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Anchor(hpMiddle); Anchor(vpMiddle); to reliably center the control

Immediately center the control within the parent, both horizontally and vertically.

Note that using Anchor is often more comfortable than this method, since you only need to set anchor once. For example, right after creating the control call Anchor(hpMiddle); Anchor(vpMiddle);. In contrast, adjusting position using this method will typically need to be repeated at each window on resize, like in TCastleUserInterface.Resize.

Source: ui/castleuicontrols_userinterface.inc (line 1141).

Public function UIScale: Single; virtual;

This item is declared in ancestor TCastleUserInterface.

UI scale of this control, derived from container (see TCastleContainer.UIScaling and EnableUIScaling).

Source: ui/castleuicontrols_userinterface.inc (line 1145).

Public procedure EditorAllowResize(out ResizeWidth, ResizeHeight: Boolean; out Reason: String); virtual;

This item is declared in ancestor TCastleUserInterface.

Override this to prevent resizing some dimension in CGE editor.

Source: ui/castleuicontrols_userinterface.inc (line 1148).

Public function EffectiveFullSize: Boolean;

This item is declared in ancestor TCastleUserInterface.

Is the FullSize actually active. Checks FullSize and not AutoSizeToChildren, i.e. it accounts that AutoSizeToChildren overrides FullSize (since they cannot both work at the same time).

Source: ui/castleuicontrols_userinterface.inc (line 1254).

Public procedure AddScreenEffect(const Node: TAbstractChildNode);

This item is declared in ancestor TCastleScreenEffects.

Add or remove a ScreenEffect node that defines new shader screen effect. See https://castle-engine.io/x3d_extensions_screen_effects.php .

In the simple case, you can pass here an instance of TScreenEffectNode. In a general case, you can passs here any X3D node you want, just remember that only the TScreenEffectNode inside will be rendered. You can e.g. pass a TGroupNode with TScreenEffectNode and TTimeSensorNode as children, and use TTimeSensorNode to provide time to your shader uniform parameter. Or you can e.g. pass an X3D graph loaded from X3D file using X3DLoad.LoadNode, this way you can define effects inside an external X3D file, e.g. like this:

ScreenEffects.AddScreenEffect(
  LoadNode('castle-data:/screen_effects_scene.x3dv'));

If you're looking for inspirations what to put in screen_effects_scene.x3dv, see https://github.com/castle-engine/demo-models/tree/master/screen_effects . See also CGE example in "examples/screen_effects_demo/" directory ( https://github.com/castle-engine/castle-engine/tree/master/examples/screen_effects_demo ) that shows more screen effects code, and shows how to load or construct X3D node graph with ScreenEffect.

The memory management of the node added here is automatic: the added screen effect becomes owned by the internal X3D Group node. It's reference-count is increased at AddScreenEffect, and decreased at RemoveScreenEffect, and it is automatically freed when reference-count drops to zero.

This means that, if you create the provided Node by code, and don't add it anywhere else, then the node will be freed automatically at our destructor (if you call AddScreenEffect and do not call RemoveScreenEffect on it), or at RemoveScreenEffect call. If you don't want this, use TX3DNode.WaitForRelease to manage the node destruction yourself.

Note that the given Node should not be used by other TCastleScene instances. In general, a node should not be present in more than one TCastleScene instance, and we already insert the node into an internal TCastleScene instance. Use TX3DNode.DeepCopy if necessary to duplicate node into multiple scenes.

Note that you can enable/disable the effect using TScreenEffectNode.Enabled, or enable/disable all using ScreenEffectsEnable. You do not need to remove the node by RemoveScreenEffect if you only want to disable it temporarily.

Source: scene/castlescreeneffects.pas (line 183).

Public procedure RemoveScreenEffect(const Node: TAbstractChildNode);

This item is declared in ancestor TCastleScreenEffects.

This item has no description.

Source: scene/castlescreeneffects.pas (line 184).

Public procedure Render; override;

This item is declared in ancestor TCastleScreenEffects.

This item has no description. Showing description inherited from TCastleUserInterface.Render.

Render a control. Called only when Exists and render context is initialized.

Do not call this method. It will be automatically called by the engine when needed. It will be called when UI is part of TCastleContainer.Controls list or rendered (e.g. for off-screen rendering) by TCastleContainer.RenderControl.

You should only override this method.

See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here.

You can depend on some OpenGL state being set before calling this method. You can depend on it being set, and you can carelessly change it. This state we set:

  • Viewport is set to include whole container.

  • Depth test is off.

  • For ancient fixed-function pipeline (see TGLFeatures.RequestCapabilities):

    • The 2D orthographic projection is always set at the beginning. Useful for 2D controls.

    • The modelview matrix is set to identity. The matrix mode is always modelview.

    • The raster position is set to (0,0). The (deprecated) WindowPos is also set to (0,0).

    • Texturing, lighting, fog is off.

Beware that GLSL RenderContext.CurrentProgram has undefined value when this is called. You should always set it, before making direct OpenGL drawing calls (all the engine drawing routines do it already, this is only a concern if you make direct OpenGL / OpenGLES calls).

Source: scene/castlescreeneffects.pas (line 187).

Public procedure RenderOverChildren; override;

This item is declared in ancestor TCastleScreenEffects.

This item has no description. Showing description inherited from TCastleUserInterface.RenderOverChildren.

Render a control contents over the children controls. This is analogous to Render, but it executes after children are drawn. You should usually prefer to override Render instead of this method, as the convention is that the parent is underneath children.

You should only override this method (do not call it, it will be called by the engine).

See https://castle-engine.io/manual_2d_ui_custom_drawn.php for examples what you can put here.

Source: scene/castlescreeneffects.pas (line 188).

Public procedure PrepareResources;

This item is declared in ancestor TCastleScreenEffects.

Make the screen effects rendering resources ready (e.g. link shaders).

Source: scene/castlescreeneffects.pas (line 209).

Protected function CalculateProjection: TProjection; virtual;

Calculate projection parameters. Determines if the view is perspective or orthogonal and exact field of view parameters. Called each time at the beginning of rendering.

The default implementation of this method in TCastleViewport calculates projection based on the Camera parameters.

In turn, the Camera parameters may be automatically calculated (if AutoCamera) based on the nodes in the TCastleRootTransform.MainScene. Nodes like TViewpointNode or TOrthoViewpointNode or TNavigationInfoNode determine the default camera and projection details.

You can override this method, or assign the OnProjection event to adjust the projection settings. But please note: instead of overriding this method, it's usually easier (and more advised) to simply change the Camera properties, like Camera.ProjectionType or Camera.Orthographic.Width or Camera.Perspective.FieldOfView.

Source: scene/castleviewport.pas (line 390).

Protected procedure InitializeGlobalLights(const GlobalLights: TLightInstancesList); virtual;

Prepare lights shining on everything. GlobalLights contents should be initialized here. The implementation in this class adds headlight determined by the Items.UseHeadlight value.

Source: scene/castleviewport.pas (line 396).

Protected procedure InitializeLights(const GlobalLights: TLightInstancesList); deprecated 'use InitializeGlobalLights';

Warning: this symbol is deprecated: use InitializeGlobalLights

This item has no description.

Source: scene/castleviewport.pas (line 398).

Protected procedure RenderFromViewEverything(const RenderingCamera: TRenderingCamera); virtual;

Render everything from given camera view (as TRenderingCamera). Given RenderingCamera.Target says to where we generate the image. This method must take care of making many rendering passes for shadow volumes, but doesn't take care of updating generated textures.

Source: scene/castleviewport.pas (line 404).

Protected procedure RenderFromView3D(const Params: TRenderParams); virtual;

Render the scene, assuming that buffers were already cleared and background was rendered. Called by RenderFromViewEverything at the end. Lights are calculated in Params at this point.

Source: scene/castleviewport.pas (line 409).

Protected procedure RenderOnePass(const Params: TRenderParams; const PassParams: TRenderOnePassParams); virtual;

Render one pass, with current camera and parameters. All current camera settings are saved in RenderParams.RenderingCamera.

Parameters
Params
Rendering parameters, see TRenderParams. TODO: move all relevant to TRenderOnePassParams.
PassParams
Rendering parameters of this pass, see TRenderOnePassParams.

Source: scene/castleviewport.pas (line 419).

Protected procedure Notification(AComponent: TComponent; Operation: TOperation); override;

This item has no description.

Source: scene/castleviewport.pas (line 422).

Protected function InternalExtraGetScreenEffects( const Index: Integer): TGLSLProgram; override;

This item has no description.

Source: scene/castleviewport.pas (line 424).

Protected function InternalExtraScreenEffectsCount: Integer; override;

This item has no description.

Source: scene/castleviewport.pas (line 426).

Protected function InternalExtraScreenEffectsNeedDepth: Boolean; override;

This item has no description.

Source: scene/castleviewport.pas (line 427).

Protected procedure PointingDevicePressFailed; virtual;

Called when PointingDevicePress was not handled by any TCastleTransform object. You can override this to make a message / sound signal to notify user that his Input_Interact click was not successful.

Source: scene/castleviewport.pas (line 432).

Protected procedure BoundNavigationInfoChanged; virtual;

This item has no description.

Source: scene/castleviewport.pas (line 434).

Protected procedure BoundViewpointChanged; virtual;

This item has no description.

Source: scene/castleviewport.pas (line 435).

Protected procedure RenderWithoutScreenEffects; override;

This item has no description. Showing description inherited from TCastleScreenEffects.RenderWithoutScreenEffects.

Descendants with special rendering code should override this, and never override Render or RenderOverChildren (as those two methods have special implementation in this class).

This rendering method will be called regardless if we have or not some screen effects. When no screen effects are actually used (e.g. AddScreenEffect wasn't used, InternalExtraScreenEffectsCount is zero), then our Render trivially calls this method without doing anything else.

Source: scene/castleviewport.pas (line 437).

Protected procedure Loaded; override;

This item has no description.

Source: scene/castleviewport.pas (line 439).

Public constructor Create(AOwner: TComponent); override;

This item has no description.

Source: scene/castleviewport.pas (line 493).

Public destructor Destroy; override;

This item has no description.

Source: scene/castleviewport.pas (line 494).

Public function AllowSuspendForInput: boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.AllowSuspendForInput.

Allow window containing this control to suspend waiting for user input. Typically you want to override this to return False when you do something in the overridden Update method.

In this class, this simply returns always True.

Source: scene/castleviewport.pas (line 496).

Public function Press(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Press.

Override this method to react to user pressing a key, mouse button or mouse wheel. Return True if the event was handled, which prevents from passing this event to other UI controls.

When implementing in descendants it is best to override it like this:

function TMyControl.Press(const Event: TInputPressRelease): boolean;
begin
  Result := inherited;
  if Result then Exit; // exit if ancestor already handled this event

  if Event.IsKey(keyEnter) then
  begin
    // do something in reaction to Enter key
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;

  if Event.IsMouseButton(buttonLeft) then
  begin
    // do something in reaction to left mouse button press
    ...
    // let engine know that this input event was handled
    Exit(true);
  end;
end;

These events are generated for all UI controls, whether they are considered "interactive" or not. These events are generated for non-interactive controls like TCastleRectangleControl or TCastleLabel as well. For example, these events ignore the TCastleButton.Enabled state, they are generated always (see https://github.com/castle-engine/castle-engine/issues/413 ). Use instead TCastleButton.OnClick to detect clicks on a button in a way that honors the TCastleButton.Enabled state.

When a control returns True from Press, it means it starts to "capture" subsequent mouse events: subsequent mouse moves and release will be send to this control even if mouse will move outside of this control.

The events Press and Release are passed to the parent only after the children had a chance to process this event. Overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.Render, which is the standard place you should draw stuff. For example our TCastleButton draws there.

In contrast, the events PreviewPress and PreviewRelease are passed first to the parent control, before children have a chance to process this event. In partcular, overriding them makes sense if you draw something that "looks clickable" in TCastleUserInterface.RenderOverChildren.

Source: scene/castleviewport.pas (line 497).

Public function Release(const Event: TInputPressRelease): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Release.

Override this method to react to user releasing a key, mouse button. Return True if the event was handled, which prevents from passing this event to other UI controls.

This is counterpart to Press method. See Press for more details.

Note: We'd like this method to also be called when user releases a mouse wheel. But currently releasing of the mouse wheel is not reported now by any backend. Only releasing of keys and mouse buttons is reported.

Source: scene/castleviewport.pas (line 498).

Public function Motion(const Event: TInputMotion): boolean; override;

This item has no description. Showing description inherited from TCastleUserInterface.Motion.

Motion of mouse or touch.

Source: scene/castleviewport.pas (line 499).

Public procedure Update(const SecondsPassed: Single; var HandleInput: boolean); override;

This item has no description. Showing description inherited from TCastleUserInterface.Update.

Control may do here anything that must be continuously repeated. E.g. camera handles here falling down due to gravity, rotating model in Examine mode, and many more.

This method may be used, among many other things, to continuously react to the fact that user pressed some key (or mouse button). For example, if holding some key should move some 3D object, you should do something like:

if HandleInput then
begin
  if Container.Pressed[keyArrowRight] then
  begin
    Transform.Position := Transform.Position + Vector3(SecondsPassed * 10, 0, 0);
    HandleInput := false;
  end;
end;

Instead of directly using a key code, consider also using TInputShortcut that makes the input key nicely configurable. See engine tutorial about handling inputs.

Multiplying movement by SecondsPassed makes your operation frame-rate independent. Object will move by 10 units in a second, regardless of how many FPS your game has.

The code related to HandleInput is important if you write a generally-useful control that should nicely cooperate with all other controls, even when placed on top of them or under them. The correct approach is to only look at pressed keys/mouse buttons if HandleInput is True. Moreover, if you did check that HandleInput is True, and you did actually handle some keys, then you have to set HandleInput := false. This will prevent the other controls (behind the current control) from handling the keys (they will get HandleInput = False). And this is important to avoid doubly-processing the same key press, e.g. if two controls react to the same key, only the one on top should process it.

Note that to handle a single press / release (like "switch light on when pressing a key") you should rather use Press and Release methods. Use this method only for continuous handling (like "holding this key makes the light brighter and brighter").

To understand why such HandleInput approach is needed, realize that the "Update" events are called differently than simple mouse and key events like "Press" and "Release". "Press" and "Release" events return whether the event was somehow "handled", and the container passes them only to the controls under the mouse (decided by TCastleUserInterface.CapturesEventsAtPosition). And as soon as some control says it "handled" the event, other controls (even if under the mouse) will not receive the event.

This approach is not suitable for Update events. Some controls need to do the Update job all the time, regardless of whether the control is under the mouse and regardless of what other controls already did. So all controls (well, all controls that exist, in case of TCastleUserInterface, see TCastleUserInterface.Exists) receive Update calls.

So the "handled" status is passed through HandleInput. If a control is not under the mouse, it will receive HandleInput = False. If a control is under the mouse, it will receive HandleInput = True as long as no other control on top of it didn't already change it to False.

Source: scene/castleviewport.pas (line 500).

Public procedure BeforeRender; override;

This item has no description. Showing description inherited from TCastleUserInterface.BeforeRender.

Prepare your resources, right before drawing. Called only when Exists and GLInitialized.

Do not explicitly call this method. Instead, render controls by adding them to the TCastleContainer.Controls list, or render them explicitly (for off-screen rendering) by TCastleContainer.RenderControl.

Source: scene/castleviewport.pas (line 502).

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: scene/castleviewport.pas (line 503).

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: scene/castleviewport.pas (line 504).

Public function GetMainScene: TCastleScene; deprecated 'use Items.MainScene';

Warning: this symbol is deprecated: use Items.MainScene

This item has no description.

Source: scene/castleviewport.pas (line 550).

Public procedure AssignDefaultCamera; virtual;

Set current camera vectors and projection, to best reflect current Items.MainScene or current Items bounding box.

If Items.MainScene is set and it has a preferred camera (TViewpointNode, which can be specified in X3D, glTF, Collada files) then it will be used. Otherwise we calculate camera using CameraViewpointForWholeScne to see the whole world.

This method only fills existing Camera with contents, it doesn't change the Camera to a new component. It will do nothing if Camera is Nil.

This is automatically used at first rendering if AutoCamera (deprecated, only sensible now if you make X3D browser that must react to X3D events changing viewpoint). You can also use it explicitly (this is recommended).

Source: scene/castleviewport.pas (line 580).

Public function ScreenSpaceAmbientOcclusionAvailable: boolean;

Does the graphic card support our ScreenSpaceAmbientOcclusion shader. This does not depend on the current state of ScreenSpaceAmbientOcclusion property. You can use it e.g. to disable the menu item to switch SSAO in 3D viewer.

Source: scene/castleviewport.pas (line 586).

Public function ScreenSpaceReflectionsAvailable: boolean;

Does the graphic card support our ScreenSpaceReflections shader. This does not depend on the current state of ScreenSpaceReflections property. You can use it e.g. to disable the menu item to switch SSR in 3D viewer.

Source: scene/castleviewport.pas (line 592).

Public procedure GLContextOpen; override;

This item has no description. Showing description inherited from TCastleUserInterface.GLContextOpen.

Initialize your OpenGL resources.

This is called when OpenGL context of the container is created, or when the control is added to the already existing context. In other words, this is the moment when you can initialize OpenGL resources, like display lists, VBOs, OpenGL texture names, etc.

As an exception, this is called regardless of the Exists value. This way a control can prepare it's resources, regardless if it exists now.

Source: scene/castleviewport.pas (line 594).

Public procedure GLContextClose; override;

This item has no description. Showing description inherited from TCastleUserInterface.GLContextClose.

Destroy your OpenGL resources.

Called when OpenGL context of the container is destroyed. Also called when controls is removed from the container Controls list. Also called from the destructor.

You should release here any resources that are tied to the OpenGL context. In particular, the ones created in GLContextOpen.

As an exception, this is called regardless of the Exists value. This way a control can release it's resources, regardless if it exists now.

Source: scene/castleviewport.pas (line 595).

Public function PrepareParams: TPrepareParams; deprecated 'use TCastleViewport.PrepareResources to prepare transforms';

Warning: this symbol is deprecated: use TCastleViewport.PrepareResources to prepare transforms

Parameters to prepare items that are to be rendered within this world. This should be passed to TCastleTransform.PrepareResources.

Note: Instead of using TCastleTransform.PrepareResources, and this method, it's usually easier to call TCastleViewport.PrepareResources. Then the appropriate TPrepareParams will be passed automatically.

Source: scene/castleviewport.pas (line 605).

Public function BaseLights: TLightInstancesList; deprecated 'this is internal info, you should not need this; use PrepareParams to get opaque information to pass to TCastleTransform.PrepareResources';

Warning: this symbol is deprecated: this is internal info, you should not need this; use PrepareParams to get opaque information to pass to TCastleTransform.PrepareResources

This item has no description.

Source: scene/castleviewport.pas (line 607).

Public function Statistics: TRenderStatistics;

Statistics about last rendering frame. See TRenderStatistics docs.

Source: scene/castleviewport.pas (line 610).

Public function TriangleHit: PTriangle;

Current 3D triangle under the mouse cursor. Updated in every mouse move. May be Nil.

Source: scene/castleviewport.pas (line 624).

Public procedure Setup2D;

Utility method to set camera to a suitable state for 2D games.

  • Sets both initial and current camera vectors like this:

    • Position camera at (0, 0, 500),

    • Looks along the -Z direction,

    • "Up" vector is in +Y.

    This way the 2D world spans horizontally in X and vertically in Y. The Z (depth) can be used to put things in front/behind each other.

    Since this initialized the camera sensibly, we also set AutoCamera to false.

  • Sets orthographic projection for the camera (TCastleCamera.ProjectionType set to ptOrthographic).

    By default our visible X range is [0..viewport width in pixels], visible Y range is [0..viewport height in pixels]. Use the properties of Camera.Orthographic to control the projection. For example set Camera.Orthographic.Width and/or Camera.Orthographic.Height to define visible projection size (horizontal or vertical) explicitly, regardless of the viewport size.

    Setting Camera.Orthographic.Origin is also often useful, e.g. set it to (0.5,0.5) to make the things positioned at (0,0) in the world visible at the middle of the viewport.

    By default our visible Z range is [-1500, 500], because this sets ProjectionNear to -1000, ProjectionFar to 1000, and camera default depth (Camera.Translation.Z) is 500. This was chosen to be comfortable for all cases – you can keep camera Z unchanged and comfortably position things around [-500, 500], or set camera Z to zero and then comfortably position things around [-1000, 1000].

Source: scene/castleviewport.pas (line 705).

Public function PositionToCameraPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const Depth: Single; out PlanePosition: TVector3): Boolean;

Convert 2D position on the viewport into 3D "world coordinates", by colliding camera ray with a plane parallel to the viewport at given Depth. "World coordinates" are coordinates space seen by TCastleTransform / TCastleScene inside viewport Items. Use Depth > 0 for positions in front of the camera.

This is similar to "Unproject" GLU routine. It allows to map points from the 2D viewport back to the 3D space inside viewport.

The interpretation of Position depends on ContainerCoordinates:

  • When ContainerCoordinates = True, then Position is relative to the whole container (like TCastleWindow or TCastleControl).

    And it is expressed in real device coordinates, just like TInputPressRelease.Position when mouse is being clicked, or like TInputMotion.Position when mouse is moved.

  • When ContainerCoordinates = False, then Position is relative to this UI control.

    And it is expressed in coordinates after UI scaling. IOW, if the size of this control is Width = 100, then Position.X between 0 and 100 reflects the visible range of this control.

Returns true and sets 3D PlanePosition if such intersection is found. Returns false if it's not possible to determine such point (which should not be possible, unless camera field of view is larger than 180 degrees).

Source: scene/castleviewport.pas (line 742).

Public procedure PositionToRay(const Position: TVector2; const ContainerCoordinates: Boolean; out RayOrigin, RayDirection: TVector3);

Convert 2D position on the viewport into 3D ray.

The interpretation of Position depends on ContainerCoordinates:

  • When ContainerCoordinates = True, then Position is relative to the whole container (like TCastleWindow or TCastleControl).

    And it is expressed in real device coordinates, just like TInputPressRelease.Position when mouse is being clicked, or like TInputMotion.Position when mouse is moved.

  • When ContainerCoordinates = False, then Position is relative to this UI control.

    And it is expressed in coordinates after UI scaling. IOW, if the size of this control is Width = 100, then Position.X between 0 and 100 reflects the visible range of this control.

Source: scene/castleviewport.pas (line 770).

Public function PositionToWorldPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const PlaneConstCoord: T3DAxis; const PlaneConstValue: Single; out PlanePosition: TVector3): Boolean; overload;

Convert 2D position on the viewport into 3D "world coordinates", by colliding camera ray with a plane at constant X, Y or Z. "World coordinates" are coordinates space seen by TCastleTransform / TCastleScene inside viewport Items.

This works with any projection (perspective or orthographic).

You can use it to pick a point on any plane with constant X (PlaneConstCoord = 0), constant Y (PlaneConstCoord = 1), constant Z (PlaneConstCoord = 2).

This intersects the ray cast by Camera with a plane where given coordinate (PlaneConstCoord) has value equal to PlaneConstValue. The parameter names and interpretation is consistent e.g. with TrySimplePlaneRayIntersection.

The interpretation of Position depends on ContainerCoordinates:

  • When ContainerCoordinates = True, then Position is relative to the whole container (like TCastleWindow or TCastleControl).

    And it is expressed in real device coordinates, just like TInputPressRelease.Position when mouse is being clicked, or like TInputMotion.Position when mouse is moved.

  • When ContainerCoordinates = False, then Position is relative to this UI control.

    And it is expressed in coordinates after UI scaling. IOW, if the size of this control is Width = 100, then Position.X between 0 and 100 reflects the visible range of this control.

Returns true and sets 3D PlanePosition (the PlaneConstCoord component of this vector must always be equal to PlaneConstValue) if such intersection is found. Returns false if it's not possible to determine such point (when the camera looks in the other direction).

Source: scene/castleviewport.pas (line 815).

Public function PositionToWorldPlane(const Position: TVector2; const ContainerCoordinates: Boolean; const PlaneConstValue: Single; out PlanePosition: TVector3): Boolean; overload; deprecated 'use PositionToWorldPlane overload with PlaneConstCoord parameter; this version assumes PlaneConstCoord = 2';

Warning: this symbol is deprecated: use PositionToWorldPlane overload with PlaneConstCoord parameter; this version assumes PlaneConstCoord = 2

This item has no description.

Source: scene/castleviewport.pas (line 820).

Public function PositionTo2DWorld(const Position: TVector2; const ContainerCoordinates: Boolean): TVector2;

Convert 2D position into "world coordinates", which is the coordinate space seen by TCastleTransform / TCastleScene inside viewport Items, assuming that we use orthographic projection in XY axes.

The interpretation of Position depends on ContainerCoordinates:

  • When ContainerCoordinates = True, then Position is relative to the whole container (like TCastleWindow or TCastleControl).

    And it is expressed in real device coordinates, just like TInputPressRelease.Position when mouse is being clicked, or like TInputMotion.Position when mouse is moved.

  • When ContainerCoordinates = False, then Position is relative to this UI control.

    And it is expressed in coordinates after UI scaling. IOW, if the size of this control is Width = 100, then Position.X between 0 and 100 reflects the visible range of this control.

This assumes that camera "up vector" is +Y, and it is looking along the negative Z axis. It also assumes orthographic projection (Camera.ProjectionType equal ptOrthographic). These are default camera direction, up and projection types set by Setup2D.

Source: scene/castleviewport.pas (line 857).

Public function PositionFrom2DWorld(const WorldPosition: TVector2; const ContainerCoordinates: Boolean): TVector2;

Invert PositionTo2DWorld, converting the "world coordinates" (the coordinate space seen by TCastleTransform / TCastleScene inside viewport Items) into final screen position.

Just like PositionTo2DWorld, this assumes that camera "up vector" is +Y, and it is looking along the negative Z axis. It also assumes orthographic projection (Camera.ProjectionType equal ptOrthographic). These are default camera direction, up and projection types set by Setup2D.

Source: scene/castleviewport.pas (line 870).

Public function PositionFromWorld(const WorldPosition: TVector3): TVector2;

Project 3D coordinates (the coordinate space seen by TCastleTransform / TCastleScene inside viewport Items) into 2D position on the viewport UI.

The resulting position is relative to this viewport control and it is expressed in coordinates after UI scaling. IOW, if the size of this control is EffectiveWidth = 100, then Position.X between 0 and 100 reflects the visible range of this control. This is like using ContainerCoordinates = False with PositionToRay.

Source: scene/castleviewport.pas (line 882).

Public procedure PrepareResources(const DisplayProgressTitle: string; const Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; deprecated 'use overload without DisplayProgressTitle: String';

Warning: this symbol is deprecated: use overload without DisplayProgressTitle: String

This item has no description.

Source: scene/castleviewport.pas (line 884).

Public procedure PrepareResources(const Item: TCastleTransform; const DisplayProgressTitle: string; Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; deprecated 'use overload without DisplayProgressTitle: String';

Warning: this symbol is deprecated: use overload without DisplayProgressTitle: String

This item has no description.

Source: scene/castleviewport.pas (line 887).

Public procedure PrepareResources( const Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload;

Prepare resources, to make various methods (like Render) execute fast. Call it only when rendering context is initialized (ApplicationProperties.IsGLContextOpen).

Source: scene/castleviewport.pas (line 894).

Public procedure PrepareResources(const Item: TCastleTransform; Options: TPrepareResourcesOptions = DefaultPrepareOptions); overload; virtual;

This item has no description.

Source: scene/castleviewport.pas (line 896).

Public function TransformUnderMouse: TCastleTransform;

Current TCastleTransform pointed by the mouse cursor position. This is the first object being hit by the ray from camera through the mouse cursor position.

Automatically updated to always reflect the current mouse position. May be Nil if nothing is hit.

The "mouse cursor position" on touch devices is just the last touch point. When the navigation uses mouse look (like TCastleWalkNavigation.MouseLook), we automatically use viewport center as the "mouse cursor position".

See also
MouseRayHit
Current components (TCastleTransform hierarchy) pointed by the mouse cursor position.
TRayCollision.Transform
TCastleTransform that was hit by given ray.

Source: scene/castleviewport.pas (line 926).

Public function TransformHit(const Position: TVector2; const ContainerCoordinates: Boolean; const MaxDistance: Single = 0): TCastleTransform;

Current TCastleTransform hit by the ray from given Position over the viewport.

Position and ContainerCoordinates meaning is the same as for PositionToRay:

  • When ContainerCoordinates = True, then Position is in real device coordinates and relative to whole container.

    E.g. passing a Position equal to MyViewport.RenderRect.Center means shooting a ray from the center of the viewport.

    E.g. passing a Position equal to Container.MousePosition means shooting a ray from the current mouse position.

  • When ContainerCoordinates = False, then Position is in scaled UI coordinates and relative to the viewport.

    E.g. passing a Position equal to Vector2(MyViewport.EffectiveWidth / 2, MyViewport.EffectiveHeight / 2) means shooting a ray from the center of the viewport.

    E.g. passing a Position equal to Vector2(0, 0) means shooting a ray from the left-bottom corner of the viewport.

Similar to TransformUnderMouse, this method returns the first TCastleTransform hit by the ray.

If the MaxDistance is non-zero, it doesn't return collisions further than MaxDistance from the camera position.

Source: scene/castleviewport.pas (line 962).

Public procedure SetupCamera;

Create new camera and make it used by this viewport. This creates new unnamed TCastleCamera, owned by this viewport, assigns it to Camera and adds it to Items.

Call this only when Camera is Nil.

This is done automatically when creating TCastleViewport (not in design-mode, not at deserialization) using the standard TCastleViewport.Create constructor. So you likely don't need to call this in typical applications.

Note: Even when used from CGE editor (CastleDesignMode), this creates non-design camera. This way viewports created with InternalCreateNonDesign have also non-design cameras. This is important, so that e.g. camera has no bounding box, and thus AssignDefaultCamera in sprite sheet editor doesn't put camera further and further away.

Source: scene/castleviewport.pas (line 993).

Public function InternalBuildNode(const SaveBaseUrl: String): TX3DRootNode;

Export whole viewport contents to a node. This is useful to save viewport contents to X3D, STL or other files that we can save. This tries to export as much as we can express using nodes, which includes everything in Items (transformations, scenes, lights and more) and optional things like TCastleNavigation types (fly, walk, examine...), current Background, current Fog.

Why is this an internal method?

  • Because for Castle Game Engine usage, we advice to save things using CastleComponentSerialize unit, like UserInterfaceSave(MyViewport, 'viewport-with-contents.castle-user-interface'). The CastleComponentSerialize routines with reliably save 100% of Pascal published properties.

  • In contrast, this method only saves a subset of engine features – the ones that can be expressed in a straightforward fashion as X3D nodes.

  • See TCastleTransform.InternalBuildNode for more explanation. including why it's an internal method.

Source: scene/castleviewport.pas (line 1055).

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 OnVisibleChange: TCastleUserInterfaceChangeEvent read FOnVisibleChange write FOnVisibleChange;

This item is declared in ancestor TCastleUserInterface.

Called always when something important inside this control (or it's children) changed. See VisibleChange for details about when and how this is called.

Be careful when handling this event. Various changes may cause this, so be prepared to handle it at any moment, even in the middle when UI control is changing. It may also occur very often. It's usually safest to only set a boolean flag like "something should be recalculated" when this event happens, and do the actual recalculation later.

Source: ui/castleuicontrols_userinterface.inc (line 524).

Public property Container: TCastleContainer read FContainer;

This item is declared in ancestor TCastleUserInterface.

Container of this control. When adding control to container's Controls list (like TCastleWindow.Controls) container will automatically set itself here, and when removing from container this will be changed back to Nil.

May be Nil if this control is not yet inserted into any container.

Source: ui/castleuicontrols_userinterface.inc (line 564).

Public property OnCursorChange: TNotifyEvent read FOnCursorChange write FOnCursorChange; deprecated 'use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use OnVisibleChange (or override VisibleChange) and watch for Changes that include chCursor

Event called when the Cursor property changes. This event is, in normal circumstances, used by the Container, so you should not use it in your own programs.

Source: ui/castleuicontrols_userinterface.inc (line 570).

Public property ExclusiveEvents: boolean read FExclusiveEvents write FExclusiveEvents default true; deprecated 'do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: do not use this; supporting this property was complicated and had no real benefit; everything now works as if ExclusiveEvents=true, always

Should we disable further mouse / keys handling for events that we already handled in this control. If True, then our events will return True for mouse and key events handled.

This means that events will not be simultaneously handled by both this control and some other (or camera or normal window callbacks), which is usually more sensible, but sometimes somewhat limiting.

Source: ui/castleuicontrols_userinterface.inc (line 582).

Public property Controls [const Index: Integer]: TCastleUserInterface read GetControls write SetControls;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 586).

Public property GetExists: Boolean read FExists; deprecated 'use Exists';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Exists

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 649).

Public property GLInitialized: boolean read FGLInitialized default false;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 769).

Public property Focused: boolean read FFocused write SetFocused;

This item is declared in ancestor TCastleUserInterface.

See SetFocused.

Source: ui/castleuicontrols_userinterface.inc (line 816).

Public property Parent: TCastleUserInterface read FParent ;

This item is declared in ancestor TCastleUserInterface.

Visual parent control. This control is rendered within the parent, and it's anchors and coordinates are relative to the parent. Parent may be Nil, which means that the Container (if set) is our direct parent.

Note that this property doesn't have a setter, as it could be confusing: the order in which children are inserted into parent sometimes matters, for back-and-front order. If you want to change the parent, you can use code like this:

if Control.Parent <> nil then
  Control.Parent.RemoveControl(Control);
if NewParent <> nil then
  NewParent.InsertFront(Control); // or InsertBack, as InsertControl...

Source: ui/castleuicontrols_userinterface.inc (line 834).

Public property FloatWidth: Single read FWidth write SetWidth stored false; deprecated 'use Width';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Width

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1152).

Public property FloatHeight: Single read FHeight write SetHeight stored false; deprecated 'use Height';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Height

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1154).

Public property AnchorDelta: TVector2 read FTranslation write SetTranslation; deprecated 'use Translation';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Translation

Position of the control, relative to the anchor at parent (by default, relative to left-bottom corner of the parent).

Source: ui/castleuicontrols_userinterface.inc (line 1160).

Public property Translation: TVector2 read FTranslation write SetTranslation;

This item is declared in ancestor TCastleUserInterface.

Position of the control, relative to the anchor at parent (by default, relative to left-bottom corner of the parent).

Source: ui/castleuicontrols_userinterface.inc (line 1165).

Public property KeepInFront: boolean read FKeepInFront write FKeepInFront default false;

This item is declared in ancestor TCastleUserInterface.

Keep the control in front of other controls (with KeepInFront=False) when inserting.

TODO: Do not change this property while the control is already a child of something.

Source: ui/castleuicontrols_userinterface.inc (line 1172).

Public property BorderColor: TCastleColor read FBorderColor write SetBorderColor;

This item is declared in ancestor TCastleUserInterface.

Color of the Border, by default completely transparent black.

Source: ui/castleuicontrols_userinterface.inc (line 1176).

Public property HasHorizontalAnchor: boolean read FHasHorizontalAnchor write FHasHorizontalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: this property does not do anything anymore, anchors are always active

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1179).

Public property HasVerticalAnchor: boolean read FHasVerticalAnchor write FHasVerticalAnchor stored false; deprecated 'this property does not do anything anymore, anchors are always active';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: this property does not do anything anymore, anchors are always active

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1182).

Public property HorizontalAnchorDelta: Single read GetHorizontalAnchorDelta write SetHorizontalAnchorDelta default 0; deprecated 'use Translation.X';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Translation.X

Delta between our border and parent.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1189).

Public property VerticalAnchorDelta: Single read GetVerticalAnchorDelta write SetVerticalAnchorDelta default 0; deprecated 'use Translation.Y';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Translation.Y

Delta between our border and parent.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1194).

Public property Visible: Boolean read FVisible;

This item is declared in ancestor TCastleUserInterface.

Is the control possibly visible. This is always True when Culling is False (the default).

Source: ui/castleuicontrols_userinterface.inc (line 1200).

Public property EnableUIScaling: boolean read FEnableUIScaling write SetEnableUIScaling default true;

This item is declared in ancestor TCastleUserInterface.

Enable or disable UI scaling for this particular control. See more about UI scaling on TCastleContainer.UIScaling and TCastleUserInterface.UIScale. Setting this to False forces TCastleUserInterface.UIScale to always return 1.0.

Note that this does not work recursively, i.e. it does not affect the children of this control. Setting this to False does not prevent UI scaling on children (you have to turn it off explicitly for children too, if you need to disable UI scaling recursively).

The use-cases for changing this property to "false" are very rare. Usually you should use UI scaling for 100% of your UI.

Source: ui/castleuicontrols_userinterface.inc (line 1214).

Public property CapturesEvents: boolean read FCapturesEvents write FCapturesEvents default true;

This item is declared in ancestor TCastleUserInterface.

Capture input events (keyboard, mouse, joystick). If False, then the methods like Press and Release will never be called, and Update will always be called with HandleInput = False. The control will never behave like focused.

The only exception is when this control is set as TCastleContainer.ForceCaptureInput. In this case, the control will receive inputs. In other words, TCastleContainer.ForceCaptureInput overrides the intent of this property.

This property may be replaced by something like "CaptureInput" or just universal "Enabled" in the future.

Source: ui/castleuicontrols_userinterface.inc (line 1229).

Public property OnInternalMouseEnter: TUiNotifyEvent read FOnInternalMouseEnter write FOnInternalMouseEnter;

This item is declared in ancestor TCastleUserInterface.

Called when control starts being under the mouse cursor and will receive events. See SetFocused, this is called when Focused changes from False to True.

This is called "Internal" now, because we do not guarantee it's 100% always paired with OnInternalMouseLeave. A different approach to this may be done in the future releases.

Source: ui/castleuicontrols_userinterface.inc (line 1238).

Public property OnInternalMouseLeave: TUiNotifyEvent read FOnInternalMouseLeave write FOnInternalMouseLeave;

This item is declared in ancestor TCastleUserInterface.

Called when control stops being under the mouse cursor and will receive events. See SetFocused, this is called when Focused changes from True to False.

This is called "Internal" now, because we do not guarantee it's 100% always paired with OnInternalMouseEnter. A different approach to this may be done in the future releases.

Source: ui/castleuicontrols_userinterface.inc (line 1247).

Published property Cursor: TMouseCursor read FCursor write SetCursor default mcDefault;

This item is declared in ancestor TCastleUserInterface.

Mouse cursor over this control. When user moves mouse over the Container, the currently focused (topmost under the cursor) control determines the mouse cursor look.

Source: ui/castleuicontrols_userinterface.inc (line 1263).

Published property OnUpdate: TUiUpdateEvent read FOnUpdate write FOnUpdate;

This item is declared in ancestor TCastleUserInterface.

Event that occurs continuously on each control. See Update for details.

Source: ui/castleuicontrols_userinterface.inc (line 1267).

Published property OnPress: TUiPressReleaseEvent read FOnPress write FOnPress;

This item is declared in ancestor TCastleUserInterface.

An input (key, mouse button, mouse wheel) was pressed. See Press for details.

Source: ui/castleuicontrols_userinterface.inc (line 1271).

Published property OnRelease: TUiPressReleaseEvent read FOnRelease write FOnRelease;

This item is declared in ancestor TCastleUserInterface.

An input (key, mouse button, mouse wheel) was released. See Release for details.

Source: ui/castleuicontrols_userinterface.inc (line 1275).

Published property OnMotion: TUiMotionEvent read FOnMotion write FOnMotion;

This item is declared in ancestor TCastleUserInterface.

Pointer (mouse or finger) moved. See Motion for details.

Source: ui/castleuicontrols_userinterface.inc (line 1279).

Published property OnRender: TUiNotifyEvent read FOnRender write FOnRender;

This item is declared in ancestor TCastleUserInterface.

Control is being displayed. See Render for details. This event it called after the Render method of this control finished but before we started rendering children.

Source: ui/castleuicontrols_userinterface.inc (line 1285).

Published property Exists: boolean read FExists write SetExists default true;

This item is declared in ancestor TCastleUserInterface.

Not existing control is not visible, it doesn't receive input and generally doesn't exist from the point of view of user. This is mostly equivalent to just removing this control from parent list.

Non-existing controls still receive GLContextOpen, GLContextClose, Resize events.

Source: ui/castleuicontrols_userinterface.inc (line 1293).

Published property Left: Single read FLeft write SetLeft stored false default 0; deprecated 'use Translation.X';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Translation.X

Position from the left side of the parent control.

It's usually better to use anchors instead of this property. For example, instead of setting Control.Left := 10, you can call Control.Anchor(hpLeft, 10), or just change Translation.X.

Note that the effects of this property and Translation.X are summed, if you set both. We advise to leave Left as zero and just use anchors in new code.

Source: ui/castleuicontrols_userinterface.inc (line 1305).

Published property Bottom: Single read FBottom write SetBottom default 0; deprecated 'use Translation.Y';

This item is declared in ancestor TCastleUserInterface.

Warning: this symbol is deprecated: use Translation.Y

Position from the bottom side of the parent control.

It's usually better to use anchors instead of this property. For example, instead of setting Control.Bottom := 10, you can call Control.Anchor(vpBottom, 10), or just change Translation.Y.

Note that the effects of this property and Translation.Y are summed, if you set both. We advise to leave Bottom as zero and just use anchors in new code.

Source: ui/castleuicontrols_userinterface.inc (line 1318).

Published property FullSize: boolean read FFullSize write SetFullSize default false;

This item is declared in ancestor TCastleUserInterface.

When FullSize, the control will always fill the whole parent area.

See also
TCastleUserInterface.EffectiveRect
Control position and size.
TCastleUserInterface.EffectiveWidth
Calculated width of the control, without UI scaling.
TCastleUserInterface.EffectiveHeight
Calculated height of the control, without UI scaling.

Source: ui/castleuicontrols_userinterface.inc (line 1325).

Published property Width: Single read FWidth write SetWidth default DefaultWidth;

This item is declared in ancestor TCastleUserInterface.

These properties determine the control size. See the EffectiveRect documentation for details how the size is calculated.

See also
TCastleUserInterface.EffectiveRect
Control position and size.
TCastleUserInterface.EffectiveWidth
Calculated width of the control, without UI scaling.
TCastleUserInterface.EffectiveHeight
Calculated height of the control, without UI scaling.

Source: ui/castleuicontrols_userinterface.inc (line 1335).

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

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1336).

Published property WidthFraction: Single read FWidthFraction write SetWidthFraction default 0.0;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1337).

Published property HeightFraction: Single read FHeightFraction write SetHeightFraction default 0.0;

This item is declared in ancestor TCastleUserInterface.

This item has no description.

Source: ui/castleuicontrols_userinterface.inc (line 1338).

Published property AutoSizeToChildren: Boolean read FAutoSizeToChildren write SetAutoSizeToChildren default false;

This item is declared in ancestor TCastleUserInterface.

Adjust size to encompass all the children. The properties FullSize, Width, Height are ignored in this case. Our Left and Bottom still matter.

Our size is adjusted to all existing children sizes and positions.

We add AutoSizeToChildrenPaddingTop to the resulting height, and AutoSizeToChildrenPaddingRight to the resulting width.

Source: ui/castleuicontrols_userinterface.inc (line 1351).

Published property AutoSizeToChildrenPaddingRight: Single read FAutoSizeToChildrenPaddingRight write SetAutoSizeToChildrenPaddingRight default 0;

This item is declared in ancestor TCastleUserInterface.

Padding added when AutoSizeToChildren is used. TODO: Should be AutoSizeToChildrenPaddingHorizontal, there's nothing that makes it specific to "right" or "left" side now.

Source: ui/castleuicontrols_userinterface.inc (line 1357).

Published property AutoSizeToChildrenPaddingTop: Single read FAutoSizeToChildrenPaddingTop write SetAutoSizeToChildrenPaddingTop default 0;

This item is declared in ancestor TCastleUserInterface.

Padding added when AutoSizeToChildren is used. TODO: Should be AutoSizeToChildrenPaddingVertical, there's nothing that makes it specific to "top" or "bottom" side now.

Source: ui/castleuicontrols_userinterface.inc (line 1363).

Published property HorizontalAnchorSelf: THorizontalPosition read FHorizontalAnchorSelf write SetHorizontalAnchorSelf default hpLeft;

This item is declared in ancestor TCastleUserInterface.

Which our border to align with parent.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1369).

Published property HorizontalAnchorParent: THorizontalPosition read FHorizontalAnchorParent write SetHorizontalAnchorParent default hpLeft;

This item is declared in ancestor TCastleUserInterface.

Which parent border is aligned to our HorizontalAnchorSelf border.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1373).

Published property VerticalAnchorSelf: TVerticalPosition read FVerticalAnchorSelf write SetVerticalAnchorSelf default vpBottom;

This item is declared in ancestor TCastleUserInterface.

Which our border to align with parent.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1378).

Published property VerticalAnchorParent: TVerticalPosition read FVerticalAnchorParent write SetVerticalAnchorParent default vpBottom;

This item is declared in ancestor TCastleUserInterface.

Which parent border is aligned to our VerticalAnchorSelf border.

See also
Anchor
Adjust position to align us to the parent vertically.

Source: ui/castleuicontrols_userinterface.inc (line 1382).

Published property Culling: Boolean read FCulling write SetCulling default false;

This item is declared in ancestor TCastleUserInterface.

Optimize rendering and event processing by checking whether the control can be visible. The visibility is checked by looking at container rectangle, and all possible clipping parents (set by TCastleScrollView, or any other control with ClipChildren).

This is useful for UI controls that have expensive rendering or other events (e.g. they do something non-trivial in Render or RenderOverChildren, or they include a lot of children controls). And they may be placed off-screen, or they may be outside of a parent with clipping, which is often the case when the parent is TCastleScrollView.

Source: ui/castleuicontrols_userinterface.inc (line 1398).

Published property ClipChildren: Boolean read FClipChildren write SetClipChildren default false;

This item is declared in ancestor TCastleUserInterface.

Clip the rendering of children.

By default this is False and so the control can draw outside of it's designated rectangle (RenderRect). Although all the standard UI controls are carefully implemented such that their Render and RenderOverChildren draw only within their RenderRect. But it is easy to place children controls outside of this rectangle.

When this property is True, the rendering is clipped, so the "overflowing" parts are never visible. This affects both Render and RenderOverChildren of this control, as well as all children rendering.

Source: ui/castleuicontrols_userinterface.inc (line 1413).

Published property Border: TBorder read FBorder;

This item is declared in ancestor TCastleUserInterface.

Border (by default transparent) of the control. Border adds a space from the control content (drawn within RenderRect) to the control rectangle (returned by RenderRectWithBorder) (scaled), or EffectiveRect (unscaled) and friends).

It is transparent by default, but you can change it by BorderColor.

Border works always, regardless of FullSize or AutoSizeToChildren.

One obvious use-case is to use this for visual space (empty space or a colorful frame, separating this control from the rest).

Another use-case is to reserve a predictable space for as additional (sibling) control within the same parent. E.g. you can set FullSize=true and Border.Top=100, and this way there is always a strip with Height=100 at the top of the parent, where you can insert another control (with Height=100, anchored to the top).

Source: ui/castleuicontrols_userinterface.inc (line 1434).

Published property CustomTheme: TCastleTheme read FCustomTheme write SetCustomTheme;

This item is declared in ancestor TCastleUserInterface.

Use a custom instance of TCastleTheme to determine the look of this control.

Source: ui/castleuicontrols_userinterface.inc (line 1437).

Published property TooltipControl: TCastleUserInterface read FTooltipControl write SetTooltipControl;

This item is declared in ancestor TCastleUserInterface.

If set, the indicated control will act as a tooltip: we will make it existing when we should show the tooltip for this control, we will make it no longer existing when the tooltip for this should be hidden. Initially the TooltipControl should usually have Exists=false, because you usually do not want to show it until we start showing it as a tooltip.

If TooltipControl is assigned then TCastleUserInterfaceFont no longer does tooltip rendering. The TCastleUserInterfaceFont.Tooltip text is ignored.

The visual parent of TooltipControl can be whatever is comfortable. That is, it is OK to make TooltipControl parent of this control, and it is OK not to: you can as well place TooltipControl as e.g. parent of container or design root.

Source: ui/castleuicontrols_userinterface.inc (line 1453).

Published property EditorSelectOnHover: Boolean read FEditorSelectOnHover write FEditorSelectOnHover default true;

This item is declared in ancestor TCastleUserInterface.

Select the UI (hover, select on click) at design-time when the mouse is over rectangle of this UI. This affects operation in the editor, and when using the inspector (press F8 at run-time, when the application is build in debug mode).

It's by default True and it makes most sense to leave it True for the majority of components. However some components are not only invisible, but also "user doesn't expect to select them by hovering". E.g. TCastleNavigation, or DesignHud in examples/3d_games/explore_impressive_castle . It is more intuitive for user then that such component doesn't obscure things underneath.

Note that hovering over children of UI with EditorSelectOnHover will still select them. This is good e.g. for DesignHud in examples/3d_games/explore_impressive_castle.

Source: ui/castleuicontrols_userinterface.inc (line 1470).

Published property BorderColorPersistent: TCastleColorPersistent read FBorderColorPersistent ;

This item is declared in ancestor TCastleUserInterface.

BorderColor 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 BorderColor directly.

See also
BorderColor
Color of the Border, by default completely transparent black.

Source: ui/auto_generated_persistent_vectors/tcastleuserinterface_persistent_vectors.inc (line 37).

Published property TranslationPersistent: TCastleVector2Persistent read FTranslationPersistent ;

This item is declared in ancestor TCastleUserInterface.

Translation 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 Translation directly.

See also
Translation
Position of the control, relative to the anchor at parent (by default, relative to left-bottom corner of the parent).

Source: ui/auto_generated_persistent_vectors/tcastleuserinterface_persistent_vectors.inc (line 105).

Public property ScreenEffectsTimeScale: Single read FScreenEffectsTimeScale write FScreenEffectsTimeScale default 1;

This item is declared in ancestor TCastleScreenEffects.

Scale time passing inside TimeSensor nodes you add as part of AddScreenEffect. May be 0 to stop time passing. This has deliberately long name, instead of simple TimeScale, to make it clear that it's completely independent from TCastleAbstractRootTransform.TimeScale.

Source: scene/castlescreeneffects.pas (line 197).

Public property ScreenEffectsEnable: Boolean read FScreenEffectsEnable write FScreenEffectsEnable default true;

This item is declared in ancestor TCastleScreenEffects.

Enable or disable all screen effects added by AddScreenEffect. When this is True, particular screen effects can still be enabled/disabled using TScreenEffectNode.Enabled. When this is False, all effects are disabled, regardless of TScreenEffectNode.Enabled.

Source: scene/castlescreeneffects.pas (line 205).

Public property Projection: TProjection read FProjection; deprecated 'in most cases, you can instead read Camera parameters, like Camera.Orthographic.EffectiveWidth, Camera.Orthographic.EffectiveHeight';

Warning: this symbol is deprecated: in most cases, you can instead read Camera parameters, like Camera.Orthographic.EffectiveWidth, Camera.Orthographic.EffectiveHeight

Current projection parameters, calculated by last CalculateProjection call, adjusted by OnProjection. This is read only. To change the projection parameters, override CalculateProjection or handle event OnProjection.

Source: scene/castleviewport.pas (line 557).

Public property BackgroundColor: TCastleColor read FBackgroundColor write FBackgroundColor;

Background color. Displayed only if Background is Nil and MainScene doesn't define any background either.

Ignored if Transparent.

Dark gray (DefaultBackgroundColor) by default.

Source: scene/castleviewport.pas (line 619).

Public property ScreenSpaceAmbientOcclusion: boolean read FScreenSpaceAmbientOcclusion write SetScreenSpaceAmbientOcclusion default DefaultScreenSpaceAmbientOcclusion;

Enable built-in SSAO screen effect in the world.

Source: scene/castleviewport.pas (line 643).

Public property ScreenSpaceReflections: Boolean read FScreenSpaceReflections write SetScreenSpaceReflections default DefaultScreenSpaceReflections;

Enable built-in SSR screen effect in the world.

Source: scene/castleviewport.pas (line 648).

Public property ScreenSpaceReflectionsSurfaceGlossiness: Single read FScreenSpaceReflectionsSurfaceGlossiness write SetScreenSpaceReflectionsSurfaceGlossiness;

Adjust SSR default surface glossiness.

Source: scene/castleviewport.pas (line 653).

Public property OnCameraChanged: TNotifyEvent read FOnCameraChanged write FOnCameraChanged;

Called on any camera change.

Source: scene/castleviewport.pas (line 657).

Public property MouseRayHit: TRayCollision read GetMouseRayHit;

Current components (TCastleTransform hierarchy) pointed by the mouse cursor position. This is the first object being hit by the ray from camera through the mouse cursor position.

Automatically updated to always reflect the current mouse position. May be Nil if nothing is hit.

The "mouse cursor position" on touch devices is just the last touch point. When the navigation uses mouse look (like TCastleWalkNavigation.MouseLook), we automatically use viewport center as the "mouse cursor position".

See also
TransformUnderMouse
Current TCastleTransform pointed by the mouse cursor position.

Source: scene/castleviewport.pas (line 911).

Public property AvoidNavigationCollisions: TCastleTransform read FAvoidNavigationCollisions write SetAvoidNavigationCollisions;

Do not collide with this object when moving by Navigation. It makes sense to put here player avatar (in 3rd person view) or player collision volume (in 1st person view) to allow player to move, not colliding with its own body.

Source: scene/castleviewport.pas (line 969).

Public property Paused: boolean read GetPaused write SetPaused default false; deprecated 'use Items.Paused';

Warning: this symbol is deprecated: use Items.Paused

See TCastleAbstractRootTransform.Paused.

Source: scene/castleviewport.pas (line 975).

Public property Navigation: TCastleNavigation read GetNavigation write SetNavigation stored false; deprecated 'instead of this property: to get, just remember current navigation instance on your side; to set, add it like "MyViewport.InsertBack(MyNavigation)"';

Warning: this symbol is deprecated: instead of this property: to get, just remember current navigation instance on your side; to set, add it like "MyViewport.InsertBack(MyNavigation)"

Navigation method is an optional component that handles the user input to control the camera.

This is a deprecated property. There's no point in assigning current navigation like this. Instead add the TCastleNavigation instance as a child of TCastleViewport and it will affect the viewport automatically. This property is now only a shortcut to

- get the current TCastleNavigation child (if multiple present, it is undefined which is returned)

- make the given set TCastleNavigation as the only child.

You can assign here an instance of TCastleNavigation, like TCastleWalkNavigation or TCastleExamineNavigation. Or you can leave it as Nil.

Source: scene/castleviewport.pas (line 1014).

Published property Items: TCastleRootTransform read FItems write SetItems;

Transformations and scenes visible in this viewport. You should add here your TCastleTransform and TCastleScene instances.

It is by default created (not Nil), but you can also assign here your own TCastleRootTransform instance. You can also copy a TCastleRootTransform from one TCastleViewport to another, that is multiple TCastleViewport can refer to the same TCastleRootTransform instance.

Note that assigning here Nil is allowed, but under the hood it just creates an empty TCastleRootTransform instance. So this property is never Nil when reading. But try to not depend on it for the future, at some point this property may be allowed to be Nil, for consistency.

Source: scene/castleviewport.pas (line 1071).

Published property Camera: TCastleCamera read FCamera write SetCamera;

Camera determines the viewer position and orientation.

You should create TCastleCamera, assign to this property, and add it somewhere to Items.

Note that camera can be placed anywhere within Items, not necessary as direct child of Items. For example it can be a children of some deeper TCastleTransform, this way you can attach camera e.g. to some bone or to a moving object.

Generally, TCastleCamera is a regular component that can be added and removed freely from Items, renamed, freed etc. And setting this property is an independent action that doesn't add/remove any camera from Items. This property can also be set to Nil.

For convenience, there are however some moments when we set up this property and add camera to Items automatically:

  1. When you create TCastleViewport from code (not by deserializing some xxx.castle-user-interface file, not in design-mode in editor) then we automatically add new (unnamed) camera and set Viewport.Camera and add it to Viewport.Items.

  2. Only at design-time (in editor): creating new viewport by editor menu also adds a default camera to it. In this case camera component is named and owned by the same owner as viewport. This is done right after TCastleViewport creation and only at design-time.

  3. For backward compatibility, after deserializing file from previous engine versions, we add the camera from it to Viewport.Items. This is made strictly for backward compatibility, only when deserializing, and it shouldn't occur when reading new design files.

It's important to note that when deserializing camera from new engine versions, there's no "magic". We just expect that Viewport.Camera and Viewport.Items are good. Trying to do something automatic/smart in this case turned out to be quite troublesome and breaking more than helping.

Source: scene/castleviewport.pas (line 1116).

Published property ShadowVolumes: boolean read FShadowVolumes write FShadowVolumes default DefaultShadowVolumes;

Should we render with shadow volumes. You can change this at any time, to switch rendering shadows on/off.

This works only if OpenGL context actually can render shadow volumes, checked by GLFeatures.ShadowVolumesPossible, which means that you have to initialize OpenGL context with stencil buffer.

The shadow volumes algorithm is used only if shadow caster is 2-manifold, that is has a correctly closed volume. Also you need a light source marked as the main shadow volumes light (shadowVolumes = shadowVolumesMain = TRUE). See [https://castle-engine.io/x3d_extensions.php#section_ext_shadows] for details.

Source: scene/castleviewport.pas (line 1131).

Published property ShadowVolumesRender: boolean read FShadowVolumesRender write FShadowVolumesRender default false;

Actually draw the shadow volumes to the color buffer, for debugging. If shadows are rendered (see GLFeatures.ShadowVolumesPossible and ShadowVolumes), you can use this to actually see shadow volumes, for debug / demo purposes. Shadow volumes will be rendered on top of the scene, as yellow blended polygons.

Source: scene/castleviewport.pas (line 1139).

Published property Background: TCastleBackground read FBackground write SetBackground;

Background (like a skybox) to display behind the Items. Displayed only when not Transparent. See https://castle-engine.io/background

Source: scene/castleviewport.pas (line 1144).

Published property Fog: TCastleFog read FFog write SetFog;

Fog to use to display viewport contents in Items. See https://castle-engine.io/fog

Source: scene/castleviewport.pas (line 1148).

Published property BackgroundWireframe: boolean read FBackgroundWireframe write FBackgroundWireframe default false;

If True then the background (from Background or MainScene) will be rendered wireframe, over the solid background filled with BackgroundColor. Useful for debugging when you want to see how your background geometry looks like.

Ignored if Transparent.

Source: scene/castleviewport.pas (line 1157).

Published property Transparent: boolean read FTransparent write FTransparent default false;

If True then the viewport will not draw a background and the UI underneath will be visible. The UI underneath is visible at pixels which are not covered by items on Items, and where items Items have partially-transparent materials.

If True, the Background, BackgroundColor, BackgroundWireframe, and any background defined inside MainScene will be ignored.

Source: scene/castleviewport.pas (line 1168).

Published property ClearDepth: boolean read FClearDepth write FClearDepth default true;

At the beginning of rendering, viewport by default clears the depth buffer. This makes every viewport draw everything on top of the previous 2D and 3D stuff (including on top of previous viewport), like a layer.

You can disable this, which allows to combine together the 3D objects rendered by various viewports (and by custom OpenGL rendering), such that the 3D positions determime what overlaps what. This only makes sense if you have a number of TCastleViewport instances, that share the same size and position on the screen, same projection and the same camera.

It's your responsibility in such case to clear the depth buffer. E.g. place one viewport in the back that has ClearDepth = True. Or place a TCastleUserInterface descendant in the back, that calls TRenderContext.Clear RenderContext.Clear in overridden TCastleUserInterface.Render.

Note: to disable clearning the color buffer, set Transparent to False.

Note: if you use shadow volumes, we will still clear the stencil buffer at the beginning of rendering.

Source: scene/castleviewport.pas (line 1194).

Published property UseGlobalLights: boolean read FUseGlobalLights write FUseGlobalLights default DefaultUseGlobalLights; deprecated 'if you need to tweak this, then do not use MainScene; use regular TCastleScene and set CastGlobalLights as needed';

Warning: this symbol is deprecated: if you need to tweak this, then do not use MainScene; use regular TCastleScene and set CastGlobalLights as needed

Let lights in MainScene shine on every other TCastleScene, not only MainScene. This is an easy way to lit your whole world with lights defined inside MainScene file. Be sure to set X3D lights global=TRUE.

Source: scene/castleviewport.pas (line 1199).

Published property UseGlobalFog: boolean read FUseGlobalFog write FUseGlobalFog default DefaultUseGlobalFog; deprecated 'configure fog by assigning to TCastleViewport.Fog component; leave deprecated MyViewport.Items.MainScene = nil';

Warning: this symbol is deprecated: configure fog by assigning to TCastleViewport.Fog component; leave deprecated MyViewport.Items.MainScene = nil

Let the fog defined in MainScene affect all objects, not only MainScene. This is consistent with UseGlobalLights, that allows lights from MainScene to shine on all objects.

Source: scene/castleviewport.pas (line 1206).

Published property ApproximateActivation: boolean read FApproximateActivation write FApproximateActivation default false;

Help user to activate pointing device sensors and pick items. Every time you press Input_Interact (by default just left mouse button), we look if current mouse/touch position hits an object (TCastleTransform) that actually does something on activation. The object may do various stuff inside TCastleTransform.PointingDevicePress, generally this causes various picking/interaction with the object (like pulling a level, opening a door), possibly dragging, possibly with the help of VRML/X3D pointing device and drag sensors.

When this is True, we try harder to hit some 3D object that handles PointingDevicePress. If there's nothing interesting under mouse/touch, we will retry a couple of other positions around the current mouse/touch.

This should be usually used when you use TCastleMouseLookNavigation.MouseLook, or other navigation when mouse cursor is hidden. It allows user to only approximately look at interesting item and hit interaction button or key. Otherwise, activating a small object is difficult, as you don't see the cursor.

Source: scene/castleviewport.pas (line 1229).

Published property OnProjection: TProjectionEvent read FOnProjection write FOnProjection; deprecated 'adjust projection by changing Camera.ProjectionType and other projection parameters inside Camera';

Warning: this symbol is deprecated: adjust projection by changing Camera.ProjectionType and other projection parameters inside Camera

Adjust the projection parameters. This event is called before every render. See the CalculateProjection for a description how to default projection parameters are calculated.

Source: scene/castleviewport.pas (line 1236).

Published property EnableParentDragging: boolean read FEnableParentDragging write FEnableParentDragging default false;

Enable to drag a parent control, for example to drag a TCastleScrollView that contains this TCastleViewport, even when the scene inside contains clickable elements (using TouchSensor node).

To do this, you need to turn on TCastleScrollView.EnableDragging, and set EnableParentDragging=True here. In effect, viewport will cancel the click operation once you start dragging, which allows the parent to handle all the motion events for dragging.

Source: scene/castleviewport.pas (line 1249).

Published property AutoCamera: Boolean read FAutoCamera write SetAutoCamera default false; deprecated 'it is simpler to set camera at design-time explicitly, or use CameraViewpointForWholeScene to auto-adjust camera; if you want to animate the camera, attach TCastleCamera to a bone transformation exposed by Scene.ExposeTransforms';

Warning: this symbol is deprecated: it is simpler to set camera at design-time explicitly, or use CameraViewpointForWholeScene to auto-adjust camera; if you want to animate the camera, attach TCastleCamera to a bone transformation exposed by Scene.ExposeTransforms

Assign initial camera properties (initial position, direction, up, TCastleCamera.ProjectionNear) by looking at the initial world (Items) when rendering the first frame.

The AssignDefaultCamera is automatically called only if this property is True.

Also, only if this property is True, we synchronize camera when X3D Viewpoint node changes, or a new X3D Viewpoint node is bound.

By default it is False, which means you control Camera properties on your own.

Source: scene/castleviewport.pas (line 1263).

Published property OnBoundViewpointChanged: TNotifyEvent read FOnBoundViewpointChanged write FOnBoundViewpointChanged;

Called when bound Viewpoint node changes. Called exactly when TCastleSceneCore.ViewpointStack.OnBoundChanged is called.

Source: scene/castleviewport.pas (line 1269).

Published property OnBoundNavigationInfoChanged: TNotifyEvent read FOnBoundNavigationInfoChanged write FOnBoundNavigationInfoChanged;

Called when bound NavigationInfo changes (to a different node, or just a field changes).

Source: scene/castleviewport.pas (line 1273).

Published property PreventInfiniteFallingDown: Boolean read FPreventInfiniteFallingDown write FPreventInfiniteFallingDown default false;

Protect from falling down because of gravity when position is outside of world bounding box. This is a nice thing for general model viewers (like castle-model-viewer), to prevent from accidentally falling down when using "Walk" mode.

This is only used by navigations performing gravity internally, that is right now: TCastleWalkNavigation (when TCastleWalkNavigation.Gravity = True).

Source: scene/castleviewport.pas (line 1282).

Published property DynamicBatching: Boolean read FDynamicBatching write SetDynamicBatching default false;

Combine (right before rendering) multiple shapes with a similar appearance into one. This can drastically reduce the number of "draw calls", making rendering much faster.

To debug effectiveness of this, display TCastleViewport.Statistics. In CGE editor (at design-time), use menu item "Edit -> Show Statistics" (F8). When dynamic batching works, the number of rendered shapes and the number of "Draw Calls" should be much smaller.

Source: scene/castleviewport.pas (line 1293).

Published property OcclusionCulling: boolean read FOcclusionCulling write SetOcclusionCulling default false;

Use the occlusion culling to optimize the rendering. The shapes obscured by other shapes will not be rendered. This makes sense when in your view, many shapes are typically obscured by others.

See the https://castle-engine.io/occlusion_culling for details how does this work.

To debug effectiveness of this, display TCastleViewport.Statistics. In CGE editor (at design-time), use menu item "Edit -> Show Statistics" (F8). If you look closely at a wall that obscures many shapes behind it, you should see the number of rendered shapes drop significantly using occlusion culling.

This is ignored if GPU doesn't support the necessary functionality (TGLFeatures.OcclusionQuery).

Source: scene/castleviewport.pas (line 1311).

Published property OcclusionSort: TShapeSort read FOcclusionSort write FOcclusionSort default sortAuto;

Sort the opaque shapes when rendering, from front to back. This may make a speedup when big shapes in front of camera obscure many shapes behind. This is only an optimization: regardless of the value of this, rendering opaque objects will be always correct. Different values of this properly may merely increase / decrease rendering performance (frames per second).

In general this is an independent optimization from OcclusionCulling, albeit it makes sense in similar situations.

When combined with OcclusionCulling, it makes occlusion culling even more effective. Occlusion culling can reject more shapes, because the things that obscure them are rendered earlier to the depth buffer.

See https://castle-engine.io/occlusion_culling#occlusion_sort for more details.

The default value, sortAuto, for now is equivalent to sortNone. It may change in the future to perform sorting esp. when OcclusionCulling is True, as OcclusionCulling and sorting are a natural pair, sorting make occlusion culling even more effective.

Source: scene/castleviewport.pas (line 1336).

Published property BlendingSort: TShapeSort read FBlendingSort write FBlendingSort default sortAuto;

Sort the blending (partially-transparent) shapes when rendering, from back to front.

This makes blending correct when there are multiple partially-transparent objects visible. See blending manual. Invalid value of this may cause rendering artifacts when rendering multiple partially-transparent objects.

The default value, sortAuto, automatically detects if camera is 2D (orthographic, looking in -Z) and if yes, it behaves like sort2D. Otherwise it behaves like sort3D.

Source: scene/castleviewport.pas (line 1351).

Published property OnCustomShapeSort: TShapeSortEvent read FOnCustomShapeSort write FOnCustomShapeSort;

Used to sort shapes, if TCastleViewport.BlendingSort or TCastleViewport.OcclusionSort indicate sortCustom. See TShapeSortEvent for usage details and example.

Source: scene/castleviewport.pas (line 1357).

Published property UpdateSoundListener: Boolean read FUpdateSoundListener write FUpdateSoundListener default true;

Should the sound listener (that determines how the sounds are heard) be updated to reflect this viewport's active camera. This is True by default, so that 3D sound "just works" out-of-the-box when you have 3D sounds in the TCastleViewport. However, if you use multiple viewports to display the same world from multiple cameras, you should set this to False for all but one viewport.

Active camera comes from Items.MainCamera and should match Camera in all normal circumstances, if you haven't customized Items.MainCamera manually.

Source: scene/castleviewport.pas (line 1371).

Published property BackgroundColorPersistent: TCastleColorPersistent read FBackgroundColorPersistent ;

BackgroundColor 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 BackgroundColor directly.

See also
BackgroundColor
Background color.

Source: scene/auto_generated_persistent_vectors/tcastleviewport_persistent_vectors.inc (line 37).


Generated by PasDoc 0.17.0.snapshot.