VR-Vantage 2.7 API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
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
namespace
makVrv {
22
23
enum
FrustumPlane
24
{
25
FRUSTUM_PLANE_NEAR
= 0,
26
FRUSTUM_PLANE_FAR
= 1,
27
FRUSTUM_PLANE_LEFT
= 2,
28
FRUSTUM_PLANE_RIGHT
= 3,
29
FRUSTUM_PLANE_TOP
= 4,
30
FRUSTUM_PLANE_BOTTOM
= 5
31
};
32
33
enum
VisibilityFromCamera
34
{
35
VISIBILITY_NONE
= 0,
VISIBILITY_PARTIAL
= 1,
VISIBILITY_FULL
= 2
36
};
37
40
template
<
class
T>
41
class
DtCamera
42
{
43
public
:
45
DtCamera
();
47
virtual
~DtCamera
();
48
49
void
setNearPlane
(T fNearPlane);
50
T
nearPlane
(
void
)
const
;
51
52
void
setFarPlane
(T fFarPlane);
53
T
farPlane
(
void
)
const
;
54
56
void
setFieldOfView
(T fFOVy);
57
T
fieldOfView
(
void
)
const
;
58
59
void
setPosition
(
const
DtVector3<T>
& vPosition);
60
DtVector3<T>
position
(
void
)
const
;
61
62
void
setDirection
(
const
DtVector3<T>
& vDirection);
63
DtVector3<T>
direction
(
void
)
const
;
64
65
DtVector3<T>
upVector
(
void
)
const
;
66
DtVector3<T>
sideVector
(
void
)
const
;
67
69
void
lookAt
(
const
DtVector3<T>
& vEye,
const
DtVector3<T>
& vLook,
const
DtVector3<T>
& vUp);
71
const
DtMatrix4<T>
&
ViewMatrix
(
void
)
const
;
72
74
void
SetPerspective
(T fFOVy, T fAspectRatio, T fNearPlane, T fFarPlane);
76
const
DtMatrix4<T>
&
ProjectionMatrix
(
void
)
const
;
77
79
const
DtMatrix4<T>
&
ViewProjectionMatrix
(
void
)
const
;
80
81
void
setFixedUpVector
(
bool
fixed);
82
bool
isFixedUpVector
(
void
)
const
;
83
85
T
aspectRatio
(
void
)
const
;
86
88
bool
IsVisible
(
const
DtAxisAlignedBoundingBox<T>
&
box
)
const
;
89
91
VisibilityFromCamera
getVisibility
(
const
DtAxisAlignedBoundingBox<T>
& box)
const
;
92
94
DtScreenRect
screenAABB
(
const
DtAxisAlignedBoundingBox<T>
& worldBox
95
,
const
Vector2_uint32
& viewPortSize)
const
;
96
private
:
97
DtVector3<T>
myVecPosition
;
98
DtVector3<T>
myVecDirection
;
99
DtVector3<T>
myVecUpVector
;
100
DtVector3<T>
myVecSideVector
;
101
102
T
myfNearPlane
;
103
T
myfFarPlane
;
104
T
myfFieldOfViewY
;
105
T
myfAspectRatio
;
106
107
DtMatrix4<T>
myViewMatrix
;
108
DtMatrix4<T>
myProjectionMatrix
;
109
DtMatrix4<T>
myViewProjectionMatrix
;
110
111
bool
mybFixedUpVector
;
112
113
DtPlane<T>
myFrustumPlanes
[6];
114
void
updateFrustumPlanes
(
void
);
115
void
updateViewProjectionMatrix
(
void
);
116
};
117
118
template
<
class
T>
119
class
ProjectionUtils
120
{
121
public
:
124
static
DtVector2<T>
project
(
const
DtVector3<T>
& vPosition
125
,
const
DtMatrix4<T>
& view_projection_matrix
126
,
bool
clip =
true
);
127
132
static
Vector2_int
project
(
const
DtVector3<T>
& vPosition
133
,
const
DtMatrix4<T>
& view_projection_matrix
134
,
const
Vector2_uint32
& viewPortSize
135
,
bool
clip =
true
);
136
139
static
DtScreenRect
screenAABB
(
const
DtAxisAlignedBoundingBox<T>
& worldBox
140
,
const
DtMatrix4<T>
& view_projection_matrix
141
,
const
Vector2_uint32
& viewPortSize
142
,
bool
clip =
true
);
143
};
144
145
148
template
<
class
T>
149
class
Frustum
150
{
151
public
:
153
Frustum
();
154
156
virtual
~Frustum
();
157
159
template
<
class
RHS>
160
Frustum
(
const
Frustum<RHS>
& rhs);
161
163
template
<
class
RHS>
164
Frustum
&
operator=
(
const
Frustum<RHS>
& rhs);
165
public
:
167
virtual
void
setPlane
(
FrustumPlane
plane
, T d,
const
DtVector3<T>
& vNormal);
168
170
virtual
const
DtPlane<T>
&
plane
(
FrustumPlane
plane)
const
;
171
173
virtual
DtVector4<T>
planeAsVector
(
FrustumPlane
plane)
const
;
174
176
virtual
bool
isVisible
(
const
DtAxisAlignedBoundingBox<T>
&
box
)
const
;
177
179
virtual
VisibilityFromCamera
visibility
(
const
DtAxisAlignedBoundingBox<T>
& box,
bool
ignoreNearFar =
false
)
const
;
180
182
virtual
void
setFromModelViewProjectionMatrix
(
const
DtMatrix4<T>
& mvp);
183
185
virtual
bool
operator==
(
const
Frustum<T>
& rhs)
const
;
186
188
virtual
bool
operator!=
(
const
Frustum<T>
& rhs)
const
;
189
protected
:
190
std::vector< DtPlane<T> >
myFrustumPlanes
;
191
};
192
193
}
//namespace makVrv
194
195
#include "
DtCamera.inl
"
Copyright © 2005-2021 MAK Technologies. All Rights Reserved (
www.mak.com
)