class csPolygon3D : public csObject, public csPolygonInt This is our main 3D polygon class
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.