summaryrefslogtreecommitdiffstats
path: root/src/camera.h
blob: 1f2c41c822a9f567f1d9e8d42c3a95e123cb3a48 (plain)
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
// camera.h

#ifndef _CAMERA_H_
#define	_CAMERA_H_


class CInstanceManager;
class CD3DEngine;
class CTerrain;
class CWater;
class CObject;
enum D3DMouse;


enum CameraType
{
	CAMERA_NULL		= 0,	// cam�ra ind�finie
	CAMERA_FREE		= 1,	// cam�ra libre (jamais en principe)
	CAMERA_EDIT		= 2,	// cam�ra pendant l'�dition d'un programme
	CAMERA_ONBOARD	= 3,	// cam�ra � bord d'un robot
	CAMERA_BACK		= 4,	// cam�ra derri�re un robot
	CAMERA_FIX		= 5,	// cam�ra fixe apr�s robot
	CAMERA_EXPLO	= 6,	// cam�ra immobile apr�s explosion
	CAMERA_SCRIPT	= 7,	// cam�ra pendant un film script�
	CAMERA_INFO		= 8,	// cam�ra pendant l'affichage des informations
	CAMERA_VISIT	= 9,	// visite du lieu d'une erreur
	CAMERA_DIALOG	= 10,	// cam�ra pendant dialogue
	CAMERA_PLANE	= 11,	// cam�ra fixe en hauteur
};

enum CameraSmooth
{
	CS_NONE			= 0,	// brusque
	CS_NORM			= 1,	// normal
	CS_HARD			= 2,	// dur
	CS_SPEC			= 3,	// sp�cial
};

enum CenteringPhase
{
	CP_NULL			= 0,
	CP_START		= 1,
	CP_WAIT			= 2,
	CP_STOP			= 3,
};

enum CameraEffect
{
	CE_NULL			= 0,	// pas d'effet
	CE_TERRAFORM	= 1,	// terrassement
	CE_CRASH		= 2,	// v�hicule volant pos� violemment
	CE_EXPLO		= 3,	// explosion
	CE_SHOT			= 4,	// coup non mortel
	CE_VIBRATION	= 5,	// vibration pendant construction
	CE_PET			= 6,	// rat� du r�acteur
};

enum OverEffect
{
	OE_NULL			= 0,	// pas d'effet
	OE_BLOOD		= 1,	// flash rouge
	OE_FADEINw		= 2,	// blanc -> rien
	OE_FADEOUTw		= 3,	// rien -> blanc
	OE_FADEOUTb		= 4,	// rien -> bleu
	OE_BLITZ		= 5,	// �clair
};



class CCamera
{
public:
	CCamera(CInstanceManager* iMan);
	~CCamera();

	BOOL		EventProcess(const Event &event);

	void		Init(D3DVECTOR eye, D3DVECTOR lookat, float delay);

	void		SetObject(CObject* object);
	CObject*	RetObject();

	void		SetType(CameraType type);
	CameraType	RetType();

	void		SetSmooth(CameraSmooth type);
	CameraSmooth RetSmoth();

	void		SetDist(float dist);
	float		RetDist();

	void		SetFixDirection(float angle);
	float		RetFixDirection();

	void		SetRemotePan(float value);
	float		RetRemotePan();

	void		SetRemoteZoom(float value);
	float		RetRemoteZoom();

	void		StartVisit(D3DVECTOR goal, float dist);
	void		StopVisit();

	void		RetCamera(D3DVECTOR &eye, D3DVECTOR &lookat);

	BOOL		StartCentering(CObject *object, float angleH, float angleV, float dist, float time);
	BOOL		StopCentering(CObject *object, float time);
	void		AbortCentering();

	void		FlushEffect();
	void		StartEffect(CameraEffect effect, D3DVECTOR pos, float force);

	void		FlushOver();
	void		SetOverBaseColor(D3DCOLORVALUE color);
	void		StartOver(OverEffect effect, D3DVECTOR pos, float force);

	void		FixCamera();
	void		SetScriptEye(D3DVECTOR eye);
	void		SetScriptLookat(D3DVECTOR lookat);

	void		SetEffect(BOOL bEnable);
	void		SetCameraScroll(BOOL bScroll);
	void		SetCameraInvertX(BOOL bInvert);
	void		SetCameraInvertY(BOOL bInvert);

	float		RetMotorTurn();
	D3DMouse	RetMouseDef(FPOINT pos);

protected:
	BOOL		EventMouseMove(const Event &event);
	void		EventMouseWheel(int dir);
	BOOL		EventFrame(const Event &event);
	BOOL		EventFrameFree(const Event &event);
	BOOL		EventFrameEdit(const Event &event);
	BOOL		EventFrameDialog(const Event &event);
	BOOL		EventFrameBack(const Event &event);
	BOOL		EventFrameFix(const Event &event);
	BOOL		EventFrameExplo(const Event &event);
	BOOL		EventFrameOnBoard(const Event &event);
	BOOL		EventFrameInfo(const Event &event);
	BOOL		EventFrameVisit(const Event &event);
	BOOL		EventFrameScript(const Event &event);

	void		SetViewTime(const D3DVECTOR &vEyePt, const D3DVECTOR &vLookatPt, float rTime);
	BOOL		IsCollision(D3DVECTOR &eye, D3DVECTOR lookat);
	BOOL		IsCollisionBack(D3DVECTOR &eye, D3DVECTOR lookat);
	BOOL		IsCollisionFix(D3DVECTOR &eye, D3DVECTOR lookat);

	D3DVECTOR	ExcludeTerrain(D3DVECTOR eye, D3DVECTOR lookat, float &angleH, float &angleV);
	D3DVECTOR	ExcludeObject(D3DVECTOR eye, D3DVECTOR lookat, float &angleH, float &angleV);

	void		SetViewParams(const D3DVECTOR &eye, const D3DVECTOR &lookat, const D3DVECTOR &up);
	void		EffectFrame(const Event &event);
	void		OverFrame(const Event &event);

protected:
	CInstanceManager* m_iMan;
	CD3DEngine*	m_engine;
	CTerrain*	m_terrain;
	CWater*		m_water;

	CameraType	m_type;				// type de la cam�ra (CAMERA_*)
	CameraSmooth m_smooth;			// type de lissage
	CObject*	m_cameraObj;		// objet li� � la cam�ra

	float		m_eyeDistance;		// distance entre les yeux
	float		m_initDelay;		// d�lai du centrage initial

	D3DVECTOR	m_actualEye;		// oeil actuel
	D3DVECTOR	m_actualLookat;		// vis�e actuelle
	D3DVECTOR	m_finalEye;			// oeil final
	D3DVECTOR	m_finalLookat;		// vis�e finale
	D3DVECTOR	m_normEye;			// oeil normal
	D3DVECTOR	m_normLookat;		// vis�e normale
	float		m_focus;

	BOOL		m_bRightDown;
	FPOINT		m_rightPosInit;
	FPOINT		m_rightPosCenter;
	FPOINT		m_rightPosMove;

	D3DVECTOR	m_eyePt;			// CAMERA_FREE: oeil
	float		m_directionH;		// CAMERA_FREE: direction horizontale
	float		m_directionV;		// CAMERA_FREE: direction verticale
	float		m_heightEye;		// CAMERA_FREE: hauteur au-dessus du sol
	float		m_heightLookat;		// CAMERA_FREE: hauteur au-dessus du sol
	float		m_speed;			// CAMERA_FREE: vitesse de d�placement

	float		m_backDist;			// CAMERA_BACK: �loignement
	float		m_backMin;			// CAMERA_BACK: �loignement minimal
	float		m_addDirectionH;	// CAMERA_BACK: direction suppl�mentaire
	float		m_addDirectionV;	// CAMERA_BACK: direction suppl�mentaire
	BOOL		m_bTransparency;

	float		m_fixDist;			// CAMERA_FIX: �loignement
	float		m_fixDirectionH;	// CAMERA_FIX: direction
	float		m_fixDirectionV;	// CAMERA_FIX: direction

	D3DVECTOR	m_visitGoal;		// CAMERA_VISIT: position vis�e
	float		m_visitDist;		// CAMERA_VISIT: �loignement
	float		m_visitTime;		// CAMERA_VISIT: temps relatif
	CameraType	m_visitType;		// CAMERA_VISIT: type initial
	float		m_visitDirectionH;	// CAMERA_VISIT: direction
	float		m_visitDirectionV;	// CAMERA_VISIT: direction

	float		m_editHeight;		// CAMERA_EDIT: hauteur

	float		m_remotePan;
	float		m_remoteZoom;

	FPOINT		m_mousePos;
	float		m_mouseDirH;
	float		m_mouseDirV;
	float		m_mouseMarging;

	float		m_motorTurn;

	CenteringPhase m_centeringPhase;
	float		m_centeringAngleH;
	float		m_centeringAngleV;
	float		m_centeringDist;
	float		m_centeringCurrentH;
	float		m_centeringCurrentV;
	float		m_centeringTime;
	float		m_centeringProgress;

	CameraEffect m_effectType;
	D3DVECTOR	m_effectPos;
	float		m_effectForce;
	float		m_effectProgress;
	D3DVECTOR	m_effectOffset;

	OverEffect	m_overType;
	float		m_overForce;
	float		m_overTime;
	D3DCOLORVALUE m_overColorBase;
	D3DCOLORVALUE m_overColor;
	int			m_overMode;
	float		m_overFadeIn;
	float		m_overFadeOut;

	D3DVECTOR	m_scriptEye;
	D3DVECTOR	m_scriptLookat;

	BOOL		m_bEffect;			// secousses si explosion ?
	BOOL		m_bCameraScroll;	// scroll dans les bords ?
	BOOL		m_bCameraInvertX;	// inversion X dans les bords ?
	BOOL		m_bCameraInvertY;	// inversion Y dans les bords ?
};


#endif //_CAMERA_H_