Castle Game Engine: CastleShapes

# Unit CastleShapes
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description Shape (TShape class) and a simple tree of shapes (TShapeTree class). ## Uses SysUtils Classes CastleVectors Castle3D CastleBoxes X3DNodes CastleClassUtils CastleUtils CastleTriangleOctree CastleFrustum CastleOctree X3DTriangles X3DFields CastleGeometryArrays FGL CastleTriangles CastleMaterialProperties ## Overview ### Classes, Interfaces, Objects and Records
Name | Description
--- | ---
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` |
### Types
`TShapeSpatialStructure = (...);`
`TShapeSpatialStructures = set of TShapeSpatialStructure;`
`TShapeTraverseFunc = procedure (Shape: TShape) is nested;`
`TEnumerateShapeTexturesFunction = procedure (Shape: TShape; Texture: TAbstractTextureNode) of object;`
`TTestShapeVisibility = function (Shape: TShape): boolean of object;`
`TTriangleEvent = procedure (Shape: TObject; const Position: TTriangle3Single; const Normal: TTriangle3Single; const TexCoord: TTriangle4Single; const Face: TFaceIndex) of object;`
`TShapeTreeList = specialize TFPGObjectList<TShapeTree>;`
`TPlaceholderName = function (const Shape: TShape): string;`
`TPlaceholderNames = specialize TFPGMap<string, TPlaceholderName>;`
### 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 (Shape: TShape) is nested;`
`TEnumerateShapeTexturesFunction = procedure (Shape: TShape; Texture: TAbstractTextureNode) of object;`
`TTestShapeVisibility = function (Shape: TShape): boolean of object;`
`TTriangleEvent = procedure (Shape: TObject; const Position: TTriangle3Single; const Normal: TTriangle3Single; const TexCoord: TTriangle4Single; const Face: TFaceIndex) of object;`
Triangle information, called by TShape.LocalTriangulate and such. ###### Parameters Shape A shape containing this triangle. This is always an instance of TShape class, but due to unit dependencies it cannot be declared as such. Normal Normal vectors, for each triangle point. TexCoord Texture coordinates, for each triangle point. Each texture coordinate is a 4D vector, since we may have 3D textures referenced by 4D (homogeneous) coordinates. For normal 2D textures, you can simply take the first 2 components of the vector, and ignore the remaining 2 components. The 3th component is always 0 if was not specified (if model had only 2D texture coords). The 4th component is always 1 if was not specified (if model had only 2D or 3D texture coords). In case of multi-texturing, this describes coordinates of the first texture unit. In case no texture is defined, this is undefined. Face Describes the indexes of this face, for editing / removing it. See TFaceIndex.
`TShapeTreeList = specialize TFPGObjectList<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.NodeName, TShape.Node.NodeName, 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.
`TPlaceholderNames = specialize TFPGMap<string, TPlaceholderName>;`
### 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 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.13.0 on 2015-06-15 04:43:11