Castle Game Engine: CastleBoxes

# Unit CastleBoxes
Description | Uses | Classes, Interfaces, Objects and Records | Functions and Procedures | Types | Constants | Variables
## Description Axis-aligned 3D boxes (TBox3D). ## Uses CastleVectors SysUtils CastleUtils CastleGenericLists CastleTriangles ## Overview ### Classes, Interfaces, Objects and Records
Name | Description
--- | ---
Class `EBox3DEmpty` |
Object `TBox3D` | Axis-aligned box.
### Functions and Procedures
`function Box3D(const p0, p1: TVector3Single): TBox3D;`
`function Box3DAroundPoint(const Pt: TVector3Single; Size: Single): TBox3D;`
`function Box3DAroundPoint(const Pt: TVector3Single; Size: TVector3Single): TBox3D;`
`function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal): TBox3D; overload;`
`function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4Single): TBox3D; overload;`
`function CalculateBoundingBox(Verts: TVector3SingleList): TBox3D; overload;`
`function CalculateBoundingBox(Verts: TVector3SingleList; const Transform: TMatrix4Single): TBox3D; overload;`
`function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3D; overload;`
`function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc): TBox3D; overload;`
`function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4Single): TBox3D; overload;`
`function TriangleBoundingBox(const T: TTriangle3Single): TBox3D;`
`function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3Single; const Plane: TVector4Single): boolean; overload;`
`function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3Double; const Plane: TVector4Double): boolean; overload;`
`function BoundingBox3DFromSphere(const Center: TVector3Single; const Radius: Single): TBox3D;`
`operator + (const Box1, Box2: TBox3D): TBox3D;`
`operator + (const B: TBox3D; const V: TVector3Single): TBox3D;`
`operator + (const V: TVector3Single; const B: TBox3D): TBox3D;`
### Types
`TGetIndexFromIndexNumFunc = function (indexNum: integer): integer of object;`
`TPlaneCollision = (...);`
`TBox3DBool = array [boolean] of TVector3Single;`
`PBox3D = ˆTBox3D;`
`TBox3DList = specialize TGenericStructList<TBox3D>;`
### Constants
`EmptyBox3D: TBox3D = (Data: ((0, 0, 0), (-1, -1, -1)));`
### Variables
`Box3DPlaneCollisionEqualityEpsilon: Double = 1e-5;`
## Description ### Functions and Procedures
`function Box3D(const p0, p1: TVector3Single): TBox3D;`
Various comfortable functions to construct TBox3D value.
`function Box3DAroundPoint(const Pt: TVector3Single; Size: Single): TBox3D;`
`function Box3DAroundPoint(const Pt: TVector3Single; Size: TVector3Single): TBox3D;`
`function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal): TBox3D; overload;`
Calculate bounding box of a set of 3D points. This calculates the smallest possible box enclosing all given points. For VertsCount = 0 this returns EmptyBox3D. Overloaded version with Transform parameter transforms each point by given matrix. Overloaded version with GetVertex as a function uses GetVertex to query for indexes from [0 .. VertsCount - 1] range. As usual, VertsStride = 0 means VertsStride = SizeOf(TVector3Single).
`function CalculateBoundingBox( Verts: PVector3Single; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4Single): TBox3D; overload;`
`function CalculateBoundingBox(Verts: TVector3SingleList): TBox3D; overload;`
`function CalculateBoundingBox(Verts: TVector3SingleList; const Transform: TMatrix4Single): TBox3D; overload;`
`function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3D; overload;`
`function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc): TBox3D; overload;`
Calculate bounding box of a set of indexed 3D points. This is much like CalculateBoundingBox, except there are two functions: For each number in [0 .. VertsIndicesCount - 1] range, GetVertIndex returns an index. If this index is >= 0 then it's used to query GetVertex function to get actual vertex position. Indexes < 0 are ignored, this is sometimes comfortable. E.g. for X3D models, you often have a list of indexes with -1 in between marking end of faces. Returns smallest box enclosing all vertexes. Overloaded version with Transform parameter transforms each point by given matrix.
`function CalculateBoundingBoxFromIndices( GetVertIndex: TGetIndexFromIndexNumFunc; VertsIndicesCount: integer; GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4Single): TBox3D; overload;`
`function TriangleBoundingBox(const T: TTriangle3Single): TBox3D;`
`function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3Single; const Plane: TVector4Single): boolean; overload;`
Tests for collision between box3d centered around (0, 0, 0) and a plane. Note that you can't express empty box3d here: all BoxHalfSize items must be >= 0. The case when size = 0 is considered like infintely small box in some dimension (e.g. if all three sizes are = 0 then the box becomes a point).
`function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3Double; const Plane: TVector4Double): boolean; overload;`
`function BoundingBox3DFromSphere(const Center: TVector3Single; const Radius: Single): TBox3D;`
Smallest possible box enclosing a sphere with Center, Radius.
`operator + (const Box1, Box2: TBox3D): TBox3D;`
`operator + (const B: TBox3D; const V: TVector3Single): TBox3D;`
`operator + (const V: TVector3Single; const B: TBox3D): TBox3D;`
### Types
`TGetIndexFromIndexNumFunc = function (indexNum: integer): integer of object;`
`TPlaneCollision = (...);`
State of collision between a plane and some other object. pcNone occurs only when the "other object" is empty (TBox3D.IsEmpty, in case of box). Other values mean that the other object is not empty. pcOutside means that the whole object is on the side of the plane pointed by plane direction (normal) vector. More formally, every point P inserted into the plane equation will yield (P*PlaneNormal + PlaneD) > 0. pcInside is the reverse of pcOutside: the other object is on the side of plane pointed by inverted plane normal. Every point inserted into plane equation will yield < 0. pcIntersecting is, well, the remaining case. It means that there's for sure some point P of other object that, when inserted into plane equation, will yield = 0. ###### Values pcIntersecting: pcOutside: pcInside: pcNone:
`TBox3DBool = array [boolean] of TVector3Single;`
`PBox3D = ˆTBox3D;`
`TBox3DList = specialize TGenericStructList<TBox3D>;`
### Constants
`EmptyBox3D: TBox3D = (Data: ((0, 0, 0), (-1, -1, -1)));`
Special TBox3D value meaning "bounding box is empty". This is different than just bounding box with zero sizes, as bounding box with zero sizes still has some position. Empty bounding box doesn't contain any portion of 3D space.
### Variables
`Box3DPlaneCollisionEqualityEpsilon: Double = 1e-5;`
Special equality epsilon used by IsCenteredBox3DPlaneCollision. For implementation reasons, they always use Double precision (even when called with arguments with Single precision), and still have to use epsilon slightly larger than usual CastleVectors.DoubleEqualityEpsilon.
Generated by PasDoc 0.13.0 on 2015-06-15 04:43:08