Matei
0ed2815c8b
LOS issues still outstanding: - LOS looks ugly because of quad tesselation into 2 triangles - Quad tesselation is unspecified by OpenGL (in fact using GL_QUADS on LOS quads seemed to give different tesselations than it did for the underlying terrain quads, but terrain rendering also used GL_QUADS). This should be fixed once we decide on the quad tesselation issue. - Units with traits.vision.permanent set are visible through FOW even if you havent seen them before; this should only be true when you have seen them before. But it gets even more complicated - if a permanent unit seen through FOW dies or gets upgraded or something, perhaps you should remember the old version. I'm not completely sure how to do this (probably involves cloning its actor somehow). This was SVN commit r2876.
120 lines
3.4 KiB
C++
Executable File
120 lines
3.4 KiB
C++
Executable File
#ifndef _GameView_H
|
|
#define _GameView_H
|
|
|
|
#include "Camera.h"
|
|
#include "Vector3D.h"
|
|
|
|
#include "scripting/ScriptableObject.h"
|
|
|
|
// 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.
|
|
#include "sdl.h"
|
|
|
|
class CGame;
|
|
class CGameAttributes;
|
|
class CWorld;
|
|
class CTerrain;
|
|
class CUnitManager;
|
|
class CProjectileManager;
|
|
class CModel;
|
|
|
|
class CGameView: public CJSObject<CGameView>
|
|
{
|
|
CGame *m_pGame;
|
|
CWorld *m_pWorld;
|
|
CTerrain *m_Terrain;
|
|
CCamera m_Camera;
|
|
|
|
|
|
////////////////////////////////////////
|
|
// Settings
|
|
float m_ViewScrollSpeed;
|
|
float m_ViewRotateSensitivity;
|
|
float m_ViewRotateSensitivityKeyboard;
|
|
float m_ViewRotateAboutTargetSensitivity;
|
|
float m_ViewRotateAboutTargetSensitivityKeyboard;
|
|
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.
|
|
|
|
|
|
////////////////////////////////////////
|
|
// Camera Controls State
|
|
CVector3D m_CameraDelta;
|
|
CVector3D m_CameraPivot;
|
|
//float m_CameraZoom;
|
|
std::vector<CVector3D> m_CameraTargets;
|
|
|
|
// Accumulate zooming changes across frames for smoothness
|
|
float m_ZoomDelta;
|
|
|
|
// RenderTerrain: iterate through all terrain patches and submit all patches
|
|
// in viewing frustum to the renderer, for terrain, water and LOS painting
|
|
void RenderTerrain(CTerrain *pTerrain);
|
|
|
|
// RenderModels: iterate through model list and submit all models in viewing
|
|
// frustum to the Renderer
|
|
void RenderModels(CUnitManager *pUnitMan, CProjectileManager *pProjectileManager);
|
|
|
|
// SubmitModelRecursive: recurse down given model, submitting it and all its
|
|
// descendents to the renderer
|
|
void SubmitModelRecursive(CModel *pModel);
|
|
|
|
// InitResources(): Load all graphics resources (textures, actor objects and
|
|
// alpha maps) required by the game
|
|
void InitResources();
|
|
|
|
// UnloadResources(): Unload all graphics resources loaded by InitResources
|
|
void UnloadResources();
|
|
|
|
// JS Interface
|
|
bool JSI_StartCustomSelection(JSContext *cx, uintN argc, jsval *argv);
|
|
bool JSI_EndCustomSelection(JSContext *cx, uintN argc, jsval *argv);
|
|
|
|
static void ScriptingInit();
|
|
|
|
public:
|
|
CGameView(CGame *pGame);
|
|
~CGameView();
|
|
|
|
void RegisterInit(CGameAttributes *pAttribs);
|
|
int Initialize(CGameAttributes *pGameAttributes);
|
|
|
|
// 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
|
|
void Render();
|
|
|
|
int HandleEvent(const SDL_Event* ev);
|
|
|
|
//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);
|
|
|
|
// RenderNoCull: render absolutely everything to a blank frame to force
|
|
// renderer to load required assets
|
|
void RenderNoCull();
|
|
|
|
// Camera Control Functions (used by input handler)
|
|
void ResetCamera();
|
|
void ResetCameraOrientation();
|
|
void RotateAboutTarget();
|
|
|
|
void PushCameraTarget( const CVector3D& target );
|
|
void SetCameraTarget( const CVector3D& target );
|
|
void PopCameraTarget();
|
|
|
|
inline CCamera *GetCamera()
|
|
{ return &m_Camera; }
|
|
};
|
|
extern int game_view_handler(const SDL_Event* ev);
|
|
|
|
#endif
|