/* */ package NET.worlds.scape; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class BumpEventTemp /* */ extends Event /* */ { /* 42 */ private static Recycler recycler = new Recycler(); /* */ public Point3Temp fullPath; /* */ public Point3Temp path; /* */ public BoundBoxTemp bound; /* */ public float fraction; /* */ public Room postBumpRoom; /* */ /* */ public static BumpEventTemp make(int time, WObject mover, Point3Temp motion) /* */ { /* 51 */ BumpEventTemp t = (BumpEventTemp)recycler.alloc(); /* */ /* 53 */ if (t == null) { /* 54 */ recycler.recycle(new BumpEventTemp(0, null)); /* 55 */ t = (BumpEventTemp)recycler.alloc(); /* */ } /* */ /* */ /* 59 */ assert (t.source == null); /* */ /* 61 */ t.time = time; /* 62 */ t.source = mover; /* */ /* */ /* */ /* */ /* 67 */ t.fullPath = Point3Temp.make(motion); /* 68 */ t.path = t.fullPath; /* 69 */ t.sourceAt = ((WObject)t.source).getWorldPosition(); /* 70 */ t.sourceBoxMinus = ((WObject)t.source).getBoundBox(); /* 71 */ t.sourceBoxMinus.lo.minus(t.sourceAt); /* 72 */ t.sourceBoxMinus.hi.minus(t.sourceAt); /* */ /* 74 */ t.setPathFraction(1.0F); /* */ /* */ /* 77 */ Room r = mover.getRoom(); /* 78 */ if (r.getBumpable()) { /* 79 */ r.detectBump(t); /* */ } /* 81 */ return t; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void recycle() /* */ { /* 91 */ this.time = 0; /* 92 */ this.source = null; /* 93 */ this.target = null; /* 94 */ this.receiver = null; /* */ /* 96 */ this.postBumpRoom = null; /* 97 */ this.postBumpPath = null; /* 98 */ this.postBumpPosition = null; /* */ } /* */ /* */ private BumpEventTemp(int time, Object source) { /* 102 */ super(time, source, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Transform postBumpPosition; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Point3Temp postBumpPath; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Point3Temp sourceAt; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public BoundBoxTemp sourceBoxMinus; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Point3Temp bumpNormal; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public void setPathFraction(float fraction) /* */ { /* 164 */ this.fraction = fraction; /* 165 */ this.path = Point3Temp.make(this.path).times(fraction); /* */ /* 167 */ this.bound = BoundBoxTemp.make(this.sourceAt, Point3Temp.make(this.sourceAt) /* 168 */ .plus(this.path)); /* 169 */ this.bound.lo.plus(this.sourceBoxMinus.lo); /* 170 */ this.bound.hi.plus(this.sourceBoxMinus.hi); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public float isCollision(Point3Temp left, Point3Temp d, Point3Temp start, Point3Temp motion) /* */ { /* 198 */ double D = motion.x * -d.y + motion.y * d.x; /* */ /* */ /* 201 */ if (D > 0.0D) { /* 202 */ Point3Temp C = Point3Temp.make(start).minus(left); /* */ /* 204 */ double betaNum = C.x * d.y - C.y * d.x; /* */ /* 206 */ double alphaNum = C.x * motion.y - motion.x * C.y; /* */ /* 208 */ if ((alphaNum >= 0.0D) && (alphaNum <= D) && (betaNum >= 0.0D) && /* 209 */ (betaNum <= D)) { /* 210 */ return (float)(betaNum / D); /* */ } /* */ /* 213 */ return -2.0F; /* */ } /* */ /* 216 */ return -1.0F; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public float hitPlane(WObject o, Point3Temp left, Point3Temp d) /* */ { /* 227 */ float dist = isCollision(left, d, this.sourceAt, this.path); /* 228 */ if (dist >= 0.0F) { /* 229 */ this.target = o; /* */ /* 231 */ setPathFraction(dist); /* 232 */ this.bumpNormal = Point3Temp.make(d.y, -d.x, 0.0F).normalize(); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 250 */ this.path.plus(Point3Temp.make(this.path).normalize().times(0.2F)); /* */ } /* */ /* 253 */ return dist; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean hitRegion(WObject o, Point3Temp left, Point3Temp d, Point3Temp extent) /* */ { /* 275 */ float dist = hitPlane(o, left, d); /* 276 */ if (dist >= 0.0F) { /* 277 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* 284 */ if (dist == -1.0F) { /* 285 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* 293 */ Point3Temp right = Point3Temp.make(left).plus(d); /* 294 */ Point3Temp minusD = Point3Temp.make().minus(d); /* 295 */ Point3Temp minusExtent = Point3Temp.make().minus(extent); /* 296 */ if ((dist = isCollision(right, minusD, this.sourceAt, minusExtent)) > 0.0F) { /* 297 */ this.target = o; /* */ /* 299 */ setPathFraction(0.0F); /* 300 */ this.bumpNormal = minusExtent; /* 301 */ return true; /* */ } /* */ /* 304 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean hitTriRegion(WObject o, Point3Temp left, Point3Temp d, Point3Temp extent) /* */ { /* 323 */ float dist = hitPlane(o, left, d); /* 324 */ if (dist >= 0.0F) { /* 325 */ return true; /* */ } /* */ /* */ /* */ /* */ /* */ /* 332 */ if (dist == -1.0F) { /* 333 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* 340 */ Point3Temp right = Point3Temp.make(left).plus(d); /* 341 */ Point3Temp minusD = Point3Temp.make().minus(d); /* 342 */ Point3Temp minusExtent = Point3Temp.make().minus(extent); /* 343 */ if ((dist = isCollision(right, minusD, this.sourceAt, minusExtent)) > 0.0F) /* */ { /* */ /* */ /* */ /* 348 */ float dx = this.sourceAt.x - (left.x + d.x / 2.0F); /* 349 */ float dy = this.sourceAt.y - (left.y + d.y / 2.0F); /* 350 */ float squaredDistFromMid = dx * dx + dy * dy; /* */ /* 352 */ dx = this.sourceAt.x - (left.x + extent.x); /* 353 */ dy = this.sourceAt.y - (left.y + extent.y); /* 354 */ float squaredDistFromA = dx * dx + dy * dy; /* 355 */ if (squaredDistFromA < squaredDistFromMid) { /* 356 */ return false; /* */ } /* 358 */ dx = this.sourceAt.x - (right.x + extent.x); /* 359 */ dy = this.sourceAt.y - (right.y + extent.y); /* 360 */ float squaredDistFromB = dx * dx + dy * dy; /* 361 */ if (squaredDistFromB < squaredDistFromMid) { /* 362 */ return false; /* */ } /* 364 */ this.target = o; /* */ /* 366 */ setPathFraction(0.0F); /* 367 */ this.bumpNormal = minusExtent; /* 368 */ return true; /* */ } /* */ /* 371 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public boolean deliver(Object o) /* */ { /* 382 */ if ((o instanceof BumpHandler)) { /* 383 */ return ((BumpHandler)o).handle(this); /* */ } /* */ /* */ /* */ /* 388 */ return false; /* */ } /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\BumpEventTemp.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */