My Project
ShapeFrustum.h
1 #pragma once
2 
3 namespace ParaEngine
4 {
5  class CShapeAABB;
6  class CShapeSphere;
7 
10  {
11  public:
12  CShapeFrustum();
14  CShapeFrustum(const Matrix4* matrix);
15 
16  bool TestSphere ( const CShapeSphere* sphere ) const;
17  bool TestSweptSphere( const CShapeSphere* sphere, const Vector3* sweepDir ) const;
23  int TestBox ( const CShapeAABB* box ) const;
24 
31  virtual void UpdateFrustum(const Matrix4* matViewProj, bool bInversedMatrix=false, float fNearPlane = 0.f, float fFarPlane = 1.f);
32 
36  inline Plane& GetPlane(int nIndex) {return planeFrustum[nIndex];}
37 
41  bool CullPointWithPlane(int iPlane, const Vector3* vPos);
42 
44  bool CullPointsWithFrustum(Vector3* pVecBounds, int nCount);
45 
50  int nVertexLUT[6];
51  public:
53  static bool SweptSpherePlaneIntersect(float& t0, float& t1, const Plane* plane, const CShapeSphere* sphere, const Vector3* sweepDir);
54  };
55 }
different physics engine has different winding order.
Definition: EventBinding.h:32
Standard 3-dimensional vector.
Definition: ParaVector3.h:16
Vector3 vecFrustum[8]
corners of the view frustum
Definition: ShapeFrustum.h:47
Definition: ShapeSphere.h:6
AABB-related code.
Definition: ShapeAABB.h:11
Plane & GetPlane(int nIndex)
Get a given frustum plane.
Definition: ShapeFrustum.h:36
bool CullPointsWithFrustum(Vector3 *pVecBounds, int nCount)
return true if any of the point is inside the frustum
Definition: ShapeFrustum.cpp:162
Class encapsulating a standard 4x4 homogeneous matrix.
Definition: ParaMatrix4.h:23
int TestBox(const CShapeAABB *box) const
Tests if an AABB is inside/intersecting the view frustum.
Definition: ShapeFrustum.cpp:134
Defines a plane in 3D space.
Definition: ParaPlane.h:23
bool CullPointWithPlane(int iPlane, const Vector3 *vPos)
whether the point is inside a given plane.
Definition: ShapeFrustum.cpp:157
Plane planeFrustum[6]
planes of the view frustum
Definition: ShapeFrustum.h:49
a general view frustum class.
Definition: ShapeFrustum.h:9
virtual void UpdateFrustum(const Matrix4 *matViewProj, bool bInversedMatrix=false, float fNearPlane=0.f, float fFarPlane=1.f)
build a frustum from a camera (projection, or viewProjection) matrix
Definition: ShapeFrustum.cpp:26
static bool SweptSpherePlaneIntersect(float &t0, float &t1, const Plane *plane, const CShapeSphere *sphere, const Vector3 *sweepDir)
this function tests if the projection of a bounding sphere along the light direction intersects the v...
Definition: ShapeFrustum.cpp:64