![]() |
Public API Reference |
#include <box.h>
Inheritance diagram for csBox3:
Public Methods | |
float | MinX () const |
Get the minimum X value of the box. More... | |
float | MinY () const |
Get the minimum Y value of the box. More... | |
float | MinZ () const |
Get the minimum Z value of the box. More... | |
float | MaxX () const |
Get the maximum X value of the box. More... | |
float | MaxY () const |
Get the maximum Y value of the box. More... | |
float | MaxZ () const |
Get the maximum Z value of the box. More... | |
float | Min (int idx) const |
Get Min component for 0 (x), 1 (y), or 2 (z). More... | |
float | Max (int idx) const |
Get Max component for 0 (x), 1 (y), or 2 (z). More... | |
const csVector3 & | Min () const |
Get the 3d vector of minimum (x, y, z) values. More... | |
const csVector3 & | Max () const |
Get the 3d vector of maximum (x, y, z) values. More... | |
csVector3 | GetCorner (int corner) const |
Return every corner of this bounding box from 0 to 7. More... | |
void | GetEdgeInfo (int edge, int &v1, int &v2, int &fleft, int &fright) const |
Given an edge index (CS_BOX_EDGE_Xyz_xyz etc.) return the two vertices (index CS_BOX_CORNER_xyz etc.) and left/right faces (CS_BOX_SIDE_x etc.). More... | |
uint8 * | GetFaceEdges (int face) const |
Given a face index (CS_BOX_SIDE_x etc.) return the four edges oriented clockwise around this face (CS_BOX_EDGE_Xyz_xyz etc.). More... | |
csVector3 | GetCenter () const |
Get the center of this box. More... | |
void | SetCenter (const csVector3 &c) |
Set the center of this box. More... | |
void | SetSize (const csVector3 &s) |
Set the size of the box but keep the center intact. More... | |
csBox2 | GetSide (int side) const |
Get a side of this box as a 2D box. More... | |
int | GetVisibleSides (const csVector3 &pos, int *visible_sides) const |
Fill the array (which should be three long at least) with all visible sides (CS_BOX_SIDE_x etc. More... | |
csSegment3 | GetEdge (int edge) const |
Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_Xyz_xyz etc. More... | |
void | GetEdge (int edge, csSegment3 &e) const |
Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_Xyz_xyz etc. More... | |
bool | In (float x, float y, float z) const |
Test if the given coordinate is in this box. More... | |
bool | In (const csVector3 &v) const |
Test if the given coordinate is in this box. More... | |
bool | Overlap (const csBox3 &box) const |
Test if this box overlaps with the given box. More... | |
bool | Contains (const csBox3 &box) const |
Test if this box contains the other box. More... | |
bool | Empty () const |
Test if this box is empty. More... | |
void | StartBoundingBox () |
Initialize this box to empty. More... | |
void | StartBoundingBox (const csVector3 &v) |
Initialize this box to one vertex. More... | |
void | AddBoundingVertex (float x, float y, float z) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertex (const csVector3 &v) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertexSmart (float x, float y, float z) |
Add a new vertex and recalculate the bounding box. More... | |
void | AddBoundingVertexSmart (const csVector3 &v) |
Add a new vertex and recalculate the bounding box. More... | |
csBox3 () | |
Initialize this box to empty. More... | |
csBox3 (const csVector3 &v) | |
Initialize this box with one point. More... | |
csBox3 (const csVector3 &v1, const csVector3 &v2) | |
Initialize this box with two points. More... | |
csBox3 (float x1, float y1, float z1, float x2, float y2, float z2) | |
Initialize this box with the given values. More... | |
void | Set (const csVector3 &bmin, const csVector3 &bmax) |
Sets the bounds of the box with the given values. More... | |
void | Set (float x1, float y1, float z1, float x2, float y2, float z2) |
Sets the bounds of the box with the given values. More... | |
void | SetMin (int idx, float val) |
Set Min component for 0 (x), 1 (y), or 2 (z). More... | |
void | SetMax (int idx, float val) |
Set Max component for 0 (x), 1 (y), or 2 (z). More... | |
bool | AdjacentX (const csBox3 &other) const |
Test if this box is adjacent to the other on the X side. More... | |
bool | AdjacentY (const csBox3 &other) const |
Test if this box is adjacent to the other on the Y side. More... | |
bool | AdjacentZ (const csBox3 &other) const |
Test if this box is adjacent to the other on the Z side. More... | |
int | Adjacent (const csBox3 &other) const |
Test if this box is adjacent to the other one. More... | |
int | CalculatePointSegment (const csVector3 &pos) const |
Assume that 3D space is divided into 27 areas. More... | |
void | GetConvexOutline (const csVector3 &pos, csVector3 *array, int &num_array, bool bVisible=false) const |
Get a convex outline (not a polygon unless projected to 2D) for for this box as seen from the given position. More... | |
bool | Between (const csBox3 &box1, const csBox3 &box2) const |
Test if this box is between two others. More... | |
void | ManhattanDistance (const csBox3 &other, csVector3 &dist) const |
Calculate the minimum manhattan distance between this box and another one. More... | |
float | SquaredOriginDist () const |
Calculate the squared distance between (0,0,0) and the box This routine is extremely efficient. More... | |
float | SquaredOriginMaxDist () const |
Calculate the squared distance between (0,0,0) and the point on the box which is furthest away from (0,0,0). More... | |
bool | ProjectBox (const csTransform &trans, float fov, float sx, float sy, csBox2 &sbox, float &min_z, float &max_z) const |
Project this box to a 2D bounding box given the view point transformation and also the field-of-view and shift values (for perspective projection). More... | |
csBox3 & | operator+= (const csBox3 &box) |
Compute the union of two bounding boxes. More... | |
csBox3 & | operator+= (const csVector3 &point) |
Compute the union of a point with this bounding box. More... | |
csBox3 & | operator *= (const csBox3 &box) |
Compute the intersection of two bounding boxes. More... | |
bool | TestIntersect (const csBox3 &box) const |
Test if the two boxes have an intersection. More... | |
Static Public Methods | |
int | OtherSide (int side) |
Static function to get the 'other' side (i.e. More... | |
Protected Types | |
typedef uint8 | bFace [4] |
Indices of four clock-wise edges (0..23). More... | |
Protected Attributes | |
csVector3 | minbox |
The top-left of this bounding box. More... | |
csVector3 | maxbox |
The bottom-right. More... | |
Static Protected Attributes | |
bEdge | edges [24] |
Index by edge number. More... | |
bFace | faces [6] |
Index by CS_BOX_SIDE_? number. More... | |
Friends | |
csBox3 | operator+ (const csBox3 &box1, const csBox3 &box2) |
Compute the union of two bounding boxes. More... | |
csBox3 | operator+ (const csBox3 &box, const csVector3 &point) |
Compute the union of a bounding box and a point. More... | |
csBox3 | operator * (const csBox3 &box1, const csBox3 &box2) |
Compute the intersection of two bounding boxes. More... | |
bool | operator== (const csBox3 &box1, const csBox3 &box2) |
Tests if two bounding boxes are equal. More... | |
bool | operator!= (const csBox3 &box1, const csBox3 &box2) |
Tests if two bounding boxes are unequal. More... | |
bool | operator< (const csBox3 &box1, const csBox3 &box2) |
Tests if box1 is a subset of box2. More... | |
bool | operator> (const csBox3 &box1, const csBox3 &box2) |
Tests if box1 is a superset of box2. More... | |
bool | operator< (const csVector3 &point, const csBox3 &box) |
Tests if a point is contained in a box. More... |
In order to operate correctly, this bounding box assumes that all values entered or compared against lie within the range (-CS_BOUNDINGBOX_MAXVALUE, CS_BOUNDINGBOX_MAXVALUE). It is not recommended to use points outside of this range.
Definition at line 497 of file box.h.
|
Indices of four clock-wise edges (0..23).
|
|
Initialize this box to empty.
Definition at line 744 of file box.h. References CS_BOUNDINGBOX_MAXVALUE. |
|
Initialize this box with one point.
|
|
Initialize this box with two points.
Definition at line 756 of file box.h. References Empty, and StartBoundingBox. |
|
Initialize this box with the given values.
Definition at line 761 of file box.h. References Empty, and StartBoundingBox. |
|
Add a new vertex and recalculate the bounding box.
Reimplemented in csOBB. Definition at line 702 of file box.h. References AddBoundingVertex, csVector3::x, csVector3::y, and csVector3::z. |
|
Add a new vertex and recalculate the bounding box.
Definition at line 694 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. Referenced by AddBoundingVertex. |
|
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box. Definition at line 724 of file box.h. References AddBoundingVertexSmart, csVector3::x, csVector3::y, and csVector3::z. |
|
Add a new vertex and recalculate the bounding box. This version is a little more optimal. It assumes however that at least one point has been added to the bounding box. Definition at line 712 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. Referenced by AddBoundingVertexSmart. |
|
Test if this box is adjacent to the other one. Return -1 if not adjacent or else any of the CS_BOX_SIDE_x etc. flags to indicate the side of this box that the other box is adjacent with. |
|
Test if this box is adjacent to the other on the X side.
|
|
Test if this box is adjacent to the other on the Y side.
|
|
Test if this box is adjacent to the other on the Z side.
|
|
Test if this box is between two others.
|
|
Assume that 3D space is divided into 27 areas. One is inside the box. The other 26 are rectangular segments around the box. This function will calculate the right segment for a given point and return that. |
|
Test if this box contains the other box.
Definition at line 660 of file box.h. References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z. |
|
Test if this box is empty.
Definition at line 668 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. Referenced by csBox3. |
|
Get the center of this box.
|
|
Get a convex outline (not a polygon unless projected to 2D) for for this box as seen from the given position. The coordinates returned are world space coordinates. Note that you need place for at least six vectors in the array. If you set bVisible true, you will get all visible corners - this could be up to 7. |
|
Return every corner of this bounding box from 0 to 7. This contrasts with Min() and Max() because those are only the min and max corners. Corner 0 = xyz, 1 = xyZ, 2 = xYz, 3 = xYZ, 4 = Xyz, 5 = XyZ, 6 = XYz, 7 = XYZ. Use CS_BOX_CORNER_xyz etc. defines. Reimplemented in csOBB. |
|
Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_Xyz_xyz etc. indices). The returned edge is undefined for any other index. Definition at line 629 of file box.h. References csSegment3::SetEnd, and csSegment3::SetStart. |
|
Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_Xyz_xyz etc. indices). The returned edge is undefined for any other index. |
|
Given an edge index (CS_BOX_EDGE_Xyz_xyz etc.) return the two vertices (index CS_BOX_CORNER_xyz etc.) and left/right faces (CS_BOX_SIDE_x etc.).
|
|
Given a face index (CS_BOX_SIDE_x etc.) return the four edges oriented clockwise around this face (CS_BOX_EDGE_Xyz_xyz etc.).
Definition at line 570 of file box.h. References faces. |
|
Get a side of this box as a 2D box. Use CS_BOX_SIDE_x etc. defines. |
|
Fill the array (which should be three long at least) with all visible sides (CS_BOX_SIDE_x etc. defines) as seen from the given point. Returns the number of visible sides. |
|
Test if the given coordinate is in this box.
Definition at line 645 of file box.h. References In, csVector3::x, csVector3::y, and csVector3::z. |
|
Test if the given coordinate is in this box.
Definition at line 636 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. Referenced by In. |
|
Calculate the minimum manhattan distance between this box and another one.
|
|
Get the 3d vector of maximum (x, y, z) values.
|
|
Get Max component for 0 (x), 1 (y), or 2 (z).
Definition at line 537 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. |
|
Get the maximum X value of the box.
|
|
Get the maximum Y value of the box.
|
|
Get the maximum Z value of the box.
|
|
Get the 3d vector of minimum (x, y, z) values.
|
|
Get Min component for 0 (x), 1 (y), or 2 (z).
Definition at line 534 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. |
|
Get the minimum X value of the box.
|
|
Get the minimum Y value of the box.
|
|
Get the minimum Z value of the box.
|
|
Compute the intersection of two bounding boxes.
|
|
Compute the union of a point with this bounding box.
|
|
Compute the union of two bounding boxes.
|
|
Static function to get the 'other' side (i.e. CS_BOX_SIDE_X to CS_BOX_SIDE_x, ...). |
|
Test if this box overlaps with the given box.
Definition at line 651 of file box.h. References maxbox, minbox, csVector3::x, csVector3::y, and csVector3::z. |
|
Project this box to a 2D bounding box given the view point transformation and also the field-of-view and shift values (for perspective projection). The transform should transform from world to camera space (using Other2This). The minimum and maximum z are also calculated. If the bounding box is behind the camera then the 'sbox' will not be calculated (min_z and max_z are still calculated) and the function will return false. If the camera is inside the transformed box then this function will return true and a very big screen space bounding box is returned. |
|
Sets the bounds of the box with the given values.
Definition at line 773 of file box.h. References StartBoundingBox, csVector3::x, csVector3::y, and csVector3::z. |
|
Sets the bounds of the box with the given values.
|
|
Set the center of this box. This will not change the size of the box but just relocate the center. |
|
Set Max component for 0 (x), 1 (y), or 2 (z).
Definition at line 792 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. |
|
Set Min component for 0 (x), 1 (y), or 2 (z).
Definition at line 784 of file box.h. References csVector3::x, csVector3::y, and csVector3::z. |
|
Set the size of the box but keep the center intact.
|
|
Calculate the squared distance between (0,0,0) and the box This routine is extremely efficient.
|
|
Calculate the squared distance between (0,0,0) and the point on the box which is furthest away from (0,0,0). This routine is extremely efficient. |
|
Initialize this box to one vertex.
|
|
Initialize this box to empty.
Definition at line 677 of file box.h. References CS_BOUNDINGBOX_MAXVALUE, csVector3::x, csVector3::y, and csVector3::z. |
|
Test if the two boxes have an intersection.
|
|
Compute the intersection of two bounding boxes.
|
|
Tests if two bounding boxes are unequal.
|
|
Compute the union of a bounding box and a point.
|
|
Compute the union of two bounding boxes.
|
|
Tests if a point is contained in a box.
|
|
Tests if box1 is a subset of box2.
|
|
Tests if two bounding boxes are equal.
|
|
Tests if box1 is a superset of box2.
|
|
Index by edge number. Edge e and e+1 with e even are opposite edges. (CS_BOX_EDGE_...) |
|
Index by CS_BOX_SIDE_? number.
Definition at line 519 of file box.h. Referenced by GetFaceEdges. |
|
The bottom-right.
|
|
The top-left of this bounding box.
|