Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csBox3 Class Reference

A bounding box in 3D space. More...

#include <box.h>

List of all members.

Public Methods

float MinX () const
 Get the minimum X value of the box.

float MinY () const
 Get the minimum Y value of the box.

float MinZ () const
 Get the minimum Z value of the box.

float MaxX () const
 Get the maximum X value of the box.

float MaxY () const
 Get the maximum Y value of the box.

float MaxZ () const
 Get the maximum Z value of the box.

float Min (int idx) const
 Get Min component for 0 (x), 1 (y), or 2 (z).

float Max (int idx) const
 Get Max component for 0 (x), 1 (y), or 2 (z).

const csVector3Min () const
 Get the 3d vector of minimum (x, y, z) values.

const csVector3Max () const
 Get the 3d vector of maximum (x, y, z) values.

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_???) return the two vertices (index CS_BOX_CORNER_???) and left/right faces (CS_BOX_SIDE_???).

uint8* GetFaceEdges (int face) const
 Given a face index (CS_BOX_SIDE_???) return the four edges oriented clockwise around this face (CS_BOX_EDGE_???).

csVector3 GetCenter () const
 Get the center of this box.

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.

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_??? defines) as seen from the given point. 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_??? indices). 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_??? indices). More...

bool In (float x, float y, float z) const
 Test if the given coordinate is in this box.

bool In (const csVector3 &v) const
 Test if the given coordinate is in this box.

bool Overlap (const csBox3 &box) const
 Test if this box overlaps with the given box.

bool Contains (const csBox3 &box) const
 Test if this box contains the other box.

bool Empty () const
 Test if this box is empty.

void StartBoundingBox ()
 Initialize this box to empty.

void StartBoundingBox (const csVector3 &v)
 Initialize this box to one vertex.

void AddBoundingVertex (float x, float y, float z)
 Add a new vertex and recalculate the bounding box.

void AddBoundingVertex (const csVector3 &v)
 Add a new vertex and recalculate the bounding box.

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.

 csBox3 (const csVector3 &v)
 Initialize this box with one point.

 csBox3 (const csVector3 &v1, const csVector3 &v2)
 Initialize this box with two points.

 csBox3 (float x1, float y1, float z1, float x2, float y2, float z2)
 Initialize this box with the given values.

void Set (const csVector3 &bmin, const csVector3 &bmax)
 Sets the bounds of the box with the given values.

void Set (float x1, float y1, float z1, float x2, float y2, float z2)
 Sets the bounds of the box with the given values.

bool AdjacentX (const csBox3 &other) const
 Test if this box is adjacent to the other on the X side.

bool AdjacentY (const csBox3 &other) const
 Test if this box is adjacent to the other on the Y side.

bool AdjacentZ (const csBox3 &other) const
 Test if this box is adjacent to the other on the Z side.

int Adjacent (const csBox3 &other) const
 Test if this box is adjacent to the other one. 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.

void ManhattanDistance (const csBox3 &other, csVector3 &dist) const
 Calculate the minimum manhattan distance between this box and another one.

float SquaredOriginDist () const
 Calculate the squared distance between (0,0,0) and the box This routine is extremely efficient.

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...

csBox3& operator+= (const csBox3 &box)
 Compute the union of two bounding boxes.

csBox3& operator+= (const csVector3 &point)
 Compute the union of a point with this bounding box.

csBox3& operator *= (const csBox3 &box)
 Compute the intersection of two bounding boxes.


Static Public Methods

int OtherSide (int side)
 Static function to get the 'other' side (i.e. More...


Protected Types

typedef uint8 bFace [4]

Protected Attributes

csVector3 minbox
 The top-left of this bounding box.

csVector3 maxbox
 The bottom-right.


Static Protected Attributes

bEdge edges [24]
bFace faces [6]

Friends

csBox3 operator+ (const csBox3 &box1, const csBox3 &box2)
 Compute the union of two bounding boxes.

csBox3 operator+ (const csBox3 &box, const csVector3 &point)
 Compute the union of a bounding box and a point.

csBox3 operator * (const csBox3 &box1, const csBox3 &box2)
 Compute the intersection of two bounding boxes.

bool operator== (const csBox3 &box1, const csBox3 &box2)
 Tests if two bounding boxes are equal.

bool operator!= (const csBox3 &box1, const csBox3 &box2)
 Tests if two bounding boxes are unequal.

bool operator< (const csBox3 &box1, const csBox3 &box2)
 Tests if box1 is a subset of box2.

bool operator> (const csBox3 &box1, const csBox3 &box2)
 Tests if box1 is a superset of box2.

bool operator< (const csVector3 &point, const csBox3 &box)
 Tests if a point is contained in a box.


Detailed Description

A bounding box in 3D space.

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.


Member Function Documentation

void csBox3::AddBoundingVertexSmart ( const csVector3 & v ) [inline]
 

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.

void csBox3::AddBoundingVertexSmart ( float x,
float y,
float z ) [inline]
 

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.

int csBox3::Adjacent ( const csBox3 & other ) const
 

Test if this box is adjacent to the other one.

Return -1 if not adjacent or else any of the CS_BOX_SIDE_??? flags to indicate the side of this box that the other box is adjacent with.

void csBox3::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.

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.

csVector3 csBox3::GetCorner ( int corner ) const
 

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_??? defines.

void csBox3::GetEdge ( int edge,
csSegment3 & e ) const [inline]
 

Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_??? indices).

The returned edge is undefined for any other index.

csSegment3 csBox3::GetEdge ( int edge ) const [inline]
 

Return every edge (segment) of this bounding box from 0 to 23 (use one of the CS_BOX_EDGE_??? indices).

The returned edge is undefined for any other index.

csBox2 csBox3::GetSide ( int side ) const
 

Get a side of this box as a 2D box.

Use CS_BOX_SIDE_??? defines.

int csBox3::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_??? defines) as seen from the given point.

Returns the number of visible sides.

int csBox3::OtherSide ( int side ) [inline, static]
 

Static function to get the 'other' side (i.e.

CS_BOX_SIDE_X to CS_BOX_SIDE_x, ...).

void csBox3::SetCenter ( const csVector3 & c )
 

Set the center of this box.

This will not change the size of the box but just relocate the center.

float csBox3::SquaredOriginMaxDist ( ) const
 

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.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000