All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
EegeoDrawParameters.h
1 // Copyright eeGeo Ltd (2012-2014), All Rights Reserved
2 
3 #pragma once
4 
5 #include "VectorMath.h"
6 #include "ScreenProperties.h"
7 #include "SpaceHelpers.h"
8 #include "RenderCamera.h"
9 
10 namespace Eegeo
11 {
13  {
14  dv3 m_ecefLocation;
15  dv3 m_ecefInterestPoint;
16  m44 m_viewMatrix;
17  m44 m_projectionMatrix;
18  m44 m_viewProjectionMatrix;
19  Rendering::ScreenProperties m_screenProperties;
20 
21  public:
22  EegeoDrawParameters(const dv3& ecefLocation,
23  const dv3& ecefInterestPoint,
24  const m44& viewMatrix,
25  const m44& projectionMatrix,
26  const Rendering::ScreenProperties& screenProperties)
27  : m_ecefLocation(ecefLocation)
28  , m_ecefInterestPoint(ecefInterestPoint)
29  , m_viewMatrix(viewMatrix)
30  , m_projectionMatrix(projectionMatrix)
31  , m_screenProperties(screenProperties)
32  {
33  Eegeo::m44::Mul(m_viewProjectionMatrix, ProjectionMatrix(), ViewMatrix());
34  }
35 
36  double Altitude() const { return Eegeo::Space::SpaceHelpers::GetAltitude(EcefLocation()); }
37 
38  const dv3& EcefLocation() const { return m_ecefLocation; }
39 
40  const dv3& EcefInterestPoint() const { return m_ecefInterestPoint; }
41 
42  const m44& ViewMatrix() const { return m_viewMatrix; }
43 
44  const m44& ProjectionMatrix() const { return m_projectionMatrix; }
45 
46  const Rendering::ScreenProperties& ScreenProperties() const { return m_screenProperties; }
47 
48  const m44& ViewProjectionMatrix() const { return m_viewProjectionMatrix; }
49  };
50 
51  inline Camera::RenderCamera RenderCameraFromEegeoDrawParameters(const EegeoDrawParameters& eegeoDrawParameters)
52  {
53  Camera::RenderCamera renderCamera;
54 
55  renderCamera.SetViewport(0.f,
56  0.f,
57  eegeoDrawParameters.ScreenProperties().GetScreenWidth(),
58  eegeoDrawParameters.ScreenProperties().GetScreenHeight());
59 
60  m33 viewOrientation(eegeoDrawParameters.ViewMatrix());
61  m33 cameraModel;
62  m33::Inverse(cameraModel, viewOrientation);
63  m44 projection(eegeoDrawParameters.ProjectionMatrix());
64  dv3 ecefLocation(eegeoDrawParameters.EcefLocation());
65 
66  renderCamera.SetOrientationMatrix(cameraModel);
67  renderCamera.SetEcefLocation(ecefLocation);
68  renderCamera.SetProjectionMatrix(projection);
69 
70  return renderCamera;
71  }
72 }