Normand Briere
2019-09-20 cbe4e90105d07d7d3fecabffaa01342403aa2ae3
Better navigation.
3 files modified
101 ■■■■■ changed files
Camera.java 53 ●●●● patch | view | raw | blame | history
CameraPane.java 44 ●●●● patch | view | raw | blame | history
Object3D.java 4 ●●●● patch | view | raw | blame | history
Camera.java
....@@ -288,25 +288,15 @@
288288 // Zoom
289289 double factor = Math.exp(-dy/300.0); // (1 + dy/100);
290290
291
- if (viewCode != 0)
292
- {
293
- LA.vecSub(location, lookAt, location);
291
+ LA.vecSub(location, lookAt, location);
294292
295
- cVector p = location;
293
+ cVector p = location;
296294
297
- p.x *= factor;
298
- p.y *= factor;
299
- p.z *= factor;
295
+ p.x *= factor;
296
+ p.y *= factor;
297
+ p.z *= factor;
300298
301
- LA.vecAdd(location, lookAt, location);
302
- }
303
- else
304
- if (//shaper_fovy < 180 && factor > 1 ||
305
- shaper_fovy * factor < 150)
306
- {
307
- shaper_fovy *= factor;
308
- //System.out.println("fovy = " + shaper_fovy);
309
- }
299
+ LA.vecAdd(location, lookAt, location);
310300 }
311301 else
312302 {
....@@ -340,9 +330,12 @@
340330 location.set(lookAt);
341331 lookAt.set(cStatic.point1);
342332
343
- cStatic.point1.set(locationBuf);
344
- locationBuf.set(lookAtBuf);
345
- lookAtBuf.set(cStatic.point1);
333
+ if (viewCode == 0 && locationBuf != null)
334
+ {
335
+ cStatic.point1.set(locationBuf);
336
+ locationBuf.set(lookAtBuf);
337
+ lookAtBuf.set(cStatic.point1);
338
+ }
346339 // UP.mul(-1);
347340
348341 RotatePosition(dx,-dy);
....@@ -354,9 +347,12 @@
354347 location.set(lookAt);
355348 lookAt.set(cStatic.point1);
356349
357
- cStatic.point1.set(locationBuf);
358
- locationBuf.set(lookAtBuf);
359
- lookAtBuf.set(cStatic.point1);
350
+ if (viewCode == 0 && locationBuf != null)
351
+ {
352
+ cStatic.point1.set(locationBuf);
353
+ locationBuf.set(lookAtBuf);
354
+ lookAtBuf.set(cStatic.point1);
355
+ }
360356
361357 computeTransform();
362358 }
....@@ -386,8 +382,13 @@
386382 {
387383 double K = 0.25;
388384
385
+ if (!CameraPane.capsLocked)
386
+ K = 1;
387
+
389388 locationBuf.y = location.y * K + locationBuf.y * (1 - K);
390389 lookAtBuf.y = lookAt.y * K + lookAtBuf.y * (1 - K);
390
+
391
+ K = 0.1;
391392
392393 upBuf.x = UP.x * K + upBuf.x * (1 - K);
393394 upBuf.y = UP.y * K + upBuf.y * (1 - K);
....@@ -421,19 +422,19 @@
421422 up2.x = UP2.x;
422423 up2.y = UP2.y;
423424 up2.z = UP2.z;
424
- LA.vecSub(lookAt, location, away);
425
- LA.vecNormalize(away);
426425 LA.vecCross(away, up2, right2);
427426 if (!(right2.length2() > 0))
428427 {
428
+ System.out.println("NO UP VECTOR: " + up2);
429
+ System.out.println("lookAtBuf: " + lookAtBuf);
430
+ System.out.println("locationBuf: " + locationBuf);
429431 System.exit(0);
432
+
430433 // old problem...
431434 assert (right2.length2() <= 0 || right2.length2() > 0); // weirdest thing ever
432435 up2.x = UP.x = 0;
433436 up2.y = UP.y = 1;
434437 up2.z = UP.z = 0;
435
- LA.vecSub(lookAt, location, away);
436
- LA.vecNormalize(away);
437438 LA.vecCross(away, up2, right2);
438439 }
439440 }
CameraPane.java
....@@ -11865,7 +11865,10 @@
1186511865 }
1186611866
1186711867 if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013
11868
+ {
11869
+ renderCamera.computeTransform();
1186811870 repaint();
11871
+ }
1186911872
1187011873 displaydone = true;
1187111874 }
....@@ -14421,7 +14424,7 @@
1442114424 //}
1442214425
1442314426 SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14424
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
14427
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx());
1442514428 anchorX = ax;
1442614429 anchorY = ay;
1442714430 prevX = px;
....@@ -14667,7 +14670,7 @@
1466714670 if (mute)
1466814671 return;
1466914672
14670
- if (capsLocked)
14673
+ if (capsLocked && manipCamera.viewCode == 0)
1467114674 {
1467214675 eye.x = manipCamera.location.x;
1467314676 eye.y = manipCamera.location.y + 0.25;
....@@ -14958,6 +14961,18 @@
1495814961 targetLookAt.set(manipCamera.lookAt);
1495914962 }
1496014963
14964
+ void ViewAngle(float dy)
14965
+ {
14966
+ double factor = Math.exp(-dy/300.0); // (1 + dy/100);
14967
+
14968
+ if (manipCamera.shaper_fovy * factor > 1 &&
14969
+ manipCamera.shaper_fovy * factor < 150)
14970
+ {
14971
+ manipCamera.shaper_fovy *= factor;
14972
+ //System.out.println("fovy = " + shaper_fovy);
14973
+ }
14974
+ }
14975
+
1496114976 void GoDown(int mod)
1496214977 {
1496314978 MODIFIERS |= COMMAND;
....@@ -14968,6 +14983,9 @@
1496814983 // if (isVR)
1496914984 // manipCamera.RotateInterest(0, speed);
1497014985 // else
14986
+ if (isVR)
14987
+ ViewAngle(-speed*delta);
14988
+ else
1497114989 manipCamera.Translate(0, -speed*delta, getWidth());
1497214990 }
1497314991 else
....@@ -15004,6 +15022,9 @@
1500415022 // if (isVR)
1500515023 // manipCamera.RotateInterest(0, -speed);
1500615024 // else
15025
+ if (isVR)
15026
+ ViewAngle(speed*delta);
15027
+ else
1500715028 manipCamera.Translate(0, speed*delta, getWidth());
1500815029 }
1500915030 else
....@@ -15034,13 +15055,13 @@
1503415055 MODIFIERS |= COMMAND;
1503515056 /**/
1503615057 if((mod&SHIFT) == SHIFT)
15037
- manipCamera.Translate(speed*delta, 0, getWidth());
15058
+ manipCamera.Translate(speed, 0, getWidth());
1503815059 else
1503915060 {
1504015061 if ((mouseMode&VR)!=0)
15041
- manipCamera.RotateInterest(-speed, 0);
15062
+ manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0);
1504215063 else
15043
- manipCamera.RotatePosition(speed, 0);
15064
+ manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0);
1504415065 }
1504515066
1504615067 /**/
....@@ -15066,13 +15087,13 @@
1506615087 MODIFIERS |= COMMAND;
1506715088 /**/
1506815089 if((mod&SHIFT) == SHIFT)
15069
- manipCamera.Translate(-speed*delta, 0, getWidth());
15090
+ manipCamera.Translate(-speed, 0, getWidth());
1507015091 else
1507115092 {
1507215093 if ((mouseMode&VR)!=0)
15073
- manipCamera.RotateInterest(speed, 0);
15094
+ manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0);
1507415095 else
15075
- manipCamera.RotatePosition(-speed, 0);
15096
+ manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0);
1507615097 }
1507715098
1507815099 /**/
....@@ -15219,6 +15240,11 @@
1521915240 if ((mouseMode & ZOOM) != 0)
1522015241 {
1522115242 //if ((mouseMode & BACKFORTH) != 0)
15243
+ if ((modifiersex & SHIFT) == SHIFT)
15244
+ {
15245
+ ViewAngle(dy);
15246
+ }
15247
+ else
1522215248 if ((mouseMode & VR) != 0)
1522315249 manipCamera.BackForth(dx, dy, getWidth());
1522415250 else
....@@ -18210,7 +18236,7 @@
1821018236
1821118237 private boolean keepshadow;
1821218238
18213
- public boolean capsLocked = false; // VR
18239
+ static public boolean capsLocked = false; // VR
1821418240
1821518241 static public int indexcount = 0;
1821618242 /*static*/ cColor vertexOcclusion = new cColor();
Object3D.java
....@@ -8869,7 +8869,7 @@
88698869 double diry = ray.viewDirection.y;
88708870 double dirz = ray.viewDirection.z;
88718871
8872
- if (this.fromParent != null)
8872
+ if (this.fromParent != null && !(this instanceof TextureNode))
88738873 {
88748874 eye.x = eyex;
88758875 eye.y = eyey;
....@@ -8894,7 +8894,7 @@
88948894
88958895 boolean touch = false;
88968896
8897
- if (bRep != null)
8897
+ if (bRep != null && link2support)
88988898 {
88998899 if (bbox == null)
89008900 {