VR-Vantage 3.0 API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
include
vrvGraphicsUtils
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
11
#include <
vrvGraphicsUtils/DtCommonTypes.h
>
12
#include <
vrvGraphicsUtils/DtAssert.h
>
13
#include <
vrvGraphicsUtils/DtMatrixUtils.h
>
14
#include <
vrvGraphicsUtils/DtAxisAlignedBoundingBox.h
>
15
#include <
vrvGraphicsUtils/DtPlane.h
>
16
#include <
vrvGraphicsUtils/DtScreenRect.h
>
17
#include <
vrvGraphicsUtils/DtVector2.h
>
18
#include <
vrvGraphicsUtils/DtIntSize.h
>
19
#include <
vrvGraphicsUtils/DtMatrix4.h
>
20
21
#include <array>
22
23
namespace
makVrv {
24
25
enum
FrustumPlane
26
{
27
FRUSTUM_PLANE_NEAR
= 0,
28
FRUSTUM_PLANE_FAR
= 1,
29
FRUSTUM_PLANE_LEFT
= 2,
30
FRUSTUM_PLANE_RIGHT
= 3,
31
FRUSTUM_PLANE_TOP
= 4,
32
FRUSTUM_PLANE_BOTTOM
= 5
33
};
34
35
enum
VisibilityFromCamera
36
{
37
VISIBILITY_NONE
= 0,
VISIBILITY_PARTIAL
= 1,
VISIBILITY_FULL
= 2
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
93
VisibilityFromCamera
getVisibility
(
const
DtAxisAlignedBoundingBox<T>
& box)
const
;
94
96
DtScreenRect
screenAABB
(
const
DtAxisAlignedBoundingBox<T>
& worldBox
97
,
const
Vector2_uint32
& viewPortSize)
const
;
98
private
:
99
DtVector3<T>
myVecPosition
;
100
DtVector3<T>
myVecDirection
;
101
DtVector3<T>
myVecUpVector
;
102
DtVector3<T>
myVecSideVector
;
103
104
T
myfNearPlane
;
105
T
myfFarPlane
;
106
T
myfFieldOfViewY
;
107
T
myfAspectRatio
;
108
109
DtMatrix4<T>
myViewMatrix
;
110
DtMatrix4<T>
myProjectionMatrix
;
111
DtMatrix4<T>
myViewProjectionMatrix
;
112
113
bool
mybFixedUpVector
;
114
115
DtPlane<T>
myFrustumPlanes
[6];
116
void
updateFrustumPlanes
(
void
);
117
void
updateViewProjectionMatrix
(
void
);
118
};
119
120
template
<
class
T>
121
class
ProjectionUtils
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
141
static
DtScreenRect
screenAABB
(
const
DtAxisAlignedBoundingBox<T>
& worldBox
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-2022 MAK Technologies. All Rights Reserved (
www.mak.com
)