forked from alpet83/Xray-Research
-
Notifications
You must be signed in to change notification settings - Fork 0
/
CameraManager.h
139 lines (114 loc) · 5.55 KB
/
CameraManager.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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
// CameraManager.h: interface for the CCameraManager class.
//
#if !defined(AFX_CAMERAMANAGER_H__B11F8AE2_1213_11D4_B4E3_4854E82A090D__INCLUDED_)
#define AFX_CAMERAMANAGER_H__B11F8AE2_1213_11D4_B4E3_4854E82A090D__INCLUDED_
#pragma once
#include "CameraDefs.h"
struct SPPInfo {
struct SColor {
f32 r, g, b;
IC operator u32() {
int _r = clampr (iFloor(r*255.f+.5f),0,255);
int _g = clampr (iFloor(g*255.f+.5f),0,255);
int _b = clampr (iFloor(b*255.f+.5f),0,255);
return color_rgba (_r,_g,_b,0);
}
IC SColor& operator += (const SColor &ppi) {
r += ppi.r; g += ppi.g; b += ppi.b;
return *this;
}
IC void set (float _r, float _g, float _b) {
r=_r;g=_g;b=_b;
}
};
f32 blur, gray;
struct SDuality { f32 h, v; } duality;
struct SNoise {
f32 intensity, grain;
f32 fps;
} noise;
SColor color_base;
SColor color_gray;
SColor color_add;
IC SPPInfo& operator += (const SPPInfo &ppi) {
blur += ppi.blur;
gray += ppi.gray;
duality.h += ppi.duality.h; duality.v += ppi.duality.v;
noise.intensity += ppi.noise.intensity; noise.grain += ppi.noise.grain;
noise.fps += ppi.noise.fps;
color_base += ppi.color_base;
color_gray += ppi.color_gray;
color_add += ppi.color_add;
return *this;
}
void normalize ();
SPPInfo ()
{
blur = gray = duality.h = duality.v = 0;
noise.intensity=0; noise.grain = 1; noise.fps = 10;
color_base.set (.5f, .5f, .5f);
color_gray.set (.333f, .333f, .333f);
color_add.set (0.f, 0.f, 0.f);
}
};
DEFINE_VECTOR (CEffector*,EffectorVec,EffectorIt);
DEFINE_VECTOR (CEffectorPP*,EffectorPPVec,EffectorPPIt);
class ENGINE_API CCameraManager
{
Fvector vPosition;
Fvector vDirection;
Fvector vNormal;
Fvector vRight;
EffectorVec m_Effectors;
EffectorPPVec m_EffectorsPP;
float fFov;
float fFar;
float fAspect;
Fmatrix unaffected_mView;
Fvector unaffected_vPosition;
Fvector unaffected_vDirection;
Fvector unaffected_vNormal;
Fvector unaffected_vRight;
Fvector affected_vPosition;
Fvector affected_vDirection;
Fvector affected_vNormal;
Fvector affected_vRight;
SPPInfo pp_identity;
SPPInfo pp_zero;
SPPInfo pp_affected;
public:
void Dump (void);
CEffector* AddEffector (CEffector* ef);
CEffector* GetEffector (EEffectorType type);
void RemoveEffector (EEffectorType type);
CEffectorPP* GetEffector (EEffectorPPType type);
CEffectorPP* AddEffector (CEffectorPP* ef);
void RemoveEffector (EEffectorPPType type);
IC Fmatrix& unaffected_View () { return unaffected_mView; }
IC Fvector& unaffected_Pos () { return unaffected_vPosition; }
IC Fvector& unaffected_Dir () { return unaffected_vDirection; }
IC Fvector& unaffected_Up () { return unaffected_vNormal; }
IC Fvector& unaffected_Right () { return unaffected_vRight; }
IC void unaffected_Matrix (Fmatrix& M)
{ M.set(unaffected_vRight,unaffected_vNormal,unaffected_vDirection,unaffected_vPosition); }
IC Fvector& affected_Pos () { return affected_vPosition; }
IC Fvector& affected_Dir () { return affected_vDirection; }
IC Fvector& affected_Up () { return affected_vNormal; }
IC Fvector& affected_Right () { return affected_vRight; }
IC void affected_Matrix (Fmatrix& M)
{ M.set(affected_vRight,affected_vNormal,affected_vDirection,affected_vPosition); }
IC Fmatrix& render_View () { return Device.mView; }
IC Fvector& render_Pos () { return vPosition; }
IC Fvector& render_Dir () { return vDirection;}
IC Fvector& render_Up () { return vNormal; }
IC Fvector& render_Right () { return vRight; }
IC void render_Matrix (Fmatrix& M)
{ M.set(vRight,vNormal,vDirection,vPosition); }
void Update (const Fvector& P, const Fvector& D, const Fvector& N, float fFOV_Dest, float fASPECT_Dest, float fFAR_Dest, u32 flags=0);
void Update (const CCameraBase* C);
CCameraManager();
~CCameraManager();
};
ENGINE_API extern float psCamInert;
ENGINE_API extern float psCamSlideInert;
#endif // !defined(AFX_CAMERAMANAGER_H__B11F8AE2_1213_11D4_B4E3_4854E82A090D__INCLUDED_)