csFrustum Class Reference
[Geometry utilities]
A general frustum.
More...
#include <csgeom/frustum.h>
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 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. | |
csPlane3 * | GetBackPlane () const |
Get the back plane. | |
const csVector3 & | GetOrigin () const |
Get the origin of this frustum. | |
csVector3 & | GetOrigin () |
Get the origin of this frustum. | |
int | GetRefCount () |
Get reference count. | |
const csVector3 & | GetVertex (int idx) const |
Get a vertex. | |
csVector3 & | GetVertex (int idx) |
Get a vertex. | |
int | GetVertexCount () const |
Get the number of vertices. | |
csVector3 * | GetVertices () const |
Get the array of vertices. | |
void | IncRef () |
Increment reference counter. | |
csPtr< csFrustum > | Intersect (csVector3 *poly, int num) const |
Intersect a convex polygon with this volume. | |
csPtr< csFrustum > | Intersect (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< 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. | |
static csPtr< csFrustum > | Intersect (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] |
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.
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.
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] |
csPlane3* csFrustum::GetBackPlane | ( | ) | const [inline] |
const csVector3& csFrustum::GetOrigin | ( | ) | const [inline] |
csVector3& csFrustum::GetOrigin | ( | ) | [inline] |
int csFrustum::GetRefCount | ( | ) | [inline] |
const csVector3& csFrustum::GetVertex | ( | int | idx | ) | const [inline] |
csVector3& csFrustum::GetVertex | ( | int | idx | ) | [inline] |
int csFrustum::GetVertexCount | ( | ) | const [inline] |
csVector3* csFrustum::GetVertices | ( | ) | const [inline] |
void csFrustum::IncRef | ( | ) | [inline] |
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.
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.
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] |
bool csFrustum::IsInfinite | ( | ) | const [inline] |
bool csFrustum::IsMirrored | ( | ) | const [inline] |
bool csFrustum::IsWide | ( | ) | const [inline] |
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] |
void csFrustum::SetOrigin | ( | const csVector3 & | o | ) | [inline] |
void csFrustum::Transform | ( | csTransform * | trans | ) |
Apply a transformation to this frustum.
The documentation for this class was generated from the following file:
- csgeom/frustum.h
Generated for Crystal Space by doxygen 1.4.7