Source Code Cross Referenced for Actor.java in  » 6.0-JDK-Modules » Java-Advanced-Imaging » jaimoves » actor » 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.actor 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Actor.java
003:         *
004:         * Created on 15 maj 2007, 11:18
005:         *
006:         * To change this template, choose Tools | Template Manager
007:         * and open the template in the editor.
008:         */
009:
010:        package jaimoves.actor;
011:
012:        import com.jme.scene.Node;
013:        import com.jme.scene.Spatial;
014:        import com.jmex.physics.PhysicsSpace;
015:        import com.jmex.physics.contact.MutableContactInfo;
016:        import com.jmex.physics.material.Material;
017:        import jaimoves.immun.ControlAntiGen;
018:        import java.util.logging.Level;
019:
020:        import com.jme.util.LoggingSystem;
021:        import com.jmex.physics.DynamicPhysicsNode;
022:        import com.jmex.physics.StaticPhysicsNode; //import com.jmex.physics.geometry.PhysicsBox;
023:        import com.jmex.physics.util.SimplePhysicsGame;
024:
025:        import com.jme.input.MouseInput;
026:        import com.jme.math.Vector3f;
027:        import com.jme.scene.shape.Box;
028:        import com.jme.scene.shape.Sphere;
029:        import com.jme.scene.shape.Capsule;
030:        import com.jme.scene.shape.Cylinder;
031:        import com.jmex.physics.Joint;
032:        import com.jmex.physics.JointAxis;
033:        import com.jmex.physics.RotationalJointAxis;
034:        import com.jme.input.KeyInput;
035:        import com.jme.input.action.InputAction;
036:        import com.jme.input.action.InputActionEvent;
037:        import com.jme.input.InputHandler;
038:
039:        import jaimoves.jaicontrol;
040:
041:        /**
042:         *
043:         * @author spin83r
044:         */
045:        public class Actor {
046:
047:            private DynamicPhysicsNode foot_r;
048:            private DynamicPhysicsNode foot_l;
049:            private DynamicPhysicsNode footAngle_r;
050:            private DynamicPhysicsNode footAngle_l;
051:
052:            private final Joint joint_foot_r1;
053:            private final RotationalJointAxis rot_foot_r1;
054:
055:            private final Joint joint_foot_l1;
056:            private final RotationalJointAxis rot_foot_l1;
057:
058:            private final Joint joint_foot_l2;
059:            private final RotationalJointAxis rot_foot_l2;
060:
061:            private final Joint joint_foot_r2;
062:            private final RotationalJointAxis rot_foot_r2;
063:
064:            private DynamicPhysicsNode legLo_r;
065:            private DynamicPhysicsNode legLo_l;
066:
067:            private DynamicPhysicsNode legHi_r;
068:            private DynamicPhysicsNode legHi_l;
069:
070:            private final Joint joint_leg_r;
071:            private final RotationalJointAxis rot_leg_r;
072:
073:            private final Joint joint_leg_l;
074:            private final RotationalJointAxis rot_leg_l;
075:
076:            private DynamicPhysicsNode legAngle_r;
077:            private DynamicPhysicsNode legAngle_l;
078:
079:            private final Joint joint_hip_r1;
080:            private final RotationalJointAxis rot_hip_r1;
081:
082:            private DynamicPhysicsNode tummyLo;
083:
084:            private final Joint joint_hip_r2;
085:            private final Joint joint_hip_l2;
086:
087:            private final Joint joint_hip_l1;
088:            private final RotationalJointAxis rot_hip_l1;
089:
090:            private RotationalJointAxis rot_hip_l2;
091:
092:            private RotationalJointAxis rot_hip_r2;
093:
094:            private DynamicPhysicsNode tummyHi;
095:
096:            private Joint joint_tummy;
097:
098:            public Actor(Node rootNode, PhysicsSpace physic, float x, float y,
099:                    float z) {
100:                //        rot_hip_l2.
101:
102:                // finally we define a custom material
103:                final Material customMaterial = new Material("supra-stopper");
104:                // we make it really light
105:                customMaterial.setDensity(0.05f);
106:                // a material should define contact detail pairs for each other material it could collide with in the scene
107:                // do that just for the floor material - the DEFAULT material
108:                MutableContactInfo contactDetails = new MutableContactInfo();
109:                // our material should not bounce on DEFAULT
110:                contactDetails.setBounce(0);
111:                // and should never slide on DEFAULT
112:                contactDetails.setMu(1000); // todo: Float.POSITIVE_INFINITY seems to cause issues on Linux (only o_O)
113:                // now set that behaviour
114:                customMaterial.putContactHandlingDetails(Material.DEFAULT,
115:                        contactDetails);
116:
117:                //prawa stopa
118:                foot_r = physic.createDynamicNode();
119:                final Box visualFloot_r = new Box("foot_r", new Vector3f(),
120:                        0.3f, 0.15f, 0.6f);
121:                foot_r.attachChild(visualFloot_r);
122:                foot_r.generatePhysicsGeometry();
123:                foot_r.getLocalTranslation().set(x - 0.6f, y, z + 0.4f);
124:                foot_r.setMass(0.6f);
125:                foot_r.setMaterial(customMaterial);
126:                rootNode.attachChild(foot_r);
127:
128:                //lewa stopa
129:                foot_l = physic.createDynamicNode();
130:                final Box visualFloot_l = new Box("foot_l", new Vector3f(),
131:                        0.3f, 0.15f, 0.6f);
132:                foot_l.attachChild(visualFloot_l);
133:                foot_l.generatePhysicsGeometry();
134:                foot_l.getLocalTranslation().set(x + 0.6f, y, z + 0.4f);
135:                foot_l.setMass(0.6f);
136:                foot_l.setMaterial(customMaterial);
137:                rootNode.attachChild(foot_l);
138:
139:                //kostka prawa
140:                footAngle_r = physic.createDynamicNode();
141:                final Sphere visualFlootA_r = new Sphere("footA_r",
142:                        new Vector3f(), 10, 10, 0.15f);
143:                footAngle_r.attachChild(visualFlootA_r);
144:                footAngle_r.generatePhysicsGeometry();
145:                footAngle_r.getLocalTranslation().set(x - 0.6f,
146:                        y + 0.3f + 0.01f, z);
147:                footAngle_r.setMass(0.1f);
148:                rootNode.attachChild(footAngle_r);
149:
150:                //kostka lewa
151:                footAngle_l = physic.createDynamicNode();
152:                final Sphere visualFlootA_l = new Sphere("footA_l",
153:                        new Vector3f(), 10, 10, 0.15f);
154:                footAngle_l.attachChild(visualFlootA_l);
155:                footAngle_l.generatePhysicsGeometry();
156:                footAngle_l.getLocalTranslation().set(x + 0.6f,
157:                        y + 0.3f + 0.01f, z);
158:                footAngle_l.setMass(0.1f);
159:                rootNode.attachChild(footAngle_l);
160:
161:                joint_foot_r1 = physic.createJoint();
162:                joint_foot_r1.attach(footAngle_r, foot_r);
163:                rot_foot_r1 = joint_foot_r1.createRotationalAxis();
164:                rot_foot_r1.setDirection(new Vector3f(1, 0, 0));
165:                rot_foot_r1.setPositionMinimum(-0.8f);
166:                rot_foot_r1.setPositionMaximum(0.2f);
167:                rot_foot_r1.setAvailableAcceleration(0);
168:
169:                joint_foot_l1 = physic.createJoint();
170:                joint_foot_l1.attach(footAngle_l, foot_l);
171:                rot_foot_l1 = joint_foot_l1.createRotationalAxis();
172:                rot_foot_l1.setDirection(new Vector3f(1, 0, 0));
173:                rot_foot_l1.setAvailableAcceleration(0);
174:                rot_foot_l1.setPositionMinimum(-0.8f);
175:                rot_foot_l1.setPositionMaximum(0.2f);
176:
177:                //noga prawa dolna część
178:                legLo_r = physic.createDynamicNode();
179:                final Capsule visualLegL_r = new Capsule("legLo_r", 10, 10, 10,
180:                        0.2f, 1.6f);
181:                legLo_r.attachChild(visualLegL_r);
182:                legLo_r.generatePhysicsGeometry(true);
183:                legLo_r.getLocalTranslation().set(x - 0.6f, y + 1.44f + 0.02f,
184:                        z);
185:                legLo_r.setMass(1.1f);
186:                rootNode.attachChild(legLo_r);
187:
188:                //noga lewa dolna część
189:                legLo_l = physic.createDynamicNode();
190:                final Capsule visualLegL_l = new Capsule("legLo_l", 10, 10, 10,
191:                        0.2f, 1.6f);
192:                legLo_l.attachChild(visualLegL_l);
193:                legLo_l.generatePhysicsGeometry(true);
194:                legLo_l.getLocalTranslation().set(x + 0.6f, y + 1.44f + 0.02f,
195:                        z);
196:                legLo_l.setMass(1.1f);
197:                rootNode.attachChild(legLo_l);
198:
199:                joint_foot_r2 = physic.createJoint();
200:                joint_foot_r2.attach(footAngle_r, legLo_r);
201:                rot_foot_r2 = joint_foot_r2.createRotationalAxis();
202:                rot_foot_r2.setDirection(new Vector3f(0, 0, 1));
203:                rot_foot_r2.setAvailableAcceleration(0);
204:                rot_foot_r2.setPositionMinimum(-0.4f);
205:                rot_foot_r2.setPositionMaximum(0.4f);
206:
207:                joint_foot_l2 = physic.createJoint();
208:                joint_foot_l2.attach(footAngle_l, legLo_l);
209:                rot_foot_l2 = joint_foot_l2.createRotationalAxis();
210:                rot_foot_l2.setDirection(new Vector3f(0, 0, 1));
211:                rot_foot_l2.setAvailableAcceleration(0);
212:                rot_foot_l2.setPositionMinimum(-0.4f);
213:                rot_foot_l2.setPositionMaximum(0.4f);
214:
215:                //noga prawa górna część
216:                legHi_r = physic.createDynamicNode();
217:                final Capsule visualLegH_r = new Capsule("legHi_r", 10, 10, 10,
218:                        0.24f, 1.6f);
219:                legHi_r.attachChild(visualLegH_r);
220:                legHi_r.generatePhysicsGeometry(true);
221:                legHi_r.getLocalTranslation().set(x - 0.6f, y + 3.48f + 0.03f,
222:                        z);
223:                legHi_r.setMass(1.2f);
224:                rootNode.attachChild(legHi_r);
225:
226:                //noga lewa górna część
227:                legHi_l = physic.createDynamicNode();
228:                final Capsule visualLegH_l = new Capsule("legHi_l", 10, 10, 10,
229:                        0.24f, 1.6f);
230:                legHi_l.attachChild(visualLegH_l);
231:                legHi_l.generatePhysicsGeometry(true);
232:                legHi_l.getLocalTranslation().set(x + 0.6f, y + 3.48f + 0.03f,
233:                        z);
234:                legHi_l.setMass(1.2f);
235:                rootNode.attachChild(legHi_l);
236:
237:                joint_leg_r = physic.createJoint();
238:                joint_leg_r.attach(legLo_r, legHi_r);
239:                joint_leg_r.setAnchor(new Vector3f(0, 1.005f, 0));
240:                rot_leg_r = joint_leg_r.createRotationalAxis();
241:                rot_leg_r.setDirection(new Vector3f(1, 0, 0));
242:                rot_leg_r.setAvailableAcceleration(0);
243:                rot_leg_r.setPositionMinimum(0f);
244:                rot_leg_r.setPositionMaximum(2.6f);
245:
246:                joint_leg_l = physic.createJoint();
247:                joint_leg_l.attach(legLo_l, legHi_l);
248:                joint_leg_l.setAnchor(new Vector3f(0, 1.005f, 0));
249:                rot_leg_l = joint_leg_l.createRotationalAxis();
250:                rot_leg_l.setDirection(new Vector3f(1, 0, 0));
251:                rot_leg_l.setAvailableAcceleration(0);
252:                rot_leg_l.setPositionMinimum(0f);
253:                rot_leg_l.setPositionMaximum(2.6f);
254:
255:                //staw biodrowy prawy
256:                legAngle_r = physic.createDynamicNode();
257:                final Sphere visualLegA_r = new Sphere("legA_r",
258:                        new Vector3f(), 10, 10, 0.15f);
259:                legAngle_r.attachChild(visualLegA_r);
260:                legAngle_r.generatePhysicsGeometry();
261:                legAngle_r.getLocalTranslation().set(x - 0.6f,
262:                        y + 4.67f + 0.04f, z);
263:                legAngle_r.setMass(0.2f);
264:                rootNode.attachChild(legAngle_r);
265:
266:                //staw biodrowy lewy
267:                legAngle_l = physic.createDynamicNode();
268:                final Sphere visualLegA_l = new Sphere("legA_l",
269:                        new Vector3f(), 10, 10, 0.15f);
270:                legAngle_l.attachChild(visualLegA_l);
271:                legAngle_l.generatePhysicsGeometry();
272:                legAngle_l.getLocalTranslation().set(x + 0.6f,
273:                        y + 4.67f + 0.04f, z);
274:                legAngle_l.setMass(0.2f);
275:                rootNode.attachChild(legAngle_l);
276:
277:                joint_hip_r1 = physic.createJoint();
278:                joint_hip_r1.attach(legAngle_r, legHi_r);
279:                rot_hip_r1 = joint_hip_r1.createRotationalAxis();
280:                rot_hip_r1.setDirection(new Vector3f(1, 0, 0));
281:                rot_hip_r1.setAvailableAcceleration(0);
282:                rot_hip_r1.setPositionMinimum(-1.6f);
283:                rot_hip_r1.setPositionMaximum(1.6f);
284:
285:                joint_hip_l1 = physic.createJoint();
286:                joint_hip_l1.attach(legAngle_l, legHi_l);
287:                rot_hip_l1 = joint_hip_l1.createRotationalAxis();
288:                rot_hip_l1.setDirection(new Vector3f(1, 0, 0));
289:                rot_hip_l1.setAvailableAcceleration(0);
290:                rot_hip_l1.setPositionMinimum(-1.6f);
291:                rot_hip_l1.setPositionMaximum(1.6f);
292:
293:                //brzuch część dolna
294:                tummyLo = physic.createDynamicNode();
295:                final Cylinder visualTummyLo = new Cylinder("tummyLo", 10, 10,
296:                        0.6f, 0.4f, true);
297:                tummyLo.attachChild(visualTummyLo);
298:                tummyLo.generatePhysicsGeometry(true);
299:                tummyLo.getLocalRotation().set(0f, 0.5f, 0.5f, 0);
300:                tummyLo.getLocalTranslation().set(x, y + 5.02f + 0.05f, z);
301:                tummyLo.setMass(2);
302:                rootNode.attachChild(tummyLo);
303:
304:                joint_hip_r2 = physic.createJoint();
305:                joint_hip_r2.attach(legAngle_r, tummyLo);
306:                rot_hip_r2 = joint_hip_r2.createRotationalAxis();
307:                rot_hip_r2.setDirection(new Vector3f(0, 0, 1));
308:                rot_hip_r2.setAvailableAcceleration(0);
309:                rot_hip_r2.setPositionMinimum(-1.2f);
310:                rot_hip_r2.setPositionMaximum(1.2f);
311:
312:                joint_hip_l2 = physic.createJoint();
313:                joint_hip_l2.attach(legAngle_l, tummyLo);
314:                rot_hip_l2 = joint_hip_l2.createRotationalAxis();
315:                rot_hip_l2.setDirection(new Vector3f(0, 0, 1));
316:                rot_hip_l2.setAvailableAcceleration(0);
317:                rot_hip_l2.setPositionMinimum(-1.2f);
318:                rot_hip_l2.setPositionMaximum(1.2f);
319:
320:                //brzuch część górna
321:                tummyHi = physic.createDynamicNode();
322:                final Sphere visualTummyHi = new Sphere("tummyHi",
323:                        new Vector3f(), 10, 10, 0.6f);
324:                tummyHi.attachChild(visualTummyHi);
325:                tummyHi.generatePhysicsGeometry();
326:                tummyHi.getLocalTranslation().set(x, y + 5.82f + 0.06f, z);
327:                tummyHi.setMass(1f);
328:                rootNode.attachChild(tummyHi);
329:
330:                joint_tummy = physic.createJoint();
331:                joint_tummy.attach(tummyHi, tummyLo);
332:                //     final Joint joint_tummy1 = physic.createJoint();
333:                //     joint_tummy1.attach( tummyHi);
334:
335:            }
336:
337:            public Vector3f getCenterOfGravity() {
338:                /*       BEDZIE MOZNA TO DODAC GDY ZAMODELOWANY ZOSTANIE CALY CZLOWIEK
339:                 *       OBECNIE WPROWADZENIE TEGO DOPROWADZI DO PRZESUNIECIE SRODKA
340:                 *       CIEZKOSCI W DOL CO JEST NIEKORZYSTNE
341:                
342:                 Vector3f v1 = new Vector3f();
343:                
344:                 foot_r.getCenterOfMass(v1);
345:                 foot_r.localToWorld(v1,v1);
346:                
347:                 Vector3f v2 = new Vector3f();
348:                
349:                 foot_l.getCenterOfMass(v2);
350:                 foot_l.localToWorld(v2,v2);
351:                
352:                 Vector3f v3 = new Vector3f();
353:                
354:                 footAngle_r.getCenterOfMass(v3);
355:                 footAngle_r.localToWorld(v3,v3);
356:                
357:                 Vector3f v4 = new Vector3f();
358:                
359:                 footAngle_l.getCenterOfMass(v4);
360:                 footAngle_l.localToWorld(v4,v4);
361:                
362:                 Vector3f v5 = new Vector3f();
363:                
364:                 legLo_r.getCenterOfMass(v5);
365:                 legLo_r.localToWorld(v5,v5);
366:                
367:                 Vector3f v6 = new Vector3f();
368:                
369:                 legLo_l.getCenterOfMass(v6);
370:                 legLo_l.localToWorld(v6,v6);
371:                
372:                 Vector3f v7 = new Vector3f();
373:                
374:                 legHi_r.getCenterOfMass(v7);
375:                 legHi_r.localToWorld(v7,v7);
376:                
377:                 Vector3f v8 = new Vector3f();
378:                
379:                 legHi_l.getCenterOfMass(v8);
380:                 legHi_l.localToWorld(v8,v8);
381:                
382:                 Vector3f v9 = new Vector3f();
383:                
384:                 legAngle_r.getCenterOfMass(v9);
385:                 legAngle_r.localToWorld(v9,v9);
386:                
387:                 Vector3f v10 = new Vector3f();
388:                
389:                 legAngle_l.getCenterOfMass(v10);
390:                 legAngle_l.localToWorld(v10,v10);
391:                
392:                
393:                 */
394:                Vector3f v11 = new Vector3f();
395:
396:                tummyLo.getCenterOfMass(v11);
397:                tummyLo.localToWorld(v11, v11);
398:
399:                Vector3f v12 = new Vector3f();
400:
401:                tummyHi.getCenterOfMass(v12);
402:                tummyHi.localToWorld(v12, v12);
403:                //        System.out.println(v12.toString());
404:
405:                v11.add(v12, v12);
406:
407:                return v12.divide(2); // wyznaczamy srednia arytmetyczna
408:            }
409:
410:            // liczba jointow ktorymi trzeba sterowac
411:
412:            //oblicza ustawia kierunek i wartość prędkośći
413:            private float computeSpeed(float torque) {
414:                float velocity;
415:                if (torque < 0) {
416:                    velocity = -1;
417:                } else {
418:                    if (torque > 0) {
419:                        velocity = 1;
420:                    } else {
421:                        velocity = 0;
422:                    }
423:                }
424:                return velocity;
425:            }
426:
427:            // obrót poszczegulnymi przegubami
428:            protected void Rotation_foot_r1(float torque) {
429:                rot_foot_r1.setDesiredVelocity(computeSpeed(torque));
430:                rot_foot_r1.setAvailableAcceleration(Math.abs(torque));
431:            }
432:
433:            protected void Rotation_foot_l1(float torque) {
434:                rot_foot_l1.setDesiredVelocity(computeSpeed(torque));
435:                rot_foot_l1.setAvailableAcceleration(Math.abs(torque));
436:            }
437:
438:            protected void Rotation_foot_r2(float torque) {
439:                rot_foot_r2.setDesiredVelocity(computeSpeed(torque));
440:                rot_foot_r2.setAvailableAcceleration(Math.abs(torque));
441:            }
442:
443:            protected void Rotation_foot_l2(float torque) {
444:                rot_foot_l2.setDesiredVelocity(computeSpeed(torque));
445:                rot_foot_l2.setAvailableAcceleration(Math.abs(torque));
446:            }
447:
448:            protected void Rotation_leg_r(float torque) {
449:                rot_leg_r.setDesiredVelocity(computeSpeed(torque));
450:                rot_leg_r.setAvailableAcceleration(Math.abs(torque));
451:            }
452:
453:            protected void Rotation_leg_l(float torque) {
454:                rot_leg_l.setDesiredVelocity(computeSpeed(torque));
455:                rot_leg_l.setAvailableAcceleration(Math.abs(torque));
456:            }
457:
458:            protected void Rotation_hip_r1(float torque) {
459:                rot_hip_r1.setDesiredVelocity(computeSpeed(torque));
460:                rot_hip_r1.setAvailableAcceleration(Math.abs(torque));
461:            }
462:
463:            protected void Rotation_hip_l1(float torque) {
464:                rot_hip_l1.setDesiredVelocity(computeSpeed(torque));
465:                rot_hip_l1.setAvailableAcceleration(Math.abs(torque));
466:            }
467:
468:            protected void Rotation_hip_r2(float torque) {
469:                rot_hip_r2.setDesiredVelocity(computeSpeed(torque));
470:                rot_hip_r2.setAvailableAcceleration(Math.abs(torque));
471:            }
472:
473:            protected void Rotation_hip_l2(float torque) {
474:                rot_hip_l2.setDesiredVelocity(computeSpeed(torque));
475:                rot_hip_l2.setAvailableAcceleration(Math.abs(torque));
476:            }
477:
478:            public void SetControls(double controls[]) {
479:                Rotation_foot_r1((float) controls[0]);
480:                Rotation_foot_l1((float) controls[1]);
481:                Rotation_foot_r2((float) controls[2]);
482:                Rotation_foot_l2((float) controls[3]);
483:                Rotation_leg_r((float) controls[4]);
484:                Rotation_leg_l((float) controls[5]);
485:                Rotation_hip_r1((float) controls[6]);
486:                Rotation_hip_l1((float) controls[7]);
487:                Rotation_hip_l2((float) controls[8]);
488:                Rotation_hip_r2((float) controls[9]);
489:            }
490:
491:            public void keep_angle(float torque) {
492:
493:                rot_foot_r1.setDesiredVelocity(0);
494:                rot_foot_r1.setAvailableAcceleration(torque);
495:
496:                rot_foot_l1.setDesiredVelocity(0);
497:                rot_foot_l1.setAvailableAcceleration(torque);
498:
499:                rot_foot_r2.setDesiredVelocity(0);
500:                rot_foot_r2.setAvailableAcceleration(torque);
501:
502:                rot_foot_l2.setDesiredVelocity(0);
503:                rot_foot_l2.setAvailableAcceleration(torque);
504:
505:                rot_leg_r.setDesiredVelocity(0);
506:                rot_leg_r.setAvailableAcceleration(torque);
507:
508:                rot_leg_l.setDesiredVelocity(0);
509:                rot_leg_l.setAvailableAcceleration(torque);
510:
511:                rot_hip_r1.setDesiredVelocity(0);
512:                rot_hip_r1.setAvailableAcceleration(torque);
513:
514:                rot_hip_l1.setDesiredVelocity(0);
515:                rot_hip_l1.setAvailableAcceleration(torque);
516:
517:                rot_hip_r2.setDesiredVelocity(0);
518:                rot_hip_r2.setAvailableAcceleration(torque);
519:
520:                rot_hip_l2.setDesiredVelocity(0);
521:                rot_hip_l2.setAvailableAcceleration(torque);
522:
523:            }
524:
525:            // położenie względne
526:            public float Position_foot_r1() {
527:                return (rot_foot_r1.getPosition());
528:            }
529:
530:            public float Position_foot_l1() {
531:                return (rot_foot_l1.getPosition());
532:            }
533:
534:            public float Position_foot_r2() {
535:                return (rot_foot_r2.getPosition());
536:            }
537:
538:            public float Position_foot_l2() {
539:                return (rot_foot_l2.getPosition());
540:            }
541:
542:            public float Position_leg_r() {
543:                return (rot_leg_r.getPosition());
544:            }
545:
546:            public float Position_leg_l() {
547:                return (rot_leg_l.getPosition());
548:            }
549:
550:            public float Position_hip_r1() {
551:                return (rot_hip_r1.getPosition());
552:            }
553:
554:            public float Position_hip_l1() {
555:                return (rot_hip_l1.getPosition());
556:            }
557:
558:            public float Position_hip_r2() {
559:                return (rot_hip_r2.getPosition());
560:            }
561:
562:            public float Position_hip_l2() {
563:                return (rot_hip_l2.getPosition());
564:            }
565:
566:            public void ResetAllDynamics() {
567:                foot_r.clearDynamics();
568:                footAngle_r.clearDynamics();
569:                footAngle_l.clearDynamics();
570:                legLo_r.clearDynamics();
571:                legLo_l.clearDynamics();
572:                legHi_r.clearDynamics();
573:                legHi_l.clearDynamics();
574:                legAngle_r.clearDynamics();
575:                legAngle_l.clearDynamics();
576:                tummyLo.clearDynamics();
577:                tummyHi.clearDynamics();
578:
579:                foot_r.setAffectedByGravity(true);
580:                footAngle_r.setAffectedByGravity(true);
581:                footAngle_l.setAffectedByGravity(true);
582:                legLo_r.setAffectedByGravity(true);
583:                legLo_l.setAffectedByGravity(true);
584:                legHi_r.setAffectedByGravity(true);
585:                legHi_l.setAffectedByGravity(true);
586:                legAngle_r.setAffectedByGravity(true);
587:                legAngle_l.setAffectedByGravity(true);
588:                tummyLo.setAffectedByGravity(true);
589:                tummyHi.setAffectedByGravity(true);
590:            }
591:
592:            public void set_position(float x, float y, float z) {
593:                keep_angle(0f);
594:                foot_r.getLocalRotation().set(0, 0, 0, 0);
595:                foot_r.getLocalTranslation().set(x - 0.6f, y, z + 0.4f);
596:                foot_l.getLocalRotation().set(0, 0, 0, 0);
597:                foot_l.getLocalTranslation().set(x + 0.6f, y, z + 0.4f);
598:                footAngle_r.getLocalRotation().set(0, 0, 0, 0);
599:                footAngle_r.getLocalTranslation().set(x - 0.6f,
600:                        y + 0.3f + 0.01f, z);
601:                footAngle_l.getLocalRotation().set(0, 0, 0, 0);
602:                footAngle_l.getLocalTranslation().set(x + 0.6f,
603:                        y + 0.3f + 0.01f, z);
604:                legLo_r.getLocalRotation().set(0, 0, 0, 0);
605:                legLo_r.getLocalTranslation().set(x - 0.6f, y + 1.44f + 0.02f,
606:                        z);
607:                legLo_l.getLocalRotation().set(0, 0, 0, 0);
608:                legLo_l.getLocalTranslation().set(x + 0.6f, y + 1.44f + 0.02f,
609:                        z);
610:                legHi_r.getLocalRotation().set(0, 0, 0, 0);
611:                legHi_r.getLocalTranslation().set(x - 0.6f, y + 3.48f + 0.03f,
612:                        z);
613:                legHi_l.getLocalRotation().set(0, 0, 0, 0);
614:                legHi_l.getLocalTranslation().set(x + 0.6f, y + 3.48f + 0.03f,
615:                        z);
616:                legAngle_r.getLocalRotation().set(0, 0, 0, 0);
617:                legAngle_r.getLocalTranslation().set(x - 0.6f,
618:                        y + 4.67f + 0.04f, z);
619:                legAngle_l.getLocalRotation().set(0, 0, 0, 0);
620:                legAngle_l.getLocalTranslation().set(x + 0.6f,
621:                        y + 4.67f + 0.04f, z);
622:                tummyLo.getLocalRotation().set(0f, 0.5f, 0.5f, 0);
623:                tummyLo.getLocalTranslation().set(x, y + 5.02f + 0.05f, z);
624:                tummyHi.getLocalRotation().set(0, 0, 0, 0);
625:                tummyHi.getLocalTranslation().set(x, y + 5.82f + 0.06f, z);
626:                keep_angle(0.2f);
627:            }
628:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.