re3/src/render/Shadows.h

211 lines
7.9 KiB
C
Raw Normal View History

2019-05-29 00:52:30 +00:00
#pragma once
2019-07-24 16:55:43 +00:00
#define MAX_STOREDSHADOWS 48
2020-07-29 09:17:53 +00:00
#define MAX_POLYBUNCHES 380
#define MAX_STATICSHADOWS 48
2019-07-24 16:55:43 +00:00
#define MAX_PERMAMENTSHADOWS 48
2020-07-29 09:17:53 +00:00
class CEntity;
2020-07-29 09:17:53 +00:00
class CPtrList;
class CAutomobile;
class CVehicle;
class CPed;
class CCutsceneShadow;
class CCutsceneObject;
2019-05-29 00:52:30 +00:00
2019-07-24 16:55:43 +00:00
enum eShadowType
{
SHADOWTYPE_NONE = 0,
2019-07-24 17:30:09 +00:00
SHADOWTYPE_DARK,
SHADOWTYPE_ADDITIVE,
SHADOWTYPE_INVCOLOR
2019-07-24 16:55:43 +00:00
};
enum eShadowTextureType
{
SHADOWTEX_NONE = 0,
SHADOWTEX_CAR,
SHADOWTEX_PED,
SHADOWTEX_EXPLOSION,
SHADOWTEX_HELI,
SHADOWTEX_HEADLIGHTS,
SHADOWTEX_BLOOD
};
2020-07-29 09:17:53 +00:00
enum VEH_SHD_TYPE
{
VEH_SHD_TYPE_CAR = 0,
VEH_SHD_TYPE_BIKE,
VEH_SHD_TYPE_HELI,
VEH_SHD_TYPE_SEAPLANE,
VEH_SHD_TYPE_RCPLANE,
};
2019-07-24 16:55:43 +00:00
class CStoredShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
2020-07-29 09:17:53 +00:00
RwTexture *m_pTexture;
CCutsceneShadow *m_pCutsceneShadow;
2019-07-24 16:55:43 +00:00
int16 m_nIntensity;
uint8 m_ShadowType;
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
struct
{
uint8 bDrawOnWater : 1;
uint8 bRendered : 1;
2020-07-29 09:17:53 +00:00
uint8 bDrawOnBuildings : 1;
2019-07-24 16:55:43 +00:00
} m_nFlags;
2020-07-29 09:17:53 +00:00
2019-07-24 16:55:43 +00:00
CStoredShadow()
{ }
};
2020-05-10 13:54:37 +00:00
2019-07-24 16:55:43 +00:00
VALIDATE_SIZE(CStoredShadow, 0x30);
class CPolyBunch
{
public:
CVector m_aVerts[7];
2020-07-29 09:17:53 +00:00
CPolyBunch *m_pNext;
int16 m_nNumVerts;
2019-07-24 16:55:43 +00:00
uint8 m_aU[7];
uint8 m_aV[7];
CPolyBunch()
{ }
};
2020-05-10 13:54:37 +00:00
2019-07-24 16:55:43 +00:00
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;
2020-07-29 09:17:53 +00:00
RwTexture *m_pTexture;
2019-07-24 16:55:43 +00:00
int16 m_nIntensity; // unsigned ?
2020-07-29 09:17:53 +00:00
uint8 m_nType;
2019-07-24 16:55:43 +00:00
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
bool m_bJustCreated;
bool m_bRendered;
bool m_bTemp;
2020-07-29 09:17:53 +00:00
2020-05-11 02:55:57 +00:00
2019-07-24 16:55:43 +00:00
CStaticShadow()
{ }
void Free();
};
2020-05-10 13:54:37 +00:00
2019-07-24 16:55:43 +00:00
VALIDATE_SIZE(CStaticShadow, 0x40);
class CPermanentShadow
{
public:
CVector m_vecPos;
CVector2D m_vecFront;
CVector2D m_vecSide;
float m_fZDistance;
float m_fScale;
2020-07-29 09:17:53 +00:00
uint32 m_nTimeCreated;
uint32 m_nLifeTime;
RwTexture *m_pTexture;
2019-07-24 16:55:43 +00:00
int16 m_nIntensity;
uint8 m_nType; // eShadowType
uint8 m_nRed;
uint8 m_nGreen;
uint8 m_nBlue;
2020-05-11 02:55:57 +00:00
2019-07-24 16:55:43 +00:00
CPermanentShadow()
{ }
};
2019-07-24 16:55:43 +00:00
VALIDATE_SIZE(CPermanentShadow, 0x38);
2019-05-29 00:52:30 +00:00
class CShadows
{
public:
2019-07-24 16:55:43 +00:00
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];
2020-07-29 09:17:53 +00:00
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 bool StoreStaticShadow (uint32 nID, uint8 ShadowType, RwTexture *pTexture, Const 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, CCutsceneShadow *pShadow, bool bDrawOnBuildings);
static void StoreShadowForVehicle (CVehicle *pCar, VEH_SHD_TYPE type);
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 StoreShadowForCutscenePedObject(CCutsceneObject *pObject, 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,
2019-07-24 16:55:43 +00:00
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
2020-07-29 09:17:53 +00:00
static void CastPlayerShadowSectorList (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 CastCutsceneShadowSectorList (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, CCutsceneShadow *pShadow);
static void CastShadowEntityXY (CEntity *pEntity, float fStartX, float fStartY, float fEndX, float fEndY,
2019-07-24 16:55:43 +00:00
CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch);
2020-07-29 09:17:53 +00:00
static void CastShadowEntityXYZ (CEntity *pEntity, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY, int16 nIntensity, uint8 nRed, uint8 nGreen, uint8 nBlue, float fZDistance, float fScale, CPolyBunch **ppPolyBunch, CCutsceneShadow *pShadow);
static void UpdateStaticShadows (void);
static void UpdatePermanentShadows (void);
2020-07-29 22:32:21 +00:00
static void CalcPedShadowValues (CVector vecLightDir, float *pfFrontX, float *pfFrontY, float *pfSideX, float *pfSideY, float *pfDisplacementX, float *pfDisplacementY);
2020-07-29 09:17:53 +00:00
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);
2019-05-31 09:44:43 +00:00
};
2020-04-17 05:54:14 +00:00
extern RwTexture *gpShadowCarTex;
extern RwTexture *gpShadowPedTex;
extern RwTexture *gpShadowHeliTex;
2020-07-29 09:17:53 +00:00
extern RwTexture *gpShadowBikeTex;
extern RwTexture *gpShadowBaronTex;
2020-04-17 05:54:14 +00:00
extern RwTexture *gpShadowExplosionTex;
extern RwTexture *gpShadowHeadLightsTex;
extern RwTexture *gpOutline1Tex;
extern RwTexture *gpOutline2Tex;
extern RwTexture *gpOutline3Tex;
extern RwTexture *gpBloodPoolTex;
extern RwTexture *gpReflectionTex;
extern RwTexture *gpWalkDontTex;
extern RwTexture *gpCrackedGlassTex;
extern RwTexture *gpPostShadowTex;
extern RwTexture *gpGoalTex;