VR-Vantage 3.2 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) 2023 MAK Technologies, Inc.
3 ** All rights reserved.
4 ******************************************************************************/
5 
9 #pragma once
10 
11 #include <vrvMath/DtCommonTypes.h>
12 #include <vrvMath/DtAssert.h>
13 #include <vrvMath/DtMatrixUtils.h>
15 #include <vrvMath/DtPlane.h>
16 #include <vrvMath/DtScreenRect.h>
17 #include <vrvMath/DtVector2.h>
18 #include <vrvMath/DtIntSize.h>
19 #include <vrvMath/DtMatrix4.h>
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 bool isSphereVisible(const DtVector3<T>& center, T radius) const;
182 
184  virtual bool isSphereVisibleRadiusSquared(const DtVector3<T>& center, double radiusSquared) const;
185 
187  virtual VisibilityFromCamera visibility(const DtAxisAlignedBoundingBox<T>& box, bool ignoreNearFar = false) const;
188 
191  virtual void setFromModelViewProjectionMatrix(const DtMatrix4<T>& modelViewMat, const DtMatrix4<T>& projMat);
192 
194  virtual void setFromModelViewProjectionMatrix(const DtMatrix4<T>& mvp);
195 
197  virtual void frustumPlanes(std::array<DtVector4<T>, 6>& planes) const;
198 
200  virtual bool operator==(const Frustum<T>& rhs) const;
201 
203  virtual bool operator!=(const Frustum<T>& rhs) const;
204 
205  protected:
206 
208  void computePlaneFromPoints(DtPlane<T>& plane, const DtVector3<T>& point0,
209  const DtVector3<T>& point1, const DtVector3<T>& point2) const;
210 
211  protected:
212  std::array< DtPlane<T>, 6 > myFrustumPlanes;
213  };
214 
215 } //namespace makVrv
216 
217 #include "DtCamera.inl"


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