Source Code Cross Referenced for jaisimulation.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jaimoves » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » 6.0 JDK Modules » Java Advanced Imaging » jaimoves 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package jaimoves;
002:
003:        import com.jme.image.Texture;
004:        import com.jme.input.InputHandler;
005:        import com.jme.input.KeyInput;
006:        import com.jme.input.MouseInput;
007:        import com.jme.input.action.InputAction;
008:        import com.jme.input.action.InputActionEvent;
009:        import com.jme.math.Vector3f;
010:        import com.jme.renderer.ColorRGBA;
011:        import com.jme.scene.Node;
012:        import com.jme.scene.shape.Box;
013:        import com.jme.scene.shape.Sphere;
014:        import com.jme.scene.state.MaterialState;
015:
016:        import com.jme.scene.state.TextureState;
017:        import com.jmex.physics.Joint;
018:        import com.jmex.physics.JointAxis;
019:        import jaimoves.immun.ControlAntiGen;
020:        import jaimoves.util.SamplingThread;
021:        import java.util.logging.Level;
022:
023:        import com.jme.util.LoggingSystem;
024:        import com.jme.util.TextureManager;
025:        import com.jmex.physics.DynamicPhysicsNode;
026:        import com.jmex.physics.RotationalJointAxis;
027:        import com.jmex.physics.util.SimplePhysicsGame;
028:        import java.net.URL;
029:
030:        import java.util.Timer;
031:        import java.util.TimerTask;
032:
033:        import jaimoves.util.Floor;
034:        import jaimoves.util.SamplingTask;
035:        import jaimoves.actor.Actor;
036:
037:        public class jaisimulation extends SimplePhysicsGame {
038:
039:            //    SamplingTask takeSample;
040:
041:            private int samplingTms;
042:
043:            private Vector3f lastPos = new Vector3f();
044:            private Vector3f currentPos = new Vector3f();
045:
046:            private Actor actor;
047:            private Floor podloga;
048:            private jaicontrol control;
049:            private int cnt = 0;
050:            private SamplingThread samplingThread;
051:
052:            protected void simpleInitGame() {
053:                //podstawa (elemęt nośny wiązania)
054:                ///kulka
055:                final Sphere visual_kula = new Sphere("kula", new Vector3f(),
056:                        8, 8, 0.2f);
057:
058:                final MaterialState materialState = display.getRenderer()
059:                        .createMaterialState();
060:                materialState.setDiffuse(ColorRGBA.yellow);
061:                visual_kula.setRenderState(materialState);
062:                visual_kula.setLocalTranslation(getWantedPos());
063:                visual_kula.setSolidColor(ColorRGBA.blue);
064:                Node d_kulka = new Node("kula");
065:                d_kulka.attachChild(visual_kula);
066:                rootNode.attachChild(d_kulka);
067:                /////////////// PODLAGA POCZATEK
068:
069:                setPodloga(new Floor(rootNode, getPhysicsSpace(), display));
070:                getPodloga().keep_position(1000);
071:
072:                // PODLOGA KONIEC
073:
074:                setAktor(new Actor(rootNode, getPhysicsSpace(), 0, 0.5f, 0));
075:                actor.keep_angle(0.2f);
076:
077:                // tylko do testów -------------------------------------------------
078:                input.addAction(new RotateAxisZ(getPodloga(), 600),
079:                        InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_K,
080:                        InputHandler.AXIS_NONE, false);
081:                input.addAction(new RotateAxisZ(getPodloga(), -600),
082:                        InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_H,
083:                        InputHandler.AXIS_NONE, false);
084:                input.addAction(new RotateAxisX(getPodloga(), 600),
085:                        InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_U,
086:                        InputHandler.AXIS_NONE, false);
087:                input.addAction(new RotateAxisX(getPodloga(), -600),
088:                        InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_J,
089:                        InputHandler.AXIS_NONE, false);
090:
091:                input.addAction(new SetPosition(actor, podloga, 0, 2, 0),
092:                        InputHandler.DEVICE_KEYBOARD, KeyInput.KEY_R,
093:                        InputHandler.AXIS_NONE, false);
094:                //--------------------------------------------
095:
096:                ///Ustawienie sceny
097:
098:                cam.getLocation().y += 10;
099:                cam.lookAt(new Vector3f(), new Vector3f(0, 0, -1));
100:                // kursor
101:                MouseInput.get().setCursorVisible(true);
102:                showPhysics = false;
103:                // WLACZENIE SAMPLERA MOZE BYC DOPIERO TUTAJ
104:                samplingThread = new SamplingThread(this , 50);
105:                samplingThread.start();
106:            }
107:
108:            public jaisimulation() {
109:                control = new jaicontrol(100, 1000, 128, new Vector3f(0, 6, 0));
110:            }
111:
112:            //aby obrócić kamere należy naciśnąć klawisz myszy
113:            //   @Override
114:            protected void simpleUpdate() {
115:                cameraInputHandler.setEnabled(MouseInput.get().isButtonDown(3));
116:                Vector3f a = this .getWantedPos();
117:                Vector3f b = actor.getCenterOfGravity();
118:                float distance = a.distance(b);
119:                if (distance > 3) {
120:                    actor.ResetAllDynamics();
121:                    actor.set_position(0.0f, 0.5f, 0.0f);
122:                    podloga.resetFloor();
123:                    //            d_kulka.setLocalTranslation(getWantedPos());
124:                }
125:            }
126:
127:            //tylko do testów   ----------------------------------------
128:            class RotateAxisX extends InputAction {
129:                private final Floor floor;
130:                private float torque;
131:
132:                public RotateAxisX(Floor floor, float torque) {
133:                    this .floor = floor;
134:                    this .torque = torque;
135:                }
136:
137:                public void performAction(InputActionEvent evt) {
138:                    if (evt.getTriggerPressed()) {
139:                        floor.rotationX(torque);
140:                    } else {
141:                        floor.keep_position(1000, true, false);
142:                        System.out.println(floor.Position_rotationX());
143:                    }
144:                }
145:            }
146:
147:            private static class RotateAxisZ extends InputAction {
148:                private final Floor floor;
149:                private float torque;
150:
151:                public RotateAxisZ(Floor floor, float torque) {
152:                    this .floor = floor;
153:                    this .torque = torque;
154:                }
155:
156:                public void performAction(InputActionEvent evt) {
157:                    if (evt.getTriggerPressed()) {
158:                        floor.rotationZ(torque);
159:                    } else {
160:                        floor.keep_position(1000, false, true);
161:                        System.out.println(floor.Position_rotationZ());
162:                    }
163:                }
164:            }
165:
166:            class SetPosition extends InputAction {
167:                private final Actor actor;
168:                private final Floor floor;
169:                private float x;
170:                private float y;
171:                private float z;
172:
173:                public SetPosition(Actor actor, Floor floor, float x, float y,
174:                        float z) {
175:                    this .actor = actor;
176:                    this .floor = floor;
177:                    this .x = x;
178:                    this .y = y;
179:                    this .z = z;
180:                }
181:
182:                public void performAction(InputActionEvent evt) {
183:                    pause = true;
184:                    actor.set_position(x, y, z);
185:                    floor.resetFloor();
186:                    pause = false;
187:                }
188:            }
189:
190:            //---------------------------------------
191:
192:            public static void main(String[] args) {
193:                LoggingSystem.getLogger().setLevel(Level.WARNING); // to see the important stuff
194:                jaisimulation sim = new jaisimulation();
195:                sim.start();
196:                //        sim.getSamplingThread();
197:                //        sim.getSamplingThread().start();
198:                //        sampler.schedule( new SamplingTask(this) , 400 ) ; // co 400 ms na symulacji
199:
200:            }
201:
202:            public void updateProblem() {
203:                jaicontrol cntrolll = getControl();
204:                ControlAntiGen aaaaaa = cntrolll.getProblem();
205:                Vector3f bb = getWantedPos();
206:                aaaaaa.updateProblem(bb);
207:            }
208:
209:            public boolean isEndOfCalcCycle() {
210:                return getControl().isCycleEnd();
211:            }
212:
213:            public void updateCurrentAntigen() {
214:                double fitting = getControl().getProblem().calcDistance(
215:                        getControl().getCurrentAntibody(), 0.1, 128);
216:                getControl().getCurrentAntibody().setFitting(fitting);
217:            }
218:
219:            public void applyControl() {
220:                this .getControl().applyControl(getAktor());
221:            }
222:
223:            public synchronized Actor getAktor() {
224:                return actor;
225:            }
226:
227:            public synchronized void setAktor(Actor aktor) {
228:
229:                this .actor = aktor;
230:            }
231:
232:            public synchronized Floor getPodloga() {
233:                return podloga;
234:            }
235:
236:            public synchronized void setPodloga(Floor podloga) {
237:                this .podloga = podloga;
238:            }
239:
240:            public synchronized void setPause(boolean pauseNew) {
241:                pause = pauseNew;
242:            }
243:
244:            public synchronized boolean getPause() {
245:                return pause;
246:            }
247:
248:            public synchronized Vector3f getLastPos() {
249:                return lastPos;
250:            }
251:
252:            public synchronized void setLastPos(Vector3f lastPos) {
253:                this .lastPos = lastPos;
254:            }
255:
256:            public synchronized Vector3f getCurrentPos() {
257:                return currentPos;
258:            }
259:
260:            public synchronized void setCurrentPos(Vector3f currentPos) {
261:                this .currentPos = currentPos;
262:            }
263:
264:            public synchronized SamplingThread getSamplingThread() {
265:                return samplingThread;
266:            }
267:
268:            public synchronized jaicontrol getControl() {
269:                return control;
270:            }
271:
272:            public synchronized Vector3f getWantedPos() {
273:                return control.getProblem().getWantedPos();
274:            }
275:
276:            public synchronized void setWantedPos(Vector3f wantedPos) {
277:                control.setProblem(new ControlAntiGen(wantedPos));
278:            }
279:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.