summaryrefslogtreecommitdiff
path: root/NET/worlds/scape/Motion.java
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-05-03 16:38:41 -0700
committerFuwn <[email protected]>2021-05-03 16:38:41 -0700
commite1e781bb2135ef78592226f1a3eaba4925702f1f (patch)
tree8a5b590463ed413e1c6eabb719130e701b95ca63 /NET/worlds/scape/Motion.java
downloadworlds.jar-main.tar.xz
worlds.jar-main.zip
:star:HEADmain
Diffstat (limited to 'NET/worlds/scape/Motion.java')
-rw-r--r--NET/worlds/scape/Motion.java484
1 files changed, 484 insertions, 0 deletions
diff --git a/NET/worlds/scape/Motion.java b/NET/worlds/scape/Motion.java
new file mode 100644
index 0000000..32367ff
--- /dev/null
+++ b/NET/worlds/scape/Motion.java
@@ -0,0 +1,484 @@
+/* */ package NET.worlds.scape;
+/* */
+/* */ import NET.worlds.console.Console;
+/* */ import java.io.IOException;
+/* */ import java.io.PrintStream;
+/* */ import java.text.MessageFormat;
+/* */ import java.util.Date;
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ class Motion
+/* */ extends TriggeredSwitchableBehavior
+/* */ implements FrameHandler, Persister, MouseDownHandler, BumpHandler
+/* */ {
+/* */ long startMotionTime;
+/* */ protected float cycleTime;
+/* */ protected String frameList;
+/* */ protected int cycles;
+/* */ protected Transform motionTransform;
+/* */ protected Point3 startPoint;
+/* */ protected Point3 endPoint;
+/* */ protected Point3 deltaPoint;
+/* */ protected Point3 startScale;
+/* */ protected Point3 endScale;
+/* */ protected Point3 deltaScale;
+/* */ protected Point3 startSpin;
+/* */ protected Point3 endSpin;
+/* */ protected Point3 currentSpin;
+/* */ protected float startRotation;
+/* */ protected float endRotation;
+/* */ protected float currentRotation;
+/* */ protected boolean motionTransformInitialized;
+/* */ protected boolean variableInitialized;
+/* 38 */ protected boolean motionEnd = true;
+/* */
+/* */
+/* */ public Motion()
+/* */ {
+/* 43 */ this.cycleTime = 1000.0F;
+/* 44 */ this.trigger = new String("none");
+/* 45 */ this.externalTriggerTag = new String("");
+/* 46 */ this.cycles = 0;
+/* 47 */ this.motionTransformInitialized = false;
+/* 48 */ this.variableInitialized = false;
+/* 49 */ this.startPoint = new Point3();
+/* 50 */ this.endPoint = new Point3();
+/* 51 */ this.deltaPoint = new Point3();
+/* 52 */ this.startScale = new Point3();
+/* 53 */ this.endScale = new Point3();
+/* 54 */ this.deltaScale = new Point3();
+/* 55 */ this.startSpin = new Point3();
+/* 56 */ this.endSpin = new Point3();
+/* 57 */ this.currentSpin = new Point3();
+/* */
+/* 59 */ startMotion();
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void ExternalTrigger(Trigger trigger_source, int sequence_no, int event_no)
+/* */ {
+/* 67 */ this.trigger_source = trigger_source;
+/* 68 */ this.sequence_no = sequence_no;
+/* 69 */ this.event_no = event_no;
+/* 70 */ startMotion();
+/* */ }
+/* */
+/* */ public boolean equivalent(Point3Temp a, Point3Temp b)
+/* */ {
+/* 75 */ if ((Math.round(a.x) == Math.round(b.x)) &&
+/* 76 */ (Math.round(a.y) == Math.round(b.y)) &&
+/* 77 */ (Math.round(a.z) == Math.round(b.z))) {
+/* 78 */ return true;
+/* */ }
+/* 80 */ return false;
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void startMotion()
+/* */ {
+/* 88 */ if ((this.motionTransform != null) &&
+/* 89 */ (equivalent(this.startPoint, this.motionTransform.getPosition())) &&
+/* 90 */ (Math.round(this.startScale.x) ==
+/* 91 */ Math.round(this.motionTransform.getTotalScale())))
+/* */ {
+/* 93 */ this.currentRotation = Math.round(this.motionTransform.getSpin(
+/* 94 */ this.currentSpin));
+/* 95 */ this.startRotation = Math.round(this.startRotation);
+/* */
+/* 97 */ if (((this.startRotation != this.currentRotation) &&
+/* 98 */ (this.startRotation - 360.0F != this.currentRotation)) || (
+/* 99 */ (equivalent(this.startSpin, this.currentSpin)) || (
+/* 100 */ ((-this.startRotation == this.currentRotation) ||
+/* 101 */ (360.0F - this.startRotation == this.currentRotation)) &&
+/* 102 */ (equivalent(this.startSpin, this.currentSpin.negate())))))
+/* */ {
+/* 104 */ Date timer = new Date();
+/* 105 */ this.startMotionTime = timer.getTime();
+/* 106 */ this.motionEnd = true;
+/* */ }
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public boolean handle(FrameEvent e)
+/* */ {
+/* 122 */ if (!this.motionTransformInitialized) {
+/* 123 */ this.motionTransform = e.target;
+/* 124 */ this.motionTransformInitialized = true;
+/* */ }
+/* 126 */ if (!this.variableInitialized) {
+/* 127 */ this.startPoint.copy(this.motionTransform.getPosition());
+/* 128 */ this.endPoint.copy(this.startPoint);
+/* 129 */ this.startScale.x = this.motionTransform.getTotalScale();
+/* 130 */ this.startScale.y = this.motionTransform.getTotalScale();
+/* 131 */ this.startScale.z = this.motionTransform.getTotalScale();
+/* 132 */ this.endScale.copy(this.startScale);
+/* */
+/* 134 */ this.startRotation = this.motionTransform.getSpin(this.startSpin);
+/* 135 */ this.endRotation = 0.0F;
+/* 136 */ this.variableInitialized = true;
+/* */ }
+/* */
+/* 139 */ if (this.enabled)
+/* */ {
+/* 141 */ Date timer = new Date();
+/* 142 */ long currentTime = timer.getTime();
+/* 143 */ float frameLoc = (float)(-this.startMotionTime + currentTime) %
+/* 144 */ this.cycleTime / this.cycleTime;
+/* 145 */ int cycleNo = (int)((float)(-this.startMotionTime + currentTime) / this.cycleTime);
+/* */
+/* 147 */ if ((cycleNo < this.cycles) || (this.cycles == 0) || (!this.motionEnd))
+/* */ {
+/* */
+/* 150 */ this.motionEnd = false;
+/* 151 */ if ((cycleNo >= this.cycles) && (this.cycles != 0)) {
+/* 152 */ this.motionEnd = true;
+/* 153 */ frameLoc = 1.0F;
+/* 154 */ if (this.trigger_source != null) {
+/* 155 */ this.trigger_source.registerFinishedTriggerTag(this.sequence_no,
+/* 156 */ this.event_no);
+/* */ }
+/* */ }
+/* 159 */ e.receiver.makeIdentity();
+/* 160 */ e.receiver.scale(
+/* 161 */ this.startScale.x + (this.endScale.x - this.startScale.x) * frameLoc,
+/* 162 */ this.startScale.x + (this.endScale.x - this.startScale.x) * frameLoc,
+/* 163 */ this.startScale.x + (this.endScale.x - this.startScale.x) * frameLoc);
+/* */
+/* 165 */ e.receiver.moveTo(
+/* 166 */ this.startPoint.x + (this.endPoint.x - this.startPoint.x) * frameLoc,
+/* 167 */ this.startPoint.y + (this.endPoint.y - this.startPoint.y) * frameLoc,
+/* 168 */ this.startPoint.z + (this.endPoint.z - this.startPoint.z) * frameLoc);
+/* */
+/* 170 */ e.receiver.spin(this.startSpin, this.startRotation);
+/* 171 */ e.receiver.spin(this.endSpin, this.endRotation * frameLoc);
+/* */ }
+/* */ }
+/* */
+/* 175 */ return true;
+/* */ }
+/* */
+/* */ public boolean handle(MouseDownEvent e)
+/* */ {
+/* 180 */ if ((this.enabled) &&
+/* 181 */ (this.trigger.equals("click"))) {
+/* 182 */ startMotion();
+/* */ }
+/* */
+/* 185 */ return true;
+/* */ }
+/* */
+/* */ public boolean handle(BumpEventTemp e)
+/* */ {
+/* 190 */ if ((this.enabled) &&
+/* 191 */ (this.trigger.equals("bump"))) {
+/* 192 */ startMotion();
+/* */ }
+/* */
+/* 195 */ return true;
+/* */ }
+/* */
+/* */
+/* */ public void startTransform()
+/* */ {
+/* 201 */ if (this.motionTransform != null) {
+/* 202 */ this.motionTransform.makeIdentity();
+/* 203 */ this.motionTransform.scale(this.startScale.x, this.startScale.x, this.startScale.x);
+/* 204 */ this.motionTransform.moveTo(this.startPoint.x, this.startPoint.y, this.startPoint.z);
+/* */
+/* 206 */ this.motionTransform.spin(this.startSpin, this.startRotation);
+/* */ } else {
+/* 208 */ System.out.println("motionTransform is null!!!!");
+/* */ }
+/* */ }
+/* */
+/* */ public void endTransform()
+/* */ {
+/* 214 */ if (this.motionTransform != null) {
+/* 215 */ this.motionTransform.makeIdentity();
+/* 216 */ this.motionTransform.scale(this.endScale.x, this.endScale.x, this.endScale.x);
+/* 217 */ this.motionTransform.moveTo(this.endPoint.x, this.endPoint.y, this.endPoint.z);
+/* */
+/* 219 */ this.motionTransform.spin(this.startSpin, this.startRotation);
+/* 220 */ this.motionTransform.spin(this.endSpin, this.endRotation);
+/* */ } else {
+/* 222 */ System.out.println("motionTransform is null!!!!");
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */
+/* */ public Object properties(int index, int offset, int mode, Object value)
+/* */ throws NoSuchPropertyException
+/* */ {
+/* 233 */ Object ret = null;
+/* 234 */ switch (index - offset) {
+/* */ case 0:
+/* 236 */ if (mode == 0)
+/* 237 */ ret = new ClassProperty(this, index, "Motion");
+/* 238 */ break;
+/* */ case 1:
+/* 240 */ if (mode == 0) {
+/* 241 */ ret = FloatPropertyEditor.make(
+/* 242 */ new Property(this, index, "Cycle Time"));
+/* 243 */ } else if (mode == 1) {
+/* 244 */ ret = new Float(this.cycleTime);
+/* 245 */ } else if (mode == 2)
+/* 246 */ this.cycleTime = ((Float)value).floatValue();
+/* 247 */ break;
+/* */ case 2:
+/* 249 */ if (mode == 0) {
+/* 250 */ ret = IntegerPropertyEditor.make(
+/* 251 */ new Property(this, index, "Cycles"));
+/* 252 */ } else if (mode == 1) {
+/* 253 */ ret = new Integer(this.cycles);
+/* 254 */ } else if (mode == 2)
+/* 255 */ this.cycles = ((Integer)value).intValue();
+/* 256 */ break;
+/* */ case 3:
+/* 258 */ if (mode == 0) {
+/* 259 */ ret = StringPropertyEditor.make(
+/* 260 */ new Property(this, index, "Trigger"));
+/* 261 */ } else if (mode == 1) {
+/* 262 */ ret = new String(this.trigger);
+/* 263 */ } else if (mode == 2) {
+/* 264 */ this.trigger = ((String)value).toString().trim();
+/* 265 */ if (this.trigger.equals("external")) {
+/* 266 */ Trigger.TriggeredSwitchableBehaviorList[
+/* 267 */ Trigger.TriggeredSwitchableBehaviorListCount] = this;
+/* 268 */ Trigger.TriggeredSwitchableBehaviorListCount += 1;
+/* */ }
+/* */ }
+/* 271 */ break;
+/* */ case 4:
+/* 273 */ if (mode == 0) {
+/* 274 */ ret = StringPropertyEditor.make(
+/* 275 */ new Property(this, index, "External Trigger Tag"));
+/* 276 */ } else if (mode == 1) {
+/* 277 */ ret = new String(this.externalTriggerTag);
+/* 278 */ } else if (mode == 2) {
+/* 279 */ this.externalTriggerTag = ((String)value).toString().trim();
+/* */ }
+/* 281 */ break;
+/* */ case 5:
+/* 283 */ if (mode == 0) {
+/* 284 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 285 */ "End Point"));
+/* 286 */ } else if (mode == 1) {
+/* 287 */ ret = new Point3(this.endPoint);
+/* 288 */ endTransform();
+/* */ }
+/* 290 */ else if (mode == 2) {
+/* 291 */ this.endPoint.copy((Point3)value);
+/* 292 */ endTransform();
+/* */ }
+/* 294 */ break;
+/* */ case 6:
+/* 296 */ if (mode == 0) {
+/* 297 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 298 */ "Start Point"));
+/* 299 */ } else if (mode == 1) {
+/* 300 */ ret = new Point3(this.startPoint);
+/* 301 */ startTransform();
+/* */
+/* */ }
+/* 304 */ else if (mode == 2) {
+/* 305 */ this.startPoint.copy((Point3)value);
+/* 306 */ startTransform();
+/* */ }
+/* 308 */ break;
+/* */ case 7:
+/* 310 */ if (mode == 0) {
+/* 311 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 312 */ "End Scale"));
+/* 313 */ } else if (mode == 1) {
+/* 314 */ ret = new Point3(this.endScale);
+/* 315 */ endTransform();
+/* */ }
+/* 317 */ else if (mode == 2) {
+/* 318 */ this.endScale.copy((Point3)value);
+/* 319 */ endTransform();
+/* */ }
+/* 321 */ break;
+/* */ case 8:
+/* 323 */ if (mode == 0) {
+/* 324 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 325 */ "Start Scale"));
+/* 326 */ } else if (mode == 1) {
+/* 327 */ ret = new Point3(this.startScale);
+/* 328 */ startTransform();
+/* */
+/* */ }
+/* 331 */ else if (mode == 2) {
+/* 332 */ this.startScale.copy((Point3)value);
+/* 333 */ startTransform();
+/* */ }
+/* 335 */ break;
+/* */ case 9:
+/* 337 */ if (mode == 0) {
+/* 338 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 339 */ "End Spin (Relative)"));
+/* 340 */ } else if (mode == 1) {
+/* 341 */ ret = new Point3(this.endSpin);
+/* 342 */ endTransform();
+/* */ }
+/* 344 */ else if (mode == 2) {
+/* 345 */ this.endSpin.copy((Point3)value);
+/* 346 */ endTransform();
+/* */ }
+/* 348 */ break;
+/* */ case 10:
+/* 350 */ if (mode == 0) {
+/* 351 */ ret = Point3PropertyEditor.make(new Property(this, index,
+/* 352 */ "Start Spin"));
+/* 353 */ } else if (mode == 1) {
+/* 354 */ ret = new Point3(this.startSpin);
+/* 355 */ startTransform();
+/* */ }
+/* 357 */ else if (mode == 2) {
+/* 358 */ this.startSpin.copy((Point3)value);
+/* 359 */ startTransform();
+/* */ }
+/* 361 */ break;
+/* */ case 11:
+/* 363 */ if (mode == 0) {
+/* 364 */ ret = FloatPropertyEditor.make(new Property(this, index,
+/* 365 */ "End Rotation (Relative)"));
+/* 366 */ } else if (mode == 1) {
+/* 367 */ ret = new Float(this.endRotation);
+/* 368 */ endTransform();
+/* */ }
+/* 370 */ else if (mode == 2) {
+/* 371 */ this.endRotation = ((Float)value).floatValue();
+/* 372 */ endTransform();
+/* */ }
+/* 374 */ break;
+/* */ case 12:
+/* 376 */ if (mode == 0) {
+/* 377 */ ret = FloatPropertyEditor.make(new Property(this, index,
+/* 378 */ "Start Rotation"));
+/* 379 */ } else if (mode == 1) {
+/* 380 */ ret = new Float(this.startRotation);
+/* 381 */ startTransform();
+/* */ }
+/* 383 */ else if (mode == 2) {
+/* 384 */ this.startRotation = ((Float)value).floatValue();
+/* 385 */ startTransform();
+/* */ }
+/* 387 */ break;
+/* */
+/* */
+/* */
+/* */
+/* */ default:
+/* 393 */ ret = super.properties(index, offset + 13, mode, value);
+/* */ }
+/* 395 */ if (mode == 2)
+/* */ {
+/* 397 */ if (this.trigger.equals("none")) {
+/* 398 */ startMotion();
+/* */ }
+/* */ }
+/* 401 */ return ret;
+/* */ }
+/* */
+/* */ public String toString()
+/* */ {
+/* 406 */ return
+/* */
+/* 408 */ "Motion: cycleTime " + this.cycleTime + ", cycles " + this.cycles + ", enabled " + this.enabled + ", trigger " + this.trigger + ", externalTriggerTag " + this.externalTriggerTag;
+/* */ }
+/* */
+/* */ public void saveState(Saver s)
+/* */ throws IOException
+/* */ {
+/* 414 */ s.saveFloat(this.cycleTime);
+/* 415 */ s.saveInt(this.cycles);
+/* 416 */ s.saveString(this.trigger);
+/* 417 */ s.saveString(this.externalTriggerTag);
+/* 418 */ this.endPoint.saveState(s);
+/* 419 */ this.startPoint.saveState(s);
+/* 420 */ this.endScale.saveState(s);
+/* 421 */ this.startScale.saveState(s);
+/* 422 */ this.endSpin.saveState(s);
+/* 423 */ this.startSpin.saveState(s);
+/* 424 */ s.saveFloat(this.endRotation);
+/* 425 */ s.saveFloat(this.startRotation);
+/* */ }
+/* */
+/* */
+/* */ public void restoreState(Restorer r)
+/* */ throws IOException
+/* */ {
+/* 432 */ this.cycleTime = r.restoreFloat();
+/* 433 */ this.cycles = r.restoreInt();
+/* 434 */ this.trigger = r.restoreString();
+/* 435 */ if (this.trigger.equals("external")) {
+/* 436 */ Trigger.TriggeredSwitchableBehaviorList[
+/* 437 */ Trigger.TriggeredSwitchableBehaviorListCount] = this;
+/* 438 */ Trigger.TriggeredSwitchableBehaviorListCount += 1;
+/* */ }
+/* */
+/* 441 */ this.externalTriggerTag = r.restoreString();
+/* */ try {
+/* 443 */ this.endPoint.restoreState(r);
+/* 444 */ this.startPoint.restoreState(r);
+/* 445 */ this.endScale.restoreState(r);
+/* 446 */ this.startScale.restoreState(r);
+/* 447 */ this.endSpin.restoreState(r);
+/* 448 */ this.startSpin.restoreState(r);
+/* */ }
+/* */ catch (Exception localException) {}
+/* 451 */ this.endRotation = r.restoreFloat();
+/* 452 */ this.startRotation = r.restoreFloat();
+/* 453 */ this.variableInitialized = true;
+/* 454 */ if (!this.trigger.equals("none")) {
+/* 455 */ this.startMotionTime = ((int)-(this.cycles * this.cycleTime));
+/* */ } else {
+/* 457 */ startMotion();
+/* */ }
+/* */ }
+/* */
+/* */
+/* */
+/* */
+/* */ public void postRestore(int version)
+/* */ {
+/* 466 */ String name = getName();
+/* 467 */ String arg1 = name == null ? "<null>" : name;
+/* 468 */ SuperRoot owner = getOwner();
+/* 469 */ String oname = "";
+/* 470 */ if (owner != null) {
+/* 471 */ oname = owner.getName();
+/* */ }
+/* 473 */ String arg2 = oname == null ? "<null>" : oname;
+/* 474 */ Object[] arguments = { new String(arg1), new String(arg2) };
+/* 475 */ Console.println(MessageFormat.format(
+/* 476 */ Console.message("Motion-obs"), arguments));
+/* */ }
+/* */ }
+
+
+/* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Motion.class
+ * Java compiler version: 6 (50.0)
+ * JD-Core Version: 0.7.1
+ */ \ No newline at end of file