01: /*
02: * SamplingTask.java
03: *
04: * Created on 25 maj 2007, 18:10
05: *
06: * To change this template, choose Tools | Template Manager
07: * and open the template in the editor.
08: */
09:
10: package jaimoves.util;
11:
12: import jaimoves.jaisimulation;
13: import java.util.Timer;
14: import java.util.TimerTask;
15: import com.jme.math.Vector3f;
16:
17: /**
18: *
19: * @author romek
20: */
21:
22: public class SamplingTask extends TimerTask {
23:
24: Vector3f currentPos = new Vector3f();
25:
26: private jaisimulation symulacja;
27:
28: /** Creates a new instance of SamplingTask */
29: public SamplingTask(jaisimulation sim) {
30: symulacja = sim;
31: currentPos = symulacja.getAktor().getCenterOfGravity();
32: symulacja.setLastPos(symulacja.getAktor().getCenterOfGravity());
33: System.out.println(symulacja.getLastPos().toString());
34: }
35:
36: public synchronized void run() {
37: while (true) {
38: try {
39: System.out.println("Dzialam wbrew pozorom");
40: wait(1000);
41: symulacja.setLastPos(currentPos);
42: currentPos = symulacja.getAktor().getCenterOfGravity();
43: symulacja.setCurrentPos(currentPos);
44: } catch (InterruptedException ex) {
45: }
46: }
47: }
48: }
|