PixelLightAPI  .
Public Types | Public Member Functions
PLMath::Polygon Class Reference

A polygon is a set of vertices on a same plane. This is only a base class with vertices... to add texture coords etc. to have to derive it! More...

#include <Polygon.h>

List of all members.

Public Types

enum  ESide { Behind = -1, Coinciding = 0, InFront = 1, Spanning = 2 }
 Plane/point relation. More...

Public Member Functions

PLMATH_API Polygon ()
 Constructor.
PLMATH_API Polygon (const Polygon &cSource)
 Copy constructor.
virtual PLMATH_API ~Polygon ()
 Destructor.
PLMATH_API const PlaneGetPlane () const
 Returns the plane the polygon is on.
PLMATH_API const PlaneComputePlane ()
 Computes and returns the plane the polygon is on.
PLMATH_API bool CheckVerticesOnPlane () const
 Checks whether all vertices are on the polygon plane or not.
PLMATH_API PLCore::Array
< Vector3 > & 
GetVertexList ()
 Returns a list of all vertices.
PLMATH_API bool AddVertex (const Vector3 &vV)
 Adds a vertex to the polygon.
PLMATH_API bool Split (const Plane &cSplitter, Polygon &cFrontPolygon, Polygon &cBackPolygon)
 Splits the polygon.
PLMATH_API Polygonoperator= (const Polygon &cSource)
 Copy operator.
PLMATH_API ESide GetSide (const Plane &cPlane) const
 Calculates the side the polygon is on.
PLMATH_API bool IsInFront (const Plane &cPlane) const
 Checks whether the polygon is completely in front of the given plane.
PLMATH_API bool IsBehind (const Plane &cPlane) const
 Checks whether the polygon is completely behind the given plane.
PLMATH_API Polygon Clip (const Plane &cPlane) const
 Clips the polygon against a plane.
virtual PLMATH_API bool CustomInit (Polygon &cPolygon)
 Initializes the data of the splitted polygon.
virtual PLMATH_API bool CustomAdd (Polygon &cPolygon, PLCore::uint32 nID)
 Adds data to a polygon.
virtual PLMATH_API bool CustomSplit (Polygon &cFrontPolygon, Polygon &cBackPolygon, PLCore::uint32 nID, float fDistance)
 Splits the polygon using the custom function.

Detailed Description

A polygon is a set of vertices on a same plane. This is only a base class with vertices... to add texture coords etc. to have to derive it!


Member Enumeration Documentation

Plane/point relation.

Enumerator:
Behind 

Behind the plane (distance < 0)

Coinciding 

Lies on the plane (distance = 0)

InFront 

Is in front of the plane (distance > 0)

Spanning 

Spans the plane


Constructor & Destructor Documentation

PLMATH_API PLMath::Polygon::Polygon ( )

Constructor.

PLMATH_API PLMath::Polygon::Polygon ( const Polygon cSource)

Copy constructor.

Parameters:
[in]cSourcePolygon to copy
virtual PLMATH_API PLMath::Polygon::~Polygon ( ) [virtual]

Destructor.


Member Function Documentation

PLMATH_API const Plane& PLMath::Polygon::GetPlane ( ) const

Returns the plane the polygon is on.

Returns:
Plane the polygon is on
PLMATH_API const Plane& PLMath::Polygon::ComputePlane ( )

Computes and returns the plane the polygon is on.

Returns:
Plane the polygon is on
Note:
  • For the plane calculation the first three vertices are used
PLMATH_API bool PLMath::Polygon::CheckVerticesOnPlane ( ) const

Checks whether all vertices are on the polygon plane or not.

Returns:
'true' if all vertices are on the polygon plane, else 'false'

Returns a list of all vertices.

Returns:
List of all vertices
Note:
  • If vertices are changed to should call the ComputePlane() function to keep the polygon plane up to date!
PLMATH_API bool PLMath::Polygon::AddVertex ( const Vector3 vV)

Adds a vertex to the polygon.

Parameters:
[in]vVVertex to add
Returns:
'true' if all went fine and the vertex was added, else 'false' (maybe the current last vertex is the same as the given one?)
PLMATH_API bool PLMath::Polygon::Split ( const Plane cSplitter,
Polygon cFrontPolygon,
Polygon cBackPolygon 
)

Splits the polygon.

Parameters:
[in]cSplitterSplitter plane
[out]cFrontPolygonPolygon in front of the plane
[out]cBackPolygonPolygon behind the plane
Returns:
'true' if all went fine, else 'false'
PLMATH_API Polygon& PLMath::Polygon::operator= ( const Polygon cSource)

Copy operator.

Parameters:
[in]cSourceSource to copy from
Returns:
Reference to this instance
PLMATH_API ESide PLMath::Polygon::GetSide ( const Plane cPlane) const

Calculates the side the polygon is on.

Returns:
Plane side
PLMATH_API bool PLMath::Polygon::IsInFront ( const Plane cPlane) const

Checks whether the polygon is completely in front of the given plane.

Returns:
'true' if the polygon is completely in front of the given plane, else 'false'
PLMATH_API bool PLMath::Polygon::IsBehind ( const Plane cPlane) const

Checks whether the polygon is completely behind the given plane.

Returns:
'true' if the polygon is completely behind the given plane, else 'false'
PLMATH_API Polygon PLMath::Polygon::Clip ( const Plane cPlane) const

Clips the polygon against a plane.

Parameters:
[in]cPlanePlane to clip this polygon against
Returns:
The resulting clipped plane
virtual PLMATH_API bool PLMath::Polygon::CustomInit ( Polygon cPolygon) [virtual]

Initializes the data of the splitted polygon.

Parameters:
[out]cPolygonPolygon which should be initialized
Returns:
'true' if all went fine, else 'false'
virtual PLMATH_API bool PLMath::Polygon::CustomAdd ( Polygon cPolygon,
PLCore::uint32  nID 
) [virtual]

Adds data to a polygon.

Parameters:
[out]cPolygonPolygon the data should be added
[in]nIDCurrent data ID
Returns:
'true' if all went fine, else 'false'
Note:
  • Is called by Split() to get an custom split behavior... a derived polygon could e.g. also have texture coordinates to be split or added!
virtual PLMATH_API bool PLMath::Polygon::CustomSplit ( Polygon cFrontPolygon,
Polygon cBackPolygon,
PLCore::uint32  nID,
float  fDistance 
) [virtual]

Splits the polygon using the custom function.

Parameters:
[out]cFrontPolygonPolygon in front of the plane
[out]cBackPolygonPolygon behind the plane
[in]nIDCurrent data ID
[in]fDistanceDistance from nID-1 to the splitter plane intersection point
Returns:
'true' if all went fine, else 'false'
See also:

The documentation for this class was generated from the following file:


PixelLight PixelLight 0.9.11-R1
Copyright (C) 2002-2012 by The PixelLight Team
Last modified Thu Feb 23 2012 14:09:35
The content of this PixelLight document is published under the
Creative Commons Attribution-NonCommercial-ShareAlike 3.0 Unported