Support Forum G3D Web Page |
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 |
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));
G3D::Box::Box | ( | ) |
|
explicit |
Constructs a box from two opposite corners.
G3D::Box::Box | ( | const Vector3 & | osMin, |
const Vector3 & | osMax, | ||
const CoordinateFrame & | frame | ||
) |
G3D::Box::Box | ( | class BinaryInput & | b | ) |
G3D::Box::Box | ( | const class AABox & | b | ) |
|
explicit |
float G3D::Box::area | ( | ) | const |
Referenced by G3D::BoxShape::area().
|
inline |
Unit length.
|
inline |
Returns the centroid of the box.
Referenced by G3D::BoxShape::boundingSphere(), and G3D::BoxShape::center().
bool G3D::Box::contains | ( | const Vector3 & | point | ) | const |
Vector3 G3D::Box::corner | ( | int | i | ) | const |
2--------3 / : /| / : / | 6--------7 | | : | | | 0....|..1 | / | / |/ |/ 4--------5 y ^ | |-->x z/
bool G3D::Box::culledBy | ( | const Array< Plane > & | plane, |
int32 & | cullingPlaneIndex, | ||
const uint32 | testMask, | ||
uint32 & | childMask | ||
) | const |
See AABox::culledBy.
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.
bool G3D::Box::culledBy | ( | const Frustum & | frustum | ) | const |
Conservative culling test.
void G3D::Box::deserialize | ( | class BinaryInput & | b | ) |
|
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().
|
inline |
void G3D::Box::getBounds | ( | class AABox & | ) | const |
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
void G3D::Box::getFacePlane | ( | int | f, |
Plane & | plane | ||
) | const |
void G3D::Box::getLocalFrame | ( | CoordinateFrame & | frame | ) | const |
void G3D::Box::getRandomSurfacePoint | ( | Point3 & | P, |
Vector3 & | N = Vector3::ignore , |
||
Random & | rnd = Random::common() |
||
) | const |
Referenced by G3D::BoxShape::getRandomSurfacePoint().
size_t G3D::Box::hashCode | ( | ) | const |
|
static |
|
inline |
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.
Box G3D::Box::operator* | ( | float | f | ) | const |
bool G3D::Box::operator== | ( | const Box & | other | ) | const |
Point3 G3D::Box::randomInteriorPoint | ( | Random & | rnd = Random::common() | ) | const |
Uniformly distributed on the interior (includes surface)
Referenced by G3D::BoxShape::randomInteriorPoint().
void G3D::Box::serialize | ( | class BinaryOutput & | b | ) | const |
Any G3D::Box::toAny | ( | ) | const |
float G3D::Box::volume | ( | ) | const |
Referenced by G3D::BoxShape::volume().
|
friend |