1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
|
package NET.worlds.scape;
import java.io.IOException;
public class PostspinBehavior extends SpinBehavior implements FrameHandler {
private float xCenter;
private float yCenter;
private float zCenter;
private static Object classCookie = new Object();
public PostspinBehavior(float x, float y, float z, float cycleTime) {
this(x, y, z, 0.0F, 0.0F, 1.0F, cycleTime);
}
public PostspinBehavior(float x, float y, float z, float ax, float ay, float az) {
this(x, y, z, ax, ay, az, 5.0F);
}
public PostspinBehavior(float x, float y, float z, float ax, float ay, float az, float cycleTime) {
super(cycleTime, ax, ay, az);
this.xCenter = x;
this.yCenter = y;
this.zCenter = z;
}
public PostspinBehavior() {
}
public float getXCenter() {
return this.xCenter;
}
public float getYCenter() {
return this.yCenter;
}
public float getZCenter() {
return this.zCenter;
}
public Point3Temp getCenter() {
return Point3Temp.make(this.xCenter, this.yCenter, this.zCenter);
}
public void setXCenter(float c) {
this.xCenter = c;
}
public void setYCenter(float c) {
this.yCenter = c;
}
public void setZCenter(float c) {
this.zCenter = c;
}
public void setCenter(Point3Temp center) {
this.xCenter = center.x;
this.yCenter = center.y;
this.zCenter = center.z;
}
@Override
public boolean handle(FrameEvent e) {
if (this.enabled && this.cycleTime > 0.0F) {
e.receiver.moveBy(-this.xCenter, -this.yCenter, -this.zCenter);
e.receiver.postspin(this.ax, this.ay, this.az, 0.36F * e.dt / this.cycleTime);
e.receiver.moveBy(this.xCenter, this.yCenter, this.zCenter);
}
return true;
}
@Override
public Object properties(int index, int offset, int mode, Object value) throws NoSuchPropertyException {
Object ret = null;
switch (index - offset) {
case 0:
if (mode == 0) {
ret = Point3PropertyEditor.make(new Property(this, index, "Center"));
} else if (mode == 1) {
ret = new Point3(this.getCenter());
} else if (mode == 2) {
this.setCenter((Point3)value);
}
break;
default:
ret = super.properties(index, offset + 1, mode, value);
}
return ret;
}
@Override
public String toString() {
return super.toString()
+ "[center "
+ this.getCenter()
+ ", axis "
+ this.getAxis()
+ ", cycleTime "
+ this.cycleTime
+ ", enabled "
+ this.enabled
+ "]";
}
@Override
public void saveState(Saver s) throws IOException {
s.saveVersion(0, classCookie);
super.saveState(s);
s.saveFloat(this.xCenter);
s.saveFloat(this.yCenter);
s.saveFloat(this.zCenter);
}
@Override
public void restoreState(Restorer r) throws IOException, TooNewException {
switch (r.restoreVersion(classCookie)) {
case 0:
super.restoreState(r);
this.xCenter = r.restoreFloat();
this.yCenter = r.restoreFloat();
this.zCenter = r.restoreFloat();
return;
default:
throw new TooNewException();
}
}
}
|