Gray C++ Libraries  0.0.2
A set of C++ libraries for MSVC, GNU on Windows, WinCE, Linux
cCamera.h
Go to the documentation of this file.
1 //
4 //
5 
6 #ifndef _INC_cCamera_H
7 #define _INC_cCamera_H
8 #ifndef NO_PRAGMA_ONCE
9 #pragma once
10 #endif
11 #include "Gray3D.h"
16 
17 namespace Gray3D
18 {
20  {
23 
24  public:
29 
30  public:
32 
33  const cVector3f& get_Eye() const noexcept
34  {
36  return m_vEye;
37  }
38  const cVector3f& get_Ang() const noexcept
39  {
41  return m_vAng;
42  }
43  };
44 
46  {
51 
52  public:
55 
57  cVector3f m_vAxisCam[AXIS_Trans];
58 
59  static const cVector3f k_vLocalSide;
60  static const cVector3f k_vLocalUp;
61  static const cVector3f k_vLocalAhead;
62 
63  protected:
65 
68 
71 
73 
75 
76  protected:
77  void UpdateDerived();
78  public:
79  cCameraParams();
80  DECLARE_HEAP_ALIGNED_ALLOC(cCameraParams); // needed! lot of need-to-be-aligned matrices inside!
81 
82  // derived params.
83  const cMatrix4x4f& get_ProjMatrix() const
84  { return m_mProj; }
85 
86  const cMatrix4x4f& get_ViewMatrix() const
87  { return m_mView; }
89  { return m_mInvView; }
90 
92  { return m_mView0; }
94  { return m_mInvView0; }
95 
97  { return m_mViewProj; }
98 
99  bool ClampProjectPos( cVector2f& posScreen ) const;
100  bool GetProjectPos( cVector2f& posScreen, const cVector3f& posTop ) const;
101 
102  GINTERSECT_TYPE CheckBSphere( const cSpheref& sphere ) const
103  {
105  return m_FrustumWindow.IntersectTest( sphere );
106  }
107  GINTERSECT_TYPE CheckBSphere( const cVector3f& vCenter, float fRadius ) const
108  {
110  return CheckBSphere( cSpheref( vCenter, fRadius ));
111  }
112 
113  GINTERSECT_TYPE CheckBSphereTrans( const cVector3f& vCenter, float fRadius ) const
114  {
116  return CheckBSphere( vCenter.GetProj( m_mView ), fRadius );
117  }
118 
119  void UpdateMatrix();
120  };
121 
123  {
127  };
128 
130  {
134 
135  protected:
141 
142  public:
144 
145  const cVector3f& get_OrbitTarget() const
146  {
148  return m_vOrbitTarget;
149  }
150  void put_OrbitHeading( RADIANf_t fOrbitHeading )
151  {
152  m_fOrbitHeading = fOrbitHeading;
153  }
155  {
156  return m_fOrbitDistanceCur;
157  }
158  void put_OrbitDistance( METERSf_t fOrbitDistance )
159  {
160  m_fOrbitDistanceCur = fOrbitDistance;
161  }
162 
163  cVector3f CalcOrbitEye();
164  };
165 
167  {
171  public:
174 
175  public:
176  cCamera(void);
177  ~cCamera(void);
178 
180  };
181 };
182 #endif
#define GRAY3D_LINK
Definition: Gray3D.h:15
#define UNITTEST_FRIEND(n)
Define this in the class body to be unit tested. Allow the unit test to access private/protected stuf...
Definition: cUnitTestDecl.h:17
Definition: cCamera.h:130
METERSf_t m_fOrbitDistanceMax
Non-occluded (good) distance. (LERP target out to m_fOrbitDistanceCur)
Definition: cCamera.h:140
RADIANf_t m_fOrbitHeading
Around m_vOrbitTarget.
Definition: cCamera.h:138
void put_OrbitHeading(RADIANf_t fOrbitHeading)
Definition: cCamera.h:150
RADIANf_t m_fOrbitPitch
Around m_vOrbitTarget.
Definition: cCamera.h:137
const METERSf_t get_OrbitDistance() const
Definition: cCamera.h:154
const cVector3f & get_OrbitTarget() const
Definition: cCamera.h:145
cVector3f m_vOrbitTarget
What am i looking at ? usually the avatar.
Definition: cCamera.h:136
METERSf_t m_fOrbitDistanceCur
Current distance from m_vOrbitTarget to camera eye. LERP state. <= m_fOrbitDistanceMax.
Definition: cCamera.h:139
void put_OrbitDistance(METERSf_t fOrbitDistance)
Definition: cCamera.h:158
Definition: cCamera.h:123
Definition: cCamera.h:20
cVector3f m_vEye
Location point POV eye of the camera. RADIANf_t.
Definition: cCamera.h:25
cVector3f m_vAng
Euler Angle of the first person camera ray from the m_vEye. (RADIANf_t) Pitch, Bank,...
Definition: cCamera.h:26
const cVector3f & get_Ang() const noexcept
Definition: cCamera.h:38
METERSf_t m_fNear
Near plane distance from eye.
Definition: cCamera.h:28
METERSf_t m_fFar
Far plane distance from eye.
Definition: cCamera.h:27
const cVector3f & get_Eye() const noexcept
Definition: cCamera.h:33
Definition: cCamera.h:46
cMatrix4x4f m_mInvView0
Invert m_mView0.
Definition: cCamera.h:70
static const cVector3f k_vLocalUp
AXIS_Y.
Definition: cCamera.h:60
static const cVector3f k_vLocalAhead
AXIS_Z.
Definition: cCamera.h:61
GINTERSECT_TYPE CheckBSphere(const cSpheref &sphere) const
Definition: cCamera.h:102
cMatrix4x4f m_mView0
m_mView with put_Translation(0,0,0)
Definition: cCamera.h:69
cMatrix4x4f m_mViewProj
Resultant m_mView * m_mProj.
Definition: cCamera.h:72
const cMatrix4x4f & get_ProjMatrix() const
Definition: cCamera.h:83
static const cVector3f k_vLocalSide
AXIS_X for calculation of m_vAxisCam.
Definition: cCamera.h:59
cMatrix4x4f m_mView
Field of view.
Definition: cCamera.h:66
const cMatrix4x4f & get_View0Matrix() const
Definition: cCamera.h:91
const cMatrix4x4f & get_InvViewMatrix() const
Definition: cCamera.h:88
GINTERSECT_TYPE CheckBSphere(const cVector3f &vCenter, float fRadius) const
Definition: cCamera.h:107
GINTERSECT_TYPE CheckBSphereTrans(const cVector3f &vCenter, float fRadius) const
Definition: cCamera.h:113
DECLARE_HEAP_ALIGNED_ALLOC(cCameraParams)
const cMatrix4x4f & get_ViewProjMatrix() const
Definition: cCamera.h:96
cRectI m_ProjRect
Cache projection dimension.
Definition: cCamera.h:54
cMatrix4x4f m_mProj
Projection based on m_ProjRect.
Definition: cCamera.h:64
cMatrix4x4f m_mInvView
Invert m_mView.
Definition: cCamera.h:67
const cMatrix4x4f & get_InvView0Matrix() const
Definition: cCamera.h:93
const cMatrix4x4f & get_ViewMatrix() const
Definition: cCamera.h:86
cHexahedron m_FrustumWindow
Recalculate when window changes size. i.e m_mProj changes.
Definition: cCamera.h:74
Definition: cCamera.h:167
cCameraParams m_Param
params to render the current view.
Definition: cCamera.h:172
cCameraController * m_pControl
What are the params for control of this camera. e.g. Control Mode.
Definition: cCamera.h:173
Definition: cHexahedron.h:18
GINTERSECT_TYPE IntersectTest(const TYPE &obj) const
Definition: cHexahedron.h:51
Definition: cMatrix.h:194
Definition: cRectI.h:22
Definition: cSphere.h:20
Definition: cVector.h:36
Definition: cVector.h:94
THIS_t GetProj(const cMatrix4x4f &M) const
Definition: cVector.cpp:98
Definition: Gray3D.cpp:12
float METERSf_t
preferred 3d units for rendering. like DVALUEDEF_t but not MAP_METER_t
Definition: Gray3D.h:24
float RADIANf_t
type is float radians
Definition: Calc.h:27
GINTERSECT_TYPE
Definition: cVecT.h:20
@ AXIS_Trans
position offset.
Definition: cVector.h:31