Support Forum       G3D Web Page     
Public Member Functions | Static Public Member Functions | Friends | List of all members
G3D::Box Class Reference


An arbitrary (oriented) 3D box, useful as a bounding box. More...

Public Member Functions

 Box ()
 
 Box (const Any &a)
 
 Box (const Vector3 &min, const Vector3 &max)
 Constructs a box from two opposite corners. More...
 
 Box (const Vector3 &osMin, const Vector3 &osMax, const CoordinateFrame &frame)
 
 Box (class BinaryInput &b)
 
 Box (const class AABox &b)
 
 Box (const Point3 &p)
 
float area () const
 
Vector3 axis (int a) const
 
Unit length. More...
 
Vector3 center () const
 Returns the centroid of the box. More...
 
bool contains (const Vector3 &point) const
 
Vector3 corner (int i) const
 
      

    2--------3
   / :      /|
  /  :     / |
 6--------7  |
 |   :    |  |
 |   0....|..1
 | /      | /
 |/       |/
 4--------5

  y  
  ^ 
  |
  |-->x
z/


    
More...
 
bool culledBy (const Array< Plane > &plane, int32 &cullingPlaneIndex, const uint32 testMask, uint32 &childMask) const
 See AABox::culledBy. More...
 
bool culledBy (const Array< Plane > &plane, int32 &cullingPlaneIndex=dummy, const uint32 testMask=-1) const
 
Conservative culling test that does not produce a mask for children. More...
 
bool culledBy (const Frustum &frustum) const
 Conservative culling test. More...
 
void deserialize (class BinaryInput &b)
 
float extent (int a) const
 
Distance from corner(0) to the next corner along the box's local axis a. More...
 
Vector3 extent () const
 
void getBounds (class AABox &) const
 
void getFaceCorners (int f, Vector3 &v0, Vector3 &v1, Vector3 &v2, Vector3 &v3) const
 
Returns the four corners of a face (0 <= f < 6). More...
 
void getFacePlane (int f, Plane &plane) const
 
void getLocalFrame (CoordinateFrame &frame) const
 
void getRandomSurfacePoint (Point3 &P, Vector3 &N=Vector3::ignore, Random &rnd=Random::common()) const
 
size_t hashCode () const
 
bool isFinite () const
 
CoordinateFrame localFrame () const
 
Returns the object to world transformation for this box, where the origin is the center of the box. More...
 
Box operator* (float f) const
 
bool operator== (const Box &other) const
 
Point3 randomInteriorPoint (Random &rnd=Random::common()) const
 
Uniformly distributed on the interior (includes surface) More...
 
void serialize (class BinaryOutput &b) const
 
Any toAny () const
 
float volume () const
 

Static Public Member Functions

static Box inf ()
 

Friends

class CoordinateFrame
 

Detailed Description


An arbitrary (oriented) 3D box, useful as a bounding box.

To construct a box from a coordinate frame, center and extent, use the idiom: Box box = cframe.toObjectSpace(Box(center - extent/2, center + extent/2));

Constructor & Destructor Documentation

◆ Box() [1/7]

G3D::Box::Box ( )

◆ Box() [2/7]

G3D::Box::Box ( const Any a)
explicit

◆ Box() [3/7]

G3D::Box::Box ( const Vector3 min,
const Vector3 max 
)

Constructs a box from two opposite corners.

◆ Box() [4/7]

G3D::Box::Box ( const Vector3 osMin,
const Vector3 osMax,
const CoordinateFrame frame 
)

◆ Box() [5/7]

G3D::Box::Box ( class BinaryInput b)

◆ Box() [6/7]

G3D::Box::Box ( const class AABox b)

◆ Box() [7/7]

G3D::Box::Box ( const Point3 p)
explicit

Member Function Documentation

◆ area()

float G3D::Box::area ( ) const

Referenced by G3D::BoxShape::area().

◆ axis()

Vector3 G3D::Box::axis ( int  a) const
inline


Unit length.

◆ center()

Vector3 G3D::Box::center ( ) const
inline

Returns the centroid of the box.

Referenced by G3D::BoxShape::boundingSphere(), and G3D::BoxShape::center().

◆ contains()

bool G3D::Box::contains ( const Vector3 point) const

◆ corner()

Vector3 G3D::Box::corner ( int  i) const

      

    2--------3
   / :      /|
  /  :     / |
 6--------7  |
 |   :    |  |
 |   0....|..1
 | /      | /
 |/       |/
 4--------5

  y  
  ^ 
  |
  |-->x
z/


    

◆ culledBy() [1/3]

bool G3D::Box::culledBy ( const Array< Plane > &  plane,
int32 cullingPlaneIndex,
const uint32  testMask,
uint32 childMask 
) const

See AABox::culledBy.

◆ culledBy() [2/3]

bool G3D::Box::culledBy ( const Array< Plane > &  plane,
int32 cullingPlaneIndex = dummy,
const uint32  testMask = -1 
) const


Conservative culling test that does not produce a mask for children.

◆ culledBy() [3/3]

bool G3D::Box::culledBy ( const Frustum frustum) const

Conservative culling test.

◆ deserialize()

void G3D::Box::deserialize ( class BinaryInput b)

◆ extent() [1/2]

float G3D::Box::extent ( int  a) const
inline


Distance from corner(0) to the next corner along the box's local axis a.

Referenced by G3D::BoxShape::boundingSphere(), and G3D::SVO::voxelSideLength().

◆ extent() [2/2]

Vector3 G3D::Box::extent ( ) const
inline

◆ getBounds()

void G3D::Box::getBounds ( class AABox ) const

◆ getFaceCorners()

void G3D::Box::getFaceCorners ( int  f,
Vector3 v0,
Vector3 v1,
Vector3 v2,
Vector3 v3 
) const


Returns the four corners of a face (0 <= f < 6).

The corners are returned to form a clockwise quad facing outwards.

  +--------+
 / :      /|
/  :     / |

+-----—+ | | : | | | +....|..+ | / | / |/ |/ +-----—+

y
^ | |–>x z/
Faces are in the following order: 0: -Z 1: X 2: Z 3: Y 4: -X 5: -Y

◆ getFacePlane()

void G3D::Box::getFacePlane ( int  f,
Plane plane 
) const

◆ getLocalFrame()

void G3D::Box::getLocalFrame ( CoordinateFrame frame) const
See also
localFrame

◆ getRandomSurfacePoint()

void G3D::Box::getRandomSurfacePoint ( Point3 P,
Vector3 N = Vector3::ignore,
Random rnd = Random::common() 
) const

◆ hashCode()

size_t G3D::Box::hashCode ( ) const

◆ inf()

static Box G3D::Box::inf ( )
static

◆ isFinite()

bool G3D::Box::isFinite ( ) const
inline

◆ localFrame()

CoordinateFrame G3D::Box::localFrame ( ) const


Returns the object to world transformation for this box, where the origin is the center of the box.

localFrame().worldToObject(...) takes objects into the space where the box axes are (1,0,0), (0,1,0), (0,0,1). Note that there is no scaling in this transformation.

◆ operator*()

Box G3D::Box::operator* ( float  f) const

◆ operator==()

bool G3D::Box::operator== ( const Box other) const

◆ randomInteriorPoint()

Point3 G3D::Box::randomInteriorPoint ( Random rnd = Random::common()) const


Uniformly distributed on the interior (includes surface)

Referenced by G3D::BoxShape::randomInteriorPoint().

◆ serialize()

void G3D::Box::serialize ( class BinaryOutput b) const

◆ toAny()

Any G3D::Box::toAny ( ) const

◆ volume()

float G3D::Box::volume ( ) const

Referenced by G3D::BoxShape::volume().

Friends And Related Function Documentation

◆ CoordinateFrame

friend class CoordinateFrame
friend

documentation generated on Wed Nov 24 2021 08:01:53 using doxygen 1.8.15