-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcHeadlight.h
119 lines (89 loc) · 3.42 KB
/
cHeadlight.h
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
///////////////////////////////////////////////////////
//*-------------------------------------------------*//
//| Part of Project One (https://www.maus-games.at) |//
//*-------------------------------------------------*//
//| Copyright (c) 2010 Martin Mauersics |//
//| Released under the zlib License |//
//*-------------------------------------------------*//
///////////////////////////////////////////////////////
#pragma once
#ifndef _P1_GUARD_HEADLIGHT_H_
#define _P1_GUARD_HEADLIGHT_H_
// TODO 3: make darkness configurable
// TODO 3: reduce black/transparent (0,0,0) color-areas in light-textures
// TODO 3: slow up-and-down glowing
// TODO 5: activation-animation (e.g. for player or boss spot-lights)
// TODO 3: remove shatter sound effect or use it ?
// ****************************************************************
//
#define HEADLIGHT_SCALE_FACTOR (SCALE_FACTOR) // frame buffer resolution factor
#define HEADLIGHT_INTENSITY (1.5f) //
enum eHeadlightType : coreUint8
{
HEADLIGHT_TYPE_ON = 0u, //
HEADLIGHT_TYPE_OFF = 1u, //
HEADLIGHT_TYPE_SHATTER = 2u //
};
// ****************************************************************
//
class cHeadlight final : public coreFullscreen, public coreResourceRelation
{
private:
//
struct sSpotCommand final
{
coreVector2 vPosition; //
coreVector2 vSize; //
coreVector2 vDirection; //
};
//
struct sPointCommand final
{
coreVector2 vPosition; //
coreVector2 vSize; //
};
private:
coreFrameBuffer m_FrameBuffer; //
coreList<sSpotCommand> m_aSpotCommand; //
coreList<sPointCommand> m_aPointCommand; //
coreObject2D m_Spot; //
coreObject2D m_Point; //
coreSoundPtr m_pFlickerSound; //
coreSoundPtr m_pShatterSound; //
coreTimer m_Flicker; //
coreUint8 m_iShatter; //
coreFlow m_fBlend; //
coreUint8 m_iDefault; //
public:
cHeadlight()noexcept;
~cHeadlight()final;
DISABLE_COPY(cHeadlight)
//
void Render()final;
void Move ()final;
//
void Update();
void UpdateDefault(const coreUint8 iType);
//
void DrawSpot (const coreVector3 vPosition, const coreVector2 vSize, const coreVector2 vOffset);
void DrawPoint(const coreVector3 vPosition, const coreVector2 vSize);
void DrawPoint(const coreObject3D* pObject);
//
void PlayFlicker (const coreUint8 iShatter);
void PlayFlickerNow(const coreUint8 iShatter);
void StopFlicker ();
void ResetFlicker ();
inline coreBool IsFlickering()const {return m_Flicker.GetStatus();}
//
inline void BlendOut() {ASSERT(!m_fBlend) m_fBlend = 1.0f;}
// access frame buffer
inline coreFrameBuffer* GetFrameBuffer() {return &m_FrameBuffer;}
//
inline void SetDefault(const coreUintW iIndex, const coreBool bState) {ASSERT(iIndex < sizeof(m_iDefault)*8u) SET_BIT(m_iDefault, iIndex, bState)}
//
inline coreBool GetDefault(const coreUintW iIndex)const {ASSERT(iIndex < sizeof(m_iDefault)*8u) return HAS_BIT(m_iDefault, iIndex);}
private:
// reset with the resource manager
void __Reset(const coreResourceReset eInit)final;
};
#endif // _P1_GUARD_HEADLIGHT_H_