crystalspace.jbind.impl.csgeom.frustum
Class csFrustum

java.lang.Object
  extended bycrystalspace.jbind.impl.csNativeObject
      extended bycrystalspace.jbind.impl.csgeom.frustum.csFrustum
All Implemented Interfaces:
iPointer

public class csFrustum
extends csNativeObject

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.

Author:
Java wrapper - Quentin Anciaux, c++ version - http://crystal.sourceforge.net/docs/online/pubapi/classcsFrustum.php

Field Summary
 
Fields inherited from class crystalspace.jbind.impl.csNativeObject
ImplFactory, nPointer
 
Constructor Summary
csFrustum(csFrustum copy)
          Copy constructor
csFrustum(csVector3 o)
          Create a new empty frustum.
csFrustum(csVector3 o, csVector3Array verts)
          Create a frustum given a polygon and a backplane.
csFrustum(csVector3 o, csVector3Array verts, csPlane3 backp)
          Create a frustum given a polygon and a backplane.
csFrustum(csVector3 o, csVertexArrayPool pl)
          Create a new empty frustum with another pool.
csFrustum(csVector3 o, int num_verts, csVertexArrayPool pl)
          Create a frustum given a number of vertices and a backplane.
csFrustum(csVector3 o, int num_verts, csVertexArrayPool pl, csPlane3 backp)
          Create a frustum given a number of vertices and a backplane.
csFrustum(iPointer nPointer)
           
 
Method Summary
 void addVertex(csVector3 v)
          Add a vertex to the frustum polygon.
static int batchClassify(csVector3Array frustum, csVector3 frustumNormals, csVector3Array poly)
          This is like the above version except that it takes a vector of precalculated frustum plane normals.
static int classify(csVector3Array frustum, csVector3Array poly)
          Check if a polygon intersects with the frustum (i.e. is visible in the frustum).
 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).
static void clipToPlane(csVector3Array vertices, csClipInfo clipinfo, csPlane3 plane)
          Clip a frustum (defined from 0,0,0 origin) to the given plane.
static void clipToPlane(csVector3Array vertices, csClipInfo clipinfo, csVector3 v1, csVector3 v2)
          Clip a frustum (defined from 0,0,0 origin) to the given plane (defined as 0-v1-v2).
 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.
 boolean contains(csVector3 point)
          Check if a point (given relative to the origin of the frustum) is inside the frustum.
static boolean contains(csVector3Array frustum, csPlane3 plane, csVector3 point)
          Check if a point is inside a frustum.
static boolean contains(csVector3Array frustum, csVector3 point)
          Check if a point is inside a frustum.
 void decRef()
          Decrement reference counter.
 csPlane3 getBackPlane()
          Get the back plane.
 csVector3 getOrigin()
          Get the origin of this frustum.
 csVector3 getVertex(int idx)
          Get a vertex.
 int getVertexCount()
          Get the number of vertices.
 csVector3Array getVertices()
          Get the array of vertices.
 void incRef()
          Increment reference counter.
 csFrustum intersect(csFrustum other)
          Intersect with another frustum.
 csFrustum intersect(csVector3Array poly)
          Intersect a convex polygon with this volume.
static csFrustum intersect(csVector3 frust_origin, csVector3Array frust, csVector3Array poly)
          Intersect a convex polygon with this volume.
static csFrustum intersect(csVector3 frust_origin, csVector3Array frust, csVector3 v1, csVector3 v2, csVector3 v3)
          Intersect a triangle with this volume.
 boolean isEmpty()
          Return true if frustum is empty.
 boolean isInfinite()
          Return true if frustum is infinite.
 boolean isMirrored()
          Is this frustum mirrored?
protected  boolean isNativePointerValidSafe(long nPointer)
           
 boolean isWide()
          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. clear the polygon and the back plane).
protected  void nDelete(long pointer)
           
 void removeBackPlane()
          Remove the back plane of this frustum.
 void setBackPlane(csPlane3 plane)
          Set the back plane of this frustum.
 void setMirrored(boolean m)
          Enable/disable mirroring.
 void setOrigin(csVector3 o)
          Set the origin of this frustum.
 void transform(csTransform trans)
          Apply a transformation to this frustum.
 
Methods inherited from class crystalspace.jbind.impl.csNativeObject
changePointer, equals, finalize, getPointer, getPointer, getPointerArray, hashCode, isMemoryOwner, isNativePointerValid, newNativeObject, setMemoryOwner, toString
 
Methods inherited from class java.lang.Object
clone, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

csFrustum

public csFrustum(iPointer nPointer)
Parameters:
nPointer -

csFrustum

public csFrustum(csVector3 o)
Create a new empty frustum. Definition at line 192 of file frustum.h.

Parameters:
o -

csFrustum

public csFrustum(csVector3 o,
                 csVertexArrayPool pl)
Create a new empty frustum with another pool. Definition at line 198 of file frustum.h.

Parameters:
o -
pl -

csFrustum

public csFrustum(csVector3 o,
                 csVector3Array verts)
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.

Parameters:
o -
verts -

csFrustum

public csFrustum(csVector3 o,
                 csVector3Array verts,
                 csPlane3 backp)
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.

Parameters:
o -
verts -
backp -

csFrustum

public csFrustum(csVector3 o,
                 int num_verts,
                 csVertexArrayPool pl)
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'.

Parameters:
o -
num_verts -
pl -

csFrustum

public csFrustum(csVector3 o,
                 int num_verts,
                 csVertexArrayPool pl,
                 csPlane3 backp)
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'.

Parameters:
o -
num_verts -
pl -
backp -

csFrustum

public csFrustum(csFrustum copy)
Copy constructor

Parameters:
copy -
Method Detail

nDelete

protected void nDelete(long pointer)
Specified by:
nDelete in class csNativeObject
See Also:
csNativeObject.nDelete(long)

isNativePointerValidSafe

protected boolean isNativePointerValidSafe(long nPointer)
Specified by:
isNativePointerValidSafe in class csNativeObject
See Also:
crystalspace.jbind.impl.csNativeObject#isNativePointerValidSafe()

addVertex

public void addVertex(csVector3 v)
Add a vertex to the frustum polygon.

Parameters:
v -

batchClassify

public static int batchClassify(csVector3Array frustum,
                                csVector3 frustumNormals,
                                csVector3Array poly)
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.

Parameters:
frustum -
frustumNormals -
poly -
Returns:

classify

public static int classify(csVector3Array frustum,
                           csVector3Array poly)
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).

Parameters:
frustum -
poly -
Returns:

clipPolyToPlane

public 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). Note that this clips the polygon which forms the frustum. It does not clip the frustum itself.

Parameters:
plane -

clipToPlane

public static void clipToPlane(csVector3Array vertices,
                               csClipInfo clipinfo,
                               csPlane3 plane)
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.

Parameters:
vertices -
clipinfo -
plane -

clipToPlane

public static void clipToPlane(csVector3Array vertices,
                               csClipInfo clipinfo,
                               csVector3 v1,
                               csVector3 v2)
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.

Parameters:
vertices -
clipinfo -
v1 -
v2 -

clipToPlane

public 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. 'v1' and 'v2' are given relative to that origin.

Parameters:
v1 -
v2 -

contains

public static boolean contains(csVector3Array frustum,
                               csPlane3 plane,
                               csVector3 point)
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.

Parameters:
frustum -
plane -
point -
Returns:

contains

public static boolean contains(csVector3Array frustum,
                               csVector3 point)
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.

Parameters:
frustum -
point -
Returns:

contains

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

Parameters:
point -
Returns:

decRef

public void decRef()
Decrement reference counter. Definition at line 451 of file frustum.h.


getBackPlane

public csPlane3 getBackPlane()
Get the back plane. Definition at line 255 of file frustum.h.

Returns:

getOrigin

public csVector3 getOrigin()
Get the origin of this frustum. Definition at line 232 of file frustum.h.

Returns:

getVertex

public csVector3 getVertex(int idx)
Get a vertex. Definition at line 275 of file frustum.h.

Parameters:
idx -
Returns:

getVertexCount

public int getVertexCount()
Get the number of vertices. Definition at line 270 of file frustum.h.

Returns:

getVertices

public csVector3Array getVertices()
Get the array of vertices. Definition at line 284 of file frustum.h.

Returns:

incRef

public void incRef()
Increment reference counter. Definition at line 449 of file frustum.h.


intersect

public static csFrustum intersect(csVector3 frust_origin,
                                  csVector3Array frust,
                                  csVector3 v1,
                                  csVector3 v2,
                                  csVector3 v3)
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.

Parameters:
frust_origin -
frust -
v1 -
v2 -
v3 -
Returns:

intersect

public static csFrustum intersect(csVector3 frust_origin,
                                  csVector3Array frust,
                                  csVector3Array poly)
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.

Parameters:
frust_origin -
frust -
poly -
Returns:

intersect

public csFrustum intersect(csVector3Array poly)
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.

Parameters:
poly -
Returns:

intersect

public csFrustum intersect(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.

Parameters:
other -
Returns:

isEmpty

public boolean isEmpty()
Return true if frustum is empty. Definition at line 429 of file frustum.h.

Returns:

isInfinite

public boolean isInfinite()
Return true if frustum is infinite. Definition at line 432 of file frustum.h.

Returns:

isMirrored

public boolean isMirrored()
Is this frustum mirrored? Definition at line 242 of file frustum.h.

Returns:

isWide

public boolean isWide()
Return true if frustum is infinitely wide but it can still have a back plane. Definition at line 435 of file frustum.h.

Returns:

makeEmpty

public void makeEmpty()
Make the frustum empty.


makeInfinite

public void makeInfinite()
Make the frustum infinite (i.e. clear the polygon and the back plane).


removeBackPlane

public void removeBackPlane()
Remove the back plane of this frustum.


setBackPlane

public void 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.

Parameters:
plane -

setMirrored

public void setMirrored(boolean m)
Enable/disable mirroring. If mirroring is enabled this means that the frustum polygon is given in anti-clockwise order. Definition at line 239 of file frustum.h.

Parameters:
m -

setOrigin

public void setOrigin(csVector3 o)
Set the origin of this frustum. Definition at line 226 of file frustum.h.

Parameters:
o -

transform

public void transform(csTransform trans)
Apply a transformation to this frustum.

Parameters:
trans -