Google

Main Page   Class Hierarchy   Compound List   File List   Compound Members  

csFrustum Class Reference

A general frustum. More...

#include <frustum.h>

Inheritance diagram for csFrustum:

csShadowFrustum List of all members.

Public Methods

 csFrustum (const csVector3 &o)
 Create a new empty frustum.

 csFrustum (const csVector3 &o, csVertexArrayPool *pl)
 Create a new empty frustum with another pool.

 csFrustum (const csVector3 &o, csVector3 *verts, int num_verts, csPlane3 *backp=NULL)
 Create a frustum given a polygon and a backplane. More...

 csFrustum (const csVector3 &o, int num_verts, csVertexArrayPool *pl, csPlane3 *backp=NULL)
 Create a frustum given a number of vertices and a backplane. More...

 csFrustum (const csFrustum &copy)
 Copy constructor.

virtual ~csFrustum ()
void SetOrigin (const csVector3 &o)
 Set the origin of this frustum.

csVector3GetOrigin ()
 Get the origin of this frustum.

const csVector3GetOrigin () const
 Get the origin of this frustum.

void SetMirrored (bool m)
 Enable/disable mirroring. More...

bool IsMirrored ()
 Is this frustum mirrored?

void SetBackPlane (csPlane3 &plane)
 Set the back plane of this frustum. More...

csPlane3GetBackPlane ()
 Get the back plane.

void RemoveBackPlane ()
 Remove the back plane of this frustum.

void AddVertex (const csVector3 &v)
 Add a vertex to the frustum polygon.

int GetVertexCount ()
 Get the number of vertices.

csVector3GetVertex (int idx)
 Get a vertex.

csVector3GetVertices ()
 Get the array of vertices.

void Transform (csTransform *trans)
 Apply a transformation to this 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. More...

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). More...

csFrustum* Intersect (const csFrustum &other)
 Intersect with another frustum. More...

csFrustum* Intersect (csVector3 *poly, int num)
 Intersect a convex polygon with this volume. More...

bool Contains (const csVector3 &point)
 Check if a point (given relative to the origin of the frustum) is inside the frustum.

bool IsEmpty () const
 Return true if frustum is empty.

bool IsInfinite () const
 Return true if frustum is infinite.

bool IsWide () const
 Return true if frustum is infinitely wide but it can still have a back plane.

void MakeInfinite ()
 Make the frustum infinite (i.e. More...

void MakeEmpty ()
 Make the frustum empty.

void IncRef ()
 Increment reference counter.

void DecRef ()
 Decrement reference counter.


Static Public Methods

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). More...

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. More...

csFrustum* Intersect (const csVector3 &frust_origin, csVector3 *frust, int num_frust, csVector3 *poly, int num)
 Intersect a convex polygon with this volume. More...

csFrustum* Intersect (const csVector3 &frust_origin, csVector3 *frust, int num_frust, const csVector3 &v1, const csVector3 &v2, const csVector3 &v3)
 Intersect a triangle with this volume. More...

int Classify (csVector3 *frustum, int num_frust, csVector3 *poly, int num_poly)
 Check if a polygon intersects with the frustum (i.e. More...

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. More...

bool Contains (csVector3 *frustum, int num_frust, const csVector3 &point)
 Check if a point is inside a frustum. More...

bool Contains (csVector3 *frustum, int num_frust, const csPlane3 &plane, const csVector3 &point)
 Check if a point is inside a frustum. More...


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 NULL (not specified). The back plane can also be NULL.


Constructor & Destructor Documentation

csFrustum::csFrustum ( const csVector3 & o,
csVector3 * verts,
int num_verts,
csPlane3 * backp = NULL )
 

Create a frustum given a polygon and a backplane.

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

csFrustum::csFrustum ( const csVector3 & o,
int num_verts,
csVertexArrayPool * pl,
csPlane3 * backp = NULL )
 

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'.


Member Function Documentation

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.

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_XXX 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.

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.

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.

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.

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.

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 NULL if there is no intersection.

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

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 NULL if there is no intersection.

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

csFrustum * csFrustum::Intersect ( csVector3 * poly,
int num )
 

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 NULL if there is no intersection.

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

csFrustum * csFrustum::Intersect ( const csFrustum & other )
 

Intersect with another frustum.

The other frustum must have the same origin as this one. Otherwise the result is undefined. Returns new frustum which you should delete after usage. If there is no intersection this function returns NULL.

void csFrustum::MakeInfinite ( )
 

Make the frustum infinite (i.e.

clear the polygon and the back plane).

void csFrustum::SetBackPlane ( 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.


The documentation for this class was generated from the following file:
Generated for Crystal Space by doxygen 1.2.5 written by Dimitri van Heesch, ©1997-2000