From 44b1501b5c4cd60ea67cc3d0971ed53f53b594e6 Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Sun, 05 May 2019 10:19:33 -0400
Subject: [PATCH] Support for right click.

---
 CameraPane.java |  108 +++++++++++++++++++++++++++++++-----------------------
 1 files changed, 62 insertions(+), 46 deletions(-)

diff --git a/CameraPane.java b/CameraPane.java
index 296ba69..8658cf7 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;
@@ -86,7 +84,7 @@
 static    boolean FULLSCREEN = false;
 static    boolean SUPPORT = true;
 static    boolean INERTIA = true;
-static    boolean FAST = true; // false;
+static    boolean FAST = false;
 static    boolean SLOWPOSE = false;
 static    boolean FOOTCONTACT = true;
 
@@ -108,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;
 
@@ -2269,7 +2267,7 @@
 
     void ToggleRandom()
     {
-        RANDOM ^= true;
+        SWITCH ^= true;
     }
 
     void ToggleHandles()
@@ -4208,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;
 
@@ -8076,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
@@ -9394,7 +9397,7 @@
             //gl.glFlush();
             gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
 
-            if (ANIMATION && ABORTED)
+            if (Globals.ANIMATION && ABORTED)
             {
     System.err.println("    ABORTED FRAME");
                 break;
@@ -9424,7 +9427,7 @@
         setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
 
         // save image
-        if (ANIMATION && !ABORTED)
+        if (Globals.ANIMATION && !ABORTED)
         {
             VPwidth = viewport[2];
             VPheight = viewport[3];
@@ -9535,7 +9538,7 @@
             
 //            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)
             {
@@ -11259,8 +11262,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();
         
@@ -12598,8 +12607,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;" +
@@ -12747,7 +12758,7 @@
               "MUL final.y, fragment.texcoord[0].x, c256;" +
               "FLR final.x, final.y;" +
               "SUB final.y, final.y, final.x;" +
-              //"MUL final.x, final.x, c256i;" +
+              "MUL final.x, final.x, c256i;" +
               "MOV final.z, zero.x;" +
               "MOV final.a, one.w;":""
               ) +
@@ -12755,7 +12766,7 @@
               "MUL final.y, fragment.texcoord[0].y, c256;" +
               "FLR final.x, final.y;" +
               "SUB final.y, final.y, final.x;" +
-              //"MUL final.x, final.x, c256i;" +
+              "MUL final.x, final.x, c256i;" +
               "MOV final.z, zero.x;" +
               "MOV final.a, one.w;":""
               ) +
@@ -13508,7 +13519,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;
@@ -13584,8 +13595,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;
@@ -13683,7 +13694,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;
@@ -13700,7 +13711,7 @@
 //        touched = true; // main DL
         if (isRenderer)
         {
-            SetMouseMode(modifiers);
+            SetMouseMode(modifiers, modifiersex);
         }
 
         selectX = anchorX = x;
@@ -13713,7 +13724,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);
@@ -13744,7 +13755,7 @@
             info.camera = renderCamera;
             info.x = x;
             info.y = y;
-            info.modifiers = modifiers;
+            info.modifiers = modifiersex;
             editObj = object.doEditClick(info, 0);
             if (!editObj)
             {
@@ -13773,7 +13784,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) {}
     }
@@ -13946,6 +13957,7 @@
         
         public void run()
         {
+                new Exception().printStackTrace();
             System.exit(0);
             for (;;)
             {
@@ -14009,7 +14021,7 @@
                     {
                         Globals.lighttouched = true;
                     }
-                    drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
+                    drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
                 }
             //else
             }
@@ -14109,7 +14121,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())
         {
@@ -14118,17 +14130,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);
@@ -14148,7 +14160,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)
@@ -14349,7 +14361,7 @@
         
         if (control || command || IsFrozen())
             timeout = true;
-        else
+// ?? May 2019        else
        // timer.setDelay((modifiers & 128) != 0?0:350);
         mouseDown = false;
     if (!control && !command) // june 2013
@@ -14459,7 +14471,7 @@
         System.out.println("keyReleased: " + e);
     }
 
-    void SetMouseMode(int modifiers)
+    void SetMouseMode(int modifiers, int modifiersex)
     {
         //System.out.println("SetMouseMode = " + modifiers);
         //modifiers &= ~1024;
@@ -14471,25 +14483,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;
@@ -14518,7 +14530,7 @@
 
         if (isRenderer) //
         {
-            SetMouseMode(modifiers);
+            SetMouseMode(0, modifiers);
         }
 
         Globals.theRenderer.keyPressed(key);
@@ -14978,7 +14990,7 @@
         //mode = ROTATE;
         if ((MODIFIERS & COMMAND) == 0) // VR??
         {
-            SetMouseMode(modifiers);
+            SetMouseMode(0, modifiers);
         }
     }
 
@@ -15114,7 +15126,7 @@
     {
         //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 && (mouseMode & SELECT) == 0)
+        if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
         {
             mouseMoved(e);
         } else
@@ -15144,6 +15156,7 @@
 
     void SelectParent()
     {
+                new Exception().printStackTrace();
         System.exit(0);
         Composite group = (Composite) object;
         java.util.Vector selectees = new java.util.Vector(group.selection);
@@ -15167,6 +15180,7 @@
 
     void SelectChildren()
     {
+                new Exception().printStackTrace();
         System.exit(0);
         /*
         Composite group = (Composite) object;
@@ -15549,6 +15563,7 @@
     public boolean mouseDown(Event evt, int x, int y)
     {
         System.out.println("mouseDown: " + evt);
+        System.exit(0);
         /*
         locked = true;
         drag = false;
@@ -15592,7 +15607,7 @@
         {
             keyPressed(0, modifiers);
         }
-        clickStart(x, y, modifiers);
+ //       clickStart(x, y, modifiers);
         return true;
     }
 
@@ -15710,7 +15725,7 @@
         {
             keyReleased(0, 0);
         }
-        drag(x, y, modifiers);
+        drag(x, y, 0, modifiers);
         return true;
     }
 
@@ -16280,6 +16295,7 @@
         {
             if (!selection)
             {
+                new Exception().printStackTrace();
                 System.exit(0);
                 return;
             }

--
Gitblit v1.6.2