From e24558ddeacfc945b9e9ba0a32b552d04e2ed4dd Mon Sep 17 00:00:00 2001 From: Normand Briere <nbriere@noware.ca> Date: Sun, 02 Jun 2019 20:11:20 -0400 Subject: [PATCH] Selectable mode + new mesh reduction. --- CameraPane.java | 210 +++++++++++++++++++++++++++++++++------------------- 1 files changed, 134 insertions(+), 76 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 8c8c173..7039da8 100644 --- a/CameraPane.java +++ b/CameraPane.java @@ -56,8 +56,6 @@ static int CURRENTANTIALIAS = 0; // 1; /*static*/ boolean RENDERSHADOW = true; /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal - static boolean ANIMATION = false; - static String filename; boolean DISPLAYTEXT = false; //boolean REDUCETEXTURE = true; @@ -92,6 +90,8 @@ static int tickcount = 0; // slow pose issue +static boolean BUTTONLESSWHEEL = false; +static boolean ZOOMBOXMODE = false; static boolean BOXMODE = false; static boolean IMAGEFLIP = false; static boolean SMOOTHFOCUS = false; @@ -106,7 +106,7 @@ static boolean OEIL = true; static boolean OEILONCE = false; // do oeilon then oeiloff static boolean LOOKAT = true; -static boolean RANDOM = true; // false; +static boolean SWITCH = true; // false; static boolean HANDLES = false; // selection doesn't work!! static boolean PAINTMODE = false; @@ -223,6 +223,11 @@ public boolean IsBoxMode() { return BOXMODE; + } + + public boolean IsZoomBoxMode() + { + return ZOOMBOXMODE; } public void ClearDepth() @@ -1612,18 +1617,18 @@ //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); if (!material.multiply) { - display.color = color; + display.color = material.color; display.saturation = material.modulation; } else { - display.color *= color*2; + display.color *= material.color*2; display.saturation *= material.modulation*2; } cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); - float[] colorV = GrafreeD.colorV; + float[] colorV = Grafreed.colorV; /**/ if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) @@ -2135,7 +2140,7 @@ System.err.println("LIVE = " + Globals.isLIVE()); if (!Globals.isLIVE()) // save sound - GrafreeD.savesound = true; // wav.save(); + Grafreed.savesound = true; // wav.save(); // else repaint(); // start loop // may 2013 } @@ -2168,6 +2173,11 @@ public void ToggleBoxMode() { BOXMODE ^= true; + } + + public void ToggleZoomBoxMode() + { + ZOOMBOXMODE ^= true; } public void ToggleSmoothFocus() @@ -2257,7 +2267,7 @@ void ToggleRandom() { - RANDOM ^= true; + SWITCH ^= true; } void ToggleHandles() @@ -4196,6 +4206,7 @@ com.sun.opengl.util.texture.Texture CompressTexture2(String name) { + new Exception().printStackTrace(); System.exit(0); com.sun.opengl.util.texture.Texture texture = null; @@ -8011,7 +8022,7 @@ } } - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE { if (// DrawMode() != 0 || /*tex == null ||*/ ambientOcclusion ) // || !textureon) @@ -8056,7 +8067,7 @@ return; // true; } - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception { CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; @@ -8064,12 +8075,16 @@ { String texname = tex; - String[] split = tex.split("Textures"); - if (split.length > 1) - texname = "/Users/nbriere/Textures" + split[split.length-1]; - else - if (!texname.startsWith("/")) - texname = "/Users/nbriere/Textures/" + texname; +// String[] split = tex.split("Textures"); +// if (split.length > 1) +// texname = "/Users/nbriere/Textures" + split[split.length-1]; +// else +// if (!texname.startsWith("/")) +// texname = "/Users/nbriere/Textures/" + texname; + if (!new File(tex).exists()) + { + texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; + } if (CACHETEXTURE) texture = textures.get(texname); // TEXTURE CACHE @@ -8169,7 +8184,9 @@ texturedata = GetFileTexture(cachename, processbump, resolution); - if (texturedata != null) + if (texturedata == null) + throw new Exception(); + texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); //texture = GetTexture(tex, bump); } @@ -8291,7 +8308,7 @@ return texture; } - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception { CacheTexture texture = GetCacheTexture(tex, bump, resolution); @@ -8309,14 +8326,14 @@ return texture!=null?texture.texture:null; } - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception { CacheTexture texture = GetCacheTexture(tex, bump, resolution); return texture!=null?texture.texturedata:null; } - boolean BindTexture(String tex, boolean bump, int resolution) + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception { if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) { @@ -9382,7 +9399,7 @@ //gl.glFlush(); gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); - if (ANIMATION && ABORTED) + if (Globals.ANIMATION && ABORTED) { System.err.println(" ABORTED FRAME"); break; @@ -9412,7 +9429,7 @@ setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); // save image - if (ANIMATION && !ABORTED) + if (Globals.ANIMATION && !ABORTED) { VPwidth = viewport[2]; VPheight = viewport[3]; @@ -9523,11 +9540,11 @@ // imagecount++; - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; if (!BOXMODE) { - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); } if (!BOXMODE) @@ -9565,7 +9582,7 @@ ABORTED = false; } else - GrafreeD.wav.cursor += 735 * ACSIZE; + Grafreed.wav.cursor += 735 * ACSIZE; if (false) { @@ -10228,11 +10245,11 @@ public void display(GLAutoDrawable drawable) { - if (GrafreeD.savesound && GrafreeD.hassound) + if (Grafreed.savesound && Grafreed.hassound) { - GrafreeD.wav.save(); - GrafreeD.savesound = false; - GrafreeD.hassound = false; + Grafreed.wav.save(); + Grafreed.savesound = false; + Grafreed.hassound = false; } // if (DEBUG_SELECTION) // { @@ -10362,7 +10379,7 @@ Object3D theobject = object; Object3D theparent = object.parent; object.parent = null; - object = (Object3D)GrafreeD.clone(object); + object = (Object3D)Grafreed.clone(object); object.Stripify(); if (theobject.selection == null || theobject.selection.Size() == 0) theobject.PreprocessOcclusion(this); @@ -10783,7 +10800,16 @@ // Bump noise gl.glActiveTexture(GL.GL_TEXTURE6); //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); - BindTexture(NOISE_TEXTURE, false, 2); + + try + { + BindTexture(NOISE_TEXTURE, false, 2); + } + catch (Exception e) + { + System.err.println("FAILED: " + NOISE_TEXTURE); + } + gl.glActiveTexture(GL.GL_TEXTURE0); gl.glEnable(GL.GL_TEXTURE_2D); @@ -11247,8 +11273,14 @@ { renderpass++; // System.out.println("Draw object... "); + STEP = 1; if (FAST) // in case there is no script - STEP = 16; + STEP = 8; + + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) + { + STEP *= 4; + } //object.FullInvariants(); @@ -11262,8 +11294,8 @@ e.printStackTrace(); } - if (GrafreeD.RENDERME > 0) - GrafreeD.RENDERME--; // mechante magouille + if (Grafreed.RENDERME > 0) + Grafreed.RENDERME--; // mechante magouille Globals.ONESTEP = false; } @@ -11333,7 +11365,14 @@ usedtextures.clear(); - BindTextures(DEFAULT_TEXTURES, 2); + try + { + BindTextures(DEFAULT_TEXTURES, 2); + } + catch (Exception e) + { + System.err.println("FAILED: " + DEFAULT_TEXTURES); + } } //System.out.println("--> " + stackdepth); // GrafreeD.traceon(); @@ -11424,7 +11463,14 @@ if (checker != null && DrawMode() == DEFAULT) { //BindTexture(IMMORTAL_TEXTURE); - BindTextures(checker.GetTextures(), checker.texres); + try + { + BindTextures(checker.GetTextures(), checker.texres); + } + catch (Exception e) + { + System.err.println("FAILED: " + checker.GetTextures()); + } // NEAREST GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); DrawChecker(gl); @@ -12586,8 +12632,10 @@ "MAX ndotl.x, ndotl.x, -ndotl.x;" + "SUB temp.x, one.x, ndotl.x;" + - "ADD temp.x, temp.x, options2.z;" + // lightsheen - "ADD temp.y, one.y, options2.y;" + // sursurface + // Tuning for default skin + //"ADD temp.x, temp.x, options2.z;" + // lightsheen + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen + "ADD temp.y, one.y, options2.y;" + // subsurface "MUL temp.x, temp.x, temp.y;" + "MUL saturation, saturation, temp.xxxx;" + @@ -13496,7 +13544,7 @@ public void mousePressed(MouseEvent e) { //System.out.println("mousePressed: " + e); - clickStart(e.getX(), e.getY(), e.getModifiersEx()); + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); } static long prevtime = 0; @@ -13523,6 +13571,7 @@ //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); + if (BUTTONLESSWHEEL) if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) { return; @@ -13531,7 +13580,7 @@ boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); // TIMER - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR { keepboxmode = BOXMODE; keepsupport = SUPPORT; @@ -13571,8 +13620,8 @@ // mode |= META; //} - SetMouseMode(WHEEL | e.getModifiersEx()); - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); anchorX = ax; anchorY = ay; prevX = px; @@ -13632,6 +13681,10 @@ // wasliveok = true; // waslive = false; + // May 2019 Forget it: + if (true) + return; + // source == timer if (mouseDown) { @@ -13670,7 +13723,7 @@ javax.swing.Timer timer = new javax.swing.Timer(350, this); - void clickStart(int x, int y, int modifiers) + void clickStart(int x, int y, int modifiers, int modifiersex) { if (!wasliveok) return; @@ -13687,7 +13740,7 @@ // touched = true; // main DL if (isRenderer) { - SetMouseMode(modifiers); + SetMouseMode(modifiers, modifiersex); } selectX = anchorX = x; @@ -13700,7 +13753,7 @@ clicked = true; hold = false; - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection { // System.out.println("RESTART II " + modifiers); @@ -13731,7 +13784,7 @@ info.camera = renderCamera; info.x = x; info.y = y; - info.modifiers = modifiers; + info.modifiers = modifiersex; editObj = object.doEditClick(info, 0); if (!editObj) { @@ -13748,11 +13801,11 @@ public void mouseDragged(MouseEvent e) { + //System.out.println("mouseDragged: " + e); if (isRenderer) movingcamera = true; //if (drawing) //return; - //System.out.println("mouseDragged: " + e); if ((e.getModifiersEx() & CTRL) != 0 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) { @@ -13760,7 +13813,7 @@ clickEnd(e.getX(), e.getY(), e.getModifiersEx()); } else - drag(e.getX(), e.getY(), e.getModifiersEx()); + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); //try { Thread.sleep(1); } catch (Exception ex) {} } @@ -13933,6 +13986,7 @@ public void run() { + new Exception().printStackTrace(); System.exit(0); for (;;) { @@ -13996,7 +14050,7 @@ { Globals.lighttouched = true; } - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); } //else } @@ -14096,7 +14150,7 @@ int X, Y; boolean SX, SY; - void drag(int x, int y, int modifiers) + void drag(int x, int y, int modifiers, int modifiersex) { if (IsFrozen()) { @@ -14105,17 +14159,17 @@ drag = true; // NEW - boolean continuous = (modifiers & COMMAND) == COMMAND; + boolean continuous = (modifiersex & COMMAND) == COMMAND; X = x; Y = y; // floating state for animation - MODIFIERS = modifiers; - modifiers &= ~1024; + MODIFIERS = modifiersex; + modifiersex &= ~1024; if (false) // modifiers != 0) { //new Exception().printStackTrace(); - System.out.println("mouseDragged: " + modifiers); + System.out.println("mouseDragged: " + modifiersex); System.out.println("SHIFT = " + SHIFT); System.out.println("CONTROL = " + COMMAND); System.out.println("META = " + META); @@ -14135,7 +14189,7 @@ info.camera = renderCamera; info.x = x; info.y = y; - object.editWindow.copy.doEditDrag(info); + object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); } else { if (x < startX) @@ -14287,7 +14341,6 @@ public void mouseMoved(MouseEvent e) { //System.out.println("mouseMoved: " + e); - if (isRenderer) return; @@ -14335,9 +14388,9 @@ boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection - if (control || command || IsFrozen()) +// No delay if (control || command || IsFrozen()) timeout = true; - else +// ?? May 2019 else // timer.setDelay((modifiers & 128) != 0?0:350); mouseDown = false; if (!control && !command) // june 2013 @@ -14447,7 +14500,7 @@ System.out.println("keyReleased: " + e); } - void SetMouseMode(int modifiers) + void SetMouseMode(int modifiers, int modifiersex) { //System.out.println("SetMouseMode = " + modifiers); //modifiers &= ~1024; @@ -14459,25 +14512,25 @@ //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) // return; //System.out.println("SetMode = " + modifiers); - if ((modifiers & WHEEL) == WHEEL) + if ((modifiersex & WHEEL) == WHEEL) { mouseMode |= ZOOM; } boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); - if (capsLocked || (modifiers & META) == META) + if (capsLocked) // || (modifiers & META) == META) { mouseMode |= VR; // BACKFORTH; } - if ((modifiers & CTRLCLICK) == CTRLCLICK) + if ((modifiersex & CTRLCLICK) == CTRLCLICK) { mouseMode |= SELECT; } - if ((modifiers & COMMAND) == COMMAND) + if ((modifiersex & COMMAND) == COMMAND) { mouseMode |= SELECT; } - if ((modifiers & SHIFT) == SHIFT || forcetranslate) + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) { mouseMode &= ~VR; mouseMode |= TRANSLATE; @@ -14506,7 +14559,7 @@ if (isRenderer) // { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } Globals.theRenderer.keyPressed(key); @@ -14842,7 +14895,7 @@ //RESIZETEXTURE ^= true; //break; case 'z': - RENDERSHADOW ^= true; + Globals.RENDERSHADOW ^= true; Globals.lighttouched = true; repaint(); break; @@ -14966,7 +15019,7 @@ //mode = ROTATE; if ((MODIFIERS & COMMAND) == 0) // VR?? { - SetMouseMode(modifiers); + SetMouseMode(0, modifiers); } } @@ -15100,8 +15153,9 @@ protected void processMouseMotionEvent(MouseEvent e) { - //System.out.println("processMouseMotionEvent: " + mouseMode); - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) { mouseMoved(e); } else @@ -15131,6 +15185,7 @@ void SelectParent() { + new Exception().printStackTrace(); System.exit(0); Composite group = (Composite) object; java.util.Vector selectees = new java.util.Vector(group.selection); @@ -15154,6 +15209,7 @@ void SelectChildren() { + new Exception().printStackTrace(); System.exit(0); /* Composite group = (Composite) object; @@ -15536,6 +15592,7 @@ public boolean mouseDown(Event evt, int x, int y) { System.out.println("mouseDown: " + evt); + System.exit(0); /* locked = true; drag = false; @@ -15579,7 +15636,7 @@ { keyPressed(0, modifiers); } - clickStart(x, y, modifiers); + // clickStart(x, y, modifiers); return true; } @@ -15697,7 +15754,7 @@ { keyReleased(0, 0); } - drag(x, y, modifiers); + drag(x, y, 0, modifiers); return true; } @@ -16267,6 +16324,7 @@ { if (!selection) { + new Exception().printStackTrace(); System.exit(0); return; } @@ -16394,16 +16452,16 @@ System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); } - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); } } if (!movingcamera && !PAINTMODE) object.editWindow.ScreenFitPoint(); // fev 2014 - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) { - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); Object3D group = new Object3D("inst" + paintcount++); @@ -16559,7 +16617,7 @@ gl.glDisable(gl.GL_CULL_FACE); } - if (!RENDERSHADOW) + if (!Globals.RENDERSHADOW) gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); // SB gl.glPolygonOffset(2.5f, 10); @@ -16569,7 +16627,7 @@ //gl.glColorMask(false, false, false, false); //render_scene_from_light_view(gl, drawable, 0, 0); - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) { gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); -- Gitblit v1.6.2