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

TShadowSampling = (...);
TShapeSpatialStructure = (...);
TShapeSpatialStructures = set of TShapeSpatialStructure;
TShapeTraverseFunc = procedure (Shape: TShape) is nested;
TEnumerateShapeTexturesFunction = function (Shape: TShape; Texture: TAbstractTextureNode): Pointer of object;
TTestShapeVisibility = function (Shape: TShape): boolean of object;
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

ShadowSamplingNames: array [TShadowSampling] of string = ( 'Simple', 'PCF 4', 'PCF 4 Bilinear', 'PCF 16', 'Variance Shadow Maps (Experimental)' );
DefaultShadowSampling = ssPCF16;
DefLocalTriangleOctreeMaxDepth = 10;
DefLocalTriangleOctreeLeafCapacity = 32;
DefLocalTriangleOctreeLimits: TOctreeLimits = ( MaxDepth: DefLocalTriangleOctreeMaxDepth; LeafCapacity: DefLocalTriangleOctreeLeafCapacity );

Variables

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

Description

Types

TShadowSampling = (...);
 
Values
  • ssSimple
  • ssPCF4: Percentage Closer Filtering improve shadow maps look, by sampling the depth map a couple of times. They also make shadow more blurry (increase shadow map size to counteract this), and a little slower. They may also introduce new artifacts (due to bad interaction with the "polygon offset" of shadow map).
  • ssPCF4Bilinear
  • ssPCF16
  • ssVarianceShadowMaps: Variance Shadow Maps, see http://www.punkuser.net/vsm/ . This may generally produce superior results, as shadow maps can be then filtered like normal textures (bilinear, mipmaps, anisotropic filtering). So shadows look much nicer from very close and very far distances. However, this requires new GPU, and may cause artifacts on some scenes.
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 (Shape: TShape) is nested;
 
TEnumerateShapeTexturesFunction = function (Shape: TShape; Texture: TAbstractTextureNode): Pointer of object;
 
TTestShapeVisibility = function (Shape: TShape): boolean of object;
 
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.GeometryParentNodeName, TShape.GeometryGrandParentNodeName, TShape.GeometryGrandGrandParentNodeName.

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 TGameSceneManager.LoadLevel 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

ShadowSamplingNames: array [TShadowSampling] of string = ( 'Simple', 'PCF 4', 'PCF 4 Bilinear', 'PCF 16', 'Variance Shadow Maps (Experimental)' );
 
DefaultShadowSampling = ssPCF16;
 
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 the shape octree to be replaced by it's approximation.

LogShapes: boolean = false;

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

Meaningful only if you initialized log (see CastleLog unit) by InitializeLog first.

PlaceholderNames: TPlaceholderNames;
 

Generated by PasDoc 0.15.0.