overview wiki api reference download
 All Classes Functions Variables Typedefs Enumerations Enumerator
Public Member Functions | Static Public Member Functions | Static Public Attributes
gameplay::Plane Class Reference

#include <Plane.h>

List of all members.

Public Member Functions

 Plane ()
 Plane (const Vector3 &normal, float distance)
 Plane (float normalX, float normalY, float normalZ, float distance)
 Plane (const Plane &copy)
 ~Plane ()
const Vector3getNormal () const
void setNormal (const Vector3 &normal)
void setNormal (float x, float y, float z)
float getDistance () const
void setDistance (float distance)
float distance (const Vector3 &point) const
float intersects (const BoundingSphere &sphere) const
float intersects (const BoundingBox &box) const
float intersects (const Frustum &frustum) const
float intersects (const Plane &plane) const
float intersects (const Ray &ray) const
bool isParallel (const Plane &plane) const
void set (const Vector3 &normal, float distance)
void set (const Plane &plane)
void transform (const Matrix &matrix)
Planeoperator*= (const Matrix &matrix)

Static Public Member Functions

static void intersection (const Plane &p1, const Plane &p2, const Plane &p3, Vector3 *point)

Static Public Attributes

static const int INTERSECTS_INTERSECTING = 0
static const int INTERSECTS_FRONT = 1
static const int INTERSECTS_BACK = -1

Detailed Description

Defines a plane which is a flat surface with 2 sides.

The plane is represented as a plane using a 3D vector normal and a distance value (stored as a negative value).


Constructor & Destructor Documentation

Constructs a new plane with normal (0, 1, 0) and distance 0.

gameplay::Plane::Plane ( const Vector3 normal,
float  distance 
)

Constructs a new plane from the specified values.

Parameters:
normalThe normal vector of this plane.
distanceThe distance from this plane along its (unit) normal to the origin.
gameplay::Plane::Plane ( float  normalX,
float  normalY,
float  normalZ,
float  distance 
)

Constructs a new plane from the specified values.

Parameters:
normalXThe x coordinate of the normal.
normalYThe y coordinate of the normal.
normalZThe z coordinate of the normal.
distanceThe distance from this plane along its (unit) normal to the origin.
gameplay::Plane::Plane ( const Plane copy)

Constructs a new plane from the given plane.

Parameters:
copyThe plane to copy.

Destructor.


Member Function Documentation

float gameplay::Plane::distance ( const Vector3 point) const

Calculates the distance from this plane to the specified point.

Parameters:
pointThe point to calculate distance to.

Gets the plane's distance to the origin along its normal.

Returns:
The plane's distance to the origin along its normal.

Gets the plane's normal in the given vector.

Returns:
normal The plane's normal.
static void gameplay::Plane::intersection ( const Plane p1,
const Plane p2,
const Plane p3,
Vector3 point 
) [static]

Calculates the point of intersection of the given three planes and stores it in the given point.

Parameters:
p1The first plane.
p2The second plane.
p3The third plane.
pointThe point to store the point of intersection in (this is left unmodified if the planes do not all intersect or if they are all parallel along one vector and intersect along a line).
float gameplay::Plane::intersects ( const BoundingSphere sphere) const

Tests whether this plane intersects the specified bounding sphere.

Parameters:
sphereThe bounding sphere to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified bounding object is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
float gameplay::Plane::intersects ( const BoundingBox box) const

Tests whether this plane intersects the specified bounding box.

Parameters:
boxThe bounding box to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified bounding object is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
float gameplay::Plane::intersects ( const Frustum frustum) const

Tests whether this plane intersects the specified frustum.

Parameters:
frustumThe frustum to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified frustum is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
float gameplay::Plane::intersects ( const Plane plane) const

Tests whether this plane intersects the specified plane.

Parameters:
planeThe plane to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified plane is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
float gameplay::Plane::intersects ( const Ray ray) const

Tests whether this plane intersects the specified ray.

Parameters:
rayThe ray to test intersection with.
Returns:
Plane::INTERSECTS_BACK if the specified ray is in the negative half-space of this plane, Plane::INTERSECTS_FRONT if it is in the positive half-space of this plane, and Plane::INTERSECTS_INTERSECTING if it intersects this plane.
bool gameplay::Plane::isParallel ( const Plane plane) const

Determines whether the given plane is parallel to this plane.

Parameters:
planeThe plane to test.
Returns:
true if the given plane is parallel to this plane; false otherwise.
Plane& gameplay::Plane::operator*= ( const Matrix matrix) [inline]

Transforms this plane by the given matrix.

Parameters:
matrixThe matrix to transform by.
Returns:
This plane, after the transformation occurs.
void gameplay::Plane::set ( const Vector3 normal,
float  distance 
)

Sets this plane to the specified values.

Parameters:
normalThe normal vector of this plane.
distanceThe distance to this plane along its normal to the origin.
void gameplay::Plane::set ( const Plane plane)

Sets this plane to the given plane.

Parameters:
planeThe plane to copy.
void gameplay::Plane::setDistance ( float  distance)

Sets the plane's distance to the origin along its normal.

Parameters:
distanceThe new distance.
void gameplay::Plane::setNormal ( const Vector3 normal)

Sets the plane's normal to the given vector.

Parameters:
normalThe new normal vector.
void gameplay::Plane::setNormal ( float  x,
float  y,
float  z 
)

Sets the plane's normal.

Parameters:
xThe x coordinate of the normal.
yThe y coordinate of the normal.
zThe z coordinate of the normal.
void gameplay::Plane::transform ( const Matrix matrix)

Transforms this plane by the given transformation matrix.

Parameters:
matrixThe transformation matrix to transform by.

Member Data Documentation

const int gameplay::Plane::INTERSECTS_BACK = -1 [static]

Represents when a 3D entity is behind (in the negative half-space of) a plane.

const int gameplay::Plane::INTERSECTS_FRONT = 1 [static]

Represents when a 3D entity is in front of (in the positive half-space of) a plane.

Represents when a 3D entity intersects a plane.

 All Classes Functions Variables Typedefs Enumerations Enumerator