summaryrefslogtreecommitdiffstats
path: root/src/renderer/Shadows.h
blob: 446c860232d51350eb1e05465d5bd2ea98018341 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
#pragma once

#define MAX_STOREDSHADOWS    48
#define MAX_POLYBUNCHES      380
#define MAX_STATICSHADOWS    48
#define MAX_PERMAMENTSHADOWS 48



class CEntity;
class CPtrList;
class CAutomobile;
class CVehicle;
class CPed;
class CCutsceneShadow;
class CCutsceneObject;

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
};

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,
};


class CStoredShadow
{
public:
	CVector m_vecPos;
	CVector2D m_vecFront;
	CVector2D m_vecSide;
	float m_fZDistance;
	float m_fScale;
	RwTexture *m_pTexture;
	CCutsceneShadow *m_pCutsceneShadow;
	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;
	

    CStoredShadow()
	{  }
};

VALIDATE_SIZE(CStoredShadow, 0x30);

class CPolyBunch
{
public:
	CVector m_aVerts[7];
	CPolyBunch *m_pNext;
	int16 m_nNumVerts;
	uint8 m_aU[7];
	uint8 m_aV[7];

    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;
	RwTexture *m_pTexture;
	int16 m_nIntensity; // unsigned ?
	uint8 m_nType;
	uint8 m_nRed;
	uint8 m_nGreen;
	uint8 m_nBlue;
	bool m_bJustCreated;
	bool m_bRendered;
	bool m_bTemp;
	

	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;
	uint32 m_nTimeCreated;
	uint32 m_nLifeTime;
	RwTexture *m_pTexture;
	int16 m_nIntensity;
	uint8 m_nType;	// eShadowType
	uint8 m_nRed;
	uint8 m_nGreen;
	uint8 m_nBlue;

	CPermanentShadow()
	{  }
};

VALIDATE_SIZE(CPermanentShadow, 0x38);

class CShadows
{
public:
	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];

	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            (CVehicle *pCar, int32 nID, RwTexture *pTexture, CVector *pPosn, float fFrontX, float fFrontY, float fSideX, float fSideY,                   uint8 nRed, uint8 nGreen, uint8 nBlue, float fMaxViewAngle, bool arg1 = false, float arg2 = 0.0f, float arg3 = 1.0f);
	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,
																							     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 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,
																							     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 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);
	static void CalcPedShadowValues            (CVector vecLightDir, float *pfFrontX, float *pfFrontY, float *pfSideX, float *pfSideY, float *pfDisplacementX, float *pfDisplacementY);
	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 *gpShadowCarTex;
extern RwTexture *gpShadowPedTex;
extern RwTexture *gpShadowHeliTex;
extern RwTexture *gpShadowBikeTex;
extern RwTexture *gpShadowBaronTex;
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;