use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestSSAO2 method simpleInitApp.
@Override
public void simpleInitApp() {
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
rootNode.addLight(dl);
flyCam.setDragToRotate(true);
setPauseOnLostFocus(false);
getStateManager().attach(new DetailedProfilerState());
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setFloat("Shininess", 16f);
//mat.setBoolean("VertexLighting", true);
Geometry floor = new Geometry("floor", new Box(1000, 0.1f, 1000));
floor.setMaterial(mat);
rootNode.attachChild(floor);
Node teapotNode = (Node) assetManager.loadModel("Models/Teapot/Teapot.mesh.xml");
Geometry teapot = (Geometry) teapotNode.getChild(0);
teapot.setMaterial(mat);
//Material mat = new Material(assetManager, "Common/MatDefs/Misc/ShowNormals.j3md");
for (int f = 10; f > 3; f--) {
for (int y = -f; y < f; y++) {
for (int x = -f; x < f; x++) {
Geometry clonePot = teapot.clone();
//clonePot.setMaterial(mat);
clonePot.setLocalTranslation(x * .5f, 10 - f, y * .5f);
clonePot.setLocalScale(.15f);
rootNode.attachChild(clonePot);
}
}
}
cam.setLocation(new Vector3f(10.247649f, 8.275992f, 10.405156f));
cam.setRotation(new Quaternion(-0.083419204f, 0.90370524f, -0.20599906f, -0.36595422f));
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
SSAOFilter ssaoFilter = new SSAOFilter(2.9299974f, 25f, 5.8100376f, 0.091000035f);
int numSamples = context.getSettings().getSamples();
if (numSamples > 0) {
fpp.setNumSamples(numSamples);
}
//ssaoFilter.setApproximateNormals(true);
fpp.addFilter(ssaoFilter);
SSAOUI ui = new SSAOUI(inputManager, ssaoFilter);
viewPort.addProcessor(fpp);
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class SSAOUI method init.
private void init(InputManager inputManager) {
System.out.println("----------------- SSAO UI Debugger --------------------");
System.out.println("-- Sample Radius : press Y to increase, H to decrease");
System.out.println("-- AO Intensity : press U to increase, J to decrease");
System.out.println("-- AO scale : press I to increase, K to decrease");
System.out.println("-- AO bias : press O to increase, P to decrease");
System.out.println("-- Toggle AO on/off : press space bar");
System.out.println("-- Use only AO : press Num pad 0");
System.out.println("-- Output config declaration : press P");
System.out.println("-------------------------------------------------------");
inputManager.addMapping("sampleRadiusUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("sampleRadiusDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("intensityUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("intensityDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("scaleUp", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("scaleDown", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("biasUp", new KeyTrigger(KeyInput.KEY_O));
inputManager.addMapping("biasDown", new KeyTrigger(KeyInput.KEY_L));
inputManager.addMapping("outputConfig", new KeyTrigger(KeyInput.KEY_P));
inputManager.addMapping("toggleUseAO", new KeyTrigger(KeyInput.KEY_SPACE));
inputManager.addMapping("toggleUseOnlyAo", new KeyTrigger(KeyInput.KEY_NUMPAD0));
inputManager.addMapping("toggleApprox", new KeyTrigger(KeyInput.KEY_NUMPAD5));
ActionListener acl = new ActionListener() {
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggleUseAO") && keyPressed) {
filter.setEnabled(!filter.isEnabled());
// filter.setUseAo(!filter.isUseAo());
System.out.println("use AO : " + filter.isEnabled());
}
if (name.equals("toggleApprox") && keyPressed) {
filter.setApproximateNormals(!filter.isApproximateNormals());
System.out.println("Approximate Normals : " + filter.isApproximateNormals());
}
if (name.equals("toggleUseOnlyAo") && keyPressed) {
filter.setUseOnlyAo(!filter.isUseOnlyAo());
System.out.println("use Only AO : " + filter.isUseOnlyAo());
}
if (name.equals("outputConfig") && keyPressed) {
System.out.println("new SSAOFilter(" + filter.getSampleRadius() + "f," + filter.getIntensity() + "f," + filter.getScale() + "f," + filter.getBias() + "f);");
}
}
};
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("sampleRadiusUp")) {
filter.setSampleRadius(filter.getSampleRadius() + 0.01f);
System.out.println("Sample Radius : " + filter.getSampleRadius());
}
if (name.equals("sampleRadiusDown")) {
filter.setSampleRadius(filter.getSampleRadius() - 0.01f);
System.out.println("Sample Radius : " + filter.getSampleRadius());
}
if (name.equals("intensityUp")) {
filter.setIntensity(filter.getIntensity() + 0.01f);
System.out.println("Intensity : " + filter.getIntensity());
}
if (name.equals("intensityDown")) {
filter.setIntensity(filter.getIntensity() - 0.01f);
System.out.println("Intensity : " + filter.getIntensity());
}
if (name.equals("scaleUp")) {
filter.setScale(filter.getScale() + 0.01f);
System.out.println("scale : " + filter.getScale());
}
if (name.equals("scaleDown")) {
filter.setScale(filter.getScale() - 0.01f);
System.out.println("scale : " + filter.getScale());
}
if (name.equals("biasUp")) {
filter.setBias(filter.getBias() + 0.001f);
System.out.println("bias : " + filter.getBias());
}
if (name.equals("biasDown")) {
filter.setBias(filter.getBias() - 0.001f);
System.out.println("bias : " + filter.getBias());
}
}
};
inputManager.addListener(acl, "toggleUseAO", "toggleApprox", "toggleUseOnlyAo", "outputConfig");
inputManager.addListener(anl, "sampleRadiusUp", "sampleRadiusDown", "intensityUp", "intensityDown", "scaleUp", "scaleDown", "biasUp", "biasDown");
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestBloom method simpleInitApp.
@Override
public void simpleInitApp() {
// put the camera in a bad position
cam.setLocation(new Vector3f(-2.336393f, 11.91392f, -7.139601f));
cam.setRotation(new Quaternion(0.23602544f, 0.11321983f, -0.027698677f, 0.96473104f));
//cam.setFrustumFar(1000);
Material mat = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
mat.setFloat("Shininess", 15f);
mat.setBoolean("UseMaterialColors", true);
mat.setColor("Ambient", ColorRGBA.Yellow.mult(0.2f));
mat.setColor("Diffuse", ColorRGBA.Yellow.mult(0.2f));
mat.setColor("Specular", ColorRGBA.Yellow.mult(0.8f));
Material matSoil = new Material(assetManager, "Common/MatDefs/Light/Lighting.j3md");
matSoil.setFloat("Shininess", 15f);
matSoil.setBoolean("UseMaterialColors", true);
matSoil.setColor("Ambient", ColorRGBA.Gray);
matSoil.setColor("Diffuse", ColorRGBA.Black);
matSoil.setColor("Specular", ColorRGBA.Gray);
teapot = assetManager.loadModel("Models/Teapot/Teapot.obj");
teapot.setLocalTranslation(0, 0, 10);
teapot.setMaterial(mat);
teapot.setShadowMode(ShadowMode.CastAndReceive);
teapot.setLocalScale(10.0f);
rootNode.attachChild(teapot);
Geometry soil = new Geometry("soil", new Box(800, 10, 700));
soil.setLocalTranslation(0, -13, 550);
soil.setMaterial(matSoil);
soil.setShadowMode(ShadowMode.CastAndReceive);
rootNode.attachChild(soil);
DirectionalLight light = new DirectionalLight();
light.setDirection(new Vector3f(-1, -1, -1).normalizeLocal());
light.setColor(ColorRGBA.White.mult(1.5f));
rootNode.addLight(light);
// load sky
Spatial sky = SkyFactory.createSky(assetManager, "Textures/Sky/Bright/FullskiesBlueClear03.dds", false);
sky.setCullHint(Spatial.CullHint.Never);
rootNode.attachChild(sky);
fpp = new FilterPostProcessor(assetManager);
// fpp.setNumSamples(4);
int numSamples = getContext().getSettings().getSamples();
if (numSamples > 0) {
fpp.setNumSamples(numSamples);
}
BloomFilter bloom = new BloomFilter();
bloom.setDownSamplingFactor(2);
bloom.setBlurScale(1.37f);
bloom.setExposurePower(3.30f);
bloom.setExposureCutOff(0.2f);
bloom.setBloomIntensity(2.45f);
BloomUI ui = new BloomUI(inputManager, bloom);
viewPort.addProcessor(fpp);
fpp.addFilter(bloom);
initInputs();
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestNiftyGui method simpleInitApp.
@Override
public void simpleInitApp() {
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", assetManager.loadTexture("Interface/Logo/Monkey.jpg"));
geom.setMaterial(mat);
rootNode.attachChild(geom);
NiftyJmeDisplay niftyDisplay = NiftyJmeDisplay.newNiftyJmeDisplay(assetManager, inputManager, audioRenderer, guiViewPort);
nifty = niftyDisplay.getNifty();
nifty.fromXml("Interface/Nifty/HelloJme.xml", "start", this);
// attach the nifty display to the gui view port as a processor
guiViewPort.addProcessor(niftyDisplay);
// disable the fly cam
// flyCam.setEnabled(false);
// flyCam.setDragToRotate(true);
inputManager.setCursorVisible(true);
}
use of com.jme3.input.InputManager in project jmonkeyengine by jMonkeyEngine.
the class TestNiftyToMesh method simpleInitApp.
public void simpleInitApp() {
ViewPort niftyView = renderManager.createPreView("NiftyView", new Camera(1024, 768));
niftyView.setClearFlags(true, true, true);
NiftyJmeDisplay niftyDisplay = new NiftyJmeDisplay(assetManager, inputManager, audioRenderer, niftyView);
nifty = niftyDisplay.getNifty();
nifty.fromXml("all/intro.xml", "start");
niftyView.addProcessor(niftyDisplay);
Texture2D depthTex = new Texture2D(1024, 768, Format.Depth);
FrameBuffer fb = new FrameBuffer(1024, 768, 1);
fb.setDepthTexture(depthTex);
Texture2D tex = new Texture2D(1024, 768, Format.RGBA8);
tex.setMinFilter(MinFilter.Trilinear);
tex.setMagFilter(MagFilter.Bilinear);
fb.setColorTexture(tex);
niftyView.setClearFlags(true, true, true);
niftyView.setOutputFrameBuffer(fb);
Box b = new Box(1, 1, 1);
Geometry geom = new Geometry("Box", b);
Material mat = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
mat.setTexture("ColorMap", tex);
geom.setMaterial(mat);
rootNode.attachChild(geom);
}
Aggregations