本文整理汇总了Java中com.jme3.input.controls.AnalogListener类的典型用法代码示例。如果您正苦于以下问题:Java AnalogListener类的具体用法?Java AnalogListener怎么用?Java AnalogListener使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
AnalogListener类属于com.jme3.input.controls包,在下文中一共展示了AnalogListener类的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: invokeAnalogs
import com.jme3.input.controls.AnalogListener; //导入依赖的package包/类
private void invokeAnalogs(int hash, float value, boolean isAxis) {
ArrayList<Mapping> maps = bindings.get(hash);
if (maps == null) {
return;
}
if (!isAxis) {
value *= frameTPF;
}
int size = maps.size();
for (int i = size - 1; i >= 0; i--) {
Mapping mapping = maps.get(i);
ArrayList<InputListener> listeners = mapping.listeners;
int listenerSize = listeners.size();
for (int j = listenerSize - 1; j >= 0; j--) {
InputListener listener = listeners.get(j);
if (listener instanceof AnalogListener) {
// NOTE: multiply by TPF for any button bindings
((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF);
}
}
}
}
示例2: simpleInitApp
import com.jme3.input.controls.AnalogListener; //导入依赖的package包/类
@Override
public void simpleInitApp() {
System.out.println("Press and hold SPACE to move box up!");
//Add some entities
EntityId plane = entityData.createEntity();
entityData.setComponents(plane,
new RigidBody(false, 0),
new CustomShape(new PlaneCollisionShape(new Plane(Vector3f.UNIT_Y.clone(), 0))));
EntityId box = entityData.createEntity();
entityData.setComponents(box,
new WarpPosition(new Vector3f(0,10,0), Quaternion.DIRECTION_Z.clone()),
new RigidBody(false, 10),
new BoxShape());
EntityId box2 = entityData.createEntity();
entityData.setComponents(box2,
new RigidBody(false, 0),
new BoxShape());
getInputManager().addMapping("Push", new KeyTrigger(KeyInput.KEY_SPACE));
getInputManager().addListener((AnalogListener) (name, time, tpf) -> {
//100 Newton are needed to lift the box up against the gravity (10kg * 9.81m/s^2 < 100N)
entityData.setComponent(box, new Force(new Vector3f(0,100,0), new Vector3f()));
}, "Push");
}
示例3: invokeAnalogsAndActions
import com.jme3.input.controls.AnalogListener; //导入依赖的package包/类
private void invokeAnalogsAndActions(int hash, float value, boolean applyTpf) {
if (value < axisDeadZone) {
invokeAnalogs(hash, value, !applyTpf);
return;
}
ArrayList<Mapping> maps = bindings.get(hash);
if (maps == null) {
return;
}
boolean valueChanged = !axisValues.containsKey(hash);
if (applyTpf) {
value *= frameTPF;
}
int size = maps.size();
for (int i = size - 1; i >= 0; i--) {
Mapping mapping = maps.get(i);
ArrayList<InputListener> listeners = mapping.listeners;
int listenerSize = listeners.size();
for (int j = listenerSize - 1; j >= 0; j--) {
InputListener listener = listeners.get(j);
if (listener instanceof ActionListener && valueChanged) {
((ActionListener) listener).onAction(mapping.name, true, frameTPF);
}
if (listener instanceof AnalogListener) {
((AnalogListener) listener).onAnalog(mapping.name, value, frameTPF);
}
}
}
}
示例4: BloomUI
import com.jme3.input.controls.AnalogListener; //导入依赖的package包/类
public BloomUI(InputManager inputManager, final BloomFilter filter) {
System.out.println("----------------- Bloom UI Debugger --------------------");
System.out.println("-- blur Scale : press Y to increase, H to decrease");
System.out.println("-- exposure Power : press U to increase, J to decrease");
System.out.println("-- exposure CutOff : press I to increase, K to decrease");
System.out.println("-- bloom Intensity : press O to increase, P to decrease");
System.out.println("-------------------------------------------------------");
inputManager.addMapping("blurScaleUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("blurScaleDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("exposurePowerUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("exposurePowerDown", new KeyTrigger(KeyInput.KEY_J));
inputManager.addMapping("exposureCutOffUp", new KeyTrigger(KeyInput.KEY_I));
inputManager.addMapping("exposureCutOffDown", new KeyTrigger(KeyInput.KEY_K));
inputManager.addMapping("bloomIntensityUp", new KeyTrigger(KeyInput.KEY_O));
inputManager.addMapping("bloomIntensityDown", new KeyTrigger(KeyInput.KEY_L));
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("blurScaleUp")) {
filter.setBlurScale(filter.getBlurScale() + 0.01f);
System.out.println("blurScale : " + filter.getBlurScale());
}
if (name.equals("blurScaleDown")) {
filter.setBlurScale(filter.getBlurScale() - 0.01f);
System.out.println("blurScale : " + filter.getBlurScale());
}
if (name.equals("exposurePowerUp")) {
filter.setExposurePower(filter.getExposurePower() + 0.01f);
System.out.println("exposurePower : " + filter.getExposurePower());
}
if (name.equals("exposurePowerDown")) {
filter.setExposurePower(filter.getExposurePower() - 0.01f);
System.out.println("exposurePower : " + filter.getExposurePower());
}
if (name.equals("exposureCutOffUp")) {
filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() + 0.001f)));
System.out.println("exposure CutOff : " + filter.getExposureCutOff());
}
if (name.equals("exposureCutOffDown")) {
filter.setExposureCutOff(Math.min(1.0f, Math.max(0.0f, filter.getExposureCutOff() - 0.001f)));
System.out.println("exposure CutOff : " + filter.getExposureCutOff());
}
if (name.equals("bloomIntensityUp")) {
filter.setBloomIntensity(filter.getBloomIntensity() + 0.01f);
System.out.println("bloom Intensity : " + filter.getBloomIntensity());
}
if (name.equals("bloomIntensityDown")) {
filter.setBloomIntensity(filter.getBloomIntensity() - 0.01f);
System.out.println("bloom Intensity : " + filter.getBloomIntensity());
}
}
};
inputManager.addListener(anl, "blurScaleUp", "blurScaleDown", "exposurePowerUp", "exposurePowerDown",
"exposureCutOffUp", "exposureCutOffDown", "bloomIntensityUp", "bloomIntensityDown");
}
示例5: WaterUI
import com.jme3.input.controls.AnalogListener; //导入依赖的package包/类
public WaterUI(InputManager inputManager, SimpleWaterProcessor proc) {
processor=proc;
System.out.println("----------------- SSAO UI Debugger --------------------");
System.out.println("-- Water transparency : press Y to increase, H to decrease");
System.out.println("-- Water depth : 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("transparencyUp", new KeyTrigger(KeyInput.KEY_Y));
inputManager.addMapping("transparencyDown", new KeyTrigger(KeyInput.KEY_H));
inputManager.addMapping("depthUp", new KeyTrigger(KeyInput.KEY_U));
inputManager.addMapping("depthDown", 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));
// ActionListener acl = new ActionListener() {
//
// public void onAction(String name, boolean keyPressed, float tpf) {
//
// if (name.equals("toggleUseAO") && keyPressed) {
// ssaoConfig.setUseAo(!ssaoConfig.isUseAo());
// System.out.println("use AO : "+ssaoConfig.isUseAo());
// }
// if (name.equals("toggleUseOnlyAo") && keyPressed) {
// ssaoConfig.setUseOnlyAo(!ssaoConfig.isUseOnlyAo());
// System.out.println("use Only AO : "+ssaoConfig.isUseOnlyAo());
//
// }
// if (name.equals("outputConfig") && keyPressed) {
// System.out.println("new SSAOConfig("+ssaoConfig.getSampleRadius()+"f,"+ssaoConfig.getIntensity()+"f,"+ssaoConfig.getScale()+"f,"+ssaoConfig.getBias()+"f,"+ssaoConfig.isUseOnlyAo()+","+ssaoConfig.isUseAo()+");");
// }
//
// }
// };
AnalogListener anl = new AnalogListener() {
public void onAnalog(String name, float value, float tpf) {
if (name.equals("transparencyUp")) {
processor.setWaterTransparency(processor.getWaterTransparency()+0.001f);
System.out.println("Water transparency : "+processor.getWaterTransparency());
}
if (name.equals("transparencyDown")) {
processor.setWaterTransparency(processor.getWaterTransparency()-0.001f);
System.out.println("Water transparency : "+processor.getWaterTransparency());
}
if (name.equals("depthUp")) {
processor.setWaterDepth(processor.getWaterDepth()+0.001f);
System.out.println("Water depth : "+processor.getWaterDepth());
}
if (name.equals("depthDown")) {
processor.setWaterDepth(processor.getWaterDepth()-0.001f);
System.out.println("Water depth : "+processor.getWaterDepth());
}
}
};
// inputManager.addListener(acl,"toggleUseAO","toggleUseOnlyAo","outputConfig");
inputManager.addListener(anl, "transparencyUp","transparencyDown","depthUp","depthDown");
}