diff options
| author | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-05-03 16:38:41 -0700 |
| commit | e1e781bb2135ef78592226f1a3eaba4925702f1f (patch) | |
| tree | 8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/MoveAction.java | |
| download | worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.tar.xz worlds.jar-e1e781bb2135ef78592226f1a3eaba4925702f1f.zip | |
Diffstat (limited to 'NET/worlds/scape/MoveAction.java')
| -rw-r--r-- | NET/worlds/scape/MoveAction.java | 622 |
1 files changed, 622 insertions, 0 deletions
diff --git a/NET/worlds/scape/MoveAction.java b/NET/worlds/scape/MoveAction.java new file mode 100644 index 0000000..0d7c61b --- /dev/null +++ b/NET/worlds/scape/MoveAction.java @@ -0,0 +1,622 @@ +/* */ package NET.worlds.scape; +/* */ +/* */ import NET.worlds.core.Std; +/* */ import java.io.IOException; +/* */ import java.util.Enumeration; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public class MoveAction +/* */ extends Action +/* */ { +/* */ int startTime; +/* 65 */ boolean killOthers = true; +/* */ +/* */ +/* 68 */ boolean killed = false; +/* */ +/* */ +/* 71 */ public int cycleTime = 1000; +/* */ +/* 73 */ public int cycles = 1; +/* 74 */ public boolean loopInfinite = false; +/* */ +/* 76 */ public Point3 startPoint = new Point3(); +/* 77 */ public Point3 startScale = new Point3(1.0F, 1.0F, 1.0F); +/* 78 */ public Point3 startSpin = new Point3(0.0F, 0.0F, -1.0F); +/* */ +/* */ public float startRotation; +/* */ +/* 82 */ public Point3 extentPoint = new Point3(); +/* 83 */ public Point3 extentScale = new Point3(1.0F, 1.0F, 1.0F); +/* 84 */ public Point3 extentSpin = new Point3(0.0F, 0.0F, -1.0F); +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public float extentRotation; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ protected Persister activeID; +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void noteAddingTo(SuperRoot owner) +/* */ { +/* 106 */ if ((this.startPoint.x == 0.0F) && (this.startPoint.y == 0.0F) && (this.startPoint.z == 0.0F) && +/* 107 */ (this.startScale.x == 1.0F) && (this.startScale.y == 1.0F) && (this.startScale.z == 1.0F) && +/* 108 */ (this.startSpin.x == 0.0F) && (this.startSpin.y == 0.0F) && (this.startSpin.z == -1.0F) && +/* 109 */ (this.startRotation == 0.0F)) { +/* 110 */ updateStored(true); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void updateStored(boolean start) +/* */ { +/* 120 */ Object owner = getOwner(); +/* 121 */ if ((owner == null) || (!(owner instanceof WObject))) +/* 122 */ return; +/* 123 */ WObject o = (WObject)owner; +/* */ +/* 125 */ if (!start) +/* */ { +/* 127 */ this.extentPoint.copy(o.getPosition()); +/* 128 */ this.extentScale.copy(o.getScale()); +/* 129 */ Point3Temp newSpin = Point3Temp.make(); +/* 130 */ endToExtent(o.getSpin(newSpin), newSpin); +/* */ } +/* */ else +/* */ { +/* 134 */ this.startPoint.copy(o.getPosition()); +/* 135 */ this.startScale.copy(o.getScale()); +/* 136 */ this.startRotation = o.getSpin(this.startSpin); +/* */ } +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void endToExtent(float rot, Point3Temp spinAxis) +/* */ { +/* 147 */ this.extentPoint.minus(this.startPoint); +/* 148 */ this.extentScale.dividedBy(this.startScale); +/* */ +/* */ +/* */ +/* 152 */ Transform t = Transform.make(); +/* 153 */ t.spin(spinAxis, rot); +/* 154 */ t.spin(this.startSpin, -this.startRotation); +/* 155 */ rot = t.getSpin(spinAxis); +/* 156 */ t.recycle(); +/* */ +/* */ +/* */ +/* 160 */ if (equivalentSpinAxises(spinAxis, this.extentSpin)) +/* */ { +/* 162 */ int wholeTurns = Math.round((this.extentRotation - rot) / 360.0F); +/* 163 */ this.extentRotation = (rot + wholeTurns * 360); +/* 164 */ } else if (equivalentSpinAxises(spinAxis, this.extentSpin.negate())) +/* */ { +/* 166 */ this.extentSpin.negate(); +/* 167 */ rot = -rot; +/* 168 */ int wholeTurns = Math.round((this.extentRotation - rot) / 360.0F); +/* 169 */ this.extentRotation = (rot + wholeTurns * 360); +/* */ } +/* */ else { +/* 172 */ this.extentSpin.copy(spinAxis); +/* 173 */ this.extentRotation = rot; +/* */ } +/* */ } +/* */ +/* */ private boolean equivalentSpinAxises(Point3Temp a, Point3Temp b) +/* */ { +/* 179 */ return Math.abs(a.x - b.x) + +/* 180 */ Math.abs(a.y - b.y) + +/* 181 */ Math.abs(a.z - b.z) < 0.001F; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void updateOwner(boolean start) +/* */ { +/* 190 */ Object owner = getOwner(); +/* 191 */ if ((owner == null) || (!(owner instanceof WObject))) +/* 192 */ return; +/* 193 */ WObject o = (WObject)owner; +/* */ +/* 195 */ o.makeIdentity(); +/* */ +/* 197 */ if (!start) +/* */ { +/* 199 */ o.spin(this.extentSpin, this.extentRotation); +/* 200 */ o.moveBy(this.extentPoint); +/* 201 */ o.scale(this.extentScale); +/* */ } +/* */ +/* 204 */ o.scale(this.startScale); +/* 205 */ o.spin(this.startSpin, this.startRotation); +/* 206 */ o.moveBy(this.startPoint); +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public void kill() +/* */ { +/* 217 */ this.killed = true; +/* */ } +/* */ +/* */ +/* */ +/* */ public boolean isRunning() +/* */ { +/* 224 */ return this.activeID != null; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Persister trigger(Event e, Persister seqID) +/* */ { +/* 236 */ Object owner = getOwner(); +/* 237 */ if ((owner == null) || (!(owner instanceof WObject))) +/* 238 */ return null; +/* 239 */ WObject o = (WObject)owner; +/* */ +/* 241 */ if (this.killed) +/* */ { +/* 243 */ this.killed = false; +/* 244 */ this.activeID = null; +/* 245 */ return null; +/* */ } +/* */ +/* */ +/* 249 */ if (seqID == null) +/* */ { +/* */ +/* 252 */ if (this.activeID != null) { +/* 253 */ return this.activeID; +/* */ } +/* 255 */ if (this.killOthers) +/* */ { +/* 257 */ Enumeration<Action> acts = o.getActions(); +/* 258 */ while (acts.hasMoreElements()) { +/* 259 */ Action a = (Action)acts.nextElement(); +/* 260 */ if ((a != this) && ((a instanceof MoveAction))) { +/* 261 */ MoveAction ma = (MoveAction)a; +/* 262 */ if (ma.isRunning()) +/* */ { +/* 264 */ ma.kill(); +/* */ } +/* */ } +/* */ } +/* */ } +/* */ +/* */ +/* 271 */ this.startTime = Std.getRealTime(); +/* 272 */ this.activeID = new SuperRoot(); +/* 273 */ seqID = this.activeID; +/* */ } +/* */ +/* */ +/* 277 */ if (seqID != this.activeID) { +/* 278 */ return null; +/* */ } +/* 280 */ int currentTime = Std.getRealTime(); +/* 281 */ int cycleNo = (currentTime - this.startTime) / this.cycleTime; +/* */ +/* 283 */ float frameLoc = 1.0F; +/* 284 */ if ((cycleNo >= this.cycles) && (!this.loopInfinite)) { +/* 285 */ this.activeID = null; +/* */ } else { +/* 287 */ frameLoc = (currentTime - this.startTime) % this.cycleTime / this.cycleTime; +/* */ } +/* 289 */ (o instanceof Camera); +/* */ +/* */ +/* */ +/* */ +/* 294 */ if ((o instanceof PosableDrone)) +/* */ { +/* */ +/* */ +/* */ +/* */ +/* */ +/* 301 */ float yaw = -(this.startRotation + this.extentRotation * frameLoc); +/* 302 */ Point3Temp dest = Point3Temp.make(this.extentPoint) +/* 303 */ .times(frameLoc) +/* 304 */ .plus(this.startPoint); +/* 305 */ o.makeIdentity().moveTo(dest).yaw(yaw); +/* */ } else { +/* 307 */ o.makeIdentity(); +/* */ +/* */ +/* */ +/* 311 */ o.spin(this.extentSpin, this.extentRotation * frameLoc); +/* 312 */ o.spin(this.startSpin, this.startRotation); +/* */ +/* 314 */ Point3Temp p = Point3Temp.make( +/* 315 */ (float)Math.pow(this.extentScale.x, frameLoc), +/* 316 */ (float)Math.pow(this.extentScale.y, frameLoc), +/* 317 */ (float)Math.pow(this.extentScale.z, frameLoc)); +/* 318 */ o.scale(p.times(this.startScale)); +/* 319 */ o.moveTo(Point3Temp.make(this.extentPoint) +/* 320 */ .times(frameLoc) +/* 321 */ .plus(this.startPoint)); +/* */ } +/* */ +/* 324 */ return this.activeID; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* */ +/* */ public Object properties(int index, int offset, int mode, Object value) +/* */ throws NoSuchPropertyException +/* */ { +/* 334 */ Object ret = null; +/* 335 */ switch (index - offset) { +/* */ case 0: +/* 337 */ if (mode == 0) { +/* 338 */ ret = FloatPropertyEditor.make( +/* 339 */ new Property(this, index, "Cycle Time (in seconds)")); +/* 340 */ } else if (mode == 1) { +/* 341 */ ret = new Float(this.cycleTime / 1000.0F); +/* 342 */ } else if (mode == 2) +/* 343 */ this.cycleTime = ((int)(1000.0F * ((Float)value).floatValue())); +/* 344 */ break; +/* */ case 1: +/* 346 */ if (mode == 0) { +/* 347 */ ret = IntegerPropertyEditor.make( +/* 348 */ new Property(this, index, "Cycles")); +/* 349 */ } else if (mode == 1) { +/* 350 */ ret = new Integer(this.cycles); +/* 351 */ } else if (mode == 2) +/* 352 */ this.cycles = ((Integer)value).intValue(); +/* 353 */ break; +/* */ case 2: +/* 355 */ if (mode == 0) { +/* 356 */ ret = IntegerPropertyEditor.make( +/* 357 */ new Property(this, index, +/* 358 */ "Copy Start/End 1/2:Action->Owner 3/4:Owner->Action")); +/* 359 */ } else if (mode == 1) { +/* 360 */ ret = new Integer(0); +/* 361 */ } else if (mode == 2) +/* */ { +/* 363 */ switch (((Integer)value).intValue()) { +/* */ case 1: +/* 365 */ updateOwner(true); break; +/* 366 */ case 2: updateOwner(false); break; +/* 367 */ case 3: updateStored(true); break; +/* 368 */ case 4: updateStored(false); +/* */ } +/* */ } +/* 371 */ break; +/* */ case 3: +/* 373 */ if (mode == 0) { +/* 374 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 375 */ "Translation Extent")); +/* 376 */ } else if (mode == 1) { +/* 377 */ ret = new Point3(this.extentPoint); +/* 378 */ } else if (mode == 2) +/* 379 */ this.extentPoint.copy((Point3)value); +/* 380 */ break; +/* */ case 4: +/* 382 */ if (mode == 0) { +/* 383 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 384 */ "Scale Extent")); +/* 385 */ } else if (mode == 1) { +/* 386 */ ret = new Point3(this.extentScale); +/* 387 */ } else if (mode == 2) +/* 388 */ this.extentScale.copy((Point3)value); +/* 389 */ break; +/* */ case 5: +/* 391 */ if (mode == 0) { +/* 392 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 393 */ "Spin Axis For Extent")); +/* 394 */ } else if (mode == 1) { +/* 395 */ Point3 p = new Point3(this.extentSpin); +/* */ +/* 397 */ p.x = (Math.round(p.x * 10000.0F) / 10000.0F); +/* 398 */ p.y = (Math.round(p.y * 10000.0F) / 10000.0F); +/* 399 */ p.z = (Math.round(p.z * 10000.0F) / 10000.0F); +/* 400 */ ret = p; +/* */ } +/* 402 */ else if (mode == 2) { +/* 403 */ this.extentSpin.copy((Point3)value); } +/* 404 */ break; +/* */ case 6: +/* 406 */ if (mode == 0) { +/* 407 */ ret = FloatPropertyEditor.make(new Property(this, index, +/* 408 */ "Extent Rotation Amount")); +/* 409 */ } else if (mode == 1) { +/* 410 */ ret = new Float(this.extentRotation); +/* 411 */ } else if (mode == 2) +/* 412 */ this.extentRotation = ((Float)value).floatValue(); +/* 413 */ break; +/* */ case 7: +/* 415 */ if (mode == 0) { +/* 416 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 417 */ "Start Point")); +/* 418 */ } else if (mode == 1) { +/* 419 */ ret = new Point3(this.startPoint); +/* 420 */ } else if (mode == 2) +/* 421 */ this.startPoint.copy((Point3)value); +/* 422 */ break; +/* */ case 8: +/* 424 */ if (mode == 0) { +/* 425 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 426 */ "Start Scale")); +/* 427 */ } else if (mode == 1) { +/* 428 */ ret = new Point3(this.startScale); +/* 429 */ } else if (mode == 2) +/* 430 */ this.startScale.copy((Point3)value); +/* 431 */ break; +/* */ case 9: +/* 433 */ if (mode == 0) { +/* 434 */ ret = Point3PropertyEditor.make(new Property(this, index, +/* 435 */ "Start Spin")); +/* 436 */ } else if (mode == 1) { +/* 437 */ ret = new Point3(this.startSpin); +/* 438 */ } else if (mode == 2) +/* 439 */ this.startSpin.copy((Point3)value); +/* 440 */ break; +/* */ case 10: +/* 442 */ if (mode == 0) { +/* 443 */ ret = FloatPropertyEditor.make(new Property(this, index, +/* 444 */ "Start Rotation")); +/* 445 */ } else if (mode == 1) { +/* 446 */ ret = new Float(this.startRotation); +/* 447 */ } else if (mode == 2) +/* 448 */ this.startRotation = ((Float)value).floatValue(); +/* 449 */ break; +/* */ case 11: +/* 451 */ if (mode == 0) { +/* 452 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 453 */ "Kill Other Move Actions"), +/* 454 */ "Let other moves finish", +/* 455 */ "Kill other move actions"); +/* 456 */ } else if (mode == 1) { +/* 457 */ ret = new Boolean(this.killOthers); +/* 458 */ } else if (mode == 2) +/* 459 */ this.killOthers = ((Boolean)value).booleanValue(); +/* 460 */ break; +/* */ case 12: +/* 462 */ if (mode == 0) { +/* 463 */ ret = BooleanPropertyEditor.make(new Property(this, index, +/* 464 */ "Loop Infinite"), +/* 465 */ "False", +/* 466 */ "True"); +/* 467 */ } else if (mode == 1) { +/* 468 */ ret = new Boolean(this.loopInfinite); +/* 469 */ } else if (mode == 2) +/* 470 */ this.loopInfinite = ((Boolean)value).booleanValue(); +/* 471 */ break; +/* */ default: +/* 473 */ ret = super.properties(index, offset + 13, mode, value); +/* */ } +/* 475 */ return ret; +/* */ } +/* */ +/* */ public String toString() +/* */ { +/* 480 */ String retVal = super.toString() + +/* 481 */ "[cycleTime " + this.cycleTime / 1000.0F + ", cycles " + this.cycles + ","; +/* 482 */ if (!this.loopInfinite) +/* */ { +/* 484 */ retVal = retVal + " not "; +/* */ } +/* 486 */ retVal = retVal + " Infinite ]"; +/* 487 */ return retVal; +/* */ } +/* */ +/* */ +/* */ +/* */ +/* 493 */ private static Object classCookie = new Object(); +/* */ +/* */ public void saveState(Saver s) throws IOException +/* */ { +/* 497 */ s.saveVersion(6, classCookie); +/* 498 */ super.saveState(s); +/* */ +/* 500 */ s.saveBoolean(this.loopInfinite); +/* 501 */ s.saveInt(this.cycleTime); +/* 502 */ s.saveInt(this.cycles); +/* 503 */ s.save(this.extentPoint); +/* 504 */ s.save(this.startPoint); +/* 505 */ s.save(this.extentScale); +/* 506 */ s.save(this.startScale); +/* 507 */ s.save(this.extentSpin); +/* 508 */ s.save(this.startSpin); +/* 509 */ s.saveFloat(this.extentRotation); +/* 510 */ s.saveFloat(this.startRotation); +/* 511 */ s.saveBoolean(this.killOthers); +/* */ } +/* */ +/* */ public void restoreState(Restorer r) throws IOException, TooNewException +/* */ { +/* 516 */ restoreStateMoveActionHelper(r, classCookie); +/* */ } +/* */ +/* */ public void restoreStateMoveActionHelper(Restorer r, Object cookie) +/* */ throws IOException, TooNewException +/* */ { +/* 522 */ switch (r.restoreVersion(cookie)) { +/* */ case 6: +/* 524 */ super.restoreState(r); +/* 525 */ this.loopInfinite = r.restoreBoolean(); +/* 526 */ this.cycleTime = r.restoreInt(); +/* 527 */ this.cycles = r.restoreInt(); +/* */ +/* 529 */ this.extentPoint = ((Point3)r.restore()); +/* 530 */ this.startPoint = ((Point3)r.restore()); +/* 531 */ this.extentScale = ((Point3)r.restore()); +/* 532 */ this.startScale = ((Point3)r.restore()); +/* 533 */ this.extentSpin = ((Point3)r.restore()); +/* 534 */ this.startSpin = ((Point3)r.restore()); +/* */ +/* 536 */ this.extentRotation = r.restoreFloat(); +/* 537 */ this.startRotation = r.restoreFloat(); +/* 538 */ this.killOthers = r.restoreBoolean(); +/* 539 */ break; +/* */ case 5: +/* 541 */ super.restoreState(r); +/* 542 */ this.cycleTime = r.restoreInt(); +/* 543 */ this.cycles = r.restoreInt(); +/* 544 */ this.loopInfinite = (this.cycles == 0); +/* */ +/* 546 */ this.extentPoint = ((Point3)r.restore()); +/* 547 */ this.startPoint = ((Point3)r.restore()); +/* 548 */ this.extentScale = ((Point3)r.restore()); +/* 549 */ this.startScale = ((Point3)r.restore()); +/* 550 */ this.extentSpin = ((Point3)r.restore()); +/* 551 */ this.startSpin = ((Point3)r.restore()); +/* */ +/* 553 */ this.extentRotation = r.restoreFloat(); +/* 554 */ this.startRotation = r.restoreFloat(); +/* 555 */ this.killOthers = r.restoreBoolean(); +/* 556 */ break; +/* */ case 3: +/* */ case 4: +/* 559 */ r.setOldFlag(); +/* 560 */ super.restoreState(r); +/* 561 */ this.cycleTime = r.restoreInt(); +/* 562 */ this.cycles = r.restoreInt(); +/* 563 */ this.loopInfinite = (this.cycles == 0); +/* 564 */ this.extentPoint = ((Point3)r.restore()); +/* 565 */ this.startPoint = ((Point3)r.restore()); +/* 566 */ this.extentScale = ((Point3)r.restore()); +/* 567 */ this.startScale = ((Point3)r.restore()); +/* 568 */ this.extentSpin = ((Point3)r.restore()); +/* 569 */ this.startSpin = ((Point3)r.restore()); +/* */ +/* 571 */ this.extentRotation = r.restoreFloat(); +/* 572 */ this.startRotation = r.restoreFloat(); +/* 573 */ break; +/* */ case 2: +/* 575 */ r.setOldFlag(); +/* 576 */ super.restoreState(r); +/* 577 */ this.cycleTime = r.restoreInt(); +/* 578 */ this.cycles = r.restoreInt(); +/* 579 */ this.loopInfinite = (this.cycles == 0); +/* 580 */ this.extentPoint = ((Point3)r.restore()); +/* 581 */ this.startPoint = ((Point3)r.restore()); +/* 582 */ this.extentScale = ((Point3)r.restore()); +/* 583 */ this.startScale = ((Point3)r.restore()); +/* 584 */ this.extentSpin = ((Point3)r.restore()); +/* 585 */ this.startSpin = ((Point3)r.restore()); +/* */ +/* 587 */ this.extentRotation = r.restoreFloat(); +/* 588 */ this.startRotation = r.restoreFloat(); +/* */ +/* 590 */ r.restoreBoolean(); +/* 591 */ break; +/* */ case 1: +/* 593 */ super.restoreState(r); +/* */ case 0: +/* 595 */ r.setOldFlag(); +/* 596 */ this.cycleTime = ((int)r.restoreFloat()); +/* 597 */ this.cycles = r.restoreInt(); +/* 598 */ this.loopInfinite = (this.cycles == 0); +/* 599 */ this.extentPoint = ((Point3)r.restore()); +/* 600 */ this.startPoint = ((Point3)r.restore()); +/* 601 */ this.extentScale = ((Point3)r.restore()); +/* 602 */ this.startScale = ((Point3)r.restore()); +/* 603 */ this.extentSpin = ((Point3)r.restore()); +/* 604 */ this.startSpin = ((Point3)r.restore()); +/* */ +/* 606 */ this.extentRotation = r.restoreFloat(); +/* 607 */ this.startRotation = r.restoreFloat(); +/* */ +/* 609 */ this.extentPoint.minus(this.startPoint); +/* 610 */ this.extentScale.dividedBy(this.startScale); +/* 611 */ break; +/* */ default: +/* 613 */ throw new TooNewException(); +/* */ } +/* */ } +/* */ } + + +/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\MoveAction.class + * Java compiler version: 6 (50.0) + * JD-Core Version: 0.7.1 + */
\ No newline at end of file |