Class TShapeTreeTransform

Unit

Declaration

type TShapeTreeTransform = class(TShapeTreeGroup)

Description

Node of the TShapeTree transforming it's children. Use this to handle X3D TTransformNode and similar nodes (which define TTransformFunctionality).

Source: scene/castleshapes.pas (line 920).

Hierarchy

Show Additional Members:

Overview

Fields

Public TransformNeedsUpdate: Boolean;

Methods

Public constructor Create(const AParentScene: TX3DEventsEngine);
Public destructor Destroy; override;
Public function MaxShapesCount: Integer;
Public procedure Traverse(const Func: TShapeTraverseFunc; const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false);
Public function TraverseList( const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false): TShapeList;
Public function ShapesCount(const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false): Cardinal;
Public function FindGeometryNodeName(const GeometryNodeName: string; OnlyActive: boolean = false): TShape;
Public function FindShapeWithParentNamed(const ParentNodeName: string; OnlyActive: boolean = false): TShape;
Public function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; virtual;
Public function DebugInfo(const Indent: string = ''): string; virtual;
Public function DebugInfoWithoutChildren: String; virtual;
Public procedure AssociateNode(const Node: TX3DNode);
Public procedure UnAssociateNode(const Node: TX3DNode);
Public class function AssociatedShape(const Node: TX3DNode; const Index: Integer): TShapeTree; static;
Public class function AssociatedShapesCount(const Node: TX3DNode): Integer; static;
Public constructor Create(const AParentScene: TX3DEventsEngine);
Public destructor Destroy; override;
Public function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; override;
Public function DebugInfo(const Indent: string = ''): string; override;
Public constructor Create(const AParentScene: TX3DEventsEngine);
Public destructor Destroy; override;
Public procedure FastTransformUpdate(var AnythingChanged: Boolean); virtual;
Public function DebugInfoWithoutChildren: String; override;
Public function TransformNode: TX3DNode;

Properties

Public property ParentScene: TX3DEventsEngine read FParentScene write FParentScene;
Public property Depth: Cardinal read FDepth;
Public property Children: TShapeTreeList read FChildren;
Public property TransformFunctionality: TTransformFunctionality read FTransformFunctionality write SetTransformFunctionality;
Public property TransformState: TX3DGraphTraverseState read FTransformState;

Description

Fields

Public TransformNeedsUpdate: Boolean;

Do we need call to FastTransformUpdateCore to recalculate our transformation (in TransformState.Transformation).

Source: scene/castleshapes.pas (line 931).

Methods

Public constructor Create(const AParentScene: TX3DEventsEngine);

This item has no description.

Source: scene/castleshapes.pas (line 237).

Public destructor Destroy; override;

This item has no description.

Source: scene/castleshapes.pas (line 238).

Public function MaxShapesCount: Integer;

Maximum value of ShapesCount. This is cached, so it's usually instant, in contrast to ShapesCount.

Source: scene/castleshapes.pas (line 242).

Public procedure Traverse(const Func: TShapeTraverseFunc; const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false);

Traverse shapes inside. There are a few alternative ways to do this:

- Use this method, and have a callback called for each TShape.

- Use TraverseList, and have a list of TShape.

- Use TShapeTreeIterator.Create, that has it's own GetNext / Current methods to enumerate. This is no longer advised – using TraverseList is simpler and equally fast.

- Use TShapeList.Create(Tree, OnlyActive, OnlyVisible, OnlyCollidable) overload. This is no longer advised – using TraverseList is simpler and faster.

Source: scene/castleshapes.pas (line 266).

Public function TraverseList( const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false): TShapeList;

Return TShapeList containing the traversed shapes, just like Traverse. Caller should never free the resulting list, it is owned by this TShapeTree instance.

Source: scene/castleshapes.pas (line 273).

Public function ShapesCount(const OnlyActive: boolean; const OnlyVisible: boolean = false; const OnlyCollidable: boolean = false): Cardinal;

How many shapes would be enumerated by Traverse.

Source: scene/castleshapes.pas (line 279).

Public function FindGeometryNodeName(const GeometryNodeName: string; OnlyActive: boolean = false): TShape;

Look for shape with Geometry.X3DName = GeometryNodeName. Returns Nil if not found.

Source: scene/castleshapes.pas (line 285).

Public function FindShapeWithParentNamed(const ParentNodeName: string; OnlyActive: boolean = false): TShape;

Look for shape with Geometry that has a parent named ParentNodeName. Parent is searched by Geometry.TryFindParentNodeByName. Returns Nil if not found.

Source: scene/castleshapes.pas (line 291).

Public function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; virtual;

Enumerate all single texture nodes (possibly) used by the shapes (TShape) in this tree. This looks into all shapes (not only active, so e.g. it looks into all Switch/LOD children, not only the chosen one). This checks all possible ways how a texture may be used by a shape, so it looks at material fields, shaders (ComposedShader, CommonSurfaceShader) and more.

If Enumerate callbacks returns non-nil for some texture, it should return the given value immediately, and stop further processing.

Descendants: Implementation in this class does nothing, assuming this tree doesn't have any TShape that use any texture. Override it in descendants that contain TShape.

Calling inherited is not necessary.

Source: scene/castleshapes.pas (line 310).

Public function DebugInfo(const Indent: string = ''): string; virtual;

Describe the shapes tree, recursively (with children), multi-line (ends with newline too).

Source: scene/castleshapes.pas (line 314).

Public function DebugInfoWithoutChildren: String; virtual;

Describe this shape, not recursively.

Source: scene/castleshapes.pas (line 317).

Public procedure AssociateNode(const Node: TX3DNode);

Using the TX3DNode.InternalSceneShape field, you can associate X3D node with a number of TShapeTree instances. This allows to map X3D node -> TShapeTree instances instantly (without e.g. searching the shapes tree for it), which is great to do some operations very quickly.

Right now: - TShapeTreeTransform is associated with node implementing TTransformFunctionality (like TTransformNode, TBillboardNode, TX3DRootNode).

- TShape is associated with TShapeNode, TAppearanceNode, TAbstractGeometryNode, TCoordinateNode (anything that can be inside TAbstractGeometryNode.CoordField), TNormalNode (anything that can be inside TAbstractGeometryNode.NormalField), TTangentNode (anything that can be inside TAbstractGeometryNode.TangentField), TColorNode, TColorRGBANode (anything that can be inside TAbstractGeometryNode.ColorField), TAbstractMaterialNode (anything that can be in TAppearanceNode.Material), TTextureCoordinateNode and other stuff that can be inside TAbstractGeometryNode.InternalTexCoord, TClipPlaneNode .

Note that UnAssociateNode should only be called on nodes with which we are associated. Trying to call UnAssociateNode on a node on which we didn't call AssociateNode will have undefined results (for speed).

It is valid to associate X3D node with TShapeTree multiple times, but it must be unassociated the same number of times.

Parameters
Node
The node with possibly associated shapes. Never Nil.

Source: scene/castleshapes.pas (line 351).

Public procedure UnAssociateNode(const Node: TX3DNode);

This item has no description.

Source: scene/castleshapes.pas (line 352).

Public class function AssociatedShape(const Node: TX3DNode; const Index: Integer): TShapeTree; static;

This item has no description.

Source: scene/castleshapes.pas (line 353).

Public class function AssociatedShapesCount(const Node: TX3DNode): Integer; static;

This item has no description.

Source: scene/castleshapes.pas (line 354).

Public constructor Create(const AParentScene: TX3DEventsEngine);

This item has no description.

Source: scene/castleshapes.pas (line 866).

Public destructor Destroy; override;

This item has no description.

Source: scene/castleshapes.pas (line 867).

Public function EnumerateTextures(const Enumerate: TEnumerateShapeTexturesFunction): Pointer; override;

This item has no description. Showing description inherited from TShapeTree.EnumerateTextures.

Enumerate all single texture nodes (possibly) used by the shapes (TShape) in this tree. This looks into all shapes (not only active, so e.g. it looks into all Switch/LOD children, not only the chosen one). This checks all possible ways how a texture may be used by a shape, so it looks at material fields, shaders (ComposedShader, CommonSurfaceShader) and more.

If Enumerate callbacks returns non-nil for some texture, it should return the given value immediately, and stop further processing.

Descendants: Implementation in this class does nothing, assuming this tree doesn't have any TShape that use any texture. Override it in descendants that contain TShape.

Calling inherited is not necessary.

Source: scene/castleshapes.pas (line 871).

Public function DebugInfo(const Indent: string = ''): string; override;

This item has no description. Showing description inherited from TShapeTree.DebugInfo.

Describe the shapes tree, recursively (with children), multi-line (ends with newline too).

Source: scene/castleshapes.pas (line 888).

Public constructor Create(const AParentScene: TX3DEventsEngine);

This item has no description.

Source: scene/castleshapes.pas (line 933).

Public destructor Destroy; override;

This item has no description.

Source: scene/castleshapes.pas (line 934).

Public procedure FastTransformUpdate(var AnythingChanged: Boolean); virtual;

Process transformation changes here and in child, if only TransformNeedsUpdate = true.

This calls FastTransformUpdateCore if update is really necessary, which in turn will make real update, call FastTransformUpdateCore on all children, and set TransformNeedsUpdate = false.

In effect, calling this may set TransformNeedsUpdate to false both on this instance, and on some children.

This makes updating transformation hierarchy, from the instances with smallest Depth, and looking only at shapes with possibly TransformNeedsUpdate=true (stored in TransformationDirty by TCastleSceneCore) optimal:

- We only enter subtrees with TransformNeedsUpdate=true, no need to process whole Shapes tree (esp. important if only a small subset of the transformations changed, e.g. we changed TTransformNode of one object in a model with 10000 objects).

- We do not process the same subtree multiple times. This is especially important for typical skeletons (glTF Skin, H-Anim HAnimHumanoid, a regular Transform hierarchy with rigid objects, Spine JSON skeletons...) where usually every frame, many joints change transformation. In this case, FastTransformUpdate on smallest depth will do the actual work – it will be the skeleton root. FastTransformUpdate on other depths will be usually ignored (if you only have this one skeleton in entire model), because they've been already updated.

Source: scene/castleshapes.pas (line 967).

Public function DebugInfoWithoutChildren: String; override;

This item has no description. Showing description inherited from TShapeTree.DebugInfoWithoutChildren.

Describe this shape, not recursively.

Source: scene/castleshapes.pas (line 969).

Public function TransformNode: TX3DNode;

This item has no description.

Source: scene/castleshapes.pas (line 974).

Properties

Public property ParentScene: TX3DEventsEngine read FParentScene write FParentScene;

Parent TCastleScene instance.

This cannot be declared here as TCastleScene or TCastleSceneCore (this would create circular unit dependency), but it always is TCastleScene.

May be Nil (used by shapes created for batching, that don't belong to any scene).

Source: scene/castleshapes.pas (line 252).

Public property Depth: Cardinal read FDepth;

Depth in the shapes tree. Root at TCastleSceneCore.Shapes starts with Depth = 0. Automatically set when you insert this TShapeTree as child of another.

Source: scene/castleshapes.pas (line 359).

Public property Children: TShapeTreeList read FChildren;

This item has no description.

Source: scene/castleshapes.pas (line 869).

Public property TransformFunctionality: TTransformFunctionality read FTransformFunctionality write SetTransformFunctionality;

This item has no description.

Source: scene/castleshapes.pas (line 971).

Public property TransformState: TX3DGraphTraverseState read FTransformState;

State right before traversing the TransformNode. Owned by this TShapeTreeTransform instance. You should assign to it when you set TransformNode.

The TransformState.Transformation contains the parent transformation, before the effect of the node in TransformNode is applied.

Source: scene/castleshapes.pas (line 982).


Generated by PasDoc 0.17.0.snapshot.