In file include/csengine/polygon.h:

class csPolygon3D : public csObject, public csPolygonInt

This is our main 3D polygon class

Inheritance:


Public Fields

static int def_mipmap_size
Option variable: shadow mipmap size
static bool do_force_recalc
Option variable: force lightmap recalculation?
static bool do_not_force_recalc
Option variable: inhibit lightmap recalculation?
bool dont_draw
If this flag is true then this polygon will never be drawn

Public Methods

void AddLightpatch(csLightPatch *lp)
Add a light patch to the light patch list
int AddVertex(const csVector3& v)
Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet
int AddVertex(float x, float y, float z)
Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet
int AddVertex(int v)
Add a vertex from the container (polygonset) to the polygon
void CacheLightMaps(csPolygonSet* owner, int index)
Call after calling InitLightMaps and CalculateLighting to cache the calculated lightmap to the level archive
void CalculateLighting(csLightView* lview)
Check visibility of this polygon with the given csLightView and fill the lightmap if needed (this function calls FillLightMap ())
void CamUpdate()
Before calling a series of Vcam() you should call CamUpdate() first to make sure that the camera vertex set is up-to-date
bool CheckFlags(ULong to_check)
Check if all the given flags are set.
int Classify(csPolygonInt* spoly)
Classify a polygon with regards to this one (in world space)
bool ClipFrustrum(csVector3& center, csVector3* frustrum, int num_frustrum, bool mirror, csVector3** new_frustrum, int* new_num_frustrum)
See if a polygon is visible from the given center (in world space using backface culling) and then clip against the frustrum and return a new frustrum (in camera space with the frustrum center at (0,0,0))
bool ClipPoly(csVector3* frustrum, int num_frustrum, bool mirror, csVector3** dest, int* num_dest)
Clip a polygon against a frustrum in camera space
void ClipPolyPlane(csVector3* verts, int* num, bool mirror, csVector3& v1, csVector3& v2)
Clip a polygon against a plane (in camera space)
bool ClipToPlane(csPlane* portal_plane, const csVector3& v_w2c, csVector3*& pverts, int& num_verts, bool cw = true)
Clip this camera space polygon to the given plane
void CreateLightMaps(IGraphics3D* g3d)
Prepare the lightmaps for use (different mipmap levels)
csPolygon3D(csPolygon3D& poly)
Construct a new polygon and copy from the given polygon
csPolygon3D(csTextureHandle* texture)
Construct a new polygon with the given name and texture
bool DoPerspective(const csTransform& trans, csVector3* source, int num_verts, csPolygon2D* dest, csVector2* orig_triangle, bool mirror)
This is the link between csPolygon3D and csPolygon2D (see below for more info about csPolygon2D)
void FillLightMap(csLightView& lview)
Fill the lightmap of this polygon according to the given light and the frustrum
void Finish()
After the plane normal and the texture matrices have been set up this routine makes some needed pre-calculations for this polygon
int GetAlpha()
Get the alpha transparency value for this polygon
float GetCosinusFactor()
Get the cosinus factor
ULong GetFlags()
Get flags.
csColor& GetFlatColor()
Get the flat color for this polygon.
csGouraudShaded* GetGouraudInfo()
This is a conveniance function to get the gouraud information structure
csLightMapped* GetLightMapInfo()
This is a conveniance function to get the lightmap information structure
csLightPatch* GetLightpatches()
Get the list of light patches for this polygon
csPolygonSet* GetParent()
Get the polygonset (container) that this polygons belongs to
csPolyPlane* GetPlane()
Return the plane of this polygon
csPlane* GetPolyPlane()
Return the world-space plane of this polygon
csPortal* GetPortal()
Get the portal structure (if there is one)
csSector* GetSector()
Get the sector that this polygon belongs to
csTextureHandle* GetTexture()
Get the texture
ITextureHandle* GetTextureHandle()
Get the texture handle for the texture manager
int GetTextureType()
Short-hand to get the texture type from the csPolygonTextureType structure
csPolygonTextureType* GetTextureTypeInfo()
Get the general texture type information structure
int GetType()
Return 1 to indicate to the BSP tree routines that this is a csPolygon3D
csPolygon3D* GetUnsplitPolygon()
Return the pointer to the original polygon (before any BSP splits).
csPolyIndexed& GetVertices()
Get the vertices
void InitLightMaps(csPolygonSet* owner, bool do_cache, int index)
Initialize the lightmaps for this polygon
bool IntersectRay(const csVector3& start, const csVector3& end)
Intersect world-space ray with this polygon
bool IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)
Intersect world-space segment with this polygon
bool IsDirty()
Return true if polygon is dirty for dynamic lights.
bool IsTransparent()
Return true if this polygon or the texture it uses is transparent
void MakeCleanDynamicLights()
Make clean again.
void MakeDirtyDynamicLights()
A dynamic light has changed (this can be either an intensity/color change of a pseudo-dynamic light or else a real dynamic light change)
bool MarkRelevantShadowFrustrums(csLightView& lview, csPlane& plane)
Check all shadow frustrums and mark all relevant ones
void ObjectToWorld(const csReversibleTransform& t)
Transform the plane of this polygon from object space to world space
void Reset()
Clear the polygon (remove all vertices)
void ResetFlatColor()
Reset flat color (i.e. use texturing again).
bool SamePlane(csPolygonInt* p)
Return true if this polygon and the given polygon are on the same plane
void SetAlpha(int da)
Set the alpha transparency value for this polygon (only if it is a portal)
void SetCosinusFactor(float f)
Set the cosinus factor
void SetCSPortal(csSector* sector)
If the polygon is a portal this will set the sector that this portal points to
void SetFlags(ULong mask, ULong value)
Set all flags with the given mask.
void SetFlatColor(float r, float g, float b)
Set the flat color for this polygon.
void SetFlatColor(csColor& fc)
Set the flat color for this polygon.
void SetParent(csPolygonSet* poly_set)
Set the polygonset (container) that this polygon belongs to
void SetPortal(csPortal* prt)
Set a pre-created portal on this polygon
void SetSector(csSector* sector)
Set the sector that this polygon belongs to
void SetTexture(csTextureHandle* texture)
Set the texture for this polygon
void SetTextureSpace(csVector3& v_orig, csVector3& v1, float len1)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureSpace(csPolygon3D* copy_from)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureSpace(csMatrix3& tx_matrix, csVector3& tx_vector)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureSpace(csPolyPlane* plane)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1, float x2, float y2, float z2, float len2)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized
void SetTextureType(int type)
Set type of texturing to use for this polygon (one of the POLYTXT_??? flags)
void SetWarp(const csTransform& t)
Set the warping transformation for the portal
void SetWarp(const csMatrix3& m_w, const csVector3& v_w_before, const csVector3& v_w_after)
Set the warping transformation for the portal
void SplitWithPlane(csPolygonInt** front, csPolygonInt** back, csPlane& plane)
Split this polygon with the given plane (A,B,C,D) and return the two resulting new polygons in 'front' and 'back'
void UnlinkLightpatch(csLightPatch* lp)
Unlink a light patch from the light patch list
void UpdateVertexLighting(csLight* light, const csColor& lcol, bool dynamic, bool reset)
Update vertex lighting for this polygon
csVector3& Vcam(int idx)
'idx' is a local index into the vertices table of the polygon
csVector3& Vobj(int idx)
'idx' is a local index into the vertices table of the polygon
csVector3& Vwor(int idx)
'idx' is a local index into the vertices table of the polygon
virtual ~csPolygon3D()
Delete everything related to this polygon

Private Fields

bool delete_plane
If 'delete_plane' is true this plane was allocated by this Polygon and it should also be deleted by it
bool delete_portal
If 'delete_portal' is true this portal was allocated by this Polygon and it should also be deleted by it
bool delete_tex_info
If 'delete_tex_info' is true this polygon is responsible for cleaning the csPolyTextures
ULong flags
Set of flags
csPolygonLightInfo light_info
General lighting information for this polygon
csPolygon3D* orig_poly
The original polygon
csPolyPlane* plane
The PolygonPlane for this polygon
csPolygonSet* poly_set
The following two fields are somewhat related
csPortal* portal
If not-null, this polygon is a portal
csSector* sector
The csSector that this polygon is in.
csPolygonTextureType* txt_info
Texture type specific information for this polygon
csPolyIndexed vertices
A table of indices into the vertices of the parent csPolygonSet (container).

Private Methods

void ComputeNormal()
Precompute the plane normal
void PlaneNormal(float* yz, float* zx, float* xy)
Return twice the signed area of the polygon in world space coordinates using the yz, zx, and xy components

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 csPolygonInt:


Documentation

This is our main 3D polygon class. Polygons are used to construct the outer hull of sectors and the faces of 3D things. Polygons can be transformed in 3D (usually they are transformed so that the camera position is at (0,0,0) and the Z-axis is forward). Polygons cannot be transformed in 2D. That's what csPolygon2D is for. It is possible to convert a csPolygon3D to a csPolygon2D though, at which point processing continues with the csPolygon2D object.

Polygons have a texture and lie on a plane. The plane does not define the orientation of the polygon but is derived from it. The plane does define how the texture is scaled and translated accross the surface of the polygon (in case we are talking about lightmapped polygons, gouraud shaded polygons have u,v coordinates at every vertex). Several planes can be shared for different polygons. As a result of this their textures will be correctly aligned.

If a polygon is part of a sector it can be a portal to another sector. A portal-polygon is a see-through polygon that defines a view to another sector. Normally the texture for a portal-polygon is not drawn unless the texture is filtered in which case it is drawn on top of the other sector.

csPolyIndexed vertices
A table of indices into the vertices of the parent csPolygonSet (container).

csPolygonSet* poly_set
The following two fields are somewhat related. 'poly_set' is the real parent (container) of this polygon. It is either a 3D thing or a sector. 'sector' is always a sector. If this polygon belongs to a sector ('poly_set' is a sector) then 'sector' will have the same value as 'poly_set'. If this polygon belongs to a thing then 'sector' will be set to the sector containing the thing.

@@@ Note! We have to reconsider this. If a thing moves to another sector we would have to update this variable for all polygons of the thing.

csSector* sector
The csSector that this polygon is in.

csPortal* portal
If not-null, this polygon is a portal

bool delete_portal
If 'delete_portal' is true this portal was allocated by this Polygon and it should also be deleted by it

csPolyPlane* plane
The PolygonPlane for this polygon

bool delete_plane
If 'delete_plane' is true this plane was allocated by this Polygon and it should also be deleted by it

csPolygonLightInfo light_info
General lighting information for this polygon

csPolygonTextureType* txt_info
Texture type specific information for this polygon. Can be either csLightMapped or csGouraudShaded.

ULong flags
Set of flags

bool delete_tex_info
If 'delete_tex_info' is true this polygon is responsible for cleaning the csPolyTextures

csPolygon3D* orig_poly
The original polygon. This is useful when a BSP tree has split a polygon. In that case, orig_poly will indicate the original polygon that this polygon was split from. If not split then this will be NULL.

void ComputeNormal()
Precompute the plane normal. Normally this is done automatically by set_texture_space but if needed you can call this function again when something has changed.

void PlaneNormal(float* yz, float* zx, float* xy)
Return twice the signed area of the polygon in world space coordinates using the yz, zx, and xy components. In effect this calculates the (P,Q,R) or the plane normal of the polygon.

static bool do_force_recalc
Option variable: force lightmap recalculation?

static bool do_not_force_recalc
Option variable: inhibit lightmap recalculation?

static int def_mipmap_size
Option variable: shadow mipmap size

bool dont_draw
If this flag is true then this polygon will never be drawn. This is useful for polygons which have been split. The original unsplit polygon is still kept because it holds the shared information about the lighted texture and lightmaps (all split children refer to the original polygon for that).

csPolygon3D(csTextureHandle* texture)
Construct a new polygon with the given name and texture

csPolygon3D(csPolygon3D& poly)
Construct a new polygon and copy from the given polygon. Note! Several fields will reflect that a copy was made! New polytextures will be allocated. This is mainly used when a BSP tree splits a polygon.

virtual ~csPolygon3D()
Delete everything related to this polygon. Less is deleted if this polygon is a copy of another one (because some stuff is shared).

void SetTextureType(int type)
Set type of texturing to use for this polygon (one of the POLYTXT_??? flags). POLYTXT_LIGHTMAP is default. This function is guaranteed not to do anything if the type is already correct.

int GetTextureType()
Short-hand to get the texture type from the csPolygonTextureType structure

csPolygonTextureType* GetTextureTypeInfo()
Get the general texture type information structure

csLightMapped* GetLightMapInfo()
This is a conveniance function to get the lightmap information structure. If this polygon is gouraud shaded it will return NULL.

csGouraudShaded* GetGouraudInfo()
This is a conveniance function to get the gouraud information structure. If this polygon is lightmapped it will return NULL.

void SetFlags(ULong mask, ULong value)
Set all flags with the given mask.

ULong GetFlags()
Get flags.

bool CheckFlags(ULong to_check)
Check if all the given flags are set.

void Reset()
Clear the polygon (remove all vertices)

int AddVertex(int v)
Add a vertex from the container (polygonset) to the polygon

int AddVertex(const csVector3& v)
Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet. If so, return that index. Otherwise add the new vertex.

int AddVertex(float x, float y, float z)
Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet. If so, return that index. Otherwise add the new vertex.

void Finish()
After the plane normal and the texture matrices have been set up this routine makes some needed pre-calculations for this polygon. It will create a texture space bounding box that is going to be used for lighting and the texture cache. Then it will allocate the light map tables for this polygons. You also need to call this function if you make a copy of a polygon (using the copy constructor) or if you change the vertices in a polygon.

csColor& GetFlatColor()
Get the flat color for this polygon.

void SetFlatColor(float r, float g, float b)
Set the flat color for this polygon.

void SetFlatColor(csColor& fc)
Set the flat color for this polygon.

void ResetFlatColor()
Reset flat color (i.e. use texturing again).

void SetCSPortal(csSector* sector)
If the polygon is a portal this will set the sector that this portal points to. If this polygon has no portal a Crystal Space portal will be created.

void SetPortal(csPortal* prt)
Set a pre-created portal on this polygon

csPortal* GetPortal()
Get the portal structure (if there is one)

void SetParent(csPolygonSet* poly_set)
Set the polygonset (container) that this polygon belongs to

csPolygonSet* GetParent()
Get the polygonset (container) that this polygons belongs to

csSector* GetSector()
Get the sector that this polygon belongs to

void SetSector(csSector* sector)
Set the sector that this polygon belongs to

csPolyPlane* GetPlane()
Return the plane of this polygon. This function returns a 3D engine type csPolyPlane which encapsulates object, world, and camera space planes as well as the texture transformation.

csPlane* GetPolyPlane()
Return the world-space plane of this polygon

csPolyIndexed& GetVertices()
Get the vertices

void SetWarp(const csTransform& t)
Set the warping transformation for the portal. If there is no portal this function does nothing.

void SetWarp(const csMatrix3& m_w, const csVector3& v_w_before, const csVector3& v_w_after)
Set the warping transformation for the portal. If there is no portal this function does nothing.

csVector3& Vwor(int idx)
'idx' is a local index into the vertices table of the polygon. This index is translated to the index in the parent container and a reference to the vertex in world-space is returned.

csVector3& Vobj(int idx)
'idx' is a local index into the vertices table of the polygon. This index is translated to the index in the parent container and a reference to the vertex in object-space is returned.

csVector3& Vcam(int idx)
'idx' is a local index into the vertices table of the polygon. This index is translated to the index in the parent container and a reference to the vertex in camera-space is returned.

void CamUpdate()
Before calling a series of Vcam() you should call CamUpdate() first to make sure that the camera vertex set is up-to-date

void SetTexture(csTextureHandle* texture)
Set the texture for this polygon. This texture handle will only be used as soon as 'Finish()' is called. So you can safely wait preparing the textures until finally csWorld::Prepare() is called (which in the end calls Finish() for every polygon).

csTextureHandle* GetTexture()
Get the texture

ITextureHandle* GetTextureHandle()
Get the texture handle for the texture manager

bool IsTransparent()
Return true if this polygon or the texture it uses is transparent

float GetCosinusFactor()
Get the cosinus factor. This factor is used for lighting.

void SetCosinusFactor(float f)
Set the cosinus factor. This factor is used for lighting.

void SetAlpha(int da)
Set the alpha transparency value for this polygon (only if it is a portal). Not all renderers support all possible values. 0, 25, 50, 75, and 100 will always work but other values may give only the closest possible to one of the above.

int GetAlpha()
Get the alpha transparency value for this polygon

void SetTextureSpace(csPolygon3D* copy_from)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

This version copies the plane from the other polygon. The plane is shared with that other plane and this allows the engine to do some optimizations. This polygon is not responsible for cleaning this plane.

void SetTextureSpace(csPolyPlane* plane)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

This version takes the given plane. Using this function you can use the same plane for several polygons. This polygon is not responsible for cleaning this plane.

void SetTextureSpace(csVector3& v_orig, csVector3& v1, float len1)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

Calculate the matrix using two vertices (which are preferably on the plane of the polygon and are possibly (but not necessarily) two vertices of the polygon). The first vertex is seen as the origin and the second as the u-axis of the texture space coordinate system. The v-axis is calculated on the plane of the polygon and orthogonal to the given u-axis. The length of the u-axis and the v-axis is given as the 'len1' parameter.

For example, if 'len1' is equal to 2 this means that texture will be tiled exactly two times between vertex 'v_orig' and 'v1'. I hope this explanation is clear since I can't seem to make it any clearer :-)

void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

Calculate the matrix using two vertices (which are preferably on the plane of the polygon and are possibly (but not necessarily) two vertices of the polygon). The first vertex is seen as the origin and the second as the u-axis of the texture space coordinate system. The v-axis is calculated on the plane of the polygon and orthogonal to the given u-axis. The length of the u-axis and the v-axis is given as the 'len1' parameter.

For example, if 'len1' is equal to 2 this means that texture will be tiled exactly two times between vertex 'v_orig' and 'v1'. I hope this explanation is clear since I can't seem to make it any clearer :-)

void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1, float x2, float y2, float z2, float len2)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

Use 'v1' and 'len1' for the u-axis and 'v2' and 'len2' for the v-axis.

void SetTextureSpace(csMatrix3& tx_matrix, csVector3& tx_vector)
One of the SetTextureSpace functions should be called after adding all vertices to the polygon (not before) and before doing any processing on the polygon (not after)! It makes sure that the plane normal is correctly computed and the texture and plane are correctly initialized.

The most general function. With these you provide the matrix directly.

void CreateLightMaps(IGraphics3D* g3d)
Prepare the lightmaps for use (different mipmap levels). This function also converts the lightmaps to the correct format required by the 3D driver. This function does NOT create the first lightmap. This is done by the precalculated lighting process (using CalculateLighting()).

csPolygon3D* GetUnsplitPolygon()
Return the pointer to the original polygon (before any BSP splits).

void MakeDirtyDynamicLights()
A dynamic light has changed (this can be either an intensity/color change of a pseudo-dynamic light or else a real dynamic light change)

bool IsDirty()
Return true if polygon is dirty for dynamic lights.

void MakeCleanDynamicLights()
Make clean again.

void UnlinkLightpatch(csLightPatch* lp)
Unlink a light patch from the light patch list. Warning! This function does not test if the light patch is really on the list!

void AddLightpatch(csLightPatch *lp)
Add a light patch to the light patch list

csLightPatch* GetLightpatches()
Get the list of light patches for this polygon

bool ClipPoly(csVector3* frustrum, int num_frustrum, bool mirror, csVector3** dest, int* num_dest)
Clip a polygon against a frustrum in camera space. The frustrum is defined with (0,0,0) as one of the points of the plane.

If the frustrum == NULL then it is considered infinite. This function returns false (and does not allocate the clipped polygon) if the polygon is completely clipped away. Otherwise it will allocated a new array of csVector3 in dest.

void ClipPolyPlane(csVector3* verts, int* num, bool mirror, csVector3& v1, csVector3& v2)
Clip a polygon against a plane (in camera space). The plane is defined as going through v1, v2, and (0,0,0). The 'verts' array is modified and 'num' is also modified if needed.

bool ClipFrustrum(csVector3& center, csVector3* frustrum, int num_frustrum, bool mirror, csVector3** new_frustrum, int* new_num_frustrum)
See if a polygon is visible from the given center (in world space using backface culling) and then clip against the frustrum and return a new frustrum (in camera space with the frustrum center at (0,0,0)). This function returns false if the polygon is completely clipped away or if it is not visible. No new_frustrum will be allocated in that case. If 'mirror' is true the given frustrum is mirrored (vertices in anti-clockwise order). This function correctly handles that case and will return a new frustrum that is also mirrored.

void InitLightMaps(csPolygonSet* owner, bool do_cache, int index)
Initialize the lightmaps for this polygon. Should be called before calling CalculateLighting() and before calling CacheLightMaps().

This function will try to read the lightmap from the cache in the level archive. If do_cache == false this function will not try to read the lightmap from the cache. Index is the index of this polygon into the containing object. This is used to identify the lightmap data on disk.

void FillLightMap(csLightView& lview)
Fill the lightmap of this polygon according to the given light and the frustrum. The light is given in world space coordinates. The view frustrum is given in camera space (with (0,0,0) the origin of the frustrum). The camera space used is just world space translated so that the center of the light is at (0,0,0). If the lightmaps were cached in the level archive this function will do nothing.

void UpdateVertexLighting(csLight* light, const csColor& lcol, bool dynamic, bool reset)
Update vertex lighting for this polygon. Only works if the polygon uses gouraud shading or is flat-shaded. 'dynamic' is true for a dynamic light. 'reset' is true if the light values need to be reset to 0. 'lcol' is the color of the light. It is given seperately because the color of the light may be modified by portals and other effects.
'light' can be NULL in which case this function is useful for resetting dynamic light values to the static lights ('reset' must be equal to true then).

bool MarkRelevantShadowFrustrums(csLightView& lview, csPlane& plane)
Check all shadow frustrums and mark all relevant ones. A shadow frustrum is relevant if it is (partially) inside the light frustrum and if it is not obscured by other shadow frustrums. In addition to the checking above this routine will return false if it can find a shadow frustrum which totally obscures the light frustrum. In this case it makes no sense to continue lighting the polygon.
This function will also discard all shadow frustrums which start at the same plane as the given plane.

void CalculateLighting(csLightView* lview)
Check visibility of this polygon with the given csLightView and fill the lightmap if needed (this function calls FillLightMap ()). This function will also traverse through a portal if so needed.

void CacheLightMaps(csPolygonSet* owner, int index)
Call after calling InitLightMaps and CalculateLighting to cache the calculated lightmap to the level archive. This function does nothing if the cached lightmap was already up-to-date.

void ObjectToWorld(const csReversibleTransform& t)
Transform the plane of this polygon from object space to world space. This is mainly used for things since sectors currently have identical object and world space coordinates.

bool ClipToPlane(csPlane* portal_plane, const csVector3& v_w2c, csVector3*& pverts, int& num_verts, bool cw = true)
Clip this camera space polygon to the given plane. 'plane' can be NULL in which case no clipping happens.

If this function returns false then the polygon is not visible (backface culling, no visible vertices, ...) and 'verts' will be NULL. Otherwise this function will return true and 'verts' will point to the new clipped polygon (this is a pointer to a static table of vertices. WARNING! Because of this you cannot do new ClipToPlane calls until you have processed the 'verts' array!).

If 'cw' is true the polygon has to be oriented clockwise in order to be visible. Otherwise it is the other way around.

bool DoPerspective(const csTransform& trans, csVector3* source, int num_verts, csPolygon2D* dest, csVector2* orig_triangle, bool mirror)
This is the link between csPolygon3D and csPolygon2D (see below for more info about csPolygon2D). It should be used after the parent container has been transformed from world to camera space. It will fill the given csPolygon2D with a perspective corrected polygon that is also clipped to the view plane (Z=SMALL_Z). If all vertices are behind the view plane the polygon will not be visible and it will return false. 'do_perspective' will also do back-face culling and returns false if the polygon is not visible because of this. If the polygon is deemed to be visible it will return true.

int Classify(csPolygonInt* spoly)
Classify a polygon with regards to this one (in world space). If this poly is on same plane as this one it returns POL_SAME_PLANE. If this poly is completely in front of the given poly it returnes POL_FRONT. If this poly is completely back of the given poly it returnes POL_BACK. Otherwise it returns POL_SPLIT_NEEDED.

void SplitWithPlane(csPolygonInt** front, csPolygonInt** back, csPlane& plane)
Split this polygon with the given plane (A,B,C,D) and return the two resulting new polygons in 'front' and 'back'. The new polygons will mimic the behaviour of the parent polygon as good as possible. This function is mainly used by the BSP splitter.

bool SamePlane(csPolygonInt* p)
Return true if this polygon and the given polygon are on the same plane. If their planes are shared this is automatically the case. Otherwise this function will check their respective plane equations to test for equality.

int GetType()
Return 1 to indicate to the BSP tree routines that this is a csPolygon3D

bool IntersectSegment(const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL)
Intersect world-space segment with this polygon. Return true if it intersects and the intersection point in world coordinates.

bool IntersectRay(const csVector3& start, const csVector3& end)
Intersect world-space ray with this polygon. This function is similar to intersect_segment except that it doesn't keep the lenght of the ray in account. It just tests if the ray intersects with the interior of the polygon.


This class has no child classes.

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