class csPolygon3D : public csObject, public csPolygonInt This is our main 3D polygon class
| | AddLightpatch (csLightPatch *lp) Add a light patch to the light patch list |
| | AddVertex (const csVector3& v) Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet |
| | AddVertex (float x, float y, float z) Add a vertex in a smart way: check if the vertex already exists in the containing csPolygonSet |
| | AddVertex (int v) Add a vertex from the container (polygonset) to the polygon |
| | CacheLightMaps (csPolygonSet* owner, int index) Call after calling InitLightMaps and CalculateLighting to cache the calculated lightmap to the level archive |
| | CalculateLighting (csLightView* lview) Check visibility of this polygon with the given csLightView and fill the lightmap if needed (this function calls FillLightMap ()) |
| | CamUpdate () Before calling a series of Vcam() you should call CamUpdate() first to make sure that the camera vertex set is up-to-date |
| | CheckFlags (ULong to_check) Check if all the given flags are set. |
| | Classify (csPolygonInt* spoly) Classify a polygon with regards to this one (in world space) |
| | 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)) |
| | ClipPoly (csVector3* frustrum, int num_frustrum, bool mirror, csVector3** dest, int* num_dest) Clip a polygon against a frustrum in camera space |
| | ClipPolyPlane (csVector3* verts, int* num, bool mirror, csVector3& v1, csVector3& v2) Clip a polygon against a plane (in camera space) |
| | 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 |
| | 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 |
| | 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) |
| | FillLightMap (csLightView& lview) Fill the lightmap of this polygon according to the given light and the frustrum |
| | Finish () After the plane normal and the texture matrices have been set up this routine makes some needed pre-calculations for this polygon |
| | GetAlpha () Get the alpha transparency value for this polygon |
| | GetCosinusFactor () Get the cosinus factor |
| | GetFlags () Get flags. |
| | GetFlatColor () Get the flat color for this polygon. |
| | GetGouraudInfo () This is a conveniance function to get the gouraud information structure |
| | GetLightMapInfo () This is a conveniance function to get the lightmap information structure |
| | GetLightpatches () Get the list of light patches for this polygon |
| | GetParent () Get the polygonset (container) that this polygons belongs to |
| | GetPlane () Return the plane of this polygon |
| | GetPolyPlane () Return the world-space plane of this polygon |
| | GetPortal () Get the portal structure (if there is one) |
| | GetSector () Get the sector that this polygon belongs to |
| | GetTexture () Get the texture |
| | GetTextureHandle () Get the texture handle for the texture manager |
| | GetTextureType () Short-hand to get the texture type from the csPolygonTextureType structure |
| | GetTextureTypeInfo () Get the general texture type information structure |
| | GetType () Return 1 to indicate to the BSP tree routines that this is a csPolygon3D |
| | GetUnsplitPolygon () Return the pointer to the original polygon (before any BSP splits). |
| | GetVertices () Get the vertices |
| | InitLightMaps (csPolygonSet* owner, bool do_cache, int index) Initialize the lightmaps for this polygon |
| | IntersectRay (const csVector3& start, const csVector3& end) Intersect world-space ray with this polygon |
| | IntersectSegment (const csVector3& start, const csVector3& end, csVector3& isect, float* pr = NULL) Intersect world-space segment with this polygon |
| | IsDirty () Return true if polygon is dirty for dynamic lights. |
| | IsTransparent () Return true if this polygon or the texture it uses is transparent |
| | MakeCleanDynamicLights () Make clean again. |
| | 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) |
| | MarkRelevantShadowFrustrums (csLightView& lview, csPlane& plane) Check all shadow frustrums and mark all relevant ones |
| | ObjectToWorld (const csReversibleTransform& t) Transform the plane of this polygon from object space to world space |
| | Reset () Clear the polygon (remove all vertices) |
| | ResetFlatColor () Reset flat color (i.e. use texturing again). |
| | SamePlane (csPolygonInt* p) Return true if this polygon and the given polygon are on the same plane |
| | SetAlpha (int da) Set the alpha transparency value for this polygon (only if it is a portal) |
| | SetCosinusFactor (float f) Set the cosinus factor |
| | SetCSPortal (csSector* sector) If the polygon is a portal this will set the sector that this portal points to |
| | SetFlags (ULong mask, ULong value) Set all flags with the given mask. |
| | SetFlatColor (float r, float g, float b) Set the flat color for this polygon. |
| | SetFlatColor (csColor& fc) Set the flat color for this polygon. |
| | SetParent (csPolygonSet* poly_set) Set the polygonset (container) that this polygon belongs to |
| | SetPortal (csPortal* prt) Set a pre-created portal on this polygon |
| | SetSector (csSector* sector) Set the sector that this polygon belongs to |
| | SetTexture (csTextureHandle* texture) Set the texture for this polygon |
| | 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 |
| | 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 |
| | 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 |
| | 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 |
| | 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 |
| | 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 |
| | SetTextureType (int type) Set type of texturing to use for this polygon (one of the POLYTXT_??? flags) |
| | SetWarp (const csTransform& t) Set the warping transformation for the portal |
| | SetWarp (const csMatrix3& m_w, const csVector3& v_w_before, const csVector3& v_w_after) Set the warping transformation for the portal |
| | 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' |
| | UnlinkLightpatch (csLightPatch* lp) Unlink a light patch from the light patch list |
| | UpdateVertexLighting (csLight* light, const csColor& lcol, bool dynamic, bool reset) Update vertex lighting for this polygon |
| | Vcam (int idx) 'idx' is a local index into the vertices table of the polygon |
| | Vobj (int idx) 'idx' is a local index into the vertices table of the polygon |
| | Vwor (int idx) 'idx' is a local index into the vertices table of the polygon |
| | ~csPolygon3D () Delete everything related to this polygon |
| | delete_plane If 'delete_plane' is true this plane was allocated by this Polygon and it should also be deleted by it |
| | delete_portal If 'delete_portal' is true this portal was allocated by this Polygon and it should also be deleted by it |
| | delete_tex_info If 'delete_tex_info' is true this polygon is responsible for cleaning the csPolyTextures |
| | flags Set of flags |
| | light_info General lighting information for this polygon |
| | orig_poly The original polygon |
| | plane The PolygonPlane for this polygon |
| | poly_set The following two fields are somewhat related |
| | portal If not-null, this polygon is a portal |
| | sector The csSector that this polygon is in. |
| | txt_info Texture type specific information for this polygon |
| | vertices A table of indices into the vertices of the parent csPolygonSet (container). |
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.
@@@ 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.
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.
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.
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 :-)
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 :-)
Use 'v1' and 'len1' for the u-axis and 'v2' and 'len2' for the
v-axis.
The most general function. With these you provide the matrix
directly.
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.
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.
csPolygonSet* poly_set
csSector* sector
csPortal* portal
bool delete_portal
csPolyPlane* plane
bool delete_plane
csPolygonLightInfo light_info
csPolygonTextureType* txt_info
ULong flags
bool delete_tex_info
csPolygon3D* orig_poly
void ComputeNormal()
void PlaneNormal(float* yz, float* zx, float* xy)
static bool do_force_recalc
static bool do_not_force_recalc
static int def_mipmap_size
bool dont_draw
csPolygon3D(csTextureHandle* texture)
csPolygon3D(csPolygon3D& poly)
virtual ~csPolygon3D()
void SetTextureType(int type)
int GetTextureType()
csPolygonTextureType* GetTextureTypeInfo()
csLightMapped* GetLightMapInfo()
csGouraudShaded* GetGouraudInfo()
void SetFlags(ULong mask, ULong value)
ULong GetFlags()
bool CheckFlags(ULong to_check)
void Reset()
int AddVertex(int v)
int AddVertex(const csVector3& v)
int AddVertex(float x, float y, float z)
void Finish()
csColor& GetFlatColor()
void SetFlatColor(float r, float g, float b)
void SetFlatColor(csColor& fc)
void ResetFlatColor()
void SetCSPortal(csSector* sector)
void SetPortal(csPortal* prt)
csPortal* GetPortal()
void SetParent(csPolygonSet* poly_set)
csPolygonSet* GetParent()
csSector* GetSector()
void SetSector(csSector* sector)
csPolyPlane* GetPlane()
csPlane* GetPolyPlane()
csPolyIndexed& GetVertices()
void SetWarp(const csTransform& t)
void SetWarp(const csMatrix3& m_w, const csVector3& v_w_before, const csVector3& v_w_after)
csVector3& Vwor(int idx)
csVector3& Vobj(int idx)
csVector3& Vcam(int idx)
void CamUpdate()
void SetTexture(csTextureHandle* texture)
csTextureHandle* GetTexture()
ITextureHandle* GetTextureHandle()
bool IsTransparent()
float GetCosinusFactor()
void SetCosinusFactor(float f)
void SetAlpha(int da)
int GetAlpha()
void SetTextureSpace(csPolygon3D* copy_from)
void SetTextureSpace(csPolyPlane* plane)
void SetTextureSpace(csVector3& v_orig, csVector3& v1, float len1)
void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1)
void SetTextureSpace(float xo, float yo, float zo, float x1, float y1, float z1, float len1, float x2, float y2, float z2, float len2)
void SetTextureSpace(csMatrix3& tx_matrix, csVector3& tx_vector)
void CreateLightMaps(IGraphics3D* g3d)
csPolygon3D* GetUnsplitPolygon()
void MakeDirtyDynamicLights()
bool IsDirty()
void MakeCleanDynamicLights()
void UnlinkLightpatch(csLightPatch* lp)
void AddLightpatch(csLightPatch *lp)
csLightPatch* GetLightpatches()
bool ClipPoly(csVector3* frustrum, int num_frustrum, bool mirror, csVector3** dest, int* num_dest)
void ClipPolyPlane(csVector3* verts, int* num, bool mirror, csVector3& v1, csVector3& v2)
bool ClipFrustrum(csVector3& center, csVector3* frustrum, int num_frustrum, bool mirror, csVector3** new_frustrum, int* new_num_frustrum)
void InitLightMaps(csPolygonSet* owner, bool do_cache, int index)
void FillLightMap(csLightView& lview)
void UpdateVertexLighting(csLight* light, const csColor& lcol, bool dynamic, bool reset)
'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)
This function will also discard all shadow frustrums which start at
the same plane as the given plane.