Castle Game Engine: CastleCameras

# Unit CastleCameras
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description Cameras to navigate in 3D space (TExamineCamera, TWalkCamera, TUniversalCamera). ## Uses SysUtils CastleVectors CastleUtils CastleKeysMouse CastleBoxes CastleQuaternions CastleFrustum CastleUIControls Classes CastleRays CastleTimeUtils CastleInputs CastleTriangles CastleRectangles ## Overview ### Classes, Interfaces, Objects and Records
Name | Description
--- | ---
Class `TCamera` | Handle user navigation in 3D scene.
Class `TExamineCamera` | Navigate the 3D model in examine mode, like you would hold a box with the model inside.
Class `TWalkCamera` | Navigation by walking (first-person-shooter-like moving) in 3D scene.
Class `TUniversalCamera` | Camera that allows any kind of navigation (Examine, Walk).
### Functions and Procedures
`procedure CorrectPreferredHeight(var PreferredHeight: Single; const Radius: Single; const CrouchHeight, HeadBobbing: Single);`
`function CamDirUp2Orient(const CamDir, CamUp: TVector3Single): TVector4Single;`
`procedure CamDirUp2Orient(const CamDir, CamUp: TVector3Single; out OrientAxis: TVector3Single; out OrientRadAngle: Single);`
`function CamDirUp2OrientQuat(CamDir, CamUp: TVector3Single): TQuaternion;`
`procedure CameraViewpointForWholeScene(const Box: TBox3D; const WantedDirection, WantedUp: Integer; const WantedDirectionPositive, WantedUpPositive: boolean; out Position, Direction, Up, GravityUp: TVector3Single);`
`procedure Register;`
### Types
`TCameraInput = (...);`
`TCameraInputs = set of TCameraInput;`
`TNavigationClass = (...);`
`TNavigationType = (...);`
`TCameraClass = class of TCamera;`
`T3BoolInputs = array [0..2, boolean] of TInputShortcut;`
`TMouseDragMode = (...);`
`TMoveAllowedFunc = function(Camera: TWalkCamera; const ProposedNewPos: TVector3Single; out NewPos: TVector3Single; const BecauseOfGravity: boolean): boolean of object;`
`TFallNotifyFunc = procedure (Camera: TWalkCamera; const FallHeight: Single) of object;`
`THeightEvent = function (Camera: TWalkCamera; const Position: TVector3Single; out AboveHeight: Single; out AboveGround: P3DTriangle): boolean of object;`
### Constants
`DefaultCameraDirection: TVector3Single = (0, 0, -1);`
`DefaultCameraUp: TVector3Single = (0, 1, 0);`
## Description ### Functions and Procedures
`procedure CorrectPreferredHeight(var PreferredHeight: Single; const Radius: Single; const CrouchHeight, HeadBobbing: Single);`
See TWalkCamera.CorrectPreferredHeight. This is a global version, sometimes may be useful.
`function CamDirUp2Orient(const CamDir, CamUp: TVector3Single): TVector4Single;`
Convert camera direction and up vectors into VRML/X3D "orientation" vector. Orientation expresses CamDir and CamUp as 4-item vector (SFRotation). First three items are the Axis (normalized) and the 4th is the Angle (in radians). Meaning: if you rotate the standard direction and up (see DefaultCameraDirection, DefaultCameraUp) around Axis by the Angle, then you get CamDir and CamUp. Given here CamDir and CamUp must be orthogonal and non-zero. Their lengths are not relevant (that is, you don't need to normalize them before passing here).
`procedure CamDirUp2Orient(const CamDir, CamUp: TVector3Single; out OrientAxis: TVector3Single; out OrientRadAngle: Single);`
`function CamDirUp2OrientQuat(CamDir, CamUp: TVector3Single): TQuaternion;`
Convert camera direction and up vectors into "rotation quaternion" of VRML/X3D "orientation". VRML orientation expresses camera direction and up as a rotation. This means that you should rotate the standard direction and up (see DefaultCameraDirection, DefaultCameraUp) by this rotation to get CamDir and CamUp. Given here CamDir and CamUp must be orthogonal and non-zero. Their lengths are not relevant (that is, you don't need to normalize them before passing here).
`procedure CameraViewpointForWholeScene(const Box: TBox3D; const WantedDirection, WantedUp: Integer; const WantedDirectionPositive, WantedUpPositive: boolean; out Position, Direction, Up, GravityUp: TVector3Single);`
Calculate sensible camera configuration to see the whole Box. WantedDirection and WantedUp indicate desired look direction/up axis (0, 1 or 2 for X, Y or Z). WantedDirectionPositive and WantedUpPositive indicate if we want the positive axis. Obviously look direction and up cannot be parallel, so WantedDirection must be different than WantedUp. Returned Direction, Up, GravityUp are normalized.
`procedure Register;`
### Types
`TCameraInput = (...);`
Possible navigation input types in cameras, set in TCamera.Input. ###### Values ciNormal: Normal input types. This includes all inputs available as Input_Xxx properties in TCamera descendants. They are all fully configurable (as TInputShortcut class), they may be mouse button presses, mouse wheel clicks, or key presses. You can always clear some shortcut (like `WalkCamera.Input_Forward.MakeClear`) to disable a specific shortcut. Excluding ciNormal from TCamera.Input is an easy way to disable all shortcuts. ciMouseDragging: Mouse and touch dragging. Both TExamineCamera and TWalkCamera implement their own, special reactions to mouse dragging, that allows to navigate / rotate while pressing specific mouse buttons. ci3dMouse: Navigation using 3D mouse devices, like the ones from 3dconnexion.
`TCameraInputs = set of TCameraInput;`
`TNavigationClass = (...);`
###### Values ncExamine: ncWalk:
`TNavigationType = (...);`
###### Values ntExamine: ntTurntable: ntWalk: ntFly: ntNone:
`TCameraClass = class of TCamera;`
`T3BoolInputs = array [0..2, boolean] of TInputShortcut;`
`TMouseDragMode = (...);`
What mouse dragging does in TWalkCamera. ###### Values mdWalk: Moves avatar continously in the direction of mouse drag (default for TWalkCamera.MouseDragMode). mdRotate: Rotates the head when mouse is moved. mdNone: Ignores the dragging.
`TMoveAllowedFunc = function(Camera: TWalkCamera; const ProposedNewPos: TVector3Single; out NewPos: TVector3Single; const BecauseOfGravity: boolean): boolean of object;`
See TWalkCamera.DoMoveAllowed and TWalkCamera.OnMoveAllowed
`TFallNotifyFunc = procedure (Camera: TWalkCamera; const FallHeight: Single) of object;`
See TWalkCamera.OnFall.
`THeightEvent = function (Camera: TWalkCamera; const Position: TVector3Single; out AboveHeight: Single; out AboveGround: P3DTriangle): boolean of object;`
### Constants
`DefaultCameraDirection: TVector3Single = (0, 0, -1);`
Default camera direction and up vectors, used to define the meaning of "camera orientation" for CamDirUp2Orient routines. These match VRML/X3D default camera values.
`DefaultCameraUp: TVector3Single = (0, 1, 0);`
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:08