Class TCastleViewport
Unit
CastleSceneManager
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
Properties
Description
Methods
 |
function GetHeadlightCamera: TCamera; override; |
|
 |
function GetPlayer: TPlayer; override; |
|
 |
function GetTimeScale: Single; override; |
|
 |
function PointingDeviceActivate(const Active: boolean): boolean; override; |
|
 |
function PointingDeviceMove(const RayOrigin, RayDirection: TVector3Single): boolean; override; |
|
 |
procedure CameraVisibleChange(ACamera: TObject); override; |
|
 |
destructor Destroy; override; |
|
 |
procedure Render; override; |
|
 |
function CreateDefaultCamera(AOwner: TComponent): TCamera; override; |
|
Properties
|