use of com.jme3.water.WaterFilter in project jmonkeyengine by jMonkeyEngine.
the class TestPostWaterLake method simpleInitApp.
public void simpleInitApp() {
this.flyCam.setMoveSpeed(10);
cam.setLocation(new Vector3f(-27.0f, 1.0f, 75.0f));
// cam.setRotation(new Quaternion(0.03f, 0.9f, 0f, 0.4f));
// load sky
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
File file = new File("wildhouse.zip");
if (file.exists()) {
useHttp = false;
}
// load the level from zip or http zip
if (useHttp) {
assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class);
} else {
assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
}
Spatial scene = assetManager.loadModel("main.scene");
rootNode.attachChild(scene);
DirectionalLight sun = new DirectionalLight();
Vector3f lightDir = new Vector3f(-0.37352666f, -0.50444174f, -0.7784704f);
sun.setDirection(lightDir);
sun.setColor(ColorRGBA.White.clone().multLocal(2));
scene.addLight(sun);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
final WaterFilter water = new WaterFilter(rootNode, lightDir);
water.setWaterHeight(-20);
water.setUseFoam(false);
water.setUseRipples(false);
water.setDeepWaterColor(ColorRGBA.Brown);
water.setWaterColor(ColorRGBA.Brown.mult(2.0f));
water.setWaterTransparency(0.2f);
water.setMaxAmplitude(0.3f);
water.setWaveScale(0.008f);
water.setSpeed(0.7f);
water.setShoreHardness(1.0f);
water.setRefractionConstant(0.2f);
water.setShininess(0.3f);
water.setSunScale(1.0f);
water.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
fpp.addFilter(water);
viewPort.addProcessor(fpp);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) {
if (water.isUseHQShoreline()) {
water.setUseHQShoreline(false);
} else {
water.setUseHQShoreline(true);
}
}
}
}, "HQ");
inputManager.addMapping("HQ", new KeyTrigger(keyInput.KEY_SPACE));
}
use of com.jme3.water.WaterFilter in project jmonkeyengine by jMonkeyEngine.
the class TestMultiViewsFilters method simpleInitApp.
public void simpleInitApp() {
// create the geometry and attach it
Geometry teaGeom = (Geometry) assetManager.loadModel("Models/Teapot/Teapot.obj");
teaGeom.scale(3);
teaGeom.getMaterial().setColor("GlowColor", ColorRGBA.Green);
DirectionalLight dl = new DirectionalLight();
dl.setColor(ColorRGBA.White);
dl.setDirection(Vector3f.UNIT_XYZ.negate());
rootNode.addLight(dl);
rootNode.attachChild(teaGeom);
// Setup first view
cam.setViewPort(.5f, 1f, 0f, 0.5f);
cam.setLocation(new Vector3f(3.3212643f, 4.484704f, 4.2812433f));
cam.setRotation(new Quaternion(-0.07680723f, 0.92299235f, -0.2564353f, -0.27645364f));
// Setup second view
Camera cam2 = cam.clone();
cam2.setViewPort(0f, 0.5f, 0f, 0.5f);
cam2.setLocation(new Vector3f(-0.10947256f, 1.5760219f, 4.81758f));
cam2.setRotation(new Quaternion(0.0010108891f, 0.99857414f, -0.04928594f, 0.020481428f));
final ViewPort view2 = renderManager.createMainView("Bottom Left", cam2);
view2.setClearFlags(true, true, true);
view2.attachScene(rootNode);
// Setup third view
Camera cam3 = cam.clone();
cam3.setName("cam3");
cam3.setViewPort(0f, .5f, .5f, 1f);
cam3.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
cam3.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));
final ViewPort view3 = renderManager.createMainView("Top Left", cam3);
view3.setClearFlags(true, true, true);
view3.attachScene(rootNode);
// Setup fourth view
Camera cam4 = cam.clone();
cam4.setName("cam4");
cam4.setViewPort(.5f, 1f, .5f, 1f);
cam4.setLocation(new Vector3f(4.775564f, 1.4548365f, 0.11491505f));
cam4.setRotation(new Quaternion(0.02356979f, -0.74957186f, 0.026729556f, 0.66096294f));
final ViewPort view4 = renderManager.createMainView("Top Right", cam4);
view4.setClearFlags(true, true, true);
view4.attachScene(rootNode);
// Camera cam5 = new Camera(200, 200);
// cam5.setFrustumPerspective(45f, (float)cam.getWidth() / cam.getHeight(), 1f, 1000f);
// cam5.setName("cam5");
// cam5.setViewPort(5.23f, 6.33f, 0.56f, 1.66f);
// this.setViewPortAreas(5.23f, 6.33f, 0.56f, 1.66f);
// this.setViewPortCamSize(200, 200);
// 1046,1266,112,332
Camera cam5 = cam.clone();
cam5.setName("cam5");
cam5.setViewPort(1046f / settings.getWidth(), 1266f / settings.getWidth(), 112f / settings.getHeight(), 332f / settings.getHeight());
cam5.setLocation(new Vector3f(0.2846221f, 6.4271426f, 0.23380789f));
cam5.setRotation(new Quaternion(0.004381671f, 0.72363687f, -0.69015175f, 0.0045953835f));
final ViewPort view5 = renderManager.createMainView("center", cam5);
view5.setClearFlags(true, true, true);
view5.attachScene(rootNode);
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
final FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
final FilterPostProcessor fpp2 = new FilterPostProcessor(assetManager);
final FilterPostProcessor fpp3 = new FilterPostProcessor(assetManager);
final FilterPostProcessor fpp4 = new FilterPostProcessor(assetManager);
final FilterPostProcessor fpp5 = new FilterPostProcessor(assetManager);
// fpp.addFilter(new WaterFilter(rootNode, Vector3f.UNIT_Y.mult(-1)));
fpp3.addFilter(new CartoonEdgeFilter());
fpp2.addFilter(new CrossHatchFilter());
final FogFilter ff = new FogFilter(ColorRGBA.Yellow, 0.7f, 2);
fpp.addFilter(ff);
final RadialBlurFilter rbf = new RadialBlurFilter(1, 10);
// rbf.setEnabled(false);
fpp.addFilter(rbf);
SSAOFilter f = new SSAOFilter(1.8899765f, 20.490374f, 0.4699998f, 0.1f);
;
fpp4.addFilter(f);
SSAOUI ui = new SSAOUI(inputManager, f);
fpp5.addFilter(new BloomFilter(BloomFilter.GlowMode.Objects));
viewPort.addProcessor(fpp);
view2.addProcessor(fpp2);
view3.addProcessor(fpp3);
view4.addProcessor(fpp4);
view5.addProcessor(fpp5);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (name.equals("press") && isPressed) {
if (filterEnabled) {
viewPort.removeProcessor(fpp);
view2.removeProcessor(fpp2);
view3.removeProcessor(fpp3);
view4.removeProcessor(fpp4);
view5.removeProcessor(fpp5);
} else {
viewPort.addProcessor(fpp);
view2.addProcessor(fpp2);
view3.addProcessor(fpp3);
view4.addProcessor(fpp4);
view5.addProcessor(fpp5);
}
filterEnabled = !filterEnabled;
}
if (name.equals("filter") && isPressed) {
ff.setEnabled(!ff.isEnabled());
rbf.setEnabled(!rbf.isEnabled());
}
}
}, "press", "filter");
inputManager.addMapping("press", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("filter", new KeyTrigger(KeyInput.KEY_F));
}
use of com.jme3.water.WaterFilter in project jmonkeyengine by jMonkeyEngine.
the class TestMultiplesFilters method simpleInitApp.
public void simpleInitApp() {
this.flyCam.setMoveSpeed(10);
cam.setLocation(new Vector3f(6.0344796f, 1.5054002f, 55.572033f));
cam.setRotation(new Quaternion(0.0016069f, 0.9810479f, -0.008143323f, 0.19358753f));
// load sky
rootNode.attachChild(SkyFactory.createSky(assetManager, "Textures/Sky/Bright/BrightSky.dds", false));
// load the level from zip or http zip
if (useHttp) {
assetManager.registerLocator("http://jmonkeyengine.googlecode.com/files/wildhouse.zip", HttpZipLocator.class);
} else {
assetManager.registerLocator("wildhouse.zip", ZipLocator.class);
}
Spatial scene = assetManager.loadModel("main.scene");
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));
sun.setColor(ColorRGBA.White.clone().multLocal(2));
scene.addLight(sun);
fpp = new FilterPostProcessor(assetManager);
// fpp.setNumSamples(4);
ssaoFilter = new SSAOFilter(0.92f, 2.2f, 0.46f, 0.2f);
final WaterFilter water = new WaterFilter(rootNode, new Vector3f(-0.4790551f, -0.39247334f, -0.7851566f));
water.setWaterHeight(-20);
SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
final BloomFilter bloom = new BloomFilter();
final ColorOverlayFilter overlay = new ColorOverlayFilter(ColorRGBA.LightGray);
fpp.addFilter(ssaoFilter);
fpp.addFilter(water);
fpp.addFilter(bloom);
fpp.addFilter(overlay);
viewPort.addProcessor(fpp);
rootNode.attachChild(scene);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if ("toggleSSAO".equals(name) && isPressed) {
if (ssaoFilter.isEnabled()) {
ssaoFilter.setEnabled(false);
} else {
ssaoFilter.setEnabled(true);
}
}
if ("toggleWater".equals(name) && isPressed) {
if (water.isEnabled()) {
water.setEnabled(false);
} else {
water.setEnabled(true);
}
}
if ("toggleBloom".equals(name) && isPressed) {
if (bloom.isEnabled()) {
bloom.setEnabled(false);
} else {
bloom.setEnabled(true);
}
}
if ("toggleOverlay".equals(name) && isPressed) {
if (overlay.isEnabled()) {
overlay.setEnabled(false);
} else {
overlay.setEnabled(true);
}
}
}
}, "toggleSSAO", "toggleBloom", "toggleWater", "toggleOverlay");
inputManager.addMapping("toggleSSAO", new KeyTrigger(KeyInput.KEY_1));
inputManager.addMapping("toggleWater", new KeyTrigger(KeyInput.KEY_2));
inputManager.addMapping("toggleBloom", new KeyTrigger(KeyInput.KEY_3));
inputManager.addMapping("toggleOverlay", new KeyTrigger(KeyInput.KEY_4));
}
use of com.jme3.water.WaterFilter in project jmonkeyengine by jMonkeyEngine.
the class TestMultiPostWater method simpleInitApp.
@Override
public void simpleInitApp() {
// setDisplayFps(false);
// setDisplayStatView(false);
Node mainScene = new Node("Main Scene");
rootNode.attachChild(mainScene);
createTerrain(mainScene);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(lightDir);
sun.setColor(ColorRGBA.White.clone().multLocal(1.7f));
mainScene.addLight(sun);
flyCam.setMoveSpeed(100);
//cam.setLocation(new Vector3f(-700, 100, 300));
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
cam.setLocation(new Vector3f(-327.21957f, 251.6459f, 126.884346f));
cam.setRotation(new Quaternion().fromAngles(new float[] { FastMath.PI * 0.06f, FastMath.PI * 0.65f, 0 }));
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
sky.setLocalScale(350);
mainScene.attachChild(sky);
cam.setFrustumFar(4000);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
water = new WaterFilter(rootNode, lightDir);
water.setCenter(new Vector3f(9.628218f, -15.830074f, 199.23595f));
water.setRadius(260);
water.setWaveScale(0.003f);
water.setMaxAmplitude(2f);
water.setFoamExistence(new Vector3f(1f, 4, 0.5f));
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water.setRefractionStrength(0.2f);
water.setWaterHeight(WATER_HEIGHT);
fpp.addFilter(water);
WaterFilter water2 = new WaterFilter(rootNode, lightDir);
water2.setCenter(new Vector3f(-280.46027f, -24.971727f, -271.71976f));
water2.setRadius(260);
water2.setWaterHeight(WATER_HEIGHT);
water2.setUseFoam(false);
water2.setUseRipples(false);
water2.setDeepWaterColor(ColorRGBA.Brown);
water2.setWaterColor(ColorRGBA.Brown.mult(2.0f));
water2.setWaterTransparency(0.2f);
water2.setMaxAmplitude(0.3f);
water2.setWaveScale(0.008f);
water2.setSpeed(0.7f);
water2.setShoreHardness(1.0f);
water2.setRefractionConstant(0.2f);
water2.setShininess(0.3f);
water2.setSunScale(1.0f);
water2.setColorExtinction(new Vector3f(10.0f, 20.0f, 30.0f));
fpp.addFilter(water2);
WaterFilter water3 = new WaterFilter(rootNode, lightDir);
water3.setCenter(new Vector3f(319.6663f, -18.367947f, -236.67674f));
water3.setRadius(260);
water3.setWaterHeight(WATER_HEIGHT);
water3.setWaveScale(0.003f);
water3.setMaxAmplitude(2f);
water3.setFoamExistence(new Vector3f(1f, 4, 0.5f));
water3.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water3.setRefractionStrength(0.2f);
water3.setDeepWaterColor(ColorRGBA.Red);
water3.setWaterColor(ColorRGBA.Red.mult(2.0f));
water3.setLightColor(ColorRGBA.Red);
fpp.addFilter(water3);
viewPort.addProcessor(fpp);
//fpp.setNumSamples(4);
}
use of com.jme3.water.WaterFilter in project jmonkeyengine by jMonkeyEngine.
the class TestPostWater method simpleInitApp.
@Override
public void simpleInitApp() {
setDisplayFps(false);
setDisplayStatView(false);
Node mainScene = new Node("Main Scene");
rootNode.attachChild(mainScene);
createTerrain(mainScene);
DirectionalLight sun = new DirectionalLight();
sun.setDirection(lightDir);
sun.setColor(ColorRGBA.White.clone().multLocal(1f));
mainScene.addLight(sun);
AmbientLight al = new AmbientLight();
al.setColor(new ColorRGBA(0.1f, 0.1f, 0.1f, 1.0f));
mainScene.addLight(al);
flyCam.setMoveSpeed(50);
//cam.setLocation(new Vector3f(-700, 100, 300));
//cam.setRotation(new Quaternion().fromAngleAxis(0.5f, Vector3f.UNIT_Z));
// cam.setLocation(new Vector3f(-327.21957f, 61.6459f, 126.884346f));
// cam.setRotation(new Quaternion(0.052168474f, 0.9443102f, -0.18395276f, 0.2678024f));
cam.setLocation(new Vector3f(-370.31592f, 182.04016f, 196.81192f));
cam.setRotation(new Quaternion(0.015302252f, 0.9304095f, -0.039101653f, 0.3641086f));
Spatial sky = SkyFactory.createSky(assetManager, "Scenes/Beach/FullskiesSunset0068.dds", false);
sky.setLocalScale(350);
mainScene.attachChild(sky);
cam.setFrustumFar(4000);
//Water Filter
water = new WaterFilter(rootNode, lightDir);
water.setWaterColor(new ColorRGBA().setAsSrgb(0.0078f, 0.3176f, 0.5f, 1.0f));
water.setDeepWaterColor(new ColorRGBA().setAsSrgb(0.0039f, 0.00196f, 0.145f, 1.0f));
water.setUnderWaterFogDistance(80);
water.setWaterTransparency(0.12f);
water.setFoamIntensity(0.4f);
water.setFoamHardness(0.3f);
water.setFoamExistence(new Vector3f(0.8f, 8f, 1f));
water.setReflectionDisplace(50);
water.setRefractionConstant(0.25f);
water.setColorExtinction(new Vector3f(30, 50, 70));
water.setCausticsIntensity(0.4f);
water.setWaveScale(0.003f);
water.setMaxAmplitude(2f);
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
water.setRefractionStrength(0.2f);
water.setWaterHeight(initialWaterHeight);
//Bloom Filter
BloomFilter bloom = new BloomFilter();
bloom.setExposurePower(55);
bloom.setBloomIntensity(1.0f);
//Light Scattering Filter
LightScatteringFilter lsf = new LightScatteringFilter(lightDir.mult(-300));
lsf.setLightDensity(0.5f);
//Depth of field Filter
DepthOfFieldFilter dof = new DepthOfFieldFilter();
dof.setFocusDistance(0);
dof.setFocusRange(100);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
fpp.addFilter(water);
fpp.addFilter(bloom);
fpp.addFilter(dof);
fpp.addFilter(lsf);
fpp.addFilter(new FXAAFilter());
// fpp.addFilter(new TranslucentBucketFilter());
int numSamples = getContext().getSettings().getSamples();
if (numSamples > 0) {
fpp.setNumSamples(numSamples);
}
uw = cam.getLocation().y < waterHeight;
waves = new AudioNode(assetManager, "Sound/Environment/Ocean Waves.ogg", false);
waves.setLooping(true);
waves.setReverbEnabled(true);
if (uw) {
waves.setDryFilter(new LowPassFilter(0.5f, 0.1f));
} else {
waves.setDryFilter(aboveWaterAudioFilter);
}
audioRenderer.playSource(waves);
//
viewPort.addProcessor(fpp);
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed) {
if (name.equals("foam1")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam.jpg"));
}
if (name.equals("foam2")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam2.jpg"));
}
if (name.equals("foam3")) {
water.setFoamTexture((Texture2D) assetManager.loadTexture("Common/MatDefs/Water/Textures/foam3.jpg"));
}
if (name.equals("upRM")) {
water.setReflectionMapSize(Math.min(water.getReflectionMapSize() * 2, 4096));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
if (name.equals("downRM")) {
water.setReflectionMapSize(Math.max(water.getReflectionMapSize() / 2, 32));
System.out.println("Reflection map size : " + water.getReflectionMapSize());
}
}
}
}, "foam1", "foam2", "foam3", "upRM", "downRM");
inputManager.addMapping("foam1", new KeyTrigger(KeyInput.KEY_1));
inputManager.addMapping("foam2", new KeyTrigger(KeyInput.KEY_2));
inputManager.addMapping("foam3", new KeyTrigger(KeyInput.KEY_3));
inputManager.addMapping("upRM", new KeyTrigger(KeyInput.KEY_PGUP));
inputManager.addMapping("downRM", new KeyTrigger(KeyInput.KEY_PGDN));
// createBox();
// createFire();
}
Aggregations