/**
*
*/
package net.cis.client.game;
import net.cis.client.game.scenery.factory.SkyBoxFactory;
import com.jme3.app.SimpleApplication;
import com.jme3.light.DirectionalLight;
import com.jme3.material.Material;
import com.jme3.math.ColorRGBA;
import com.jme3.math.Plane;
import com.jme3.math.Vector3f;
import com.jme3.post.FilterPostProcessor;
import com.jme3.post.filters.BloomFilter;
import com.jme3.renderer.queue.RenderQueue.ShadowMode;
import com.jme3.scene.Node;
import com.jme3.scene.Spatial;
import com.jme3.water.SimpleWaterProcessor;
/**
* @author Matze
*
*/
public class TestStarGate extends SimpleApplication {
SimpleWaterProcessor waterProcessor;
private Vector3f lightPos = new Vector3f(33, 12, -29);
/*
* (non-Javadoc)
*
* @see com.jme3.app.SimpleApplication#simpleInitApp()
*/
@Override
public void simpleInitApp() {
initializeScenery();
}
private void initializeScenery() {
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
BloomFilter bloom = new BloomFilter(BloomFilter.GlowMode.Objects);
fpp.addFilter(bloom);
viewPort.addProcessor(fpp);
// Skybox
rootNode.attachChild(SkyBoxFactory.createSimpleSkyBox(assetManager));
// create processor
waterProcessor = new SimpleWaterProcessor(assetManager);
waterProcessor.setReflectionScene(rootNode);
// waterProcessor.setDebug(false);
// waterProcessor.setLightPosition(new Vector3f(-0.1f, -0.7f, -1.0f));
initStarGate();
viewPort.addProcessor(waterProcessor);
// Light
DirectionalLight sun = new DirectionalLight();
sun.setDirection(new Vector3f(-0.1f, -0.7f, -1.0f));
sun.setColor(ColorRGBA.White.clone().multLocal(2));
rootNode.addLight(sun);
}
private void initStarGate() {
Vector3f waterLocation = new Vector3f(0, -6, 0);
waterProcessor.setPlane(new Plane(Vector3f.UNIT_Y, waterLocation.dot(Vector3f.UNIT_Y)));
Node ship = new Node("Carrier");
Spatial center = assetManager.loadModel("spaceobject/gates/stargate/center.mesh.xml");
center.setShadowMode(ShadowMode.Receive);
center.setMaterial(waterProcessor.getMaterial());
Spatial gate = assetManager.loadModel("spaceobject/gates/stargate/gate.mesh.xml");
Material mat_wall = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat_wall.setTexture("DiffuseMap", assetManager.loadTexture("spaceobject/gates/stargate/gate_blue.png"));
mat_wall.setTexture("GlowMap", assetManager.loadTexture("spaceobject/gates/stargate/gate_blue_glow.png"));
gate.setMaterial(mat_wall);
ship.attachChild(center);
ship.attachChild(gate);
rootNode.attachChild(ship);
// // Cylinder quad = new Cylinder(10, 10, 10f, 3f);
// Quad quad = new Quad(10f, 10f);
// Quad background = new Quad(10f, 10f);
//
// // the texture coordinates define the general size of the waves
// quad.scaleTextureCoordinates(new Vector2f(0.5f, 0.5f));
// Geometry backgroundGeo = new Geometry("background", background);
// Material mat = new Material(assetManager,
// "Common/MatDefs/Misc/Unshaded.j3md");
// mat.setColor("Color", ColorRGBA.Blue); // set color of material to
// blue
// backgroundGeo.setMaterial(mat);
// backgroundGeo.setLocalTranslation(0, -10, -0.1f);
// rootNode.attachChild(backgroundGeo);
// Geometry water = new Geometry("water", quad);
// water.setShadowMode(ShadowMode.Receive);
// water.setMaterial(waterProcessor.getMaterial());
// water.setLocalTranslation(0, -10, 0);
// rootNode.attachChild(water);
}
public static void main(String[] args) {
new TestStarGate().start();
}
}