In file include/csengine/polyset.h:

## class csPolygonSet : public csObject, public csPolygonParentInt

> A PolygonSet class is a set of polygons (amazing, isn't it :-) A PolygonSet describes a set of polygons that form a convex and (probably) closed hull

## Inheritance:

### Public Fields

static long current_light_frame_number
  Current light frame number
csVector2* curve_texels
  Texture coords of curve vertices
csVector3* curve_vertices
  Curve vertices
csVector3 curves_center
  Tesselation parameter: Center of thing to determine distance from
float curves_scale
  scale param (the larger this param it, the more the curves are tesselated).
int draw_busy
  How many times are we busy drawing this polyset (recursive)
int max_curve_vertices
  Maximum number of vertices.
int num_curve_vertices
  Number of vertices.

### Public Methods

void AddCurve(csCurve* curve)
  Add a curve to this polygonset
void AddCurveVertex(csVector3& v, csVector2& t)
  Add a curve vertex
void AddPolygon(csPolygonInt* spoly)
  Add a polygon to this polygonset
int AddVertex(float x, float y, float z)
  Just add a new vertex to the polygonset
int AddVertex(const csVector3& v)
  Just add a new vertex to the polygonset
int AddVertexSmart(float x, float y, float z)
  Add a vertex but first check if there is already a vertex close to the wanted position
int AddVertexSmart(const csVector3& v)
  Add a vertex but first check if there is already a vertex close to the wanted position
void CamUpdate()
  Make sure the camera vertices are up-to-date to the current camera frame
void CreateBoundingBox()
  Create an oriented bounding box (currently not oriented yet@@@) for this polygon set
csPolygonSet()
  Construct a csPolygonSet
csVector2& CurveTexel(int i)
  Get the specified curve texture coordinate (texel)
csVector3& CurveVertex(int i)
  Get the specified curve vertex
csPolygonSetBBox* GetBoundingBox()
  Get the oriented bounding box created by CreateBoundingBox()
void GetCameraMinMaxZ(float& minz, float& mazx)
  Find the minimum and maximum Z values of all vertices in this polygon set (in camera space)
csCurve* GetCurve(int idx)
  Get the specified curve from this set
csCurve* GetCurve(char* name)
  Get the named curve from this set
csFog& GetFog()
  Return fog structure
csPolygonSet* GetNext()
  Get the next polygonset in its linked list
int GetNumCurves()
  Get the number of curves in this polygonset
int GetNumCurveVertices()
  Get the number of curve vertices
int GetNumPolygons()
  Get the number of polygons in this polygonset
int GetNumVertices()
  Return the number of vertices
csPolygon3D* GetPolygon(char* name)
  Get the named polygon from this set
csPolygonInt* GetPolygon(int idx)
  Get the specified polygon from this set
csSector* GetSector()
  Return the sector that this polygonset belongs to
csFrustrumList* GetShadows(csVector3& origin)
  Return a list of shadow frustrums which extend from this polygon set
bool HasFog()
  Return true if this has fog
csVector2* IntersectCameraZPlane(float z, csVector2* clipper, int num_clip, int& num_pts)
  Intersect this polygon set in camera space with a polygon which coincides with plane Zc = (a plane parallel to the view plane) and return a new polygon which is the intersection (as a 2D polygon with z not given)
virtual csPolygon3D* IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)
  Intersect world-space segment with polygons of this set
bool IsBSP()
  Return true if there is a BSP tree used in this sector
csPolygon3D* NewPolygon(csTextureHandle* texture)
  Create a new polygon in this polygonset and add it
virtual void Prepare()
  Prepare all polygons for use
void SetNext(csPolygonSet* next)
  Set the next polygonset in its linked list
void SetSector(csSector* sector)
  Set the sector that this polygonset belongs to
void UpdateTransformation(const csVector3& trans)
  Translate with the given vector if needed
void UpdateTransformation(const csCamera& c)
  Transform to the given camera if needed
void UseBSP()
  Enable the optional BSP tree
csVector3& Vcam(int idx)
  Return the camera space vector for the vertex
csVector3& Vobj(int idx)
  Return the object space vector for the vertex
csVector3& Vwor(int idx)
  Return the world space vector for the vertex
virtual ~csPolygonSet()
  Delete all contents of this polygonset (vertices, polygons, curves, and BSP tree)

### Protected Fields

csPolygonSetBBox* bbox
  Optional oriented bounding box.
csBspTree* bsp
  Optional bsp tree.
csVector3* cam_verts
  Vertices in camera space.
csTransformedSet cam_verts_set
  Camera space vertices.
csCurve** curves
  Table of ptr to curves forming the outside of the set
long light_frame_number
  Light frame number
int max_curves
  Maximum number of curves in 'curves' array.
int max_polygon
  Maximum number of polygons in 'polygon' array.
csPolygonSet* next
  PolygonSets are linked either in a csWorld object or in another PolygonSet (Thing in csSector for example)
int num_curves
  Number of curves used.
int num_polygon
  Number of polygons used.
csVector3* obj_verts
  Vertices in object space.
csPolygonInt** polygons
  Table of ptr to polygons forming the outside of the set
csSector* sector
  csSector where this polyset belongs (pointer to 'this' if it is a sector).
csVector3* wor_verts
  Vertices in world space.

### Protected Methods

void DrawOnePolygon(csPolygon3D* p, csPolygon2D* poly, csRenderView* d, bool use_z_buf)
  Draw one 3D/2D polygon combination
void DrawPolygonArray(csPolygonInt** polygon, int num, csRenderView* rview, bool use_z_buf)
  Draw the given array of polygons in the current csPolygonSet
void* TestQueuePolygonArray(csPolygonInt** polygon, int num, csRenderView* d, csPolygon2DQueue* poly_queue)
  Test a number of polygons against the c-buffer and insert them to the c-buffer if visible and also add them to a queue

### Private Fields

csFog fog
  Fog information

### Inherited from csObject:

### Public Methods

CS_ID GetID()
csObject* GetObj(const csIdType& objtype)
virtual csObject* GetObjectParent()
void ObjAdd(csObject* obj)
csObjIterator ObjGet(const csIdType& objtype)
void ObjRelease(csObject* obj)
void ObjRemove(csObject* obj)

### Private Fields

CS_ID csid_value
csObjTree* objtree

### Private Methods

virtual void SetObjectParent(csObject* parent)

### Inherited from csBase:

### Inherited from csPolygonParentInt:

## Documentation

> A PolygonSet class is a set of polygons (amazing, isn't it :-) A PolygonSet describes a set of polygons that form a convex and (probably) closed hull. All polygons in a set share vertices from the same pool.

> A recent extension also allows PolygonSets that are not convex by adding an optional BSP tree. This BSP tree is only useful if the PolygonSet is concave. Otherwise the tree is wasted.

> Every polygon in the set has a visible and an invisible face; if the vertices of the polygon are ordered clockwise then the polygon is visible. Using this feature it is possible to define two kinds of PolygonSets: in one kind the polygons are oriented such that they are visible from within the hull. In other words, the polygons form a sort of container or room where the camera can be located. We call this kind of PolygonSet a csSector (a subclass of PolygonSet). In another kind the polygons are oriented such that they are visible from the outside. We call this kind of PolygonSet a Thing (another subclass of PolygonSet).

> Things and csSectors have many similarities. That's why the PolygonSet class was created: to exploit these similarities. However, there are some important differences between Things and csSectors:

> - Currently, only things can move. This means that the object space coordinates of a csSector are ALWAYS equal to the world space coordinates. It would be possible to allow moveable csSectors but I don't how this should be integrated into an easy model of the world.
> - Things do not require portals but can use them.

`csPolygonSet* next`
  PolygonSets are linked either in a csWorld object or in another PolygonSet (Thing in csSector for example)

`csVector3* wor_verts`
  Vertices in world space.

`csVector3* obj_verts`
  Vertices in object space.

`csVector3* cam_verts`
  Vertices in camera space.

`csTransformedSet cam_verts_set`
  Camera space vertices.

`csPolygonInt** polygons`
  Table of ptr to polygons forming the outside of the set

`int num_polygon`
  Number of polygons used.

`int max_polygon`
  Maximum number of polygons in 'polygon' array.

`csCurve** curves`
  Table of ptr to curves forming the outside of the set

`int num_curves`
  Number of curves used.

`int max_curves`
  Maximum number of curves in 'curves' array.

`csSector* sector`
  csSector where this polyset belongs (pointer to 'this' if it is a sector).

`csBspTree* bsp`
  Optional bsp tree.

`csPolygonSetBBox* bbox`
  Optional oriented bounding box.

`long light_frame_number`
  Light frame number. Using this number one can see if gouraud shaded vertices have been initialized already.

`void DrawOnePolygon(csPolygon3D* p, csPolygon2D* poly, csRenderView* d, bool use_z_buf)`
  Draw one 3D/2D polygon combination. The 2D polygon is the transformed and clipped version of the 3D polygon.

`void DrawPolygonArray(csPolygonInt** polygon, int num, csRenderView* rview, bool use_z_buf)`
  Draw the given array of polygons in the current csPolygonSet. This function is called by subclasses of csPolygonSet (csSector and csThing currently).

`void* TestQueuePolygonArray(csPolygonInt** polygon, int num, csRenderView* d, csPolygon2DQueue* poly_queue)`
  Test a number of polygons against the c-buffer and insert them to the c-buffer if visible and also add them to a queue

`csFog fog`
  Fog information

`static long current_light_frame_number`
  Current light frame number. This is used for seeing if gouraud shading should be recalculated for this polygonset. If there is a mismatch between the frame number of this set and the global number then the gouraud shading is not up-to-date.

`int draw_busy`
  How many times are we busy drawing this polyset (recursive). This is an important variable as it indicates to 'new_transformation' which set of camera vertices it should use.

`csVector3 curves_center`
  Tesselation parameter: Center of thing to determine distance from

`float curves_scale`
  scale param (the larger this param it, the more the curves are tesselated).

`csVector3* curve_vertices`
  Curve vertices

`csVector2* curve_texels`
  Texture coords of curve vertices

`int num_curve_vertices`
  Number of vertices.

`int max_curve_vertices`
  Maximum number of vertices.

`csPolygonSet()`
  Construct a csPolygonSet

`virtual ~csPolygonSet()`
  Delete all contents of this polygonset (vertices, polygons, curves, and BSP tree)

`virtual void Prepare()`
  Prepare all polygons for use. This function MUST be called AFTER the texture manager has been prepared. This function is normally called by csWorld::Prepare() so you only need to worry about this function when you add sectors or things later.

`int AddVertex(const csVector3& v)`
  Just add a new vertex to the polygonset

`int AddVertex(float x, float y, float z)`
  Just add a new vertex to the polygonset

`int AddVertexSmart(const csVector3& v)`
  Add a vertex but first check if there is already a vertex close to the wanted position. In that case don't add a new vertex but return the index of the old one.

`int AddVertexSmart(float x, float y, float z)`
  Add a vertex but first check if there is already a vertex close to the wanted position. In that case don't add a new vertex but return the index of the old one.

`csVector3& Vwor(int idx)`
  Return the world space vector for the vertex

`csVector3& Vobj(int idx)`
  Return the object space vector for the vertex

`csVector3& Vcam(int idx)`
  Return the camera space vector for the vertex. Make sure you recently called CamUpdate(). Otherwise it is possible that this coordinate will not be valid.

`void CamUpdate()`
  Make sure the camera vertices are up-to-date to the current camera frame

`int GetNumVertices()`
  Return the number of vertices

`void AddPolygon(csPolygonInt* spoly)`
  Add a polygon to this polygonset

`csPolygon3D* NewPolygon(csTextureHandle* texture)`
  Create a new polygon in this polygonset and add it

`int GetNumPolygons()`
  Get the number of polygons in this polygonset

`csPolygonInt* GetPolygon(int idx)`
  Get the specified polygon from this set

`csPolygon3D* GetPolygon(char* name)`
  Get the named polygon from this set

`void AddCurve(csCurve* curve)`
  Add a curve to this polygonset

`int GetNumCurves()`
  Get the number of curves in this polygonset

`csCurve* GetCurve(int idx)`
  Get the specified curve from this set

`csCurve* GetCurve(char* name)`
  Get the named curve from this set

`int GetNumCurveVertices()`
  Get the number of curve vertices

`csVector3& CurveVertex(int i)`
  Get the specified curve vertex

`csVector2& CurveTexel(int i)`
  Get the specified curve texture coordinate (texel)

`void AddCurveVertex(csVector3& v, csVector2& t)`
  Add a curve vertex

`void UseBSP()`
  Enable the optional BSP tree. This should be done AFTER all polygons and vertices have been added and all polygons are correctly initialized (textures and planes).

`bool IsBSP()`
  Return true if there is a BSP tree used in this sector

`virtual csPolygon3D* IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)`
  Intersect world-space segment with polygons of this set. Return polygon it intersects with (or NULL) and the intersection point in world coordinates.

  If 'pr' != NULL it will also return a value between 0 and 1 indicating where on the 'start'-'end' vector the intersection happened.

`void UpdateTransformation(const csCamera& c)`
  Transform to the given camera if needed. This function works via the transformation manager and will only transform if needed.

`void UpdateTransformation(const csVector3& trans)`
  Translate with the given vector if needed. This function works via the transformation manager and will only translate if needed.

`csPolygonSet* GetNext()`
  Get the next polygonset in its linked list

`void SetNext(csPolygonSet* next)`
  Set the next polygonset in its linked list

`void SetSector(csSector* sector)`
  Set the sector that this polygonset belongs to. This is either the polygonset itself if it is a sector or else the sector that this thing is in.

`csSector* GetSector()`
  Return the sector that this polygonset belongs to

`csFrustrumList* GetShadows(csVector3& origin)`
  Return a list of shadow frustrums which extend from this polygon set. The origin is the position of the light. Note that this function uses camera space coordinates and thus assumes that this polygon set is transformed to the origin of the light.

`void CreateBoundingBox()`
  Create an oriented bounding box (currently not oriented yet@@@) for this polygon set. This function will add the vertices for the bounding box to the set itself so that they will get translated together with the other vertices. The indices of the vertices are added to the csPolygonSetBBox structure which is returned here. Note that this creation is done in object space. The newly added vertices will not have been translated to world/camera space yet.

`csPolygonSetBBox* GetBoundingBox()`
  Get the oriented bounding box created by CreateBoundingBox()

`bool HasFog()`
  Return true if this has fog

`csFog& GetFog()`
  Return fog structure

`void GetCameraMinMaxZ(float& minz, float& mazx)`
  Find the minimum and maximum Z values of all vertices in this polygon set (in camera space). This is used for planed fog.

`csVector2* IntersectCameraZPlane(float z, csVector2* clipper, int num_clip, int& num_pts)`
  Intersect this polygon set in camera space with a polygon which coincides with plane Zc = (a plane parallel to the view plane) and return a new polygon which is the intersection (as a 2D polygon with z not given). This function assumes that the polygon set is convex (so it can in general not be used for polygon sets which use a BSP tree) and gives unexpected results otherwise. Delete the returned polygon with 'delete []' when ready.

Direct child classes:
  csThing
  csSector

alphabetic index hierarchy of classes

this page has been generated automatically by doc++

(c)opyright by Malte Zöckler, Roland Wunderling
contact: doc++@zib.de