• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (c) 2009-2010 jMonkeyEngine
3  * All rights reserved.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are
7  * met:
8  *
9  * * Redistributions of source code must retain the above copyright
10  *   notice, this list of conditions and the following disclaimer.
11  *
12  * * Redistributions in binary form must reproduce the above copyright
13  *   notice, this list of conditions and the following disclaimer in the
14  *   documentation and/or other materials provided with the distribution.
15  *
16  * * Neither the name of 'jMonkeyEngine' nor the names of its contributors
17  *   may be used to endorse or promote products derived from this software
18  *   without specific prior written permission.
19  *
20  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21  * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
22  * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
23  * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
24  * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
25  * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
26  * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
27  * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
28  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
29  * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
30  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
31  */
32 
33 package jme3test.water;
34 
35 import com.jme3.input.InputManager;
36 import com.jme3.input.KeyInput;
37 import com.jme3.input.controls.AnalogListener;
38 import com.jme3.input.controls.KeyTrigger;
39 import com.jme3.water.SimpleWaterProcessor;
40 
41 /**
42  *
43  * @author nehon
44  */
45 public class WaterUI {
46     private SimpleWaterProcessor processor;
WaterUI(InputManager inputManager, SimpleWaterProcessor proc)47     public WaterUI(InputManager inputManager, SimpleWaterProcessor proc) {
48         processor=proc;
49 
50 
51         System.out.println("----------------- SSAO UI Debugger --------------------");
52         System.out.println("-- Water transparency : press Y to increase, H to decrease");
53         System.out.println("-- Water depth : press U to increase, J to decrease");
54 //        System.out.println("-- AO scale : press I to increase, K to decrease");
55 //        System.out.println("-- AO bias : press O to increase, P to decrease");
56 //        System.out.println("-- Toggle AO on/off : press space bar");
57 //        System.out.println("-- Use only AO : press Num pad 0");
58 //        System.out.println("-- Output config declaration : press P");
59         System.out.println("-------------------------------------------------------");
60 
61         inputManager.addMapping("transparencyUp", new KeyTrigger(KeyInput.KEY_Y));
62         inputManager.addMapping("transparencyDown", new KeyTrigger(KeyInput.KEY_H));
63         inputManager.addMapping("depthUp", new KeyTrigger(KeyInput.KEY_U));
64         inputManager.addMapping("depthDown", new KeyTrigger(KeyInput.KEY_J));
65 //        inputManager.addMapping("scaleUp", new KeyTrigger(KeyInput.KEY_I));
66 //        inputManager.addMapping("scaleDown", new KeyTrigger(KeyInput.KEY_K));
67 //        inputManager.addMapping("biasUp", new KeyTrigger(KeyInput.KEY_O));
68 //        inputManager.addMapping("biasDown", new KeyTrigger(KeyInput.KEY_L));
69 //        inputManager.addMapping("outputConfig", new KeyTrigger(KeyInput.KEY_P));
70 //        inputManager.addMapping("toggleUseAO", new KeyTrigger(KeyInput.KEY_SPACE));
71 //        inputManager.addMapping("toggleUseOnlyAo", new KeyTrigger(KeyInput.KEY_NUMPAD0));
72 
73 //        ActionListener acl = new ActionListener() {
74 //
75 //            public void onAction(String name, boolean keyPressed, float tpf) {
76 //
77 //                if (name.equals("toggleUseAO") && keyPressed) {
78 //                    ssaoConfig.setUseAo(!ssaoConfig.isUseAo());
79 //                    System.out.println("use AO : "+ssaoConfig.isUseAo());
80 //                }
81 //                if (name.equals("toggleUseOnlyAo") && keyPressed) {
82 //                    ssaoConfig.setUseOnlyAo(!ssaoConfig.isUseOnlyAo());
83 //                    System.out.println("use Only AO : "+ssaoConfig.isUseOnlyAo());
84 //
85 //                }
86 //                if (name.equals("outputConfig") && keyPressed) {
87 //                    System.out.println("new SSAOConfig("+ssaoConfig.getSampleRadius()+"f,"+ssaoConfig.getIntensity()+"f,"+ssaoConfig.getScale()+"f,"+ssaoConfig.getBias()+"f,"+ssaoConfig.isUseOnlyAo()+","+ssaoConfig.isUseAo()+");");
88 //                }
89 //
90 //            }
91 //        };
92 
93          AnalogListener anl = new AnalogListener() {
94 
95             public void onAnalog(String name, float value, float tpf) {
96                 if (name.equals("transparencyUp")) {
97                     processor.setWaterTransparency(processor.getWaterTransparency()+0.001f);
98                     System.out.println("Water transparency : "+processor.getWaterTransparency());
99                 }
100                 if (name.equals("transparencyDown")) {
101                     processor.setWaterTransparency(processor.getWaterTransparency()-0.001f);
102                     System.out.println("Water transparency : "+processor.getWaterTransparency());
103                 }
104                 if (name.equals("depthUp")) {
105                     processor.setWaterDepth(processor.getWaterDepth()+0.001f);
106                     System.out.println("Water depth : "+processor.getWaterDepth());
107                 }
108                 if (name.equals("depthDown")) {
109                     processor.setWaterDepth(processor.getWaterDepth()-0.001f);
110                     System.out.println("Water depth : "+processor.getWaterDepth());
111                 }
112 
113             }
114         };
115     //    inputManager.addListener(acl,"toggleUseAO","toggleUseOnlyAo","outputConfig");
116         inputManager.addListener(anl, "transparencyUp","transparencyDown","depthUp","depthDown");
117 
118     }
119 
120 
121 
122 }
123