Unit CastleTransform

Description

Group and transform scenes (TCastleTransform).

Uses

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 a 3D objects tree.
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.
Class TRenderParams Information that a TCastleTransform object 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.
Class TCastleAbstractRootTransform Root of transformations and scenes (tree of TCastleTransform and TCastleScene).
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.
Record TPhysicsCollisionDetails Information send along with TCollisionEvent event, like TRigidBody.OnCollisionEnter, TRigidBody.OnCollisionExit.
Class TPhysicsProperties Configure physics simulation calculation.
Class TCollider Shape used for collision detection of a rigid body TRigidBody.
Class TPlaneCollider Collide as an infinite plane.
Class TBoxCollider Collide as a box.
Class TSphereCollider Collide as a sphere.
Class TCapsuleCollider Collide as a capsule.
Class TRigidBody Rigid body properties for the physics engine, see TCastleTransform.RigidBody.

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;

Types

TCastleTransformClass = class of TCastleTransform;
TRenderFromViewFunction = procedure (const RenderingCamera: TRenderingCamera) of object;
TVisibleChange = (...);
TVisibleChanges = set of TVisibleChange;
TVisibleChangeEvent = procedure (const Sender: TCastleTransform; const Changes: TVisibleChanges) of object;
TPrepareResourcesOption = (...);
TPrepareResourcesOptions = set of TPrepareResourcesOption;
PRayCollisionNode = ˆTRayCollisionNode;
PCollisionDetailsItem = ˆTCollisionDetailsItem;
TRemoveType = (...);
TOrientationType = (...);
TUserRenderingPass = 0..2;
TCastleBehaviorClass = class of TCastleBehavior;
T3DCoord = 0..2;
T3DCoords = set of T3DCoord;
TCollisionEvent = procedure (const CollisionDetails: TPhysicsCollisionDetails) of object;
TOnCollision = TCollisionEvent deprecated 'use TCollisionEvent';
TRigidBodyList = specialize TList<TRigidBody>;
TSceneManagerWorld = TCastleAbstractRootTransform deprecated 'use TCastleRootTransform';

Constants

rfOffScreen = rfRenderedTexture deprecated 'use rfRenderedTexture';

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. }
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.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;
 
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

 
function StrToOrientationType(const S: String): TOrientationType;
 

Types

TCastleTransformClass = class of TCastleTransform;
 
TRenderFromViewFunction = procedure (const RenderingCamera: TRenderingCamera) of object;
 
TVisibleChange = (...);

Describe what visible thing changed for TCastleTransform.VisibleChangeHere.

Values
  • vcVisibleGeometry: Visible geometry (actual 3D shape) changed. It's not used when only light conditions, materials, textures and such changed.

    In practice, this means that the depth buffer from some point in space changed. Which means that shadow maps should be regenerated.

  • vcVisibleNonGeometry: Something visible, but not the geometry shape, changes. For example, material or texture on a visible surface changed.
TVisibleChanges = set of TVisibleChange;
 
TVisibleChangeEvent = procedure (const Sender: TCastleTransform; const Changes: TVisibleChanges) of object;
 
TPrepareResourcesOption = (...);

Various things that TCastleTransform.PrepareResources may prepare.

Values
  • prRenderSelf: Prepare resources for rendering *this* scene (on which TCastleTransform.PrepareResources is called).
  • prRenderClones: Prepare resources for rendering clones of the scene. E.g. textures, which are shared by clones using the cache.
  • prBackground
  • prBoundingBox
  • prShadowVolume
  • prSpatial: Prepare octrees (determined by things like TCastleSceneCore.Spatial).
  • prScreenEffects
TPrepareResourcesOptions = set of TPrepareResourcesOption;
 
PRayCollisionNode = ˆTRayCollisionNode;
 
PCollisionDetailsItem = ˆTCollisionDetailsItem;
 
TRemoveType = (...);
 
Values
  • rtNone
  • rtRemove
  • rtRemoveAndFree
TOrientationType = (...);

Orientation of the model is 3D world, determining where is the conceptual "up" direction of the model, and where is it facing. Used by the TCastleTransform.Orientation and TCastleTransform.DefaultOrientation.

Values
  • otUpYDirectionMinusZ: Orientation sensible for models oriented around Y axis, using default export from Blender to X3D.

    Gravity pulls in -Y and GravityUp vector is +Y. Transformation makes -Z and +Y match (respectively) Direction and Up.

    This matches default direction/up of OpenGL and VRML/X3D cameras.

    For example, using this value for TCastleTransform.Orientation (or even TCastleTransform.DefaultOrientation) is sensible if you use default Blender X3D exporter, and you let the exporter to make a default transformation (to make +Z up into +Y up). This is the default setting. Then you can follow the standard Blender view names ("front", "top" and such) when modelling, and Blender tools like "X-axis mirror" will work best.

  • otUpYDirectionZ: Orientation sensible for models oriented around Y axis, using default export from Blender to glTF or Wavefront OBJ. This matches glTF specification that explicitly says "The front of a glTF asset faces +Z".

    Gravity pulls in -Y and GravityUp vector is +Y. Transformation makes +Z and +Y match (respectively) Direction and Up.

    This does not match default direction/up of OpenGL and VRML/X3D cameras. When viewed from the default direction/up of OpenGL and VRML/X3D cameras, you will see the front of the model, which means that the model's direction is the opposite of the camera direction.

    For example, using this value for TCastleTransform.Orientation (or even TCastleTransform.DefaultOrientation) is sensible if you use default Blender glTF or OBJ exporter, and you let the exporter to make a default transformation (to make +Z up into +Y up). This is the default setting. Then you can follow the standard Blender view names ("front", "top" and such) when modelling, and Blender tools like "X-axis mirror" will work best.

  • otUpZDirectionMinusY: Orientation sensible for models oriented around Z axis. Transformation makes -Y and +Z match (respectively) Direction and Up.

    Using this value for TCastleTransform.Orientation (or even TCastleTransform.DefaultOrientation) is sensible if you export your models from Blender without transforming them during export. Note that this is not the default Blender X3D exporter behavior. But you can configure the exporter to work like this (not transform), and then you can follow the standard Blender view names ("front", "top" and such) when modelling.

  • otUpZDirectionX:

    Warning: this symbol is deprecated.

    Up in +Z (like otUpZDirectionMinusY) and direction in +X. Should not be used in new models.
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).

TCastleBehaviorClass = class of TCastleBehavior;

TCastleBehavior.

T3DCoord = 0..2;
 
T3DCoords = set of T3DCoord;
 
TCollisionEvent = procedure (const CollisionDetails: TPhysicsCollisionDetails) of object;
 
TOnCollision = TCollisionEvent deprecated 'use TCollisionEvent';

Warning: this symbol is deprecated: use TCollisionEvent

 
TRigidBodyList = specialize TList<TRigidBody>;
 
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.

—————————————————————————-

Constants

rfOffScreen = rfRenderedTexture deprecated 'use rfRenderedTexture';

Warning: this symbol is deprecated: use rfRenderedTexture

 

Generated by PasDoc 0.16.0.