Unit CastleShapes

Description

Shape (TShape class) and a simple tree of shapes (TShapeTree class).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Record TTriangleHelper Triangle in a 3D model.
Class TShapeTree Tree of shapes.
Class TShape Shape is a geometry node Geometry instance and it's State.
Class TShapeTreeGroup Internal (non-leaf) node of the TShapeTree.
Class TShapeTreeSwitch Node of the TShapeTree representing an alternative, choosing one (or none) child from it's children list as active.
Class TShapeTreeTransform Node of the TShapeTree transforming it's children.
Class TShapeTreeLOD Node of the TShapeTree representing the LOD (level of detail) alternative.
Class TProximitySensorInstance  
Class TVisibilitySensorInstance  
Class TShapeTreeIterator Iterates over all TShape items that would be enumerated by Tree.Traverse.
Class TShapeList  
Class TPlaceholderNames  

Types

TShapeSpatialStructure = (...);
TShapeSpatialStructures = set of TShapeSpatialStructure;
TShapeTraverseFunc = procedure (const Shape: TShape) of object;
TEnumerateShapeTexturesFunction = function (Shape: TShape; Texture: TAbstractTextureNode): Pointer of object;
TTestShapeVisibility = function (Shape: TShape): boolean of object;
TShapesHash = QWord;
TTriangleEvent = procedure (Shape: TObject; const Position: TTriangle3; const Normal: TTriangle3; const TexCoord: TTriangle4; const Face: TFaceIndex) of object;
TShapeTreeList = specialize TObjectList<TShapeTree>;
TPlaceholderName = function (const Shape: TShape): string;

Constants

DefLocalTriangleOctreeMaxDepth = 10;
DefLocalTriangleOctreeLeafCapacity = 32;
DefLocalTriangleOctreeLimits: TOctreeLimits = ( MaxDepth: DefLocalTriangleOctreeMaxDepth; LeafCapacity: DefLocalTriangleOctreeLeafCapacity );

Variables

DisableAutoDynamicGeometry: Cardinal;
LogShapes: boolean = false;
PlaceholderNames: TPlaceholderNames;

Description

Types

TShapeSpatialStructure = (...);

Possible spatial structure types that may be managed by TShape, see TShape.Spatial.

Values
  • ssTriangles: Create the TShape.OctreeTriangles. This is an octree containing all triangles.
TShapeSpatialStructures = set of TShapeSpatialStructure;
 
TShapeTraverseFunc = procedure (const Shape: TShape) of object;
 
TEnumerateShapeTexturesFunction = function (Shape: TShape; Texture: TAbstractTextureNode): Pointer of object;
 
TTestShapeVisibility = function (Shape: TShape): boolean of object;
 
TShapesHash = QWord;
 
TTriangleEvent = procedure (Shape: TObject; const Position: TTriangle3; const Normal: TTriangle3; const TexCoord: TTriangle4; const Face: TFaceIndex) of object;

Triangle information, called by TShape.LocalTriangulate and such. See the TTriangle fields documentation for the meaning of parameters of this callback.

TShapeTreeList = specialize TObjectList<TShapeTree>;
 
TPlaceholderName = function (const Shape: TShape): string;

Detect the 3D placeholder name set in the external modeler, like 3D object name set in Blender or 3DS Max. Assumes that a specific modeler was used to create and export this 3D model. Each TPlaceholderName function is made to follow the logic of a single modeler, and they are gathered in PlaceholderNames.

Returns empty string if none.

When implementing this, you may find useful the following properties of the shape: TShape.OriginalGeometry.X3DName, TShape.Node.X3DName, TShape.GeometryParentNode.X3DName, TShape.GeometryGrandParentNode.X3DName, TShape.GeometryGrandGrandParentNode.X3DName.

Preferably, the result should be unique, only for this VRML/X3D shape. But in practice it's the responsibility of the modeler and model author to make it true. For example, modelers that allow multiple materials on object (like Blender) must split a single 3D object into many VRML/X3D shapes sometimes. So just don't use shapes with multiple materials if this shape may be meaningful for a placeholder.

This is used only by TLevel.Load placeholders. Ultimately, this should be something that is easy to set when creating a 3D model in given external modeler. Nothing else in our engine depends on a particular modeler strategy for exporting VRML/X3D models.

This should be object name (to allow sharing a single mesh underneath). Except when it's not possible (like for old Blender VRML 1.0 exporter, when only mesh names are stored in VRML/X3D exported files), in which case it can be a mesh name.

Constants

DefLocalTriangleOctreeMaxDepth = 10;
 
DefLocalTriangleOctreeLeafCapacity = 32;

Default octree leaf capacity for TShape.OctreeTriangles.

This is slightly larger than DefTriangleOctreeLeafCapacity, as this octree will usually be used interactively for collision detection, not by ray-tracer. So octree construction speed is somewhat important, and cannot be too large...

DefLocalTriangleOctreeLimits: TOctreeLimits = ( MaxDepth: DefLocalTriangleOctreeMaxDepth; LeafCapacity: DefLocalTriangleOctreeLeafCapacity );
 

Variables

DisableAutoDynamicGeometry: Cardinal;

If nonzero, disables automatic TShape.DynamicGeometry detection on every node modification. This is useful if you do some interactive editing of the shape, but you don't want to mark shape as dynamic.

LogShapes: boolean = false;

Log various information about shapes. This displays quite a lot of non-critical information when opening non-trivial models.

PlaceholderNames: TPlaceholderNames;
 

Generated by PasDoc 0.16.0.