2007-05-07 09:33:24 -07:00
|
|
|
#ifndef INCLUDED_GAMEVIEW
|
|
|
|
|
#define INCLUDED_GAMEVIEW
|
2004-07-27 14:00:53 -07:00
|
|
|
|
2005-10-19 10:16:34 -07:00
|
|
|
// needed by minimap
|
|
|
|
|
extern float g_MaxZoomHeight; //note: Max terrain height is this minus YMinOffset
|
|
|
|
|
extern float g_YMinOffset;
|
|
|
|
|
|
2006-09-24 04:25:11 -07:00
|
|
|
#include "renderer/Scene.h"
|
|
|
|
|
|
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;
|
|
|
|
|
class CGameAttributes;
|
2007-01-07 17:56:46 -08:00
|
|
|
class CObjectManager;
|
|
|
|
|
class CCamera;
|
|
|
|
|
class CCinemaManager;
|
|
|
|
|
class CVector3D;
|
2005-12-06 12:16:50 -08:00
|
|
|
class CEntity;
|
2004-07-27 14:00:53 -07:00
|
|
|
|
2007-01-07 17:56:46 -08:00
|
|
|
struct JSObject;
|
|
|
|
|
|
|
|
|
|
class CGameViewImpl;
|
|
|
|
|
|
2007-02-01 06:46:14 -08:00
|
|
|
class CGameView : private Scene, public boost::noncopyable
|
2004-07-27 14:00:53 -07:00
|
|
|
{
|
2006-03-21 12:55:45 -08:00
|
|
|
public:
|
|
|
|
|
static const float defaultFOV, defaultNear, defaultFar;
|
|
|
|
|
|
|
|
|
|
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();
|
|
|
|
|
|
2006-09-24 04:25:11 -07:00
|
|
|
//BEGIN: Implementation of Scene
|
|
|
|
|
void EnumerateObjects(const CFrustum& frustum, SceneCollector* c);
|
|
|
|
|
//END: Implementation of Scene
|
2006-02-14 16:45:16 -08:00
|
|
|
|
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
|
|
|
|
2005-03-21 18:17:55 -08:00
|
|
|
void RegisterInit(CGameAttributes *pAttribs);
|
2005-05-03 14:36:57 -07:00
|
|
|
int Initialize(CGameAttributes *pGameAttributes);
|
2005-03-21 18:17:55 -08:00
|
|
|
|
2007-01-07 17:56:46 -08:00
|
|
|
CObjectManager& GetObjectManager() const;
|
|
|
|
|
|
2006-02-14 16:45:16 -08:00
|
|
|
// Update: Update all the view information (i.e. rotate camera, scroll,
|
2004-07-31 08:57:18 -07:00
|
|
|
// whatever). This will *not* change any World information - only the
|
|
|
|
|
// *presentation*
|
|
|
|
|
void Update(float DeltaTime);
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2004-07-31 08:57:18 -07:00
|
|
|
// Render: Render the World
|
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
|
|
|
|
2005-09-27 20:49:11 -07:00
|
|
|
//Keep the camera in between boundaries/smooth camera scrolling/translating
|
|
|
|
|
//Should call this whenever moving (translating) the camera
|
2007-01-07 17:56:46 -08:00
|
|
|
void CameraLock(const CVector3D& Trans, bool smooth=true);
|
2005-09-27 20:49:11 -07:00
|
|
|
void CameraLock(float x, float y, float z, bool smooth=true);
|
|
|
|
|
|
2004-07-31 08:57:18 -07:00
|
|
|
// Camera Control Functions (used by input handler)
|
|
|
|
|
void ResetCamera();
|
2004-08-02 16:14:54 -07:00
|
|
|
void ResetCameraOrientation();
|
2004-07-31 08:57:18 -07:00
|
|
|
void RotateAboutTarget();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
2004-07-31 08:57:18 -07:00
|
|
|
void PushCameraTarget( const CVector3D& target );
|
|
|
|
|
void SetCameraTarget( const CVector3D& target );
|
|
|
|
|
void PopCameraTarget();
|
2005-12-05 22:58:30 -08:00
|
|
|
|
|
|
|
|
//First person camera attachment (through the eyes of the unit)
|
2005-12-06 12:16:50 -08:00
|
|
|
void ToUnitView(CEntity* target, CModel* prop);
|
2005-12-05 22:58:30 -08:00
|
|
|
//Keep view the same but follow the unit
|
2007-01-07 17:56:46 -08:00
|
|
|
void AttachToUnit(CEntity* target);
|
|
|
|
|
|
|
|
|
|
bool IsAttached();
|
|
|
|
|
bool IsUnitView();
|
2006-02-14 16:45:16 -08:00
|
|
|
|
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();
|
2008-04-06 07:03:23 -07:00
|
|
|
static void ScriptingInit();
|
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);
|
2005-08-14 16:34:37 -07:00
|
|
|
|
2004-07-27 14:00:53 -07:00
|
|
|
#endif
|