/** Returns whether the point is in the frustum. * * @param point The point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (Vector3 point) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(point); if (result == PlaneSide.Back) return false; } return true; }
/** Returns whether the point is in the frustum. * * @param point The point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (Vector3 point) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(point); if (result == PlaneSide.Back) return false; } return true; }
/** Returns whether the point is in the frustum. * * @param x The X coordinate of the point * @param y The Y coordinate of the point * @param z The Z coordinate of the point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (float x, float y, float z) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(x, y, z); if (result == PlaneSide.Back) return false; } return true; }
/** Returns whether the point is in the frustum. * * @param x The X coordinate of the point * @param y The Y coordinate of the point * @param z The Z coordinate of the point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (float x, float y, float z) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(x, y, z); if (result == PlaneSide.Back) return false; } return true; }
/** Returns whether the given bounding box is in the frustum. * @return Whether the bounding box is in the frustum */ public boolean boundsInFrustum (float x, float y, float z, float halfWidth, float halfHeight, float halfDepth) { for (int i = 0, len2 = planes.length; i < len2; i++) { if (planes[i].testPoint(x + halfWidth, y + halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y + halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y - halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y - halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y + halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y + halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y - halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y - halfHeight, z - halfDepth) != PlaneSide.Back) continue; return false; } return true; }
/** Returns whether the given bounding box is in the frustum. * @return Whether the bounding box is in the frustum */ public boolean boundsInFrustum (float x, float y, float z, float halfWidth, float halfHeight, float halfDepth) { for (int i = 0, len2 = planes.length; i < len2; i++) { if (planes[i].testPoint(x + halfWidth, y + halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y + halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y - halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x + halfWidth, y - halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y + halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y + halfHeight, z - halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y - halfHeight, z + halfDepth) != PlaneSide.Back) continue; if (planes[i].testPoint(x - halfWidth, y - halfHeight, z - halfDepth) != PlaneSide.Back) continue; return false; } return true; }
/** Returns whether the given {@link BoundingBox} is in the frustum. * * @param bounds The bounding box * @return Whether the bounding box is in the frustum */ public boolean boundsInFrustum (BoundingBox bounds) { for (int i = 0, len2 = planes.length; i < len2; i++) { if (planes[i].testPoint(bounds.getCorner000(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner001(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner010(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner011(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner100(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner101(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner110(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner111(tmpV)) != PlaneSide.Back) continue; return false; } return true; }
/** Returns whether the given {@link BoundingBox} is in the frustum. * * @param bounds The bounding box * @return Whether the bounding box is in the frustum */ public boolean boundsInFrustum (BoundingBox bounds) { for (int i = 0, len2 = planes.length; i < len2; i++) { if (planes[i].testPoint(bounds.getCorner000(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner001(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner010(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner011(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner100(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner101(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner110(tmpV)) != PlaneSide.Back) continue; if (planes[i].testPoint(bounds.getCorner111(tmpV)) != PlaneSide.Back) continue; return false; } return true; }
boolean r1 = plane.testPoint(triangle[0], triangle[1], triangle[2]) == PlaneSide.Back; boolean r2 = plane.testPoint(triangle[0 + stride], triangle[1 + stride], triangle[2 + stride]) == PlaneSide.Back; boolean r3 = plane.testPoint(triangle[0 + stride * 2], triangle[1 + stride * 2], triangle[2 + stride * 2]) == PlaneSide.Back;
boolean r1 = plane.testPoint(triangle[0], triangle[1], triangle[2]) == PlaneSide.Back; boolean r2 = plane.testPoint(triangle[0 + stride], triangle[1 + stride], triangle[2 + stride]) == PlaneSide.Back; boolean r3 = plane.testPoint(triangle[0 + stride * 2], triangle[1 + stride * 2], triangle[2 + stride * 2]) == PlaneSide.Back;
/** Intersects a {@link Ray} and a {@link Plane}. The intersection point is stored in intersection in case an intersection is * present. * * @param ray The ray * @param plane The plane * @param intersection The vector the intersection point is written to (optional) * @return Whether an intersection is present. */ public static boolean intersectRayPlane (Ray ray, Plane plane, Vector3 intersection) { float denom = ray.direction.dot(plane.getNormal()); if (denom != 0) { float t = -(ray.origin.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0) return false; if (intersection != null) intersection.set(ray.origin).add(v0.set(ray.direction).scl(t)); return true; } else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(ray.origin); return true; } else return false; }
/** Intersects a {@link Ray} and a {@link Plane}. The intersection point is stored in intersection in case an intersection is * present. * * @param ray The ray * @param plane The plane * @param intersection The vector the intersection point is written to (optional) * @return Whether an intersection is present. */ public static boolean intersectRayPlane (Ray ray, Plane plane, Vector3 intersection) { float denom = ray.direction.dot(plane.getNormal()); if (denom != 0) { float t = -(ray.origin.dot(plane.getNormal()) + plane.getD()) / denom; if (t < 0) return false; if (intersection != null) intersection.set(ray.origin).add(v0.set(ray.direction).scl(t)); return true; } else if (plane.testPoint(ray.origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(ray.origin); return true; } else return false; }
/** Intersects a line and a plane. The intersection is returned as the distance from the first point to the plane. In case an * intersection happened, the return value is in the range [0,1]. The intersection point can be recovered by point1 + t * * (point2 - point1) where t is the return value of this method. * @param x * @param y * @param z * @param x2 * @param y2 * @param z2 * @param plane */ public static float intersectLinePlane (float x, float y, float z, float x2, float y2, float z2, Plane plane, Vector3 intersection) { Vector3 direction = tmp.set(x2, y2, z2).sub(x, y, z); Vector3 origin = tmp2.set(x, y, z); float denom = direction.dot(plane.getNormal()); if (denom != 0) { float t = -(origin.dot(plane.getNormal()) + plane.getD()) / denom; if (intersection != null) intersection.set(origin).add(direction.scl(t)); return t; } else if (plane.testPoint(origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(origin); return 0; } return -1; }
/** Intersects a line and a plane. The intersection is returned as the distance from the first point to the plane. In case an * intersection happened, the return value is in the range [0,1]. The intersection point can be recovered by point1 + t * * (point2 - point1) where t is the return value of this method. * @param x * @param y * @param z * @param x2 * @param y2 * @param z2 * @param plane */ public static float intersectLinePlane (float x, float y, float z, float x2, float y2, float z2, Plane plane, Vector3 intersection) { Vector3 direction = tmp.set(x2, y2, z2).sub(x, y, z); Vector3 origin = tmp2.set(x, y, z); float denom = direction.dot(plane.getNormal()); if (denom != 0) { float t = -(origin.dot(plane.getNormal()) + plane.getD()) / denom; if (intersection != null) intersection.set(origin).add(direction.scl(t)); return t; } else if (plane.testPoint(origin) == Plane.PlaneSide.OnPlane) { if (intersection != null) intersection.set(origin); return 0; } return -1; }
if (MathUtils.isZero(det)) { p.set(t1, t2, t3); if (p.testPoint(ray.origin) == PlaneSide.OnPlane && Intersector.isPointInTriangle(ray.origin, t1, t2, t3)) { if (intersection != null) intersection.set(ray.origin); return true;
if (MathUtils.isZero(det)) { p.set(t1, t2, t3); if (p.testPoint(ray.origin) == PlaneSide.OnPlane && Intersector.isPointInTriangle(ray.origin, t1, t2, t3)) { if (intersection != null) intersection.set(ray.origin); return true;
/** Returns whether the point is in the frustum. * * @param point The point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (Vector3 point) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(point); if (result == PlaneSide.Back) return false; } return true; }
/** Returns whether the point is in the frustum. * * @param x The X coordinate of the point * @param y The Y coordinate of the point * @param z The Z coordinate of the point * @return Whether the point is in the frustum. */ public boolean pointInFrustum (float x, float y, float z) { for (int i = 0; i < planes.length; i++) { PlaneSide result = planes[i].testPoint(x, y, z); if (result == PlaneSide.Back) return false; } return true; }
public Plane.PlaneSide sideRightPlane(Vector3 point) { return rightPlane.testPoint(point); } }
public Plane.PlaneSide sideLeftPlane(Vector3 point) { return leftPlane.testPoint(point); }