CrystalSpace

Public API Reference

Main Page   Modules   Class Hierarchy   Alphabetical List   Compound List   File List   Compound Members   File Members   Related Pages  

csFrustum Class Reference
[Geometry utilities]

A general frustum. More...

#include <frustum.h>

List of all members.

Public Methods

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

 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, int num_verts, csPlane3 *backp=0)
 Create a frustum given a number of vertices and a backplane.

 csFrustum (const csFrustum &copy)
 Copy constructor.

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.

bool IsMirrored ()
 Is this frustum mirrored?

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

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.

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

csPtr< csFrustum > Intersect (const csFrustum &other)
 Intersect with another frustum.

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

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.

void MakeEmpty ()
 Make the frustum empty.

void IncRef ()
 Increment reference counter.

void DecRef ()
 Decrement reference counter.

int GetRefCount ()
 Get reference count.


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

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.

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

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

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

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.

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

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


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 143 of file frustum.h.


Constructor & Destructor Documentation

csFrustum::csFrustum const csVector3   o [inline]
 

Create a new empty frustum.

Definition at line 190 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.

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

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.

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 448 of file frustum.h.

csPlane3* csFrustum::GetBackPlane   [inline]
 

Get the back plane.

Definition at line 247 of file frustum.h.

const csVector3& csFrustum::GetOrigin   const [inline]
 

Get the origin of this frustum.

Definition at line 224 of file frustum.h.

csVector3& csFrustum::GetOrigin   [inline]
 

Get the origin of this frustum.

Definition at line 221 of file frustum.h.

int csFrustum::GetRefCount   [inline]
 

Get reference count.

Definition at line 450 of file frustum.h.

csVector3& csFrustum::GetVertex int    idx [inline]
 

Get a vertex.

Definition at line 267 of file frustum.h.

int csFrustum::GetVertexCount   [inline]
 

Get the number of vertices.

Definition at line 262 of file frustum.h.

csVector3* csFrustum::GetVertices   [inline]
 

Get the array of vertices.

Definition at line 276 of file frustum.h.

void csFrustum::IncRef   [inline]
 

Increment reference counter.

Definition at line 446 of file frustum.h.

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.

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
 

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
 

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

bool csFrustum::IsEmpty   const [inline]
 

Return true if frustum is empty.

Definition at line 423 of file frustum.h.

bool csFrustum::IsInfinite   const [inline]
 

Return true if frustum is infinite.

Definition at line 426 of file frustum.h.

bool csFrustum::IsMirrored   [inline]
 

Is this frustum mirrored?

Definition at line 234 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 432 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 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 231 of file frustum.h.

void csFrustum::SetOrigin const csVector3   o [inline]
 

Set the origin of this frustum.

Definition at line 218 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.2.18