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;
....@@ -134,7 +135,7 @@
134135 static boolean ZOOMBOXMODE = false;
135136 static boolean BOXMODE = false;
136137 static boolean IMAGEFLIP = false;
137
-static boolean SMOOTHFOCUS = false;
138
+static boolean SMOOTHFOCUS = true; // false;
138139 static boolean SPEAKERMOCAP = true; // jan 2014 false;
139140 static boolean SPEAKERCAMERA = false;
140141 static boolean SPEAKERFOCUS = false;
....@@ -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 }
....@@ -2109,7 +2110,7 @@
21092110 // Start with free camera
21102111 SwitchCameras(true);
21112112
2112
- pingthread.jump = true; // optional?
2113
+// pingthread.jump = true; // optional?
21132114
21142115 if (TRACKONCE)
21152116 {
....@@ -2296,18 +2297,6 @@
22962297 public void ToggleTrack()
22972298 {
22982299 TRACK ^= true;
2299
- if (TRACK)
2300
- {
2301
- if (object.selection != null &&
2302
- object.selection.size() > 0 &&
2303
- object.selection.elementAt(0) != null &&
2304
- !(object.selection.elementAt(0) instanceof Camera) &&
2305
- !(object.selection.elementAt(0) instanceof ScriptNode))
2306
- {
2307
- trackedobject = object.selection.elementAt(0);
2308
- repaint();
2309
- }
2310
- }
23112300
23122301 repaint();
23132302 }
....@@ -6973,30 +6962,30 @@
69736962 short residu = 0;
69746963
69756964 // wraparound workarounds
6976
- short fuck = (short) (buffer[i] & 0xFF);
6965
+ short ww = (short) (buffer[i] & 0xFF);
69776966 /*
6978
- residu += (fuck%2);
6979
- if(fuck/2 < 256-residu/2)
6967
+ residu += (ww%2);
6968
+ if(ww/2 < 256-residu/2)
69806969 {
6981
- fuck = (short)((fuck/2) + residu/2);
6970
+ ww = (short)((ww/2) + residu/2);
69826971 if(residu == 2)
69836972 residu = 0;
69846973 }
69856974 else
69866975 {
69876976 residu = 0;
6988
- fuck /= 2;
6977
+ ww /= 2;
69896978 }
69906979 */
6991
- if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254)
6980
+ if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254)
69926981 {
6993
- fuck /= 2;
6982
+ ww /= 2;
69946983 } else
69956984 {
6996
- fuck = (short) ((fuck / 2) + fuck % 2);
6985
+ ww = (short) ((ww / 2) + ww % 2);
69976986 }
69986987
6999
- buffer[i] = (byte) fuck;
6988
+ buffer[i] = (byte) ww;
70006989 }
70016990 //System.out.print(bytes[i] + " ");
70026991 //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps;
....@@ -10772,7 +10761,9 @@
1077210761 }
1077310762 /**/
1077410763
10775
- if (selection)
10764
+ boolean control = ((modifiers & CTRL) != 0);
10765
+
10766
+ if (selection && (!Globals.isLIVE() || control))
1077610767 {
1077710768 selectbuffer.display();
1077810769 return;
....@@ -10915,6 +10906,12 @@
1091510906 }
1091610907 else
1091710908 speedkey[RIGHT_ARROW] = 0;
10909
+
10910
+ if (Globals.WALK && capsLocked)
10911
+ {
10912
+ Walk();
10913
+ keyon = true;
10914
+ }
1091810915
1091910916 if (keyon)
1092010917 {
....@@ -11870,8 +11867,11 @@
1187011867 repaint();
1187111868 }
1187211869
11873
- if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013
11870
+ if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013
11871
+ {
11872
+ renderCamera.computeTransform();
1187411873 repaint();
11874
+ }
1187511875
1187611876 displaydone = true;
1187711877 }
....@@ -11946,9 +11946,23 @@
1194611946 //GL gl = getGL();
1194711947 if ((TRACK || SHADOWTRACK) || zoomonce)
1194811948 {
11949
+ if (TRACK)
11950
+ {
11951
+ if (object.selection != null &&
11952
+ object.selection.size() > 0 &&
11953
+ object.selection.elementAt(0) != null &&
11954
+ !(object.selection.elementAt(0) instanceof Camera) &&
11955
+ !(object.selection.elementAt(0) instanceof ScriptNode))
11956
+ {
11957
+ trackedobject = object.selection.elementAt(0);
11958
+ //repaint();
11959
+ }
11960
+ else
11961
+ trackedobject = null;
11962
+ }
1194911963 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
1195011964 object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11951
- pingthread.StepToTarget(true); // true);
11965
+ pingthread.StepToTarget(); // true);
1195211966 // zoomonce = false;
1195311967 }
1195411968
....@@ -14329,6 +14343,7 @@
1432914343 public void mouseClicked(MouseEvent e)
1433014344 {
1433114345 System.out.println("mouseClicked: " + e);
14346
+ System.exit(0);
1433214347 }
1433314348
1433414349 public void mousePressed(MouseEvent e)
....@@ -14413,7 +14428,7 @@
1441314428 //}
1441414429
1441514430 SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14416
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
14431
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx());
1441714432 anchorX = ax;
1441814433 anchorY = ay;
1441914434 prevX = px;
....@@ -14508,8 +14523,9 @@
1450814523 // fev 2014???
1450914524 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
1451014525 object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14511
- pingthread.StepToTarget(true); // true);
14526
+ pingthread.StepToTarget(); // true);
1451214527 }
14528
+
1451314529 // if (!LIVE)
1451414530 super.repaint();
1451514531 }
....@@ -14629,11 +14645,17 @@
1462914645 return targetLookAt;
1463014646 }
1463114647
14648
+ javax.vecmath.Point3d eye = new javax.vecmath.Point3d();
14649
+ javax.vecmath.Point3d eye2 = new javax.vecmath.Point3d();
14650
+ javax.vecmath.Vector3d dir = new javax.vecmath.Vector3d();
14651
+
14652
+
1463214653 class PingThread extends Thread
1463314654 {
1463414655 boolean jump;
14656
+ boolean live;
1463514657
14636
- boolean mute;
14658
+ boolean mute = false;
1463714659
1463814660 // void JumpToTarget()
1463914661 // {
....@@ -14649,8 +14671,94 @@
1464914671 // only one thread!? synchronized
1465014672 void StepToTarget(boolean jump)
1465114673 {
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
+
1465214696 if (mute)
1465314697 return;
14698
+
14699
+ if (capsLocked && manipCamera.viewCode == 0)
14700
+ {
14701
+ eye.x = manipCamera.location.x;
14702
+ eye.y = manipCamera.location.y + 0.25;
14703
+ eye.z = manipCamera.location.z;
14704
+
14705
+ dir.y = -1;
14706
+
14707
+ Ray ray = new Ray(eye, dir);
14708
+
14709
+ IntersectResult res = new IntersectResult();
14710
+ res.t = Double.POSITIVE_INFINITY;
14711
+
14712
+ tmp.set(targetLookAt);
14713
+ tmp.sub(manipCamera.location);
14714
+
14715
+ double dist = tmp.length();
14716
+
14717
+ tmp.normalize();
14718
+
14719
+ eye2.x = manipCamera.location.x + tmp.x * 0.25;
14720
+ eye2.y = manipCamera.location.y + 0.25;
14721
+ eye2.z = manipCamera.location.z + tmp.z * 0.25;
14722
+
14723
+ Ray ray2 = new Ray(eye2, dir);
14724
+
14725
+ IntersectResult res2 = new IntersectResult();
14726
+ res2.t = Double.POSITIVE_INFINITY;
14727
+
14728
+ if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25)
14729
+ {
14730
+ //tmp.set(manipCamera.location);
14731
+
14732
+ manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t;
14733
+ manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5;
14734
+ manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t;
14735
+
14736
+ //tmp.sub(manipCamera.location);
14737
+
14738
+ targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t;
14739
+ targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5;
14740
+ targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t;
14741
+
14742
+ targetLookAt.sub(manipCamera.location);
14743
+ targetLookAt.normalize();
14744
+ targetLookAt.mul(dist);
14745
+ targetLookAt.add(manipCamera.location);
14746
+
14747
+ //if (tmp.dot(tmp) > 0.000001)
14748
+ // System.out.println("INTERSECTION " + manipCamera.location);
14749
+
14750
+ manipCamera.lookAt.set(targetLookAt);
14751
+
14752
+ tmp.x = res.n.x;
14753
+ tmp.y = res.n.y;
14754
+ tmp.z = res.n.z;
14755
+ tmp.x += res2.n.x;
14756
+ tmp.y += res2.n.y;
14757
+ tmp.z += res2.n.z;
14758
+ tmp.normalize();
14759
+ manipCamera.UP.set(tmp);
14760
+ }
14761
+ }
1465414762
1465514763 tmp.set(targetLookAt);
1465614764 tmp.sub(manipCamera.lookAt); // june 2014
....@@ -14689,7 +14797,7 @@
1468914797
1469014798 if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target
1469114799 {
14692
- jump = true; // step = 1;
14800
+ // sep 2019 jump = true; // step = 1;
1469314801 }
1469414802
1469514803 if (OEILONCE && OEIL)
....@@ -14724,7 +14832,10 @@
1472414832 if (tmp.dot(tmp) < 0.00001)
1472514833 {
1472614834 zoomonce = false;
14835
+ live = false;
1472714836 }
14837
+ else
14838
+ live = true;
1472814839
1472914840 tmp.mul(step > step2 ? step : step2);
1473014841 }
....@@ -14866,8 +14977,28 @@
1486614977 PingThread pingthread = new PingThread();
1486714978 int delta = 1;
1486814979 int speed = 1;
14980
+ int walk = 8;
1486914981 boolean autorepeat = false;
1487014982
14983
+ void Walk()
14984
+ {
14985
+ manipCamera.BackForth(0, walk, 1000);
14986
+
14987
+ targetLookAt.set(manipCamera.lookAt);
14988
+ }
14989
+
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
+
1487115002 void GoDown(int mod)
1487215003 {
1487315004 MODIFIERS |= COMMAND;
....@@ -14878,6 +15009,9 @@
1487815009 // if (isVR)
1487915010 // manipCamera.RotateInterest(0, speed);
1488015011 // else
15012
+ if (isVR)
15013
+ ViewAngle(-speed*delta);
15014
+ else
1488115015 manipCamera.Translate(0, -speed*delta, getWidth());
1488215016 }
1488315017 else
....@@ -14905,6 +15039,8 @@
1490515039
1490615040 void GoUp(int mod)
1490715041 {
15042
+ RigidBody.justclicked = true;
15043
+
1490815044 MODIFIERS |= COMMAND;
1490915045 /**/
1491015046 boolean isVR = (mouseMode&VR)!=0;
....@@ -14914,6 +15050,9 @@
1491415050 // if (isVR)
1491515051 // manipCamera.RotateInterest(0, -speed);
1491615052 // else
15053
+ if (isVR)
15054
+ ViewAngle(speed*delta);
15055
+ else
1491715056 manipCamera.Translate(0, speed*delta, getWidth());
1491815057 }
1491915058 else
....@@ -14944,13 +15083,13 @@
1494415083 MODIFIERS |= COMMAND;
1494515084 /**/
1494615085 if((mod&SHIFT) == SHIFT)
14947
- manipCamera.Translate(speed*delta, 0, getWidth());
15086
+ manipCamera.Translate(speed, 0, getWidth());
1494815087 else
1494915088 {
1495015089 if ((mouseMode&VR)!=0)
14951
- manipCamera.RotateInterest(-speed, 0);
15090
+ manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0);
1495215091 else
14953
- manipCamera.RotatePosition(speed, 0);
15092
+ manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0);
1495415093 }
1495515094
1495615095 /**/
....@@ -14976,13 +15115,13 @@
1497615115 MODIFIERS |= COMMAND;
1497715116 /**/
1497815117 if((mod&SHIFT) == SHIFT)
14979
- manipCamera.Translate(-speed*delta, 0, getWidth());
15118
+ manipCamera.Translate(-speed, 0, getWidth());
1498015119 else
1498115120 {
1498215121 if ((mouseMode&VR)!=0)
14983
- manipCamera.RotateInterest(speed, 0);
15122
+ manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0);
1498415123 else
14985
- manipCamera.RotatePosition(-speed, 0);
15124
+ manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0);
1498615125 }
1498715126
1498815127 /**/
....@@ -15129,6 +15268,11 @@
1512915268 if ((mouseMode & ZOOM) != 0)
1513015269 {
1513115270 //if ((mouseMode & BACKFORTH) != 0)
15271
+ if ((modifiersex & SHIFT) == SHIFT)
15272
+ {
15273
+ ViewAngle(dy);
15274
+ }
15275
+ else
1513215276 if ((mouseMode & VR) != 0)
1513315277 manipCamera.BackForth(dx, dy, getWidth());
1513415278 else
....@@ -15230,6 +15374,12 @@
1523015374
1523115375 public void mouseReleased(MouseEvent e)
1523215376 {
15377
+ if (isRenderer && !movingcamera)
15378
+ {
15379
+ RigidBody.justclicked = true;
15380
+ System.out.println("justclicked: " + e);
15381
+ }
15382
+
1523315383 Globals.MOUSEDRAGGED = false;
1523415384
1523515385 movingcamera = false;
....@@ -15833,6 +15983,10 @@
1583315983 case ENTER:
1583415984 // object.editWindow.ScreenFit(); // Edit();
1583515985 ToggleLive();
15986
+ if (capsLocked)
15987
+ {
15988
+ Globals.WALK ^= true;
15989
+ }
1583615990 break;
1583715991 case DELETE:
1583815992 ClearSelection();
....@@ -15869,17 +16023,23 @@
1586916023 object.GetWindow().refreshContents(true);
1587016024 break;
1587116025 case '{':
15872
- manipCamera.shaper_fovy /= 1.1;
16026
+ double factor = 1.1;
16027
+ if (manipCamera.shaper_fovy / factor > 0.1)
16028
+ manipCamera.shaper_fovy /= factor;
1587316029 System.out.println("FOV = " + manipCamera.shaper_fovy);
1587416030 repaint();
1587516031 break;
1587616032 case '}':
15877
- manipCamera.shaper_fovy *= 1.1;
16033
+ factor = 1.1;
16034
+ if (manipCamera.shaper_fovy * factor < 150)
16035
+ manipCamera.shaper_fovy *= factor;
1587816036 System.out.println("FOV = " + manipCamera.shaper_fovy);
1587916037 repaint();
1588016038 break;
1588116039 case '[':
15882
- manipCamera.shaper_fovy /= 1.01;
16040
+ factor = 1.01;
16041
+ if (manipCamera.shaper_fovy / factor > 0.1)
16042
+ manipCamera.shaper_fovy /= factor;
1588316043 if (false) //manipCamera.hAspect == 0)
1588416044 {
1588516045 double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2);
....@@ -15895,7 +16055,9 @@
1589516055 break;
1589616056 case ']':
1589716057 //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1;
15898
- manipCamera.shaper_fovy *= 1.01;
16058
+ factor = 1.01;
16059
+ if (manipCamera.shaper_fovy * factor < 150)
16060
+ manipCamera.shaper_fovy *= factor;
1589916061 if (false) //manipCamera.hAspect == 0)
1590016062 {
1590116063 double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2);
....@@ -16615,7 +16777,8 @@
1661516777
1661616778 public boolean mouseDrag(Event evt, int x, int y)
1661716779 {
16618
- //System.out.println("mouseDrag: " + evt);
16780
+ System.out.println("mouseDrag: " + evt);
16781
+ System.exit(0);
1661916782 /*
1662016783 drag = true;
1662116784 //System.out.println("Mouse DRAG");
....@@ -16734,6 +16897,7 @@
1673416897 public boolean mouseUp(Event evt, int x, int y)
1673516898 {
1673616899 System.out.println("mouseUp: " + evt);
16900
+ System.exit(0);
1673716901 /*
1673816902 locked = false;
1673916903 if (isRenderer)
....@@ -17004,7 +17168,7 @@
1700417168 return;
1700517169 }
1700617170
17007
- if (WIREFRAME)
17171
+ //if (WIREFRAME)
1700817172 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1700917173
1701017174 gl.glDisable(gl.GL_CULL_FACE);
....@@ -17104,6 +17268,8 @@
1710417268
1710517269 if (WIREFRAME)
1710617270 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
17271
+ else
17272
+ gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1710717273 }
1710817274
1710917275 private void DrawChecker(GL gl)
....@@ -18108,7 +18274,7 @@
1810818274
1810918275 private boolean keepshadow;
1811018276
18111
- public boolean capsLocked = false; // VR
18277
+ static public boolean capsLocked = false; // VR
1811218278
1811318279 static public int indexcount = 0;
1811418280 /*static*/ cColor vertexOcclusion = new cColor();