From cfd7a643cb5a445016ddb15595158ecc59b184fd Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 30 Jun 2019 18:18:44 -0400 Subject: [PATCH] Proto wget 3d models. --- CameraPane.java | 212 +++++++++++++++++++++++++++++++++++++++++++++++++--- 1 files changed, 197 insertions(+), 15 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 7afdef6..cdf2ce1 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -335,14 +335,28 @@ display.options1[2] = material.shadowbias; display.options1[3] = material.aniso; display.options1[4] = material.anisoV; +// System.out.println("display.options1[0] " + display.options1[0]); +// System.out.println("display.options1[1] " + display.options1[1]); +// System.out.println("display.options1[2] " + display.options1[2]); +// System.out.println("display.options1[3] " + display.options1[3]); +// System.out.println("display.options1[4] " + display.options1[4]); display.options2[0] = material.opacity; display.options2[1] = material.diffuse; display.options2[2] = material.factor; +// System.out.println("display.options2[0] " + display.options2[0]); +// System.out.println("display.options2[1] " + display.options2[1]); +// System.out.println("display.options2[2] " + display.options2[2]); cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); +// System.out.println("display.options3[0] " + display.options3[0]); +// System.out.println("display.options3[1] " + display.options3[1]); +// System.out.println("display.options3[2] " + display.options3[2]); display.options4[0] = material.cameralight/0.2f; display.options4[1] = material.subsurface; display.options4[2] = material.sheen; +// System.out.println("display.options4[0] " + display.options4[0]); +// System.out.println("display.options4[1] " + display.options4[1]); +// System.out.println("display.options4[2] " + display.options4[2]); // if (display.CURRENTANTIALIAS > 0) // display.options3[3] /= 4; @@ -2382,6 +2396,128 @@ public GL GetGL() // INTERFACE { return currentGL; + } + + private void GetRemoteZip(String url, String name, boolean unzip, boolean save) + { + java.net.URL u; + InputStream is = null; + DataInputStream dis; + java.util.zip.ZipInputStream zis; + //String s; + + System.out.println("GetRemoteZip " + name); + + int total = 0; // dis.available(); + + byte[] bytes = new byte[16384]; + + try + { + u = new java.net.URL(url + name); + is = u.openStream(); + + System.out.println(url + name); + + if (unzip) + { + //dis = new DataInputStream(new BufferedInputStream(is)); + zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is)); + //while ((s = dis.readLine()) != null) + + if (save) + new java.io.File(name).mkdirs(); + + // FileOutputStream stream = new FileOutputStream("test.zip"); + // + // int count; + // + // while ((count = dis.read(bytes)) != -1) + // { + // //System.out.println(s); + // System.out.println(count); + // total += count; + // stream.write(bytes); + // } + // + // stream.close(); + + // now iterate through each item in the stream. The get next + // entry call will return a ZipEntry for each file in the + // stream + java.util.zip.ZipEntry entry; + while((entry = zis.getNextEntry())!=null) + { + if (entry.getName().endsWith(".gsm")) + { + continue; + } + + String s = String.format("Entry: %s len %d added %TD", + entry.getName(), entry.getSize(), + new java.util.Date(entry.getTime())); + System.out.println(s); + + if (save) + { + // Once we get the entry from the stream, the stream is + // positioned read to read the raw data, and we keep + // reading until read returns 0 or less. + String outpath = name + "/" + entry.getName(); + FileOutputStream output = null; + try + { + output = new FileOutputStream(outpath); + int len = 0; + while ((len = zis.read(bytes)) > 0) + { + output.write(bytes, 0, len); + } + } + finally + { + // we must always close the output file + if(output!=null) output.close(); + } + } + } + } + } + catch (java.net.MalformedURLException mue) + { + System.err.println("Ouch - a MalformedURLException happened."); + mue.printStackTrace(); + //System.exit(2); + } + catch (IOException ioe) + { + //System.err.println("Oops - an IOException happened."); + //ioe.printStackTrace(); + //System.exit(3); + } + finally + { + try + { + if (is != null) + is.close(); + } + catch (IOException ioe) + { + } + } + + // System.out.println("length = " + total); + +// try +// { +// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); +// } +// catch (Exception e) +// { +// e.printStackTrace(); +// } + } /**/ @@ -9366,11 +9502,35 @@ jy8[3] = 0.5f; } - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation float[] options3 = new float[]{1, 1, 1, 0}; // fog color float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen + void ResetOptions() + { + options1[0] = 100; + options1[1] = 0.025f; + options1[2] = 0.01f; + options1[3] = 0; + options1[4] = 0; + + options2[0] = 0; + options2[1] = 0.75f; + options2[2] = 0; + options2[3] = 0; + + options3[0] = 1; + options3[1] = 1; + options3[2] = 1; + options3[3] = 0; + + options4[0] = 1; + options4[1] = 0; + options4[2] = 1; + options4[3] = 0; + } + static int imagecount = 0; // movie generation static int jitter = 0; @@ -10481,6 +10641,7 @@ ANTIALIAS = 0; //System.out.println("RESTART"); AAtimer.restart(); + Globals.TIMERRUNNING = true; } } } @@ -11459,7 +11620,7 @@ static boolean zoomonce = false; - void CreateSelectedPoint() + static void CreateSelectedPoint() { if (selectedpoint == null) { @@ -11479,6 +11640,9 @@ void DrawObject(GL gl, boolean draw) { + // To clear camera values + ResetOptions(); + //System.out.println("DRAW OBJECT " + mouseDown); // DrawMode() = SELECTION; //GL gl = getGL(); @@ -12046,7 +12210,7 @@ for (int i = tp.size(); --i >= 0;) { //for (int count = tp.get(i).GetTransformCount(); --count>=0;) - LA.xformPos(light, tp.get(i).GlobalTransform(), light); + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); } @@ -13333,9 +13497,10 @@ "DP3 " + dest + ".z," + "normals," + "eye;" + "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + //"MOV " + dest + ".w," + "normal.z;" + - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + - //"MOV " + dest + ".z," + "params2.w;" + +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + + + "MOV " + dest + ".z," + "params2.w;" + // EXACT "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + "RCP " + dest + ".w," + dest + ".w;" + //"RSQ " + dest + ".w," + dest + ".w;" + @@ -13840,6 +14005,7 @@ else if (evt.getSource() == AAtimer) { + Globals.TIMERRUNNING = false; if (mouseDown) { //new Exception().printStackTrace(); @@ -13914,6 +14080,7 @@ return; AAtimer.restart(); // + Globals.TIMERRUNNING = true; // waslive = LIVE; // LIVE = false; @@ -14377,7 +14544,8 @@ info.camera = renderCamera; info.x = x; info.y = y; - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); + object.GetWindow().copy + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -14541,9 +14709,9 @@ ci.camera = renderCamera; if (!isRenderer) { - ObjEditor editWindow = object.editWindow; - Object3D copy = editWindow.copy; - if (copy.doEditClick(ci, 0)) + //ObjEditor editWindow = object.editWindow; + //Object3D copy = editWindow.copy; + if (object.doEditClick(ci, 0)) { setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); } else @@ -15074,9 +15242,9 @@ case '_': kompactbit = 5; break; - case '+': - kompactbit = 6; - break; +// case '+': +// kompactbit = 6; +// break; case ' ': ObjEditor.theFrame.ToggleFullScreen(); repaint(); @@ -15125,8 +15293,15 @@ case DELETE: ClearSelection(); break; - /* case '+': + + //for (int i=0; i<0x7FFFFFFF; i++) + { + //String.format("%08X", i); // "7caca905" + GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true); + } + + /* //fontsize += 1; bbzoom *= 2; repaint(); @@ -15377,7 +15552,7 @@ } */ - object.editWindow.EditSelection(); + object.editWindow.EditSelection(false); } void SelectParent() @@ -16622,6 +16797,8 @@ // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); + CreateSelectedPoint(); + // Will fit the mesh !!! selectedpoint.toParent[0][0] = 0.0001; selectedpoint.toParent[1][1] = 0.0001; @@ -16736,6 +16913,11 @@ //System.out.println("objects[color] = " + objects[color]); //objects[color].Select(); indexcount = 0; + ObjEditor window = object.GetWindow(); + if (window != null && deselect) + { + window.Select(null, deselect, true); + } object.Select(color, deselect); } -- Gitblit v1.6.2