|
@@ -62,10 +62,13 @@ import com.jme3.texture.Texture.MinFilter;
|
|
import com.jme3.texture.Texture.ShadowCompareMode;
|
|
import com.jme3.texture.Texture.ShadowCompareMode;
|
|
import com.jme3.texture.Texture2D;
|
|
import com.jme3.texture.Texture2D;
|
|
import com.jme3.ui.Picture;
|
|
import com.jme3.ui.Picture;
|
|
|
|
+import com.jme3.util.clone.Cloner;
|
|
|
|
+import com.jme3.util.clone.JmeCloneable;
|
|
|
|
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
|
+import java.util.logging.Logger;
|
|
|
|
|
|
/**
|
|
/**
|
|
* abstract shadow renderer that holds commons feature to have for a shadow
|
|
* abstract shadow renderer that holds commons feature to have for a shadow
|
|
@@ -73,7 +76,9 @@ import java.util.List;
|
|
*
|
|
*
|
|
* @author Rémy Bouquet aka Nehon
|
|
* @author Rémy Bouquet aka Nehon
|
|
*/
|
|
*/
|
|
-public abstract class AbstractShadowRenderer implements SceneProcessor, Savable {
|
|
|
|
|
|
+public abstract class AbstractShadowRenderer implements SceneProcessor, Savable, JmeCloneable, Cloneable {
|
|
|
|
+
|
|
|
|
+ protected static final Logger logger = Logger.getLogger(AbstractShadowRenderer.class.getName());
|
|
|
|
|
|
protected int nbShadowMaps = 1;
|
|
protected int nbShadowMaps = 1;
|
|
protected float shadowMapSize;
|
|
protected float shadowMapSize;
|
|
@@ -147,7 +152,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
- protected void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) {
|
|
|
|
|
|
+ private void init(AssetManager assetManager, int nbShadowMaps, int shadowMapSize) {
|
|
this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md");
|
|
this.postshadowMat = new Material(assetManager, "Common/MatDefs/Shadow/PostShadow.j3md");
|
|
shadowFB = new FrameBuffer[nbShadowMaps];
|
|
shadowFB = new FrameBuffer[nbShadowMaps];
|
|
shadowMaps = new Texture2D[nbShadowMaps];
|
|
shadowMaps = new Texture2D[nbShadowMaps];
|
|
@@ -677,8 +682,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|
}
|
|
}
|
|
|
|
|
|
/**
|
|
/**
|
|
- * returns true if the light source bounding box is in the view frustum
|
|
|
|
- * @return
|
|
|
|
|
|
+ * @return true if the light source bounding box is in the view frustum
|
|
*/
|
|
*/
|
|
protected abstract boolean checkCulling(Camera viewCam);
|
|
protected abstract boolean checkCulling(Camera viewCam);
|
|
|
|
|
|
@@ -747,7 +751,6 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|
@Deprecated
|
|
@Deprecated
|
|
public void setFlushQueues(boolean flushQueues) {}
|
|
public void setFlushQueues(boolean flushQueues) {}
|
|
|
|
|
|
-
|
|
|
|
/**
|
|
/**
|
|
* returns the pre shadows pass render state.
|
|
* returns the pre shadows pass render state.
|
|
* use it to adjust the RenderState parameters of the pre shadow pass.
|
|
* use it to adjust the RenderState parameters of the pre shadow pass.
|
|
@@ -789,13 +792,28 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|
return renderBackFacesShadows != null?renderBackFacesShadows:false;
|
|
return renderBackFacesShadows != null?renderBackFacesShadows:false;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ @Override
|
|
|
|
+ public Object jmeClone() {
|
|
|
|
+ try {
|
|
|
|
+ return super.clone();
|
|
|
|
+ } catch (final CloneNotSupportedException e) {
|
|
|
|
+ throw new RuntimeException(e);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void cloneFields(final Cloner cloner, final Object original) {
|
|
|
|
+ forcedRenderState = cloner.clone(forcedRenderState);
|
|
|
|
+ init(assetManager, nbShadowMaps, (int) shadowMapSize);
|
|
|
|
+ }
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* De-serialize this instance, for example when loading from a J3O file.
|
|
* De-serialize this instance, for example when loading from a J3O file.
|
|
*
|
|
*
|
|
* @param im importer (not null)
|
|
* @param im importer (not null)
|
|
*/
|
|
*/
|
|
public void read(JmeImporter im) throws IOException {
|
|
public void read(JmeImporter im) throws IOException {
|
|
- InputCapsule ic = (InputCapsule) im.getCapsule(this);
|
|
|
|
|
|
+ InputCapsule ic = im.getCapsule(this);
|
|
assetManager = im.getAssetManager();
|
|
assetManager = im.getAssetManager();
|
|
nbShadowMaps = ic.readInt("nbShadowMaps", 1);
|
|
nbShadowMaps = ic.readInt("nbShadowMaps", 1);
|
|
shadowMapSize = ic.readFloat("shadowMapSize", 0f);
|
|
shadowMapSize = ic.readFloat("shadowMapSize", 0f);
|
|
@@ -814,7 +832,7 @@ public abstract class AbstractShadowRenderer implements SceneProcessor, Savable
|
|
* @param ex exporter (not null)
|
|
* @param ex exporter (not null)
|
|
*/
|
|
*/
|
|
public void write(JmeExporter ex) throws IOException {
|
|
public void write(JmeExporter ex) throws IOException {
|
|
- OutputCapsule oc = (OutputCapsule) ex.getCapsule(this);
|
|
|
|
|
|
+ OutputCapsule oc = ex.getCapsule(this);
|
|
oc.write(nbShadowMaps, "nbShadowMaps", 1);
|
|
oc.write(nbShadowMaps, "nbShadowMaps", 1);
|
|
oc.write(shadowMapSize, "shadowMapSize", 0);
|
|
oc.write(shadowMapSize, "shadowMapSize", 0);
|
|
oc.write(shadowIntensity, "shadowIntensity", 0.7f);
|
|
oc.write(shadowIntensity, "shadowIntensity", 0.7f);
|