summaryrefslogtreecommitdiffstats
path: root/src/render/Shadows.h
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/render/Shadows.h177
1 files changed, 167 insertions, 10 deletions
diff --git a/src/render/Shadows.h b/src/render/Shadows.h
index 37749de4..ca6718b0 100644
--- a/src/render/Shadows.h
+++ b/src/render/Shadows.h
@@ -1,5 +1,11 @@
#pragma once
+#define MAX_STOREDSHADOWS 48
+#define MAX_POLYBUNCHES 300
+#define MAX_STATICSHADOWS 64
+#define MAX_PERMAMENTSHADOWS 48
+
+
struct RwTexture;
class CEntity;
@@ -8,19 +14,170 @@ enum
SHADOWTYPE_2 = 2
};
+enum eShadowType
+{
+ SHADOWTYPE_NONE = 0,
+ SHADOWTYPE_DARK,
+ SHADOWTYPE_ADDITIVE,
+ SHADOWTYPE_INVCOLOR
+};
+
+enum eShadowTextureType
+{
+ SHADOWTEX_NONE = 0,
+ SHADOWTEX_CAR,
+ SHADOWTEX_PED,
+ SHADOWTEX_EXPLOSION,
+ SHADOWTEX_HELI,
+ SHADOWTEX_HEADLIGHTS,
+ SHADOWTEX_BLOOD
+};
+
+class CStoredShadow
+{
+public:
+ CVector m_vecPos;
+ CVector2D m_vecFront;
+ CVector2D m_vecSide;
+ float m_fZDistance;
+ float m_fScale;
+ int16 m_nIntensity;
+ uint8 m_ShadowType;
+ uint8 m_nRed;
+ uint8 m_nGreen;
+ uint8 m_nBlue;
+ struct
+ {
+ uint8 bDrawOnWater : 1;
+ uint8 bRendered : 1;
+ //uint8 bDrawOnBuildings : 1;
+ } m_nFlags;
+ char _pad0;
+ RwTexture *m_pTexture;
+
+ CStoredShadow()
+ { }
+};
+VALIDATE_SIZE(CStoredShadow, 0x30);
+
+class CPolyBunch
+{
+public:
+ int16 m_nNumVerts;
+ char _pad0[2];
+ CVector m_aVerts[7];
+ uint8 m_aU[7];
+ uint8 m_aV[7];
+ char _pad1[2];
+ CPolyBunch *m_pNext;
+
+ CPolyBunch()
+ { }
+};
+VALIDATE_SIZE(CPolyBunch, 0x6C);
+
+class CStaticShadow
+{
+public:
+ uint32 m_nId;
+ CPolyBunch *m_pPolyBunch;
+ uint32 m_nTimeCreated;
+ CVector m_vecPosn;
+ CVector2D m_vecFront;
+ CVector2D m_vecSide;
+ float m_fZDistance;
+ float m_fScale;
+ uint8 m_nType;
+ char _pad0;
+ int16 m_nIntensity; // unsigned ?
+ uint8 m_nRed;
+ uint8 m_nGreen;
+ uint8 m_nBlue;
+ bool m_bJustCreated;
+ bool m_bRendered;
+ bool m_bTemp;
+ char _pad1[2];
+ RwTexture *m_pTexture;
+
+ CStaticShadow()
+ { }
+
+ void Free();
+};
+VALIDATE_SIZE(CStaticShadow, 0x40);
+
+class CPermanentShadow
+{
+public:
+ CVector m_vecPos;
+ CVector2D m_vecFront;
+ CVector2D m_vecSide;
+ float m_fZDistance;
+ float m_fScale;
+ int16 m_nIntensity;
+ uint8 m_nType; // eShadowType
+ uint8 m_nRed;
+ uint8 m_nGreen;
+ uint8 m_nBlue;
+ char _pad0[2];
+ uint32 m_nTimeCreated;
+ uint32 m_nLifeTime;
+ RwTexture *m_pTexture;
+
+ CPermanentShadow()
+ { }
+};
+VALIDATE_SIZE(CPermanentShadow, 0x38);
+
+class CPtrList;
+class CAutomobile;
+class CPed;
+
class CShadows
{
public:
- static void AddPermanentShadow(uint8 ShadowType, RwTexture* pTexture, CVector* pPosn, float fX1, float fY1, float fX2, float fY2, short nTransparency, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
- static void RenderStaticShadows(void);
- static void RenderStoredShadows(void);
- static void RenderExtraPlayerShadows(void);
- static void CalcPedShadowValues(CVector light, float *frontX, float *frontY, float *sideX, float *sideY, float *dispX, float *dispY);
- static void StoreShadowForTree(CEntity *ent);
- static void StoreShadowForPole(CEntity *ent, float offsetX, float offsetY, float offsetZ, float poleHeight, float poleWidth, uint32 subId);
- static void StoreShadowForPedObject(CEntity *ent, float dispX, float dispY, float frontX, float frontY, float sideX, float sideY);
- static void StoreStaticShadow(uint32 id, uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, float scale, float drawDistance, bool temporaryShadow, float upDistance);;
- static void StoreShadowToBeRendered(uint8 type, RwTexture *texture, CVector *coors, float frontX, float frontY, float sideX, float sideY, int16 intensity, uint8 red, uint8 green, uint8 blue, float zDistance, bool drawOnWater, float upDistance);
+#if 1
+ static int16 ShadowsStoredToBeRendered;
+ static CStoredShadow asShadowsStored [MAX_STOREDSHADOWS];
+ static CPolyBunch aPolyBunches [MAX_POLYBUNCHES];
+ static CStaticShadow aStaticShadows [MAX_STATICSHADOWS];
+ static CPolyBunch *pEmptyBunchList;
+ static CPermanentShadow aPermanentShadows[MAX_PERMAMENTSHADOWS];
+#else
+ static int16 &ShadowsStoredToBeRendered;
+ static CStoredShadow (&asShadowsStored) [MAX_STOREDSHADOWS];
+ static CPolyBunch (&aPolyBunches) [MAX_POLYBUNCHES];
+ static CStaticShadow (&aStaticShadows) [MAX_STATICSHADOWS];
+ static CPolyBunch *&pEmptyBunchList;
+ static CPermanentShadow (&aPermanentShadows)[MAX_PERMAMENTSHADOWS];
+#endif
+
+ static void Init (void);
+ static void Shutdown (void);
+ static void AddPermanentShadow ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, uint32 nTime, float fScale);
+ static void StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, float fDrawDistance, bool bTempShadow, float fUpDistance);
+ static void StoreShadowToBeRendered ( uint8 ShadowType, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue);
+ static void StoreShadowToBeRendered ( uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, bool bDrawOnWater, float fScale);
+ static void StoreShadowForCar (CAutomobile *pCar);
+ static void StoreCarLightShadow (CAutomobile *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle);
+ static void StoreShadowForPed (CPed *pPed, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
+ static void StoreShadowForPedObject (CEntity *pPedObject, float fDisplacementX, float fDisplacementY, float fFrontX, float fFrontY, float fSideX, float fSideY);
+ static void StoreShadowForTree (CEntity *pTree);
+ static void StoreShadowForPole (CEntity *pPole, float fOffsetX, float fOffsetY, float fOffsetZ, float fPoleHeight, float fPoleWidth, uint32 nID);
+ static void SetRenderModeForShadowType (uint8 ShadowType);
+ static void RenderStoredShadows (void);
+ static void RenderStaticShadows (void);
+ static void GeneratePolysForStaticShadow (int16 nStaticShadowID);
+ static void CastShadowSectorList (CPtrList &PtrList, float fStartX, float fStartY, float fEndX, float fEndY,
+ CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
+ static void CastShadowEntity (CEntity *pEntity, float fStartX, float fStartY, float fEndX, float fEndY,
+ CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
+ static void UpdateStaticShadows (void);
+ static void UpdatePermanentShadows (void);
+ static void CalcPedShadowValues (CVector vecLightDir, float *pfDisplacementX, float *pfDisplacementY, float *pfFrontX, float *pfFrontY, float *pfSideX, float *pfSideY);
+ static void RenderExtraPlayerShadows (void);
+ static void TidyUpShadows (void);
+ static void RenderIndicatorShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity);
};
extern RwTexture *&gpBloodPoolTex;