aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/classes/share/javax/media/j3d/CachedFrustum.java131
-rw-r--r--src/classes/share/javax/media/j3d/Canvas3D.java6
2 files changed, 5 insertions, 132 deletions
diff --git a/src/classes/share/javax/media/j3d/CachedFrustum.java b/src/classes/share/javax/media/j3d/CachedFrustum.java
index a034e7d..e4d1df1 100644
--- a/src/classes/share/javax/media/j3d/CachedFrustum.java
+++ b/src/classes/share/javax/media/j3d/CachedFrustum.java
@@ -437,135 +437,4 @@ class CachedFrustum {
}
-
- /**
- * Tests for intersection of six sided hull and the frustum
- * @param six sided bounding box ( lower (x,y,z), upper (x,y,z))
- * @return true if they intersect
- */
- boolean intersect( double lx, double ly, double lz,
- double ux, double uy, double uz) {
- int i,index;
-
- // System.out.println("intersect frustum with box : lower ( " + lx + ", " + ly + ", " + lz +
- // ") upper( " + ux + ", " + uy + ", " + uz + ")");
- // System.out.println("frustum "+this.toString());
- // check if box and bounding box of frustum intersect
- if( ux > this.lower.x &&
- lx < this.upper.x &&
- uy > this.lower.y &&
- ly < this.upper.y &&
- uz > this.lower.z &&
- lz < this.upper.z ) {
- } else {
- // System.out.println("false box and bounding box of frustum do not intersect");
- return false;
- }
-
- // check if all box points out any frustum plane
- for(i=0;i<6;i++){
- if(( ux*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue; // corner inside plane
- }
- if(( ux*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ){
- continue;
- }
- if(( ux*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ){
- continue;
- }
- if(( ux*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- uz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- ly*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- if(( lx*this.clipPlanes[i].x +
- uy*this.clipPlanes[i].y +
- lz*this.clipPlanes[i].z + this.clipPlanes[i].w ) > -EPSILON ) {
- continue;
- }
- // System.out.println("false all corners outside this frustum plane"+frustum.clipPlanes[i].toString());
- return false; // all corners outside this frustum plane
- }
-
- // check if any box corner is inside of the frustum silhoette edges in the 3 views
- // y-z
- for(i=0;i<this.nxEdges;i++){
- index = this.xEdgeList[i];
- if(( uy*this.xEdges[index].y +
- uz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break; // corner inside ege
- if(( uy*this.xEdges[index].y +
- lz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if(( ly*this.xEdges[index].y +
- uz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if(( ly*this.xEdges[index].y +
- lz*this.xEdges[index].z + this.xEdges[index].w ) < EPSILON ) break;
- if( i == this.nxEdges-1) {
- // System.out.println("false all box corners outside yz silhouette edges ");
- return false; // all box corners outside yz silhouette edges
- }
- }
- // x-z
- for(i=0;i<this.nyEdges;i++){
- index = this.yEdgeList[i];
- if(( ux*this.yEdges[index].x +
- uz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( ux*this.yEdges[index].x +
- lz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( lx*this.yEdges[index].x +
- uz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if(( lx*this.yEdges[index].x +
- lz*this.yEdges[index].z + this.yEdges[index].w ) < EPSILON ) break;
- if( i == this.nyEdges-1) {
- // System.out.println("false all box corners outside xz silhouette edges");
- return false; // all box corners outside xz silhouette edges
- }
- }
- // x-y
- for(i=0;i<this.nzEdges;i++){
- index = this.zEdgeList[i];
- if(( uy*this.zEdges[index].y +
- uz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( uy*this.zEdges[index].y +
- lz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( ly*this.zEdges[index].y +
- uz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if(( ly*this.zEdges[index].y +
- lz*this.zEdges[index].z + this.zEdges[index].w ) < EPSILON ) break;
- if( i == this.nzEdges-1) {
- /*
- System.out.println("false all box corners outside xy silhouette edges");
- System.out.println("xy silhouette edges=");
- for(int j=0;j<this.nzEdges;j++){
- System.out.println(this.zEdges[j].toString());
- }
- */
- return false; // all box corners outside xy silhouette edges
- }
- }
- // System.out.println("true");
- return true;
- }
-
-
}
diff --git a/src/classes/share/javax/media/j3d/Canvas3D.java b/src/classes/share/javax/media/j3d/Canvas3D.java
index 4505897..8a7dc82 100644
--- a/src/classes/share/javax/media/j3d/Canvas3D.java
+++ b/src/classes/share/javax/media/j3d/Canvas3D.java
@@ -1536,7 +1536,11 @@ public class Canvas3D extends Canvas {
}
void setFrustumPlanes(Vector4d[] planes) {
- viewFrustum.set(planes);
+
+ if(VirtualUniverse.mc.viewFrustumCulling) {
+ /* System.out.println("Canvas3D.setFrustumPlanes()"); */
+ viewFrustum.set(planes);
+ }
}