1 ////////////////////////////////////////////////////////////////////////////////
2 //    Scorched3D (c) 2000-2011
3 //
4 //    This file is part of Scorched3D.
5 //
6 //    Scorched3D is free software; you can redistribute it and/or modify
7 //    it under the terms of the GNU General Public License as published by
8 //    the Free Software Foundation; either version 2 of the License, or
9 //    (at your option) any later version.
10 //
11 //    Scorched3D is distributed in the hope that it will be useful,
12 //    but WITHOUT ANY WARRANTY; without even the implied warranty of
13 //    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14 //    GNU General Public License for more details.
15 //
16 //    You should have received a copy of the GNU General Public License along
17 //    with this program; if not, write to the Free Software Foundation, Inc.,
18 //    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19 ////////////////////////////////////////////////////////////////////////////////
20 
21 #if !defined(AFX_TARGETCAMERA_H__97593EBB_5901_4D81_BAEB_8ADC76CFB627__INCLUDED_)
22 #define AFX_TARGETCAMERA_H__97593EBB_5901_4D81_BAEB_8ADC76CFB627__INCLUDED_
23 
24 #include <GLEXT/GLCamera.h>
25 #include <GLW/GLWToolTip.h>
26 #include <engine/GameState.h>
27 #include <graph/ParticleEmitter.h>
28 #include <common/Keyboard.h>
29 
30 class Tank;
31 class TargetCamera
32 {
33 public:
34 	enum CamType
35 	{
36 		CamTop = 0,
37 		CamBehind,
38 		CamTank,
39 		CamShot,
40 		CamAim,
41 		CamExplosion,
42 		CamAction,
43 		CamLeft,
44 		CamRight,
45 		CamLeftFar,
46 		CamRightFar,
47 		CamSpectator,
48 		CamObject,
49 		CamFree
50 	};
51 
52 	TargetCamera();
53 	virtual ~TargetCamera();
54 
getCamera()55 	GLCamera &getCamera() { return mainCam_; }
getCameraType()56 	CamType getCameraType() { return cameraPos_; }
getPrecipitationEngine()57 	ParticleEngine &getPrecipitationEngine() { return particleEngine_; }
setCameraType(CamType type)58 	void setCameraType(CamType type) { cameraPos_ = type; }
59 	void resetCam();
60 
61 	void simulate(float frameTime, bool playing);
62 	void draw();
63 	void drawPrecipitation();
64 	void mouseWheel(int x, int y, int z, bool &skipRest);
65 	void mouseDown(GameState::MouseButton button,
66 		int x, int y, bool &skipRest);
67 	void mouseUp(GameState::MouseButton button,
68 		int x, int y, bool &skipRest);
69 	void mouseDrag(GameState::MouseButton button,
70 		int mx, int my, int x, int y, bool &skipRest);
71 	bool keyboardCheck(
72 		float frameTime,
73 		char *buffer, unsigned int keyState,
74 		KeyboardHistory::HistoryElement *history, int hisCount,
75 		bool &skipRest);
76 
77 	static const char **getCameraNames();
78 	static ToolTip *getCameraToolTips();
79 	static int getNoCameraNames();
80 	static float minHeightFunc(int x, int y, void *heightData);
81 	static float maxHeightFunc(int x, int y, void *heightData);
82 
getCurrentTargetCamera()83 	static TargetCamera *getCurrentTargetCamera() { return currentTargetCamera_; }
84 
85 protected:
86 	static TargetCamera *currentTargetCamera_;
87 	GLCamera mainCam_;
88 	CamType cameraPos_;
89 	ParticleEmitter rainEmitter_, snowEmitter_;
90 	ParticleEngine particleEngine_;
91 	float totalTime_, objectTime_;
92 	int viewObject_;
93 	int dragXStart_, dragYStart_;
94 	bool dragging_;
95 	bool lastLandIntersectValid_;
96 	Vector lastLandIntersect_;
97 
98 	void moveCamera();
99 	bool getLandIntersect(int x, int y, Vector &intersect);
100 	void viewBehindTank(Tank *tank);
101 	void viewSpectator();
102 };
103 
104 #endif // !defined(AFX_TARGETCAMERA_H__97593EBB_5901_4D81_BAEB_8ADC76CFB627__INCLUDED_)
105 
106