forked from 0ad/0ad
50e5e9acd9
-Auras now take additional parameters from XML, containing a tag for r, g, b, and a. No line thickness parameter yet. -For territories, added function to frustum for determining if line segment passes through the frustum. This was SVN commit r4242.
58 lines
1.5 KiB
C++
58 lines
1.5 KiB
C++
//***********************************************************
|
|
//
|
|
// Name: Frustum.H
|
|
// Last Update: 24/2/02
|
|
// Author: Poya Manouchehri
|
|
//
|
|
// Description: CFrustum is a collection of planes which define
|
|
// a viewing space. Usually associated with the
|
|
// camera, there are 6 planes which define the
|
|
// view pyramid. But we allow more planes per
|
|
// frustum which maybe used for portal rendering,
|
|
// where a portal may have 3 or more edges.
|
|
//
|
|
//***********************************************************
|
|
|
|
#ifndef FRUSTUM_H
|
|
#define FRUSTUM_H
|
|
|
|
#include "maths/Plane.h"
|
|
|
|
//10 planes should be enough
|
|
#define MAX_NUM_FRUSTUM_PLANES (10)
|
|
|
|
class CBound;
|
|
|
|
class CFrustum
|
|
{
|
|
public:
|
|
CFrustum ();
|
|
~CFrustum ();
|
|
|
|
//Set the number of planes to use for
|
|
//calculations. This is clipped to
|
|
//[0,MAX_NUM_FRUSTUM_PLANES]
|
|
void SetNumPlanes (int num);
|
|
|
|
uint GetNumPlanes() const { return m_NumPlanes; }
|
|
|
|
//The following methods return true if the shape is
|
|
//partially or completely in front of the frustum planes
|
|
bool IsPointVisible (const CVector3D &point) const;
|
|
bool DoesSegmentIntersect(const CVector3D& start, const CVector3D &end);
|
|
bool IsSphereVisible (const CVector3D ¢er, float radius) const;
|
|
bool IsBoxVisible (const CVector3D &position,const CBound &bounds) const;
|
|
|
|
CPlane& operator[](uint idx) { return m_aPlanes[idx]; }
|
|
const CPlane& operator[](uint idx) const { return m_aPlanes[idx]; }
|
|
|
|
public:
|
|
//make the planes public for ease of use
|
|
CPlane m_aPlanes[MAX_NUM_FRUSTUM_PLANES];
|
|
|
|
private:
|
|
int m_NumPlanes;
|
|
};
|
|
|
|
#endif
|