Class TCastleNavigation

Unit

Declaration

type TCastleNavigation = class(TCastleUserInterface)

Description

Handle user input to modify viewport's camera.

Create an instance of this class, and set it as TCastleViewport.Navigation value. It will become a child control of the associated TCastleViewport.

In many ways, this is just a normal TCastleUserInterface descendant. E.g. it processes input just like any other TCastleUserInterface descendant (there isn't any special mechanism through which TCastleViewport passes input to the navigation), the Exists property works and so on. Setting it as TCastleViewport.Navigation (as opposed to just adding it manually by TCastleUserInterface.InsertFront to the viewport) serves just two purposes: we set internal link to the viewport, and we make sure to remove previous TCastleViewport.Navigation value from children.

The point of the above explanation is that you can modify TCastleViewport.Camera (move, rotate and do other stuff with camera) from any place in the code. You don't need to use an ancestor of TCastleNavigation to manipulate the camera. TCastleNavigation is a comfortable way to encapsulate common navigation methods, but it's not the only way to move the camera.

Various TCastleNavigation descendants implement various navigation methods, for example TCastleExamineNavigation allows the user to rotate and scale the model (imagine that you're holding a 3D model in your hands and you look at it from various sides) and TCastleWalkNavigation implements typical navigation in the style of first-person shooter games.

Hierarchy

Overview

Fields

Protected MouseDraggingStarted: Integer;
Protected MouseDraggingStart: TVector2;
Public nested const DefaultRadius = 0.25;
Public nested const DefaultPreferredHeight = 1.6;
Public nested const DefaultInput = [niNormal, niMouseDragging, ni3dMouse, niGesture];
Public nested const DefaultHeadBobbingTime = 0.5;
Public nested const DefaultHeadBobbing = 0.02;
Public nested const DefaultCrouchHeight = 0.5;

Methods

Protected procedure SetInput(const Value: TNavigationInputs); virtual;
Protected function GetIgnoreAllInputs: boolean;
Protected procedure SetIgnoreAllInputs(const Value: boolean);
Protected procedure SetRadius(const Value: Single); virtual;
Protected function ReallyEnableMouseDragging: boolean; virtual;
Protected procedure SetModelBox(const B: TBox3D);
Protected procedure Height(const APosition: TVector3; out AIsAbove: Boolean; out AnAboveHeight: Single; out AnAboveGround: PTriangle);
Protected function MoveAllowed( const OldPos: TVector3; ProposedNewPos: TVector3; out NewPos: TVector3; const Radius: Single; const BecauseOfGravity: Boolean): Boolean;
Public constructor Create(AOwner: TComponent); override;
Public procedure Assign(Source: TPersistent); override;
Public function GetExists: boolean; override;
Public function Camera: TCastleCamera;
Public function Matrix: TMatrix4; deprecated 'use Viewport.Camera.Matrix';
Public function MatrixInverse: TMatrix4; deprecated 'use Viewport.Camera.MatrixInverse';
Public function RotationMatrix: TMatrix4; deprecated 'use Viewport.Camera.RotationMatrix';
Public procedure GetView(out APos, ADir, AUp: TVector3); overload; deprecated 'use Viewport.Camera.GetView';
Public procedure GetView(out APos, ADir, AUp, AGravityUp: TVector3); overload; deprecated 'use Viewport.Camera.GetView';
Public procedure SetView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; deprecated 'use Viewport.Camera.SetView';
Public procedure SetView(const APos, ADir, AUp, AGravityUp: TVector3; const AdjustUp: boolean = true); overload; deprecated 'use Viewport.Camera.SetView';
Public procedure Ray(const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); deprecated 'use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead';
Public procedure MouseRay( const Projection: TProjection; out RayOrigin, RayDirection: TVector3); deprecated 'use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead';
Public procedure CustomRay( const ViewportRect: TRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); overload; deprecated 'use Viewport.Camera.CustomRay';
Public procedure CustomRay( const ViewportRect: TFloatRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); overload; deprecated 'use Viewport.Camera.CustomRay';
Public function Press(const Event: TInputPressRelease): boolean; override;
Public function Release(const Event: TInputPressRelease): boolean; override;
Public procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); deprecated 'use Viewport.Camera.AnimateTo';
Public procedure AnimateTo(const OtherNavigation: TCastleNavigation; const Time: TFloatTime); deprecated 'use AnimateTo with TCastleCamera, not TCastleNavigation';
Public procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); deprecated 'use Viewport.Camera.AnimateTo';
Public function Animation: boolean; deprecated 'use Viewport.Camera.Animation';
Public function InitialPosition: TVector3; deprecated 'use Viewport.Camera.InitialPosition';
Public function InitialDirection: TVector3; deprecated 'use Viewport.Camera.InitialDirection';
Public function InitialUp: TVector3; deprecated 'use Viewport.Camera.InitialUp';
Public procedure SetInitialView( const AInitialPosition: TVector3; AInitialDirection, AInitialUp: TVector3; const TransformCurrentCamera: boolean); deprecated 'use Viewport.Camera.SetInitialView';
Public procedure GoToInitial; deprecated 'use Viewport.Camera.GoToInitial';
Public function GetNavigationType: TNavigationType; virtual;
Public procedure CorrectPreferredHeight;

Properties

Public property OnMoveAllowed: TMoveAllowedFunc read FOnMoveAllowed write FOnMoveAllowed;
Public property OnInternalMoveAllowed: TMoveAllowedFunc read FOnInternalMoveAllowed write FOnInternalMoveAllowed;
Public property OnInternalHeight: THeightEvent read FOnInternalHeight write FOnInternalHeight;
Public property OnFall: TFallNotifyFunc read FOnFall write FOnFall;
Public property IgnoreAllInputs: boolean read GetIgnoreAllInputs write SetIgnoreAllInputs default false; deprecated;
Public property Frustum: TFrustum read GetFrustum; deprecated 'use Viewport.Camera.Frustum';
Public property ProjectionMatrix: TMatrix4 read GetProjectionMatrix write SetProjectionMatrix; deprecated 'use Viewport.Camera.ProjectionMatrix';
Public property Radius: Single read FRadius write SetRadius default DefaultRadius;
Public property Position : TVector3 read GetPosition write SetPosition; deprecated 'use Viewport.Camera.Position';
Public property Direction: TVector3 read GetDirection write SetDirection; deprecated 'use Viewport.Camera.Direction';
Public property Up : TVector3 read GetUp write SetUp; deprecated 'use Viewport.Camera.Up';
Public property GravityUp: TVector3 read GetGravityUp write SetGravityUp; deprecated 'use Viewport.Camera.GravityUp';
Public property PreferredHeight: Single read FPreferredHeight write FPreferredHeight default DefaultPreferredHeight;
Public property CrouchHeight: Single read FCrouchHeight write FCrouchHeight default DefaultCrouchHeight;
Public property HeadBobbing: Single read FHeadBobbing write FHeadBobbing default DefaultHeadBobbing;
Public property HeadBobbingTime: Single read FHeadBobbingTime write FHeadBobbingTime default DefaultHeadBobbingTime;
Public property MoveHorizontalSpeed: Single read FMoveHorizontalSpeed write FMoveHorizontalSpeed default 1.0;
Public property MoveVerticalSpeed: Single read FMoveVerticalSpeed write FMoveVerticalSpeed default 1.0;
Public property MoveSpeed: Single read FMoveSpeed write FMoveSpeed default 1.0;
Public property ClimbHeight: Single read FClimbHeight write FClimbHeight;
Public property ModelBox: TBox3D read FModelBox write SetModelBox;
Public property Input: TNavigationInputs read FInput write SetInput default DefaultInput;
Published property FullSize default true;

Description

Fields

Protected MouseDraggingStarted: Integer;

Needed for niMouseDragging navigation. Checking MouseDraggingStarted means that we handle only dragging that was initialized on viewport (since the viewport passed events to navigation). MouseDraggingStarted -1 means none, otherwise it's the finder index (to support multitouch).

Protected MouseDraggingStart: TVector2;
 
Public nested const DefaultRadius = 0.25;

Default value for TCastleNavigation.Radius. Matches the default VRML/X3D NavigationInfo.avatarSize[0].

Public nested const DefaultPreferredHeight = 1.6;

Default value for TCastleNavigation.PreferredHeight. Matches the default VRML/X3D NavigationInfo.avatarSize[1].

Public nested const DefaultInput = [niNormal, niMouseDragging, ni3dMouse, niGesture];
 
Public nested const DefaultHeadBobbingTime = 0.5;
 
Public nested const DefaultHeadBobbing = 0.02;
 
Public nested const DefaultCrouchHeight = 0.5;
 

Methods

Protected procedure SetInput(const Value: TNavigationInputs); virtual;
 
Protected function GetIgnoreAllInputs: boolean;
 
Protected procedure SetIgnoreAllInputs(const Value: boolean);
 
Protected procedure SetRadius(const Value: Single); virtual;
 
Protected function ReallyEnableMouseDragging: boolean; virtual;
 
Protected procedure SetModelBox(const B: TBox3D);
 
Protected procedure Height(const APosition: TVector3; out AIsAbove: Boolean; out AnAboveHeight: Single; out AnAboveGround: PTriangle);

Check collisions to determine how high above ground is given point. Calls OnInternalHeight callback.

Protected function MoveAllowed( const OldPos: TVector3; ProposedNewPos: TVector3; out NewPos: TVector3; const Radius: Single; const BecauseOfGravity: Boolean): Boolean;

Check collisions to determine can the object move. Object wants to move from OldPos to ProposedNewPos.

Returns False if no move is allowed. Otherwise returns True and sets NewPos to the position where user should be moved.

If you're doing a simple check for collisions, you will always want to set NewPos to ProposedNewPos when returning True.

But you can also do more sophisticated calculations and sometimes not allow user to move to ProposedNewPos, but allow him to move instead to some other close position. For example when doing "wall sliding" (common in FPS games): when you're trying to walk "into the wall", you move along the wall instead.

It's allowed to modify NewPos when returning False. It makes no effect.

BecauseOfGravity says whether this move is caused by gravity dragging the player down. You can use BecauseOfGravity e.g. to implement TCastleViewport.PreventInfiniteFallingDown.

Implementation calls OnMoveAllowed and OnInternalMoveAllowed.

Public constructor Create(AOwner: TComponent); override;
 
Public procedure Assign(Source: TPersistent); override;
 
Public function GetExists: boolean; override;
 
Public function Camera: TCastleCamera;

Associated TCastleCamera of the viewport.

Exceptions raised
EViewportNotAssigned
If Viewport not assigned yet.
Public function Matrix: TMatrix4; deprecated 'use Viewport.Camera.Matrix';

Warning: this symbol is deprecated: use Viewport.Camera.Matrix

Camera matrix, transforming from world space into camera space.

Public function MatrixInverse: TMatrix4; deprecated 'use Viewport.Camera.MatrixInverse';

Warning: this symbol is deprecated: use Viewport.Camera.MatrixInverse

Inverse of Matrix, transforming from camera space into world space.

Public function RotationMatrix: TMatrix4; deprecated 'use Viewport.Camera.RotationMatrix';

Warning: this symbol is deprecated: use Viewport.Camera.RotationMatrix

Extract only rotation from your current camera Matrix. This is useful for rendering skybox in 3D programs (e.g. for VRML/X3D Background node) and generally to transform directions between world and camera space.

It's guaranteed that this is actually only 3x3 matrix, the 4th row and 4th column are all zero except the lowest right item which is 1.0.

Public procedure GetView(out APos, ADir, AUp: TVector3); overload; deprecated 'use Viewport.Camera.GetView';

Warning: this symbol is deprecated: use Viewport.Camera.GetView

Express current view as camera vectors: position, direction, up.

Returned Dir and Up must be orthogonal. Returned Dir and Up and GravityUp are already normalized.

Public procedure GetView(out APos, ADir, AUp, AGravityUp: TVector3); overload; deprecated 'use Viewport.Camera.GetView';

Warning: this symbol is deprecated: use Viewport.Camera.GetView

 
Public procedure SetView(const APos, ADir, AUp: TVector3; const AdjustUp: boolean = true); overload; deprecated 'use Viewport.Camera.SetView';

Warning: this symbol is deprecated: use Viewport.Camera.SetView

Set camera view from vectors: position, direction, up.

Direction, Up and GravityUp do not have to be normalized, we will normalize them internally if necessary. But make sure they are non-zero.

We will automatically fix Direction and Up to be orthogonal, if necessary: when AdjustUp = True (the default) we will adjust the up vector (preserving the given direction value), otherwise we will adjust the direction (preserving the given up value).

Public procedure SetView(const APos, ADir, AUp, AGravityUp: TVector3; const AdjustUp: boolean = true); overload; deprecated 'use Viewport.Camera.SetView';

Warning: this symbol is deprecated: use Viewport.Camera.SetView

 
Public procedure Ray(const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); deprecated 'use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead';

Warning: this symbol is deprecated: use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead

Calculate a 3D ray picked by the WindowX, WindowY position on the window.

Uses current container size, which means that it assumes that viewport fills the whole window, and requires that it's added to TCastleViewport.Navigation and this TCastleViewport must be part of TCastleWindowBase.Controls or TCastleControlBase.Controls.

Projection (read-only here) describe your projection, required for calculating the ray properly. Resulting RayDirection is always normalized.

WindowPosition is given in the same style as TUIContainer.MousePosition: (0, 0) is bottom-left.

Public procedure MouseRay( const Projection: TProjection; out RayOrigin, RayDirection: TVector3); deprecated 'use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead';

Warning: this symbol is deprecated: use Viewport.Camera.CustomRay with proper viewport sizes, or use higher-level utilities like Viewport.MouseRayHit instead

Calculate a ray picked by current mouse position on the window.

Uses current container size, which means that it assumes that viewport fills the whole window, and requires that it's added to TCastleViewport.Navigation and this TCastleViewport must be part of TCastleWindowBase.Controls or TCastleControlBase.Controls.

See also
Ray
Calculate a 3D ray picked by the WindowX, WindowY position on the window.
CustomRay
Public procedure CustomRay( const ViewportRect: TRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); overload; deprecated 'use Viewport.Camera.CustomRay';

Warning: this symbol is deprecated: use Viewport.Camera.CustomRay

Calculate a ray picked by WindowPosition position on the viewport, assuming current viewport dimensions are as given. This doesn't look at our container sizes at all.

Projection (read-only here) describe projection, required for calculating the ray properly.

Resulting RayDirection is always normalized.

WindowPosition is given in the same style as TUIContainer.MousePosition: (0, 0) is bottom-left.

Public procedure CustomRay( const ViewportRect: TFloatRectangle; const WindowPosition: TVector2; const Projection: TProjection; out RayOrigin, RayDirection: TVector3); overload; deprecated 'use Viewport.Camera.CustomRay';

Warning: this symbol is deprecated: use Viewport.Camera.CustomRay

 
Public function Press(const Event: TInputPressRelease): boolean; override;
 
Public function Release(const Event: TInputPressRelease): boolean; override;
 
Public procedure AnimateTo(const OtherCamera: TCastleCamera; const Time: TFloatTime); deprecated 'use Viewport.Camera.AnimateTo';

Warning: this symbol is deprecated: use Viewport.Camera.AnimateTo

 
Public procedure AnimateTo(const OtherNavigation: TCastleNavigation; const Time: TFloatTime); deprecated 'use AnimateTo with TCastleCamera, not TCastleNavigation';

Warning: this symbol is deprecated: use AnimateTo with TCastleCamera, not TCastleNavigation

 
Public procedure AnimateTo(const APos, ADir, AUp: TVector3; const Time: TFloatTime); deprecated 'use Viewport.Camera.AnimateTo';

Warning: this symbol is deprecated: use Viewport.Camera.AnimateTo

 
Public function Animation: boolean; deprecated 'use Viewport.Camera.Animation';

Warning: this symbol is deprecated: use Viewport.Camera.Animation

 
Public function InitialPosition: TVector3; deprecated 'use Viewport.Camera.InitialPosition';

Warning: this symbol is deprecated: use Viewport.Camera.InitialPosition

 
Public function InitialDirection: TVector3; deprecated 'use Viewport.Camera.InitialDirection';

Warning: this symbol is deprecated: use Viewport.Camera.InitialDirection

 
Public function InitialUp: TVector3; deprecated 'use Viewport.Camera.InitialUp';

Warning: this symbol is deprecated: use Viewport.Camera.InitialUp

 
Public procedure SetInitialView( const AInitialPosition: TVector3; AInitialDirection, AInitialUp: TVector3; const TransformCurrentCamera: boolean); deprecated 'use Viewport.Camera.SetInitialView';

Warning: this symbol is deprecated: use Viewport.Camera.SetInitialView

 
Public procedure GoToInitial; deprecated 'use Viewport.Camera.GoToInitial';

Warning: this symbol is deprecated: use Viewport.Camera.GoToInitial

 
Public function GetNavigationType: TNavigationType; virtual;

By default this returns ntNone. Internal navigation descendants can return something else, to cooperate with TCastleViewport.NavigationType. Your custom navigation descendants can just return ntNone.

Public procedure CorrectPreferredHeight;

Correct PreferredHeight based on Radius and on current HeadBobbing.

Exactly what and why is done: if you do any kind of collision detection with some Radius, then you should make sure that RealPreferredHeight is always >= of your Radius, otherwise strange effects may happen when crouching or when head bobbing forces camera to go down.

Exactly, the required equation is

MinimumRealPreferredHeight :=
  PreferredHeight * CrouchHeight * (1 - HeadBobbing);

and always must be

MinimumRealPreferredHeight >= RealPreferredHeight

Reasoning: otherwise this class would "want camera to fall down" (because we will always be higher than RealPreferredHeight) but your OnMoveAllowed would not allow it (because Radius would not allow it).

This method will make sure that this condition holds by eventually adjusting (making larger) PreferredHeight. Note that for Radius = 0.0 this will always leave PreferredHeight as it is.

Properties

Public property OnMoveAllowed: TMoveAllowedFunc read FOnMoveAllowed write FOnMoveAllowed;

Used by MoveAllowed, see there for description. You can assign this property.

Public property OnInternalMoveAllowed: TMoveAllowedFunc read FOnInternalMoveAllowed write FOnInternalMoveAllowed;

Used by MoveAllowed, see there for description. This property is used internally by TCastleViewport.

Public property OnInternalHeight: THeightEvent read FOnInternalHeight write FOnInternalHeight;

Assign here the callback to check collisions and determine what is the current height of position above the ground. This should be calculated like collision of ray from Position in direction -GravityUp with the world. See TCastleTransform.Height for specification what returned parameters mean.

Public property OnFall: TFallNotifyFunc read FOnFall write FOnFall;

Notification that we have been falling down for some time due to gravity, and suddenly stopped (which means we "hit the ground").

This event can be useful in games, for example to lower player's health, and/or make a visual effect (like a "red out" indicating pain) and/or make a sound effect ("Ouch!" or "Thud!" or such sounds). You can look at FallHeight parameter, given to the callback, e.g. to gauge how much health decreases.

Public property IgnoreAllInputs: boolean read GetIgnoreAllInputs write SetIgnoreAllInputs default false; deprecated;

Warning: this symbol is deprecated.

Deprecated, use more flexible Input instead. IgnoreAllInputs := true is equivalent to Input := [], IgnoreAllInputs := false is equivalent to Input := DefaultInput.

Public property Frustum: TFrustum read GetFrustum; deprecated 'use Viewport.Camera.Frustum';

Warning: this symbol is deprecated: use Viewport.Camera.Frustum

The current camera viewing frustum, based on ProjectionMatrix (set by the outside) and Matrix (calculated here). This is recalculated whenever one of these two properties change. Be sure to set ProjectionMatrix before using this.

Public property ProjectionMatrix: TMatrix4 read GetProjectionMatrix write SetProjectionMatrix; deprecated 'use Viewport.Camera.ProjectionMatrix';

Warning: this symbol is deprecated: use Viewport.Camera.ProjectionMatrix

Projection matrix of the camera. Camera needs to know this to calculate Frustum, which in turn allows rendering code to use frustum culling.

In normal circumstances, if you use our scene manager and viewport (TCastleViewport) for rendering, this is automatically correctly set for you.

Public property Radius: Single read FRadius write SetRadius default DefaultRadius;

The radius of a sphere around the camera that makes collisions with the world.

  • Collision detection routines use this.

  • It determines the projection near plane (that must be slightly smaller than this radius) for 3D rendering.

  • Walk navigation uses this for automatically correcting PreferredHeight, otherwise weird things could happen if your avatar height is too small compared to the camera radius. See CorrectPreferredHeight.

    Especially useful if you let user change PreferredHeight at runtime by Input_IncreasePreferredHeight, Input_DecreasePreferredHeight.

Public property Position : TVector3 read GetPosition write SetPosition; deprecated 'use Viewport.Camera.Position';

Warning: this symbol is deprecated: use Viewport.Camera.Position

Camera position, looking direction and up vector.

Initially (after creating this object) they are equal to InitialPosition, InitialDirection, InitialUp. Also GoToInitial methods reset them to these initial values.

The Direction and Up vectors should always be normalized (have length 1). When setting them by these properties, we will normalize them automatically, so their given length is actually ignored.

When setting Direction, Up will always be automatically adjusted to be orthogonal to Direction. And vice versa — when setting Up, Direction will be adjusted.

Public property Direction: TVector3 read GetDirection write SetDirection; deprecated 'use Viewport.Camera.Direction';

Warning: this symbol is deprecated: use Viewport.Camera.Direction

 
Public property Up : TVector3 read GetUp write SetUp; deprecated 'use Viewport.Camera.Up';

Warning: this symbol is deprecated: use Viewport.Camera.Up

 
Public property GravityUp: TVector3 read GetGravityUp write SetGravityUp; deprecated 'use Viewport.Camera.GravityUp';

Warning: this symbol is deprecated: use Viewport.Camera.GravityUp

"Up" direction of the world in which player moves. Always normalized (when setting this property, we take care to normalize the provided vector).

This determines in which direction TCastleWalkNavigation.Gravity works.

This is also the "normal" value for both Up and InitialUp — one that means that player is looking straight foward. This is used for features like PreferGravityUpForRotations and/or PreferGravityUpForMoving.

The default value of this vector is (0, 1, 0) (same as the default Up and InitialUp vectors).

Public property PreferredHeight: Single read FPreferredHeight write FPreferredHeight default DefaultPreferredHeight;

Height above the ground, only used by TCastleWalkNavigation descendant when TCastleWalkNavigation.Gravity is True. The Position tries to stay PreferredHeight above the ground. Temporarily it may still be lower (e.g. player can shortly "duck" when he falls from high).

This must always be >= 0. You should set this to something greater than zero to get sensible behavior of some things related to TCastleWalkNavigation.Gravity.

See CorrectPreferredHeight for important property of PreferredHeight that you should keep.

Public property CrouchHeight: Single read FCrouchHeight write FCrouchHeight default DefaultCrouchHeight;

Preferred height when crouching. This is always mutiplied to PreferredHeight. This should always be <= 1 (CrouchHeight = 1 effectively disables crouching, although it's better to do this by calling MakeClear on Input_Crouch).

Public property HeadBobbing: Single read FHeadBobbing write FHeadBobbing default DefaultHeadBobbing;

When TCastleWalkNavigation moves, it may make a "head bobbing" effect, by moving the camera a bit up and down.

This property mutiplied by PreferredHeight says how much head bobbing can move you along GravityUp. Set this to 0 to disable head bobbing. This must always be < 1.0. For sensible effects, this should be rather close to 0.0, for example 0.02.

This is meaningfull only when TCastleWalkNavigation.Gravity works.

Public property HeadBobbingTime: Single read FHeadBobbingTime write FHeadBobbingTime default DefaultHeadBobbingTime;

Controls head bobbing frequency. In the time of HeadBobbingTime seconds, we do full head bobbing sequence (camera swing up, then down again).

Note that if you do a footsteps sound in your game (see stPlayerFootstepsDefault or TMaterialProperty.FootstepsSound) then you will want this property to match your footsteps sound length, things feel and sound natural then. Also, often it sounds better to record two footsteps inside a single sound file, in which case the footstep sound length should be twice as long as this property. For example, record 2 steps inside a 1-second long footstep sound, and set this property to 0.5 a second (which is a default in fact).

Public property MoveHorizontalSpeed: Single read FMoveHorizontalSpeed write FMoveHorizontalSpeed default 1.0;

Moving speeds, only used by TCastleWalkNavigation descendant. MoveHorizontalSpeed is only for horizontal movement, MoveVerticalSpeed is only for vertical, and MoveSpeed simply affects both types of movement. Effectively, we always scale the speed of movement by either MoveHorizontalSpeed * MoveSpeed or MoveVerticalSpeed * MoveSpeed.

We move by distance MoveSpeed * MoveHorizontalSpeed (or MoveVerticalSpeed) during one second. So if you leave MoveHorizontalSpeed = MoveVerticalSpeed = 1 (as default), MoveSpeed expresses the speed in nice units / per second.

Default values for all these speed properties is 1.0, so you simply move by 1 unit per second.

Public property MoveVerticalSpeed: Single read FMoveVerticalSpeed write FMoveVerticalSpeed default 1.0;
 
Public property MoveSpeed: Single read FMoveSpeed write FMoveSpeed default 1.0;
 
Public property ClimbHeight: Single read FClimbHeight write FClimbHeight;

The tallest height that you can climb, only used by TCastleWalkNavigation descendant when TCastleWalkNavigation.Gravity is True. This is checked in each single horizontal move when TCastleWalkNavigation.Gravity works. Must be >= 0. Value 0 means there is no limit (and makes a small speedup).

This is reliable to prevent user from climbing stairs and such, when vertical walls are really vertical (not just steep-almost-vertical).

It's not 100% reliable to prevent player from climbing steep hills. That's because, depending on how often an event processing occurs, you actually climb using less or more steps. So even a very steep hill can be always climbed on a computer with very fast speed, because with large FPS you effectively climb it using a lot of very small steps (assuming that FPS limit is not enabled, that is CastleWindow.TCastleApplication.LimitFPS or CastleControl.LimitFPS is zero).

Remember that user can still try jumping to climb on high obstactes. See TCastleWalkNavigation.JumpMaxHeight for a way to control jumping.

For a 100% reliable way to prevent user from reaching some point, that does not rely on specific navigation settings, you should build actual walls in 3D (invisible walls can be created by Collision.proxy in VRML/X3D).

Public property ModelBox: TBox3D read FModelBox write SetModelBox;

Approximate size of 3D world that is viewed, used by TCastleExamineNavigation descendant. Determines speed of movement and zooming. Initially this is TBox3D.Empty.

Public property Input: TNavigationInputs read FInput write SetInput default DefaultInput;

Input methods available to user. See documentation of TNavigationInput type for possible values and their meaning.

To disable any user interaction with this navigation you can simply set this to empty. You can also leave TCastleViewport.Navigation as Nil.

Published property FullSize default true;

By default this captures events from whole parent, which should be whole Viewport.


Generated by PasDoc 0.15.0.