.. | .. |
---|
1 | 1 | |
---|
| 2 | +import com.bulletphysics.dynamics.RigidBody; |
---|
2 | 3 | import java.awt.*; |
---|
3 | 4 | import java.awt.event.*; |
---|
4 | 5 | import java.awt.image.*; |
---|
.. | .. |
---|
49 | 50 | |
---|
50 | 51 | static int STEP = 1; |
---|
51 | 52 | |
---|
| 53 | + //static int[] pixels = new int[10000000]; |
---|
| 54 | + |
---|
52 | 55 | private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
53 | 56 | { |
---|
54 | 57 | int[] pixels = new int[bytes.length/3]; |
---|
55 | | - for (int i=pixels.length; --i>=0;) |
---|
| 58 | + for (int i=bytes.length/3; --i>=0;) |
---|
56 | 59 | { |
---|
57 | 60 | int i3 = i*3; |
---|
58 | 61 | pixels[i] = 0xFF; |
---|
.. | .. |
---|
123 | 126 | static boolean LOCALTRANSFORM = false; |
---|
124 | 127 | static boolean FULLSCREEN = false; |
---|
125 | 128 | static boolean SUPPORT = true; |
---|
126 | | -static boolean INERTIA = true; |
---|
| 129 | +static boolean INERTIA = false; // true; |
---|
127 | 130 | static boolean FAST = false; |
---|
128 | 131 | static boolean SLOWPOSE = false; |
---|
129 | 132 | static boolean FOOTCONTACT = true; |
---|
.. | .. |
---|
192 | 195 | |
---|
193 | 196 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
194 | 197 | |
---|
| 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 | + |
---|
195 | 210 | public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
196 | 211 | { |
---|
197 | 212 | try |
---|
.. | .. |
---|
249 | 264 | |
---|
250 | 265 | public javax.media.opengl.GL GetGL0() |
---|
251 | 266 | { |
---|
252 | | - return null; |
---|
| 267 | + return currentGL; |
---|
253 | 268 | } |
---|
254 | 269 | |
---|
255 | 270 | public int GenList() |
---|
.. | .. |
---|
1529 | 1544 | } |
---|
1530 | 1545 | } |
---|
1531 | 1546 | float b = 0; |
---|
1532 | | - if (obj.support != null && obj.link2master) |
---|
| 1547 | + if (obj.support != null && obj.Link2Support()) |
---|
1533 | 1548 | { |
---|
1534 | 1549 | b = 1; |
---|
1535 | 1550 | } |
---|
.. | .. |
---|
2177 | 2192 | //SwitchCameras(); |
---|
2178 | 2193 | } |
---|
2179 | 2194 | |
---|
| 2195 | + cVector origin = new cVector(); |
---|
| 2196 | + |
---|
2180 | 2197 | void RevertCamera() |
---|
2181 | 2198 | { |
---|
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); |
---|
2183 | 2207 | |
---|
2184 | 2208 | //SwitchCameras(); |
---|
2185 | 2209 | } |
---|
.. | .. |
---|
2227 | 2251 | // else |
---|
2228 | 2252 | repaint(); // start loop // may 2013 |
---|
2229 | 2253 | } |
---|
| 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 | + } |
---|
2230 | 2261 | |
---|
2231 | 2262 | public void ToggleSupport() |
---|
2232 | 2263 | { |
---|
.. | .. |
---|
2272 | 2303 | { |
---|
2273 | 2304 | IMAGEFLIP ^= true; |
---|
2274 | 2305 | } |
---|
| 2306 | + |
---|
2275 | 2307 | |
---|
2276 | 2308 | public void ToggleSpeakerMocap() |
---|
2277 | 2309 | { |
---|
.. | .. |
---|
3829 | 3861 | |
---|
3830 | 3862 | switch (resolution) |
---|
3831 | 3863 | { |
---|
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; |
---|
3838 | 3871 | } |
---|
3839 | 3872 | |
---|
3840 | 3873 | // restarget = 512*512; // 512*512; // 2048; // 512; // 1024; |
---|
.. | .. |
---|
6961 | 6994 | short residu = 0; |
---|
6962 | 6995 | |
---|
6963 | 6996 | // wraparound workarounds |
---|
6964 | | - short fuck = (short) (buffer[i] & 0xFF); |
---|
| 6997 | + short ww = (short) (buffer[i] & 0xFF); |
---|
6965 | 6998 | /* |
---|
6966 | | - residu += (fuck%2); |
---|
6967 | | - if(fuck/2 < 256-residu/2) |
---|
| 6999 | + residu += (ww%2); |
---|
| 7000 | + if(ww/2 < 256-residu/2) |
---|
6968 | 7001 | { |
---|
6969 | | - fuck = (short)((fuck/2) + residu/2); |
---|
| 7002 | + ww = (short)((ww/2) + residu/2); |
---|
6970 | 7003 | if(residu == 2) |
---|
6971 | 7004 | residu = 0; |
---|
6972 | 7005 | } |
---|
6973 | 7006 | else |
---|
6974 | 7007 | { |
---|
6975 | 7008 | residu = 0; |
---|
6976 | | - fuck /= 2; |
---|
| 7009 | + ww /= 2; |
---|
6977 | 7010 | } |
---|
6978 | 7011 | */ |
---|
6979 | | - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) |
---|
| 7012 | + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) |
---|
6980 | 7013 | { |
---|
6981 | | - fuck /= 2; |
---|
| 7014 | + ww /= 2; |
---|
6982 | 7015 | } else |
---|
6983 | 7016 | { |
---|
6984 | | - fuck = (short) ((fuck / 2) + fuck % 2); |
---|
| 7017 | + ww = (short) ((ww / 2) + ww % 2); |
---|
6985 | 7018 | } |
---|
6986 | 7019 | |
---|
6987 | | - buffer[i] = (byte) fuck; |
---|
| 7020 | + buffer[i] = (byte) ww; |
---|
6988 | 7021 | } |
---|
6989 | 7022 | //System.out.print(bytes[i] + " "); |
---|
6990 | 7023 | //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; |
---|
.. | .. |
---|
9366 | 9399 | boolean pointselection = false; |
---|
9367 | 9400 | ///*static*/ boolean lighttouched = true; |
---|
9368 | 9401 | boolean deselect; |
---|
9369 | | - private boolean ambientOcclusion = false; |
---|
| 9402 | + |
---|
| 9403 | + static boolean ambientOcclusion = false; |
---|
| 9404 | + |
---|
9370 | 9405 | static boolean flash = false; |
---|
9371 | 9406 | /*static*/ boolean wait = false; |
---|
9372 | 9407 | boolean displaydone = false; // after repaint() calls |
---|
.. | .. |
---|
9618 | 9653 | pixdx, pixdy, edx, edy, focus); |
---|
9619 | 9654 | } |
---|
9620 | 9655 | |
---|
9621 | | - static int ACSIZE = 4; // 16; |
---|
| 9656 | + static int ACSIZE = 16; // 16; |
---|
9622 | 9657 | static int MAXACSIZE = 256; // 1024; |
---|
9623 | 9658 | static float[] jx8 = new float[MAXACSIZE]; |
---|
9624 | 9659 | static float[] jy8 = new float[MAXACSIZE]; |
---|
.. | .. |
---|
9652 | 9687 | void ResetOptions() |
---|
9653 | 9688 | { |
---|
9654 | 9689 | options1[0] = 100; |
---|
9655 | | - options1[1] = 0.025f; |
---|
9656 | | - options1[2] = 0.01f; |
---|
| 9690 | + options1[1] = 0.01f; // .025f; |
---|
| 9691 | + options1[2] = 3f; |
---|
9657 | 9692 | options1[3] = 0; |
---|
9658 | 9693 | options1[4] = 0; |
---|
9659 | 9694 | |
---|
.. | .. |
---|
9993 | 10028 | ext = "png"; |
---|
9994 | 10029 | Iterator iter = ImageIO.getImageWritersByFormatName(ext); |
---|
9995 | 10030 | if (iter.hasNext()) { |
---|
9996 | | - writer = (ImageWriter)iter.next(); |
---|
| 10031 | + writer = (ImageWriter)iter.next(); |
---|
9997 | 10032 | } |
---|
9998 | 10033 | |
---|
9999 | 10034 | // patch for NULLE PART |
---|
.. | .. |
---|
10760 | 10795 | } |
---|
10761 | 10796 | /**/ |
---|
10762 | 10797 | |
---|
10763 | | - if (selection) |
---|
| 10798 | + boolean control = ((modifiers & CTRL) != 0); |
---|
| 10799 | + |
---|
| 10800 | + if (selection && (!Globals.isLIVE() || control)) |
---|
10764 | 10801 | { |
---|
10765 | 10802 | selectbuffer.display(); |
---|
10766 | 10803 | return; |
---|
.. | .. |
---|
10858 | 10895 | { |
---|
10859 | 10896 | //pingthread.mute = true; |
---|
10860 | 10897 | |
---|
10861 | | - boolean keyon = false; |
---|
10862 | | - |
---|
10863 | | - if (keys[DOWN_ARROW]) |
---|
| 10898 | + if (capsLocked) |
---|
10864 | 10899 | { |
---|
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; |
---|
10873 | 10901 | |
---|
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; |
---|
10884 | 10912 | |
---|
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; |
---|
10895 | 10923 | |
---|
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 | + } |
---|
10916 | 10956 | } |
---|
10917 | 10957 | |
---|
10918 | 10958 | //pingthread.mute = false; |
---|
.. | .. |
---|
11257 | 11297 | //gl.glEnable(gl.GL_ALPHA_TEST); |
---|
11258 | 11298 | //gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
11259 | 11299 | |
---|
11260 | | - if (!IsFrozen() && !ambientOcclusion) |
---|
| 11300 | + if (!IsFrozen()) // && !ambientOcclusion) |
---|
11261 | 11301 | { |
---|
11262 | 11302 | DrawSkyBox(gl, (float)ratio); |
---|
11263 | 11303 | } |
---|
.. | .. |
---|
11865 | 11905 | } |
---|
11866 | 11906 | |
---|
11867 | 11907 | if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 |
---|
| 11908 | + { |
---|
| 11909 | + renderCamera.computeTransform(); |
---|
11868 | 11910 | repaint(); |
---|
| 11911 | + } |
---|
11869 | 11912 | |
---|
11870 | 11913 | displaydone = true; |
---|
11871 | 11914 | } |
---|
.. | .. |
---|
14337 | 14380 | public void mouseClicked(MouseEvent e) |
---|
14338 | 14381 | { |
---|
14339 | 14382 | System.out.println("mouseClicked: " + e); |
---|
| 14383 | + System.exit(0); |
---|
14340 | 14384 | } |
---|
14341 | 14385 | |
---|
14342 | 14386 | public void mousePressed(MouseEvent e) |
---|
.. | .. |
---|
14406 | 14450 | int ay = anchorY; |
---|
14407 | 14451 | MODIFIERS &= ~COMMAND; |
---|
14408 | 14452 | 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 | + |
---|
14417 | 14456 | // int mode = WHEEL; |
---|
14418 | 14457 | // if (e.metaDown()) |
---|
14419 | 14458 | // { |
---|
.. | .. |
---|
14421 | 14460 | //} |
---|
14422 | 14461 | |
---|
14423 | 14462 | 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()); |
---|
14425 | 14464 | anchorX = ax; |
---|
14426 | 14465 | anchorY = ay; |
---|
14427 | 14466 | prevX = px; |
---|
.. | .. |
---|
14529 | 14568 | { |
---|
14530 | 14569 | if (!wasliveok) |
---|
14531 | 14570 | return; |
---|
| 14571 | + |
---|
| 14572 | + Jump2Target(); |
---|
14532 | 14573 | |
---|
14533 | 14574 | AAtimer.restart(); // |
---|
14534 | 14575 | Globals.TIMERRUNNING = true; |
---|
.. | .. |
---|
14648 | 14689 | boolean jump; |
---|
14649 | 14690 | boolean live; |
---|
14650 | 14691 | |
---|
14651 | | - boolean mute; |
---|
| 14692 | + boolean mute = false; |
---|
14652 | 14693 | |
---|
14653 | 14694 | // void JumpToTarget() |
---|
14654 | 14695 | // { |
---|
.. | .. |
---|
14664 | 14705 | // only one thread!? synchronized |
---|
14665 | 14706 | void StepToTarget(boolean jump) |
---|
14666 | 14707 | { |
---|
| 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 | + |
---|
14667 | 14731 | if (mute) |
---|
14668 | 14732 | return; |
---|
14669 | 14733 | |
---|
14670 | | - if (capsLocked) |
---|
| 14734 | + if (capsLocked && manipCamera.viewCode == 0) |
---|
14671 | 14735 | { |
---|
14672 | 14736 | eye.x = manipCamera.location.x; |
---|
14673 | 14737 | eye.y = manipCamera.location.y + 0.25; |
---|
.. | .. |
---|
14958 | 15022 | targetLookAt.set(manipCamera.lookAt); |
---|
14959 | 15023 | } |
---|
14960 | 15024 | |
---|
| 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 | + |
---|
14961 | 15037 | void GoDown(int mod) |
---|
14962 | 15038 | { |
---|
| 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 | + |
---|
14963 | 15047 | MODIFIERS |= COMMAND; |
---|
14964 | 15048 | boolean isVR = (mouseMode&VR)!=0; |
---|
14965 | 15049 | /**/ |
---|
.. | .. |
---|
14968 | 15052 | // if (isVR) |
---|
14969 | 15053 | // manipCamera.RotateInterest(0, speed); |
---|
14970 | 15054 | // 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()); |
---|
14972 | 15059 | } |
---|
14973 | 15060 | else |
---|
14974 | 15061 | { |
---|
14975 | 15062 | if (isVR) |
---|
14976 | | - manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15063 | + manipCamera.BackForth(0, -speed*delta*scale, isVR?1000:0); // getWidth()); |
---|
14977 | 15064 | else |
---|
14978 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 15065 | + manipCamera.RotatePosition(0, -speed*scale); |
---|
14979 | 15066 | } |
---|
14980 | 15067 | |
---|
14981 | 15068 | /**/ |
---|
.. | .. |
---|
14995 | 15082 | |
---|
14996 | 15083 | void GoUp(int mod) |
---|
14997 | 15084 | { |
---|
| 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 | + |
---|
14998 | 15095 | MODIFIERS |= COMMAND; |
---|
14999 | 15096 | /**/ |
---|
15000 | 15097 | boolean isVR = (mouseMode&VR)!=0; |
---|
.. | .. |
---|
15004 | 15101 | // if (isVR) |
---|
15005 | 15102 | // manipCamera.RotateInterest(0, -speed); |
---|
15006 | 15103 | // 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()); |
---|
15008 | 15108 | } |
---|
15009 | 15109 | else |
---|
15010 | 15110 | { |
---|
15011 | 15111 | if (isVR) |
---|
15012 | | - manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15112 | + manipCamera.BackForth(0, speed*delta*scale, isVR?1000:0); // getWidth()); |
---|
15013 | 15113 | else |
---|
15014 | | - manipCamera.RotatePosition(0, speed); |
---|
| 15114 | + manipCamera.RotatePosition(0, speed*scale); |
---|
15015 | 15115 | } |
---|
15016 | 15116 | |
---|
15017 | 15117 | /**/ |
---|
.. | .. |
---|
15031 | 15131 | |
---|
15032 | 15132 | void GoLeft(int mod) |
---|
15033 | 15133 | { |
---|
| 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 | + |
---|
15034 | 15142 | MODIFIERS |= COMMAND; |
---|
15035 | 15143 | /**/ |
---|
15036 | 15144 | if((mod&SHIFT) == SHIFT) |
---|
15037 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 15145 | + manipCamera.Translate(speed*scale, 0, getWidth()); |
---|
15038 | 15146 | else |
---|
15039 | 15147 | { |
---|
15040 | 15148 | if ((mouseMode&VR)!=0) |
---|
15041 | | - manipCamera.RotateInterest(-speed, 0); |
---|
| 15149 | + manipCamera.RotateInterest(-speed*scale*manipCamera.shaper_fovy/90, 0); |
---|
15042 | 15150 | else |
---|
15043 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 15151 | + manipCamera.RotatePosition(speed*scale*manipCamera.shaper_fovy/90, 0); |
---|
15044 | 15152 | } |
---|
15045 | 15153 | |
---|
15046 | 15154 | /**/ |
---|
.. | .. |
---|
15063 | 15171 | |
---|
15064 | 15172 | void GoRight(int mod) |
---|
15065 | 15173 | { |
---|
| 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 | + |
---|
15066 | 15182 | MODIFIERS |= COMMAND; |
---|
15067 | 15183 | /**/ |
---|
15068 | 15184 | if((mod&SHIFT) == SHIFT) |
---|
15069 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 15185 | + manipCamera.Translate(-speed*scale, 0, getWidth()); |
---|
15070 | 15186 | else |
---|
15071 | 15187 | { |
---|
15072 | 15188 | if ((mouseMode&VR)!=0) |
---|
15073 | | - manipCamera.RotateInterest(speed, 0); |
---|
| 15189 | + manipCamera.RotateInterest(speed*scale*manipCamera.shaper_fovy/90, 0); |
---|
15074 | 15190 | else |
---|
15075 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 15191 | + manipCamera.RotatePosition(-speed*scale*manipCamera.shaper_fovy/90, 0); |
---|
15076 | 15192 | } |
---|
15077 | 15193 | |
---|
15078 | 15194 | /**/ |
---|
.. | .. |
---|
15219 | 15335 | if ((mouseMode & ZOOM) != 0) |
---|
15220 | 15336 | { |
---|
15221 | 15337 | //if ((mouseMode & BACKFORTH) != 0) |
---|
| 15338 | + if ((modifiersex & SHIFT) == SHIFT) |
---|
| 15339 | + { |
---|
| 15340 | + ViewAngle(dy); |
---|
| 15341 | + } |
---|
| 15342 | + else |
---|
15222 | 15343 | if ((mouseMode & VR) != 0) |
---|
15223 | 15344 | manipCamera.BackForth(dx, dy, getWidth()); |
---|
15224 | 15345 | else |
---|
.. | .. |
---|
15320 | 15441 | |
---|
15321 | 15442 | public void mouseReleased(MouseEvent e) |
---|
15322 | 15443 | { |
---|
| 15444 | + if (isRenderer && !movingcamera) |
---|
| 15445 | + { |
---|
| 15446 | + RigidBody.justclicked = true; |
---|
| 15447 | + System.out.println("justclicked: " + e); |
---|
| 15448 | + } |
---|
| 15449 | + |
---|
15323 | 15450 | Globals.MOUSEDRAGGED = false; |
---|
15324 | 15451 | |
---|
15325 | 15452 | movingcamera = false; |
---|
.. | .. |
---|
15546 | 15673 | { |
---|
15547 | 15674 | // Set the blank cursor to the JFrame. |
---|
15548 | 15675 | //object.editWindow.frame. |
---|
15549 | | - setCursor(blankCursor); |
---|
| 15676 | + if (key == ENTER) // Globals.ADVANCED) |
---|
| 15677 | + setCursor(blankCursor); // Contaminates other apps! |
---|
15550 | 15678 | |
---|
15551 | 15679 | if (key >= '0' && key <= '5') |
---|
15552 | 15680 | clampbit = (key-'0'); |
---|
.. | .. |
---|
15631 | 15759 | DISPLAYTEXT ^= true; |
---|
15632 | 15760 | repaint(); |
---|
15633 | 15761 | break; |
---|
15634 | | - case 'A': |
---|
| 15762 | + //case 'A': |
---|
15635 | 15763 | case 'a': |
---|
15636 | | - CURRENTANTIALIAS = ((CURRENTANTIALIAS != 0) ? 0 : 1); |
---|
15637 | | - System.out.println("Antialias ACSIZE = " + ACSIZE); |
---|
15638 | | - System.out.println("CURRENTANTIALIAS = " + CURRENTANTIALIAS); |
---|
| 15764 | + ToggleAntialiasing(); |
---|
15639 | 15765 | repaint(); |
---|
15640 | 15766 | break; |
---|
15641 | 15767 | case 'd': |
---|
.. | .. |
---|
15739 | 15865 | { |
---|
15740 | 15866 | //PrintMemory(); |
---|
15741 | 15867 | ToggleImageFlip(); |
---|
| 15868 | + renderCamera.computeTransform(); |
---|
| 15869 | + repaint(); |
---|
15742 | 15870 | break; |
---|
15743 | 15871 | } |
---|
15744 | 15872 | case 'M': |
---|
.. | .. |
---|
15859 | 15987 | // kompactbit = 6; |
---|
15860 | 15988 | // break; |
---|
15861 | 15989 | case ' ': |
---|
15862 | | - capsLocked ^= true; |
---|
15863 | | - repaint(); |
---|
| 15990 | + if (manipCamera != lightCamera) |
---|
| 15991 | + { |
---|
| 15992 | + capsLocked ^= true; |
---|
| 15993 | + repaint(); |
---|
| 15994 | + } |
---|
15864 | 15995 | break; |
---|
15865 | 15996 | case 'l': |
---|
15866 | 15997 | lightMode ^= true; |
---|
.. | .. |
---|
15923 | 16054 | case ENTER: |
---|
15924 | 16055 | // object.editWindow.ScreenFit(); // Edit(); |
---|
15925 | 16056 | ToggleLive(); |
---|
15926 | | - if (capsLocked) |
---|
15927 | | - { |
---|
15928 | | - Globals.WALK ^= true; |
---|
15929 | | - } |
---|
| 16057 | +// if (capsLocked) |
---|
| 16058 | +// { |
---|
| 16059 | +// Globals.WALK ^= true; |
---|
| 16060 | +// } |
---|
15930 | 16061 | break; |
---|
15931 | 16062 | case DELETE: |
---|
15932 | 16063 | ClearSelection(); |
---|
.. | .. |
---|
16011 | 16142 | } |
---|
16012 | 16143 | repaint(); |
---|
16013 | 16144 | break; |
---|
| 16145 | + case '.': |
---|
| 16146 | + Globals.ONESTEP = true; |
---|
| 16147 | + repaint(); |
---|
| 16148 | + break; |
---|
16014 | 16149 | case BACKSPACE: |
---|
16015 | | - enablebackspace = true; |
---|
| 16150 | + // almost working enablebackspace = true; |
---|
| 16151 | + Globals.WALK ^= true; |
---|
16016 | 16152 | |
---|
16017 | 16153 | // SwitchCameras(false); |
---|
16018 | 16154 | repaint(); |
---|
.. | .. |
---|
16044 | 16180 | switch (e.getID()) |
---|
16045 | 16181 | { |
---|
16046 | 16182 | 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 | + |
---|
16051 | 16238 | repaint(); |
---|
16052 | 16239 | break; |
---|
16053 | 16240 | // if (!autorepeat) |
---|
.. | .. |
---|
16717 | 16904 | |
---|
16718 | 16905 | public boolean mouseDrag(Event evt, int x, int y) |
---|
16719 | 16906 | { |
---|
16720 | | - //System.out.println("mouseDrag: " + evt); |
---|
| 16907 | + System.out.println("mouseDrag: " + evt); |
---|
| 16908 | + System.exit(0); |
---|
16721 | 16909 | /* |
---|
16722 | 16910 | drag = true; |
---|
16723 | 16911 | //System.out.println("Mouse DRAG"); |
---|
.. | .. |
---|
16836 | 17024 | public boolean mouseUp(Event evt, int x, int y) |
---|
16837 | 17025 | { |
---|
16838 | 17026 | System.out.println("mouseUp: " + evt); |
---|
| 17027 | + System.exit(0); |
---|
16839 | 17028 | /* |
---|
16840 | 17029 | locked = false; |
---|
16841 | 17030 | if (isRenderer) |
---|
.. | .. |
---|
17106 | 17295 | return; |
---|
17107 | 17296 | } |
---|
17108 | 17297 | |
---|
17109 | | - if (WIREFRAME) |
---|
| 17298 | + //if (WIREFRAME) |
---|
17110 | 17299 | gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); |
---|
17111 | 17300 | |
---|
17112 | 17301 | gl.glDisable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17206 | 17395 | |
---|
17207 | 17396 | if (WIREFRAME) |
---|
17208 | 17397 | gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE); |
---|
| 17398 | + else |
---|
| 17399 | + gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); |
---|
17209 | 17400 | } |
---|
17210 | 17401 | |
---|
17211 | 17402 | private void DrawChecker(GL gl) |
---|
.. | .. |
---|
17969 | 18160 | |
---|
17970 | 18161 | gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
17971 | 18162 | |
---|
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); |
---|
17973 | 18171 | |
---|
17974 | 18172 | double r = 0, g = 0, b = 0; |
---|
17975 | 18173 | |
---|
.. | .. |
---|
17981 | 18179 | |
---|
17982 | 18180 | double FACTOR = 1; |
---|
17983 | 18181 | |
---|
| 18182 | + float minvalue = 1; |
---|
| 18183 | + float maxvalue = 0; |
---|
| 18184 | + |
---|
17984 | 18185 | for (int i = 0; i < depths.length; i++) |
---|
17985 | 18186 | { |
---|
17986 | 18187 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
18064 | 18265 | |
---|
18065 | 18266 | double scale = ray.z; // 1; // cos |
---|
18066 | 18267 | |
---|
| 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 | + |
---|
18067 | 18289 | float depth = depths[newindex]; |
---|
18068 | 18290 | |
---|
18069 | 18291 | /* |
---|
.. | .. |
---|
18100 | 18322 | double z_eye = tempmat2[3*4 + 2] / (depth * -2.0 + 1.0 - tempmat2[2*4 + 2]); |
---|
18101 | 18323 | |
---|
18102 | 18324 | double factor = 1 - Math.exp(-z_eye * z_eye / FACTOR); |
---|
| 18325 | + |
---|
| 18326 | + factor *= value; |
---|
18103 | 18327 | |
---|
18104 | 18328 | r += factor * scale; |
---|
18105 | 18329 | g += factor * scale; |
---|
.. | .. |
---|
18143 | 18367 | |
---|
18144 | 18368 | stackdepth--; |
---|
18145 | 18369 | |
---|
| 18370 | +// System.err.println("minvalue = " + minvalue); |
---|
| 18371 | +// System.err.println("maxvalue = " + maxvalue); |
---|
18146 | 18372 | //System.err.println("depth = " + stackdepth); |
---|
18147 | 18373 | // DEBUG |
---|
18148 | 18374 | /* |
---|
.. | .. |
---|
18210 | 18436 | |
---|
18211 | 18437 | private boolean keepshadow; |
---|
18212 | 18438 | |
---|
18213 | | - public boolean capsLocked = false; // VR |
---|
| 18439 | + static public boolean capsLocked = false; // VR |
---|
18214 | 18440 | |
---|
18215 | 18441 | static public int indexcount = 0; |
---|
18216 | 18442 | /*static*/ cColor vertexOcclusion = new cColor(); |
---|