VR-Vantage 3.0 API Documentation
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
DtCamera.h
Go to the documentation of this file.
1 /******************************************************************************
2 ** Copyright (c) 2020 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
20 
21 #include <array>
22 
23 namespace makVrv {
24 
26  {
33  };
34 
36  {
38  };
39 
42  template <class T>
43  class DtCamera
44  {
45  public:
47  DtCamera();
49  virtual ~DtCamera();
50 
51  void setNearPlane(T fNearPlane);
52  T nearPlane(void) const;
53 
54  void setFarPlane(T fFarPlane);
55  T farPlane(void) const;
56 
58  void setFieldOfView(T fFOVy);
59  T fieldOfView(void) const;
60 
61  void setPosition(const DtVector3<T>& vPosition);
62  DtVector3<T> position(void) const;
63 
64  void setDirection(const DtVector3<T>& vDirection);
65  DtVector3<T> direction(void) const;
66 
67  DtVector3<T> upVector(void) const;
68  DtVector3<T> sideVector(void) const;
69 
71  void lookAt(const DtVector3<T>& vEye, const DtVector3<T>& vLook, const DtVector3<T>& vUp);
73  const DtMatrix4<T>& ViewMatrix(void) const;
74 
76  void SetPerspective(T fFOVy, T fAspectRatio, T fNearPlane, T fFarPlane);
78  const DtMatrix4<T>& ProjectionMatrix(void) const;
79 
81  const DtMatrix4<T>& ViewProjectionMatrix(void) const;
82 
83  void setFixedUpVector(bool fixed);
84  bool isFixedUpVector(void) const;
85 
87  T aspectRatio(void) const;
88 
90  bool IsVisible(const DtAxisAlignedBoundingBox<T>& box) const;
91 
94 
97  , const Vector2_uint32& viewPortSize) const;
98  private:
103 
108 
112 
114 
116  void updateFrustumPlanes(void);
117  void updateViewProjectionMatrix(void);
118  };
119 
120  template <class T>
122  {
123  public:
126  static DtVector2<T> project(const DtVector3<T>& vPosition
127  , const DtMatrix4<T>& view_projection_matrix
128  , bool clip = true);
129 
134  static Vector2_int project(const DtVector3<T>& vPosition
135  , const DtMatrix4<T>& view_projection_matrix
136  , const Vector2_uint32& viewPortSize
137  , bool clip = true);
138 
142  , const DtMatrix4<T>& view_projection_matrix
143  , const Vector2_uint32& viewPortSize
144  , bool clip = true);
145  };
146 
147 
150  template <class T>
151  class Frustum
152  {
153  public:
155  Frustum();
156 
158  virtual ~Frustum();
159 
161  template <class RHS>
162  Frustum(const Frustum<RHS>& rhs);
163 
165  template <class RHS>
166  Frustum& operator=(const Frustum<RHS>& rhs);
167  public:
169  virtual void setPlane(FrustumPlane plane, T d, const DtVector3<T>& vNormal);
170 
172  virtual const DtPlane<T>& plane(FrustumPlane plane) const;
173 
175  virtual DtVector4<T> planeAsVector(FrustumPlane plane) const;
176 
178  virtual bool isVisible(const DtAxisAlignedBoundingBox<T>& box) const;
179 
181  virtual VisibilityFromCamera visibility(const DtAxisAlignedBoundingBox<T>& box, bool ignoreNearFar = false) const;
182 
184  virtual void setFromModelViewProjectionMatrix(const DtMatrix4<T>& mvp);
185 
187  virtual bool operator==(const Frustum<T>& rhs) const;
188 
190  virtual bool operator!=(const Frustum<T>& rhs) const;
191  protected:
192  std::array< DtPlane<T>, 6 > myFrustumPlanes;
193  };
194 
195 } //namespace makVrv
196 
197 #include "DtCamera.inl"


Copyright © 2005-2021 MAK Technologies. All Rights Reserved (www.mak.com)