VR-Vantage API Documentation
Home
Modules
Namespaces
Classes
Files
Libraries
Examples
Tutorials
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) 2014 MAK Technologies, Inc.
3
** All rights reserved.
4
******************************************************************************/
5
9
#pragma once
10
11
#include "
DtCommonTypes.h
"
12
#include "
DtAssert.h
"
13
#include "
DtMatrixUtils.h
"
14
#include "
DtAxisAlignedBoundingBox.h
"
15
#include "
DtPlane.h
"
16
#include "
DtScreenRect.h
"
17
18
#include "
DtVector2.h
"
19
#include "
DtIntSize.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
:
123
static
DtVector2<T>
project
(
const
DtVector3<T>
& vPosition
124
,
const
DtMatrix4<T>
& view_projection_matrix);
125
129
static
Vector2_uint32
project
(
const
DtVector3<T>
& vPosition
130
,
const
DtMatrix4<T>
& view_projection_matrix
131
,
const
Vector2_uint32
& viewPortSize);
132
134
static
DtScreenRect
getScreenAABB
(
const
DtAxisAlignedBoundingBox<T>
& worldBox
135
,
const
DtMatrix4<T>
& view_projection_matrix
136
,
const
Vector2_uint32
& viewPortSize);
137
138
};
139
140
143
template
<
class
T>
144
class
Frustum
145
{
146
public
:
147
Frustum
();
148
virtual
~Frustum
();
149
150
void
SetPlane
(
FrustumPlane
plane,
T
d,
const
DtVector3<T>
& vNormal);
151
const
DtPlane<T>
&
GetPlane
(
FrustumPlane
plane);
152
153
bool
IsVisible
(
const
DtAxisAlignedBoundingBox<T>
& box)
const
;
154
VisibilityFromCamera
GetVisibility
(
const
DtAxisAlignedBoundingBox<T>
& box)
const
;
155
156
private
:
157
std::vector< DtPlane<T> >
m_FrustumPlanes
;
158
};
159
160
}
//namespace makVrv
161
162
#include "
DtCamera.inl
"
Copyright © 2005-2013 VT MÄK. All Rights Reserved (
www.mak.com
)