use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method addGeometriesInCamFrustumAndViewPortFromNode.
/**
* Helper function to recursively collect the geometries for getLitGeometriesInViewPort function.
*
* @param vpCamera the viewPort camera
* @param cameras the camera array to check geometries against, representing the light viewspace
* @param scene the Node to traverse or geometry to possibly add
* @param outputGeometryList the output list of all geometries that are in the camera frustum
*/
private static void addGeometriesInCamFrustumAndViewPortFromNode(Camera vpCamera, Camera[] cameras, Spatial scene, RenderQueue.ShadowMode mode, GeometryList outputGeometryList) {
if (scene.getCullHint() == Spatial.CullHint.Always)
return;
boolean inFrustum = false;
for (int j = 0; j < cameras.length && inFrustum == false; j++) {
Camera camera = cameras[j];
int planeState = camera.getPlaneState();
camera.setPlaneState(0);
inFrustum = camera.contains(scene.getWorldBound()) != Camera.FrustumIntersect.Outside && scene.checkCulling(vpCamera);
camera.setPlaneState(planeState);
}
if (inFrustum) {
if (scene instanceof Node) {
Node node = (Node) scene;
for (Spatial child : node.getChildren()) {
addGeometriesInCamFrustumAndViewPortFromNode(vpCamera, cameras, child, mode, outputGeometryList);
}
} else if (scene instanceof Geometry) {
if (checkShadowMode(scene.getShadowMode(), mode) && !((Geometry) scene).isGrouped()) {
outputGeometryList.add((Geometry) scene);
}
}
}
}
use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.
the class DirectionalLightShadowRenderer method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
lambda = ic.readFloat("lambda", 0.65f);
zFarOverride = ic.readInt("zFarOverride", 0);
light = (DirectionalLight) ic.readSavable("light", null);
fadeInfo = (Vector2f) ic.readSavable("fadeInfo", null);
fadeLength = ic.readFloat("fadeLength", 0f);
init(nbShadowMaps, (int) shadowMapSize);
}
use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.
the class PointLightShadowRenderer method write.
@Override
public void write(JmeExporter ex) throws IOException {
super.write(ex);
OutputCapsule oc = ex.getCapsule(this);
oc.write(light, "light", null);
}
use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.
the class PointLightShadowRenderer method read.
@Override
public void read(JmeImporter im) throws IOException {
super.read(im);
InputCapsule ic = im.getCapsule(this);
light = (PointLight) ic.readSavable("light", null);
init((int) shadowMapSize);
}
use of com.jme3.light.Light in project jmonkeyengine by jMonkeyEngine.
the class PointLightShadowRenderer method checkCulling.
/**
*
* @param viewCam
* @return
*/
@Override
protected boolean checkCulling(Camera viewCam) {
if (light == null) {
return false;
}
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;
}
Aggregations