Class TCastleViewport

DescriptionHierarchyFieldsMethodsProperties

Unit

Declaration

type TCastleViewport = class(TCastleAbstractViewport)

Description

Custom 2D viewport showing 3D world. This uses assigned SceneManager to show 3D world on the screen.

For simple games, using this is not needed, because TCastleSceneManager also acts as a viewport (when TCastleSceneManager.DefaultViewport is True, which is the default). Using custom viewports (implemented by this class) is useful when you want to have more than one viewport showing the same 3D world. Different viewports may have different cameras, but they always share the same 3D world (in scene manager).

You can control the size of this viewport by FullSize, Left, Bottom, Width, Height properties. For custom viewports, you often want to set FullSize = False and control viewport's position and size explicitly.

Example usages: in a typical 3D modeling programs, you like to have 4 viewports with 4 different cameras (front view, side view, top view, and free perspective view). See examples/vrml/multiple_viewports.lpr in engine sources for demo of this. Or when you make a split-screen game, played by 2 people on a single monitor.

Viewports may be overlapping, that is one viewport may (partially) obscure another viewport. Just like with any other TUIControl, position of viewport on the Controls list (like TCastleControlCustom.Controls or TCastleWindowCustom.Controls) is important: Controls are specified in the front-to-back order. That is, if the viewport X may obscure viewport Y, then X must be before Y on the Controls list.

Example usage of overlapping viewports: imagine a space shooter, like Epic or Wing Commander. You can imagine that a camera is mounted on each rocket fired by the player. You can display in one viewport (with FullSize = True) normal (first person) view from your space ship. And additionally you can place a small viewport (with FullSize = False and small Width / Height) in the upper-right corner that displays view from last fired rocket.

Hierarchy

Overview

Methods

Protected function GetItems: T3DWorld; override;
Protected function GetMainScene: TCastleScene; override;
Protected function GetShadowVolumeRenderer: TGLShadowVolumeRenderer; override;
Protected function GetMouseRayHit: TRayCollision; override;
Protected function GetHeadlightCamera: TCamera; override;
Protected function GetPlayer: TPlayer; override;
Protected function GetTimeScale: Single; override;
Protected function PointingDeviceActivate(const Active: boolean): boolean; override;
Protected function PointingDeviceMove(const RayOrigin, RayDirection: TVector3Single): boolean; override;
Protected function CameraMoveAllowed(ACamera: TWalkCamera; const ProposedNewPos: TVector3Single; out NewPos: TVector3Single; const BecauseOfGravity: boolean): boolean; override;
Protected function CameraHeight(ACamera: TWalkCamera; const Position: TVector3Single; out AboveHeight: Single; out AboveGround: P3DTriangle): boolean; override;
Protected function CameraRayCollision(const RayOrigin, RayDirection: TVector3Single): TRayCollision; override;
Protected procedure CameraVisibleChange(ACamera: TObject); override;
Protected function Headlight: TAbstractLightNode; override;
Public destructor Destroy; override;
Public procedure Render; override;
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;

Properties

Published property SceneManager: TCastleSceneManager read FSceneManager write SetSceneManager;

Description

Methods

Protected function GetItems: T3DWorld; override;
 
Protected function GetMainScene: TCastleScene; override;
 
Protected function GetShadowVolumeRenderer: TGLShadowVolumeRenderer; override;
 
Protected function GetMouseRayHit: TRayCollision; override;
 
Protected function GetHeadlightCamera: TCamera; override;
 
Protected function GetPlayer: TPlayer; override;
 
Protected function GetTimeScale: Single; override;
 
Protected function PointingDeviceActivate(const Active: boolean): boolean; override;
 
Protected function PointingDeviceMove(const RayOrigin, RayDirection: TVector3Single): boolean; override;
 
Protected function CameraMoveAllowed(ACamera: TWalkCamera; const ProposedNewPos: TVector3Single; out NewPos: TVector3Single; const BecauseOfGravity: boolean): boolean; override;
 
Protected function CameraHeight(ACamera: TWalkCamera; const Position: TVector3Single; out AboveHeight: Single; out AboveGround: P3DTriangle): boolean; override;
 
Protected function CameraRayCollision(const RayOrigin, RayDirection: TVector3Single): TRayCollision; override;
 
Protected procedure CameraVisibleChange(ACamera: TObject); override;
 
Protected function Headlight: TAbstractLightNode; override;
 
Public destructor Destroy; override;
 
Public procedure Render; override;
 
Public function CreateDefaultCamera(AOwner: TComponent): TCamera; override;
 

Properties

Published property SceneManager: TCastleSceneManager read FSceneManager write SetSceneManager;