Castle Game EngineIntroduction Units Class Hierarchy Classes, Interfaces, Objects and Records Types Variables Constants Functions and Procedures Identifiers
|
Unit CastleBoxes
Description
Axis-aligned 3D boxes (TBox3D).
Uses
Overview
Classes, Interfaces, Objects and Records
Functions and Procedures
Types
Constants
EmptyBox3D: TBox3D = (Data: ((Data: (0, 0, 0)), (Data: (-1, -1, -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 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 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 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
|
TBlendingSort = (...); |
Various ways to sort the 3D objects, in particular useful to correctly render the partially-transparent objects.
See also
- TSceneRenderingAttributes.BlendingSort
- How to sort the rendered objects using blending (partial transparency).
Values
-
bsNone: Do not sort. Using this for Scene.Attributes.BlendingSort is fastest, but will cause artifacts if multiple partially-transparent objects may be visible on top of each other.
-
bs2D: Sort objects by their Z coordinate. Using this for Scene.Attributes.BlendingSort is very useful for 2D worlds, with flat 2D objects that have zero (or near-zero) size in the Z axis, and they are moved in the Z axis to specify which is on top for another.
More precisely, we take the minimum bounding box Z coordinate of two objects. (We don't bother calculating the middle Z coordinate, as we assume that the bounding box is infinitely small along the Z axis.) The one with larger Z coordinate is considered to be closer, this is consistent with the right-handed coordinate system.
Note that the actual camera position doesn't matter for this sorting. So the 2D object will look OK, even if viewed from an angle, even if viewed from the other side.
-
bs3D: Sort objects by the (3D) distance to the camera. Using this for Scene.Attributes.BlendingSort is the best sorting method for 3D scenes with many partially-transparent objects.
The distance is measured from the middle of the bounding box to the camera posotion.
|
TBox3DBool = array [boolean] of TVector3; |
|
Constants
EmptyBox3D: TBox3D = (Data: ((Data: (0, 0, 0)), (Data: (-1, -1, -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.15.0.
|