Normand Briere
2019-10-04 57c5b6cd8d12ffdaa3e0b099451e3c031012750a
CameraPane.java
....@@ -1,4 +1,5 @@
11
2
+import com.bulletphysics.dynamics.RigidBody;
23 import java.awt.*;
34 import java.awt.event.*;
45 import java.awt.image.*;
....@@ -123,7 +124,7 @@
123124 static boolean LOCALTRANSFORM = false;
124125 static boolean FULLSCREEN = false;
125126 static boolean SUPPORT = true;
126
-static boolean INERTIA = true;
127
+static boolean INERTIA = false; // true;
127128 static boolean FAST = false;
128129 static boolean SLOWPOSE = false;
129130 static boolean FOOTCONTACT = true;
....@@ -249,7 +250,7 @@
249250
250251 public javax.media.opengl.GL GetGL0()
251252 {
252
- return null;
253
+ return currentGL;
253254 }
254255
255256 public int GenList()
....@@ -1529,7 +1530,7 @@
15291530 }
15301531 }
15311532 float b = 0;
1532
- if (obj.support != null && obj.link2master)
1533
+ if (obj.support != null && obj.Link2Support())
15331534 {
15341535 b = 1;
15351536 }
....@@ -6961,30 +6962,30 @@
69616962 short residu = 0;
69626963
69636964 // wraparound workarounds
6964
- short fuck = (short) (buffer[i] & 0xFF);
6965
+ short ww = (short) (buffer[i] & 0xFF);
69656966 /*
6966
- residu += (fuck%2);
6967
- if(fuck/2 < 256-residu/2)
6967
+ residu += (ww%2);
6968
+ if(ww/2 < 256-residu/2)
69686969 {
6969
- fuck = (short)((fuck/2) + residu/2);
6970
+ ww = (short)((ww/2) + residu/2);
69706971 if(residu == 2)
69716972 residu = 0;
69726973 }
69736974 else
69746975 {
69756976 residu = 0;
6976
- fuck /= 2;
6977
+ ww /= 2;
69776978 }
69786979 */
6979
- if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254)
6980
+ if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254)
69806981 {
6981
- fuck /= 2;
6982
+ ww /= 2;
69826983 } else
69836984 {
6984
- fuck = (short) ((fuck / 2) + fuck % 2);
6985
+ ww = (short) ((ww / 2) + ww % 2);
69856986 }
69866987
6987
- buffer[i] = (byte) fuck;
6988
+ buffer[i] = (byte) ww;
69886989 }
69896990 //System.out.print(bytes[i] + " ");
69906991 //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps;
....@@ -10760,7 +10761,9 @@
1076010761 }
1076110762 /**/
1076210763
10763
- if (selection)
10764
+ boolean control = ((modifiers & CTRL) != 0);
10765
+
10766
+ if (selection && (!Globals.isLIVE() || control))
1076410767 {
1076510768 selectbuffer.display();
1076610769 return;
....@@ -11865,7 +11868,10 @@
1186511868 }
1186611869
1186711870 if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013
11871
+ {
11872
+ renderCamera.computeTransform();
1186811873 repaint();
11874
+ }
1186911875
1187011876 displaydone = true;
1187111877 }
....@@ -14337,6 +14343,7 @@
1433714343 public void mouseClicked(MouseEvent e)
1433814344 {
1433914345 System.out.println("mouseClicked: " + e);
14346
+ System.exit(0);
1434014347 }
1434114348
1434214349 public void mousePressed(MouseEvent e)
....@@ -14421,7 +14428,7 @@
1442114428 //}
1442214429
1442314430 SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14424
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
14431
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx());
1442514432 anchorX = ax;
1442614433 anchorY = ay;
1442714434 prevX = px;
....@@ -14648,7 +14655,7 @@
1464814655 boolean jump;
1464914656 boolean live;
1465014657
14651
- boolean mute;
14658
+ boolean mute = false;
1465214659
1465314660 // void JumpToTarget()
1465414661 // {
....@@ -14664,10 +14671,32 @@
1466414671 // only one thread!? synchronized
1466514672 void StepToTarget(boolean jump)
1466614673 {
14674
+ RigidBody.pos.x = 0;
14675
+ RigidBody.pos.y = 0;
14676
+ RigidBody.pos.z = 0;
14677
+ if (RigidBody.justclicked)
14678
+ {
14679
+// RigidBody.pos.x = (float)manipCamera.lookAt.x;
14680
+// RigidBody.pos.y = (float)manipCamera.lookAt.y;
14681
+// RigidBody.pos.z = (float)manipCamera.lookAt.z;
14682
+ // System.err.println("selected point = " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][1]) + " " + Trunk(selectedpoint.toParent[3][2]));
14683
+ CreateSelectedPoint();
14684
+
14685
+ RigidBody.pos.x = (float)selectedpoint.toParent[3][0];
14686
+ RigidBody.pos.y = (float)selectedpoint.toParent[3][1];
14687
+ RigidBody.pos.z = (float)selectedpoint.toParent[3][2];
14688
+
14689
+ RigidBody.wind.set(RigidBody.pos);
14690
+ RigidBody.wind.x -= (float)manipCamera.location.x;
14691
+ RigidBody.wind.y -= (float)manipCamera.location.y;
14692
+ RigidBody.wind.z -= (float)manipCamera.location.z;
14693
+ RigidBody.wind.normalize();
14694
+ }
14695
+
1466714696 if (mute)
1466814697 return;
1466914698
14670
- if (capsLocked)
14699
+ if (capsLocked && manipCamera.viewCode == 0)
1467114700 {
1467214701 eye.x = manipCamera.location.x;
1467314702 eye.y = manipCamera.location.y + 0.25;
....@@ -14958,6 +14987,18 @@
1495814987 targetLookAt.set(manipCamera.lookAt);
1495914988 }
1496014989
14990
+ void ViewAngle(float dy)
14991
+ {
14992
+ double factor = Math.exp(-dy/300.0); // (1 + dy/100);
14993
+
14994
+ if (manipCamera.shaper_fovy * factor > 1 &&
14995
+ manipCamera.shaper_fovy * factor < 150)
14996
+ {
14997
+ manipCamera.shaper_fovy *= factor;
14998
+ //System.out.println("fovy = " + shaper_fovy);
14999
+ }
15000
+ }
15001
+
1496115002 void GoDown(int mod)
1496215003 {
1496315004 MODIFIERS |= COMMAND;
....@@ -14968,6 +15009,9 @@
1496815009 // if (isVR)
1496915010 // manipCamera.RotateInterest(0, speed);
1497015011 // else
15012
+ if (isVR)
15013
+ ViewAngle(-speed*delta);
15014
+ else
1497115015 manipCamera.Translate(0, -speed*delta, getWidth());
1497215016 }
1497315017 else
....@@ -14995,6 +15039,8 @@
1499515039
1499615040 void GoUp(int mod)
1499715041 {
15042
+ RigidBody.justclicked = true;
15043
+
1499815044 MODIFIERS |= COMMAND;
1499915045 /**/
1500015046 boolean isVR = (mouseMode&VR)!=0;
....@@ -15004,6 +15050,9 @@
1500415050 // if (isVR)
1500515051 // manipCamera.RotateInterest(0, -speed);
1500615052 // else
15053
+ if (isVR)
15054
+ ViewAngle(speed*delta);
15055
+ else
1500715056 manipCamera.Translate(0, speed*delta, getWidth());
1500815057 }
1500915058 else
....@@ -15034,13 +15083,13 @@
1503415083 MODIFIERS |= COMMAND;
1503515084 /**/
1503615085 if((mod&SHIFT) == SHIFT)
15037
- manipCamera.Translate(speed*delta, 0, getWidth());
15086
+ manipCamera.Translate(speed, 0, getWidth());
1503815087 else
1503915088 {
1504015089 if ((mouseMode&VR)!=0)
15041
- manipCamera.RotateInterest(-speed, 0);
15090
+ manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0);
1504215091 else
15043
- manipCamera.RotatePosition(speed, 0);
15092
+ manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0);
1504415093 }
1504515094
1504615095 /**/
....@@ -15066,13 +15115,13 @@
1506615115 MODIFIERS |= COMMAND;
1506715116 /**/
1506815117 if((mod&SHIFT) == SHIFT)
15069
- manipCamera.Translate(-speed*delta, 0, getWidth());
15118
+ manipCamera.Translate(-speed, 0, getWidth());
1507015119 else
1507115120 {
1507215121 if ((mouseMode&VR)!=0)
15073
- manipCamera.RotateInterest(speed, 0);
15122
+ manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0);
1507415123 else
15075
- manipCamera.RotatePosition(-speed, 0);
15124
+ manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0);
1507615125 }
1507715126
1507815127 /**/
....@@ -15219,6 +15268,11 @@
1521915268 if ((mouseMode & ZOOM) != 0)
1522015269 {
1522115270 //if ((mouseMode & BACKFORTH) != 0)
15271
+ if ((modifiersex & SHIFT) == SHIFT)
15272
+ {
15273
+ ViewAngle(dy);
15274
+ }
15275
+ else
1522215276 if ((mouseMode & VR) != 0)
1522315277 manipCamera.BackForth(dx, dy, getWidth());
1522415278 else
....@@ -15320,6 +15374,12 @@
1532015374
1532115375 public void mouseReleased(MouseEvent e)
1532215376 {
15377
+ if (isRenderer && !movingcamera)
15378
+ {
15379
+ RigidBody.justclicked = true;
15380
+ System.out.println("justclicked: " + e);
15381
+ }
15382
+
1532315383 Globals.MOUSEDRAGGED = false;
1532415384
1532515385 movingcamera = false;
....@@ -15923,6 +15983,10 @@
1592315983 case ENTER:
1592415984 // object.editWindow.ScreenFit(); // Edit();
1592515985 ToggleLive();
15986
+ if (capsLocked)
15987
+ {
15988
+ Globals.WALK ^= true;
15989
+ }
1592615990 break;
1592715991 case DELETE:
1592815992 ClearSelection();
....@@ -16713,7 +16777,8 @@
1671316777
1671416778 public boolean mouseDrag(Event evt, int x, int y)
1671516779 {
16716
- //System.out.println("mouseDrag: " + evt);
16780
+ System.out.println("mouseDrag: " + evt);
16781
+ System.exit(0);
1671716782 /*
1671816783 drag = true;
1671916784 //System.out.println("Mouse DRAG");
....@@ -16832,6 +16897,7 @@
1683216897 public boolean mouseUp(Event evt, int x, int y)
1683316898 {
1683416899 System.out.println("mouseUp: " + evt);
16900
+ System.exit(0);
1683516901 /*
1683616902 locked = false;
1683716903 if (isRenderer)
....@@ -17102,7 +17168,7 @@
1710217168 return;
1710317169 }
1710417170
17105
- if (WIREFRAME)
17171
+ //if (WIREFRAME)
1710617172 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1710717173
1710817174 gl.glDisable(gl.GL_CULL_FACE);
....@@ -17202,6 +17268,8 @@
1720217268
1720317269 if (WIREFRAME)
1720417270 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
17271
+ else
17272
+ gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1720517273 }
1720617274
1720717275 private void DrawChecker(GL gl)
....@@ -18206,7 +18274,7 @@
1820618274
1820718275 private boolean keepshadow;
1820818276
18209
- public boolean capsLocked = false; // VR
18277
+ static public boolean capsLocked = false; // VR
1821018278
1821118279 static public int indexcount = 0;
1821218280 /*static*/ cColor vertexOcclusion = new cColor();