use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestBloomAlphaThreshold method initInputs.
private void initInputs() {
inputManager.addMapping("toggle", new KeyTrigger(KeyInput.KEY_SPACE));
ActionListener acl = new ActionListener() {
@Override
public void onAction(String name, boolean keyPressed, float tpf) {
if (name.equals("toggle") && keyPressed) {
if (active) {
active = false;
viewPort.removeProcessor(fpp);
} else {
active = true;
viewPort.addProcessor(fpp);
}
}
}
};
inputManager.addListener(acl, "toggle");
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestHWSkinning method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
makeHudText();
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
model.setLocalScale(0.1f);
model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim(animNames[(i + j) % 4]);
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
skControls.add(skeletonControl);
rootNode.attachChild(model);
}
}
inputManager.addListener(this, "toggleHWS");
inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestOgreAnim method simpleInitApp.
@Override
public void simpleInitApp() {
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(6.4013605f, 7.488437f, 12.843031f));
cam.setRotation(new Quaternion(-0.060740203f, 0.93925786f, -0.2398315f, -0.2378785f));
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
model.center();
control = model.getControl(AnimControl.class);
control.addListener(this);
channel = control.createChannel();
for (String anim : control.getAnimationNames()) System.out.println(anim);
channel.setAnim("stand");
geom = (Geometry) ((Node) model).getChild(0);
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
Box b = new Box(.25f, 3f, .25f);
Geometry item = new Geometry("Item", b);
item.move(0, 1.5f, 0);
item.setMaterial(assetManager.loadMaterial("Common/Materials/RedColor.j3m"));
Node n = skeletonControl.getAttachmentsNode("hand.right");
n.attachChild(item);
rootNode.attachChild(model);
inputManager.addListener(this, "Attack");
inputManager.addMapping("Attack", new KeyTrigger(KeyInput.KEY_SPACE));
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestSkeletonControlRefresh method simpleInitApp.
@Override
public void simpleInitApp() {
viewPort.setBackgroundColor(ColorRGBA.White);
flyCam.setMoveSpeed(10f);
cam.setLocation(new Vector3f(3.8664846f, 6.2704787f, 9.664585f));
cam.setRotation(new Quaternion(-0.054774776f, 0.94064945f, -0.27974048f, -0.18418397f));
makeHudText();
DirectionalLight dl = new DirectionalLight();
dl.setDirection(new Vector3f(-0.1f, -0.7f, -1).normalizeLocal());
dl.setColor(new ColorRGBA(1f, 1f, 1f, 1.0f));
rootNode.addLight(dl);
Material m = new Material(assetManager, "Common/MatDefs/Misc/Unshaded.j3md");
TextureKey k = new TextureKey("Models/Oto/Oto.jpg", false);
m.setTexture("ColorMap", assetManager.loadTexture(k));
for (int i = 0; i < SIZE; i++) {
for (int j = 0; j < SIZE; j++) {
Spatial model = (Spatial) assetManager.loadModel("Models/Oto/Oto.mesh.xml");
//setting a different material
model.setMaterial(m.clone());
model.setLocalScale(0.1f);
model.setLocalTranslation(i - SIZE / 2, 0, j - SIZE / 2);
control = model.getControl(AnimControl.class);
channel = control.createChannel();
channel.setAnim(animNames[(i + j) % 4]);
channel.setLoopMode(LoopMode.DontLoop);
SkeletonControl skeletonControl = model.getControl(SkeletonControl.class);
//This is a workaround the issue. this call will make the SkeletonControl gather the targets again.
//skeletonControl.setSpatial(model);
skeletonControl.setHardwareSkinningPreferred(hwSkinningEnable);
skControls.add(skeletonControl);
rootNode.attachChild(model);
}
}
rootNode.setShadowMode(RenderQueue.ShadowMode.CastAndReceive);
setupFloor();
inputManager.addListener(this, "toggleHWS");
inputManager.addMapping("toggleHWS", new KeyTrigger(KeyInput.KEY_SPACE));
// DirectionalLightShadowRenderer pssm = new DirectionalLightShadowRenderer(assetManager, 1024, 2);
// pssm.setLight(dl);
// viewPort.addProcessor(pssm);
FilterPostProcessor fpp = new FilterPostProcessor(assetManager);
DirectionalLightShadowFilter sf = new DirectionalLightShadowFilter(assetManager, 1024, 2);
sf.setLight(dl);
fpp.addFilter(sf);
fpp.addFilter(new SSAOFilter());
viewPort.addProcessor(fpp);
}
use of com.jme3.input.controls.KeyTrigger in project jmonkeyengine by jMonkeyEngine.
the class TestParallaxPBR method simpleInitApp.
@Override
public void simpleInitApp() {
cam.setLocation(new Vector3f(-15.445636f, 30.162927f, 60.252777f));
cam.setRotation(new Quaternion(0.05173137f, 0.92363626f, -0.13454558f, 0.35513034f));
flyCam.setMoveSpeed(30);
setupLighting();
setupSkyBox();
setupFloor();
setupSignpost();
inputManager.addListener(new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if ("heightUP".equals(name)) {
parallaxHeigh += 0.01;
mat.setFloat("ParallaxHeight", parallaxHeigh);
}
if ("heightDown".equals(name)) {
parallaxHeigh -= 0.01;
parallaxHeigh = Math.max(parallaxHeigh, 0);
mat.setFloat("ParallaxHeight", parallaxHeigh);
}
}
}, "heightUP", "heightDown");
inputManager.addMapping("heightUP", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("heightDown", new KeyTrigger(KeyInput.KEY_K));
inputManager.addListener(new ActionListener() {
public void onAction(String name, boolean isPressed, float tpf) {
if (isPressed && "toggleSteep".equals(name)) {
steep = !steep;
mat.setBoolean("SteepParallax", steep);
}
}
}, "toggleSteep");
inputManager.addMapping("toggleSteep", new KeyTrigger(KeyInput.KEY_SPACE));
}
Aggregations