/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.core.Std; /* */ import java.io.IOException; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class RelativeMoveAction /* */ extends Action /* */ { /* */ int startTime; /* 59 */ public int cycleTime = 1000; /* */ /* 61 */ public int cycles = 1; /* 62 */ public boolean loopInfinite = false; /* */ /* */ /* 65 */ public Point3 extentPoint = new Point3(); /* 66 */ public Point3 extentScale = new Point3(1.0F, 1.0F, 1.0F); /* 67 */ public Point3 extentSpin = new Point3(0.0F, 0.0F, -1.0F); /* 68 */ public float extentRotation = 0.0F; /* */ /* */ /* */ /* */ /* */ public float accumulatedRotation; /* */ /* */ /* */ /* */ /* */ public Point3 accumulatedScale; /* */ /* */ /* */ /* */ /* */ public Point3 accumulatedPoint; /* */ /* */ /* */ /* */ /* */ protected Persister activeID; /* */ /* */ /* */ /* */ /* */ /* */ public Persister trigger(Event e, Persister seqID) /* */ { /* 96 */ Object owner = getOwner(); /* 97 */ if ((owner == null) || (!(owner instanceof WObject))) /* 98 */ return null; /* 99 */ WObject o = (WObject)owner; /* */ /* */ /* 102 */ if (seqID == null) /* */ { /* */ /* 105 */ if (this.activeID != null) { /* 106 */ return this.activeID; /* */ } /* */ /* 109 */ this.startTime = Std.getRealTime(); /* 110 */ this.activeID = new SuperRoot(); /* 111 */ seqID = this.activeID; /* 112 */ this.accumulatedRotation = 0.0F; /* 113 */ this.accumulatedPoint = new Point3(0.0F, 0.0F, 0.0F); /* 114 */ this.accumulatedScale = new Point3(1.0F, 1.0F, 1.0F); /* */ } /* */ /* */ /* 118 */ if (seqID != this.activeID) /* 119 */ return null; /* 120 */ int currentTime = Std.getRealTime(); /* 121 */ int cycleNo = (currentTime - this.startTime) / this.cycleTime; /* */ /* 123 */ float frameLoc = 1.0F; /* 124 */ if ((cycleNo >= this.cycles) && (!this.loopInfinite)) { /* 125 */ this.activeID = null; /* */ } else { /* 127 */ frameLoc = (currentTime - this.startTime) % this.cycleTime / this.cycleTime; /* */ } /* */ /* */ /* 131 */ float tmpSpin = this.extentRotation * frameLoc; /* 132 */ o.spin(this.extentSpin, tmpSpin - this.accumulatedRotation); /* 133 */ this.accumulatedRotation = tmpSpin; /* */ /* 135 */ Point3 tmpScale = new Point3( /* 136 */ (float)Math.pow(this.extentScale.x, frameLoc), /* 137 */ (float)Math.pow(this.extentScale.y, frameLoc), /* 138 */ (float)Math.pow(this.extentScale.z, frameLoc)); /* 139 */ o.scale(Point3Temp.make(tmpScale).dividedBy(this.accumulatedScale)); /* 140 */ this.accumulatedScale = tmpScale; /* */ /* 142 */ Point3 tmpPoint = new Point3(Point3Temp.make(this.extentPoint) /* 143 */ .times(frameLoc)); /* 144 */ o.moveBy(Point3Temp.make(tmpPoint) /* 145 */ .minus(this.accumulatedPoint)); /* 146 */ this.accumulatedPoint = tmpPoint; /* */ /* 148 */ return this.activeID; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 158 */ Object ret = null; /* 159 */ switch (index - offset) { /* */ case 0: /* 161 */ if (mode == 0) { /* 162 */ ret = FloatPropertyEditor.make( /* 163 */ new Property(this, index, "Cycle Time (in seconds)")); /* 164 */ } else if (mode == 1) { /* 165 */ ret = new Float(this.cycleTime / 1000.0F); /* 166 */ } else if (mode == 2) /* 167 */ this.cycleTime = ((int)(1000.0F * ((Float)value).floatValue())); /* 168 */ break; /* */ case 1: /* 170 */ if (mode == 0) { /* 171 */ ret = IntegerPropertyEditor.make( /* 172 */ new Property(this, index, "Cycles")); /* 173 */ } else if (mode == 1) { /* 174 */ ret = new Integer(this.cycles); /* 175 */ } else if (mode == 2) /* 176 */ this.cycles = ((Integer)value).intValue(); /* 177 */ break; /* */ case 2: /* 179 */ if (mode == 0) { /* 180 */ ret = BooleanPropertyEditor.make(new Property(this, index, /* 181 */ "Loop Infinite"), "False", "True"); /* 182 */ } else if (mode == 1) { /* 183 */ ret = new Boolean(this.loopInfinite); /* 184 */ } else if (mode == 2) /* 185 */ this.loopInfinite = ((Boolean)value).booleanValue(); /* 186 */ break; /* */ case 3: /* 188 */ if (mode == 0) { /* 189 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 190 */ "Translation Extent")); /* 191 */ } else if (mode == 1) { /* 192 */ ret = new Point3(this.extentPoint); /* 193 */ } else if (mode == 2) /* 194 */ this.extentPoint.copy((Point3)value); /* 195 */ break; /* */ case 4: /* 197 */ if (mode == 0) { /* 198 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 199 */ "Scale Extent")); /* 200 */ } else if (mode == 1) { /* 201 */ ret = new Point3(this.extentScale); /* 202 */ } else if (mode == 2) /* 203 */ this.extentScale.copy((Point3)value); /* 204 */ break; /* */ case 5: /* 206 */ if (mode == 0) { /* 207 */ ret = Point3PropertyEditor.make(new Property(this, index, /* 208 */ "Spin Axis For Extent")); /* 209 */ } else if (mode == 1) { /* 210 */ Point3 p = new Point3(this.extentSpin); /* */ /* 212 */ p.x = (Math.round(p.x * 10000.0F) / 10000.0F); /* 213 */ p.y = (Math.round(p.y * 10000.0F) / 10000.0F); /* 214 */ p.z = (Math.round(p.z * 10000.0F) / 10000.0F); /* 215 */ ret = p; /* */ } /* 217 */ else if (mode == 2) { /* 218 */ this.extentSpin.copy((Point3)value); } /* 219 */ break; /* */ case 6: /* 221 */ if (mode == 0) { /* 222 */ ret = FloatPropertyEditor.make(new Property(this, index, /* 223 */ "Extent Rotation Amount")); /* 224 */ } else if (mode == 1) { /* 225 */ ret = new Float(this.extentRotation); /* 226 */ } else if (mode == 2) /* 227 */ this.extentRotation = ((Float)value).floatValue(); /* 228 */ break; /* */ default: /* 230 */ ret = super.properties(index, offset + 7, mode, value); /* */ } /* 232 */ return ret; /* */ } /* */ /* */ public String toString() /* */ { /* 237 */ String retVal = super.toString() + /* 238 */ "[cycleTime " + this.cycleTime / 1000.0F + ", cycles " + this.cycles + ", "; /* 239 */ if (!this.loopInfinite) /* 240 */ retVal = retVal + " NOT"; /* 241 */ retVal = retVal + " Infinite]"; /* */ /* 243 */ return retVal; /* */ } /* */ /* */ /* */ /* */ /* 249 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 253 */ s.saveVersion(5, classCookie); /* 254 */ super.saveState(s); /* */ /* 256 */ s.saveBoolean(this.loopInfinite); /* 257 */ s.saveInt(this.cycleTime); /* 258 */ s.saveInt(this.cycles); /* 259 */ s.save(this.extentPoint); /* 260 */ s.save(this.extentScale); /* 261 */ s.save(this.extentSpin); /* 262 */ s.saveFloat(this.extentRotation); /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 267 */ switch (r.restoreVersion(classCookie)) { /* */ case 5: /* 269 */ super.restoreState(r); /* 270 */ this.loopInfinite = r.restoreBoolean(); /* 271 */ this.cycleTime = r.restoreInt(); /* 272 */ this.cycles = r.restoreInt(); /* 273 */ this.extentPoint = ((Point3)r.restore()); /* 274 */ this.extentScale = ((Point3)r.restore()); /* 275 */ this.extentSpin = ((Point3)r.restore()); /* */ /* 277 */ this.extentRotation = r.restoreFloat(); /* 278 */ break; /* */ case 4: /* 280 */ super.restoreState(r); /* 281 */ this.cycleTime = r.restoreInt(); /* 282 */ this.cycles = r.restoreInt(); /* */ /* 284 */ this.extentPoint = ((Point3)r.restore()); /* 285 */ this.extentScale = ((Point3)r.restore()); /* 286 */ this.extentSpin = ((Point3)r.restore()); /* */ /* 288 */ this.extentRotation = r.restoreFloat(); /* 289 */ break; /* */ /* */ default: /* 292 */ throw new TooNewException(); /* */ } /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\RelativeMoveAction.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */