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" 22 #include "simulation2/system/Entity.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 { 39 NONCOPYABLE(CGameView); 40 private: 41 CGameViewImpl* m; 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(); 50 virtual CTerritoryTexture& GetTerritoryTexture(); 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 70 CObjectManager& GetObjectManager() const; 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 83 InReaction HandleEvent(const SDL_Event_* ev); 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); 98 entity_id_t GetFollowedEntity(); 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(); 120 CCinemaManager* GetCinema(); 121 122 JSObject* GetScript(); 123 }; 124 extern InReaction game_view_handler(const SDL_Event_* ev); 125 #endif 126