5 #ifndef __S_VIEW_FRUSTUM_H_INCLUDED__ 6 #define __S_VIEW_FRUSTUM_H_INCLUDED__ 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;
277 recalculateBoundingSphere();
282 return BoundingRadius;
287 return BoundingCenter;
351 planes[i].Normal.getLengthSQ());
369 index = SViewFrustum::ETS_PROJECTION;
break;
371 index = SViewFrustum::ETS_VIEW;
break;
375 return Matrices [
index ];
387 index = SViewFrustum::ETS_PROJECTION;
break;
389 index = SViewFrustum::ETS_VIEW;
break;
393 return Matrices [
index ];
399 bool wasClipped =
false;
418 inline void SViewFrustum::recalculateBoundingSphere()
424 const float farlen = FarNearDistance;
425 const float fartocenter = (farlen + (shortlen - longlen) * (shortlen + longlen)/(4*farlen)) / 2;
426 const float neartocenter = farlen - fartocenter;
442 float diam[8] = { 0.f };
444 for (i = 0; i < 8; ++i)
445 diam[i] = dir[i].getLengthSQ();
449 for (i = 0; i < 8; ++i)
451 if (diam[i] > longest)
455 BoundingRadius = sqrtf(longest);
core::vector3df getNearLeftUp() const
returns the point which is on the near left upper corner inside the the view frustum.
T Y
Y coordinate of the vector.
void transform(const core::matrix4 &mat)
transforms the frustum by the matrix
core::plane3d< f32 > planes[VF_PLANE_COUNT]
all planes enclosing the view frustum.
float f32
32 bit floating point variable.
vector3d< T > getInterpolated(const vector3d< T > &other, f64 d) const
Creates an interpolated vector between this vector and another vector.
f32 getKnownIntersectionWithLine(const vector3d< T > &linePoint1, const vector3d< T > &linePoint2) const
Get percentage of line between two points where an intersection with this plane happens.
void transformPlane(core::plane3d< f32 > &plane) const
Transforms a plane by this matrix.
const core::aabbox3d< f32 > & getBoundingBox() const
returns a bounding box enclosing the whole view frustum
vector3d< T > Normal
Normal vector of the plane.
core::vector3df getFarLeftDown() const
returns the point which is on the far left bottom corner inside the the view frustum.
Left plane of the frustum.
void setFrom(const core::matrix4 &mat, bool zClipFromZero)
This constructor creates a view frustum based on a projection and/or view matrix.
T X
X coordinate of the vector.
core::vector3df getNearRightUp() const
returns the point which is on the near right top corner inside the the view frustum.
core::vector3df getFarLeftUp() const
returns the point which is on the far left upper corner inside the the view frustum.
Everything in the Irrlicht Engine can be found in this namespace.
Top plane of the frustum.
3D line between two points with intersection methods.
Defines the view frustum. That's the space visible by the camera.
void reset(T x, T y, T z)
Resets the bounding box to a one-point box.
bool getIntersectionWithPlanes(const plane3d< T > &o1, const plane3d< T > &o2, vector3d< T > &outPoint) const
Get the intersection point with two other planes if there is one.
Projection transformation.
GLsizei GLsizei GLfloat distance
core::vector3df getBoundingCenter() const
get the bounding sphere's radius (of an optimized sphere, not the AABB's)
core::vector3df getFarRightDown() const
returns the point which is on the far right bottom corner inside the the view frustum.
core::aabbox3d< f32 > boundingBox
bounding box around the view frustum
Right plane of the frustum.
core::vector3df getFarRightUp() const
returns the point which is on the far right top corner inside the the view frustum.
E_TRANSFORMATION_STATE
enumeration for geometry transformation states
float getBoundingRadius() const
get the bounding sphere's radius (of an optimized sphere, not the AABB's)
bool clipLine(core::line3d< f32 > &line) const
clips a line to the view frustum.
vector3d< T > end
End point of line.
unsigned int u32
32 bit unsigned variable.
Amount of planes enclosing the view frustum. Should be 6.
void transformVect(vector3df &vect) const
Transforms the vector by this matrix.
core::vector3df cameraPosition
the position of the camera
core::vector3df getNearRightDown() const
returns the point which is on the near right bottom corner inside the the view frustum.
SViewFrustum()
Default Constructor.
void setFarNearDistance(float distance)
the cam should tell the frustum the distance between far and near
Near plane of the frustum. That is the plane nearest to the eye.
4x4 matrix. Mostly used as transformation matrix for 3d calculations.
vector3d< T > start
Start point of line.
void addInternalPoint(const vector3d< T > &p)
Adds a point to the bounding box.
core::matrix4 & getTransform(video::E_TRANSFORMATION_STATE state)
get the given state's matrix based on frustum E_TRANSFORMATION_STATE
T Z
Z coordinate of the vector.
Far plane of the frustum. That is the plane furthest away from the eye.
void recalculateBoundingBox()
recalculates the bounding box and sphere based on the planes
core::vector3df getNearLeftDown() const
returns the point which is on the near left bottom corner inside the the view frustum.
REALINLINE f64 reciprocal_squareroot(const f64 x)
Bottom plane of the frustum.