2004-07-27 23:00:53 +02:00
|
|
|
#ifndef _GameView_H
|
|
|
|
#define _GameView_H
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
#include "Camera.h"
|
|
|
|
#include "Vector3D.h"
|
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
#include "scripting/ScriptableObject.h"
|
|
|
|
|
2005-09-30 02:59:42 +02:00
|
|
|
// note: cannot forward declare SDL_Event since it is a nameless union
|
|
|
|
// in the standard SDL library and a nameless struct in wsdl, so
|
|
|
|
// include the full SDL header instead.
|
2005-08-15 01:34:37 +02:00
|
|
|
#include "sdl.h"
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
class CGame;
|
|
|
|
class CGameAttributes;
|
|
|
|
class CWorld;
|
|
|
|
class CTerrain;
|
|
|
|
class CUnitManager;
|
2005-05-10 09:13:25 +02:00
|
|
|
class CProjectileManager;
|
2004-07-27 23:00:53 +02:00
|
|
|
class CModel;
|
|
|
|
|
2005-05-18 07:32:09 +02:00
|
|
|
class CGameView: public CJSObject<CGameView>
|
2004-07-27 23:00:53 +02:00
|
|
|
{
|
|
|
|
CGame *m_pGame;
|
|
|
|
CWorld *m_pWorld;
|
2005-09-28 05:49:11 +02:00
|
|
|
CTerrain *m_Terrain;
|
2004-07-31 17:57:18 +02:00
|
|
|
CCamera m_Camera;
|
2005-09-28 05:49:11 +02:00
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
////////////////////////////////////////
|
|
|
|
// Settings
|
|
|
|
float m_ViewScrollSpeed;
|
|
|
|
float m_ViewRotateSensitivity;
|
2004-11-11 08:09:32 +01:00
|
|
|
float m_ViewRotateSensitivityKeyboard;
|
2004-07-31 17:57:18 +02:00
|
|
|
float m_ViewRotateAboutTargetSensitivity;
|
2004-11-11 08:09:32 +01:00
|
|
|
float m_ViewRotateAboutTargetSensitivityKeyboard;
|
2004-07-31 17:57:18 +02:00
|
|
|
float m_ViewDragSensitivity;
|
|
|
|
float m_ViewZoomSensitivityWheel;
|
|
|
|
float m_ViewZoomSensitivity;
|
|
|
|
float m_ViewZoomSmoothness; // 0.0 = instantaneous zooming, 1.0 = so slow it never moves
|
|
|
|
float m_ViewSnapSmoothness; // Just the same.
|
|
|
|
|
2005-09-28 05:49:11 +02:00
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
////////////////////////////////////////
|
|
|
|
// Camera Controls State
|
|
|
|
CVector3D m_CameraDelta;
|
|
|
|
CVector3D m_CameraPivot;
|
|
|
|
//float m_CameraZoom;
|
|
|
|
std::vector<CVector3D> m_CameraTargets;
|
|
|
|
|
2005-09-29 01:57:55 +02:00
|
|
|
// Accumulate zooming changes across frames for smoothness
|
|
|
|
float m_ZoomDelta;
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
// RenderTerrain: iterate through all terrain patches and submit all patches
|
2005-09-18 05:47:15 +02:00
|
|
|
// in viewing frustum to the renderer, for terrain painting
|
2004-07-27 23:00:53 +02:00
|
|
|
void RenderTerrain(CTerrain *pTerrain);
|
|
|
|
|
2005-09-18 05:47:15 +02:00
|
|
|
// RenderWater: iterate through all terrain patches and submit all patches
|
|
|
|
// in viewing frustum to the renderer, for water painting
|
|
|
|
void RenderWater(CTerrain *pTerrain);
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
// RenderModels: iterate through model list and submit all models in viewing
|
|
|
|
// frustum to the Renderer
|
2005-05-10 09:13:25 +02:00
|
|
|
void RenderModels(CUnitManager *pUnitMan, CProjectileManager *pProjectileManager);
|
2004-07-27 23:00:53 +02:00
|
|
|
|
|
|
|
// SubmitModelRecursive: recurse down given model, submitting it and all its
|
|
|
|
// descendents to the renderer
|
|
|
|
void SubmitModelRecursive(CModel *pModel);
|
2004-07-31 17:57:18 +02:00
|
|
|
|
|
|
|
// InitResources(): Load all graphics resources (textures, actor objects and
|
|
|
|
// alpha maps) required by the game
|
|
|
|
void InitResources();
|
2004-12-16 13:41:54 +01:00
|
|
|
|
|
|
|
// UnloadResources(): Unload all graphics resources loaded by InitResources
|
|
|
|
void UnloadResources();
|
2005-05-18 07:32:09 +02:00
|
|
|
|
|
|
|
// JS Interface
|
|
|
|
bool JSI_StartCustomSelection(JSContext *cx, uintN argc, jsval *argv);
|
|
|
|
bool JSI_EndCustomSelection(JSContext *cx, uintN argc, jsval *argv);
|
|
|
|
|
|
|
|
static void ScriptingInit();
|
2004-12-16 13:41:54 +01:00
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
public:
|
|
|
|
CGameView(CGame *pGame);
|
2004-12-16 13:41:54 +01:00
|
|
|
~CGameView();
|
2004-07-27 23:00:53 +02:00
|
|
|
|
2005-03-22 03:17:55 +01:00
|
|
|
void RegisterInit(CGameAttributes *pAttribs);
|
2005-05-03 23:36:57 +02:00
|
|
|
int Initialize(CGameAttributes *pGameAttributes);
|
2005-03-22 03:17:55 +01:00
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
// Update: Update all the view information (i.e. rotate camera, scroll,
|
|
|
|
// whatever). This will *not* change any World information - only the
|
|
|
|
// *presentation*
|
|
|
|
void Update(float DeltaTime);
|
|
|
|
|
|
|
|
// Render: Render the World
|
2004-07-27 23:00:53 +02:00
|
|
|
void Render();
|
2005-09-28 05:49:11 +02:00
|
|
|
|
2005-09-29 01:57:55 +02:00
|
|
|
int HandleEvent(const SDL_Event* ev);
|
|
|
|
|
2005-09-28 05:49:11 +02:00
|
|
|
//Keep the camera in between boundaries/smooth camera scrolling/translating
|
|
|
|
//Should call this whenever moving (translating) the camera
|
|
|
|
void CameraLock(CVector3D Trans, bool smooth=true);
|
|
|
|
void CameraLock(float x, float y, float z, bool smooth=true);
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
// RenderNoCull: render absolutely everything to a blank frame to force
|
|
|
|
// renderer to load required assets
|
|
|
|
void RenderNoCull();
|
|
|
|
|
2004-07-31 17:57:18 +02:00
|
|
|
// Camera Control Functions (used by input handler)
|
|
|
|
void ResetCamera();
|
2004-08-03 01:14:54 +02:00
|
|
|
void ResetCameraOrientation();
|
2004-07-31 17:57:18 +02:00
|
|
|
void RotateAboutTarget();
|
|
|
|
|
|
|
|
void PushCameraTarget( const CVector3D& target );
|
|
|
|
void SetCameraTarget( const CVector3D& target );
|
|
|
|
void PopCameraTarget();
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
inline CCamera *GetCamera()
|
2004-07-31 17:57:18 +02:00
|
|
|
{ return &m_Camera; }
|
2004-07-27 23:00:53 +02:00
|
|
|
};
|
2005-08-15 01:34:37 +02:00
|
|
|
extern int game_view_handler(const SDL_Event* ev);
|
|
|
|
|
2004-07-27 23:00:53 +02:00
|
|
|
#endif
|