TalanSoft Toolkits  201707
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Groups Pages
Public Member Functions | List of all members
cPolygon Class Reference
Inheritance diagram for cPolygon:
cMemImpl

Public Member Functions

 cPolygon (tFVF aFVF=eFVF_Position)
 Constructor. More...
 
 cPolygon (const cPolygon &aRight)
 Copy constructor. More...
 
 ~cPolygon ()
 Destructor. More...
 
void ZeroMembers ()
 Zero class members. More...
 
tBool IsOK () const
 Return eTrue if the polygon is ok. More...
 
tBool SetVertexPosition (ni::tU32 anIndex, const sVec3f &pos)
 
sVec3f GetVertexPosition (ni::tU32 anIndex) const
 
tBool operator== (const cPolygon &aRight) const
 
const acharGetSerializeObjectTypeID () const
 Get the object type ID. More...
 
tSize Serialize (iFile *apFile, eSerializeMode aMode)
 Serialize the object. More...
 
- Public Member Functions inherited from cMemImpl
voidoperator new (size_t anSize, void *apMem)
 
void operator delete (void *apMem, void *apMemDum)
 
voidoperator new (size_t anSize)
 
voidoperator new[] (size_t anSize)
 
voidoperator new (size_t anSize, const achar *aaszFile, int anLine)
 
voidoperator new[] (size_t anSize, const achar *aaszFile, int anLine)
 
void operator delete (void *apMem)
 
void operator delete[] (void *apMem)
 
void operator delete (void *apMem, const achar *aaszFile, int anLine)
 
void operator delete[] (void *apMem, const achar *aaszFile, int anLine)
 

Vertices

void SetFVF (tFVF aFVF)
 Set the FVF. More...
 
tFVF GetFVF () const
 Get the FVF. More...
 
tBool IsSameFVF (const cPolygon *aPoly) const
 Check if the passed polygon's FVF is the same as this polygon's FVF. More...
 
tU16 GetVertexSize () const
 Get the vertex size. More...
 
void ClearVertices ()
 Remove all vertices of the polygon. More...
 
void ReserveVertices (tU32 aunNumVert)
 Reserve memory for the specified number of vertices. More...
 
tU16 GetNumVertices () const
 Get the number of vertices in the polygon. More...
 
void SetNumVertices (tU16 anNum)
 Set the number of vertices. More...
 
iFileCreateVerticesFile () const
 Create a vertices file. More...
 
void AddVertices (const tPtr apVerts, tU16 aunNumVert=1)
 Add vertices to the polygon. More...
 
void AddVertices (const cFVFDescription &aFVF, const tPtr apVerts, tU16 aunNumVert=1)
 Add vertices to the polygon. More...
 
void RemoveVertex (tU32 anVert=eInvalidHandle)
 Remove a vertex of the polygon. More...
 
void SwapVertices (tU32 i, tU32 j)
 Swap the content of two vertex. More...
 
tPtr GetVertex (tU32 nVert) const
 Get the vertex at the given index. More...
 
tPtr GetFirstVertex () const
 Get the first vertex. More...
 
tPtr GetNextVertex (tPtr apVert) const
 Get the next vertex. More...
 
tBool IsEndVertex (tPtr apVert) const
 Check if this is the end vertex. More...
 
sVec3fGetPosition (tU32 nVert) const
 Get the position at the given index. More...
 
sVec3fGetFirstPosition () const
 Get the first position. More...
 
sVec3fGetNextPosition (sVec3f *apVert) const
 Get the next position. More...
 
tBool IsEndPosition (sVec3f *apVert) const
 Check if this is the end position. More...
 
tBool IsEmpty () const
 Return eTrue if their's no vertex in the polygon. More...
 
tBool IsValidPolygon () const
 Return eTrue if the polygon is valid, aka has at least 3 vertex. More...
 
tBool Exists (const sVec3f &pos, const tF32 epsilon)
 return eTrue if a vertex with the given position is already in the list More...
 
tBool Exists (const sVec3f &pos)
 

Misc infos

sVec3f GetCOM () const
 Get the polygon center of mass. More...
 
tF32 GetArea () const
 Get the polygon area. More...
 

Plane

tBool ComputePlane ()
 Compute the plane. More...
 
tBool ComputePlaneNormal (const sVec3f &vNormal)
 Compute the plane using a given normal from a polygon which is coplanar. More...
 
void SetPlane (const sPlanef &plane)
 Set the value of the plane with the given plane. More...
 
sPlanef GetPlane () const
 Get the polygon's plane. More...
 

Intersection/Classification

eClassify Classify (const sPlanef &Plane, const tF32 epsilon) const
 Classify along a plane. More...
 
eClassify Classify (const sPlanef &Plane) const
 Classify along a plane. More...
 
tBool IsEqual (const cPolygon *b) const
 Return eTrue if the specified polygon is the same as this polygon. More...
 
tBool Intersect (const sVec3f &pt, const tF32 fEpsilon=niEpsilon5) const
 Return eTrue if the specified point is inside the polygon. More...
 
tBool IntersectPoint (const sVec3f &pt) const
 
tBool Intersect (const cAABBf &aAABB, const tF32 fEpsilon=niEpsilon5) const
 Return eTrue if the specified AABB intersect the polygon. More...
 
tBool IntersectAABB (const sVec3f &avMin, const sVec3f &avMax) const
 

Splitting

void Split (const sPlanef &Plane, cPolygon *pFront, cPolygon *pBack, tBool abKeepCoplanar, tF32 epsilon) const
 Split along a plane. More...
 
void Split (const sPlanef &Plane, cPolygon *pFront, cPolygon *pBack, tBool abKeepCoplanar) const
 
tBool Clip (const sPlanef *apPlanes, tU32 aulNumPlanes, cPolygon &aResult, tBool abKeepBack, tBool abKeepCoplanar, tF32 epsilon) const
 Clip the polygon against the given set of planes. The planes are supposted to form a convex hull. More...
 
tBool Clip (const tVec4fCVec *avPlanes, cPolygon *apResult, tBool abKeepBack, tBool abKeepCoplanar) const
 

Misc operations

tBool GenerateBaseForPlane (const sPlanef &Plane, const tF32 fWidth=1024.0f, tBool bCCW=eFalse)
 Generate vertices for the given plane the size is fWidth. More...
 
tBool GenerateBaseForPlaneAABB (const sPlanef &Plane, const sVec3f &avMin, const sVec3f &avMax, tBool bCCW=eFalse)
 Generate vertices for the given plane the size is defined by the specified AABB. More...
 
void SortVerts ()
 Sort the vertices in clockwise order. More...
 
void Reverse ()
 Reverse the polygon facing. More...
 
sVec3fClosestPointOnPerimeter (sVec3f &Out, const sVec3f &pt, sVec3f *pEA=NULL, sVec3f *pEB=NULL, tBool *pbEdgeFlag=NULL) const
 Return the closest point to the specified point that lay on an edge of this polygon. More...
 
tBool IsDegenerate () const
 Check if the polygon is degenerate. More...
 

Material and Flags

void SetMaterial (tU32 aunMatID)
 Set the polygon's material. More...
 
tU32 GetMaterial () const
 Get the polygon's material. More...
 
void SetFlags (tU32 anFlags)
 Set the polygon's flags. More...
 
tU32 GetFlags () const
 Get the polygon's flags. More...
 

Creation & Copy

void CopyVertices (const cPolygon *apPoly)
 Copy only the vertices of the specified polygon. More...
 
void Copy (const cPolygon *apPoly)
 Copy the specified polygon in this polygon. More...
 
cPolygonCreate () const
 Create a polygon with the same FVF as this polygon. More...
 
cPolygonClone () const
 Create a copy of this polygon. More...
 

Member Function Documentation

tBool SetVertexPosition ( ni::tU32  anIndex,
const sVec3f pos 
)
sVec3f GetVertexPosition ( ni::tU32  anIndex) const
tBool operator== ( const cPolygon aRight) const
const achar* GetSerializeObjectTypeID ( ) const

Get the object type ID.

tSize Serialize ( iFile apFile,
eSerializeMode  aMode 
)

Serialize the object.