Unit CastleBoxes

Description

Axis-aligned 3D boxes (TBox3D).

Uses

Overview

Classes, Interfaces, Objects and Records

Name Description
Class EBox3DEmpty  
Record TBox3D Axis-aligned box.

Functions and Procedures

function Box3D(const p0, p1: TVector3): TBox3D;
function Box3DAroundPoint(const Pt: TVector3; Size: Single): TBox3D; overload;
function Box3DAroundPoint(const Pt: TVector3; Size: TVector3): TBox3D; overload;
function CalculateBoundingBox( Verts: PVector3; VertsCount: Cardinal; VertsStride: Cardinal): TBox3D; overload;
function CalculateBoundingBox( Verts: PVector3; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4): TBox3D; overload;
function CalculateBoundingBox(Verts: TVector3List): TBox3D; overload;
function CalculateBoundingBox(Verts: TVector3List; const Transform: TMatrix4): TBox3D; overload;
function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3D; overload;
function CalculateBoundingBoxFromIndices( const GetVertIndex: TGetIndexFromIndexNumFunc; const VertsIndicesCount: integer; const GetVertex: TGetVertexFromIndexFunc): TBox3D; overload;
function CalculateBoundingBoxFromIndices( const GetVertIndex: TGetIndexFromIndexNumFunc; const VertsIndicesCount: integer; const GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4): TBox3D; overload;
function TriangleBoundingBox(const T: TTriangle3): TBox3D;
function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3; const Plane: TVector4): boolean;
function BoundingBox3DFromSphere(const Center: TVector3; const Radius: Single): TBox3D;

Types

TGetIndexFromIndexNumFunc = function (indexNum: integer): integer of object;
TPlaneCollision = (...);
TBoxCorners = array [0..7] of TVector3;
TBox3DBool = array [boolean] of TVector3;
PBox3D = ˆTBox3D;
TBox3DList = specialize TStructList<TBox3D>;
TBox3DEvent = function: TBox3D of object;

Constants

EmptyBox3D: TBox3D = (Data: ((X: 0; Y: 0; Z: 0), (X: -1; Y: -1; Z: -1))) deprecated 'use TBox3D.Empty';

Description

Functions and Procedures

function Box3D(const p0, p1: TVector3): TBox3D;

Construct TBox3D value from a minimum and maximum 3D point.

function Box3DAroundPoint(const Pt: TVector3; Size: Single): TBox3D; overload;

Construct TBox3D value from a center and size. When any Size component is < 0, we return an empty box (TBox3D.Empty). This is consistent with X3D bboxCenter/Size definition e.g. at X3D Group node, see http://www.web3d.org/documents/specifications/19775-1/V3.2/Part01/components/group.html#Group

function Box3DAroundPoint(const Pt: TVector3; Size: TVector3): TBox3D; overload;
 
function CalculateBoundingBox( Verts: PVector3; 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 TBox3D.Empty.

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(TVector3).

function CalculateBoundingBox( Verts: PVector3; VertsCount: Cardinal; VertsStride: Cardinal; const Transform: TMatrix4): TBox3D; overload;
 
function CalculateBoundingBox(Verts: TVector3List): TBox3D; overload;
 
function CalculateBoundingBox(Verts: TVector3List; const Transform: TMatrix4): TBox3D; overload;
 
function CalculateBoundingBox( GetVertex: TGetVertexFromIndexFunc; VertsCount: integer): TBox3D; overload;
 
function CalculateBoundingBoxFromIndices( const GetVertIndex: TGetIndexFromIndexNumFunc; const VertsIndicesCount: integer; const 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( const GetVertIndex: TGetIndexFromIndexNumFunc; const VertsIndicesCount: integer; const GetVertex: TGetVertexFromIndexFunc; const Transform: TMatrix4): TBox3D; overload;
 
function TriangleBoundingBox(const T: TTriangle3): TBox3D;
 
function IsCenteredBox3DPlaneCollision( const BoxHalfSize: TVector3; const Plane: TVector4): boolean;

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 BoundingBox3DFromSphere(const Center: TVector3; const Radius: Single): TBox3D;

Smallest possible box enclosing a sphere with Center, Radius.

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
TBoxCorners = array [0..7] of TVector3;
 
TBox3DBool = array [boolean] of TVector3;
 
PBox3D = ˆTBox3D;
 
TBox3DList = specialize TStructList<TBox3D>;
 
TBox3DEvent = function: TBox3D of object;
 

Constants

EmptyBox3D: TBox3D = (Data: ((X: 0; Y: 0; Z: 0), (X: -1; Y: -1; Z: -1))) deprecated 'use TBox3D.Empty';

Warning: this symbol is deprecated: use TBox3D.Empty

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.


Generated by PasDoc 0.16.0.