use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method getGeometriesInLightRadius.
/**
* Populates the outputGeometryList with the geometry of the
* inputGeomtryList that are in the radius of a light.
* The array of camera must be an array of 6 cameras initialized so they represent the light viewspace of a pointlight
*
* @param inputGeometryList The list containing all geometry to check
* against the camera frustum
* @param cameras the camera array to check geometries against
* @param outputGeometryList the list of all geometries that are in the
* camera frustum
*/
public static void getGeometriesInLightRadius(GeometryList inputGeometryList, Camera[] cameras, GeometryList outputGeometryList) {
for (int i = 0; i < inputGeometryList.size(); i++) {
Geometry g = inputGeometryList.get(i);
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(g.getWorldBound()) != Camera.FrustumIntersect.Outside;
camera.setPlaneState(planeState);
}
if (inFrustum) {
outputGeometryList.add(g);
}
}
}
use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeUnionBound.
/**
* Compute bounds of a geomList
* @param list
* @param mat
* @return
*/
public static BoundingBox computeUnionBound(GeometryList list, Matrix4f mat) {
BoundingBox bbox = new BoundingBox();
TempVars tempv = TempVars.get();
for (int i = 0; i < list.size(); i++) {
BoundingVolume vol = list.get(i).getWorldBound();
BoundingVolume store = vol.transform(mat, tempv.bbox);
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(store.getCenter().x) && !Float.isInfinite(store.getCenter().x)) {
bbox.mergeLocal(store);
}
}
tempv.release();
return bbox;
}
use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.
the class ShadowUtil method computeUnionBound.
/**
* Compute bounds of a geomList
* @param list
* @param transform
* @return
*/
public static BoundingBox computeUnionBound(GeometryList list, Transform transform) {
BoundingBox bbox = new BoundingBox();
TempVars tempv = TempVars.get();
for (int i = 0; i < list.size(); i++) {
BoundingVolume vol = list.get(i).getWorldBound();
BoundingVolume newVol = vol.transform(transform, tempv.bbox);
//Nehon : prevent NaN and infinity values to screw the final bounding box
if (!Float.isNaN(newVol.getCenter().x) && !Float.isInfinite(newVol.getCenter().x)) {
bbox.mergeLocal(newVol);
}
}
tempv.release();
return bbox;
}
use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.
the class AbstractShadowRendererVR method setMatParams.
private void setMatParams(GeometryList l) {
//iteration throught all the geometries of the list to gather the materials
buildMatCache(l);
//iterating through the mat cache and setting the parameters
for (Material mat : matCache) {
mat.setFloat("ShadowMapSize", shadowMapSize);
for (int j = 0; j < nbShadowMaps; j++) {
mat.setMatrix4(lightViewStringCache[j], lightViewProjectionsMatrices[j]);
}
for (int j = 0; j < nbShadowMaps; j++) {
mat.setTexture(shadowMapStringCache[j], shadowMaps[j]);
}
mat.setBoolean("HardwareShadows", shadowCompareMode == CompareMode.Hardware);
mat.setInt("FilterMode", edgeFilteringMode.getMaterialParamValue());
mat.setFloat("PCFEdge", edgesThickness);
mat.setFloat("ShadowIntensity", shadowIntensity);
if (fadeInfo != null) {
mat.setVector2("FadeInfo", fadeInfo);
}
if (renderBackFacesShadows != null) {
mat.setBoolean("BackfaceShadows", renderBackFacesShadows);
}
setMaterialParameters(mat);
}
//so we fall back to the forced material solution (transparent shadows won't be supported for these objects)
if (needsfallBackMaterial) {
setPostShadowParams();
}
}
use of com.jme3.renderer.queue.GeometryList in project jmonkeyengine by jMonkeyEngine.
the class DirectionalLightShadowRendererVR method getOccludersToRender.
@Override
protected GeometryList getOccludersToRender(int shadowMapIndex, GeometryList shadowMapOccluders) {
// update frustum points based on current camera and split
ShadowUtil.updateFrustumPoints(viewPort.getCamera(), splitsArray[shadowMapIndex], splitsArray[shadowMapIndex + 1], 1.0f, points);
//Updating shadow cam with curent split frustra
if (lightReceivers.size() == 0) {
for (Spatial scene : viewPort.getScenes()) {
ShadowUtil.getGeometriesInCamFrustum(scene, viewPort.getCamera(), RenderQueue.ShadowMode.Receive, lightReceivers);
}
}
ShadowUtil.updateShadowCamera(viewPort, lightReceivers, shadowCam, points, shadowMapOccluders, stabilize ? shadowMapSize : 0);
return shadowMapOccluders;
}
Aggregations