Class Box3

3DS Max Plug-In SDK

Class Box3

See Also: Class Point3, Class Matrix3.

class Box3

Description:

This class represents a 3D box volume described by two 3D corner coordinates. Box3 provides methods that return individual coordinates of the box, scale and translate it, retrieve its center, modify its size, expand it to include points or other boxes, and determine if points are inside the box. All methods are implemented by the system.

Data Members:

public:

Point3 pmin,pmax;

The corners of the 3D box.

Methods:

Prototype:

Box3();

Remarks:

Constructor. The corners of the box are initialized such that the box is 'empty'. See IsEmpty().

Prototype:

Box3(const Point3& p, const Point3& q)

Remarks:

Constructor. The corners of the box are initialized to the points passed. pmin=p; pmax = q.

Prototype:

void Init();

Remarks:

Initializes this box such that pmin is a very large value while pmax is a small value. Thus the box is 'empty'. See IsEmpty().

Prototype:

int IsEmpty() const;

Remarks:

Determines if the box is empty. This indicates the box has not had specific values set by the developer.

Return Value:

Nonzero if the box is empty; otherwise 0.

Prototype:

void MakeCube(const Point3& p, float side);

Remarks:

Modifies this box such that half the side length is subtracted from pmin and added to pmax. This creates a cube with the specified center p and side length side.

Parameters:

const Point3& p

Specifies the center point of the cube.

float side

Specifies the side length.

Prototype:

Point3 Min() const

Remarks:

Returns the value of corner pmin.

Prototype:

Point3 Max() const

Remarks:

Returns the value of corner pmax.

Prototype:

Point3 Center() const

Remarks:

Returns the center of this Box3 as a Point3.

Prototype:

Point3 Width() const

Remarks:

Returns the width of the box as a Point3. This is pmax-pmin.

Prototype:

void Scale(float s);

Remarks:

Scales this box about its center by the specified scale.

Parameters:

float s

Specifies the scale factor for this Box3.

Prototype:

void Translate(const Point3 &p);

Remarks:

Translates this box by the distance specified. The point is added to each corner.

Parameters:

const Point3 &p

Specifies the distance to translate the box.

Prototype:

void EnlargeBy(float s);

Remarks:

Enlarges this box. A Point3 is created from s as Point3(s,s,s) and added to pmax and subtracted from pmin. If the box is 'empty', the box is centered at (0,0,0) and then enlarged.

Prototype:

int Contains(const Point3& p) const;

Remarks:

Determines if the specified point p is contained in this box.

Parameters:

const Point3& p

Specifies the point to check.

Return Value:

Nonzero if the specified point is contained in this box; otherwise 0.

Prototype:

int Contains(const Box3& b) const;

Remarks:

Determines if the specified Box3 is contained totally within this box.

Parameters:

const Box3& b

Specifies the box to check.

Return Value:

Nonzero if the specified box is entirely contained within this box; otherwise 0.

Operators:

Prototype:

Point3 operator[](int i) const;

Remarks:

Operator[] returns the 'i-th' corner point:

Mapping : X Y Z

[0] : (min,min,min)

[1] : (max,min,min)

[2] : (min,max,min)

[3] : (max,max,min)

[4] : (min,min,max)

[5] : (max,min,max)

[6] : (min,max,max)

[7] : (max,max,max)

Parameters:

int i

Specifies the corner to retrieve (0 <= i <= 7)

Return Value:

The 'i-th' corner point as a Point3.

Prototype:

Box3& operator+=(const Point3& p);

Remarks:

Expands this Box3 to include the Point3 p.

Parameters:

const Point3& p

Specifies the point to expand the box to include.

Prototype:

Box3& operator+=(const Box3& b);

Remarks:

Expands this Box3 to include the Box3 b.

Parameters:

const Box3& b

Specifies the Box3 to expand this box to include.

Prototype:

Box3 operator*(const Matrix3& tm) const;

Remarks:

Returns a box that bounds the 8 transformed corners of the input box.

Parameters:

const Matrix3& tm

Specifies the matrix to transform the box corners by.