Normand Briere
2019-11-21 ddb10cb84dddfeef1ef9946f2e13cef3c93e6cc4
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.*;
....@@ -49,10 +50,12 @@
4950
5051 static int STEP = 1;
5152
53
+ //static int[] pixels = new int[10000000];
54
+
5255 private static BufferedImage CreateBim(byte[] bytes, int width, int height)
5356 {
5457 int[] pixels = new int[bytes.length/3];
55
- for (int i=pixels.length; --i>=0;)
58
+ for (int i=bytes.length/3; --i>=0;)
5659 {
5760 int i3 = i*3;
5861 pixels[i] = 0xFF;
....@@ -123,7 +126,7 @@
123126 static boolean LOCALTRANSFORM = false;
124127 static boolean FULLSCREEN = false;
125128 static boolean SUPPORT = true;
126
-static boolean INERTIA = true;
129
+static boolean INERTIA = false; // true;
127130 static boolean FAST = false;
128131 static boolean SLOWPOSE = false;
129132 static boolean FOOTCONTACT = true;
....@@ -192,6 +195,18 @@
192195
193196 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194197
198
+ public void Jump2Target()
199
+ {
200
+ if (manipCamera.hAspect == 0)
201
+ {
202
+ tmp.set(targetLookAt);
203
+ tmp.sub(manipCamera.lookAt);
204
+ manipCamera.lookAt.add(tmp);
205
+ manipCamera.location.add(tmp);
206
+ manipCamera.computeTransform();
207
+ }
208
+ }
209
+
195210 public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196211 {
197212 try
....@@ -249,7 +264,7 @@
249264
250265 public javax.media.opengl.GL GetGL0()
251266 {
252
- return null;
267
+ return currentGL;
253268 }
254269
255270 public int GenList()
....@@ -1529,7 +1544,7 @@
15291544 }
15301545 }
15311546 float b = 0;
1532
- if (obj.support != null && obj.link2master)
1547
+ if (obj.support != null && obj.Link2Support())
15331548 {
15341549 b = 1;
15351550 }
....@@ -2177,9 +2192,18 @@
21772192 //SwitchCameras();
21782193 }
21792194
2195
+ cVector origin = new cVector();
2196
+
21802197 void RevertCamera()
21812198 {
2182
- SwapCamera(1, 0);
2199
+ if (lightMode)
2200
+ {
2201
+ CreateSelectedPoint();
2202
+ selectedpoint.GetOrigin(origin);
2203
+ lightCamera.setAim(new cVector(3,4,5), origin);
2204
+ }
2205
+ else
2206
+ SwapCamera(1, 0);
21832207
21842208 //SwitchCameras();
21852209 }
....@@ -2227,6 +2251,13 @@
22272251 // else
22282252 repaint(); // start loop // may 2013
22292253 }
2254
+
2255
+ public void ToggleAntialiasing()
2256
+ {
2257
+ CURRENTANTIALIAS = ((CURRENTANTIALIAS != 0) ? 0 : 1);
2258
+ System.out.println("Antialias ACSIZE = " + ACSIZE);
2259
+ System.out.println("CURRENTANTIALIAS = " + CURRENTANTIALIAS);
2260
+ }
22302261
22312262 public void ToggleSupport()
22322263 {
....@@ -2272,6 +2303,7 @@
22722303 {
22732304 IMAGEFLIP ^= true;
22742305 }
2306
+
22752307
22762308 public void ToggleSpeakerMocap()
22772309 {
....@@ -3829,12 +3861,13 @@
38293861
38303862 switch (resolution)
38313863 {
3832
- case 0: restarget = 256*256; break;
3833
- case 1: restarget = 512*512; break;
3834
- case 2: restarget = 1024*1024; break;
3835
- case 3: restarget = 2048*2048; break;
3836
- case 4: restarget = 4096*4096; break;
3837
- case 5: restarget = 8192*8192; break;
3864
+ case 0: restarget = 128*128; break;
3865
+ case 1: restarget = 256*256; break;
3866
+ case 2: restarget = 512*512; break;
3867
+ case 3: restarget = 1024*1024; break;
3868
+ case 4: restarget = 2048*2048; break;
3869
+ case 5: restarget = 4096*4096; break;
3870
+ case 6: restarget = 8192*8192; break;
38383871 }
38393872
38403873 // restarget = 512*512; // 512*512; // 2048; // 512; // 1024;
....@@ -6961,30 +6994,30 @@
69616994 short residu = 0;
69626995
69636996 // wraparound workarounds
6964
- short fuck = (short) (buffer[i] & 0xFF);
6997
+ short ww = (short) (buffer[i] & 0xFF);
69656998 /*
6966
- residu += (fuck%2);
6967
- if(fuck/2 < 256-residu/2)
6999
+ residu += (ww%2);
7000
+ if(ww/2 < 256-residu/2)
69687001 {
6969
- fuck = (short)((fuck/2) + residu/2);
7002
+ ww = (short)((ww/2) + residu/2);
69707003 if(residu == 2)
69717004 residu = 0;
69727005 }
69737006 else
69747007 {
69757008 residu = 0;
6976
- fuck /= 2;
7009
+ ww /= 2;
69777010 }
69787011 */
6979
- if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254)
7012
+ if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254)
69807013 {
6981
- fuck /= 2;
7014
+ ww /= 2;
69827015 } else
69837016 {
6984
- fuck = (short) ((fuck / 2) + fuck % 2);
7017
+ ww = (short) ((ww / 2) + ww % 2);
69857018 }
69867019
6987
- buffer[i] = (byte) fuck;
7020
+ buffer[i] = (byte) ww;
69887021 }
69897022 //System.out.print(bytes[i] + " ");
69907023 //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps;
....@@ -9366,7 +9399,9 @@
93669399 boolean pointselection = false;
93679400 ///*static*/ boolean lighttouched = true;
93689401 boolean deselect;
9369
- private boolean ambientOcclusion = false;
9402
+
9403
+ static boolean ambientOcclusion = false;
9404
+
93709405 static boolean flash = false;
93719406 /*static*/ boolean wait = false;
93729407 boolean displaydone = false; // after repaint() calls
....@@ -9618,7 +9653,7 @@
96189653 pixdx, pixdy, edx, edy, focus);
96199654 }
96209655
9621
- static int ACSIZE = 4; // 16;
9656
+ static int ACSIZE = 16; // 16;
96229657 static int MAXACSIZE = 256; // 1024;
96239658 static float[] jx8 = new float[MAXACSIZE];
96249659 static float[] jy8 = new float[MAXACSIZE];
....@@ -9652,8 +9687,8 @@
96529687 void ResetOptions()
96539688 {
96549689 options1[0] = 100;
9655
- options1[1] = 0.025f;
9656
- options1[2] = 0.01f;
9690
+ options1[1] = 0.01f; // .025f;
9691
+ options1[2] = 3f;
96579692 options1[3] = 0;
96589693 options1[4] = 0;
96599694
....@@ -9993,7 +10028,7 @@
999310028 ext = "png";
999410029 Iterator iter = ImageIO.getImageWritersByFormatName(ext);
999510030 if (iter.hasNext()) {
9996
- writer = (ImageWriter)iter.next();
10031
+ writer = (ImageWriter)iter.next();
999710032 }
999810033
999910034 // patch for NULLE PART
....@@ -10760,7 +10795,9 @@
1076010795 }
1076110796 /**/
1076210797
10763
- if (selection)
10798
+ boolean control = ((modifiers & CTRL) != 0);
10799
+
10800
+ if (selection && (!Globals.isLIVE() || control))
1076410801 {
1076510802 selectbuffer.display();
1076610803 return;
....@@ -10858,61 +10895,64 @@
1085810895 {
1085910896 //pingthread.mute = true;
1086010897
10861
- boolean keyon = false;
10862
-
10863
- if (keys[DOWN_ARROW])
10898
+ if (capsLocked)
1086410899 {
10865
- speed = ++speedkey[DOWN_ARROW];
10866
- if (speed > 20)
10867
- speed = 20;
10868
- GoDown(modifiers);
10869
- keyon = true;
10870
- }
10871
- else
10872
- speedkey[DOWN_ARROW] = 0;
10900
+ boolean keyon = false;
1087310901
10874
- if (keys[UP_ARROW])
10875
- {
10876
- speed = ++speedkey[UP_ARROW];
10877
- if (speed > 20)
10878
- speed = 20;
10879
- GoUp(modifiers);
10880
- keyon = true;
10881
- }
10882
- else
10883
- speedkey[UP_ARROW] = 0;
10902
+ if (keys[DOWN_ARROW])
10903
+ {
10904
+ speed = ++speedkey[DOWN_ARROW];
10905
+ if (speed > 20)
10906
+ speed = 20;
10907
+ GoDown(modifiers);
10908
+ keyon = true;
10909
+ }
10910
+ else
10911
+ speedkey[DOWN_ARROW] = 0;
1088410912
10885
- if (keys[LEFT_ARROW])
10886
- {
10887
- speed = ++speedkey[LEFT_ARROW];
10888
- if (speed > 20)
10889
- speed = 20;
10890
- GoLeft(modifiers);
10891
- keyon = true;
10892
- }
10893
- else
10894
- speedkey[LEFT_ARROW] = 0;
10913
+ if (keys[UP_ARROW])
10914
+ {
10915
+ speed = ++speedkey[UP_ARROW];
10916
+ if (speed > 20)
10917
+ speed = 20;
10918
+ GoUp(modifiers);
10919
+ keyon = true;
10920
+ }
10921
+ else
10922
+ speedkey[UP_ARROW] = 0;
1089510923
10896
- if (keys[RIGHT_ARROW])
10897
- {
10898
- speed = ++speedkey[RIGHT_ARROW];
10899
- if (speed > 20)
10900
- speed = 20;
10901
- GoRight(modifiers);
10902
- keyon = true;
10903
- }
10904
- else
10905
- speedkey[RIGHT_ARROW] = 0;
10906
-
10907
- if (Globals.WALK && capsLocked)
10908
- {
10909
- Walk();
10910
- keyon = true;
10911
- }
10912
-
10913
- if (keyon)
10914
- {
10915
- repaint();
10924
+ if (keys[LEFT_ARROW])
10925
+ {
10926
+ speed = ++speedkey[LEFT_ARROW];
10927
+ if (speed > 20)
10928
+ speed = 20;
10929
+ GoLeft(modifiers);
10930
+ keyon = true;
10931
+ }
10932
+ else
10933
+ speedkey[LEFT_ARROW] = 0;
10934
+
10935
+ if (keys[RIGHT_ARROW])
10936
+ {
10937
+ speed = ++speedkey[RIGHT_ARROW];
10938
+ if (speed > 20)
10939
+ speed = 20;
10940
+ GoRight(modifiers);
10941
+ keyon = true;
10942
+ }
10943
+ else
10944
+ speedkey[RIGHT_ARROW] = 0;
10945
+
10946
+ if (Globals.WALK)
10947
+ {
10948
+ Walk();
10949
+ keyon = true;
10950
+ }
10951
+
10952
+ if (keyon)
10953
+ {
10954
+ repaint();
10955
+ }
1091610956 }
1091710957
1091810958 //pingthread.mute = false;
....@@ -11257,7 +11297,7 @@
1125711297 //gl.glEnable(gl.GL_ALPHA_TEST);
1125811298 //gl.glActiveTexture(GL.GL_TEXTURE0);
1125911299
11260
- if (!IsFrozen() && !ambientOcclusion)
11300
+ if (!IsFrozen()) // && !ambientOcclusion)
1126111301 {
1126211302 DrawSkyBox(gl, (float)ratio);
1126311303 }
....@@ -11865,7 +11905,10 @@
1186511905 }
1186611906
1186711907 if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013
11908
+ {
11909
+ renderCamera.computeTransform();
1186811910 repaint();
11911
+ }
1186911912
1187011913 displaydone = true;
1187111914 }
....@@ -14337,6 +14380,7 @@
1433714380 public void mouseClicked(MouseEvent e)
1433814381 {
1433914382 System.out.println("mouseClicked: " + e);
14383
+ System.exit(0);
1434014384 }
1434114385
1434214386 public void mousePressed(MouseEvent e)
....@@ -14406,14 +14450,9 @@
1440614450 int ay = anchorY;
1440714451 MODIFIERS &= ~COMMAND;
1440814452 mouseMode = 0; // autorepeat
14409
- tmp.set(targetLookAt);
14410
- tmp.sub(manipCamera.lookAt);
14411
- if (manipCamera.hAspect == 0)
14412
- {
14413
- manipCamera.lookAt.add(tmp);
14414
- manipCamera.location.add(tmp);
14415
- manipCamera.computeTransform();
14416
- }
14453
+
14454
+ Jump2Target();
14455
+
1441714456 // int mode = WHEEL;
1441814457 // if (e.metaDown())
1441914458 // {
....@@ -14421,7 +14460,7 @@
1442114460 //}
1442214461
1442314462 SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14424
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
14463
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx());
1442514464 anchorX = ax;
1442614465 anchorY = ay;
1442714466 prevX = px;
....@@ -14529,6 +14568,8 @@
1452914568 {
1453014569 if (!wasliveok)
1453114570 return;
14571
+
14572
+ Jump2Target();
1453214573
1453314574 AAtimer.restart(); //
1453414575 Globals.TIMERRUNNING = true;
....@@ -14648,7 +14689,7 @@
1464814689 boolean jump;
1464914690 boolean live;
1465014691
14651
- boolean mute;
14692
+ boolean mute = false;
1465214693
1465314694 // void JumpToTarget()
1465414695 // {
....@@ -14664,10 +14705,33 @@
1466414705 // only one thread!? synchronized
1466514706 void StepToTarget(boolean jump)
1466614707 {
14708
+ RigidBody.pos.x = 0;
14709
+ RigidBody.pos.y = 0;
14710
+ RigidBody.pos.z = 0;
14711
+ if (RigidBody.justclicked)
14712
+ {
14713
+ RigidBody.pos.x = (float)manipCamera.lookAt.x;
14714
+ RigidBody.pos.y = (float)manipCamera.lookAt.y;
14715
+ RigidBody.pos.z = (float)manipCamera.lookAt.z;
14716
+ // System.err.println("selected point = " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][1]) + " " + Trunk(selectedpoint.toParent[3][2]));
14717
+ CreateSelectedPoint();
14718
+
14719
+// RigidBody.pos.x = (float)selectedpoint.toParent[3][0];
14720
+// RigidBody.pos.y = (float)selectedpoint.toParent[3][1];
14721
+// RigidBody.pos.z = (float)selectedpoint.toParent[3][2];
14722
+//
14723
+// RigidBody.wind.set(RigidBody.pos);
14724
+// RigidBody.wind.x -= (float)manipCamera.lookAt.x;
14725
+// RigidBody.wind.y -= (float)manipCamera.lookAt.y;
14726
+// RigidBody.wind.z -= (float)manipCamera.lookAt.z;
14727
+// RigidBody.wind.scale(-1);
14728
+// RigidBody.wind.normalize();
14729
+ }
14730
+
1466714731 if (mute)
1466814732 return;
1466914733
14670
- if (capsLocked)
14734
+ if (capsLocked && manipCamera.viewCode == 0)
1467114735 {
1467214736 eye.x = manipCamera.location.x;
1467314737 eye.y = manipCamera.location.y + 0.25;
....@@ -14958,8 +15022,28 @@
1495815022 targetLookAt.set(manipCamera.lookAt);
1495915023 }
1496015024
15025
+ void ViewAngle(float dy)
15026
+ {
15027
+ double factor = Math.exp(-dy/300.0); // (1 + dy/100);
15028
+
15029
+ if (manipCamera.shaper_fovy * factor > 1 &&
15030
+ manipCamera.shaper_fovy * factor < 150)
15031
+ {
15032
+ manipCamera.shaper_fovy *= factor;
15033
+ //System.out.println("fovy = " + shaper_fovy);
15034
+ }
15035
+ }
15036
+
1496115037 void GoDown(int mod)
1496215038 {
15039
+ LA.vecSub(manipCamera.location, manipCamera.lookAt, manipCamera.direction);
15040
+ float scale = (float)manipCamera.direction.length() / 10;
15041
+
15042
+ if (!capsLocked)
15043
+ {
15044
+ scale = 50;
15045
+ }
15046
+
1496315047 MODIFIERS |= COMMAND;
1496415048 boolean isVR = (mouseMode&VR)!=0;
1496515049 /**/
....@@ -14968,14 +15052,17 @@
1496815052 // if (isVR)
1496915053 // manipCamera.RotateInterest(0, speed);
1497015054 // else
14971
- manipCamera.Translate(0, -speed*delta, getWidth());
15055
+ //if (isVR)
15056
+ // ViewAngle(-speed*delta*scale);
15057
+ //else
15058
+ manipCamera.Translate(0, -speed*delta*scale, getWidth());
1497215059 }
1497315060 else
1497415061 {
1497515062 if (isVR)
14976
- manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
15063
+ manipCamera.BackForth(0, -speed*delta*scale, isVR?1000:0); // getWidth());
1497715064 else
14978
- manipCamera.RotatePosition(0, -speed);
15065
+ manipCamera.RotatePosition(0, -speed*scale);
1497915066 }
1498015067
1498115068 /**/
....@@ -14995,6 +15082,16 @@
1499515082
1499615083 void GoUp(int mod)
1499715084 {
15085
+ LA.vecSub(manipCamera.location, manipCamera.lookAt, manipCamera.direction);
15086
+ float scale = (float)manipCamera.direction.length() / 10;
15087
+
15088
+ if (!capsLocked)
15089
+ {
15090
+ scale = 50;
15091
+ }
15092
+
15093
+ RigidBody.justclicked = true;
15094
+
1499815095 MODIFIERS |= COMMAND;
1499915096 /**/
1500015097 boolean isVR = (mouseMode&VR)!=0;
....@@ -15004,14 +15101,17 @@
1500415101 // if (isVR)
1500515102 // manipCamera.RotateInterest(0, -speed);
1500615103 // else
15007
- manipCamera.Translate(0, speed*delta, getWidth());
15104
+ //if (isVR)
15105
+ // ViewAngle(speed*delta*scale);
15106
+ //else
15107
+ manipCamera.Translate(0, speed*delta*scale, getWidth());
1500815108 }
1500915109 else
1501015110 {
1501115111 if (isVR)
15012
- manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
15112
+ manipCamera.BackForth(0, speed*delta*scale, isVR?1000:0); // getWidth());
1501315113 else
15014
- manipCamera.RotatePosition(0, speed);
15114
+ manipCamera.RotatePosition(0, speed*scale);
1501515115 }
1501615116
1501715117 /**/
....@@ -15031,16 +15131,24 @@
1503115131
1503215132 void GoLeft(int mod)
1503315133 {
15134
+ LA.vecSub(manipCamera.location, manipCamera.lookAt, manipCamera.direction);
15135
+ float scale = (float)manipCamera.direction.length() / 10;
15136
+
15137
+ if (!capsLocked)
15138
+ {
15139
+ scale = 50;
15140
+ }
15141
+
1503415142 MODIFIERS |= COMMAND;
1503515143 /**/
1503615144 if((mod&SHIFT) == SHIFT)
15037
- manipCamera.Translate(speed*delta, 0, getWidth());
15145
+ manipCamera.Translate(speed*scale, 0, getWidth());
1503815146 else
1503915147 {
1504015148 if ((mouseMode&VR)!=0)
15041
- manipCamera.RotateInterest(-speed, 0);
15149
+ manipCamera.RotateInterest(-speed*scale*manipCamera.shaper_fovy/90, 0);
1504215150 else
15043
- manipCamera.RotatePosition(speed, 0);
15151
+ manipCamera.RotatePosition(speed*scale*manipCamera.shaper_fovy/90, 0);
1504415152 }
1504515153
1504615154 /**/
....@@ -15063,16 +15171,24 @@
1506315171
1506415172 void GoRight(int mod)
1506515173 {
15174
+ LA.vecSub(manipCamera.location, manipCamera.lookAt, manipCamera.direction);
15175
+ float scale = (float)manipCamera.direction.length() / 10;
15176
+
15177
+ if (!capsLocked)
15178
+ {
15179
+ scale = 50;
15180
+ }
15181
+
1506615182 MODIFIERS |= COMMAND;
1506715183 /**/
1506815184 if((mod&SHIFT) == SHIFT)
15069
- manipCamera.Translate(-speed*delta, 0, getWidth());
15185
+ manipCamera.Translate(-speed*scale, 0, getWidth());
1507015186 else
1507115187 {
1507215188 if ((mouseMode&VR)!=0)
15073
- manipCamera.RotateInterest(speed, 0);
15189
+ manipCamera.RotateInterest(speed*scale*manipCamera.shaper_fovy/90, 0);
1507415190 else
15075
- manipCamera.RotatePosition(-speed, 0);
15191
+ manipCamera.RotatePosition(-speed*scale*manipCamera.shaper_fovy/90, 0);
1507615192 }
1507715193
1507815194 /**/
....@@ -15219,6 +15335,11 @@
1521915335 if ((mouseMode & ZOOM) != 0)
1522015336 {
1522115337 //if ((mouseMode & BACKFORTH) != 0)
15338
+ if ((modifiersex & SHIFT) == SHIFT)
15339
+ {
15340
+ ViewAngle(dy);
15341
+ }
15342
+ else
1522215343 if ((mouseMode & VR) != 0)
1522315344 manipCamera.BackForth(dx, dy, getWidth());
1522415345 else
....@@ -15320,6 +15441,12 @@
1532015441
1532115442 public void mouseReleased(MouseEvent e)
1532215443 {
15444
+ if (isRenderer && !movingcamera)
15445
+ {
15446
+ RigidBody.justclicked = true;
15447
+ System.out.println("justclicked: " + e);
15448
+ }
15449
+
1532315450 Globals.MOUSEDRAGGED = false;
1532415451
1532515452 movingcamera = false;
....@@ -15546,7 +15673,8 @@
1554615673 {
1554715674 // Set the blank cursor to the JFrame.
1554815675 //object.editWindow.frame.
15549
- setCursor(blankCursor);
15676
+ if (key == ENTER) // Globals.ADVANCED)
15677
+ setCursor(blankCursor); // Contaminates other apps!
1555015678
1555115679 if (key >= '0' && key <= '5')
1555215680 clampbit = (key-'0');
....@@ -15631,11 +15759,9 @@
1563115759 DISPLAYTEXT ^= true;
1563215760 repaint();
1563315761 break;
15634
- case 'A':
15762
+ //case 'A':
1563515763 case 'a':
15636
- CURRENTANTIALIAS = ((CURRENTANTIALIAS != 0) ? 0 : 1);
15637
- System.out.println("Antialias ACSIZE = " + ACSIZE);
15638
- System.out.println("CURRENTANTIALIAS = " + CURRENTANTIALIAS);
15764
+ ToggleAntialiasing();
1563915765 repaint();
1564015766 break;
1564115767 case 'd':
....@@ -15739,6 +15865,8 @@
1573915865 {
1574015866 //PrintMemory();
1574115867 ToggleImageFlip();
15868
+ renderCamera.computeTransform();
15869
+ repaint();
1574215870 break;
1574315871 }
1574415872 case 'M':
....@@ -15859,8 +15987,11 @@
1585915987 // kompactbit = 6;
1586015988 // break;
1586115989 case ' ':
15862
- capsLocked ^= true;
15863
- repaint();
15990
+ if (manipCamera != lightCamera)
15991
+ {
15992
+ capsLocked ^= true;
15993
+ repaint();
15994
+ }
1586415995 break;
1586515996 case 'l':
1586615997 lightMode ^= true;
....@@ -15923,10 +16054,10 @@
1592316054 case ENTER:
1592416055 // object.editWindow.ScreenFit(); // Edit();
1592516056 ToggleLive();
15926
- if (capsLocked)
15927
- {
15928
- Globals.WALK ^= true;
15929
- }
16057
+// if (capsLocked)
16058
+// {
16059
+// Globals.WALK ^= true;
16060
+// }
1593016061 break;
1593116062 case DELETE:
1593216063 ClearSelection();
....@@ -16011,8 +16142,13 @@
1601116142 }
1601216143 repaint();
1601316144 break;
16145
+ case '.':
16146
+ Globals.ONESTEP = true;
16147
+ repaint();
16148
+ break;
1601416149 case BACKSPACE:
16015
- enablebackspace = true;
16150
+ // almost working enablebackspace = true;
16151
+ Globals.WALK ^= true;
1601616152
1601716153 // SwitchCameras(false);
1601816154 repaint();
....@@ -16044,10 +16180,61 @@
1604416180 switch (e.getID())
1604516181 {
1604616182 case KeyEvent.KEY_PRESSED:
16047
- keys[e.getKeyCode()] = true;
16048
- modifiers = e.getModifiersEx();
16049
- keyPressed(e.getKeyChar(), modifiers);
16050
- //Globals.theRenderer.keyPressed(e.getKeyChar());
16183
+
16184
+ if (capsLocked)
16185
+ {
16186
+ keys[e.getKeyCode()] = true;
16187
+ modifiers = e.getModifiersEx();
16188
+ keyPressed(e.getKeyChar(), modifiers);
16189
+ //Globals.theRenderer.keyPressed(e.getKeyChar());
16190
+ }
16191
+ else
16192
+ {
16193
+ if (manipCamera == lightCamera)
16194
+ {
16195
+ switch (e.getKeyCode())
16196
+ {
16197
+ case DOWN_ARROW:
16198
+ lightCamera.DECAL /= 2;
16199
+ break;
16200
+ case UP_ARROW:
16201
+ lightCamera.DECAL *= 2;
16202
+ break;
16203
+ case LEFT_ARROW:
16204
+ lightCamera.SCALE /= 2;
16205
+ break;
16206
+ case RIGHT_ARROW:
16207
+ lightCamera.SCALE *= 2;
16208
+ break;
16209
+ default:
16210
+ break;
16211
+ }
16212
+
16213
+ System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE);
16214
+ } else
16215
+ {
16216
+ switch (e.getKeyCode())
16217
+ {
16218
+ case DOWN_ARROW:
16219
+ GoDown(e.getModifiersEx());
16220
+ break;
16221
+ case UP_ARROW:
16222
+ GoUp(e.getModifiersEx());
16223
+ break;
16224
+ case LEFT_ARROW:
16225
+ GoLeft(e.getModifiersEx());
16226
+ break;
16227
+ case RIGHT_ARROW:
16228
+ GoRight(e.getModifiersEx());
16229
+ break;
16230
+ default:
16231
+ modifiers = e.getModifiersEx();
16232
+ keyPressed(e.getKeyChar(), modifiers);
16233
+ break;
16234
+ }
16235
+ }
16236
+ }
16237
+
1605116238 repaint();
1605216239 break;
1605316240 // if (!autorepeat)
....@@ -16717,7 +16904,8 @@
1671716904
1671816905 public boolean mouseDrag(Event evt, int x, int y)
1671916906 {
16720
- //System.out.println("mouseDrag: " + evt);
16907
+ System.out.println("mouseDrag: " + evt);
16908
+ System.exit(0);
1672116909 /*
1672216910 drag = true;
1672316911 //System.out.println("Mouse DRAG");
....@@ -16836,6 +17024,7 @@
1683617024 public boolean mouseUp(Event evt, int x, int y)
1683717025 {
1683817026 System.out.println("mouseUp: " + evt);
17027
+ System.exit(0);
1683917028 /*
1684017029 locked = false;
1684117030 if (isRenderer)
....@@ -17106,7 +17295,7 @@
1710617295 return;
1710717296 }
1710817297
17109
- if (WIREFRAME)
17298
+ //if (WIREFRAME)
1711017299 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1711117300
1711217301 gl.glDisable(gl.GL_CULL_FACE);
....@@ -17206,6 +17395,8 @@
1720617395
1720717396 if (WIREFRAME)
1720817397 gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE);
17398
+ else
17399
+ gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL);
1720917400 }
1721017401
1721117402 private void DrawChecker(GL gl)
....@@ -17969,7 +18160,14 @@
1796918160
1797018161 gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
1797118162
17972
- int[] pixels = selectsizebuffer.array();
18163
+ int[] pixels = occlusioncolorbuffer.array();
18164
+
18165
+// BufferedImage rendImage = new BufferedImage(OCCLUSION_SIZE, OCCLUSION_SIZE, BufferedImage.TYPE_INT_RGB);
18166
+// rendImage.setRGB(0,0, OCCLUSION_SIZE,OCCLUSION_SIZE, pixels, OCCLUSION_SIZE*(OCCLUSION_SIZE-1),-OCCLUSION_SIZE);
18167
+//
18168
+// Grafreed.SaveImage("testocclusion.jpg", rendImage, 0.5f);
18169
+//
18170
+// System.exit(0);
1797318171
1797418172 double r = 0, g = 0, b = 0;
1797518173
....@@ -17981,6 +18179,9 @@
1798118179
1798218180 double FACTOR = 1;
1798318181
18182
+ float minvalue = 1;
18183
+ float maxvalue = 0;
18184
+
1798418185 for (int i = 0; i < depths.length; i++)
1798518186 {
1798618187 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -18064,6 +18265,27 @@
1806418265
1806518266 double scale = ray.z; // 1; // cos
1806618267
18268
+ int pixel = pixels[newindex];
18269
+
18270
+ float value = (pixel&255) / 255.0f;
18271
+
18272
+ pixel >>= 8;
18273
+
18274
+ value += (pixel&255) / 255.0f;
18275
+
18276
+ pixel >>= 8;
18277
+
18278
+ value += (pixel&255) / 255.0f;
18279
+
18280
+ value /= 3;
18281
+
18282
+ if (minvalue > value)
18283
+ minvalue = value;
18284
+ if (maxvalue < value)
18285
+ maxvalue = value;
18286
+
18287
+ //scale *= value;
18288
+
1806718289 float depth = depths[newindex];
1806818290
1806918291 /*
....@@ -18100,6 +18322,8 @@
1810018322 double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]);
1810118323
1810218324 double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR);
18325
+
18326
+ factor *= value;
1810318327
1810418328 r += factor * scale;
1810518329 g += factor * scale;
....@@ -18143,6 +18367,8 @@
1814318367
1814418368 stackdepth--;
1814518369
18370
+// System.err.println("minvalue = " + minvalue);
18371
+// System.err.println("maxvalue = " + maxvalue);
1814618372 //System.err.println("depth = " + stackdepth);
1814718373 // DEBUG
1814818374 /*
....@@ -18210,7 +18436,7 @@
1821018436
1821118437 private boolean keepshadow;
1821218438
18213
- public boolean capsLocked = false; // VR
18439
+ static public boolean capsLocked = false; // VR
1821418440
1821518441 static public int indexcount = 0;
1821618442 /*static*/ cColor vertexOcclusion = new cColor();