5#ifndef __S_VIEW_FRUSTUM_H_INCLUDED__
6#define __S_VIEW_FRUSTUM_H_INCLUDED__
13#include "IVideoDriver.h"
125 enum E_TRANSFORMATION_STATE_FRUSTUM
133 inline void recalculateBoundingSphere();
138 float BoundingRadius;
139 float FarNearDistance;
156 for (i=0; i<ETS_COUNT_FRUSTUM; ++i)
157 Matrices[i]=other.Matrices[i];
159 BoundingRadius = other.BoundingRadius;
160 FarNearDistance = other.FarNearDistance;
161 BoundingCenter = other.BoundingCenter;
275 recalculateBoundingSphere();
280 return BoundingRadius;
285 return BoundingCenter;
290 FarNearDistance = distance;
337 const f32 len = -core::reciprocal_squareroot(
338 planes[i].Normal.getLengthSQ());
356 index = SViewFrustum::ETS_PROJECTION;
break;
358 index = SViewFrustum::ETS_VIEW;
break;
362 return Matrices [ index ];
374 index = SViewFrustum::ETS_PROJECTION;
break;
376 index = SViewFrustum::ETS_VIEW;
break;
380 return Matrices [ index ];
389 index = SViewFrustum::ETS_PROJECTION;
break;
391 index = SViewFrustum::ETS_VIEW;
break;
396 Matrices[index] = mat;
402 bool wasClipped =
false;
405 if (
planes[i].classifyPointRelation(line.
start) == core::ISREL3D_FRONT)
411 if (
planes[i].classifyPointRelation(line.
end) == core::ISREL3D_FRONT)
421 inline void SViewFrustum::recalculateBoundingSphere()
427 const float farlen = FarNearDistance;
428 const float fartocenter = (farlen + (shortlen - longlen) * (shortlen + longlen)/(4*farlen)) / 2;
429 const float neartocenter = farlen - fartocenter;
445 float diam[8] = { 0.f };
447 for (i = 0; i < 8; ++i)
448 diam[i] = dir[i].getLengthSQ();
452 for (i = 0; i < 8; ++i)
454 if (diam[i] > longest)
458 BoundingRadius = sqrtf(longest);
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
Definition matrix4.h:1140
void transformPlane(core::plane3d< f32 > &plane) const
Transforms a plane by this matrix.
Definition matrix4.h:1182
Axis aligned bounding box in 3d dimensional space.
Definition aabbox3d.h:22
3D line between two points with intersection methods.
Definition line3d.h:19
vector3d< T > start
Start point of line.
Definition line3d.h:130
vector3d< T > end
End point of line.
Definition line3d.h:132
Template plane class with some intersection testing methods.
Definition plane3d.h:34
vector3d< T > Normal
Normal vector of the plane.
Definition plane3d.h:228
vector3d< f32 > vector3df
Typedef for a f32 3d vector.
Definition vector3d.h:445
CMatrix4< f32 > matrix4
Typedef for f32 matrix.
Definition matrix4.h:2241
All scene management can be found in this namespace: Mesh loading, special scene nodes like octrees a...
Definition CIndexBuffer.h:13
E_TRANSFORMATION_STATE
enumeration for geometry transformation states
Definition IVideoDriver.h:57
@ ETS_VIEW
View transformation.
Definition IVideoDriver.h:59
@ ETS_PROJECTION
Projection transformation.
Definition IVideoDriver.h:63
Everything in the Irrlicht Engine can be found in this namespace.
Definition Skylicht.h:33
float f32
32 bit floating point variable.
Definition irrTypes.h:104
unsigned int u32
32 bit unsigned variable.
Definition irrTypes.h:58
Defines the view frustum. That's the space visible by the camera.
Definition SViewFrustum.h:26
const core::aabbox3d< f32 > & getBoundingBox() const
returns a bounding box enclosing the whole view frustum
Definition SViewFrustum.h:260
void setFrom(const core::matrix4 &mat)
This constructor creates a view frustum based on a projection and/or view matrix.
Definition SViewFrustum.h:295
float getBoundingRadius() const
get the bounding sphere's radius (of an optimized sphere, not the AABB's)
Definition SViewFrustum.h:278
core::vector3df getFarRightUp() const
returns the point which is on the far right top corner inside the the view frustum.
Definition SViewFrustum.h:200
void recalculateBoundingBox()
recalculates the bounding box and sphere based on the planes
Definition SViewFrustum.h:265
core::vector3df getNearRightUp() const
returns the point which is on the near right top corner inside the the view frustum.
Definition SViewFrustum.h:240
core::vector3df getNearRightDown() const
returns the point which is on the near right bottom corner inside the the view frustum.
Definition SViewFrustum.h:250
SViewFrustum()
Default Constructor.
Definition SViewFrustum.h:48
core::vector3df cameraPosition
the position of the camera
Definition SViewFrustum.h:115
core::vector3df getFarLeftDown() const
returns the point which is on the far left bottom corner inside the the view frustum.
Definition SViewFrustum.h:190
bool clipLine(core::line3d< f32 > &line) const
clips a line to the view frustum.
Definition SViewFrustum.h:400
core::vector3df getBoundingCenter() const
get the bounding sphere's radius (of an optimized sphere, not the AABB's)
Definition SViewFrustum.h:283
core::vector3df getFarLeftUp() const
returns the point which is on the far left upper corner inside the the view frustum.
Definition SViewFrustum.h:180
core::vector3df getFarRightDown() const
returns the point which is on the far right bottom corner inside the the view frustum.
Definition SViewFrustum.h:210
void setFarNearDistance(float distance)
the cam should tell the frustum the distance between far and near
Definition SViewFrustum.h:288
core::matrix4 & getTransform(video::E_TRANSFORMATION_STATE state)
get the given state's matrix based on frustum E_TRANSFORMATION_STATE
Definition SViewFrustum.h:350
core::aabbox3d< f32 > boundingBox
bounding box around the view frustum
Definition SViewFrustum.h:121
core::vector3df getNearLeftUp() const
returns the point which is on the near left upper corner inside the the view frustum.
Definition SViewFrustum.h:220
VFPLANES
Definition SViewFrustum.h:28
@ VF_FAR_PLANE
Far plane of the frustum. That is the plane farest away from the eye.
Definition SViewFrustum.h:30
@ VF_LEFT_PLANE
Left plane of the frustum.
Definition SViewFrustum.h:34
@ VF_PLANE_COUNT
Amount of planes enclosing the view frustum. Should be 6.
Definition SViewFrustum.h:43
@ VF_BOTTOM_PLANE
Bottom plane of the frustum.
Definition SViewFrustum.h:38
@ VF_RIGHT_PLANE
Right plane of the frustum.
Definition SViewFrustum.h:36
@ VF_NEAR_PLANE
Near plane of the frustum. That is the plane nearest to the eye.
Definition SViewFrustum.h:32
@ VF_TOP_PLANE
Top plane of the frustum.
Definition SViewFrustum.h:40
core::vector3df getNearLeftDown() const
returns the point which is on the near left bottom corner inside the the view frustum.
Definition SViewFrustum.h:230
void transform(const core::matrix4 &mat)
transforms the frustum by the matrix
Definition SViewFrustum.h:170
core::plane3d< f32 > planes[VF_PLANE_COUNT]
all planes enclosing the view frustum.
Definition SViewFrustum.h:118