CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csPoly3D Class Reference
[Geometry utilities]

The following class represents a general 3D polygon. More...

#include <poly3d.h>

Inheritance diagram for csPoly3D:

csVector3Array List of all members.

Public Methods

 csPoly3D (int start_size=10)
 Make a new empty polygon.

 csPoly3D (const csPoly3D &copy)
 Copy constructor.

virtual ~csPoly3D ()
 Destructor.

void MakeEmpty ()
 Initialize the polygon to empty.

int GetVertexCount () const
 Get the number of vertices.

csVector3GetVertices () const
 Get the array with all vertices.

csVector3GetVertex (int i) const
 Get the specified vertex.

csVector3operator[] (int i)
 Get the specified vertex.

csVector3operator[] (int i) const
 Get the specified vertex.

csVector3GetFirst () const
 Get the first vertex.

csVector3GetLast () const
 Get the last vertex.

bool In (const csVector3 &v) const
 Test if this vector is inside the polygon.

void MakeRoom (int new_max)
 Make room for at least the specified number of vertices.

void SetVertexCount (int n)
 Set the number of vertices.

int AddVertex (const csVector3 &v)
 Add a vertex (3D) to the polygon.

int AddVertex (float x, float y, float z)
 Add a vertex (3D) to the polygon.

void SetVertices (csVector3 const *v, int num)
 Set all polygon vertices at once.

bool ProjectXPlane (const csVector3 &point, float plane_x, csPoly2D *poly2d) const
 Project this polygon onto a X plane as seen from some point in space.

bool ProjectYPlane (const csVector3 &point, float plane_y, csPoly2D *poly2d) const
 Project this polygon onto a Y plane as seen from some point in space.

bool ProjectZPlane (const csVector3 &point, float plane_z, csPoly2D *poly2d) const
 Project this polygon onto a Z plane as seen from some point in space.

bool ProjectAxisPlane (const csVector3 &point, int plane_nr, float plane_pos, csPoly2D *poly2d) const
 Project this polygon onto an axis-aligned plane as seen from some point in space.

int Classify (const csPlane3 &pl) const
 Classify this polygon with regards to a plane.

int ClassifyX (float x) const
 Same as Classify() but for X plane only.

int ClassifyY (float y) const
 Same as Classify() but for Y plane only.

int ClassifyZ (float z) const
 Same as Classify() but for Z plane only.

void CutToPlane (const csPlane3 &split_plane)
 Cut this polygon with a plane and only keep the front side.

void SplitWithPlane (csPoly3D &front, csPoly3D &back, const csPlane3 &split_plane) const
 Split this polygon with the given plane (A,B,C,D).

void SplitWithPlaneX (csPoly3D &front, csPoly3D &back, float x) const
 Split this polygon to the x-plane.

void SplitWithPlaneY (csPoly3D &front, csPoly3D &back, float y) const
 Split this polygon to the y-plane.

void SplitWithPlaneZ (csPoly3D &front, csPoly3D &back, float z) const
 Split this polygon to the z-plane.

csVector3 ComputeNormal () const
 Compute the normal of this polygon.

csPlane3 ComputePlane () const
 Compute the plane of this polygon.

float GetArea () const
 Calculate the area of this polygon.

csVector3 GetCenter () const
 Compute and get the central vertex of this polygon.


Static Public Methods

bool In (csVector3 *poly, int num_poly, const csVector3 &v)
 Test if a vector is inside the given polygon.

int Classify (const csPlane3 &pl, csVector3 *vertices, int num_vertices)
 Static function to classify a polygon with regards to a plane.

csVector3 ComputeNormal (csVector3 *vertices, int num)
 Compute the normal of a polygon.

csPlane3 ComputePlane (csVector3 *vertices, int num)
 Compute the plane of a polygon.


Protected Attributes

csVector3vertices
 The 3D vertices.


Detailed Description

The following class represents a general 3D polygon.

Definition at line 43 of file poly3d.h.


Constructor & Destructor Documentation

csPoly3D::csPoly3D int    start_size = 10
 

Make a new empty polygon.

csPoly3D::csPoly3D const csPoly3D &    copy
 

Copy constructor.

virtual csPoly3D::~csPoly3D   [virtual]
 

Destructor.


Member Function Documentation

int csPoly3D::AddVertex float    x,
float    y,
float    z
 

Add a vertex (3D) to the polygon.

Return index of added vertex.

int csPoly3D::AddVertex const csVector3   v [inline]
 

Add a vertex (3D) to the polygon.

Return index of added vertex.

Definition at line 143 of file poly3d.h.

References csVector3::x, csVector3::y, and csVector3::z.

int csPoly3D::Classify const csPlane3   pl const [inline]
 

Classify this polygon with regards to a plane.

If this poly is on same plane it returns CS_POL_SAME_PLANE. If this poly is completely in front of the given plane it returnes CS_POL_FRONT. If this poly is completely back of the given plane it returnes CS_POL_BACK. Otherwise it returns CS_POL_SPLIT_NEEDED.

Definition at line 225 of file poly3d.h.

int csPoly3D::Classify const csPlane3   pl,
csVector3   vertices,
int    num_vertices
[static]
 

Static function to classify a polygon with regards to a plane.

If this poly is on same plane it returns CS_POL_SAME_PLANE. If this poly is completely in front of the given plane it returnes CS_POL_FRONT. If this poly is completely back of the given plane it returnes CS_POL_BACK. Otherwise it returns CS_POL_SPLIT_NEEDED.

int csPoly3D::ClassifyX float    x const
 

Same as Classify() but for X plane only.

int csPoly3D::ClassifyY float    y const
 

Same as Classify() but for Y plane only.

int csPoly3D::ClassifyZ float    z const
 

Same as Classify() but for Z plane only.

csVector3 csPoly3D::ComputeNormal   const [inline]
 

Compute the normal of this polygon.

Definition at line 259 of file poly3d.h.

csVector3 csPoly3D::ComputeNormal csVector3   vertices,
int    num
[static]
 

Compute the normal of a polygon.

csPlane3 csPoly3D::ComputePlane   const [inline]
 

Compute the plane of this polygon.

Definition at line 268 of file poly3d.h.

csPlane3 csPoly3D::ComputePlane csVector3   vertices,
int    num
[static]
 

Compute the plane of a polygon.

void csPoly3D::CutToPlane const csPlane3   split_plane
 

Cut this polygon with a plane and only keep the front side.

float csPoly3D::GetArea  
 

Calculate the area of this polygon.

csVector3 csPoly3D::GetCenter  
 

Compute and get the central vertex of this polygon.

csVector3* csPoly3D::GetFirst   const [inline]
 

Get the first vertex.

Definition at line 110 of file poly3d.h.

csVector3* csPoly3D::GetLast   const [inline]
 

Get the last vertex.

Definition at line 116 of file poly3d.h.

csVector3* csPoly3D::GetVertex int    i const [inline]
 

Get the specified vertex.

Definition at line 83 of file poly3d.h.

int csPoly3D::GetVertexCount   const [inline]
 

Get the number of vertices.

Definition at line 73 of file poly3d.h.

csVector3* csPoly3D::GetVertices   const [inline]
 

Get the array with all vertices.

Definition at line 78 of file poly3d.h.

bool csPoly3D::In csVector3   poly,
int    num_poly,
const csVector3   v
[static]
 

Test if a vector is inside the given polygon.

bool csPoly3D::In const csVector3   v const
 

Test if this vector is inside the polygon.

void csPoly3D::MakeEmpty  
 

Initialize the polygon to empty.

void csPoly3D::MakeRoom int    new_max
 

Make room for at least the specified number of vertices.

csVector3& csPoly3D::operator[] int    i const [inline]
 

Get the specified vertex.

Definition at line 101 of file poly3d.h.

csVector3& csPoly3D::operator[] int    i [inline]
 

Get the specified vertex.

Definition at line 92 of file poly3d.h.

bool csPoly3D::ProjectAxisPlane const csVector3   point,
int    plane_nr,
float    plane_pos,
csPoly2D   poly2d
const [inline]
 

Project this polygon onto an axis-aligned plane as seen from some point in space.

Fills the given 2D polygon with the projection on the plane. This function assumes that there actually is a projection. Plane_nr is 0 for the X plane, 1 for Y, and 2 for Z.

Definition at line 196 of file poly3d.h.

bool csPoly3D::ProjectXPlane const csVector3   point,
float    plane_x,
csPoly2D   poly2d
const
 

Project this polygon onto a X plane as seen from some point in space.

Fills the given 2D polygon with the projection on the plane. This function assumes that there actually is a projection. If the polygon to project comes on the same plane as 'point' then it will return false (no valid projection).

bool csPoly3D::ProjectYPlane const csVector3   point,
float    plane_y,
csPoly2D   poly2d
const
 

Project this polygon onto a Y plane as seen from some point in space.

Fills the given 2D polygon with the projection on the plane. This function assumes that there actually is a projection. If the polygon to project comes on the same plane as 'point' then it will return false (no valid projection).

bool csPoly3D::ProjectZPlane const csVector3   point,
float    plane_z,
csPoly2D   poly2d
const
 

Project this polygon onto a Z plane as seen from some point in space.

Fills the given 2D polygon with the projection on the plane. This function assumes that there actually is a projection. If the polygon to project comes on the same plane as 'point' then it will return false (no valid projection).

void csPoly3D::SetVertexCount int    n [inline]
 

Set the number of vertices.

Definition at line 137 of file poly3d.h.

void csPoly3D::SetVertices csVector3 const *    v,
int    num
[inline]
 

Set all polygon vertices at once.

Copies the array.

Definition at line 154 of file poly3d.h.

void csPoly3D::SplitWithPlane csPoly3D &    front,
csPoly3D &    back,
const csPlane3   split_plane
const
 

Split this polygon with the given plane (A,B,C,D).

void csPoly3D::SplitWithPlaneX csPoly3D &    front,
csPoly3D &    back,
float    x
const
 

Split this polygon to the x-plane.

void csPoly3D::SplitWithPlaneY csPoly3D &    front,
csPoly3D &    back,
float    y
const
 

Split this polygon to the y-plane.

void csPoly3D::SplitWithPlaneZ csPoly3D &    front,
csPoly3D &    back,
float    z
const
 

Split this polygon to the z-plane.


Member Data Documentation

csVector3* csPoly3D::vertices [protected]
 

The 3D vertices.

Definition at line 47 of file poly3d.h.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.18