/* */ package NET.worlds.scape; /* */ /* */ import NET.worlds.console.Console; /* */ import NET.worlds.console.Main; /* */ import NET.worlds.console.MainCallback; /* */ import NET.worlds.network.URL; /* */ import java.io.IOException; /* */ import java.io.PrintStream; /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public class Hologram /* */ extends Surface /* */ implements Prerenderable, BGLoaded, Postrenderable, MainCallback /* */ { /* */ private int isLoading; /* */ ScapePicMovie fromMovie; /* */ URL movieName; /* */ protected Texture[] images; /* */ protected Material[] materials; /* */ /* */ public Hologram(float w, float h, Texture[] texs) /* */ { /* 120 */ super(null); /* 121 */ scale(w, 1.0F, h); /* */ /* 123 */ this.images = texs; /* */ } /* */ /* */ /* */ /* */ /* */ public Hologram() /* */ { /* 131 */ super(null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Hologram(Texture[] texs) /* */ { /* 141 */ this(texs[0].getW(), texs[0].getH(), texs); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Hologram(ScapePicMovie texs) /* */ { /* 154 */ this(texs.getW(), texs.getH(), texs.getTextures()); /* 155 */ this.fromMovie = texs; /* */ } /* */ /* */ /* */ /* */ public Hologram(float w, float h, ScapePicMovie texs) /* */ { /* 162 */ this(w, h, texs.getTextures()); /* 163 */ this.fromMovie = texs; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Hologram(URL movieName, HoloCallback cb) /* */ { /* 173 */ super(null); /* 174 */ setAutosize(true); /* 175 */ scale(100.0F, 1.0F, 100.0F); /* 176 */ load(movieName, cb); /* */ } /* */ /* */ /* */ /* */ public Hologram(URL movieName) /* */ { /* 183 */ this(movieName, null); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ public Hologram(float w, float h, URL movieName, HoloCallback cb) /* */ { /* 193 */ super(null); /* 194 */ scale(w, 1.0F, h); /* 195 */ load(movieName, cb); /* */ } /* */ /* */ /* */ /* */ /* */ public Hologram(float w, float h, URL movieName) /* */ { /* 203 */ this(w, h, movieName, null); /* */ } /* */ /* */ static { /* 207 */ nativeInit(); /* */ } /* */ /* */ /* */ private void load(URL movieName, HoloCallback cb) /* */ { /* 213 */ assert (getMaterial() != null); /* */ /* 215 */ this.callback = cb; /* */ /* 217 */ this.movieName = movieName; /* */ /* */ /* */ /* 221 */ if ((this.callback != null) || (hasClump())) /* 222 */ forceLoad(); /* */ } /* */ /* */ private void lockMaterials(boolean val) { /* 226 */ if (this.materials != null) /* 227 */ for (int i = 0; i < this.materials.length; i++) /* 228 */ this.materials[i].setKeepLoaded(val); /* */ } /* */ /* */ private void releaseMaterials() { /* 232 */ lockMaterials(false); /* 233 */ this.materials = null; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void loadMultipart(URL url, String base, int numParts, String end) /* */ { /* 243 */ this.images = null; /* 244 */ releaseMaterials(); /* 245 */ this.materials = new Material[numParts]; /* */ do { /* 247 */ this.materials[numParts] = new Material( /* 248 */ URL.make(url, base + (numParts + 1) + end));numParts--; /* 246 */ } while (numParts >= 0); /* */ /* */ /* */ /* */ /* 251 */ setMaterial(this.materials[0]); /* 252 */ if (this.callback != null) { /* 253 */ this.callback.holoCallback(this, true); /* 254 */ this.callback = null; /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private void forceLoad() /* */ { /* 269 */ URL url = HoloDrone.permission(this.movieName); /* 270 */ String name = (url == null ? this.movieName : url).getBase(); /* */ /* 272 */ int len = name.length(); /* */ /* 274 */ boolean isMov = (len > 5) && (name.regionMatches(true, len - 5, "*.mov", 0, 5)); /* */ /* 276 */ int h = 1; /* 277 */ int v = 1; /* */ int num; /* 279 */ for (int nextStarIndex = len - 5; /* */ /* 281 */ (nextStarIndex > 2) && (name.charAt(nextStarIndex) == '*') && /* 282 */ ((num = name.charAt(nextStarIndex - 2) - '0') > 0) && ( /* 283 */ num <= 9); /* 284 */ nextStarIndex -= 3) { /* */ int num; /* 286 */ char control = Character.toLowerCase( /* 287 */ name.charAt(nextStarIndex - 1)); /* 288 */ if (control == 'h') { /* 289 */ h = num; /* 290 */ } else if (control == 'v') { /* 291 */ v = num; /* 292 */ } else if (control == 's') /* */ { /* 294 */ if (getAutosize()) { /* 295 */ scale(h * 160.0F / v / getScaleX(), 1.0F, 160.0F / getScaleZ()); /* */ } /* 297 */ if (isMov) /* */ { /* */ /* */ /* 301 */ loadMultipart(this.movieName, /* 302 */ name.substring(0, nextStarIndex - 2), /* 303 */ num, /* 304 */ "s*" + h + "h*" + v + "v*.mov"); /* */ } else /* 306 */ loadMultipart(this.movieName, /* 307 */ name.substring(0, nextStarIndex - 2), /* 308 */ num, /* 309 */ name.substring(nextStarIndex + 1)); /* 310 */ return; /* */ } /* */ } /* */ /* 314 */ this.isLoading += 1; /* 315 */ BackgroundLoader.get(this, this.movieName); /* */ } /* */ /* */ public Object asyncBackgroundLoad(String localName, URL remoteName) /* */ { /* 320 */ if (localName != null) { /* 321 */ if (localName.toLowerCase().endsWith(".mov")) { /* 322 */ return new ScapePicMovie(localName, remoteName).getTextures(); /* */ } /* 324 */ Texture[] texs = new Texture[1]; /* 325 */ texs[0] = TextureDecoder.decode(remoteName, localName); /* 326 */ if ((texs[0] != null) && (texs[0].textureID != 0)) { /* 327 */ return texs; /* */ } /* */ } /* 330 */ return null; /* */ } /* */ /* */ public boolean syncBackgroundLoad(Object obj, URL remoteURL) /* */ { /* 335 */ releaseMaterials(); /* 336 */ if (obj != null) { /* 337 */ this.images = ((Texture[])obj); /* 338 */ if (getAutosize()) /* 339 */ scale(this.images[0].getW() / getScaleX(), 1.0F, /* 340 */ this.images[0].getH() / getScaleZ()); /* */ } else { /* 342 */ if (this.movieName != null) /* 343 */ Console.println( /* 344 */ Console.message("No-load-hologram") + this.movieName); /* 345 */ this.images = null; /* 346 */ setMaterial(null); /* */ } /* 348 */ if (this.callback != null) { /* 349 */ this.callback.holoCallback(this, (this.images != null) || (this.materials != null)); /* 350 */ this.callback = null; /* */ } /* */ /* 353 */ this.isLoading -= 1; /* */ /* 355 */ return false; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public Room getBackgroundLoadRoom() /* */ { /* 364 */ return getRoom(); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ public BoundBoxTemp getBoundBox() /* */ { /* 376 */ Point3Temp center = getWorldPosition(); /* 377 */ Point3Temp jog = Point3Temp.make(getW() / 2.0F, getW() / 2.0F, getH() / 2.0F); /* */ /* 379 */ return BoundBoxTemp.make(Point3Temp.make(center).minus(jog), /* 380 */ Point3Temp.make(center).plus(jog)); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ public float getMinXYExtent() /* */ { /* 389 */ return getW(); /* */ } /* */ /* 392 */ public float getW() { return getScaleX(); } /* 393 */ public float getH() { return getScaleZ(); } /* */ /* */ /* */ /* */ /* */ /* */ public int getNumSides() /* */ { /* 401 */ if (this.images == null) { /* 402 */ return this.materials == null ? 1 : this.materials.length; /* */ } /* 404 */ return this.images.length; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ void setActiveSide(int side) /* */ { /* 413 */ if (side >= getNumSides()) { /* 414 */ System.out.println( /* 415 */ "Error at NET.worlds.Hologram.setActiveSide side " + /* 416 */ side + " of " + getNumSides()); /* 417 */ side = 0; /* */ } /* */ /* 420 */ if (this.materials == null) { /* 421 */ Texture t = /* 422 */ side < this.images.length ? this.images[side] : this.images == null ? null : null; /* 423 */ if (t != null) /* 424 */ t.incRef(); /* 425 */ this.material.setTexture(t); /* 426 */ } else if (this.materials[side] != this.material) { /* 427 */ setMaterial(this.materials[side]); /* */ } /* */ } /* */ /* */ public URL getMovieName() { /* 432 */ if ((this.movieName == null) && (this.fromMovie != null)) /* 433 */ return this.fromMovie.getURL(); /* 434 */ return this.movieName; /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected void addRwChildren(WObject container) /* */ { /* 451 */ addNewRwChild(container); /* */ /* */ /* 454 */ if ((this.images == null) && (this.materials == null) && /* 455 */ (this.movieName != null) && (this.isLoading == 0)) /* */ { /* 457 */ forceLoad(); /* */ } /* */ /* */ /* */ /* */ /* 463 */ addVertex(0.5F, 0.0F, -0.5F, 0.0F, 1.0F); /* 464 */ addVertex(-0.5F, 0.0F, -0.5F, 1.0F, 1.0F); /* 465 */ addVertex(-0.5F, 0.0F, 0.5F, 1.0F, 0.0F); /* 466 */ addVertex(0.5F, 0.0F, 0.5F, 0.0F, 0.0F); /* */ /* 468 */ doneWithEditing(); /* */ /* 470 */ if (!isReclumping()) { /* 471 */ lockMaterials(true); /* 472 */ getRoom().addPrerenderHandler(this); /* 473 */ getRoom().addPostrenderHandler(this); /* */ } /* */ /* 476 */ if ((this.images == null) && (this.materials == null) && (this.isLoading > 0)) { /* 477 */ makeTemporarilyInvisible(); /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ protected void markVoid() /* */ { /* 488 */ if (!isReclumping()) { /* 489 */ lockMaterials(false); /* 490 */ getRoom().removePrerenderHandler(this); /* 491 */ getRoom().removePostrenderHandler(this); /* */ } /* */ /* */ /* */ /* 496 */ if ((this.movieName != null) && (this.fromMovie == null) && (this.isLoading == 0)) { /* 497 */ Main.register(this); /* */ } /* 499 */ super.markVoid(); /* */ } /* */ /* */ public void mainCallback() { /* 503 */ if (!hasClump()) { /* 504 */ if (this.images != null) { /* 505 */ int i = this.images.length; /* 506 */ do { if (this.images[i] != null) { /* 507 */ this.images[i].decRef(); /* */ } /* 505 */ i--; } while (i >= 0); /* */ /* */ /* 508 */ this.images = null; /* */ } /* 510 */ releaseMaterials(); /* */ } /* 512 */ Main.unregister(this); /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 522 */ private static Object classCookie = new Object(); /* */ /* */ public void saveState(Saver s) throws IOException /* */ { /* 526 */ s.saveVersion(6, classCookie); /* 527 */ s.saveFloat(this.scaleDist); /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* 536 */ Material origMaterial = getMaterial(); /* 537 */ URL name = getMovieName(); /* 538 */ if (name != null) /* 539 */ setMaterial(null); /* 540 */ super.saveState(s); /* 541 */ setMaterial(origMaterial); /* */ /* 543 */ URL.save(s, name); /* */ /* 545 */ if (name == null) { /* 546 */ if (this.fromMovie != null) { /* 547 */ s.saveBoolean(true); /* 548 */ s.save(this.fromMovie); /* */ } else { /* 550 */ s.saveBoolean(false); /* 551 */ if (this.images != null) { /* 552 */ s.saveBoolean(true); /* 553 */ s.saveArray(this.images); /* */ } /* */ else /* */ { /* 557 */ assert (this.materials == null); /* */ /* 559 */ s.saveBoolean(false); /* */ } /* */ } /* */ } /* */ } /* */ /* */ /* */ /* */ /* */ /* */ /* */ /* */ private static Texture[] extractTextureArray(Material[] mats) /* */ { /* 573 */ Texture[] texs = new Texture[mats.length]; /* 574 */ for (int i = 0; i < mats.length; i++) { /* 575 */ texs[i] = mats[i].extractTexture(0); /* */ } /* 577 */ return texs; /* */ } /* */ /* */ public void restoreState(Restorer r) throws IOException, TooNewException /* */ { /* 582 */ int vers = r.restoreVersion(classCookie); /* */ /* 584 */ switch (vers) { /* */ case 5: /* */ case 6: /* 587 */ this.scaleDist = r.restoreFloat(); /* */ /* */ case 4: /* 590 */ super.restoreState(r); /* 591 */ if ((this.movieName = URL.restore(r)) != null) { /* 592 */ load(this.movieName, null); /* */ } /* 594 */ else if (r.restoreBoolean()) { /* 595 */ this.fromMovie = ((ScapePicMovie)r.restore()); /* 596 */ this.images = this.fromMovie.getTextures(); /* */ } else { /* 598 */ if (vers < 6) /* 599 */ setAutosize(true); /* 600 */ if (r.restoreBoolean()) { /* 601 */ this.images = ((Texture[])r.restoreArray()); /* */ } /* */ } /* */ /* */ /* */ /* 607 */ break; /* */ case 3: /* 609 */ super.restoreState(r); /* 610 */ if ((this.movieName = URL.restore(r)) != null) { /* 611 */ load(this.movieName, null); /* */ } /* 613 */ else if (r.restoreBoolean()) { /* 614 */ this.fromMovie = ((ScapePicMovie)r.restore()); /* 615 */ this.images = this.fromMovie.getTextures(); /* */ } else { /* 617 */ setAutosize(true); /* 618 */ if (r.restoreBoolean()) { /* 619 */ this.images = extractTextureArray( /* 620 */ (Material[])r.restoreArray()); /* */ } /* */ } /* */ /* */ /* */ /* 626 */ break; /* */ case 2: /* 628 */ super.restoreState(r); /* 629 */ if ((this.movieName = URL.restore(r)) != null) { /* 630 */ load(this.movieName, null); /* */ } /* 632 */ else if (r.restoreBoolean()) { /* 633 */ this.fromMovie = ((ScapePicMovie)r.restore()); /* 634 */ this.images = this.fromMovie.getTextures(); /* */ } else { /* 636 */ setAutosize(true); /* */ } /* 638 */ break; /* */ case 1: /* 640 */ super.restoreState(r); /* 641 */ float w = r.restoreFloat(); /* 642 */ if (w == 0.0F) /* 643 */ w = 100.0F; /* 644 */ float h = r.restoreFloat(); /* 645 */ if (h == 0.0F) /* 646 */ h = 100.0F; /* 647 */ scale(w, 1.0F, h); /* 648 */ if ((this.movieName = URL.restore(r)) != null) { /* 649 */ load(this.movieName, null); /* */ } /* 651 */ else if (r.restoreBoolean()) { /* 652 */ this.fromMovie = ((ScapePicMovie)r.restore()); /* 653 */ this.images = this.fromMovie.getTextures(); /* */ } else { /* 655 */ setAutosize(true); /* */ } /* 657 */ break; /* */ case 0: /* 659 */ super.restoreState(r); /* 660 */ float w = r.restoreFloat(); /* 661 */ if (w == 0.0F) /* 662 */ w = 100.0F; /* 663 */ float h = r.restoreFloat(); /* 664 */ if (h == 0.0F) /* 665 */ h = 100.0F; /* 666 */ scale(w, 1.0F, h); /* */ /* 668 */ if (r.restoreBoolean()) { /* 669 */ this.fromMovie = ((ScapePicMovie)r.restore()); /* 670 */ this.images = this.fromMovie.getTextures(); /* */ } else { /* 672 */ setAutosize(true); } /* 673 */ break; /* */ default: /* 675 */ throw new TooNewException(); /* */ } /* */ } /* */ /* */ public Hologram setRoughCut(boolean b) /* */ { /* 681 */ if (b) { /* 682 */ this.flags |= 0x4; /* */ } else /* 684 */ this.flags &= 0xFFFFFFFB; /* 685 */ return this; /* */ } /* */ /* */ public final boolean getRoughCut() { /* 689 */ return (this.flags & 0x4) != 0; /* */ } /* */ /* */ public void setAutosize(boolean b) /* */ { /* 694 */ if (b) { /* 695 */ this.flags |= 0x400000; /* */ } else /* 697 */ this.flags &= 0xFFBFFFFF; /* */ } /* */ /* */ public final boolean getAutosize() { /* 701 */ return (this.flags & 0x400000) != 0; /* */ } /* */ /* */ public Hologram setViewplaneAligned(boolean b) /* */ { /* 706 */ if (b) { /* 707 */ this.flags |= 0x40000; /* */ } else /* 709 */ this.flags &= 0xFFFBFFFF; /* 710 */ return this; /* */ } /* */ /* */ public final boolean getViewplaneAligned() { /* 714 */ return (this.flags & 0x40000) != 0; /* */ } /* */ /* */ /* */ /* */ /* */ public Object properties(int index, int offset, int mode, Object value) /* */ throws NoSuchPropertyException /* */ { /* 723 */ Object ret = null; /* 724 */ switch (index - offset) { /* */ case 0: /* 726 */ if (mode == 0) { /* 727 */ ret = URLPropertyEditor.make( /* 728 */ new Property(this, index, "File"), /* 729 */ TextureDecoder.getAllExts()); /* 730 */ } else if (mode == 1) { /* 731 */ ret = getMovieName(); /* 732 */ } else if (mode == 2) /* 733 */ load((URL)value, null); /* 734 */ break; /* */ case 1: /* 736 */ if (mode == 0) { /* 737 */ ret = BooleanPropertyEditor.make( /* 738 */ new Property(this, index, "Viewplane Aligned"), /* 739 */ "No", "Yes"); /* 740 */ } else if (mode == 1) { /* 741 */ ret = new Boolean(getViewplaneAligned()); /* 742 */ } else if (mode == 2) /* 743 */ setViewplaneAligned(((Boolean)value).booleanValue()); /* 744 */ break; /* */ case 2: /* 746 */ if (mode == 0) { /* 747 */ ret = BooleanPropertyEditor.make( /* 748 */ new Property(this, index, "Rough Cut Alignment"), /* 749 */ "No", "Yes"); /* 750 */ } else if (mode == 1) { /* 751 */ ret = new Boolean(getRoughCut()); /* 752 */ } else if (mode == 2) /* 753 */ setRoughCut(((Boolean)value).booleanValue()); /* 754 */ break; /* */ case 3: /* 756 */ if (mode == 0) { /* 757 */ ret = FloatPropertyEditor.make( /* 758 */ new Property(this, index, "Scale Distance")); /* 759 */ } else if (mode == 1) { /* 760 */ ret = new Float(getScaleDist()); /* 761 */ } else if (mode == 2) /* 762 */ setScaleDist(((Float)value).floatValue()); /* 763 */ break; /* */ case 4: /* 765 */ if (mode == 0) { /* 766 */ ret = Point2PropertyEditor.make( /* 767 */ new Property(this, index, "Extent")); /* 768 */ } else if (mode == 1) { /* 769 */ ret = new Point2(getScaleX(), getScaleZ()); /* 770 */ } else if (mode == 2) { /* 771 */ setAutosize(false); /* 772 */ scale(((Point2)value).x / getScaleX(), 1.0F, /* 773 */ ((Point2)value).y / getScaleZ()); /* */ } /* 775 */ break; /* */ case 5: /* 777 */ if (mode == 0) { /* 778 */ ret = BooleanPropertyEditor.make( /* 779 */ new Property(this, index, "Autosize"), /* 780 */ "No", "Yes"); /* 781 */ } else if (mode == 1) { /* 782 */ ret = new Boolean(getAutosize()); /* 783 */ } else if (mode == 2) /* 784 */ setAutosize(((Boolean)value).booleanValue()); /* 785 */ break; /* */ default: /* 787 */ ret = super.properties(index, offset + 6, mode, value); /* */ } /* 789 */ return ret; /* */ } /* */ /* */ public String toString() /* */ { /* 794 */ URL name = getMovieName(); /* 795 */ return super.toString() + "[" + ( /* 796 */ name != null ? name.toString() : "") + "]"; /* */ } /* */ /* */ /* */ /* */ /* 802 */ private int origTransformID = 0; /* */ /* */ /* */ /* */ /* */ /* */ private HoloCallback callback; /* */ /* */ /* */ /* */ /* */ private float scaleDist; /* */ /* */ /* */ /* */ /* 818 */ public void setScaleDist(float dist) { this.scaleDist = dist; } /* */ /* 820 */ public final float getScaleDist() { return this.scaleDist; } /* */ /* */ public static native void nativeInit(); /* */ /* */ public native void makeTemporarilyInvisible(); /* */ /* */ public native void prerender(Camera paramCamera); /* */ /* */ public native void postrender(Camera paramCamera); /* */ } /* Location: C:\Program Files (x86)\Worlds Inc\WorldsPlayer - Win7\lib\worlds.jar!\NET\worlds\scape\Hologram.class * Java compiler version: 6 (50.0) * JD-Core Version: 0.7.1 */