Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
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 struct 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  void MoveCameraTarget(const CVector3D& target);
88  void ResetCameraTarget(const CVector3D& target);
89  void ResetCameraAngleZoom();
90  void CameraFollow(entity_id_t entity, bool firstPerson);
92 
93  CVector3D GetSmoothPivot(CCamera &camera) const;
94 
95  float GetNear() const;
96  float GetFar() const;
97  float GetFOV() const;
98  float GetCullFOV() const;
99 
100  #define DECLARE_BOOLEAN_SETTING(NAME) \
101  bool Get##NAME##Enabled(); \
102  void Set##NAME##Enabled(bool Enabled);
103 
104  DECLARE_BOOLEAN_SETTING(Culling);
105  DECLARE_BOOLEAN_SETTING(LockCullCamera);
106  DECLARE_BOOLEAN_SETTING(ConstrainCamera);
107 
108  #undef DECLARE_BOOLEAN_SETTING
109 
110  // Set projection of current camera using near, far, and FOV values
111  void SetCameraProjection();
112 
113  CCamera *GetCamera();
115 
116  JSObject* GetScript();
117 };
118 extern InReaction game_view_handler(const SDL_Event_* ev);
119 #endif
void UnloadResources()
Definition: GameView.cpp:602
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:39
float GetFar() const
Definition: GameView.cpp:1046
void BeginFrame()
Definition: GameView.cpp:473
CCinemaManager * GetCinema()
Definition: GameView.cpp:395
CVector3D GetSmoothPivot(CCamera &camera) const
Definition: GameView.cpp:667
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:504
void CameraFollow(entity_id_t entity, bool firstPerson)
Definition: GameView.cpp:1030
void Render()
Definition: GameView.cpp:496
void SetCameraProjection()
Definition: GameView.cpp:1061
float GetCameraX()
Definition: GameView.cpp:952
CGameViewImpl * m
Definition: GameView.h:41
void SetViewport(const SViewPort &vp)
Definition: GameView.cpp:379
void ResetCameraAngleZoom()
Definition: GameView.cpp:1012
JSObject * GetScript()
This interface accepts renderable objects.
Definition: Scene.h:82
float GetFOV() const
Definition: GameView.cpp:1051
void Update(const float deltaRealTime)
Updates all the view information (i.e.
Definition: GameView.cpp:672
void CheckLightEnv()
Definition: GameView.cpp:579
InReaction
Definition: input.h:34
int Initialize()
Definition: GameView.cpp:410
Definition: Camera.h:39
InReaction game_view_handler(const SDL_Event_ *ev)
Definition: GameView.cpp:1066
CGameView(CGame *pGame)
Definition: GameView.cpp:354
CCamera * GetCamera()
Definition: GameView.cpp:390
virtual CTerritoryTexture & GetTerritoryTexture()
Return the territory texture to be used for rendering this scene.
Definition: GameView.cpp:405
float GetCameraZ()
Definition: GameView.cpp:959
entity_id_t GetFollowedEntity()
Definition: GameView.cpp:1036
void RegisterInit()
Definition: GameView.cpp:461
float GetNear() const
Definition: GameView.cpp:1041
virtual CLOSTexture & GetLOSTexture()
Return the LOS texture to be used for rendering this scene.
Definition: GameView.cpp:400
float GetCullFOV() const
Definition: GameView.cpp:1056
NONCOPYABLE(CGameView)
This interface describes a scene to the renderer.
Definition: Scene.h:51
DECLARE_BOOLEAN_SETTING(Culling)
CObjectManager & GetObjectManager() const
Definition: GameView.cpp:385
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:1077
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24
void MoveCameraTarget(const CVector3D &target)
Definition: GameView.cpp:966
Maintains the territory boundary texture, used for rendering and for the minimap. ...
void ResetCameraTarget(const CVector3D &target)
Definition: GameView.cpp:988