/** * * @param viewCam * @return */ @Override protected boolean checkCulling(Camera viewCam) { Camera cam = viewCam; if(frustumCam != null){ cam = frustumCam; cam.setLocation(viewCam.getLocation()); cam.setRotation(viewCam.getRotation()); } TempVars vars = TempVars.get(); boolean intersects = light.intersectsFrustum(cam,vars); vars.release(); return intersects; }
@Override public void simpleUpdate(float tpf) { TempVars vars = TempVars.get(); boolean intersect = spotLight.intersectsFrustum(frustumCam, vars); if (intersect) { geom.getMaterial().setColor("Diffuse", ColorRGBA.Green); } else { geom.getMaterial().setColor("Diffuse", ColorRGBA.White); } Vector3f farPoint = vars.vect1.set(spotLight.getPosition()).addLocal(vars.vect2.set(spotLight.getDirection()).multLocal(spotLight.getSpotRange())); //computing the radius of the base disc float farRadius = (spotLight.getSpotRange() / FastMath.cos(spotLight.getSpotOuterAngle())) * FastMath.sin(spotLight.getSpotOuterAngle()); //computing the projection direction : perpendicular to the light direction and coplanar with the direction vector and the normal vector Vector3f perpDirection = vars.vect2.set(spotLight.getDirection()).crossLocal(frustumCam.getWorldPlane(3).getNormal()).normalizeLocal().crossLocal(spotLight.getDirection()); //projecting the far point on the base disc perimeter Vector3f projectedPoint = vars.vect3.set(farPoint).addLocal(perpDirection.multLocal(farRadius)); vars.release(); // boxGeo.setLocalTranslation(spotLight.getPosition()); // boxGeo.setLocalTranslation(projectedPoint); } }
assert !sl.intersectsFrustum(cam, vars); assert sl.intersectsFrustum(cam, vars); } finally { vars.release();
/** * * @param viewCam * @return */ @Override protected boolean checkCulling(Camera viewCam) { Camera cam = viewCam; if(frustumCam != null){ cam = frustumCam; cam.setLocation(viewCam.getLocation()); cam.setRotation(viewCam.getRotation()); } TempVars vars = TempVars.get(); boolean intersects = light.intersectsFrustum(cam,vars); vars.release(); return intersects; }