2010-08-13 06:26:29 -07:00
|
|
|
/* Copyright (C) 2010 Wildfire Games.
|
2009-04-18 10:00:33 -07:00
|
|
|
* This file is part of 0 A.D.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is free software: you can redistribute it and/or modify
|
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
|
* the Free Software Foundation, either version 2 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* 0 A.D. is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
|
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
|
*/
|
|
|
|
|
|
2007-05-07 09:33:24 -07:00
|
|
|
#ifndef INCLUDED_GAMEVIEW
|
|
|
|
|
#define INCLUDED_GAMEVIEW
|
2004-07-27 14:00:53 -07:00
|
|
|
|
2006-09-24 04:25:11 -07:00
|
|
|
#include "renderer/Scene.h"
|
2010-09-26 16:05:25 -07:00
|
|
|
#include "simulation2/system/Entity.h"
|
2006-09-24 04:25:11 -07:00
|
|
|
|
2007-01-13 10:32:03 -08:00
|
|
|
#include "lib/input.h" // InReaction - can't forward-declare enum
|
|
|
|
|
|
2004-07-27 14:00:53 -07:00
|
|
|
class CGame;
|
2007-01-07 17:56:46 -08:00
|
|
|
class CObjectManager;
|
|
|
|
|
class CCamera;
|
|
|
|
|
class CCinemaManager;
|
|
|
|
|
class CVector3D;
|
2010-06-03 12:07:59 -07:00
|
|
|
struct SViewPort;
|
2004-07-27 14:00:53 -07:00
|
|
|
|
2014-03-28 13:26:32 -07:00
|
|
|
class JSObject;
|
2007-01-07 17:56:46 -08:00
|
|
|
|
|
|
|
|
class CGameViewImpl;
|
|
|
|
|
|
2009-01-03 10:40:28 -08:00
|
|
|
class CGameView : private Scene
|
2004-07-27 14:00:53 -07:00
|
|
|
{
|
2009-01-03 10:40:28 -08:00
|
|
|
NONCOPYABLE(CGameView);
|
2006-03-21 12:55:45 -08:00
|
|
|
private:
|
2007-01-07 17:56:46 -08:00
|
|
|
CGameViewImpl* m;
|
2006-02-14 16:45:16 -08:00
|
|
|
|
|
|
|
|
// Check whether lighting environment has changed and update vertex data if necessary
|
|
|
|
|
void CheckLightEnv();
|
|
|
|
|
|
2011-04-05 13:32:03 -07:00
|
|
|
public:
|
2006-09-24 04:25:11 -07:00
|
|
|
//BEGIN: Implementation of Scene
|
2011-04-05 13:32:03 -07:00
|
|
|
virtual void EnumerateObjects(const CFrustum& frustum, SceneCollector* c);
|
|
|
|
|
virtual CLOSTexture& GetLOSTexture();
|
2011-07-20 12:48:06 -07:00
|
|
|
virtual CTerritoryTexture& GetTerritoryTexture();
|
2006-09-24 04:25:11 -07:00
|
|
|
//END: Implementation of Scene
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2011-04-05 13:32:03 -07:00
|
|
|
private:
|
2004-07-31 08:57:18 -07:00
|
|
|
// InitResources(): Load all graphics resources (textures, actor objects and
|
|
|
|
|
// alpha maps) required by the game
|
2005-10-31 10:57:03 -08:00
|
|
|
//void InitResources();
|
2004-12-16 04:41:54 -08:00
|
|
|
|
|
|
|
|
// UnloadResources(): Unload all graphics resources loaded by InitResources
|
|
|
|
|
void UnloadResources();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2004-07-27 14:00:53 -07:00
|
|
|
public:
|
|
|
|
|
CGameView(CGame *pGame);
|
2004-12-16 04:41:54 -08:00
|
|
|
~CGameView();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2010-06-03 12:07:59 -07:00
|
|
|
void SetViewport(const SViewPort& vp);
|
|
|
|
|
|
2010-06-30 14:41:04 -07:00
|
|
|
void RegisterInit();
|
|
|
|
|
int Initialize();
|
2005-03-21 18:17:55 -08:00
|
|
|
|
2007-01-07 17:56:46 -08:00
|
|
|
CObjectManager& GetObjectManager() const;
|
|
|
|
|
|
2012-06-06 12:37:03 -07:00
|
|
|
/**
|
2016-11-23 03:18:37 -08:00
|
|
|
* Updates all the view information (i.e. rotate camera, scroll, whatever). This will *not* change any
|
2012-06-06 12:37:03 -07:00
|
|
|
* World information - only the *presentation*.
|
2016-11-23 03:18:37 -08:00
|
|
|
*
|
2012-06-06 12:37:03 -07:00
|
|
|
* @param deltaRealTime Elapsed real time since the last frame.
|
|
|
|
|
*/
|
|
|
|
|
void Update(const float deltaRealTime);
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2011-03-26 13:17:21 -07:00
|
|
|
void BeginFrame();
|
2004-07-27 14:00:53 -07:00
|
|
|
void Render();
|
2005-09-27 20:49:11 -07:00
|
|
|
|
2006-08-26 14:52:18 -07:00
|
|
|
InReaction HandleEvent(const SDL_Event_* ev);
|
2005-09-28 16:57:55 -07:00
|
|
|
|
2013-06-09 13:21:19 -07:00
|
|
|
float GetCameraX();
|
|
|
|
|
float GetCameraZ();
|
2014-04-06 09:27:57 -07:00
|
|
|
float GetCameraPosX();
|
|
|
|
|
float GetCameraPosY();
|
|
|
|
|
float GetCameraPosZ();
|
|
|
|
|
float GetCameraRotX();
|
|
|
|
|
float GetCameraRotY();
|
|
|
|
|
float GetCameraZoom();
|
|
|
|
|
void SetCamera(CVector3D Pos, float RotX, float RotY, float Zoom);
|
2011-12-09 23:07:04 -08:00
|
|
|
void MoveCameraTarget(const CVector3D& target);
|
2010-08-13 06:26:29 -07:00
|
|
|
void ResetCameraTarget(const CVector3D& target);
|
2010-08-13 17:52:19 -07:00
|
|
|
void ResetCameraAngleZoom();
|
2010-11-01 14:40:29 -07:00
|
|
|
void CameraFollow(entity_id_t entity, bool firstPerson);
|
2011-07-05 14:29:11 -07:00
|
|
|
entity_id_t GetFollowedEntity();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2012-04-18 13:39:00 -07:00
|
|
|
CVector3D GetSmoothPivot(CCamera &camera) const;
|
|
|
|
|
|
2011-11-17 15:34:01 -08:00
|
|
|
float GetNear() const;
|
|
|
|
|
float GetFar() const;
|
|
|
|
|
float GetFOV() const;
|
2016-11-23 03:18:37 -08:00
|
|
|
|
2013-09-12 05:40:05 -07:00
|
|
|
#define DECLARE_BOOLEAN_SETTING(NAME) \
|
|
|
|
|
bool Get##NAME##Enabled(); \
|
|
|
|
|
void Set##NAME##Enabled(bool Enabled);
|
|
|
|
|
|
|
|
|
|
DECLARE_BOOLEAN_SETTING(Culling);
|
|
|
|
|
DECLARE_BOOLEAN_SETTING(LockCullCamera);
|
|
|
|
|
DECLARE_BOOLEAN_SETTING(ConstrainCamera);
|
|
|
|
|
|
|
|
|
|
#undef DECLARE_BOOLEAN_SETTING
|
2011-11-17 15:34:01 -08:00
|
|
|
|
|
|
|
|
// Set projection of current camera using near, far, and FOV values
|
|
|
|
|
void SetCameraProjection();
|
|
|
|
|
|
2007-01-07 17:56:46 -08:00
|
|
|
CCamera *GetCamera();
|
|
|
|
|
CCinemaManager* GetCinema();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2007-01-07 17:56:46 -08:00
|
|
|
JSObject* GetScript();
|
2004-07-27 14:00:53 -07:00
|
|
|
};
|
2006-08-26 14:52:18 -07:00
|
|
|
extern InReaction game_view_handler(const SDL_Event_* ev);
|
2004-07-27 14:00:53 -07:00
|
|
|
#endif
|