@Test public void testBoundsInFrustum() { final BoundingBox bounds = new BoundingBox(); boolean result = frustum.boundsInFrustum(bounds); assertTrue(result); }
public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; }
Frustum { public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; } }
Frustum { public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; } Frustum(); }
Frustum { public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; } Frustum(); void update(Matrix4 inverseProjectionView); boolean sphereInFrustum(Vector3 center, double radius); boolean boundsInFrustum(BoundingBox bounds); boolean pointInFrustum(Vector3 point); }
Frustum { public boolean boundsInFrustum(BoundingBox bounds) { for(int i=0; i<6; i++) { Plane p = mPlanes[i]; mPoint1.x = p.getNormal().x > 0 ? bounds.getMin().x : bounds.getMax().x; mPoint2.x = p.getNormal().x > 0 ? bounds.getMax().x : bounds.getMin().x; mPoint1.y = p.getNormal().y > 0 ? bounds.getMin().y : bounds.getMax().y; mPoint2.y = p.getNormal().y > 0 ? bounds.getMax().y : bounds.getMin().y; mPoint1.z = p.getNormal().z > 0 ? bounds.getMin().z : bounds.getMax().z; mPoint2.z = p.getNormal().z > 0 ? bounds.getMax().z : bounds.getMin().z; double distance1 = p.getDistanceTo(mPoint1); double distance2 = p.getDistanceTo(mPoint2); if ( distance1 < 0 && distance2 < 0 ) return false; } return true; } Frustum(); void update(Matrix4 inverseProjectionView); boolean sphereInFrustum(Vector3 center, double radius); boolean boundsInFrustum(BoundingBox bounds); boolean pointInFrustum(Vector3 point);  }