From 4ec7130da08861dc4aff0232dbce38f3471696a4 Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Mon, 05 Aug 2019 20:41:17 -0400 Subject: [PATCH] Materials working. --- Grafreed.java | 60 ++++++++++++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 50 insertions(+), 10 deletions(-) diff --git a/Grafreed.java b/Grafreed.java index 4f0341c..a463511 100644 --- a/Grafreed.java +++ b/Grafreed.java @@ -58,7 +58,7 @@ universe.material = new cMaterial(); //god.addChild(universe); universe.name = "Applet"; - grafreeD = this; + grafreed = this; } /**/ @@ -626,12 +626,12 @@ System.out.println("jarfile = " + jarfile); - String command = javaPath + " -Xmx2048m -Djava.library.path=" + jarpath; + String command = javaPath + " -Xmx1024m -Djava.library.path=" + jarpath; // -Djava.library.path=/Users/nbriere/Projects/shared/lib if (jarfile.charAt(2) == ':') { - command = "\"" + javaPath + "\" -Xmx2048m -Djava.library.path=" + jarpath; + command = "\"" + javaPath + "\" -Xmx1024m -Djava.library.path=" + jarpath; // On Windows systems, the path is /C:/ jarfile = jarfile.substring(1, jarfile.length()); System.out.println("jarfile = " + jarfile); @@ -849,19 +849,59 @@ //Monitor mon=MonitorFactory.start("myFirstMonitor"); standAlone = true; - grafreeD = new Grafreed(); - grafreeD.universe = new cGroup(); - grafreeD.universe.name = "Grafreed"; - grafreeD.universe.material = new cMaterial(); + grafreed = new Grafreed(); + grafreed.materials = ReadGFD(grafreed.getClass().getClassLoader().getResourceAsStream("gfd/materials.gfd")); + + grafreed.universe = new cGroup(); + grafreed.universe.name = "Grafreed"; + grafreed.universe.material = new cMaterial(); // theApplet3D.universe.textures = CameraPane.DEFAULT_TEXTURE; - grafreeD.universe.root = true; - grafreeD.universe.openEditWindow(null, true); //, true); + grafreed.universe.root = true; + grafreed.universe.openEditWindow(null, true); //, true); //mon.stop(); //System.out.println(mon); //timeflow.app.TimeflowAppLauncher.GetTimeFlow(); } + static Object3D materials; + + static Object3D ReadGFD(java.io.InputStream istream) + { + Object3D readobj = null; + + try + { + // Try compressed version first. + java.util.zip.GZIPInputStream zstream = new java.util.zip.GZIPInputStream(istream); + java.io.ObjectInputStream p = new java.io.ObjectInputStream(zstream); + + readobj = (Object3D) p.readObject(); + istream.close(); + + readobj.ResetDisplayList(); + } catch (Exception e) + { + if (!e.toString().contains("GZIP")) + e.printStackTrace(); + + try + { + java.io.ObjectInputStream p = new java.io.ObjectInputStream(istream); + + readobj = (Object3D) p.readObject(); + istream.close(); + + readobj.ResetDisplayList(); + } catch (Exception e2) + { + e2.printStackTrace(); + } + } + + return readobj; + } + // Timer callback public void actionPerformed(ActionEvent e) { @@ -1085,7 +1125,7 @@ } while (avail > 0 && numRead >= 0); return new String(data, 0, pos, "US-ASCII"); } - public static Grafreed grafreeD; + public static Grafreed grafreed; public static boolean standAlone = true; public Composite universe; public static Object3D clipboard = new Object3D(); -- Gitblit v1.6.2