Pyrogenesis  13997
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
GameView.cpp
Go to the documentation of this file.
1 /* Copyright (C) 2012 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 #include "precompiled.h"
19 
20 #include "GameView.h"
21 
22 #include "graphics/Camera.h"
23 #include "graphics/CinemaTrack.h"
25 #include "graphics/HFTracer.h"
26 #include "graphics/LightEnv.h"
27 #include "graphics/LOSTexture.h"
28 #include "graphics/Model.h"
29 #include "graphics/ObjectManager.h"
30 #include "graphics/Patch.h"
32 #include "graphics/Terrain.h"
35 #include "graphics/Unit.h"
36 #include "graphics/UnitManager.h"
38 #include "lib/input.h"
39 #include "lib/timer.h"
41 #include "maths/MathUtil.h"
42 #include "maths/Matrix3D.h"
43 #include "maths/Quaternion.h"
44 #include "ps/ConfigDB.h"
45 #include "ps/Filesystem.h"
46 #include "ps/Game.h"
47 #include "ps/Globals.h"
48 #include "ps/Hotkey.h"
49 #include "ps/Joystick.h"
50 #include "ps/Loader.h"
51 #include "ps/LoaderThunks.h"
52 #include "ps/Profile.h"
53 #include "ps/Pyrogenesis.h"
54 #include "ps/TouchInput.h"
55 #include "ps/World.h"
56 #include "renderer/Renderer.h"
57 #include "renderer/WaterManager.h"
61 
62 extern int g_xres, g_yres;
63 
64 // Maximum distance outside the edge of the map that the camera's
65 // focus point can be moved
66 static const float CAMERA_EDGE_MARGIN = 2.0f*TERRAIN_TILE_SIZE;
67 
68 /**
69  * A value with exponential decay towards the target value.
70  */
72 {
73 public:
74  CSmoothedValue(float value, float smoothness, float minDelta)
75  : m_Target(value), m_Current(value), m_Smoothness(smoothness), m_MinDelta(minDelta)
76  {
77  }
78 
80  {
81  return m_Current;
82  }
83 
84  void SetValueSmoothly(float value)
85  {
86  m_Target = value;
87  }
88 
89  void AddSmoothly(float value)
90  {
91  m_Target += value;
92  }
93 
94  void Add(float value)
95  {
96  m_Target += value;
97  m_Current += value;
98  }
99 
100  float GetValue()
101  {
102  return m_Target;
103  }
104 
105  void SetValue(float value)
106  {
107  m_Target = value;
108  m_Current = value;
109  }
110 
111  float Update(float time)
112  {
113  if (fabs(m_Target - m_Current) < m_MinDelta)
114  return 0.0f;
115 
116  double p = pow((double)m_Smoothness, 10.0 * (double)time);
117  // (add the factor of 10 so that smoothnesses don't have to be tiny numbers)
118 
119  double delta = (m_Target - m_Current) * (1.0 - p);
120  m_Current += delta;
121  return (float)delta;
122  }
123 
124  void ClampSmoothly(float min, float max)
125  {
126  m_Target = Clamp(m_Target, (double)min, (double)max);
127  }
128 
129  // Wrap so 'target' is in the range [min, max]
130  void Wrap(float min, float max)
131  {
132  double t = fmod(m_Target - min, (double)(max - min));
133  if (t < 0)
134  t += max - min;
135  t += min;
136 
137  m_Current += t - m_Target;
138  m_Target = t;
139  }
140 
141 private:
142  double m_Target; // the value which m_Current is tending towards
143  double m_Current;
144  // (We use double because the extra precision is worthwhile here)
145 
146  float m_MinDelta; // cutoff where we stop moving (to avoid ugly shimmering effects)
147 public:
149 };
150 
152 {
154 public:
156  : Game(game),
158  ObjectManager(MeshManager, SkeletonAnimManager, *game->GetSimulation2()),
159  LOSTexture(*game->GetSimulation2()),
160  TerritoryTexture(*game->GetSimulation2()),
161  ViewCamera(),
162  CullCamera(),
163  LockCullCamera(false),
164  ConstrainCamera(true),
165  Culling(true),
167  FollowFirstPerson(false),
168 
169  // Dummy values (these will be filled in by the config file)
170  ViewScrollSpeed(0),
172  ViewRotateXSpeed(0),
173  ViewRotateXMin(0),
174  ViewRotateXMax(0),
176  ViewRotateYSpeed(0),
180  ViewDragSpeed(0),
181  ViewZoomSpeed(0),
183  ViewZoomMin(0),
184  ViewZoomMax(0),
185  ViewZoomDefault(0),
187  ViewFOV(DEGTORAD(45.f)),
188  ViewNear(2.f),
189  ViewFar(4096.f),
190  JoystickPanX(-1),
191  JoystickPanY(-1),
192  JoystickRotateX(-1),
193  JoystickRotateY(-1),
194  JoystickZoomIn(-1),
195  JoystickZoomOut(-1),
196  HeightSmoothness(0.5f),
197  HeightMin(16.f),
198 
199  PosX(0, 0, 0.01f),
200  PosY(0, 0, 0.01f),
201  PosZ(0, 0, 0.01f),
202  Zoom(0, 0, 0.1f),
203  RotateX(0, 0, 0.001f),
204  RotateY(0, 0, 0.001f)
205  {
206  }
207 
215 
216  /**
217  * this camera controls the eye position when rendering
218  */
220 
221  /**
222  * this camera controls the frustum that is used for culling
223  * and shadow calculations
224  *
225  * Note that all code that works with camera movements should only change
226  * m_ViewCamera. The render functions automatically sync the cull camera to
227  * the view camera depending on the value of m_LockCullCamera.
228  */
230 
231  /**
232  * When @c true, the cull camera is locked in place.
233  * When @c false, the cull camera follows the view camera.
234  *
235  * Exposed to JS as gameView.lockCullCamera
236  */
238 
239  /**
240  * When @c true, culling is enabled so that only models that have a chance of
241  * being visible are sent to the renderer.
242  * Otherwise, the entire world is sent to the renderer.
243  *
244  * Exposed to JS as gameView.culling
245  */
246  bool Culling;
247 
248  /**
249  * Whether the camera movement should be constrained by min/max limits
250  * and terrain avoidance.
251  */
253 
254  /**
255  * Cache global lighting environment. This is used to check whether the
256  * environment has changed during the last frame, so that vertex data can be updated etc.
257  */
259 
261 
262  /**
263  * Entity for the camera to follow, or INVALID_ENTITY if none.
264  */
266 
267  /**
268  * Whether to follow FollowEntity in first-person mode.
269  */
271 
272  ////////////////////////////////////////
273  // Settings
287  float ViewZoomMin;
288  float ViewZoomMax;
291  float ViewFOV;
292  float ViewNear;
293  float ViewFar;
301  float HeightMin;
302 
303  ////////////////////////////////////////
304  // Camera Controls State
309  CSmoothedValue RotateX; // inclination around x axis (relative to camera)
310  CSmoothedValue RotateY; // rotation around y (vertical) axis
311 };
312 
313 #define IMPLEMENT_BOOLEAN_SETTING(NAME) \
314 bool CGameView::Get##NAME##Enabled() \
315 { \
316  return m->NAME; \
317 } \
318 \
319 void CGameView::Set##NAME##Enabled(bool Enabled) \
320 { \
321  m->NAME = Enabled; \
322 }
323 
325 IMPLEMENT_BOOLEAN_SETTING(LockCullCamera);
326 IMPLEMENT_BOOLEAN_SETTING(ConstrainCamera);
327 
328 #undef IMPLEMENT_BOOLEAN_SETTING
329 
330 static void SetupCameraMatrixSmooth(CGameViewImpl* m, CMatrix3D* orientation)
331 {
332  orientation->SetIdentity();
333  orientation->RotateX(m->RotateX.GetSmoothedValue());
334  orientation->RotateY(m->RotateY.GetSmoothedValue());
336 }
337 
339 {
340  orientation->SetIdentity();
341  orientation->RotateX(m->RotateX.GetSmoothedValue());
342  orientation->RotateY(m->RotateY.GetSmoothedValue());
343  orientation->Translate(m->PosX.GetValue(), m->PosY.GetValue(), m->PosZ.GetValue());
344 }
345 
347 {
348  orientation->SetIdentity();
349  orientation->RotateX(m->RotateX.GetValue());
350  orientation->RotateY(m->RotateY.GetValue());
351  orientation->Translate(m->PosX.GetValue(), m->PosY.GetValue(), m->PosZ.GetValue());
352 }
353 
355  m(new CGameViewImpl(pGame))
356 {
357  SViewPort vp;
358  vp.m_X=0;
359  vp.m_Y=0;
360  vp.m_Width=g_xres;
361  vp.m_Height=g_yres;
362  m->ViewCamera.SetViewPort(vp);
363 
367 
368  m->CullCamera = m->ViewCamera;
369  g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera);
370 }
371 
373 {
374  UnloadResources();
375 
376  delete m;
377 }
378 
380 {
381  m->ViewCamera.SetViewPort(vp);
383 }
384 
386 {
387  return m->ObjectManager;
388 }
389 
391 {
392  return &m->ViewCamera;
393 }
394 
396 {
397  return &m->TrackManager;
398 };
399 
401 {
402  return m->LOSTexture;
403 }
404 
406 {
407  return m->TerritoryTexture;
408 }
409 
411 {
412  CFG_GET_VAL("view.scroll.speed", Float, m->ViewScrollSpeed);
413  CFG_GET_VAL("view.scroll.speed.modifier", Float, m->ViewScrollSpeedModifier);
414  CFG_GET_VAL("view.rotate.x.speed", Float, m->ViewRotateXSpeed);
415  CFG_GET_VAL("view.rotate.x.min", Float, m->ViewRotateXMin);
416  CFG_GET_VAL("view.rotate.x.max", Float, m->ViewRotateXMax);
417  CFG_GET_VAL("view.rotate.x.default", Float, m->ViewRotateXDefault);
418  CFG_GET_VAL("view.rotate.y.speed", Float, m->ViewRotateYSpeed);
419  CFG_GET_VAL("view.rotate.y.speed.wheel", Float, m->ViewRotateYSpeedWheel);
420  CFG_GET_VAL("view.rotate.y.default", Float, m->ViewRotateYDefault);
421  CFG_GET_VAL("view.rotate.speed.modifier", Float, m->ViewRotateSpeedModifier);
422  CFG_GET_VAL("view.drag.speed", Float, m->ViewDragSpeed);
423  CFG_GET_VAL("view.zoom.speed", Float, m->ViewZoomSpeed);
424  CFG_GET_VAL("view.zoom.speed.wheel", Float, m->ViewZoomSpeedWheel);
425  CFG_GET_VAL("view.zoom.min", Float, m->ViewZoomMin);
426  CFG_GET_VAL("view.zoom.max", Float, m->ViewZoomMax);
427  CFG_GET_VAL("view.zoom.default", Float, m->ViewZoomDefault);
428  CFG_GET_VAL("view.zoom.speed.modifier", Float, m->ViewZoomSpeedModifier);
429 
430  CFG_GET_VAL("joystick.camera.pan.x", Int, m->JoystickPanX);
431  CFG_GET_VAL("joystick.camera.pan.y", Int, m->JoystickPanY);
432  CFG_GET_VAL("joystick.camera.rotate.x", Int, m->JoystickRotateX);
433  CFG_GET_VAL("joystick.camera.rotate.y", Int, m->JoystickRotateY);
434  CFG_GET_VAL("joystick.camera.zoom.in", Int, m->JoystickZoomIn);
435  CFG_GET_VAL("joystick.camera.zoom.out", Int, m->JoystickZoomOut);
436 
437  CFG_GET_VAL("view.height.smoothness", Float, m->HeightSmoothness);
438  CFG_GET_VAL("view.height.min", Float, m->HeightMin);
439 
440  CFG_GET_VAL("view.pos.smoothness", Float, m->PosX.m_Smoothness);
441  CFG_GET_VAL("view.pos.smoothness", Float, m->PosY.m_Smoothness);
442  CFG_GET_VAL("view.pos.smoothness", Float, m->PosZ.m_Smoothness);
443  CFG_GET_VAL("view.zoom.smoothness", Float, m->Zoom.m_Smoothness);
444  CFG_GET_VAL("view.rotate.x.smoothness", Float, m->RotateX.m_Smoothness);
445  CFG_GET_VAL("view.rotate.y.smoothness", Float, m->RotateY.m_Smoothness);
446 
447  CFG_GET_VAL("view.near", Float, m->ViewNear);
448  CFG_GET_VAL("view.far", Float, m->ViewFar);
449  CFG_GET_VAL("view.fov", Float, m->ViewFOV);
450 
451  // Convert to radians
454  m->ViewFOV = DEGTORAD(m->ViewFOV);
455 
456  return 0;
457 }
458 
459 
460 
462 {
463  // CGameView init
464  RegMemFun(this, &CGameView::Initialize, L"CGameView init", 1);
465 
466  // previously done by CGameView::InitResources
467  RegMemFun(g_TexMan.GetSingletonPtr(), &CTerrainTextureManager::LoadTerrainTextures, L"LoadTerrainTextures", 60);
468  RegMemFun(g_Renderer.GetSingletonPtr(), &CRenderer::LoadAlphaMaps, L"LoadAlphaMaps", 5);
469  RegMemFun(g_Renderer.GetSingletonPtr()->GetWaterManager(), &WaterManager::LoadWaterTextures, L"LoadWaterTextures", 80);
470 }
471 
472 
474 {
475  if (m->LockCullCamera == false)
476  {
477  // Set up cull camera
478  m->CullCamera = m->ViewCamera;
479 
480  // One way to fix shadows popping in at the edge of the screen is to widen the culling frustum so that
481  // objects aren't culled as early. The downside is that objects will get rendered even though they appear
482  // off screen, which is somewhat inefficient. A better solution would be to decouple shadow map rendering
483  // from model rendering; as it is now, a shadow map is only rendered if its associated model is to be
484  // rendered.
485  // (See http://trac.wildfiregames.com/ticket/504)
488  }
489  g_Renderer.SetSceneCamera(m->ViewCamera, m->CullCamera);
490 
491  CheckLightEnv();
492 
494 }
495 
497 {
498  g_Renderer.RenderScene(*this);
499 }
500 
501 ///////////////////////////////////////////////////////////
502 // This callback is part of the Scene interface
503 // Submit all objects visible in the given frustum
505 {
506  {
507  PROFILE3("submit terrain");
508 
509  CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain();
510  const ssize_t patchesPerSide = pTerrain->GetPatchesPerSide();
511 
512  // find out which patches will be drawn
513  for (ssize_t j=0; j<patchesPerSide; j++) {
514  for (ssize_t i=0; i<patchesPerSide; i++) {
515  CPatch* patch=pTerrain->GetPatch(i,j); // can't fail
516 
517  // If the patch is underwater, calculate a bounding box that also contains the water plane
518  CBoundingBoxAligned bounds = patch->GetWorldBounds();
519  float waterHeight = g_Renderer.GetWaterManager()->m_WaterHeight + 0.001f;
520  if(bounds[1].Y < waterHeight) {
521  bounds[1].Y = waterHeight;
522  }
523 
524  if (!m->Culling || frustum.IsBoxVisible (CVector3D(0,0,0), bounds)) {
525  //c->Submit(patch);
526 
527  // set the renderstate for this patch
528  patch->setDrawState(true);
529 
530  // set the renderstate for the neighbors
531  CPatch *nPatch;
532 
533  nPatch = pTerrain->GetPatch(i-1,j-1);
534  if(nPatch) nPatch->setDrawState(true);
535 
536  nPatch = pTerrain->GetPatch(i,j-1);
537  if(nPatch) nPatch->setDrawState(true);
538 
539  nPatch = pTerrain->GetPatch(i+1,j-1);
540  if(nPatch) nPatch->setDrawState(true);
541 
542  nPatch = pTerrain->GetPatch(i-1,j);
543  if(nPatch) nPatch->setDrawState(true);
544 
545  nPatch = pTerrain->GetPatch(i+1,j);
546  if(nPatch) nPatch->setDrawState(true);
547 
548  nPatch = pTerrain->GetPatch(i-1,j+1);
549  if(nPatch) nPatch->setDrawState(true);
550 
551  nPatch = pTerrain->GetPatch(i,j+1);
552  if(nPatch) nPatch->setDrawState(true);
553 
554  nPatch = pTerrain->GetPatch(i+1,j+1);
555  if(nPatch) nPatch->setDrawState(true);
556  }
557  }
558  }
559 
560  // draw the patches
561  for (ssize_t j=0; j<patchesPerSide; j++)
562  {
563  for (ssize_t i=0; i<patchesPerSide; i++)
564  {
565  CPatch* patch=pTerrain->GetPatch(i,j); // can't fail
566  if(patch->getDrawState() == true)
567  {
568  c->Submit(patch);
569  patch->setDrawState(false);
570  }
571  }
572  }
573  }
574 
575  m->Game->GetSimulation2()->RenderSubmit(*c, frustum, m->Culling);
576 }
577 
578 
580 {
581  if (m->CachedLightEnv == g_LightEnv)
582  return;
583 
585  g_Renderer.MakeShadersDirty();
586 
588  CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain();
589 
590  if (!pTerrain)
591  return;
592 
593  PROFILE("update light env");
595 
596  const std::vector<CUnit*>& units = m->Game->GetWorld()->GetUnitManager().GetUnits();
597  for (size_t i = 0; i < units.size(); ++i)
598  units[i]->GetModel().SetDirtyRec(RENDERDATA_UPDATE_COLOR);
599 }
600 
601 
603 {
604  g_TexMan.UnloadTerrainTextures();
605  g_Renderer.UnloadAlphaMaps();
606  g_Renderer.GetWaterManager()->UnloadWaterTextures();
607 }
608 
609 static void FocusHeight(CGameViewImpl* m, bool smooth)
610 {
611  /*
612  The camera pivot height is moved towards ground level.
613  To prevent excessive zoom when looking over a cliff,
614  the target ground level is the maximum of the ground level at the camera's near and pivot points.
615  The ground levels are filtered to achieve smooth camera movement.
616  The filter radius is proportional to the zoom level.
617  The camera height is clamped to prevent map penetration.
618  */
619 
620  if (!m->ConstrainCamera)
621  return;
622 
623  CCamera targetCam = m->ViewCamera;
625 
626  const CVector3D position = targetCam.m_Orientation.GetTranslation();
627  const CVector3D forwards = targetCam.m_Orientation.GetIn();
628 
629  // horizontal view radius
630  const float radius = sqrtf(forwards.X * forwards.X + forwards.Z * forwards.Z) * m->Zoom.GetSmoothedValue();
631  const float near_radius = radius * m->HeightSmoothness;
632  const float pivot_radius = radius * m->HeightSmoothness;
633 
634  const CVector3D nearPoint = position + forwards * m->ViewNear;
635  const CVector3D pivotPoint = position + forwards * m->Zoom.GetSmoothedValue();
636 
637  const float ground = m->Game->GetWorld()->GetTerrain()->GetExactGroundLevel(nearPoint.X, nearPoint.Z);
638 
639  // filter ground levels for smooth camera movement
640  const float filtered_near_ground = m->Game->GetWorld()->GetTerrain()->GetFilteredGroundLevel(nearPoint.X, nearPoint.Z, near_radius);
641  const float filtered_pivot_ground = m->Game->GetWorld()->GetTerrain()->GetFilteredGroundLevel(pivotPoint.X, pivotPoint.Z, pivot_radius);
642 
643  // filtered maximum visible ground level in view
644  const float filtered_ground = std::max(filtered_near_ground, filtered_pivot_ground);
645 
646  // target camera height above pivot point
647  const float pivot_height = -forwards.Y * (m->Zoom.GetSmoothedValue() - m->ViewNear);
648  // minimum camera height above filtered ground level
649  const float min_height = (m->HeightMin + ground - filtered_ground);
650 
651  const float target_height = std::max(pivot_height, min_height);
652  const float height = (nearPoint.Y - filtered_ground);
653  const float diff = target_height - height;
654  if (fabsf(diff) < 0.0001f)
655  return;
656 
657  if (smooth)
658  {
659  m->PosY.AddSmoothly(diff);
660  }
661  else
662  {
663  m->PosY.Add(diff);
664  }
665 }
666 
668 {
669  return camera.m_Orientation.GetTranslation() + camera.m_Orientation.GetIn() * m->Zoom.GetSmoothedValue();
670 }
671 
672 void CGameView::Update(const float deltaRealTime)
673 {
674  // If camera movement is being handled by the touch-input system,
675  // then we should stop to avoid conflicting with it
676  if (g_TouchInput.IsEnabled())
677  return;
678 
679  if (!g_app_has_focus)
680  return;
681 
683  {
684  if (! m->TrackManager.Update(deltaRealTime))
685  {
686 // ResetCamera();
687  }
688  return;
689  }
690 
691  // Calculate mouse movement
692  static int mouse_last_x = 0;
693  static int mouse_last_y = 0;
694  int mouse_dx = g_mouse_x - mouse_last_x;
695  int mouse_dy = g_mouse_y - mouse_last_y;
696  mouse_last_x = g_mouse_x;
697  mouse_last_y = g_mouse_y;
698 
699  if (HotkeyIsPressed("camera.rotate.cw"))
700  m->RotateY.AddSmoothly(m->ViewRotateYSpeed * deltaRealTime);
701  if (HotkeyIsPressed("camera.rotate.ccw"))
702  m->RotateY.AddSmoothly(-m->ViewRotateYSpeed * deltaRealTime);
703  if (HotkeyIsPressed("camera.rotate.up"))
704  m->RotateX.AddSmoothly(-m->ViewRotateXSpeed * deltaRealTime);
705  if (HotkeyIsPressed("camera.rotate.down"))
706  m->RotateX.AddSmoothly(m->ViewRotateXSpeed * deltaRealTime);
707 
708  float moveRightward = 0.f;
709  float moveForward = 0.f;
710 
711  if (HotkeyIsPressed("camera.pan"))
712  {
713  moveRightward += m->ViewDragSpeed * mouse_dx;
714  moveForward += m->ViewDragSpeed * -mouse_dy;
715  }
716 
717  if (g_mouse_active)
718  {
719  if (g_mouse_x >= g_xres - 2 && g_mouse_x < g_xres)
720  moveRightward += m->ViewScrollSpeed * deltaRealTime;
721  else if (g_mouse_x <= 3 && g_mouse_x >= 0)
722  moveRightward -= m->ViewScrollSpeed * deltaRealTime;
723 
724  if (g_mouse_y >= g_yres - 2 && g_mouse_y < g_yres)
725  moveForward -= m->ViewScrollSpeed * deltaRealTime;
726  else if (g_mouse_y <= 3 && g_mouse_y >= 0)
727  moveForward += m->ViewScrollSpeed * deltaRealTime;
728  }
729 
730  if (HotkeyIsPressed("camera.right"))
731  moveRightward += m->ViewScrollSpeed * deltaRealTime;
732  if (HotkeyIsPressed("camera.left"))
733  moveRightward -= m->ViewScrollSpeed * deltaRealTime;
734  if (HotkeyIsPressed("camera.up"))
735  moveForward += m->ViewScrollSpeed * deltaRealTime;
736  if (HotkeyIsPressed("camera.down"))
737  moveForward -= m->ViewScrollSpeed * deltaRealTime;
738 
739  if (g_Joystick.IsEnabled())
740  {
741  // This could all be improved with extra speed and sensitivity settings
742  // (maybe use pow to allow finer control?), and inversion settings
743 
744  moveRightward += g_Joystick.GetAxisValue(m->JoystickPanX) * m->ViewScrollSpeed * deltaRealTime;
745  moveForward -= g_Joystick.GetAxisValue(m->JoystickPanY) * m->ViewScrollSpeed * deltaRealTime;
746 
749 
750  // Use a +1 bias for zoom because I want this to work with trigger buttons that default to -1
751  m->Zoom.AddSmoothly((g_Joystick.GetAxisValue(m->JoystickZoomIn) + 1.0f) / 2.0f * m->ViewZoomSpeed * deltaRealTime);
752  m->Zoom.AddSmoothly(-(g_Joystick.GetAxisValue(m->JoystickZoomOut) + 1.0f) / 2.0f * m->ViewZoomSpeed * deltaRealTime);
753  }
754 
755  if (moveRightward || moveForward)
756  {
757  // Break out of following mode when the user starts scrolling
759 
760  float s = sin(m->RotateY.GetSmoothedValue());
761  float c = cos(m->RotateY.GetSmoothedValue());
762  m->PosX.AddSmoothly(c * moveRightward);
763  m->PosZ.AddSmoothly(-s * moveRightward);
764  m->PosX.AddSmoothly(s * moveForward);
765  m->PosZ.AddSmoothly(c * moveForward);
766  }
767 
768  if (m->FollowEntity)
769  {
770  CmpPtr<ICmpPosition> cmpPosition(*(m->Game->GetSimulation2()), m->FollowEntity);
772  if (cmpPosition && cmpPosition->IsInWorld() &&
773  cmpRangeManager && cmpRangeManager->GetLosVisibility(m->FollowEntity, m->Game->GetPlayerID(), false) == ICmpRangeManager::VIS_VISIBLE)
774  {
775  // Get the most recent interpolated position
776  float frameOffset = m->Game->GetSimulation2()->GetLastFrameOffset();
777  CMatrix3D transform = cmpPosition->GetInterpolatedTransform(frameOffset, false);
778  CVector3D pos = transform.GetTranslation();
779 
780  if (m->FollowFirstPerson)
781  {
782  float x, z, angle;
783  cmpPosition->GetInterpolatedPosition2D(frameOffset, x, z, angle);
784  float height = 4.f;
786  m->ViewCamera.m_Orientation.RotateX((float)M_PI/24.f);
788  m->ViewCamera.m_Orientation.Translate(pos.X, pos.Y + height, pos.Z);
789 
791  return;
792  }
793  else
794  {
795  // Move the camera to match the unit
796  CCamera targetCam = m->ViewCamera;
798 
799  CVector3D pivot = GetSmoothPivot(targetCam);
800  CVector3D delta = pos - pivot;
801  m->PosX.AddSmoothly(delta.X);
802  m->PosY.AddSmoothly(delta.Y);
803  m->PosZ.AddSmoothly(delta.Z);
804  }
805  }
806  else
807  {
808  // The unit disappeared (died or garrisoned etc), so stop following it
810  }
811  }
812 
813  if (HotkeyIsPressed("camera.zoom.in"))
814  m->Zoom.AddSmoothly(-m->ViewZoomSpeed * deltaRealTime);
815  if (HotkeyIsPressed("camera.zoom.out"))
816  m->Zoom.AddSmoothly(m->ViewZoomSpeed * deltaRealTime);
817 
818  if (m->ConstrainCamera)
820 
821  float zoomDelta = -m->Zoom.Update(deltaRealTime);
822  if (zoomDelta)
823  {
824  CVector3D forwards = m->ViewCamera.m_Orientation.GetIn();
825  m->PosX.AddSmoothly(forwards.X * zoomDelta);
826  m->PosY.AddSmoothly(forwards.Y * zoomDelta);
827  m->PosZ.AddSmoothly(forwards.Z * zoomDelta);
828  }
829 
830  if (m->ConstrainCamera)
832 
833  FocusHeight(m, true);
834 
835  // Ensure the ViewCamera focus is inside the map with the chosen margins
836  // if not so - apply margins to the camera
837  if (m->ConstrainCamera)
838  {
839  CCamera targetCam = m->ViewCamera;
841 
842  CTerrain* pTerrain = m->Game->GetWorld()->GetTerrain();
843 
844  CVector3D pivot = GetSmoothPivot(targetCam);
845  CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot;
846 
847  CVector3D desiredPivot = pivot;
848 
850  if (cmpRangeManager && cmpRangeManager->GetLosCircular())
851  {
852  // Clamp to a circular region around the center of the map
853  float r = pTerrain->GetMaxX() / 2;
854  CVector3D center(r, desiredPivot.Y, r);
855  float dist = (desiredPivot - center).Length();
856  if (dist > r - CAMERA_EDGE_MARGIN)
857  desiredPivot = center + (desiredPivot - center).Normalized() * (r - CAMERA_EDGE_MARGIN);
858  }
859  else
860  {
861  // Clamp to the square edges of the map
862  desiredPivot.X = Clamp(desiredPivot.X, pTerrain->GetMinX() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxX() - CAMERA_EDGE_MARGIN);
863  desiredPivot.Z = Clamp(desiredPivot.Z, pTerrain->GetMinZ() + CAMERA_EDGE_MARGIN, pTerrain->GetMaxZ() - CAMERA_EDGE_MARGIN);
864  }
865 
866  // Update the position so that pivot is within the margin
867  m->PosX.SetValueSmoothly(desiredPivot.X + delta.X);
868  m->PosZ.SetValueSmoothly(desiredPivot.Z + delta.Z);
869  }
870 
871  m->PosX.Update(deltaRealTime);
872  m->PosY.Update(deltaRealTime);
873  m->PosZ.Update(deltaRealTime);
874 
875  // Handle rotation around the Y (vertical) axis
876  {
877  CCamera targetCam = m->ViewCamera;
879 
880  float rotateYDelta = m->RotateY.Update(deltaRealTime);
881  if (rotateYDelta)
882  {
883  // We've updated RotateY, and need to adjust Pos so that it's still
884  // facing towards the original focus point (the terrain in the center
885  // of the screen).
886 
887  CVector3D upwards(0.0f, 1.0f, 0.0f);
888 
889  CVector3D pivot = GetSmoothPivot(targetCam);
890  CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot;
891 
892  CQuaternion q;
893  q.FromAxisAngle(upwards, rotateYDelta);
894  CVector3D d = q.Rotate(delta) - delta;
895 
896  m->PosX.Add(d.X);
897  m->PosY.Add(d.Y);
898  m->PosZ.Add(d.Z);
899  }
900  }
901 
902  // Handle rotation around the X (sideways, relative to camera) axis
903  {
904  CCamera targetCam = m->ViewCamera;
906 
907  float rotateXDelta = m->RotateX.Update(deltaRealTime);
908  if (rotateXDelta)
909  {
910  CVector3D rightwards = targetCam.m_Orientation.GetLeft() * -1.0f;
911 
912  CVector3D pivot = GetSmoothPivot(targetCam);
913  CVector3D delta = targetCam.m_Orientation.GetTranslation() - pivot;
914 
915  CQuaternion q;
916  q.FromAxisAngle(rightwards, rotateXDelta);
917  CVector3D d = q.Rotate(delta) - delta;
918 
919  m->PosX.Add(d.X);
920  m->PosY.Add(d.Y);
921  m->PosZ.Add(d.Z);
922  }
923  }
924 
925  /* This is disabled since it doesn't seem necessary:
926 
927  // Ensure the camera's near point is never inside the terrain
928  if (m->ConstrainCamera)
929  {
930  CMatrix3D target;
931  target.SetIdentity();
932  target.RotateX(m->RotateX.GetValue());
933  target.RotateY(m->RotateY.GetValue());
934  target.Translate(m->PosX.GetValue(), m->PosY.GetValue(), m->PosZ.GetValue());
935 
936  CVector3D nearPoint = target.GetTranslation() + target.GetIn() * defaultNear;
937  float ground = m->Game->GetWorld()->GetTerrain()->GetExactGroundLevel(nearPoint.X, nearPoint.Z);
938  float limit = ground + 16.f;
939  if (nearPoint.Y < limit)
940  m->PosY.AddSmoothly(limit - nearPoint.Y);
941  }
942  */
943 
944  m->RotateY.Wrap(-(float)M_PI, (float)M_PI);
945 
946  // Update the camera matrix
950 }
951 
953 {
954  CCamera targetCam = m->ViewCamera;
955  CVector3D pivot = GetSmoothPivot(targetCam);
956  return pivot.X;
957 }
958 
960 {
961  CCamera targetCam = m->ViewCamera;
962  CVector3D pivot = GetSmoothPivot(targetCam);
963  return pivot.Z;
964 }
965 
967 {
968  // Maintain the same orientation and level of zoom, if we can
969  // (do this by working out the point the camera is looking at, saving
970  // the difference between that position and the camera point, and restoring
971  // that difference to our new target)
972 
973  CCamera targetCam = m->ViewCamera;
975 
976  CVector3D pivot = GetSmoothPivot(targetCam);
977  CVector3D delta = target - pivot;
978 
979  m->PosX.SetValueSmoothly(delta.X + m->PosX.GetValue());
980  m->PosZ.SetValueSmoothly(delta.Z + m->PosZ.GetValue());
981 
982  FocusHeight(m, false);
983 
984  // Break out of following mode so the camera really moves to the target
986 }
987 
989 {
990  CMatrix3D orientation;
991  orientation.SetIdentity();
992  orientation.RotateX(DEGTORAD(m->ViewRotateXDefault));
993  orientation.RotateY(DEGTORAD(m->ViewRotateYDefault));
994 
995  CVector3D delta = orientation.GetIn() * m->ViewZoomDefault;
996  m->PosX.SetValue(target.X - delta.X);
997  m->PosY.SetValue(target.Y - delta.Y);
998  m->PosZ.SetValue(target.Z - delta.Z);
1002 
1003  FocusHeight(m, false);
1004 
1007 
1008  // Break out of following mode so the camera really moves to the target
1010 }
1011 
1013 {
1014  CCamera targetCam = m->ViewCamera;
1016 
1017  // Compute the zoom adjustment to get us back to the default
1018  CVector3D forwards = targetCam.m_Orientation.GetIn();
1019 
1020  CVector3D pivot = GetSmoothPivot(targetCam);
1021  CVector3D delta = pivot - targetCam.m_Orientation.GetTranslation();
1022  float dist = delta.Dot(forwards);
1023  m->Zoom.AddSmoothly(m->ViewZoomDefault - dist);
1024 
1025  // Reset orientations to default
1028 }
1029 
1030 void CGameView::CameraFollow(entity_id_t entity, bool firstPerson)
1031 {
1032  m->FollowEntity = entity;
1033  m->FollowFirstPerson = firstPerson;
1034 }
1035 
1037 {
1038  return m->FollowEntity;
1039 }
1040 
1041 float CGameView::GetNear() const
1042 {
1043  return m->ViewNear;
1044 }
1045 
1046 float CGameView::GetFar() const
1047 {
1048  return m->ViewFar;
1049 }
1050 
1051 float CGameView::GetFOV() const
1052 {
1053  return m->ViewFOV;
1054 }
1055 
1057 {
1058  return m->ViewFOV + DEGTORAD(6.0f); //add 6 degrees to the default FOV for use with the culling frustum;
1059 }
1060 
1062 {
1064 }
1065 
1067 {
1068  // put any events that must be processed even if inactive here
1069  if(!g_app_has_focus || !g_Game || !g_Game->IsGameStarted())
1070  return IN_PASS;
1071 
1072  CGameView *pView=g_Game->GetView();
1073 
1074  return pView->HandleEvent(ev);
1075 }
1076 
1078 {
1079  switch(ev->ev.type)
1080  {
1081 
1082  case SDL_HOTKEYDOWN:
1083  std::string hotkey = static_cast<const char*>(ev->ev.user.data1);
1084 
1085  if (hotkey == "wireframe")
1086  {
1087  if (g_Renderer.GetModelRenderMode() == SOLID)
1088  {
1089  g_Renderer.SetTerrainRenderMode(EDGED_FACES);
1090  g_Renderer.SetModelRenderMode(EDGED_FACES);
1091  }
1092  else if (g_Renderer.GetModelRenderMode() == EDGED_FACES)
1093  {
1094  g_Renderer.SetTerrainRenderMode(WIREFRAME);
1095  g_Renderer.SetModelRenderMode(WIREFRAME);
1096  }
1097  else
1098  {
1099  g_Renderer.SetTerrainRenderMode(SOLID);
1100  g_Renderer.SetModelRenderMode(SOLID);
1101  }
1102  return IN_HANDLED;
1103  }
1104  // Mouse wheel must be treated using events instead of polling,
1105  // because SDL auto-generates a sequence of mousedown/mouseup events
1106  // and we never get to see the "down" state inside Update().
1107  else if (hotkey == "camera.zoom.wheel.in")
1108  {
1110  return IN_HANDLED;
1111  }
1112  else if (hotkey == "camera.zoom.wheel.out")
1113  {
1115  return IN_HANDLED;
1116  }
1117  else if (hotkey == "camera.rotate.wheel.cw")
1118  {
1120  return IN_HANDLED;
1121  }
1122  else if (hotkey == "camera.rotate.wheel.ccw")
1123  {
1125  return IN_HANDLED;
1126  }
1127  else if (hotkey == "camera.scroll.speed.increase")
1128  {
1130  return IN_HANDLED;
1131  }
1132  else if (hotkey == "camera.scroll.speed.decrease")
1133  {
1135  return IN_HANDLED;
1136  }
1137  else if (hotkey == "camera.rotate.speed.increase")
1138  {
1141  return IN_HANDLED;
1142  }
1143  else if (hotkey == "camera.rotate.speed.decrease")
1144  {
1147  return IN_HANDLED;
1148  }
1149  else if (hotkey == "camera.zoom.speed.increase")
1150  {
1152  return IN_HANDLED;
1153  }
1154  else if (hotkey == "camera.zoom.speed.decrease")
1155  {
1157  return IN_HANDLED;
1158  }
1159  else if (hotkey == "camera.reset")
1160  {
1162  return IN_HANDLED;
1163  }
1164  }
1165 
1166  return IN_PASS;
1167 }
void UnloadResources()
Definition: GameView.cpp:602
#define M_PI
Definition: wposix.h:64
float ViewDragSpeed
Definition: GameView.cpp:284
The container that holds the rules, resources and attributes of the game.
Definition: Game.h:39
void Translate(float x, float y, float z)
Definition: Matrix3D.cpp:172
float GetFar() const
Definition: GameView.cpp:1046
float ViewScrollSpeedModifier
Definition: GameView.cpp:275
void BeginFrame()
Definition: GameView.cpp:473
#define g_TexMan
CSmoothedValue RotateY
Definition: GameView.cpp:310
Definition: Decompose.h:22
CCamera CullCamera
this camera controls the frustum that is used for culling and shadow calculations ...
Definition: GameView.cpp:229
float ViewRotateYSpeedWheel
Definition: GameView.cpp:281
static void SetupCameraMatrixSmooth(CGameViewImpl *m, CMatrix3D *orientation)
Definition: GameView.cpp:330
CLightEnv CachedLightEnv
Cache global lighting environment.
Definition: GameView.cpp:258
CCinemaManager * GetCinema()
Definition: GameView.cpp:395
void MakeDirty(ssize_t i0, ssize_t j0, ssize_t i1, ssize_t j1, int dirtyFlags)
Definition: Terrain.cpp:598
bool FollowFirstPerson
Whether to follow FollowEntity in first-person mode.
Definition: GameView.cpp:270
bool IsEnabled()
Returns whether the touch input mode is enabled for this device.
Definition: TouchInput.cpp:54
CVector3D GetSmoothPivot(CCamera &camera) const
Definition: GameView.cpp:667
CMeshManager MeshManager
Definition: GameView.cpp:210
CUnitManager & GetUnitManager()
Get a reference to the unit manager object.
Definition: World.h:96
const ssize_t TERRAIN_TILE_SIZE
metres [world space units] per tile in x and z
Definition: Terrain.h:40
float HeightSmoothness
Definition: GameView.cpp:300
static void SetupCameraMatrixSmoothRot(CGameViewImpl *m, CMatrix3D *orientation)
Definition: GameView.cpp:338
virtual void EnumerateObjects(const CFrustum &frustum, SceneCollector *c)
Send all objects that can be seen when rendering the given frustum to the scene collector.
Definition: GameView.cpp:504
float ViewZoomMin
Definition: GameView.cpp:287
double m_Current
Definition: GameView.cpp:143
CLightEnv g_LightEnv
File : World.cpp Project : engine Description : Contains the CWorld Class implementation.
Definition: World.cpp:49
CSmoothedValue PosX
Definition: GameView.cpp:305
float GetAxisValue(int axis)
Returns current value of the given joystick axis, in the range [-1, +1].
Definition: Joystick.cpp:87
float Update(float time)
Definition: GameView.cpp:111
float GetValue()
Definition: GameView.cpp:100
void CachePlayerColours()
Retrieving player colours from scripts is slow, so this updates an internal cache of all players&#39; col...
Definition: Game.cpp:332
float GetMaxX() const
Definition: Terrain.h:73
int g_xres
Definition: Config.cpp:58
int m_Y
Definition: Camera.h:34
#define CFG_GET_VAL(name, type, destination)
Definition: ConfigDB.h:147
const std::string & GetLightingModel() const
Definition: LightEnv.h:85
void CameraFollow(entity_id_t entity, bool firstPerson)
Definition: GameView.cpp:1030
float ViewRotateYSpeed
Definition: GameView.cpp:280
float Dot(const CVector3D &vector) const
Definition: Vector3D.cpp:48
int JoystickRotateX
Definition: GameView.cpp:296
void ClampSmoothly(float min, float max)
Definition: GameView.cpp:124
void Render()
Definition: GameView.cpp:496
bool IsBoxVisible(const CVector3D &position, const CBoundingBoxAligned &bounds) const
Definition: Frustum.cpp:116
CLOSTexture LOSTexture
Definition: GameView.cpp:213
Definition: Renderer.h:55
CVector3D Rotate(const CVector3D &vec) const
Definition: Quaternion.cpp:300
float GetMinZ() const
Definition: Terrain.h:72
float GetExactGroundLevel(float x, float z) const
Definition: Terrain.cpp:353
#define RENDERDATA_UPDATE_COLOR
bool g_mouse_active
Indicates whether the mouse is focused on the game window (mouse positions should usually be consider...
Definition: Globals.cpp:31
void AddSmoothly(float value)
Definition: GameView.cpp:89
virtual CMatrix3D GetInterpolatedTransform(float frameOffset, bool forceFloating)=0
Get the current interpolated transform matrix, for rendering.
void RenderSubmit(SceneCollector &collector, const CFrustum &frustum, bool culling)
float ViewZoomSpeedModifier
Definition: GameView.cpp:290
T Clamp(T val, T min, T max)
low-level aka &quot;lib&quot;
Definition: lib.h:68
int JoystickRotateY
Definition: GameView.cpp:297
void SetCameraProjection()
Definition: GameView.cpp:1061
virtual bool IsInWorld()=0
Returns true if the entity currently exists at a defined position in the world.
float GetCameraX()
Definition: GameView.cpp:952
int m_Height
Definition: Camera.h:36
CGameViewImpl * m
Definition: GameView.h:41
virtual bool GetLosCircular()=0
Returns whether the LOS is restricted to a circular map.
float GetLastFrameOffset() const
Returns the last frame offset passed to Interpolate(), i.e.
void SetViewport(const SViewPort &vp)
Definition: GameView.cpp:379
const entity_id_t SYSTEM_ENTITY
Entity ID for singleton &#39;system&#39; components.
Definition: Entity.h:44
CJoystick g_Joystick
Definition: Joystick.cpp:26
float ViewZoomSpeedWheel
Definition: GameView.cpp:286
virtual ELosVisibility GetLosVisibility(CEntityHandle ent, player_id_t player, bool forceRetainInFog=false)=0
Returns the visibility status of the given entity, with respect to the given player.
double m_Target
Definition: GameView.cpp:142
void ResetCameraAngleZoom()
Definition: GameView.cpp:1012
This interface accepts renderable objects.
Definition: Scene.h:82
#define g_Renderer
Definition: Renderer.h:61
Hotkey system.
float ViewZoomDefault
Definition: GameView.cpp:289
int GetPlayerID()
Definition: Game.cpp:249
CTerrain * GetTerrain()
Get the pointer to the terrain object.
Definition: World.h:88
bool IsPlaying() const
Definition: CinemaTrack.h:148
SDL_Event ev
Definition: libsdl.h:56
CVector3D GetIn() const
Definition: Matrix3D.cpp:253
#define IMPLEMENT_BOOLEAN_SETTING(NAME)
Definition: GameView.cpp:313
int JoystickZoomOut
Definition: GameView.cpp:299
void RotateY(float angle)
Definition: Matrix3D.cpp:117
float GetFOV() const
Definition: GameView.cpp:1051
bool ConstrainCamera
Whether the camera movement should be constrained by min/max limits and terrain avoidance.
Definition: GameView.cpp:252
Uint8 type
Definition: wsdl.h:302
CGame * Game
Definition: GameView.cpp:208
CTouchInput g_TouchInput
Definition: TouchInput.cpp:291
bool Update(const float deltaRealTime)
CCinemaManager TrackManager
Definition: GameView.cpp:260
float X
Definition: Vector3D.h:31
entity_id_t FollowEntity
Entity for the camera to follow, or INVALID_ENTITY if none.
Definition: GameView.cpp:265
void Update(const float deltaRealTime)
Updates all the view information (i.e.
Definition: GameView.cpp:672
float Y
Definition: Vector3D.h:31
bool g_app_has_focus
Definition: Globals.cpp:27
void CheckLightEnv()
Definition: GameView.cpp:579
int LoadWaterTextures()
LoadWaterTextures: Load water textures from within the progressive load framework.
CGameViewImpl(CGame *game)
Definition: GameView.cpp:155
float ViewZoomMax
Definition: GameView.cpp:288
int JoystickZoomIn
Definition: GameView.cpp:298
InReaction
Definition: input.h:34
Definition: input.h:40
CSkeletonAnimManager SkeletonAnimManager
Definition: GameView.cpp:211
int g_yres
Definition: Config.cpp:58
int Initialize()
Definition: GameView.cpp:410
bool Culling
When true, culling is enabled so that only models that have a chance of being visible are sent to the...
Definition: GameView.cpp:246
Definition: Camera.h:39
float m_MinDelta
Definition: GameView.cpp:146
InReaction game_view_handler(const SDL_Event_ *ev)
Definition: GameView.cpp:1066
CGameView(CGame *pGame)
Definition: GameView.cpp:354
CColladaManager ColladaManager
Definition: GameView.cpp:209
void SetIdentity()
Definition: Matrix3D.cpp:30
CCamera * GetCamera()
Definition: GameView.cpp:390
Definition: Patch.h:48
CGame * g_Game
Globally accessible pointer to the CGame object.
Definition: Game.cpp:56
#define PROFILE(name)
Definition: Profile.h:195
float ViewRotateYDefault
Definition: GameView.cpp:282
float GetSmoothedValue()
Definition: GameView.cpp:79
bool IsEnabled()
Returns true if initialised and the joystick is present and enabled by configuration.
Definition: Joystick.cpp:82
const int SDL_HOTKEYDOWN
Definition: Hotkey.h:41
void Wrap(float min, float max)
Definition: GameView.cpp:130
int LoadAlphaMaps()
Definition: Renderer.cpp:1803
virtual CTerritoryTexture & GetTerritoryTexture()
Return the territory texture to be used for rendering this scene.
Definition: GameView.cpp:405
CSmoothedValue Zoom
Definition: GameView.cpp:308
A simplified syntax for accessing entity components.
Definition: CmpPtr.h:55
virtual void GetInterpolatedPosition2D(float frameOffset, float &x, float &z, float &rotY)=0
Get the current interpolated 2D position and orientation, for rendering.
CSmoothedValue RotateX
Definition: GameView.cpp:309
void SetViewPort(const SViewPort &viewport)
Definition: Camera.cpp:136
float GetCameraZ()
Definition: GameView.cpp:959
CSimulation2 * GetSimulation2()
Get the pointer to the simulation2 object.
Definition: Game.h:136
intptr_t ssize_t
Definition: wposix_types.h:82
CObjectManager ObjectManager
Definition: GameView.cpp:212
void SetValueSmoothly(float value)
Definition: GameView.cpp:84
float GetFilteredGroundLevel(float x, float z, float radius) const
Definition: Terrain.cpp:342
CSmoothedValue PosY
Definition: GameView.cpp:306
entity_id_t GetFollowedEntity()
Definition: GameView.cpp:1036
void RegisterInit()
Definition: GameView.cpp:461
float ViewRotateSpeedModifier
Definition: GameView.cpp:283
void UpdateFrustum(const CBoundingBoxAligned &scissor=CBoundingBoxAligned(CVector3D(-1.0f,-1.0f,-1.0f), CVector3D(1.0f, 1.0f, 1.0f)))
Definition: Camera.cpp:83
CGameView * GetView()
Get the pointer to the game view object.
Definition: Game.h:128
static const float CAMERA_EDGE_MARGIN
Definition: GameView.cpp:66
float HeightMin
Definition: GameView.cpp:301
NONCOPYABLE(CGameViewImpl)
#define PROFILE3(name)
Definition: Profile.h:201
float ViewRotateXMax
Definition: GameView.cpp:278
float GetNear() const
Definition: GameView.cpp:1041
CPatch * GetPatch(ssize_t i, ssize_t j) const
Definition: Terrain.cpp:283
float ViewZoomSpeed
Definition: GameView.cpp:285
virtual CLOSTexture & GetLOSTexture()
Return the LOS texture to be used for rendering this scene.
Definition: GameView.cpp:400
float GetCullFOV() const
Definition: GameView.cpp:1056
float ViewScrollSpeed
Definition: GameView.cpp:274
float GetMinX() const
Definition: Terrain.h:71
int m_Width
Definition: Camera.h:35
bool IsGameStarted() const
Get m_GameStarted.
Definition: Game.h:110
float GetMaxZ() const
Definition: Terrain.h:74
const std::vector< CUnit * > & GetUnits() const
Definition: UnitManager.h:56
CVector3D GetLeft() const
Definition: Matrix3D.cpp:241
CMatrix3D m_Orientation
Definition: Camera.h:112
int g_mouse_x
Definition: Globals.cpp:30
CObjectManager & GetObjectManager() const
Definition: GameView.cpp:385
CWorld * GetWorld()
Get the pointer to the game world object.
Definition: Game.h:120
float Z
Definition: Vector3D.h:31
Maintains the LOS (fog-of-war / shroud-of-darkness) texture, used for rendering and for the minimap...
Definition: LOSTexture.h:32
bool HotkeyIsPressed(const CStr &keyname)
Definition: Hotkey.cpp:400
void FromAxisAngle(const CVector3D &axis, float angle)
Definition: Quaternion.cpp:260
SDL_UserEvent user
Definition: wsdl.h:312
void RegMemFun(T *this_, int(T::*func)(void), const wchar_t *description, int estimated_duration_ms)
Definition: LoaderThunks.h:67
InReaction HandleEvent(const SDL_Event_ *ev)
Definition: GameView.cpp:1077
#define DEGTORAD(a)
Definition: MathUtil.h:21
static void FocusHeight(CGameViewImpl *m, bool smooth)
Definition: GameView.cpp:609
CVector3D GetTranslation() const
Definition: Matrix3D.cpp:195
void SetValue(float value)
Definition: GameView.cpp:105
void Add(float value)
Definition: GameView.cpp:94
int g_mouse_y
Definition: Globals.cpp:30
Class CLightEnv: description of a lighting environment - contains all the necessary parameters for re...
Definition: LightEnv.h:36
float ViewNear
Definition: GameView.cpp:292
const CBoundingBoxAligned & GetWorldBounds()
Returns the world-space axis-aligned bounds of this object.
static float Length(const SVec3 v)
Definition: mikktspace.cpp:112
ssize_t GetPatchesPerSide() const
Definition: Terrain.h:69
int m_X
Definition: Camera.h:33
const entity_id_t INVALID_ENTITY
Invalid entity ID.
Definition: Entity.h:36
PIVFS g_VFS
Definition: Filesystem.cpp:30
u32 entity_id_t
Entity ID type.
Definition: Entity.h:24
virtual void Submit(CPatch *patch)=0
Submit a terrain patch that is part of the scene.
bool LockCullCamera
When true, the cull camera is locked in place.
Definition: GameView.cpp:237
CCamera ViewCamera
this camera controls the eye position when rendering
Definition: GameView.cpp:219
float ViewRotateXMin
Definition: GameView.cpp:277
CSmoothedValue(float value, float smoothness, float minDelta)
Definition: GameView.cpp:74
void MoveCameraTarget(const CVector3D &target)
Definition: GameView.cpp:966
Maintains the territory boundary texture, used for rendering and for the minimap. ...
CTerritoryTexture TerritoryTexture
Definition: GameView.cpp:214
float m_Smoothness
Definition: GameView.cpp:148
void ResetCameraTarget(const CVector3D &target)
Definition: GameView.cpp:988
A value with exponential decay towards the target value.
Definition: GameView.cpp:71
CSmoothedValue PosZ
Definition: GameView.cpp:307
void SetProjection(float nearp, float farp, float fov)
Definition: Camera.cpp:51
void RotateX(float angle)
Definition: Matrix3D.cpp:97
bool IsActive() const
Definition: CinemaTrack.h:150
float ViewRotateXSpeed
Definition: GameView.cpp:276
bool getDrawState()
Definition: Patch.h:74
void * data1
Definition: wsdl.h:282
float ViewRotateXDefault
Definition: GameView.cpp:279
void setDrawState(bool value)
Definition: Patch.h:73
static void SetupCameraMatrixNonSmooth(CGameViewImpl *m, CMatrix3D *orientation)
Definition: GameView.cpp:346