Unit CastleTransform
Description
Group and transform scenes (TCastleTransform).
Source: transform/castletransform.pas (line 16).
Uses
- SysUtils
- Classes
- Math
- Generics.Collections
- Contnrs
- Kraft
- CastleVectors
- CastleFrustum
- CastleBoxes
- CastleClassUtils
- CastleKeysMouse
- CastleRectangles
- CastleUtils
- CastleTimeUtils
- CastleComponentSerialize
- CastleSoundEngine
- CastleTriangles
- CastleRenderOptions
- CastleProjection
- CastleUIControls
- CastleQuaternions
- CastleColors
- CastleInternalClassUtils
- CastleInternalFileMonitor
Overview
Classes, Interfaces, Objects and Records
| Name | Description |
|---|---|
Class ECannotAddToAnotherWorld |
|
Class ETransformParentUndefined |
|
Class EMultipleReferencesInWorld |
|
Class ENotAddedToWorld |
|
Class EPhysicsError |
|
Class TBaseShadowVolumeRenderer |
Shadow volumes helper, not depending on OpenGL. |
Record TRayCollisionNode |
Information about ray collision with a single 3D object. |
Class TRayCollision |
Represents a ray collision with TCastleTransform (TCastleTransform that may have parents). |
Record TCollisionDetailsItem |
Detailed information about collision with a single 3D object. |
Class TCollisionDetails |
Represents a collision with a 3D objects tree. |
Record TRenderStatistics |
Statistics about what was rendered during last frame. |
Record TRenderOnePassParams |
How to render a single pass, when the shapes are already collected. |
Class TRenderParams |
Information that a TCastleTransform.LocalRender needs to render. |
Class TPrepareParams |
Information that a TCastleTransform object needs to prepare rendering. |
Class TCastleBehavior |
Behaviors can be attached to TCastleTransform to perform specific logic, for example implement creature movement. |
Class TCastleTransformList |
List of TCastleTransform instances. |
Class TCastleTransform |
Group and transform (move, rotate, scale) children objects. |
Record TRayCastResult |
Result of "ray cast" and "sphere cast", that describes what is hit by a ray (or sphere moving along a ray) in a viewport. |
Record TPhysicsCollisionDetails |
Information send along with TCollisionEvent event, like TCastleRigidBody.OnCollisionEnter, TCastleRigidBody.OnCollisionExit. |
Class TCastleLayerCollisions |
|
Class TCastleLayerNames |
|
Class TPhysicsProperties |
Configure physics simulation calculation. |
Class TCastleCollider |
Abstract collider that determines the shape used to determine collisions with physics bodies. |
Class TCastlePlaneCollider |
Push everything to be above the given static plane, like a floor. |
Class TCastleBoxCollider |
Collide as a box. |
Class TCastleSphereCollider |
Collide as a sphere. |
Class TCastleCapsuleCollider |
Collide as a capsule. |
Class TCastleMeshCollider |
Collide as a set of triangles determined by Mesh. |
Class TCastleRigidBody |
Use this behavior to be affected by physics collisions and forces. |
Class TCastleAbstractRootTransform |
Root of transformations and scenes (tree of TCastleTransform and TCastleScene). |
Class EMaximumTransformDesignDepth |
type section started in CastleTransform.pas |
Class TCastleTransformDesign |
Contents are loaded from an indicated castle-transform file (by the Url property). |
Class TCastleTransformReference |
Reference another TCastleTransform instance, to render one TCastleTransform multiple times within the same viewport. |
Class TCastlePerspective |
Subcomponent used in TCastleCamera.Perspective to set perspective projection parameters. |
Class TCastleOrthographic |
Subcomponent used in TCastleCamera.Orthographic to set orthographic projection parameters. |
Class TCastleCamera |
Camera determines viewer position and orientation in the viewport. |
Class TCastleAbstractJoint |
Base class for physics joints, that connects two physics bodies and constraints their relative movement. |
Class TCastleAbstractOneBodyJoint |
Abstract class for joints that use only one TCastleTransform. |
Class TCastleAbstractTwoBodiesJoint |
Abstract class for joints that connect two TCastleTransform instances. |
Class EConnectedSameAsParent |
|
Class TCastleHingeJoint |
Hinge joint allows to rotate the transformation around a given axis, like a door attached using hinges to the frame. |
Class TCastleRopeJoint |
Rope joint connects two bodies by an invisible rope that prevents the distance between them to grow beyond specfied Distance. |
Class TCastleBallJoint |
Ball joint allows to freely rotate the transformation of one object relative to another (rotate in any axis) but does not allow any movement. |
Class TCastleDistanceJoint |
Distance joint tries to maintain a certain distance between two rigid bodies, with certain flexibility (like a spring). |
Class TCastleGrabJoint |
Grab joint pulls the rigid body Anchor towards a TargetWorld defined in the world coordinates. |
Functions and Procedures
procedure TransformSave(const T: TCastleTransform; const Url: String); |
function TransformLoad(const Url: String; const Owner: TComponent): TCastleTransform; |
procedure TransformMatricesMult(var Transform, InverseTransform: TMatrix4; const Center: TVector3; const Rotation: TVector4; const Scale: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); deprecated 'use TTransformation.Multiply'; |
function StrToOrientationType(const S: String): TOrientationType; |
function OrientationFromDirectionUp(const Direction, Up: TVector3): TVector4; overload; |
procedure OrientationFromDirectionUp(const Direction, Up: TVector3; out Axis: TVector3; out Angle: Single); overload; |
function OrientationFromDirectionUp(const Direction, Up: TVector3; const DefaultDirection, DefaultUp: TVector3): TVector4; overload; |
function OrientationToDirection(const OrientationRotation: TVector4): TVector3; |
function OrientationToUp(const OrientationRotation: TVector4): TVector3; |
function CamDirUp2Orient(const Direction, Up: TVector3): TVector4; overload; deprecated 'use OrientationFromDirectionUp'; |
procedure CamDirUp2Orient(const Direction, Up: TVector3; out Axis: TVector3; out Angle: Single); overload; deprecated 'use OrientationFromDirectionUp'; |
function OrientationQuaternionFromDirectionUp(Direction, Up: TVector3; const DefaultDirection, DefaultUp: TVector3): TQuaternion; overload; |
function OrientationQuaternionFromDirectionUp(const Direction, Up: TVector3): TQuaternion; overload; |
function CamDirUp2OrientQuat(const Direction, Up: TVector3): TQuaternion; deprecated 'OrientationQuaternionFromDirectionUp'; |
procedure CameraViewpointForWholeScene(const Box: TBox3D; const WantedDirection, WantedUp: Integer; const WantedDirectionPositive, WantedUpPositive: boolean; out Position, Direction, Up, GravityUp: TVector3); |
procedure CameraOrthoViewpointForWholeScene(const Box: TBox3D; const ViewportWidth, ViewportHeight: Single; const Origin: TVector2; out Position: TVector3; out AProjectionWidth, AProjectionHeight, AProjectionFar: Single); |
Types
Constants
AllLayers = [Low(TPhysicsLayer)..High(TPhysicsLayer)]; |
rfOffScreen = rfRenderedTexture deprecated 'use rfRenderedTexture'; |
DefaultCameraDirection: TVector3 = (X: 0; Y: 0; Z: -1); |
DefaultCameraUp : TVector3 = (X: 0; Y: 1; Z: 0); |
Default2DProjectionFar = 1000.0 deprecated 'this default is not used; ProjectionFar in orthographic projection is now automatically adjusted to what you display'; |
Default2DProjectionNear = - 1000.0 deprecated 'this default is not used; ProjectionNear in orthographic projection is now automatically adjusted to what you display'; |
Default2DCameraZ = 1000.0 / 2; |
RadiusToProjectionNear = 0.6; |
DefaultCameraRadius = 0.1; |
RadiusToPreferredHeightMin = 4.0; |
Variables
InternalGizmoBoundingBox: Cardinal; |
Description
Functions and Procedures
procedure TransformSave(const T: TCastleTransform; const Url: String); |
|
Save / load TCastleTransform (or descendant) to a .castle-transform file. An example: { TransformSave and TransformLoad example. } {$apptype CONSOLE} uses SysUtils, Classes, CastleLog, CastleVectors, CastleTransform, CastleScene, CastleComponentSerialize; var Scene: TCastleScene; Transform: TCastleTransform; TransformOwner: TComponent; begin InitializeLog; { Create TCastleTransform instance, with a TCastleScene child. } Scene := TCastleScene.Create(nil); Scene.Name := 'MyScene'; // will enable to find it later with FindRequiredComponent Scene.Load('castle-data:/teapot.x3dv'); Transform := TCastleTransform.Create(nil); Transform.Translation := Vector3(1, 2, 3); Transform.Add(Scene); { Save it to file. } TransformSave(Transform, 'aaa.castle-transform'); { You can destroy the instances now. } FreeAndNil(Scene); FreeAndNil(Transform); { Create a component that will own all loaded instances, allowing to easily free them, and to use FindRequiredComponent. } TransformOwner := TComponent.Create(nil); { Now you can load them from file, and check that they are equal. } Transform := TransformLoad('aaa.castle-transform', TransformOwner); WritelnLog('Loaded transform, with translation %s, with %d children', [ Transform.Translation.ToString, Transform.Count ]); Scene := TransformOwner.FindRequiredComponent('MyScene') as TCastleScene; WritelnLog('Found scene in loaded transform, with url %s', [ Scene.Url ]); { Free loaded stuff. } FreeAndNil(TransformOwner); end. |
function TransformLoad(const Url: String; const Owner: TComponent): TCastleTransform; |
|
This item has no description. |
procedure TransformMatricesMult(var Transform, InverseTransform: TMatrix4; const Center: TVector3; const Rotation: TVector4; const Scale: TVector3; const ScaleOrientation: TVector4; const Translation: TVector3); deprecated 'use TTransformation.Multiply'; |
|
Warning: this symbol is deprecated: use TTransformation.Multiply This item has no description. Source: transform/castletransform_miscellaneous_globals.inc (line 22). |
function StrToOrientationType(const S: String): TOrientationType; |
|
This item has no description. Source: transform/castletransform_miscellaneous_globals.inc (line 33). |
function OrientationFromDirectionUp(const Direction, Up: TVector3): TVector4; overload; |
|
Convert camera direction and up vectors into a rotation (X3D "orientation" vector). Orientation vector expresses Direction and Up as a rotation. First three components of the resulting vector are the Axis (normalized) and the 4th component is the Angle (in radians). If you would rotate the standard direction and up (see DefaultCameraDirection, DefaultCameraUp) around Axis by the Angle, then you would get Direction and Up back. There is an overloaded version where you can pass your custom DefaultDirection, DefaultUp to be used instead of default DefaultCameraDirection, DefaultCameraUp. Given here Direction and Up must be orthogonal and non-zero. Their lengths are not relevant (that is, you don't need to normalize them before passing here). Source: transform/castletransform_camera_utils.inc (line 50). |
procedure OrientationFromDirectionUp(const Direction, Up: TVector3; out Axis: TVector3; out Angle: Single); overload; |
|
This item has no description. Source: transform/castletransform_camera_utils.inc (line 51). |
function OrientationFromDirectionUp(const Direction, Up: TVector3; const DefaultDirection, DefaultUp: TVector3): TVector4; overload; |
|
This item has no description. Source: transform/castletransform_camera_utils.inc (line 53). |
function OrientationToDirection(const OrientationRotation: TVector4): TVector3; |
|
Convert rotation (X3D orientation) to a direction vector, reversing the OrientationFromDirectionUp. Source: transform/castletransform_camera_utils.inc (line 59). |
function OrientationToUp(const OrientationRotation: TVector4): TVector3; |
|
Convert rotation (X3D orientation) to an up vector, reversing the OrientationFromDirectionUp. Source: transform/castletransform_camera_utils.inc (line 63). |
function CamDirUp2Orient(const Direction, Up: TVector3): TVector4; overload; deprecated 'use OrientationFromDirectionUp'; |
|
Warning: this symbol is deprecated: use OrientationFromDirectionUp This item has no description. Source: transform/castletransform_camera_utils.inc (line 65). |
procedure CamDirUp2Orient(const Direction, Up: TVector3; out Axis: TVector3; out Angle: Single); overload; deprecated 'use OrientationFromDirectionUp'; |
|
Warning: this symbol is deprecated: use OrientationFromDirectionUp This item has no description. Source: transform/castletransform_camera_utils.inc (line 67). |
function OrientationQuaternionFromDirectionUp(Direction, Up: TVector3; const DefaultDirection, DefaultUp: TVector3): TQuaternion; overload; |
|
Convert camera direction and up vectors into a "rotation quaternion". Just like OrientationFromDirectionUp, but the result is a quaternion, not an axis-angle vector. Source: transform/castletransform_camera_utils.inc (line 75). |
function OrientationQuaternionFromDirectionUp(const Direction, Up: TVector3): TQuaternion; overload; |
|
This item has no description. Source: transform/castletransform_camera_utils.inc (line 77). |
function CamDirUp2OrientQuat(const Direction, Up: TVector3): TQuaternion; deprecated 'OrientationQuaternionFromDirectionUp'; |
|
Warning: this symbol is deprecated: OrientationQuaternionFromDirectionUp This item has no description. Source: transform/castletransform_camera_utils.inc (line 81). |
procedure CameraViewpointForWholeScene(const Box: TBox3D; const WantedDirection, WantedUp: Integer; const WantedDirectionPositive, WantedUpPositive: boolean; out Position, Direction, Up, GravityUp: TVector3); |
|
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. Source: transform/castletransform_camera_utils.inc (line 92). |
procedure CameraOrthoViewpointForWholeScene(const Box: TBox3D; const ViewportWidth, ViewportHeight: Single; const Origin: TVector2; out Position: TVector3; out AProjectionWidth, AProjectionHeight, AProjectionFar: Single); |
|
Calculate suitable camera to see everything using an orthographic projection. Assumes that the camera direction is -Z, and camera up is +Y. So the horizontal axis of the world is X, vertical axis is Y. These are default values of camera set by TCastleViewport.Setup2D. The meaning of Origin is the same as TCastleOrthographic.Origin. Returns new correct values of TCastleOrthographic.Width, TCastleOrthographic.Height, TCastleCamera.ProjectionFar and camera position (set it like Source: transform/castletransform_camera_utils.inc (line 112). |
Types
TPhysicsLayer = 0..19; |
|
Each physics rigid body is part of a specific layer, TCastleRigidBody.Layer. It is configurable which layers can collide with each other (see https://castle-engine.io/physics#_layers ). Moreover routines like TCastleRigidBody.PhysicsRayCast allow to specify which layers are checked. Source: transform/castletransform_physics_layers.inc (line 30). |
TPhysicsLayers = set of TPhysicsLayer; |
|
This item has no description. Source: transform/castletransform_physics_layers.inc (line 32). |
TCastleTransformClass = class of TCastleTransform; |
|
This item has no description. Source: transform/castletransform_initial_types.inc (line 28). |
TRenderFromViewFunction = procedure (const RenderingCamera: TRenderingCamera) of object; |
|
This item has no description. |
TVisibleChange = (...); |
|
Describe what visible thing changed for TCastleTransform.VisibleChangeHere. Values
Source: transform/castletransform_initial_types.inc (line 39). |
TVisibleChanges = set of TVisibleChange; |
|
This item has no description. Source: transform/castletransform_initial_types.inc (line 52). |
TVisibleChangeEvent = procedure (const Sender: TCastleTransform; const Changes: TVisibleChanges) of object; |
|
This item has no description. |
TPrepareResourcesOption = (...); |
|
Various things that TCastleTransform.PrepareResources may prepare. Values
Source: transform/castletransform_initial_types.inc (line 57). |
TPrepareResourcesOptions = set of TPrepareResourcesOption; |
|
This item has no description. Source: transform/castletransform_initial_types.inc (line 70). |
PRayCollisionNode = ˆTRayCollisionNode; |
|
This item has no description. Source: transform/castletransform_initial_types.inc (line 124). |
PCollisionDetailsItem = ˆTCollisionDetailsItem; |
|
This item has no description. Source: transform/castletransform_initial_types.inc (line 210). |
TRemoveType = (...); |
|
This item has no description. Values
Source: transform/castletransform_initial_types.inc (line 231). |
TOrientationType = (...); |
|
Orientation of the model is 3D world, determining where is the conceptual "up" direction of the model, and where is it facing. This type is used by the TCastleTransform.Orientation and TCastleTransform.DefaultOrientation. Orientation determines how TCastleTransform.Direction, TCastleTransform.Up work, i.e. what is TCastleTransform.Direction and TCastleTransform.Up relation to TCastleTransform.Rotation. The names of the enum values describe what is the direction/up when rotation is zero. Values
Source: transform/castletransform_initial_types.inc (line 246). |
PRenderStatistics = ˆTRenderStatistics; |
|
This item has no description. Source: transform/castletransform_renderparams.inc (line 60). |
TUserRenderingPass = 0..2; |
|
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). Source: transform/castletransform_renderparams.inc (line 98). |
TRenderEvent = procedure (const Transformation: TTransformation; const PassParams: TRenderOnePassParams) of object; |
|
Callback used by TRenderParams.AddRenderEvent. See also
|
TCastleBehaviorClass = class of TCastleBehavior; |
TCastleBehaviorList = specialize TObjectList<TCastleBehavior>; |
|
This item has no description. |
TPhysicsRayCastResult = TRayCastResult deprecated 'use TRayCastResult'; |
|
Warning: this symbol is deprecated: use TRayCastResult This item has no description. |
TCollisionEvent = procedure (const CollisionDetails: TPhysicsCollisionDetails) of object; |
|
This item has no description. |
TCastleRigidBodyList = specialize TList<TCastleRigidBody>; |
|
This item has no description. |
TCollisionDetection = (...); |
|
This item has no description. Values
|
TReferenceTransformation = (...); |
|
How do we treat the transformation of TCastleTransformReference.Reference when rendering TCastleTransformReference. Values
|
TFieldOfViewAxis = (...); |
|
Value of TCastlePerspective.FieldOfViewAxis. Values
|
TSceneManagerWorld = TCastleAbstractRootTransform deprecated 'use TCastleRootTransform'; |
|
Warning: this symbol is deprecated: use TCastleRootTransform Copyright 2017-2022 Michalis Kamburelis. This file is part of "Castle Game Engine". "Castle Game Engine" is free software; see the file COPYING.txt, included in this distribution, for details about the copyright. "Castle Game Engine" is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. —————————————————————————- Source: transform/castletransform_miscellaneous_globals.inc (line 20). |
Constants
AllLayers = [Low(TPhysicsLayer)..High(TPhysicsLayer)]; |
|
This item has no description. Source: transform/castletransform_physics_layers.inc (line 35). |
rfOffScreen = rfRenderedTexture deprecated 'use rfRenderedTexture'; |
|
Warning: this symbol is deprecated: use rfRenderedTexture This item has no description. Source: transform/castletransform_miscellaneous_globals.inc (line 31). |
DefaultCameraDirection: TVector3 = (X: 0; Y: 0; Z: -1); |
|
Default camera direction and up vectors, used to define the meaning of "camera orientation" for OrientationFromDirectionUp, OrientationToDirection, OrientationToUp. These match X3D default camera values. Source: transform/castletransform_camera_utils.inc (line 25). |
DefaultCameraUp : TVector3 = (X: 0; Y: 1; Z: 0); |
|
This item has no description. Source: transform/castletransform_camera_utils.inc (line 26). |
Default2DProjectionFar = 1000.0 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 This item has no description. Source: transform/castletransform_camera_utils.inc (line 29). |
Default2DProjectionNear = - 1000.0 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: transform/castletransform_camera_utils.inc (line 30). |
Default2DCameraZ = 1000.0 / 2; |
|
Source: transform/castletransform_camera_utils.inc (line 31). |
RadiusToProjectionNear = 0.6; |
|
Following X3D spec of NavigationType: "It is recommended that the near clipping plane be set to one-half of the collision radius as specified in the avatarSize field." Source: transform/castletransform_camera_utils.inc (line 124). |
DefaultCameraRadius = 0.1; |
|
Default Radius, determining also (with RadiusToProjectionNear) default TCastleCamera.EffectiveProjectionNear. Note: *Do not* base automatic Radius (and, consistently, automatic ProjectionNear) on Box size. - Major reason: It makes things go bad, as automatic ProjectionNear increases and clipping at near plane becomes visible, when you have some TCastleTransform in your world that travels forever (and thus increases the Viewport.ItemsBoundingBox into infinity). E.g. a missile that flies into infinity. Or a box that falls down due to gravity into infinity. While such things in general should not happen (you should prevent things from traveling to infinity), but they may happen esp. in development, and it's bad when one problem (flying to infinity) causes another (sudden clipping at near plane). - Minor reason: It avoids the need to calculate Viewport.ItemsBoundingBox at each frame, at least for the purpose of automatic projection for ProjectionNear. It was never observed in profiler, but in theory Viewport.ItemsBoundingBox may be costly when you have a lot of scenes. Note: This is smaller, so even safer, than X3D default Navigation.avatarSize[0] (0.25). Source: transform/castletransform_camera_utils.inc (line 152). |
RadiusToPreferredHeightMin = 4.0; |
|
Multiply radius by this to get sensible "preferred height". We need to make "preferred height" much larger than Radius * 2, to allow some space to decrease (e.g. by Input_DecreasePreferredHeight). Remember that CorrectPreferredHeight adds a limit to PreferredHeight, around Radius * 2. This determines minimal PreferredHeight, it should be used always like Max(DefaultPreferredHeight, Radius * Source: transform/castletransform_camera_utils.inc (line 167). |
Variables
InternalGizmoBoundingBox: Cardinal; |
|
This item has no description. Source: transform/castletransform_miscellaneous_globals.inc (line 36). |
Generated by PasDoc 0.17.0.snapshot.