From 57c5b6cd8d12ffdaa3e0b099451e3c031012750a Mon Sep 17 00:00:00 2001
From: Normand Briere <nbriere@noware.ca>
Date: Thu, 03 Oct 2019 20:34:32 -0400
Subject: [PATCH] Fix lighttouched

---
 CameraPane.java |  429 +++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 335 insertions(+), 94 deletions(-)

diff --git a/CameraPane.java b/CameraPane.java
index 706f7ec..b60cf14 100644
--- a/CameraPane.java
+++ b/CameraPane.java
@@ -1,4 +1,5 @@
 
+import com.bulletphysics.dynamics.RigidBody;
 import java.awt.*;
 import java.awt.event.*;
 import java.awt.image.*;
@@ -123,7 +124,7 @@
 static    boolean LOCALTRANSFORM = false;
 static    boolean FULLSCREEN = false;
 static    boolean SUPPORT = true;
-static    boolean INERTIA = true;
+static    boolean INERTIA = false; // true;
 static    boolean FAST = false;
 static    boolean SLOWPOSE = false;
 static    boolean FOOTCONTACT = true;
@@ -134,7 +135,7 @@
 static    boolean ZOOMBOXMODE = false;
 static    boolean BOXMODE = false;
 static    boolean IMAGEFLIP = false;
-static    boolean SMOOTHFOCUS = false;
+static    boolean SMOOTHFOCUS = true; // false;
 static    boolean SPEAKERMOCAP = true; // jan 2014 false;
 static    boolean SPEAKERCAMERA = false;
 static    boolean SPEAKERFOCUS = false;
@@ -221,7 +222,7 @@
         cameras = new Camera[2];
         targetLookAts = new cVector[2];
 
-        SetCamera(cam);
+        SetCamera(cam, true);
 
         // Warning: not used.
         //SetLight(new Camera(new cVector(15, 10, -20)));
@@ -249,7 +250,7 @@
     
     public javax.media.opengl.GL GetGL0()
     {
-            return null;
+            return currentGL;
     }
     
     public int GenList()
@@ -1529,7 +1530,7 @@
                 }
             }
             float b = 0;
-            if (obj.support != null && obj.link2master)
+            if (obj.support != null && obj.Link2Support())
             {
                 b = 1;
             }
@@ -2064,7 +2065,7 @@
     
     static int camerachangeframe;
     
-    public boolean SetCamera(Camera cam)
+    public boolean SetCamera(Camera cam, boolean set)
     {
         // may 2014 if (cam == cameras[0] || cam == cameras[1])
         //    return false;
@@ -2092,7 +2093,10 @@
             if (cameras[i] == null)
             {
                 cameras[i] = new Camera(cam.viewCode);
-                
+            }
+            
+            if (set)
+            {
                 cameras[i].setAim(cam.location, cam.lookAt);
                 cameras[i].shaper_fovy = cam.shaper_fovy;
                 cameras[i].UP.set(cam.UP);
@@ -2106,7 +2110,7 @@
         // Start with free camera
         SwitchCameras(true);
         
-        pingthread.jump = true; // optional?
+//        pingthread.jump = true; // optional?
         
         if (TRACKONCE)
         {
@@ -2293,18 +2297,6 @@
     public void ToggleTrack()
     {
         TRACK ^= true;
-        if (TRACK)
-        {
-            if (object.selection != null &&
-                object.selection.size() > 0 &&
-                object.selection.elementAt(0) != null &&
-                !(object.selection.elementAt(0) instanceof Camera) &&
-                !(object.selection.elementAt(0) instanceof ScriptNode))
-            {
-                trackedobject = object.selection.elementAt(0);
-                repaint();
-            }
-        }
         
         repaint();
     }
@@ -3598,6 +3590,8 @@
            };
      /**/
         
+        static Object3D lastObject;
+        
         //com.sun.opengl.util.texture.Texture
         TextureData
                 GetFileTexture(String name, boolean bump, int resolution)
@@ -3634,6 +3628,8 @@
                 //    return null;
                     //if (i == 2)
                     //    return null;
+                    // TIFF issue sept 2019
+                    System.err.println("lastObject = " + lastObject);
                     e.printStackTrace();
                     name = name.split("\\.tif")[0] + ".jpg";
                 }
@@ -6966,30 +6962,30 @@
                     short residu = 0;
 
                 // wraparound workarounds
-                    short fuck = (short) (buffer[i] & 0xFF);
+                    short ww = (short) (buffer[i] & 0xFF);
                     /*
-                    residu += (fuck%2);
-                    if(fuck/2 < 256-residu/2)
+                    residu += (ww%2);
+                    if(ww/2 < 256-residu/2)
                     {
-                    fuck = (short)((fuck/2) + residu/2);
+                    ww = (short)((ww/2) + residu/2);
                     if(residu == 2)
                     residu = 0;
                     }
                     else
                     {
                     residu = 0;
-                    fuck /= 2;
+                    ww /= 2;
                     }
                      */
-                    if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254)
+                    if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254)
                     {
-                        fuck /= 2;
+                        ww /= 2;
                     } else
                     {
-                        fuck = (short) ((fuck / 2) + fuck % 2);
+                        ww = (short) ((ww / 2) + ww % 2);
                     }
 
-                    buffer[i] = (byte) fuck;
+                    buffer[i] = (byte) ww;
                 }
             //System.out.print(bytes[i] + " ");
             //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps;
@@ -8461,7 +8457,7 @@
                                 new Exception().printStackTrace();
                         } else
                         {
-                        if (texname.startsWith("@"))
+                        if (texname.startsWith("@") && textureon)
                         {
                 //            texturecache = textures.get(texname); // suspicious
                             if (texturecache == null)
@@ -9847,7 +9843,7 @@
             
             boolean vr = capsLocked && !lightMode;
             
-            accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 2 : 1),
+            accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1),
                     ratio,
                     //near_plane, far_plane,
                     renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(),
@@ -10765,7 +10761,9 @@
         }
         /**/
 
-        if (selection)
+        boolean control = ((modifiers & CTRL) != 0);
+        
+        if (selection && (!Globals.isLIVE() || control))
         {
             selectbuffer.display();
             return;
@@ -10867,30 +10865,59 @@
                 
                 if (keys[DOWN_ARROW])
                 {
+                    speed = ++speedkey[DOWN_ARROW];
+                    if (speed > 20)
+                        speed = 20;
                     GoDown(modifiers);
                     keyon = true;
                 }
+                else
+                    speedkey[DOWN_ARROW] = 0;
 
                 if (keys[UP_ARROW])
                 {
+                    speed = ++speedkey[UP_ARROW];
+                    if (speed > 20)
+                        speed = 20;
                     GoUp(modifiers);
                     keyon = true;
                 }
+                else
+                    speedkey[UP_ARROW] = 0;
 
                 if (keys[LEFT_ARROW])
                 {
+                    speed = ++speedkey[LEFT_ARROW];
+                    if (speed > 20)
+                        speed = 20;
                     GoLeft(modifiers);
                     keyon = true;
                 }
+                else 
+                    speedkey[LEFT_ARROW] = 0;
 
                 if (keys[RIGHT_ARROW])
                 {
+                    speed = ++speedkey[RIGHT_ARROW];
+                    if (speed > 20)
+                        speed = 20;
                     GoRight(modifiers);
+                    keyon = true;
+                }
+                else
+                    speedkey[RIGHT_ARROW] = 0;
+                
+                if (Globals.WALK && capsLocked)
+                {
+                    Walk();
                     keyon = true;
                 }
                 
                 if (keyon)
+                {
                     repaint();
+                }
+                
                 //pingthread.mute = false;
             }
             
@@ -11483,7 +11510,8 @@
                 {
                     boolean vr = capsLocked && !lightMode;
                     
-                    glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 2 : 1), ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance());
+                    glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 1.2 : 1),
+                            ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance());
                 }
             }
 
@@ -11839,8 +11867,11 @@
             repaint();
         }
         
-        if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
+        if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013
+        {
+            renderCamera.computeTransform();
             repaint();
+        }
         
         displaydone = true;
     }
@@ -11915,9 +11946,23 @@
         //GL gl = getGL();
         if ((TRACK || SHADOWTRACK) || zoomonce)
         {
+        if (TRACK)
+        {
+            if (object.selection != null &&
+                object.selection.size() > 0 &&
+                object.selection.elementAt(0) != null &&
+                !(object.selection.elementAt(0) instanceof Camera) &&
+                !(object.selection.elementAt(0) instanceof ScriptNode))
+            {
+                trackedobject = object.selection.elementAt(0);
+                //repaint();
+            }
+            else
+                trackedobject = null;
+        }
             if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
                 object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
-            pingthread.StepToTarget(true); // true);
+            pingthread.StepToTarget(); // true);
        //     zoomonce = false;
         }
 
@@ -14298,6 +14343,7 @@
     public void mouseClicked(MouseEvent e)
     {
         System.out.println("mouseClicked: " + e);
+        System.exit(0);
     }
 
     public void mousePressed(MouseEvent e)
@@ -14382,7 +14428,7 @@
         //}
         
         SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
-        drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
+        drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx());
         anchorX = ax;
         anchorY = ay;
         prevX = px;
@@ -14477,8 +14523,9 @@
 // fev 2014???
             if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
                 object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
-            pingthread.StepToTarget(true); // true);
+            pingthread.StepToTarget(); // true);
         }
+        
     //    if (!LIVE)
             super.repaint();
     }
@@ -14573,8 +14620,8 @@
         
         //if (drawing)
         //return;
-        if ((e.getModifiersEx() & CTRL) != 0
-            || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
+        if ((e.getModifiersEx() & CTRL) != 0 ||
+            (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
         {
             //System.out.println("mouseDragged: " + e);
             clickEnd(e.getX(), e.getY(), e.getModifiersEx());
@@ -14598,11 +14645,17 @@
             return targetLookAt;
     }
 
+        javax.vecmath.Point3d eye = new javax.vecmath.Point3d();
+        javax.vecmath.Point3d eye2 = new javax.vecmath.Point3d();
+        javax.vecmath.Vector3d dir = new javax.vecmath.Vector3d();
+
+                
     class PingThread extends Thread
     {
         boolean jump;
+        boolean live;
         
-        boolean mute;
+        boolean mute = false;
         
 //        void JumpToTarget()
 //        {
@@ -14618,8 +14671,94 @@
         // only one thread!? synchronized
                 void StepToTarget(boolean jump)
         {
+            RigidBody.pos.x = 0;
+            RigidBody.pos.y = 0;
+            RigidBody.pos.z = 0;
+            if (RigidBody.justclicked)
+            {
+//                RigidBody.pos.x = (float)manipCamera.lookAt.x;
+//                RigidBody.pos.y = (float)manipCamera.lookAt.y;
+//                RigidBody.pos.z = (float)manipCamera.lookAt.z;
+                                 //       System.err.println("selected point = " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][1]) + " " + Trunk(selectedpoint.toParent[3][2]));
+                CreateSelectedPoint();
+                
+                RigidBody.pos.x = (float)selectedpoint.toParent[3][0];
+                RigidBody.pos.y = (float)selectedpoint.toParent[3][1];
+                RigidBody.pos.z = (float)selectedpoint.toParent[3][2];
+
+                RigidBody.wind.set(RigidBody.pos);
+                RigidBody.wind.x -= (float)manipCamera.location.x;
+                RigidBody.wind.y -= (float)manipCamera.location.y;
+                RigidBody.wind.z -= (float)manipCamera.location.z;
+                RigidBody.wind.normalize();
+            }
+                    
             if (mute)
                 return;
+            
+            if (capsLocked && manipCamera.viewCode == 0)
+            {
+                eye.x = manipCamera.location.x;
+                eye.y = manipCamera.location.y + 0.25;
+                eye.z = manipCamera.location.z;
+
+                dir.y = -1;
+
+                Ray ray = new Ray(eye, dir);
+
+                IntersectResult res = new IntersectResult();
+                res.t = Double.POSITIVE_INFINITY;
+
+                tmp.set(targetLookAt);
+                tmp.sub(manipCamera.location);
+                
+                double dist = tmp.length();
+                
+                tmp.normalize();
+                    
+                eye2.x = manipCamera.location.x + tmp.x * 0.25;
+                eye2.y = manipCamera.location.y + 0.25;
+                eye2.z = manipCamera.location.z + tmp.z * 0.25;
+
+                Ray ray2 = new Ray(eye2, dir);
+
+                IntersectResult res2 = new IntersectResult();
+                res2.t = Double.POSITIVE_INFINITY;
+
+                if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25)
+                {
+                    //tmp.set(manipCamera.location);
+
+                    manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t;
+                    manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5;
+                    manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t;
+
+                    //tmp.sub(manipCamera.location);
+
+                    targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t;
+                    targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5;
+                    targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t;
+                    
+                    targetLookAt.sub(manipCamera.location);
+                    targetLookAt.normalize();
+                    targetLookAt.mul(dist);
+                    targetLookAt.add(manipCamera.location);
+                    
+                    //if (tmp.dot(tmp) > 0.000001)
+                    //    System.out.println("INTERSECTION " + manipCamera.location);
+
+                    manipCamera.lookAt.set(targetLookAt);
+                    
+                    tmp.x = res.n.x;
+                    tmp.y = res.n.y;
+                    tmp.z = res.n.z;
+                    tmp.x += res2.n.x;
+                    tmp.y += res2.n.y;
+                    tmp.z += res2.n.z;
+                    tmp.normalize();
+                    manipCamera.UP.set(tmp);
+                }
+            }
             
             tmp.set(targetLookAt);
             tmp.sub(manipCamera.lookAt); // june 2014
@@ -14658,7 +14797,7 @@
                 
                 if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target
                 {
-                    jump = true; // step = 1;
+                    // sep 2019 jump = true; // step = 1;
                 }
                 
                 if (OEILONCE && OEIL)
@@ -14693,7 +14832,10 @@
                 if (tmp.dot(tmp) < 0.00001)
                 {
                     zoomonce = false;
+                    live = false;
                 }
+                else
+                    live = true;
                 
                 tmp.mul(step > step2 ? step : step2);
             }
@@ -14720,7 +14862,7 @@
             {
                 if (LOOKAT)
                     manipCamera.lookAt.add(tmp);
-                if (OEIL)
+                if (OEIL && !capsLocked)
                     manipCamera.location.add(tmp);
                 
                 {
@@ -14735,7 +14877,10 @@
                     lightCamera.computeTransform();
                     }
                 }
-                manipCamera.computeTransform();
+                if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0)
+                {
+                    manipCamera.computeTransform();
+                }
             }
 // ??????            mouseDown = true;
             //System.out.println("----------------   ----------      Paint " + tmp.length2());
@@ -14828,11 +14973,32 @@
             }
         }
         }
+    
     PingThread pingthread = new PingThread();
-    int delta = 2;
-    int speed = 2;
+    int delta = 1;
+    int speed = 1;
+    int walk = 8;
     boolean autorepeat = false;
 
+    void Walk()
+    {
+        manipCamera.BackForth(0, walk, 1000);
+        
+        targetLookAt.set(manipCamera.lookAt);
+    }
+    
+    void ViewAngle(float dy)
+    {
+        double factor = Math.exp(-dy/300.0); // (1 + dy/100);
+                    
+        if (manipCamera.shaper_fovy * factor > 1 &&
+            manipCamera.shaper_fovy * factor < 150)
+        {
+            manipCamera.shaper_fovy *= factor;
+            //System.out.println("fovy = " + shaper_fovy);
+        }
+    }
+    
     void GoDown(int mod)
     {
         MODIFIERS |= COMMAND;
@@ -14840,21 +15006,30 @@
         /**/
         if((mod&SHIFT) == SHIFT)
         {
+//            if (isVR)
+//                manipCamera.RotateInterest(0, speed);
+//            else
             if (isVR)
-                manipCamera.RotateInterest(0, speed);
+                ViewAngle(-speed*delta);
+            else
+                manipCamera.Translate(0, -speed*delta, getWidth());
+        }
+        else
+        {
+            if (isVR)
+                manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
             else
                 manipCamera.RotatePosition(0, -speed);
         }
-        else
-            manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
+        
         /**/
-        if ((mod & SHIFT) == SHIFT)
-        {
-            mouseMode = mouseMode; // VR??
-        } else
-        {
-            mouseMode |= BACKFORTH;
-        }
+//        if ((mod & SHIFT) == SHIFT)
+//        {
+//            mouseMode = mouseMode; // VR??
+//        } else
+//        {
+//            mouseMode |= BACKFORTH;
+//        }
 
         targetLookAt.set(manipCamera.lookAt);
         
@@ -14864,27 +15039,38 @@
 
     void GoUp(int mod)
     {
+                RigidBody.justclicked = true;
+        
         MODIFIERS |= COMMAND;
         /**/
         boolean isVR = (mouseMode&VR)!=0;
         
         if((mod&SHIFT) == SHIFT)
         {
+//            if (isVR)
+//                manipCamera.RotateInterest(0, -speed);
+//            else
             if (isVR)
-                manipCamera.RotateInterest(0, -speed);
+                ViewAngle(speed*delta);
+            else
+                manipCamera.Translate(0, speed*delta, getWidth());
+        }
+        else
+        {
+            if (isVR)
+                manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
             else
                 manipCamera.RotatePosition(0, speed);
         }
-        else
-            manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
+        
         /**/
-        if ((mod & SHIFT) == SHIFT)
-        {
-            mouseMode = mouseMode;
-        } else
-        {
-            mouseMode |= BACKFORTH;
-        }
+//        if ((mod & SHIFT) == SHIFT)
+//        {
+//            mouseMode = mouseMode;
+//        } else
+//        {
+//            mouseMode |= BACKFORTH;
+//        }
 
         targetLookAt.set(manipCamera.lookAt);
         
@@ -14897,22 +15083,23 @@
         MODIFIERS |= COMMAND;
         /**/
         if((mod&SHIFT) == SHIFT)
-            manipCamera.Translate(speed*delta, 0, getWidth());
+            manipCamera.Translate(speed, 0, getWidth());
         else
         {
             if ((mouseMode&VR)!=0)
-                manipCamera.RotateInterest(-speed, 0);
+                manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0);
             else
-                manipCamera.RotatePosition(speed, 0);
+                manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0);
         }
+        
         /**/
-        if ((mod & SHIFT) == SHIFT)
-        {
-            mouseMode = mouseMode;
-        } else
-        {
-            mouseMode |= ROTATE;
-        } // TRANSLATE;
+//        if ((mod & SHIFT) == SHIFT)
+//        {
+//            mouseMode = mouseMode;
+//        } else
+//        {
+//            mouseMode |= ROTATE;
+//        } // TRANSLATE;
 
         //System.err.println("lookAt = " + manipCamera.lookAt);
         //System.err.println("location = " + manipCamera.location);
@@ -14928,23 +15115,23 @@
         MODIFIERS |= COMMAND;
         /**/
         if((mod&SHIFT) == SHIFT)
-            manipCamera.Translate(-speed*delta, 0, getWidth());
+            manipCamera.Translate(-speed, 0, getWidth());
         else
         {
             if ((mouseMode&VR)!=0)
-                manipCamera.RotateInterest(speed, 0);
+                manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0);
             else
-                manipCamera.RotatePosition(-speed, 0);
+                manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0);
         }
         
         /**/
-        if ((mod & SHIFT) == SHIFT)
-        {
-            mouseMode = mouseMode;
-        } else
-        {
-            mouseMode |= ROTATE;
-        } // TRANSLATE;
+//        if ((mod & SHIFT) == SHIFT)
+//        {
+//            mouseMode = mouseMode;
+//        } else
+//        {
+//            mouseMode |= ROTATE;
+//        } // TRANSLATE;
 
         targetLookAt.set(manipCamera.lookAt);
         
@@ -15081,6 +15268,11 @@
                 if ((mouseMode & ZOOM) != 0)
                 {
                     //if ((mouseMode & BACKFORTH) != 0)
+                    if ((modifiersex & SHIFT) == SHIFT)
+                    {
+                        ViewAngle(dy);
+                    }
+                    else
                     if ((mouseMode & VR) != 0)
                         manipCamera.BackForth(dx, dy, getWidth());
                     else
@@ -15151,6 +15343,9 @@
         
     public void mouseMoved(MouseEvent e)
     {
+//object.editWindow.frame.
+        setCursor(Cursor.getDefaultCursor());
+
         //System.out.println("mouseMoved: " + e);
         if (isRenderer)
             return;
@@ -15179,6 +15374,12 @@
 
     public void mouseReleased(MouseEvent e)
     {
+        if (isRenderer && !movingcamera)
+        {
+            RigidBody.justclicked = true;
+            System.out.println("justclicked: " + e);
+        }
+        
         Globals.MOUSEDRAGGED = false;
         
         movingcamera = false;
@@ -15350,7 +15551,8 @@
         {
             mouseMode |= SELECT;
         }
-        if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
+        if (//(modifiersex & SHIFT) == SHIFT ||
+                forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
         {
             mouseMode &= ~VR;
             mouseMode |= TRANSLATE;
@@ -15394,8 +15596,18 @@
     float SATPOW = 1; // 2; // 0.5f;
     float BRIPOW = 1; // 0.5f; // 0.5f;
     
+static BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB);
+
+// Create a new blank cursor.
+static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor(
+    cursorImg, new Point(0, 0), "blank cursor");
+    
     public void keyPressed(int key)
     {
+// Set the blank cursor to the JFrame.
+//object.editWindow.frame.
+        setCursor(blankCursor);
+
         if (key >= '0' && key <= '5')
             clampbit = (key-'0');
         
@@ -15712,6 +15924,16 @@
                 break;
             case 'l':
                 lightMode ^= true;
+                if (lightMode)
+                {
+                    keepshadow = Globals.RENDERSHADOW;
+                    Globals.RENDERSHADOW = false;
+                }
+                else
+                {
+                    Globals.RENDERSHADOW = keepshadow;
+                }
+        
                 Globals.lighttouched = true;
                 manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
                 targetLookAt.set(manipCamera.lookAt);
@@ -15761,6 +15983,10 @@
             case ENTER:
                 // object.editWindow.ScreenFit(); // Edit();
                 ToggleLive();
+                if (capsLocked)
+                {
+                    Globals.WALK ^= true;
+                }
                 break;
             case DELETE:
                 ClearSelection();
@@ -15797,17 +16023,23 @@
                     object.GetWindow().refreshContents(true);
                 break;
             case '{':
-                manipCamera.shaper_fovy /= 1.1;
+                double factor = 1.1;
+                if (manipCamera.shaper_fovy / factor > 0.1)
+                    manipCamera.shaper_fovy /= factor;
                 System.out.println("FOV = " + manipCamera.shaper_fovy);
                 repaint();
                 break;
             case '}':
-                manipCamera.shaper_fovy *= 1.1;
+                factor = 1.1;
+                if (manipCamera.shaper_fovy * factor < 150)
+                    manipCamera.shaper_fovy *= factor;
                 System.out.println("FOV = " + manipCamera.shaper_fovy);
                 repaint();
                 break;
             case '[':
-                manipCamera.shaper_fovy /= 1.01;
+                factor = 1.01;
+                if (manipCamera.shaper_fovy / factor > 0.1)
+                    manipCamera.shaper_fovy /= factor;
                 if (false) //manipCamera.hAspect == 0)
                 {
                     double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2);
@@ -15823,7 +16055,9 @@
                 break;
             case ']':
                 //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1;
-                manipCamera.shaper_fovy *= 1.01;
+                factor = 1.01;
+                if (manipCamera.shaper_fovy * factor < 150)
+                    manipCamera.shaper_fovy *= factor;
                 if (false) //manipCamera.hAspect == 0)
                 {
                     double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2);
@@ -15862,6 +16096,7 @@
     }
 
     boolean keys[] = new boolean[256];
+    int speedkey[] = new int[256];
     int modifiers = 0;
     
     public void processKeyEvent(KeyEvent e)
@@ -16542,7 +16777,8 @@
 
     public boolean mouseDrag(Event evt, int x, int y)
     {
-        //System.out.println("mouseDrag: " + evt);
+        System.out.println("mouseDrag: " + evt);
+        System.exit(0);
 		/*
         drag = true;
         //System.out.println("Mouse DRAG");
@@ -16661,6 +16897,7 @@
     public boolean mouseUp(Event evt, int x, int y)
     {
         System.out.println("mouseUp: " + evt);
+        System.exit(0);
         /*
         locked = false;
         if (isRenderer)
@@ -16931,7 +17168,7 @@
             return;
         }
 
-        if (WIREFRAME)
+        //if (WIREFRAME)
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
         
         gl.glDisable(gl.GL_CULL_FACE);
@@ -17031,6 +17268,8 @@
 
         if (WIREFRAME)
             gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
+        else
+            gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
     }
 
     private void DrawChecker(GL gl)
@@ -17368,7 +17607,7 @@
 
             float depth = depths[y * TEX_SIZE + x];
 
-            if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1)
+            if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1)
             {
                 pointselection = false;
                 
@@ -18033,7 +18272,9 @@
     boolean OCCLUSION_CULLING = false; //true;
     public boolean lightMode = false;
     
-    public boolean capsLocked = false; // VR
+    private boolean keepshadow;
+    
+    static public boolean capsLocked = false; // VR
     
     static public int indexcount = 0;
     /*static*/ cColor vertexOcclusion = new cColor();

--
Gitblit v1.6.2