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 | 118 ++++++++++++++++++++++++++++++++++++++++++++++------------ 1 files changed, 93 insertions(+), 25 deletions(-) diff --git a/CameraPane.java b/CameraPane.java index 6e4b50c..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; @@ -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; } @@ -6961,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; @@ -10760,7 +10761,9 @@ } /**/ - if (selection) + boolean control = ((modifiers & CTRL) != 0); + + if (selection && (!Globals.isLIVE() || control)) { selectbuffer.display(); return; @@ -11865,7 +11868,10 @@ } if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 + { + renderCamera.computeTransform(); repaint(); + } displaydone = true; } @@ -14337,6 +14343,7 @@ public void mouseClicked(MouseEvent e) { System.out.println("mouseClicked: " + e); + System.exit(0); } public void mousePressed(MouseEvent e) @@ -14421,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; @@ -14648,7 +14655,7 @@ boolean jump; boolean live; - boolean mute; + boolean mute = false; // void JumpToTarget() // { @@ -14664,10 +14671,32 @@ // 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) + if (capsLocked && manipCamera.viewCode == 0) { eye.x = manipCamera.location.x; eye.y = manipCamera.location.y + 0.25; @@ -14958,6 +14987,18 @@ 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; @@ -14968,6 +15009,9 @@ // if (isVR) // manipCamera.RotateInterest(0, speed); // else + if (isVR) + ViewAngle(-speed*delta); + else manipCamera.Translate(0, -speed*delta, getWidth()); } else @@ -14995,6 +15039,8 @@ void GoUp(int mod) { + RigidBody.justclicked = true; + MODIFIERS |= COMMAND; /**/ boolean isVR = (mouseMode&VR)!=0; @@ -15004,6 +15050,9 @@ // if (isVR) // manipCamera.RotateInterest(0, -speed); // else + if (isVR) + ViewAngle(speed*delta); + else manipCamera.Translate(0, speed*delta, getWidth()); } else @@ -15034,13 +15083,13 @@ 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); } /**/ @@ -15066,13 +15115,13 @@ 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); } /**/ @@ -15219,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 @@ -15320,6 +15374,12 @@ public void mouseReleased(MouseEvent e) { + if (isRenderer && !movingcamera) + { + RigidBody.justclicked = true; + System.out.println("justclicked: " + e); + } + Globals.MOUSEDRAGGED = false; movingcamera = false; @@ -15923,6 +15983,10 @@ case ENTER: // object.editWindow.ScreenFit(); // Edit(); ToggleLive(); + if (capsLocked) + { + Globals.WALK ^= true; + } break; case DELETE: ClearSelection(); @@ -16713,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"); @@ -16832,6 +16897,7 @@ public boolean mouseUp(Event evt, int x, int y) { System.out.println("mouseUp: " + evt); + System.exit(0); /* locked = false; if (isRenderer) @@ -17102,7 +17168,7 @@ return; } - if (WIREFRAME) + //if (WIREFRAME) gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); gl.glDisable(gl.GL_CULL_FACE); @@ -17202,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) @@ -18206,7 +18274,7 @@ private boolean keepshadow; - public boolean capsLocked = false; // VR + static public boolean capsLocked = false; // VR static public int indexcount = 0; /*static*/ cColor vertexOcclusion = new cColor(); -- Gitblit v1.6.2