CrystalSpace

Public API Reference

csFrustum Class Reference
[Geometry utilities]

A general frustum. More...

#include <csgeom/frustum.h>

List of all members.

Public Member Functions

void AddVertex (const csVector3 &v)
 Add a vertex to the frustum polygon.
void ClipPolyToPlane (csPlane3 *plane)
 Clip the polygon of this frustum to the postive side of an arbitrary plane (which should be specified relative to the origin of the frustum).
void ClipToPlane (csVector3 &v1, csVector3 &v2)
 Clip this frustum to the positive side of a plane formed by the origin of this frustum, and the two given vertices.
bool Contains (const csVector3 &point)
 Check if a point (given relative to the origin of the frustum) is inside the frustum.
 csFrustum (const csFrustum &copy)
 Copy constructor.
 csFrustum (const csVector3 &o, int num_verts, csPlane3 *backp=0)
 Create a frustum given a number of vertices and a backplane.
 csFrustum (const csVector3 &o, csVector3 *verts, int num_verts, csPlane3 *backp=0)
 Create a frustum given a polygon and a backplane.
 csFrustum (const csVector3 &o)
 Create a new empty frustum.
void DecRef ()
 Decrement reference counter.
csPlane3GetBackPlane () const
 Get the back plane.
const csVector3GetOrigin () const
 Get the origin of this frustum.
csVector3GetOrigin ()
 Get the origin of this frustum.
int GetRefCount ()
 Get reference count.
const csVector3GetVertex (int idx) const
 Get a vertex.
csVector3GetVertex (int idx)
 Get a vertex.
int GetVertexCount () const
 Get the number of vertices.
csVector3GetVertices () const
 Get the array of vertices.
void IncRef ()
 Increment reference counter.
csPtr< csFrustumIntersect (csVector3 *poly, int num) const
 Intersect a convex polygon with this volume.
csPtr< csFrustumIntersect (const csFrustum &other) const
 Intersect with another frustum.
bool IsEmpty () const
 Return true if frustum is empty.
bool IsInfinite () const
 Return true if frustum is infinite.
bool IsMirrored () const
 Is this frustum mirrored?
bool IsWide () const
 Return true if frustum is infinitely wide but it can still have a back plane.
void MakeEmpty ()
 Make the frustum empty.
void MakeInfinite ()
 Make the frustum infinite (i.e.
void RemoveBackPlane ()
 Remove the back plane of this frustum.
void SetBackPlane (const csPlane3 &plane)
 Set the back plane of this frustum.
void SetMirrored (bool m)
 Enable/disable mirroring.
void SetOrigin (const csVector3 &o)
 Set the origin of this frustum.
void Transform (csTransform *trans)
 Apply a transformation to this frustum.

Static Public Member Functions

static int BatchClassify (csVector3 *frustum, csVector3 *frustumNormals, int num_frust, csVector3 *poly, int num_poly)
 This is like the above version except that it takes a vector of precalculated frustum plane normals.
static int Classify (csVector3 *frustum, int num_frust, csVector3 *poly, int num_poly)
 Check if a polygon intersects with the frustum (i.e.
static void ClipToPlane (csVector3 *vertices, int &num_vertices, csClipInfo *clipinfo, const csPlane3 &plane)
 Clip a frustum (defined from 0,0,0 origin) to the given plane.
static void ClipToPlane (csVector3 *vertices, int &num_vertices, csClipInfo *clipinfo, const csVector3 &v1, const csVector3 &v2)
 Clip a frustum (defined from 0,0,0 origin) to the given plane (defined as 0-v1-v2).
static bool Contains (csVector3 *frustum, int num_frust, const csPlane3 &plane, const csVector3 &point)
 Check if a point is inside a frustum.
static bool Contains (csVector3 *frustum, int num_frust, const csVector3 &point)
 Check if a point is inside a frustum.
static csPtr< csFrustumIntersect (const csVector3 &frust_origin, csVector3 *frust, int num_frust, const csVector3 &v1, const csVector3 &v2, const csVector3 &v3)
 Intersect a triangle with this volume.
static csPtr< csFrustumIntersect (const csVector3 &frust_origin, csVector3 *frust, int num_frust, csVector3 *poly, int num)
 Intersect a convex polygon with this volume.


Detailed Description

A general frustum.

This consist of a center point (origin), a frustum polygon in 3D space (relative to center point) and a plane. The planes which go through the center and every edge of the polygon form the frustum. The plane is the back plane of the frustum. It is also possible to have an infinite frustum in which case the polygon will be 0 (not specified). The back plane can also be 0.

Definition at line 155 of file frustum.h.


Constructor & Destructor Documentation

csFrustum::csFrustum ( const csVector3 o  )  [inline]

Create a new empty frustum.

Definition at line 202 of file frustum.h.

csFrustum::csFrustum ( const csVector3 o,
csVector3 verts,
int  num_verts,
csPlane3 backp = 0 
)

Create a frustum given a polygon and a backplane.

The polygon is given relative to the origin 'o'. If the given polygon is 0 then we create an empty frustum.

csFrustum::csFrustum ( const csVector3 o,
int  num_verts,
csPlane3 backp = 0 
)

Create a frustum given a number of vertices and a backplane.

The vertices are not initialized but space is reserved for them. The polygon is given relative to the origin 'o'.

csFrustum::csFrustum ( const csFrustum copy  ) 

Copy constructor.


Member Function Documentation

void csFrustum::AddVertex ( const csVector3 v  ) 

Add a vertex to the frustum polygon.

static int csFrustum::BatchClassify ( csVector3 frustum,
csVector3 frustumNormals,
int  num_frust,
csVector3 poly,
int  num_poly 
) [static]

This is like the above version except that it takes a vector of precalculated frustum plane normals.

Use this if you have to classify a batch of polygons against the same frustum.

static int csFrustum::Classify ( csVector3 frustum,
int  num_frust,
csVector3 poly,
int  num_poly 
) [static]

Check if a polygon intersects with the frustum (i.e.

is visible in the frustum). Returns one of CS_FRUST_OUTSIDE etc. values. Frustum and polygon should be given relative to (0,0,0).

void csFrustum::ClipPolyToPlane ( csPlane3 plane  ) 

Clip the polygon of this frustum to the postive side of an arbitrary plane (which should be specified relative to the origin of the frustum).

Note that this clips the polygon which forms the frustum. It does not clip the frustum itself.

static void csFrustum::ClipToPlane ( csVector3 vertices,
int &  num_vertices,
csClipInfo clipinfo,
const csPlane3 plane 
) [static]

Clip a frustum (defined from 0,0,0 origin) to the given plane.

This routine will also fill an array of clipinfo so that you can use this information to correctly interpolate information related to the vertex (like texture mapping coordinates). Note that clipinfo needs to be preinitialized correctly with CS_CLIPINFO_ORIGINAL instances and correct indices.

static void csFrustum::ClipToPlane ( csVector3 vertices,
int &  num_vertices,
csClipInfo clipinfo,
const csVector3 v1,
const csVector3 v2 
) [static]

Clip a frustum (defined from 0,0,0 origin) to the given plane (defined as 0-v1-v2).

This routine will also fill an array of clipinfo so that you can use this information to correctly interpolate information related to the vertex (like texture mapping coordinates). Note that clipinfo needs to be preinitialized correctly with CS_CLIPINFO_ORIGINAL instances and correct indices.

void csFrustum::ClipToPlane ( csVector3 v1,
csVector3 v2 
)

Clip this frustum to the positive side of a plane formed by the origin of this frustum, and the two given vertices.

'v1' and 'v2' are given relative to that origin.

static bool csFrustum::Contains ( csVector3 frustum,
int  num_frust,
const csPlane3 plane,
const csVector3 point 
) [static]

Check if a point is inside a frustum.

The point and frustum are relative to (0,0,0). This function also checks if point is in front of given plane.

static bool csFrustum::Contains ( csVector3 frustum,
int  num_frust,
const csVector3 point 
) [static]

Check if a point is inside a frustum.

The point and frustum are relative to (0,0,0). Note that this function does not work correctly if the point is in the other direction from the average direction of the frustum.

bool csFrustum::Contains ( const csVector3 point  ) 

Check if a point (given relative to the origin of the frustum) is inside the frustum.

void csFrustum::DecRef (  )  [inline]

Decrement reference counter.

Definition at line 466 of file frustum.h.

csPlane3* csFrustum::GetBackPlane (  )  const [inline]

Get the back plane.

Definition at line 259 of file frustum.h.

const csVector3& csFrustum::GetOrigin (  )  const [inline]

Get the origin of this frustum.

Definition at line 236 of file frustum.h.

csVector3& csFrustum::GetOrigin (  )  [inline]

Get the origin of this frustum.

Definition at line 233 of file frustum.h.

int csFrustum::GetRefCount (  )  [inline]

Get reference count.

Definition at line 468 of file frustum.h.

const csVector3& csFrustum::GetVertex ( int  idx  )  const [inline]

Get a vertex.

Definition at line 288 of file frustum.h.

References CS_ASSERT.

csVector3& csFrustum::GetVertex ( int  idx  )  [inline]

Get a vertex.

Definition at line 279 of file frustum.h.

References CS_ASSERT.

int csFrustum::GetVertexCount (  )  const [inline]

Get the number of vertices.

Definition at line 274 of file frustum.h.

csVector3* csFrustum::GetVertices (  )  const [inline]

Get the array of vertices.

Definition at line 297 of file frustum.h.

void csFrustum::IncRef (  )  [inline]

Increment reference counter.

Definition at line 464 of file frustum.h.

static csPtr<csFrustum> csFrustum::Intersect ( const csVector3 frust_origin,
csVector3 frust,
int  num_frust,
const csVector3 v1,
const csVector3 v2,
const csVector3 v3 
) [static]

Intersect a triangle with this volume.

The triangle is given relative to the center point (origin) of this frustum.

Returns a new frustum which exactly covers the intersection of the triangle with the frustum (i.e. the smallest frustum which is part of this frustum and which 'sees' exactly the same of the given polygon as this frustum).

This function returns 0 if there is no intersection.

Note that the frustum polygon of the returned csFrustum is guaranteed to be coplanar with the given triangle.

static csPtr<csFrustum> csFrustum::Intersect ( const csVector3 frust_origin,
csVector3 frust,
int  num_frust,
csVector3 poly,
int  num 
) [static]

Intersect a convex polygon with this volume.

The convex polygon is given relative to the center point (origin) of this frustum.

Returns a new frustum which exactly covers the intersection of the polygon with the frustum (i.e. the smallest frustum which is part of this frustum and which 'sees' exactly the same of the given polygon as this frustum).

This function returns 0 if there is no intersection.

Note that the frustum polygon of the returned csFrustum is guaranteed to be coplanar with the given polygon.

csPtr<csFrustum> csFrustum::Intersect ( csVector3 poly,
int  num 
) const

Intersect a convex polygon with this volume.

The convex polygon is given relative to the center point (origin) of this frustum.

Returns a new frustum which exactly covers the intersection of the polygon with the frustum (i.e. the smallest frustum which is part of this frustum and which 'sees' exactly the same of the given polygon as this frustum).

This function returns 0 if there is no intersection.

Note that the frustum polygon of the returned csFrustum is guaranteed to be coplanar with the given polygon.

csPtr<csFrustum> csFrustum::Intersect ( const csFrustum other  )  const

Intersect with another frustum.

The other frustum must have the same origin as this one. Otherwise the result is undefined.

Returns:
The new frustum. If there is no intersection then 0 is returned.

Referenced by csIntersect3::FrustumFrustum().

bool csFrustum::IsEmpty (  )  const [inline]

Return true if frustum is empty.

Definition at line 441 of file frustum.h.

bool csFrustum::IsInfinite (  )  const [inline]

Return true if frustum is infinite.

Definition at line 444 of file frustum.h.

bool csFrustum::IsMirrored (  )  const [inline]

Is this frustum mirrored?

Definition at line 246 of file frustum.h.

bool csFrustum::IsWide (  )  const [inline]

Return true if frustum is infinitely wide but it can still have a back plane.

Definition at line 450 of file frustum.h.

void csFrustum::MakeEmpty (  ) 

Make the frustum empty.

void csFrustum::MakeInfinite (  ) 

Make the frustum infinite (i.e.

clear the polygon and the back plane).

void csFrustum::RemoveBackPlane (  ) 

Remove the back plane of this frustum.

void csFrustum::SetBackPlane ( const csPlane3 plane  ) 

Set the back plane of this frustum.

The given plane is copied to this structure and can thus be reused/freed later. The plane should be specified relative to the origin point.

void csFrustum::SetMirrored ( bool  m  )  [inline]

Enable/disable mirroring.

If mirroring is enabled this means that the frustum polygon is given in anti-clockwise order.

Definition at line 243 of file frustum.h.

void csFrustum::SetOrigin ( const csVector3 o  )  [inline]

Set the origin of this frustum.

Definition at line 230 of file frustum.h.

void csFrustum::Transform ( csTransform trans  ) 

Apply a transformation to this frustum.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.4.7