131 vSide.
x, vSide.
y, vSide.
z, 0
132 , vUp.
x, vUp.
y, vUp.
z, 0
133 , -vForward.
x, -vForward.
y, -vForward.
z, 0
222 for (
int i = 0; i < 6; ++i)
261 for (
int plane = 0; plane < 6; ++plane)
297 bool bAllInside =
true;
300 for (
int plane = 0; plane < 6; ++plane)
334 T w = (-position.
w < position.
w) ? position.
w : -position.
w;
355 position = position * T(0.5) + T(0.5);
375 vClipCoords.
x *= viewPortSize.
x;
376 vClipCoords.
y *= viewPortSize.
y;
391 rect.
vMax = viewPortSize;
401 rect.
vMin = viewPortSize;
408 for (
size_t i = 0; i < 8; ++i)
411 =
project(vectorAABBCorners[i], view_projection_matrix, viewPortSize, clip);
413 rect.
vMin.
x = std::min(rect.
vMin.
x, vWindowCoords.
x);
414 rect.
vMin.
y = std::min(rect.
vMin.
y, vWindowCoords.
y);
416 rect.
vMax.
x = std::max(rect.
vMax.
x, vWindowCoords.
x);
417 rect.
vMax.
y = std::max(rect.
vMax.
y, vWindowCoords.
y);
486 bool bAllInside =
true;
560 const T x = center.
x;
561 const T y = center.
y;
562 const T z = center.
z;
564 for (
unsigned int i = 0; i < 6; ++i)
568 const T dist = x * n.
x + y * n.
y + z * n.
z +
plane.d;
569 if (dist + radius < 0.0)
581 const T x = center.
x;
582 const T y = center.
y;
583 const T z = center.
z;
585 for (
unsigned int i = 0; i < 6; ++i)
589 const T dist = x * n.
x + y * n.
y + z * n.
z +
plane.d;
591 ((dist * dist) > radiusSquared))
629 bool reverseZ = (projMat[2][2] > 0.0);
637 frustNear = projMat[3][2] / (1.0 + projMat[2][2]);
638 frustFar = projMat[3][2] / projMat[2][2];
642 frustNear = projMat[3][2] / (projMat[2][2] - 1.0);
643 frustFar = projMat[3][2] / (1.0 + projMat[2][2]);
646 const T frustLeft = (projMat[2][0] - 1.0) / projMat[0][0];
647 const T frustRight = (1.0 + projMat[2][0]) / projMat[0][0];
648 const T frustTop = (1.0 + projMat[2][1]) / projMat[1][1];
649 const T frustBottom = (projMat[2][1] - 1.0) / projMat[1][1];
652 const T nLeft = frustNear * frustLeft;
653 const T nRight = frustNear * frustRight;
654 const T nTop = frustNear * frustTop;
655 const T nBottom = frustNear * frustBottom;
658 const T fLeft = frustFar * frustLeft;
659 const T fRight = frustFar * frustRight;
660 const T fTop = frustFar * frustTop;
661 const T fBottom = frustFar * frustBottom;
677 for (
int i = 0; i < 8; ++i)
733 for (
int i = 0; i < 6; ++i)
744 for(
int i=0; i<6; ++i)
749 destPlane.
x = sourceN.
x;
750 destPlane.
y = sourceN.
y;
751 destPlane.
z = sourceN.
z;
752 destPlane.
w = sourcePlane.
d;
759 for (
int i = 0; i < 6; ++i)
775 return !(lhs == rhs);
779 inline std::ostream&
operator <<
#define ASSERT_PREDICATE_RETURN(p)
Definition DtAssert.h:37
Template for 32/64 bit Axis Aligned bounding boxesnot virtual because its stored as is on the GPU.
Definition DtAxisAlignedBoundingBox.h:28
bool isNull(void) const
is null?
Definition DtAxisAlignedBoundingBox.inl:203
DtVector3< T > center(void) const
get the center
Definition DtAxisAlignedBoundingBox.inl:67
bool isInfinite(void) const
is infinite extents?
Definition DtAxisAlignedBoundingBox.inl:193
DtVector3< T > halfSize(void) const
half size
Definition DtAxisAlignedBoundingBox.inl:132
void GetCorners(DtVector3< T > corners[8]) const
get the 8 corners
Definition DtAxisAlignedBoundingBox.inl:209
DtVector3< T > myVecSideVector
Definition DtCamera.h:102
const DtMatrix4< T > & ViewProjectionMatrix(void) const
concatenated matrix : projection * view
Definition DtCamera.inl:235
T farPlane(void) const
Definition DtCamera.inl:58
T myfAspectRatio
Definition DtCamera.h:107
DtVector3< T > position(void) const
Definition DtCamera.inl:83
const DtMatrix4< T > & ProjectionMatrix(void) const
Get the projection matrix specified above.
Definition DtCamera.inl:195
T nearPlane(void) const
Definition DtCamera.inl:45
bool isFixedUpVector(void) const
Definition DtCamera.inl:206
T fieldOfView(void) const
Definition DtCamera.inl:71
DtMatrix4< T > myViewMatrix
Definition DtCamera.h:109
DtVector3< T > myVecUpVector
Definition DtCamera.h:101
DtVector3< T > myVecDirection
Definition DtCamera.h:100
T myfFarPlane
Definition DtCamera.h:105
void setFieldOfView(T fFOVy)
This is the complete field of view in the Y direction. Not half.
Definition DtCamera.inl:64
DtVector3< T > myVecPosition
Definition DtCamera.h:99
DtVector3< T > upVector(void) const
Definition DtCamera.inl:101
virtual ~DtCamera()
DTOR.
Definition DtCamera.inl:32
DtVector3< T > sideVector(void) const
Definition DtCamera.inl:107
void updateFrustumPlanes(void)
Definition DtCamera.inl:218
bool mybFixedUpVector
Definition DtCamera.h:113
DtCamera()
CTOR.
Definition DtCamera.inl:18
DtPlane< T > myFrustumPlanes[6]
Definition DtCamera.h:115
VisibilityFromCamera getVisibility(const DtAxisAlignedBoundingBox< T > &box) const
Returns visibility from this camera?
Definition DtCamera.inl:278
bool IsVisible(const DtAxisAlignedBoundingBox< T > &box) const
Is a box visible from this camera?
Definition DtCamera.inl:241
void SetPerspective(T fFOVy, T fAspectRatio, T fNearPlane, T fFarPlane)
gluPerspective style setting of the projection matrix
Definition DtCamera.inl:170
void lookAt(const DtVector3< T > &vEye, const DtVector3< T > &vLook, const DtVector3< T > &vUp)
gluLookAt style setting of the view matrix
Definition DtCamera.inl:113
T aspectRatio(void) const
Get the aspect ratio.
Definition DtCamera.inl:212
void setPosition(const DtVector3< T > &vPosition)
Definition DtCamera.inl:77
void setFixedUpVector(bool fixed)
Definition DtCamera.inl:201
DtVector3< T > direction(void) const
Definition DtCamera.inl:95
T myfNearPlane
Definition DtCamera.h:104
void updateViewProjectionMatrix(void)
Definition DtCamera.inl:229
DtMatrix4< T > myProjectionMatrix
Definition DtCamera.h:110
const DtMatrix4< T > & ViewMatrix(void) const
Get the view matrix specified above.
Definition DtCamera.inl:164
DtMatrix4< T > myViewProjectionMatrix
Definition DtCamera.h:111
void setNearPlane(T fNearPlane)
Definition DtCamera.inl:38
void setFarPlane(T fFarPlane)
Definition DtCamera.inl:51
void setDirection(const DtVector3< T > &vDirection)
Definition DtCamera.inl:89
T myfFieldOfViewY
Definition DtCamera.h:106
DtScreenRect screenAABB(const DtAxisAlignedBoundingBox< T > &worldBox, const Vector2_uint32 &viewPortSize) const
Get the screen space bounds of a world box.
Definition DtCamera.inl:362
Math utilities.
Definition DtMath.h:54
static T clamp(T val, T minval, T maxval)
Clamping routines.
Definition DtMath.h:173
static T Tan(T val)
Definition DtMath.h:63
4 dimensional matrix
Definition DtMatrix4.h:23
DtMatrix4< T > getInverse(void) const
Get the inverse of this matrix.
Definition DtMatrix4.h:375
const DtVector4< T > transposeMultiply(const DtVector4< T > &rhs) const
This is equal to: this->GetTranspose() * rhs (but potentialy faster).
Definition DtMatrix4.h:253
DtPlane class.
Definition DtPlane.h:25
T d
Definition DtPlane.h:35
DtVector3< T > vNormal
Definition DtPlane.h:34
2 dimensional vector
Definition DtVector2.h:26
T y
Definition DtVector2.h:105
static const DtVector2 theZeroVector
Definition DtVector2.h:108
T x
Definition DtVector2.h:105
2 dimensional vector
Definition DtVector3.h:27
T length(void) const
get the length of this vector
Definition DtVector3.h:180
DtVector3 crossProduct(const DtVector3 &rhs) const
get the cross product of this vector and rhs
Definition DtVector3.h:255
T y
Definition DtVector3.h:135
T z
Definition DtVector3.h:135
T x
Definition DtVector3.h:135
T dotProduct(const DtVector3 &rhs) const
get the dot product of this vector and rhs
Definition DtVector3.h:268
void normalize(void)
normalize this vector in place
Definition DtVector3.h:167
4 dimensional vector
Definition DtVector4.h:28
T x
Definition DtVector4.h:118
T w
Definition DtVector4.h:118
T z
Definition DtVector4.h:118
T y
Definition DtVector4.h:118
Template for 32/64 bit bit frustums.
Definition DtCamera.h:160
virtual VisibilityFromCamera visibility(const DtAxisAlignedBoundingBox< T > &box, bool ignoreNearFar=false) const
get visibility of bounding box within the frustum
Definition DtCamera.inl:473
virtual const DtPlane< T > & plane(FrustumPlane plane) const
get a frustum plane
Definition DtCamera.inl:458
Frustum & operator=(const Frustum< RHS > &rhs)
Assignment Operator.
virtual bool operator==(const Frustum< T > &rhs) const
equality
Definition DtCamera.inl:757
virtual DtVector4< T > planeAsVector(FrustumPlane plane) const
get the frustum plane as a vector
Definition DtCamera.inl:464
virtual bool isVisible(const DtAxisAlignedBoundingBox< T > &box) const
is bounding box visible within this frustum?
Definition DtCamera.inl:519
Frustum()
ctor
Definition DtCamera.inl:423
virtual void setPlane(FrustumPlane plane, T d, const DtVector3< T > &vNormal)
set a frustum plane
Definition DtCamera.inl:450
virtual void frustumPlanes(std::array< DtVector4< T >, 6 > &planes) const
get the frustum planes as DtVector4's
Definition DtCamera.inl:742
std::array< DtPlane< T >, 6 > myFrustumPlanes
Definition DtCamera.h:220
virtual bool isSphereVisibleRadiusSquared(const DtVector3< T > ¢er, double radiusSquared) const
is bounding sphere (with a radius squared) visible within this frustum?
Definition DtCamera.inl:579
void computePlaneFromPoints(DtPlane< T > &plane, const DtVector3< T > &point0, const DtVector3< T > &point1, const DtVector3< T > &point2) const
Helper to compute a plane from 3 points.
Definition DtCamera.inl:601
virtual ~Frustum()
dtor
Definition DtCamera.inl:429
virtual bool operator!=(const Frustum< T > &rhs) const
inequality
Definition DtCamera.inl:772
virtual void setFromModelViewProjectionMatrix(const DtMatrix4< T > &modelViewMat, const DtMatrix4< T > &projMat)
Definition DtCamera.inl:620
virtual bool isSphereVisible(const DtVector3< T > ¢er, T radius) const
is bounding sphere visible within this frustum?
Definition DtCamera.inl:558
static DtScreenRect screenAABB(const DtAxisAlignedBoundingBox< T > &worldBox, const DtMatrix4< T > &view_projection_matrix, const Vector2_uint32 &viewPortSize, bool clip=true)
Definition DtCamera.inl:382
static DtVector2< T > project(const DtVector3< T > &vPosition, const DtMatrix4< T > &view_projection_matrix, bool clip=true)
Definition DtCamera.inl:329
Contains DtCreateSensorFieldOfViewCommand and DtCreateSensorFieldOfViewCommandCreator class declarati...
Definition DtGridLinesSettingsRecord.h:16
PlaneSide
Definition DtPlane.h:14
@ NEGATIVE_SIDE
Definition DtPlane.h:17
@ BOTH_SIDE
Definition DtPlane.h:18
unsigned int uint32
Definition DtCommonTypes.h:28
DtVector2< uint32 > Vector2_uint32
Definition DtVector2.h:274
FrustumPlane
Definition DtCamera.h:26
@ FRUSTUM_PLANE_RIGHT
Definition DtCamera.h:30
@ FRUSTUM_PLANE_TOP
Definition DtCamera.h:31
@ FRUSTUM_PLANE_NEAR
Definition DtCamera.h:27
@ FRUSTUM_PLANE_LEFT
Definition DtCamera.h:29
@ FRUSTUM_PLANE_FAR
Definition DtCamera.h:28
@ FRUSTUM_PLANE_BOTTOM
Definition DtCamera.h:32
double length(const dvec3 &theVec)
Definition DtVecUtils.h:20
const DtVector2< T > DtVector2< T >::theZeroVector
Definition DtVector2.h:113
DtVector2< int32 > Vector2_int
Definition DtVector2.h:273
VisibilityFromCamera
Definition DtCamera.h:36
@ VISIBILITY_PARTIAL
Definition DtCamera.h:37
@ VISIBILITY_FULL
Definition DtCamera.h:37
@ VISIBILITY_NONE
Definition DtCamera.h:37
Screen Space Rectangle class.
Definition DtScreenRect.h:22
Vector2_int vMax
Definition DtScreenRect.h:25
Vector2_int vMin
Definition DtScreenRect.h:24