Main Page   Namespace List   Class Hierarchy   Compound List   File List   Compound Members   File Members  

POLYGON Class Reference

#include <polygon.h>

List of all members.

Public Methods

 POLYGON ()
 ~POLYGON ()
int Compare (const POLYGON &Polygon)
int GetMyPosition () const
void SetMyPosition (int newPosition)
bool IsLast ()
POLYGON * GetNext ()
void AddPolygon (POLYGON *Poly)
void SetNext (POLYGON *Poly)
POLYGON * CopyList ()
VECTOR GetNormal ()
void SetNormal ()
const bool POLYGON::operator== (const POLYGON &Poly) const

Public Attributes

int linkPosition
POLYGON * NextPoly
int id
int numVertices
int removable
unsigned int Texture
float Scale [2]
float Shift [2]
float Rotate
VERTEX Vertex [maxPolygonVerts]


Constructor & Destructor Documentation

POLYGON::POLYGON  
 

Definition at line 9 of file polygon.cpp.

References NextPoly, numVertices, and Texture.

00010 {
00011     NextPoly = NULL;
00012     numVertices    = 0;
00013     Texture = 0;
00014 }

POLYGON::~POLYGON  
 

Definition at line 16 of file polygon.cpp.

00017 {
00018 }


Member Function Documentation

void POLYGON::AddPolygon POLYGON *    Poly
 

Definition at line 71 of file polygon.cpp.

References GetNext(), IsLast(), and NextPoly.

Referenced by CopyList(), CSGAddition(), and CSGClipPolygon().

00072 {
00073     if (Poly != NULL)
00074     {
00075         if (IsLast())
00076         {
00077             NextPoly = Poly;
00078             return;
00079         }
00080 
00081         POLYGON* TempPoly = NextPoly;
00082 
00083         while (!TempPoly->IsLast())
00084             TempPoly = TempPoly->GetNext();
00085 
00086         TempPoly->NextPoly = Poly;
00087     }
00088 }

int POLYGON::Compare const POLYGON &    Polygon
 

Definition at line 90 of file polygon.cpp.

References bigger, linkPosition, same, and smaller.

00091 {
00092     if (linkPosition < Polygon.linkPosition)
00093             return smaller;
00094       if (linkPosition > Polygon.linkPosition)
00095             return bigger;
00096       else
00097             return same;
00098 }

POLYGON * POLYGON::CopyList  
 

Definition at line 54 of file polygon.cpp.

References AddPolygon(), IsLast(), NextPoly, numVertices, Texture, and Vertex.

Referenced by CSGAddition().

00055 {
00056     POLYGON* TempPoly = new POLYGON;
00057 
00058     TempPoly->Texture = Texture;
00059 
00060     TempPoly->numVertices = numVertices;
00061 
00062     for (int loop = 0; loop < numVertices; loop++)
00063         TempPoly->Vertex[loop] = Vertex[loop];
00064 
00065     if (!IsLast())
00066         TempPoly->AddPolygon(NextPoly->CopyList());
00067 
00068     return TempPoly;
00069 }

int POLYGON::GetMyPosition   const [inline]
 

Definition at line 21 of file polygon.h.

References linkPosition.

00021 {return linkPosition;}

POLYGON * POLYGON::GetNext  
 

Definition at line 28 of file polygon.cpp.

References IsLast(), and NextPoly.

Referenced by AddPolygon(), CSGAddition(), CSGClipPolygon(), DeleteList(), and SetNext().

00029 {
00030     if (!IsLast())
00031         return NextPoly;
00032     else
00033         return NULL;
00034 }

VECTOR POLYGON::GetNormal  
 

Definition at line 100 of file polygon.cpp.

References VERTEX::coords, Vertex, VECTOR::x, VECTOR::y, and VECTOR::z.

Referenced by CheckForCollision(), CheckForParticleCollision(), CreateLargePortal(), and CreateLightmaps().

00101 {
00102         VECTOR temp, u, v;
00103           u = Vertex[1].coords - Vertex[0].coords;
00104           v = Vertex[2].coords - Vertex[0].coords;
00105           temp.x = (u.y*v.z)-(v.y*u.z);
00106           temp.y = (u.z*v.x)-(v.z*u.x);
00107           temp.z = (u.x*v.y)-(v.x*u.y);
00108         return temp;
00109 }

bool POLYGON::IsLast  
 

Definition at line 20 of file polygon.cpp.

References NextPoly.

Referenced by AddPolygon(), CopyList(), DeleteList(), GetNext(), and SetNext().

00021 {
00022     if (NextPoly == NULL)
00023         return true;
00024     else
00025         return false;
00026 }

const bool POLYGON::POLYGON::operator== const POLYGON &    Poly const [inline]
 

Definition at line 46 of file polygon.h.

References VERTEX::coords, VERTEX::normal, numVertices, Texture, VERTEX::u, VERTEX::v, Vertex, VECTOR::x, VECTOR::y, and VECTOR::z.

00047         {
00048             float PolyDistance = -(Poly.Vertex[0].normal.x * Poly.Vertex[0].coords.x + Poly.Vertex[0].normal.y * Poly.Vertex[0].coords.y + Poly.Vertex[0].normal.z * Poly.Vertex[0].coords.z);
00049             float ThisDistance = -(Vertex[0].normal.x * Vertex[0].coords.x + Vertex[0].normal.y * Vertex[0].coords.y + Vertex[0].normal.z * Vertex[0].coords.z);
00050 
00051             if (numVertices == Poly.numVertices)
00052             {
00053                 if (PolyDistance == ThisDistance)
00054                 {
00055                     if (Vertex[0].normal == Poly.Vertex[0].normal)
00056                     {
00057                         for (int loop = 0; loop < numVertices; loop++)
00058                         {
00059                             if (Vertex[loop].u != Poly.Vertex[loop].u)
00060                                 return false;
00061                             if (Vertex[loop].v != Poly.Vertex[loop].v)
00062                                 return false;
00063                         }
00064 
00065                         if (Texture == Poly.Texture)
00066                             return true;
00067                     }
00068                 }
00069             }
00070             return false;
00071         }

void POLYGON::SetMyPosition int    newPosition [inline]
 

Definition at line 22 of file polygon.h.

References linkPosition.

00022 {linkPosition = newPosition;}

void POLYGON::SetNext POLYGON *    Poly
 

Definition at line 36 of file polygon.cpp.

References GetNext(), IsLast(), and NextPoly.

00037 {
00038     if (IsLast())
00039     {
00040         NextPoly = Poly;
00041         return;
00042     }
00043 
00044     // Insert the given list
00045     POLYGON* TempPoly = Poly;
00046 
00047     while (!TempPoly->IsLast())
00048         TempPoly = TempPoly->GetNext();
00049 
00050     TempPoly->SetNext(NextPoly);
00051     NextPoly = Poly;
00052 }

void POLYGON::SetNormal  
 

Definition at line 111 of file polygon.cpp.

References VERTEX::coords, maxPolygonVerts, VERTEX::normal, Vertex, VECTOR::x, VECTOR::y, and VECTOR::z.

Referenced by InitializeBullets(), InvertBrushPolygons(), InvertPolygon(), SetBrushPolygons(), SetGLWorld(), SplitPolygon(), and SplitTriangle().

00112 {
00113     VECTOR u;
00114     VECTOR v;
00115     VERTEX tempVertex;
00116     u = Vertex[1].coords - Vertex[0].coords;
00117     v = Vertex[2].coords - Vertex[0].coords;
00118     tempVertex.normal.x = (u.y*v.z)-(v.y*u.z);
00119     tempVertex.normal.y = (u.z*v.x)-(v.z*u.x);
00120     tempVertex.normal.z = (u.x*v.y)-(v.x*u.y);
00121     for (int loop = 0; loop < maxPolygonVerts; loop++)
00122     {
00123         Vertex[loop].normal = tempVertex.normal;
00124     }
00125 }


Member Data Documentation

int POLYGON::id
 

Definition at line 36 of file polygon.h.

Referenced by ResetBrushes().

int POLYGON::linkPosition
 

Definition at line 23 of file polygon.h.

Referenced by Compare(), GetMyPosition(), and SetMyPosition().

POLYGON* POLYGON::NextPoly
 

Definition at line 26 of file polygon.h.

Referenced by AddPolygon(), CopyList(), CSGAddition(), GetNext(), IsLast(), POLYGON(), and SetNext().

int POLYGON::numVertices
 

Definition at line 37 of file polygon.h.

Referenced by ClassifyPolygon(), CopyList(), InitializeBullets(), InvertBrushPolygons(), InvertPolygon(), POLYGON(), POLYGON::operator==(), RenderTexturedBrush(), RenderWireframeBrush(), ResetBrushes(), SplitPolygon(), and SplitTriangle().

int POLYGON::removable
 

Definition at line 38 of file polygon.h.

Referenced by InitializeBullets(), and SplitPolygon().

float POLYGON::Rotate
 

Definition at line 42 of file polygon.h.

Referenced by InitializeBullets(), RenderBSP(), and SetGLWorld().

float POLYGON::Scale[2]
 

Definition at line 40 of file polygon.h.

Referenced by InitializeBullets(), RenderBSP(), and SetGLWorld().

float POLYGON::Shift[2]
 

Definition at line 41 of file polygon.h.

Referenced by InitializeBullets(), RenderBSP(), and SetGLWorld().

unsigned int POLYGON::Texture
 

Definition at line 39 of file polygon.h.

Referenced by CopyList(), InitializeBullets(), POLYGON(), POLYGON::operator==(), RenderBSP(), RenderTexturedBrush(), SetBrushPolygons(), SetGLWorld(), and SplitPolygon().

VERTEX POLYGON::Vertex[maxPolygonVerts]
 

Definition at line 43 of file polygon.h.

Referenced by CheckForCollision(), CheckForParticleCollision(), ClassifyInvertedPortal(), ClassifyPolygon(), ClassifyPortal(), CopyList(), CreateDecal(), CreateLargePortal(), CreateLightmaps(), CSGClipPolygon(), FindCurrentLeaf(), GetEdgeIntersection(), GetNormal(), InitGL(), InitializeBullets(), InvertBrushPolygons(), InvertPolygon(), InvertPortals(), line_plane_collision(), POLYGON::operator==(), RenderBSP(), RenderTexturedBrush(), RenderWireframeBrush(), SetBrushPolygons(), SetGLWorld(), SetNormal(), SplitPolygon(), SplitPortal(), SplitTriangle(), and UpdateBullets().


The documentation for this class was generated from the following files:
Generated on Fri Dec 23 05:15:52 2005 for Constructive Solid Geometry by doxygen1.2.15