Pyrogenesis  trunk
GameView.h
Go to the documentation of this file.
1 /* Copyright (C) 2010 Wildfire Games.
2  * This file is part of 0 A.D.
3  *
4  * 0 A.D. is free software: you can redistribute it and/or modify
5  * it under the terms of the GNU General Public License as published by
6  * the Free Software Foundation, either version 2 of the License, or
7  * (at your option) any later version.
8  *
9  * 0 A.D. is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  * GNU General Public License for more details.
13  *
14  * You should have received a copy of the GNU General Public License
15  * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16  */
17 
18 #ifndef INCLUDED_GAMEVIEW
19 #define INCLUDED_GAMEVIEW
20 
21 #include "renderer/Scene.h"
23 
24 #include "lib/input.h" // InReaction - can't forward-declare enum
25 
26 class CGame;
27 class CObjectManager;
28 class CCamera;
29 class CCinemaManager;
30 class CVector3D;
31 struct SViewPort;
32 
33 class JSObject;
34 
35 class CGameViewImpl;
36 
37 class CGameView : private Scene
38 {
40 private:
42 
43  // Check whether lighting environment has changed and update vertex data if necessary
44  void CheckLightEnv();
45 
46 public:
47  //BEGIN: Implementation of Scene
48  virtual void EnumerateObjects(const CFrustum& frustum, SceneCollector* c);
49  virtual CLOSTexture& GetLOSTexture();
51  //END: Implementation of Scene
52 
53 private:
54  // InitResources(): Load all graphics resources (textures, actor objects and
55  // alpha maps) required by the game
56  //void InitResources();
57 
58  // UnloadResources(): Unload all graphics resources loaded by InitResources
59  void UnloadResources();
60 
61 public:
62  CGameView(CGame *pGame);
63  ~CGameView();
64 
65  void SetViewport(const SViewPort& vp);
66 
67  void RegisterInit();
68  int Initialize();
69 
71 
72  /**
73  * Updates all the view information (i.e. rotate camera, scroll, whatever). This will *not* change any
74  * World information - only the *presentation*.
75  *
76  * @param deltaRealTime Elapsed real time since the last frame.
77  */
78  void Update(const float deltaRealTime);
79 
80  void BeginFrame();
81  void Render();
82 
84 
85  float GetCameraX();
86  float GetCameraZ();
87  float GetCameraPosX();
88  float GetCameraPosY();
89  float GetCameraPosZ();
90  float GetCameraRotX();
91  float GetCameraRotY();
92  float GetCameraZoom();
93  void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom);
94  void MoveCameraTarget(const CVector3D& target);
95  void ResetCameraTarget(const CVector3D& target);
96  void ResetCameraAngleZoom();
97  void CameraFollow(entity_id_t entity, bool firstPerson);
99 
100  CVector3D GetSmoothPivot(CCamera &camera) const;
101 
102  float GetNear() const;
103  float GetFar() const;
104  float GetFOV() const;
105 
106  #define DECLARE_BOOLEAN_SETTING(NAME) \
107  bool Get##NAME##Enabled(); \
108  void Set##NAME##Enabled(bool Enabled);
109 
110  DECLARE_BOOLEAN_SETTING(Culling);
111  DECLARE_BOOLEAN_SETTING(LockCullCamera);
112  DECLARE_BOOLEAN_SETTING(ConstrainCamera);
113 
114  #undef DECLARE_BOOLEAN_SETTING
115 
116  // Set projection of current camera using near, far, and FOV values
117  void SetCameraProjection();
118 
119  CCamera *GetCamera();
121 
122  JSObject* GetScript();
123 };
124 extern InReaction game_view_handler(const SDL_Event_* ev);
125 #endif
void UnloadResources()
Definition: GameView.cpp:549
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:40
float GetFar() const
Definition: GameView.cpp:1036
void BeginFrame()
Definition: GameView.cpp:473
float GetCameraPosZ()
Definition: GameView.cpp:918
CCinemaManager * GetCinema()
Definition: GameView.cpp:396
float GetCameraPosY()
Definition: GameView.cpp:913
CVector3D GetSmoothPivot(CCamera &camera) const
Definition: GameView.cpp:614
~CGameView()
Definition: GameView.cpp:373
virtual void EnumerateObjects(const CFrustum &frustum, SceneCollector *c)
Send all objects that can be seen when rendering the given frustum to the scene collector.
Definition: GameView.cpp:495
Definition: Camera.h:31
Definition: GameView.cpp:152
void CameraFollow(entity_id_t entity, bool firstPerson)
Definition: GameView.cpp:1020
Definition: ObjectManager.h:37
Definition: Vector3D.h:28
void Render()
Definition: GameView.cpp:487
Definition: Frustum.h:39
float GetCameraZoom()
Definition: GameView.cpp:933
float GetCameraRotY()
Definition: GameView.cpp:928
void SetCameraProjection()
Definition: GameView.cpp:1046
Definition: libsdl.h:51
float GetCameraX()
Definition: GameView.cpp:894
CGameViewImpl * m
Definition: GameView.h:41
void SetViewport(const SViewPort &vp)
Definition: GameView.cpp:380
void ResetCameraAngleZoom()
Definition: GameView.cpp:1002
JSObject * GetScript()
This interface accepts renderable objects.
Definition: Scene.h:83
float GetFOV() const
Definition: GameView.cpp:1041
void Update(const float deltaRealTime)
Updates all the view information (i.e.
Definition: GameView.cpp:619
void CheckLightEnv()
Definition: GameView.cpp:526
InReaction
Definition: input.h:34
int Initialize()
Definition: GameView.cpp:411
Definition: Camera.h:39
CGameView(CGame *pGame)
Definition: GameView.cpp:355
Definition: GameView.h:37
CCamera * GetCamera()
Definition: GameView.cpp:391
float GetCameraPosX()
Definition: GameView.cpp:908
virtual CTerritoryTexture & GetTerritoryTexture()
Return the territory texture to be used for rendering this scene.
Definition: GameView.cpp:406
float GetCameraZ()
Definition: GameView.cpp:901
entity_id_t GetFollowedEntity()
Definition: GameView.cpp:1026
void RegisterInit()
Definition: GameView.cpp:462
float GetNear() const
Definition: GameView.cpp:1031
Class for in game playing of cinematics.
Definition: CinemaManager.h:34
virtual CLOSTexture & GetLOSTexture()
Return the LOS texture to be used for rendering this scene.
Definition: GameView.cpp:401
float GetCameraRotX()
Definition: GameView.cpp:923
NONCOPYABLE(CGameView)
This interface describes a scene to the renderer.
Definition: Scene.h:52
DECLARE_BOOLEAN_SETTING(Culling)
void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom)
Definition: GameView.cpp:938
CObjectManager & GetObjectManager() const
Definition: GameView.cpp:386
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap...
Definition: LOSTexture.h:32
InReaction HandleEvent(const SDL_Event_ *ev)
Definition: GameView.cpp:1062
InReaction game_view_handler(const SDL_Event_ *ev)
Definition: GameView.cpp:1051
u32 entity_id_t
Entity ID type.
Definition: Entity.h:23
void MoveCameraTarget(const CVector3D &target)
Definition: GameView.cpp:956
Maintains the territory boundary texture, used for rendering and for the minimap. ...
Definition: TerritoryTexture.h:29
void ResetCameraTarget(const CVector3D &target)
Definition: GameView.cpp:978