.. | .. |
---|
23 | 23 | static float epsvertex2 = 0.001f; |
---|
24 | 24 | static boolean linkUV = false; // not uniform at load time |
---|
25 | 25 | |
---|
| 26 | + static boolean smoothmode = false; |
---|
| 27 | + |
---|
26 | 28 | static Wav wav = new Wav("/Users/nbriere/0ut/wavs/monoformat"); // output"); |
---|
27 | 29 | static boolean hassound = false; |
---|
28 | 30 | static boolean savesound = false; |
---|
.. | .. |
---|
41 | 43 | static void Assert(boolean b) |
---|
42 | 44 | { |
---|
43 | 45 | if (!b) |
---|
| 46 | + { |
---|
| 47 | + b = !!b; |
---|
44 | 48 | new Exception().printStackTrace(); // assert(b); |
---|
| 49 | + |
---|
| 50 | + } |
---|
| 51 | + } |
---|
| 52 | + |
---|
| 53 | + public static String RemovePrefix(String s, String prefix) |
---|
| 54 | + { |
---|
| 55 | + if (s != null && prefix != null && s.startsWith(prefix)) |
---|
| 56 | + { |
---|
| 57 | + return s.substring(prefix.length()); |
---|
| 58 | + } |
---|
| 59 | + |
---|
| 60 | + return s; |
---|
| 61 | + } |
---|
| 62 | + |
---|
| 63 | + static void ParseFileSystem(java.io.File dir, iResourceCallBack callback, String prefix) |
---|
| 64 | + { |
---|
| 65 | + callback.ResourceCallBack(RemovePrefix(dir.toString(),prefix).split("/")); |
---|
| 66 | + File[] listFiles = dir.listFiles(); |
---|
| 67 | + if (listFiles != null) |
---|
| 68 | + { |
---|
| 69 | + for (java.io.File file : listFiles) |
---|
| 70 | + { |
---|
| 71 | + ParseFileSystem(file, callback, prefix); |
---|
| 72 | + } |
---|
| 73 | + } |
---|
| 74 | + } |
---|
| 75 | + |
---|
| 76 | + static interface iResourceCallBack |
---|
| 77 | + { |
---|
| 78 | + void ResourceCallBack(String[] path); |
---|
| 79 | + } |
---|
| 80 | + |
---|
| 81 | + static void ParseResources(String path, iResourceCallBack callback) |
---|
| 82 | + { |
---|
| 83 | + java.io.File jarFile = new java.io.File(Grafreed.class.getProtectionDomain().getCodeSource().getLocation().getPath()); |
---|
| 84 | + |
---|
| 85 | + if (jarFile.isFile()) |
---|
| 86 | + { |
---|
| 87 | + // Run with JAR file |
---|
| 88 | + try |
---|
| 89 | + { |
---|
| 90 | + java.util.jar.JarFile jar = new java.util.jar.JarFile(jarFile); |
---|
| 91 | + java.util.Enumeration<java.util.jar.JarEntry> entries = jar.entries(); //gives ALL entries in jar |
---|
| 92 | + while (entries.hasMoreElements()) |
---|
| 93 | + { |
---|
| 94 | + String name = entries.nextElement().getName(); |
---|
| 95 | + |
---|
| 96 | + if (name.startsWith(path + "/")) |
---|
| 97 | + callback.ResourceCallBack(RemovePrefix(name, path + "/").split("/")); |
---|
| 98 | + } |
---|
| 99 | + jar.close(); |
---|
| 100 | + } catch (Exception ex) |
---|
| 101 | + { |
---|
| 102 | + ex.printStackTrace(); |
---|
| 103 | + } |
---|
| 104 | + } else |
---|
| 105 | + { |
---|
| 106 | + // Run with IDE |
---|
| 107 | + final java.net.URL url = Object3D.class.getResource("/" + path); |
---|
| 108 | + if (url != null) |
---|
| 109 | + { |
---|
| 110 | + try |
---|
| 111 | + { |
---|
| 112 | + java.io.File apps = new java.io.File(url.toURI()); |
---|
| 113 | + ParseFileSystem(apps, callback, RemovePrefix(url.toString() + "/", "file:")); |
---|
| 114 | +// for (java.io.File app : apps.listFiles()) |
---|
| 115 | +// { |
---|
| 116 | +// //System.out.println(RemovePrefix(app.toString(), RemovePrefix(url.toString(), "file:") + "/")); |
---|
| 117 | +// } |
---|
| 118 | + } catch (Exception ex) |
---|
| 119 | + { |
---|
| 120 | + ex.printStackTrace(); |
---|
| 121 | + } |
---|
| 122 | + } |
---|
| 123 | + } |
---|
45 | 124 | } |
---|
46 | 125 | |
---|
47 | 126 | public void init() |
---|
.. | .. |
---|
52 | 131 | universe.material = new cMaterial(); |
---|
53 | 132 | //god.addChild(universe); |
---|
54 | 133 | universe.name = "Applet"; |
---|
55 | | - grafreeD = this; |
---|
| 134 | + grafreed = this; |
---|
56 | 135 | } |
---|
57 | 136 | |
---|
58 | 137 | /**/ |
---|
.. | .. |
---|
843 | 922 | |
---|
844 | 923 | //Monitor mon=MonitorFactory.start("myFirstMonitor"); |
---|
845 | 924 | standAlone = true; |
---|
846 | | - grafreeD = new Grafreed(); |
---|
847 | | - grafreeD.universe = new Composite(); |
---|
848 | | - grafreeD.universe.name = "Grafreed"; |
---|
849 | | - grafreeD.universe.material = new cMaterial(); |
---|
| 925 | + grafreed = new Grafreed(); |
---|
| 926 | + grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd")); |
---|
| 927 | + |
---|
| 928 | + grafreed.universe = new cGroup(); |
---|
| 929 | + grafreed.universe.name = "Grafreed"; |
---|
| 930 | + grafreed.universe.material = new cMaterial(); |
---|
850 | 931 | // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; |
---|
851 | 932 | |
---|
852 | | - grafreeD.universe.root = true; |
---|
853 | | - grafreeD.universe.openEditWindow(null, true); //, true); |
---|
| 933 | + grafreed.universe.root = true; |
---|
| 934 | + grafreed.universe.openEditWindow(null, true); //, true); |
---|
854 | 935 | //mon.stop(); |
---|
855 | 936 | //System.out.println(mon); |
---|
856 | 937 | //timeflow.app.TimeflowAppLauncher.GetTimeFlow(); |
---|
857 | 938 | } |
---|
858 | 939 | |
---|
| 940 | + static Object3D materials; |
---|
| 941 | + |
---|
| 942 | + static Object3D ReadGFD(java.io.InputStream istream) |
---|
| 943 | + { |
---|
| 944 | + Object3D readobj = null; |
---|
| 945 | + |
---|
| 946 | + try |
---|
| 947 | + { |
---|
| 948 | + // Try compressed version first. |
---|
| 949 | + java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); |
---|
| 950 | + java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); |
---|
| 951 | + |
---|
| 952 | + readobj = (Object3D) p.readObject(); |
---|
| 953 | + istream.close(); |
---|
| 954 | + |
---|
| 955 | + readobj.ResetDisplayList(); |
---|
| 956 | + } catch (Exception e) |
---|
| 957 | + { |
---|
| 958 | + if (!e.toString().contains("GZIP")) |
---|
| 959 | + e.printStackTrace(); |
---|
| 960 | + |
---|
| 961 | + try |
---|
| 962 | + { |
---|
| 963 | + java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream); |
---|
| 964 | + |
---|
| 965 | + readobj = (Object3D) p.readObject(); |
---|
| 966 | + istream.close(); |
---|
| 967 | + |
---|
| 968 | + readobj.ResetDisplayList(); |
---|
| 969 | + } catch (Exception e2) |
---|
| 970 | + { |
---|
| 971 | + e2.printStackTrace(); |
---|
| 972 | + } |
---|
| 973 | + } |
---|
| 974 | + |
---|
| 975 | + return readobj; |
---|
| 976 | + } |
---|
| 977 | + |
---|
859 | 978 | // Timer callback |
---|
860 | 979 | public void actionPerformed(ActionEvent e) |
---|
861 | 980 | { |
---|
.. | .. |
---|
870 | 989 | static int depth = 0; |
---|
871 | 990 | static java.util.Stack stack = new java.util.Stack(); |
---|
872 | 991 | static boolean traceoff = false; // true; |
---|
873 | | - static float[] colorV = new float[5]; |
---|
| 992 | + static float[] colorV = new float[4]; // 5]; |
---|
874 | 993 | |
---|
875 | 994 | static void traceon() |
---|
876 | 995 | { |
---|
.. | .. |
---|
1079 | 1198 | } while (avail > 0 && numRead >= 0); |
---|
1080 | 1199 | return new String(data, 0, pos, "US-ASCII"); |
---|
1081 | 1200 | } |
---|
1082 | | - public static Grafreed grafreeD; |
---|
| 1201 | + public static Grafreed grafreed; |
---|
1083 | 1202 | public static boolean standAlone = true; |
---|
1084 | 1203 | public Composite universe; |
---|
1085 | 1204 | public static Object3D clipboard = new Object3D(); |
---|