.. | .. |
---|
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.*; |
---|
.. | .. |
---|
110 | 111 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 112 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 113 | static GLContext glcontext = null; |
---|
113 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 116 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 117 | + boolean transformMode; |
---|
| 118 | + |
---|
114 | 119 | boolean reverseUP = false; |
---|
115 | 120 | static boolean frozen = false; |
---|
116 | 121 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
130 | 135 | static boolean ZOOMBOXMODE = false; |
---|
131 | 136 | static boolean BOXMODE = false; |
---|
132 | 137 | static boolean IMAGEFLIP = false; |
---|
133 | | -static boolean SMOOTHFOCUS = false; |
---|
| 138 | +static boolean SMOOTHFOCUS = true; // false; |
---|
134 | 139 | static boolean SPEAKERMOCAP = true; // jan 2014 false; |
---|
135 | 140 | static boolean SPEAKERCAMERA = false; |
---|
136 | 141 | static boolean SPEAKERFOCUS = false; |
---|
.. | .. |
---|
164 | 169 | |
---|
165 | 170 | |
---|
166 | 171 | // OPTIONS |
---|
167 | | - boolean Skinshader = true; |
---|
| 172 | + boolean Skinshader = false; // true; |
---|
168 | 173 | boolean cameraLight = false; |
---|
169 | 174 | boolean UVdebug = false; |
---|
170 | 175 | boolean Udebug = false; |
---|
171 | 176 | boolean Vdebug = false; |
---|
172 | 177 | boolean NORMALdebug = false; |
---|
173 | | - static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
| 178 | + static boolean doublesided = true; // false; // reversed normals are awful for conformance |
---|
174 | 179 | boolean anisotropy = true; |
---|
175 | 180 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 181 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 182 | |
---|
178 | 183 | boolean macromode = false; |
---|
179 | 184 | |
---|
.. | .. |
---|
187 | 192 | } |
---|
188 | 193 | |
---|
189 | 194 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 195 | + |
---|
| 196 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 197 | + { |
---|
| 198 | + try |
---|
| 199 | + { |
---|
| 200 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 201 | + } catch (IOException e) |
---|
| 202 | + { |
---|
| 203 | + System.out.println("NAME = " + name); |
---|
| 204 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 205 | + return null; |
---|
| 206 | + } |
---|
| 207 | + } |
---|
190 | 208 | |
---|
191 | 209 | void SetAsGLRenderer(boolean b) |
---|
192 | 210 | { |
---|
.. | .. |
---|
204 | 222 | cameras = new Camera[2]; |
---|
205 | 223 | targetLookAts = new cVector[2]; |
---|
206 | 224 | |
---|
207 | | - SetCamera(cam); |
---|
| 225 | + SetCamera(cam, true); |
---|
208 | 226 | |
---|
209 | 227 | // Warning: not used. |
---|
210 | | - SetLight(new Camera(new cVector(15, 10, -20))); |
---|
| 228 | + //SetLight(new Camera(new cVector(15, 10, -20))); |
---|
211 | 229 | |
---|
212 | 230 | object = o; |
---|
213 | 231 | |
---|
.. | .. |
---|
525 | 543 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
526 | 544 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
527 | 545 | LA.vecNormalize(obj.v2); |
---|
528 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 546 | + |
---|
| 547 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
529 | 548 | } |
---|
530 | 549 | |
---|
531 | 550 | // P |
---|
.. | .. |
---|
547 | 566 | y += ny * obj.NORMALPUSH; |
---|
548 | 567 | z += nz * obj.NORMALPUSH; |
---|
549 | 568 | |
---|
550 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 569 | + SetGLNormal(gl, nx, ny, nz); |
---|
551 | 570 | } |
---|
552 | 571 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
553 | 572 | SetColor(obj, pv); |
---|
.. | .. |
---|
579 | 598 | y += ny * obj.NORMALPUSH; |
---|
580 | 599 | z += nz * obj.NORMALPUSH; |
---|
581 | 600 | |
---|
582 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 601 | + SetGLNormal(gl, nx, ny, nz); |
---|
583 | 602 | } |
---|
584 | 603 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
585 | 604 | // boolean locked = false; |
---|
.. | .. |
---|
627 | 646 | y += ny * obj.NORMALPUSH; |
---|
628 | 647 | z += nz * obj.NORMALPUSH; |
---|
629 | 648 | |
---|
630 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 649 | + SetGLNormal(gl, nx, ny, nz); |
---|
631 | 650 | } |
---|
632 | 651 | |
---|
633 | 652 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
863 | 882 | //// tris.postdraw(this); |
---|
864 | 883 | } |
---|
865 | 884 | |
---|
866 | | - static Camera localcamera = new Camera(); |
---|
| 885 | + static Camera localAOcamera = new Camera(); |
---|
867 | 886 | static cVector from = new cVector(); |
---|
868 | 887 | static cVector to = new cVector(); |
---|
869 | 888 | |
---|
.. | .. |
---|
872 | 891 | CameraPane cp = this; |
---|
873 | 892 | |
---|
874 | 893 | Camera keep = cp.RenderCamera(); |
---|
875 | | - cp.renderCamera = localcamera; |
---|
| 894 | + cp.renderCamera = localAOcamera; |
---|
876 | 895 | |
---|
877 | 896 | if (br.trimmed) |
---|
878 | 897 | { |
---|
.. | .. |
---|
890 | 909 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
891 | 910 | LA.xformPos(from, transform, from); |
---|
892 | 911 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
893 | | - localcamera.setAim(from, to); |
---|
| 912 | + localAOcamera.setAim(from, to); |
---|
894 | 913 | |
---|
895 | 914 | CameraPane.occlusionbuffer.display(); |
---|
896 | 915 | |
---|
.. | .. |
---|
924 | 943 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
925 | 944 | LA.xformPos(from, transform, from); |
---|
926 | 945 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
927 | | - localcamera.setAim(from, to); |
---|
| 946 | + localAOcamera.setAim(from, to); |
---|
928 | 947 | |
---|
929 | 948 | CameraPane.occlusionbuffer.display(); |
---|
930 | 949 | |
---|
.. | .. |
---|
1233 | 1252 | { |
---|
1234 | 1253 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1235 | 1254 | { |
---|
1236 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1255 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1237 | 1256 | } else |
---|
1238 | 1257 | { |
---|
1239 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1258 | + SetGLNormal(gl, 0, 0, 1); |
---|
1240 | 1259 | } |
---|
1241 | 1260 | |
---|
1242 | 1261 | if (c != null) |
---|
.. | .. |
---|
1260 | 1279 | { |
---|
1261 | 1280 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1262 | 1281 | { |
---|
1263 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1282 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1264 | 1283 | } else |
---|
1265 | 1284 | { |
---|
1266 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1285 | + SetGLNormal(gl, 0, 0, 1); |
---|
1267 | 1286 | } |
---|
1268 | 1287 | if (c != null) |
---|
1269 | 1288 | { |
---|
.. | .. |
---|
1288 | 1307 | { |
---|
1289 | 1308 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1290 | 1309 | { |
---|
1291 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1310 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1292 | 1311 | } else |
---|
1293 | 1312 | { |
---|
1294 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1313 | + SetGLNormal(gl, 0, 0, 1); |
---|
1295 | 1314 | } |
---|
1296 | 1315 | if (c != null) |
---|
1297 | 1316 | { |
---|
.. | .. |
---|
1473 | 1492 | { |
---|
1474 | 1493 | if (!selectmode) |
---|
1475 | 1494 | { |
---|
1476 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1495 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1477 | 1496 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1478 | 1497 | |
---|
1479 | 1498 | if (flipV) |
---|
.. | .. |
---|
1485 | 1504 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1486 | 1505 | } |
---|
1487 | 1506 | |
---|
| 1507 | + float[] colorV = new float[4]; |
---|
| 1508 | + |
---|
1488 | 1509 | void SetColor(Object3D obj, Vertex p0) |
---|
1489 | 1510 | { |
---|
1490 | 1511 | CameraPane display = this; |
---|
.. | .. |
---|
1552 | 1573 | { |
---|
1553 | 1574 | return; |
---|
1554 | 1575 | } |
---|
1555 | | - |
---|
1556 | | - float[] colorV = new float[3]; |
---|
1557 | 1576 | |
---|
1558 | 1577 | if (false) // marked) |
---|
1559 | 1578 | { |
---|
.. | .. |
---|
1802 | 1821 | |
---|
1803 | 1822 | display.modelParams7[0] = 0; |
---|
1804 | 1823 | display.modelParams7[1] = 1000; |
---|
1805 | | - display.modelParams7[2] = 0; |
---|
| 1824 | + display.modelParams7[2] = material.parallax; |
---|
1806 | 1825 | display.modelParams7[3] = 0; |
---|
1807 | 1826 | |
---|
1808 | 1827 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2035 | 2054 | switch(viewcode) |
---|
2036 | 2055 | { |
---|
2037 | 2056 | case 0: return "main"; |
---|
2038 | | - case 1: return "one"; |
---|
2039 | | - case 2: return "two"; |
---|
2040 | | - case 3: return "three"; |
---|
| 2057 | + case 1: return "Red"; |
---|
| 2058 | + case 2: return "Green"; |
---|
| 2059 | + case 3: return "Blue"; |
---|
2041 | 2060 | case 4: return "light"; |
---|
2042 | 2061 | } |
---|
2043 | 2062 | |
---|
.. | .. |
---|
2046 | 2065 | |
---|
2047 | 2066 | static int camerachangeframe; |
---|
2048 | 2067 | |
---|
2049 | | - public boolean SetCamera(Camera cam) |
---|
| 2068 | + public boolean SetCamera(Camera cam, boolean set) |
---|
2050 | 2069 | { |
---|
2051 | 2070 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
2052 | 2071 | // return false; |
---|
.. | .. |
---|
2064 | 2083 | |
---|
2065 | 2084 | camerachangeframe = Globals.framecount; |
---|
2066 | 2085 | |
---|
2067 | | - cam.hAspect = -1; // Read only |
---|
| 2086 | + if (cam != null) |
---|
| 2087 | + cam.hAspect = -1; // Read only |
---|
2068 | 2088 | |
---|
2069 | 2089 | cameras[0] = cam; |
---|
2070 | 2090 | targetLookAts[0] = new cVector(cam.lookAt); |
---|
.. | .. |
---|
2074 | 2094 | { |
---|
2075 | 2095 | cameras[i] = new Camera(cam.viewCode); |
---|
2076 | 2096 | } |
---|
2077 | | - |
---|
2078 | | - cameras[i].setAim(cam.location, cam.lookAt); |
---|
2079 | | - cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
2080 | | - cameras[i].UP.set(cam.UP); |
---|
2081 | | - targetLookAts[i] = new cVector(cameras[i].lookAt); |
---|
| 2097 | + |
---|
| 2098 | + if (set) |
---|
| 2099 | + { |
---|
| 2100 | + cameras[i].setAim(cam.location, cam.lookAt); |
---|
| 2101 | + cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
| 2102 | + cameras[i].UP.set(cam.UP); |
---|
| 2103 | + targetLookAts[i] = new cVector(cameras[i].lookAt); |
---|
| 2104 | + } |
---|
2082 | 2105 | } |
---|
2083 | 2106 | cameracount = 0; |
---|
2084 | 2107 | targetLookAt = targetLookAts[cameracount]; |
---|
.. | .. |
---|
2087 | 2110 | // Start with free camera |
---|
2088 | 2111 | SwitchCameras(true); |
---|
2089 | 2112 | |
---|
2090 | | - pingthread.jump = true; // optional? |
---|
| 2113 | +// pingthread.jump = true; // optional? |
---|
2091 | 2114 | |
---|
2092 | 2115 | if (TRACKONCE) |
---|
2093 | 2116 | { |
---|
.. | .. |
---|
2274 | 2297 | public void ToggleTrack() |
---|
2275 | 2298 | { |
---|
2276 | 2299 | TRACK ^= true; |
---|
2277 | | - if (TRACK) |
---|
2278 | | - { |
---|
2279 | | - if (object.selection != null && |
---|
2280 | | - object.selection.size() > 0 && |
---|
2281 | | - object.selection.elementAt(0) != null && |
---|
2282 | | - !(object.selection.elementAt(0) instanceof Camera) && |
---|
2283 | | - !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
2284 | | - { |
---|
2285 | | - trackedobject = object.selection.elementAt(0); |
---|
2286 | | - repaint(); |
---|
2287 | | - } |
---|
2288 | | - } |
---|
2289 | 2300 | |
---|
2290 | 2301 | repaint(); |
---|
2291 | 2302 | } |
---|
.. | .. |
---|
2377 | 2388 | { |
---|
2378 | 2389 | //System.out.println("PROTECTION = " + cam.hAspect); |
---|
2379 | 2390 | //assert (cam.hAspect == 0); |
---|
2380 | | - cam.hAspect = 0; |
---|
| 2391 | + if (cam != null) |
---|
| 2392 | + cam.hAspect = 0; |
---|
2381 | 2393 | lightCamera = cam; |
---|
2382 | 2394 | } |
---|
2383 | 2395 | |
---|
.. | .. |
---|
2458 | 2470 | return CreateBim(bytes, width, height); |
---|
2459 | 2471 | } |
---|
2460 | 2472 | |
---|
| 2473 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2474 | + { |
---|
| 2475 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2476 | + |
---|
| 2477 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2478 | + // Ground or ceiling |
---|
| 2479 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2480 | + else |
---|
| 2481 | + // Walls |
---|
| 2482 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2483 | + } |
---|
| 2484 | + |
---|
2461 | 2485 | /**/ |
---|
2462 | 2486 | class CacheTexture |
---|
2463 | 2487 | { |
---|
.. | .. |
---|
2500 | 2524 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2501 | 2525 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2502 | 2526 | true, |
---|
2503 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2527 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2504 | 2528 | } catch (java.io.IOException e) |
---|
2505 | 2529 | { |
---|
2506 | 2530 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
3566 | 3590 | }; |
---|
3567 | 3591 | /**/ |
---|
3568 | 3592 | |
---|
| 3593 | + static Object3D lastObject; |
---|
| 3594 | + |
---|
3569 | 3595 | //com.sun.opengl.util.texture.Texture |
---|
3570 | 3596 | TextureData |
---|
3571 | 3597 | GetFileTexture(String name, boolean bump, int resolution) |
---|
.. | .. |
---|
3602 | 3628 | // return null; |
---|
3603 | 3629 | //if (i == 2) |
---|
3604 | 3630 | // return null; |
---|
| 3631 | + // TIFF issue sept 2019 |
---|
| 3632 | + System.err.println("lastObject = " + lastObject); |
---|
3605 | 3633 | e.printStackTrace(); |
---|
3606 | 3634 | name = name.split("\\.tif")[0] + ".jpg"; |
---|
3607 | 3635 | } |
---|
.. | .. |
---|
6934 | 6962 | short residu = 0; |
---|
6935 | 6963 | |
---|
6936 | 6964 | // wraparound workarounds |
---|
6937 | | - short fuck = (short) (buffer[i] & 0xFF); |
---|
| 6965 | + short ww = (short) (buffer[i] & 0xFF); |
---|
6938 | 6966 | /* |
---|
6939 | | - residu += (fuck%2); |
---|
6940 | | - if(fuck/2 < 256-residu/2) |
---|
| 6967 | + residu += (ww%2); |
---|
| 6968 | + if(ww/2 < 256-residu/2) |
---|
6941 | 6969 | { |
---|
6942 | | - fuck = (short)((fuck/2) + residu/2); |
---|
| 6970 | + ww = (short)((ww/2) + residu/2); |
---|
6943 | 6971 | if(residu == 2) |
---|
6944 | 6972 | residu = 0; |
---|
6945 | 6973 | } |
---|
6946 | 6974 | else |
---|
6947 | 6975 | { |
---|
6948 | 6976 | residu = 0; |
---|
6949 | | - fuck /= 2; |
---|
| 6977 | + ww /= 2; |
---|
6950 | 6978 | } |
---|
6951 | 6979 | */ |
---|
6952 | | - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) |
---|
| 6980 | + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) |
---|
6953 | 6981 | { |
---|
6954 | | - fuck /= 2; |
---|
| 6982 | + ww /= 2; |
---|
6955 | 6983 | } else |
---|
6956 | 6984 | { |
---|
6957 | | - fuck = (short) ((fuck / 2) + fuck % 2); |
---|
| 6985 | + ww = (short) ((ww / 2) + ww % 2); |
---|
6958 | 6986 | } |
---|
6959 | 6987 | |
---|
6960 | | - buffer[i] = (byte) fuck; |
---|
| 6988 | + buffer[i] = (byte) ww; |
---|
6961 | 6989 | } |
---|
6962 | 6990 | //System.out.print(bytes[i] + " "); |
---|
6963 | 6991 | //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; |
---|
.. | .. |
---|
8346 | 8374 | // else |
---|
8347 | 8375 | // if (!texname.startsWith("/")) |
---|
8348 | 8376 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8349 | | - if (!FileExists(texname)) |
---|
| 8377 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8350 | 8378 | { |
---|
8351 | 8379 | texname = fallbackTextureName; |
---|
8352 | 8380 | } |
---|
.. | .. |
---|
8424 | 8452 | { |
---|
8425 | 8453 | // texturecache = textures.get(texname); // suspicious |
---|
8426 | 8454 | if (texturecache == null) |
---|
8427 | | - texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8455 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.jpg", bump),resolution); |
---|
| 8456 | + else |
---|
| 8457 | + new Exception().printStackTrace(); |
---|
| 8458 | + } else |
---|
| 8459 | + { |
---|
| 8460 | + if (texname.startsWith("@") && textureon) |
---|
| 8461 | + { |
---|
| 8462 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8463 | + if (texturecache == null) |
---|
| 8464 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
8428 | 8465 | else |
---|
8429 | 8466 | new Exception().printStackTrace(); |
---|
8430 | 8467 | } else |
---|
.. | .. |
---|
8488 | 8525 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8489 | 8526 | //texture = GetTexture(tex, bump); |
---|
8490 | 8527 | } |
---|
| 8528 | + } |
---|
8491 | 8529 | } |
---|
8492 | 8530 | //} |
---|
8493 | 8531 | } |
---|
.. | .. |
---|
8602 | 8640 | { |
---|
8603 | 8641 | tex.bw = texturecache.texturedata.getWidth(); |
---|
8604 | 8642 | tex.bh = texturecache.texturedata.getHeight(); |
---|
8605 | | - tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8643 | + tex.bumpdata = //CompressJPEG(CreateBim( |
---|
| 8644 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8645 | + //, tex.bw, tex.bh), 0.5f); |
---|
8606 | 8646 | } |
---|
8607 | 8647 | } |
---|
8608 | 8648 | } |
---|
.. | .. |
---|
8756 | 8796 | |
---|
8757 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8758 | 8798 | MAXSTACK = temp[0]; |
---|
8759 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8760 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8761 | 8802 | MAXSTACK = temp[0]; |
---|
8762 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8763 | 8805 | |
---|
8764 | 8806 | // Use debug pipeline |
---|
8765 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8767 | 8809 | gl = drawable.getGL(); // |
---|
8768 | 8810 | |
---|
8769 | 8811 | GL gl3 = getGL(); |
---|
8770 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8771 | 8814 | |
---|
8772 | 8815 | |
---|
8773 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8932 | 8975 | |
---|
8933 | 8976 | if (cubemap == null) |
---|
8934 | 8977 | { |
---|
8935 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8936 | 8979 | } |
---|
8937 | 8980 | |
---|
8938 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9208 | 9251 | |
---|
9209 | 9252 | void LoadEnvy(int which) |
---|
9210 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9211 | 9256 | String name; |
---|
9212 | 9257 | String ext; |
---|
9213 | 9258 | |
---|
.. | .. |
---|
9219 | 9264 | cubemap = null; |
---|
9220 | 9265 | return; |
---|
9221 | 9266 | case 1: |
---|
9222 | | - name = "cubemaps/box_"; |
---|
9223 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9224 | 9269 | reverseUP = false; |
---|
9225 | 9270 | break; |
---|
9226 | 9271 | case 2: |
---|
9227 | | - name = "cubemaps/uffizi_"; |
---|
9228 | | - ext = "png"; |
---|
9229 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9230 | 9276 | case 3: |
---|
9231 | | - name = "cubemaps/CloudyHills_"; |
---|
9232 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9233 | 9279 | reverseUP = false; |
---|
9234 | 9280 | break; |
---|
9235 | 9281 | case 4: |
---|
9236 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9237 | 9283 | ext = "png"; |
---|
9238 | 9284 | reverseUP = false; |
---|
9239 | 9285 | break; |
---|
| 9286 | + case 5: |
---|
| 9287 | + name = "cubemaps/skycube/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 6: |
---|
| 9292 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
| 9296 | + case 7: |
---|
| 9297 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9298 | + ext = "jpg"; |
---|
| 9299 | + reverseUP = false; |
---|
| 9300 | + break; |
---|
| 9301 | + case 8: |
---|
| 9302 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9303 | + ext = "jpg"; |
---|
| 9304 | + reverseUP = false; |
---|
| 9305 | + break; |
---|
| 9306 | + case 9: |
---|
| 9307 | + name = "cubemaps/UnionSquare/"; |
---|
| 9308 | + ext = "jpg"; |
---|
| 9309 | + reverseUP = false; |
---|
| 9310 | + break; |
---|
9240 | 9311 | default: |
---|
9241 | | - name = "cubemaps/rgb_"; |
---|
9242 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9243 | 9315 | break; |
---|
9244 | 9316 | } |
---|
9245 | | - |
---|
9246 | | - try |
---|
9247 | | - { |
---|
9248 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9249 | | - } catch (IOException e) |
---|
9250 | | - { |
---|
9251 | | - throw new RuntimeException(e); |
---|
9252 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9253 | 9319 | } |
---|
9254 | 9320 | |
---|
9255 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9281 | 9347 | static double[] model = new double[16]; |
---|
9282 | 9348 | double[] camera2light = new double[16]; |
---|
9283 | 9349 | double[] light2camera = new double[16]; |
---|
9284 | | - int newenvy = -1; |
---|
9285 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9286 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9287 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9288 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9762 | 9832 | rati = 1 / rati; |
---|
9763 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9764 | 9834 | } |
---|
9765 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9766 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9767 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9768 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9769 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9770 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9771 | | - accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
| 9843 | + |
---|
| 9844 | + boolean vr = capsLocked && !lightMode; |
---|
| 9845 | + |
---|
| 9846 | + accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
9772 | 9847 | ratio, |
---|
9773 | 9848 | //near_plane, far_plane, |
---|
9774 | 9849 | renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(), |
---|
.. | .. |
---|
10631 | 10706 | static boolean init = false; |
---|
10632 | 10707 | |
---|
10633 | 10708 | double[][] matrix = LA.newMatrix(); |
---|
| 10709 | + |
---|
| 10710 | + // This is to refresh the UI of the material panel. |
---|
| 10711 | + ObjEditor patchMaterial; |
---|
10634 | 10712 | |
---|
10635 | 10713 | public void display(GLAutoDrawable drawable) |
---|
10636 | 10714 | { |
---|
| 10715 | + if (patchMaterial.patchMaterial) |
---|
| 10716 | + { |
---|
| 10717 | + patchMaterial.patchMaterial = false; |
---|
| 10718 | + patchMaterial.objectTabbedPane.setSelectedIndex(1); |
---|
| 10719 | + } |
---|
| 10720 | + |
---|
10637 | 10721 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10638 | 10722 | { |
---|
10639 | 10723 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10729 | 10813 | |
---|
10730 | 10814 | if (DrawMode() == DEFAULT) |
---|
10731 | 10815 | { |
---|
| 10816 | + if (manipCamera == lightCamera) |
---|
| 10817 | + { |
---|
| 10818 | +// switch (e.getKeyCode()) |
---|
| 10819 | +// { |
---|
| 10820 | +// case DOWN_ARROW: |
---|
| 10821 | +// lightCamera.DECAL /= 2; |
---|
| 10822 | +// repaint(); |
---|
| 10823 | +// break; |
---|
| 10824 | +// case UP_ARROW: |
---|
| 10825 | +// lightCamera.DECAL *= 2; |
---|
| 10826 | +// repaint(); |
---|
| 10827 | +// break; |
---|
| 10828 | +// case LEFT_ARROW: |
---|
| 10829 | +// lightCamera.SCALE /= 2; |
---|
| 10830 | +// repaint(); |
---|
| 10831 | +// break; |
---|
| 10832 | +// case RIGHT_ARROW: |
---|
| 10833 | +// lightCamera.SCALE *= 2; |
---|
| 10834 | +// repaint(); |
---|
| 10835 | +// break; |
---|
| 10836 | +// default: |
---|
| 10837 | +// break; |
---|
| 10838 | + if (keys[DOWN_ARROW]) |
---|
| 10839 | + { |
---|
| 10840 | + lightCamera.DECAL /= 2; |
---|
| 10841 | + } |
---|
| 10842 | + |
---|
| 10843 | + if (keys[UP_ARROW]) |
---|
| 10844 | + { |
---|
| 10845 | + lightCamera.DECAL *= 2; |
---|
| 10846 | + } |
---|
| 10847 | + |
---|
| 10848 | + if (keys[LEFT_ARROW]) |
---|
| 10849 | + { |
---|
| 10850 | + lightCamera.SCALE /= 2; |
---|
| 10851 | + } |
---|
| 10852 | + |
---|
| 10853 | + if (keys[RIGHT_ARROW]) |
---|
| 10854 | + { |
---|
| 10855 | + lightCamera.SCALE *= 2; |
---|
| 10856 | + } |
---|
| 10857 | + } |
---|
| 10858 | + else |
---|
| 10859 | + { |
---|
| 10860 | + //pingthread.mute = true; |
---|
| 10861 | + |
---|
| 10862 | + boolean keyon = false; |
---|
| 10863 | + |
---|
| 10864 | + if (keys[DOWN_ARROW]) |
---|
| 10865 | + { |
---|
| 10866 | + speed = ++speedkey[DOWN_ARROW]; |
---|
| 10867 | + if (speed > 20) |
---|
| 10868 | + speed = 20; |
---|
| 10869 | + GoDown(modifiers); |
---|
| 10870 | + keyon = true; |
---|
| 10871 | + } |
---|
| 10872 | + else |
---|
| 10873 | + speedkey[DOWN_ARROW] = 0; |
---|
| 10874 | + |
---|
| 10875 | + if (keys[UP_ARROW]) |
---|
| 10876 | + { |
---|
| 10877 | + speed = ++speedkey[UP_ARROW]; |
---|
| 10878 | + if (speed > 20) |
---|
| 10879 | + speed = 20; |
---|
| 10880 | + GoUp(modifiers); |
---|
| 10881 | + keyon = true; |
---|
| 10882 | + } |
---|
| 10883 | + else |
---|
| 10884 | + speedkey[UP_ARROW] = 0; |
---|
| 10885 | + |
---|
| 10886 | + if (keys[LEFT_ARROW]) |
---|
| 10887 | + { |
---|
| 10888 | + speed = ++speedkey[LEFT_ARROW]; |
---|
| 10889 | + if (speed > 20) |
---|
| 10890 | + speed = 20; |
---|
| 10891 | + GoLeft(modifiers); |
---|
| 10892 | + keyon = true; |
---|
| 10893 | + } |
---|
| 10894 | + else |
---|
| 10895 | + speedkey[LEFT_ARROW] = 0; |
---|
| 10896 | + |
---|
| 10897 | + if (keys[RIGHT_ARROW]) |
---|
| 10898 | + { |
---|
| 10899 | + speed = ++speedkey[RIGHT_ARROW]; |
---|
| 10900 | + if (speed > 20) |
---|
| 10901 | + speed = 20; |
---|
| 10902 | + GoRight(modifiers); |
---|
| 10903 | + keyon = true; |
---|
| 10904 | + } |
---|
| 10905 | + else |
---|
| 10906 | + speedkey[RIGHT_ARROW] = 0; |
---|
| 10907 | + |
---|
| 10908 | + if (Globals.WALK && capsLocked) |
---|
| 10909 | + { |
---|
| 10910 | + Walk(); |
---|
| 10911 | + keyon = true; |
---|
| 10912 | + } |
---|
| 10913 | + |
---|
| 10914 | + if (keyon) |
---|
| 10915 | + { |
---|
| 10916 | + repaint(); |
---|
| 10917 | + } |
---|
| 10918 | + |
---|
| 10919 | + //pingthread.mute = false; |
---|
| 10920 | + } |
---|
| 10921 | + |
---|
10732 | 10922 | currentlydrawing = true; |
---|
10733 | 10923 | } |
---|
10734 | 10924 | |
---|
.. | .. |
---|
10802 | 10992 | |
---|
10803 | 10993 | if (wait) |
---|
10804 | 10994 | { |
---|
10805 | | - Sleep(500); |
---|
| 10995 | + Sleep(200); // blocks everything |
---|
10806 | 10996 | |
---|
10807 | 10997 | wait = false; |
---|
10808 | 10998 | } |
---|
.. | .. |
---|
11018 | 11208 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11019 | 11209 | } |
---|
11020 | 11210 | |
---|
11021 | | - if (newenvy > -1) |
---|
| 11211 | +// if (newenvy > -1) |
---|
| 11212 | +// { |
---|
| 11213 | +// LoadEnvy(newenvy); |
---|
| 11214 | +// } |
---|
| 11215 | +// |
---|
| 11216 | +// newenvy = -1; |
---|
| 11217 | + |
---|
| 11218 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11022 | 11219 | { |
---|
11023 | | - LoadEnvy(newenvy); |
---|
| 11220 | + if (cubemaprgb == null) |
---|
| 11221 | + { |
---|
| 11222 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11223 | + } |
---|
| 11224 | + |
---|
| 11225 | + cubemap = cubemaprgb; |
---|
11024 | 11226 | } |
---|
11025 | | - |
---|
11026 | | - newenvy = -1; |
---|
11027 | | - |
---|
| 11227 | + else |
---|
| 11228 | + { |
---|
| 11229 | + if (object.skyboxname != null) |
---|
| 11230 | + { |
---|
| 11231 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11232 | + { |
---|
| 11233 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11234 | + cubemap.dispose(); |
---|
| 11235 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11236 | + loadedskyboxname = object.skyboxname; |
---|
| 11237 | + } |
---|
| 11238 | + } |
---|
| 11239 | + else |
---|
| 11240 | + { |
---|
| 11241 | + cubemapcustom = null; |
---|
| 11242 | + loadedskyboxname = null; |
---|
| 11243 | + } |
---|
| 11244 | + |
---|
| 11245 | + cubemap = cubemapcustom; |
---|
| 11246 | + } |
---|
| 11247 | + |
---|
11028 | 11248 | ratio = ((double) getWidth()) / getHeight(); |
---|
11029 | 11249 | //System.out.println("ratio = " + ratio); |
---|
11030 | 11250 | |
---|
.. | .. |
---|
11040 | 11260 | |
---|
11041 | 11261 | if (!IsFrozen() && !ambientOcclusion) |
---|
11042 | 11262 | { |
---|
11043 | | - DrawSkyBox(gl); |
---|
| 11263 | + DrawSkyBox(gl, (float)ratio); |
---|
11044 | 11264 | } |
---|
11045 | 11265 | |
---|
11046 | 11266 | //if (selection_view == -1) |
---|
.. | .. |
---|
11223 | 11443 | |
---|
11224 | 11444 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11225 | 11445 | |
---|
11226 | | -gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
11227 | | -gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11228 | | -gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11446 | +//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11447 | +//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11448 | +//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
11229 | 11449 | } else |
---|
11230 | 11450 | { |
---|
11231 | 11451 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11286 | 11506 | //gl.glOrtho(-BOOST, BOOST, -BOOST, BOOST, 0.001, 1000); |
---|
11287 | 11507 | } else |
---|
11288 | 11508 | { |
---|
11289 | | - glu.gluPerspective(cam.shaper_fovy / ratio, ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
| 11509 | + boolean vr = capsLocked && !lightMode; |
---|
| 11510 | + |
---|
| 11511 | + glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
| 11512 | + ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
11290 | 11513 | } |
---|
11291 | 11514 | } |
---|
11292 | 11515 | |
---|
.. | .. |
---|
11326 | 11549 | |
---|
11327 | 11550 | // if (cam != lightCamera) |
---|
11328 | 11551 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11329 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11552 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11330 | 11553 | } |
---|
11331 | 11554 | |
---|
11332 | 11555 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11642 | 11865 | repaint(); |
---|
11643 | 11866 | } |
---|
11644 | 11867 | |
---|
11645 | | - if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
| 11868 | + if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 |
---|
| 11869 | + { |
---|
| 11870 | + renderCamera.computeTransform(); |
---|
11646 | 11871 | repaint(); |
---|
| 11872 | + } |
---|
11647 | 11873 | |
---|
11648 | 11874 | displaydone = true; |
---|
11649 | 11875 | } |
---|
.. | .. |
---|
11718 | 11944 | //GL gl = getGL(); |
---|
11719 | 11945 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11720 | 11946 | { |
---|
| 11947 | + if (TRACK) |
---|
| 11948 | + { |
---|
| 11949 | + if (object.selection != null && |
---|
| 11950 | + object.selection.size() > 0 && |
---|
| 11951 | + object.selection.elementAt(0) != null && |
---|
| 11952 | + !(object.selection.elementAt(0) instanceof Camera) && |
---|
| 11953 | + !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
| 11954 | + { |
---|
| 11955 | + trackedobject = object.selection.elementAt(0); |
---|
| 11956 | + //repaint(); |
---|
| 11957 | + } |
---|
| 11958 | + else |
---|
| 11959 | + trackedobject = null; |
---|
| 11960 | + } |
---|
11721 | 11961 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11722 | 11962 | object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11723 | | - pingthread.StepToTarget(true); // true); |
---|
| 11963 | + pingthread.StepToTarget(); // true); |
---|
11724 | 11964 | // zoomonce = false; |
---|
11725 | 11965 | } |
---|
11726 | 11966 | |
---|
.. | .. |
---|
12400 | 12640 | |
---|
12401 | 12641 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12402 | 12642 | |
---|
12403 | | - String program = |
---|
| 12643 | + String programmin = |
---|
12404 | 12644 | // Min shader |
---|
12405 | 12645 | "!!ARBfp1.0\n" + |
---|
12406 | | - "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12407 | | - "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12646 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12647 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12648 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
12408 | 12649 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12409 | 12650 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12410 | 12651 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
.. | .. |
---|
12419 | 12660 | "TEMP eye;" + |
---|
12420 | 12661 | "TEMP pos;" + |
---|
12421 | 12662 | |
---|
12422 | | - "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12663 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
12423 | 12664 | Normalize("normal") + |
---|
12424 | 12665 | "MOV light, state.light[0].position;" + |
---|
12425 | 12666 | "DP3 ndotl.x, light, normal;" + |
---|
| 12667 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
12426 | 12668 | |
---|
12427 | 12669 | // shadow |
---|
12428 | 12670 | "MOV pos, fragment.texcoord[1];" + |
---|
.. | .. |
---|
12438 | 12680 | "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12439 | 12681 | |
---|
12440 | 12682 | // Backlit |
---|
12441 | | - "MOV pos.w, zero123.y;" + |
---|
| 12683 | + "MOV pos.w, zero12t.y;" + // one |
---|
12442 | 12684 | "DP4 eye.x, pos, light2cam0;" + |
---|
12443 | 12685 | "DP4 eye.y, pos, light2cam1;" + |
---|
12444 | 12686 | "DP4 eye.z, pos, light2cam2;" + |
---|
.. | .. |
---|
12446 | 12688 | |
---|
12447 | 12689 | "DP3 ndotl.y, -eye, normal;" + |
---|
12448 | 12690 | //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
12449 | | - "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
12450 | | - "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12691 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12692 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12693 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
12451 | 12694 | //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
12452 | 12695 | //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12696 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12697 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
12453 | 12698 | |
---|
12454 | | - "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12699 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12700 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
12455 | 12701 | |
---|
12456 | 12702 | // Pigment |
---|
12457 | 12703 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12458 | | - "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12459 | | - "MUL temp, temp, ndotl.x;" + |
---|
12460 | | - |
---|
12461 | | - "MUL temp, temp, zero123.z;" + |
---|
| 12704 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12705 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
12462 | 12706 | |
---|
12463 | 12707 | //"MUL temp, temp, ndotl.y;" + |
---|
| 12708 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
12464 | 12709 | |
---|
12465 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12710 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12711 | + |
---|
| 12712 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
12466 | 12713 | "MOV result.color, temp;" + |
---|
12467 | 12714 | "END"; |
---|
12468 | 12715 | |
---|
12469 | | - String program2 = |
---|
| 12716 | + String programmax = |
---|
12470 | 12717 | "!!ARBfp1.0\n" + |
---|
12471 | 12718 | |
---|
12472 | 12719 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12494 | 12741 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12495 | 12742 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12496 | 12743 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12497 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12744 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12498 | 12745 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12499 | 12746 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12500 | 12747 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12739 | 12986 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12740 | 12987 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12741 | 12988 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12742 | | - "KIL alpha.a;" + |
---|
| 12989 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12743 | 12990 | /* |
---|
12744 | 12991 | "MUL temp.xy, temp, two;" + |
---|
12745 | 12992 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12825 | 13072 | "SUB bump0, bump0, half;" + |
---|
12826 | 13073 | "ADD bump, bump, bump0;" + |
---|
12827 | 13074 | |
---|
12828 | | - "MOV temp.x, texSamp.a;" + |
---|
12829 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12830 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12831 | | - "MOV texSamp.a, temp.x;" + |
---|
12832 | | - |
---|
12833 | 13075 | // double-sided |
---|
12834 | 13076 | /**/ |
---|
12835 | 13077 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12839 | 13081 | "ADD temp.x, temp.x, one.x;" + |
---|
12840 | 13082 | "MUL normal, normal, temp.xxxx;":"" |
---|
12841 | 13083 | ) + |
---|
12842 | | - /**/ |
---|
12843 | | -//// Normalize("normal") + |
---|
12844 | | -//// "MAX normal.z, eps.x, normal.z;" + |
---|
12845 | | -// Normalize("normal") + |
---|
12846 | | - "MOV normald, normal;" + |
---|
12847 | | - "MOV normals, normal;" + |
---|
| 13084 | + /**/ |
---|
| 13085 | + |
---|
| 13086 | + "MOV temp, fragment.texcoord[4];" + |
---|
12848 | 13087 | |
---|
12849 | 13088 | // UV base |
---|
12850 | 13089 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12851 | 13090 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12852 | 13091 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12853 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12854 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12855 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 13092 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 13093 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 13094 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 13095 | + Normalize("UP") + |
---|
| 13096 | + |
---|
12856 | 13097 | "XPD V, normal, UP;" + |
---|
12857 | 13098 | Normalize("V") + |
---|
12858 | 13099 | "XPD U, V, normal;" + |
---|
12859 | 13100 | Normalize("U") + |
---|
12860 | 13101 | |
---|
| 13102 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 13103 | + |
---|
| 13104 | +// "MAD normal, -temp.x, U, normal;" + |
---|
| 13105 | +// "MAD normal, -temp.y, V, normal;" + |
---|
| 13106 | +// Normalize("normal") + |
---|
| 13107 | + |
---|
| 13108 | +//// "MAX normal.z, eps.x, normal.z;" + |
---|
| 13109 | +// Normalize("normal") + |
---|
| 13110 | + "MOV normald, normal;" + |
---|
| 13111 | + "MOV normals, normal;" + |
---|
| 13112 | + |
---|
12861 | 13113 | // parallax mapping |
---|
| 13114 | + |
---|
| 13115 | + "DP3 temp2.x, V, eye;" + |
---|
| 13116 | + "DP3 temp2.y, U, eye;" + |
---|
| 13117 | + "DP3 temp2.z, normal, eye;" + |
---|
| 13118 | + "RCP temp2.z, temp2.z;" + |
---|
| 13119 | + |
---|
| 13120 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 13121 | + "RSQ temp2.w, temp2.w;" + |
---|
| 13122 | + "RCP temp2.w, temp2.w;" + |
---|
| 13123 | + |
---|
| 13124 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 13125 | + // "SGE temp.x, temp2.w, eps.x;" + |
---|
| 13126 | + // "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 13127 | + |
---|
| 13128 | + // "MOV texSamp, U;" + |
---|
| 13129 | + |
---|
| 13130 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 13131 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 13132 | + |
---|
| 13133 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 13134 | + |
---|
| 13135 | + "SUB temp, temp, temp2;" + |
---|
| 13136 | + |
---|
| 13137 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13138 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13139 | + |
---|
| 13140 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13141 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13142 | + |
---|
| 13143 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13144 | + |
---|
| 13145 | +// parallax mapping |
---|
| 13146 | + |
---|
| 13147 | + "MOV temp.x, texSamp.a;" + |
---|
| 13148 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13149 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13150 | + "MOV texSamp.a, temp.x;" + |
---|
12862 | 13151 | |
---|
12863 | 13152 | //"MOV temp, fragment.texcoord[0];" + |
---|
12864 | 13153 | // |
---|
.. | .. |
---|
12991 | 13280 | // display shadow only (fakedepth == 0) |
---|
12992 | 13281 | "SUB temp.x, half.x, shadow.x;" + |
---|
12993 | 13282 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12994 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13283 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12995 | 13284 | "SUB temp.y, one.x, temp.z;" + |
---|
12996 | 13285 | "MUL temp.x, temp.x, temp.y;" + |
---|
12997 | 13286 | "KIL temp.x;" + |
---|
.. | .. |
---|
13322 | 13611 | //once = true; |
---|
13323 | 13612 | } |
---|
13324 | 13613 | |
---|
13325 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13326 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13614 | + String program = programmax; |
---|
| 13615 | + |
---|
| 13616 | + if (Globals.MINSHADER) |
---|
| 13617 | + { |
---|
| 13618 | + program = programmin; |
---|
| 13619 | + } |
---|
| 13620 | + |
---|
| 13621 | + if (Globals.DEBUG) |
---|
| 13622 | + { |
---|
| 13623 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13624 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13625 | + } |
---|
| 13626 | + |
---|
13327 | 13627 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13328 | 13628 | |
---|
13329 | 13629 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13370 | 13670 | "\n" + |
---|
13371 | 13671 | "END\n"; |
---|
13372 | 13672 | |
---|
13373 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13673 | + if (Globals.DEBUG) |
---|
| 13674 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13374 | 13675 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13676 | |
---|
13376 | 13677 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13628 | 13929 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13629 | 13930 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13630 | 13931 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13631 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13932 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13632 | 13933 | |
---|
13633 | 13934 | //Object3D.cVector2[] vector2buffer; |
---|
13634 | 13935 | |
---|
.. | .. |
---|
13795 | 14096 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13796 | 14097 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13797 | 14098 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13798 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 14099 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13799 | 14100 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13800 | 14101 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13801 | 14102 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13856 | 14157 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13857 | 14158 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13858 | 14159 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13859 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14160 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13860 | 14161 | "MOV result.texcoord, temp;" + |
---|
13861 | 14162 | // border fade |
---|
13862 | 14163 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13903 | 14204 | |
---|
13904 | 14205 | //"ADD temp.z, temp.z, one;" + |
---|
13905 | 14206 | |
---|
13906 | | - "MOV result.color, temp;" |
---|
| 14207 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14208 | + |
---|
| 14209 | + "MOV result.color, temp;" // Normal |
---|
13907 | 14210 | : "MOV result.color, vertex.color;") + |
---|
13908 | 14211 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13909 | 14212 | : "") + |
---|
.. | .. |
---|
14038 | 14341 | public void mouseClicked(MouseEvent e) |
---|
14039 | 14342 | { |
---|
14040 | 14343 | System.out.println("mouseClicked: " + e); |
---|
| 14344 | + System.exit(0); |
---|
14041 | 14345 | } |
---|
14042 | 14346 | |
---|
14043 | 14347 | public void mousePressed(MouseEvent e) |
---|
14044 | 14348 | { |
---|
| 14349 | + RigidBody.justclicked = true; |
---|
| 14350 | + System.out.println("justclicked: " + e); |
---|
14045 | 14351 | //System.out.println("mousePressed: " + e); |
---|
14046 | 14352 | clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
14047 | 14353 | } |
---|
.. | .. |
---|
14076 | 14382 | return; |
---|
14077 | 14383 | } |
---|
14078 | 14384 | |
---|
14079 | | - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14385 | + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 14386 | + |
---|
| 14387 | + boolean vr = capsLocked && !lightMode; |
---|
14080 | 14388 | |
---|
14081 | 14389 | // TIMER |
---|
14082 | | - if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14390 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !vr) // VR |
---|
14083 | 14391 | { |
---|
14084 | 14392 | keepboxmode = BOXMODE; |
---|
14085 | 14393 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
14120 | 14428 | //} |
---|
14121 | 14429 | |
---|
14122 | 14430 | SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
14123 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
| 14431 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx()); |
---|
14124 | 14432 | anchorX = ax; |
---|
14125 | 14433 | anchorY = ay; |
---|
14126 | 14434 | prevX = px; |
---|
.. | .. |
---|
14215 | 14523 | // fev 2014??? |
---|
14216 | 14524 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
14217 | 14525 | object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
14218 | | - pingthread.StepToTarget(true); // true); |
---|
| 14526 | + pingthread.StepToTarget(); // true); |
---|
14219 | 14527 | } |
---|
| 14528 | + |
---|
14220 | 14529 | // if (!LIVE) |
---|
14221 | 14530 | super.repaint(); |
---|
14222 | 14531 | } |
---|
.. | .. |
---|
14311 | 14620 | |
---|
14312 | 14621 | //if (drawing) |
---|
14313 | 14622 | //return; |
---|
14314 | | - if ((e.getModifiersEx() & CTRL) != 0 |
---|
14315 | | - || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
| 14623 | + if ((e.getModifiersEx() & CTRL) != 0 || |
---|
| 14624 | + (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
14316 | 14625 | { |
---|
14317 | 14626 | //System.out.println("mouseDragged: " + e); |
---|
14318 | 14627 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
.. | .. |
---|
14336 | 14645 | return targetLookAt; |
---|
14337 | 14646 | } |
---|
14338 | 14647 | |
---|
| 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 | + |
---|
14339 | 14653 | class PingThread extends Thread |
---|
14340 | 14654 | { |
---|
14341 | 14655 | boolean jump; |
---|
| 14656 | + boolean live; |
---|
| 14657 | + |
---|
| 14658 | + boolean mute; |
---|
14342 | 14659 | |
---|
14343 | 14660 | // void JumpToTarget() |
---|
14344 | 14661 | // { |
---|
.. | .. |
---|
14354 | 14671 | // only one thread!? synchronized |
---|
14355 | 14672 | void StepToTarget(boolean jump) |
---|
14356 | 14673 | { |
---|
| 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 | + RigidBody.wind.set(RigidBody.pos); |
---|
| 14683 | + RigidBody.wind.x -= (float)manipCamera.location.x; |
---|
| 14684 | + RigidBody.wind.y -= (float)manipCamera.location.y; |
---|
| 14685 | + RigidBody.wind.z -= (float)manipCamera.location.z; |
---|
| 14686 | + RigidBody.wind.normalize(); |
---|
| 14687 | + } |
---|
| 14688 | + |
---|
| 14689 | + if (mute) |
---|
| 14690 | + return; |
---|
| 14691 | + |
---|
| 14692 | + if (capsLocked && manipCamera.viewCode == 0) |
---|
| 14693 | + { |
---|
| 14694 | + eye.x = manipCamera.location.x; |
---|
| 14695 | + eye.y = manipCamera.location.y + 0.25; |
---|
| 14696 | + eye.z = manipCamera.location.z; |
---|
| 14697 | + |
---|
| 14698 | + dir.y = -1; |
---|
| 14699 | + |
---|
| 14700 | + Ray ray = new Ray(eye, dir); |
---|
| 14701 | + |
---|
| 14702 | + IntersectResult res = new IntersectResult(); |
---|
| 14703 | + res.t = Double.POSITIVE_INFINITY; |
---|
| 14704 | + |
---|
| 14705 | + tmp.set(targetLookAt); |
---|
| 14706 | + tmp.sub(manipCamera.location); |
---|
| 14707 | + |
---|
| 14708 | + double dist = tmp.length(); |
---|
| 14709 | + |
---|
| 14710 | + tmp.normalize(); |
---|
| 14711 | + |
---|
| 14712 | + eye2.x = manipCamera.location.x + tmp.x * 0.25; |
---|
| 14713 | + eye2.y = manipCamera.location.y + 0.25; |
---|
| 14714 | + eye2.z = manipCamera.location.z + tmp.z * 0.25; |
---|
| 14715 | + |
---|
| 14716 | + Ray ray2 = new Ray(eye2, dir); |
---|
| 14717 | + |
---|
| 14718 | + IntersectResult res2 = new IntersectResult(); |
---|
| 14719 | + res2.t = Double.POSITIVE_INFINITY; |
---|
| 14720 | + |
---|
| 14721 | + if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25) |
---|
| 14722 | + { |
---|
| 14723 | + //tmp.set(manipCamera.location); |
---|
| 14724 | + |
---|
| 14725 | + manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t; |
---|
| 14726 | + manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5; |
---|
| 14727 | + manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t; |
---|
| 14728 | + |
---|
| 14729 | + //tmp.sub(manipCamera.location); |
---|
| 14730 | + |
---|
| 14731 | + targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t; |
---|
| 14732 | + targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5; |
---|
| 14733 | + targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t; |
---|
| 14734 | + |
---|
| 14735 | + targetLookAt.sub(manipCamera.location); |
---|
| 14736 | + targetLookAt.normalize(); |
---|
| 14737 | + targetLookAt.mul(dist); |
---|
| 14738 | + targetLookAt.add(manipCamera.location); |
---|
| 14739 | + |
---|
| 14740 | + //if (tmp.dot(tmp) > 0.000001) |
---|
| 14741 | + // System.out.println("INTERSECTION " + manipCamera.location); |
---|
| 14742 | + |
---|
| 14743 | + manipCamera.lookAt.set(targetLookAt); |
---|
| 14744 | + |
---|
| 14745 | + tmp.x = res.n.x; |
---|
| 14746 | + tmp.y = res.n.y; |
---|
| 14747 | + tmp.z = res.n.z; |
---|
| 14748 | + tmp.x += res2.n.x; |
---|
| 14749 | + tmp.y += res2.n.y; |
---|
| 14750 | + tmp.z += res2.n.z; |
---|
| 14751 | + tmp.normalize(); |
---|
| 14752 | + manipCamera.UP.set(tmp); |
---|
| 14753 | + } |
---|
| 14754 | + } |
---|
| 14755 | + |
---|
14357 | 14756 | tmp.set(targetLookAt); |
---|
14358 | 14757 | tmp.sub(manipCamera.lookAt); // june 2014 |
---|
14359 | 14758 | |
---|
.. | .. |
---|
14391 | 14790 | |
---|
14392 | 14791 | if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target |
---|
14393 | 14792 | { |
---|
14394 | | - jump = true; // step = 1; |
---|
| 14793 | + // sep 2019 jump = true; // step = 1; |
---|
14395 | 14794 | } |
---|
14396 | 14795 | |
---|
14397 | 14796 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
14426 | 14825 | if (tmp.dot(tmp) < 0.00001) |
---|
14427 | 14826 | { |
---|
14428 | 14827 | zoomonce = false; |
---|
| 14828 | + live = false; |
---|
14429 | 14829 | } |
---|
| 14830 | + else |
---|
| 14831 | + live = true; |
---|
14430 | 14832 | |
---|
14431 | 14833 | tmp.mul(step > step2 ? step : step2); |
---|
14432 | 14834 | } |
---|
.. | .. |
---|
14453 | 14855 | { |
---|
14454 | 14856 | if (LOOKAT) |
---|
14455 | 14857 | manipCamera.lookAt.add(tmp); |
---|
14456 | | - if (OEIL) |
---|
| 14858 | + if (OEIL && !capsLocked) |
---|
14457 | 14859 | manipCamera.location.add(tmp); |
---|
14458 | 14860 | |
---|
14459 | 14861 | { |
---|
.. | .. |
---|
14468 | 14870 | lightCamera.computeTransform(); |
---|
14469 | 14871 | } |
---|
14470 | 14872 | } |
---|
14471 | | - manipCamera.computeTransform(); |
---|
| 14873 | + if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0) |
---|
| 14874 | + { |
---|
| 14875 | + manipCamera.computeTransform(); |
---|
| 14876 | + } |
---|
14472 | 14877 | } |
---|
14473 | 14878 | // ?????? mouseDown = true; |
---|
14474 | 14879 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
.. | .. |
---|
14561 | 14966 | } |
---|
14562 | 14967 | } |
---|
14563 | 14968 | } |
---|
| 14969 | + |
---|
14564 | 14970 | PingThread pingthread = new PingThread(); |
---|
14565 | | - int delta = 5; |
---|
14566 | | - int speed = 5; |
---|
| 14971 | + int delta = 1; |
---|
| 14972 | + int speed = 1; |
---|
| 14973 | + int walk = 8; |
---|
14567 | 14974 | boolean autorepeat = false; |
---|
14568 | 14975 | |
---|
| 14976 | + void Walk() |
---|
| 14977 | + { |
---|
| 14978 | + manipCamera.BackForth(0, walk, 1000); |
---|
| 14979 | + |
---|
| 14980 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14981 | + } |
---|
| 14982 | + |
---|
| 14983 | + void ViewAngle(float dy) |
---|
| 14984 | + { |
---|
| 14985 | + double factor = Math.exp(-dy/300.0); // (1 + dy/100); |
---|
| 14986 | + |
---|
| 14987 | + if (manipCamera.shaper_fovy * factor > 1 && |
---|
| 14988 | + manipCamera.shaper_fovy * factor < 150) |
---|
| 14989 | + { |
---|
| 14990 | + manipCamera.shaper_fovy *= factor; |
---|
| 14991 | + //System.out.println("fovy = " + shaper_fovy); |
---|
| 14992 | + } |
---|
| 14993 | + } |
---|
| 14994 | + |
---|
14569 | 14995 | void GoDown(int mod) |
---|
14570 | 14996 | { |
---|
14571 | 14997 | MODIFIERS |= COMMAND; |
---|
| 14998 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14572 | 14999 | /**/ |
---|
14573 | 15000 | if((mod&SHIFT) == SHIFT) |
---|
14574 | | - manipCamera.RotatePosition(0, -speed); |
---|
14575 | | - else |
---|
14576 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
14577 | | - /**/ |
---|
14578 | | - if ((mod & SHIFT) == SHIFT) |
---|
14579 | 15001 | { |
---|
14580 | | - mouseMode = mouseMode; // VR?? |
---|
14581 | | - } else |
---|
14582 | | - { |
---|
14583 | | - mouseMode |= BACKFORTH; |
---|
| 15002 | +// if (isVR) |
---|
| 15003 | +// manipCamera.RotateInterest(0, speed); |
---|
| 15004 | +// else |
---|
| 15005 | + if (isVR) |
---|
| 15006 | + ViewAngle(-speed*delta); |
---|
| 15007 | + else |
---|
| 15008 | + manipCamera.Translate(0, -speed*delta, getWidth()); |
---|
14584 | 15009 | } |
---|
| 15010 | + else |
---|
| 15011 | + { |
---|
| 15012 | + if (isVR) |
---|
| 15013 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15014 | + else |
---|
| 15015 | + manipCamera.RotatePosition(0, -speed); |
---|
| 15016 | + } |
---|
| 15017 | + |
---|
| 15018 | + /**/ |
---|
| 15019 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15020 | +// { |
---|
| 15021 | +// mouseMode = mouseMode; // VR?? |
---|
| 15022 | +// } else |
---|
| 15023 | +// { |
---|
| 15024 | +// mouseMode |= BACKFORTH; |
---|
| 15025 | +// } |
---|
14585 | 15026 | |
---|
| 15027 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15028 | + |
---|
14586 | 15029 | //prevX = X = anchorX; |
---|
14587 | 15030 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14588 | 15031 | } |
---|
14589 | 15032 | |
---|
14590 | 15033 | void GoUp(int mod) |
---|
14591 | 15034 | { |
---|
| 15035 | + RigidBody.justclicked = true; |
---|
| 15036 | + |
---|
14592 | 15037 | MODIFIERS |= COMMAND; |
---|
14593 | 15038 | /**/ |
---|
| 15039 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 15040 | + |
---|
14594 | 15041 | if((mod&SHIFT) == SHIFT) |
---|
14595 | | - manipCamera.RotatePosition(0, speed); |
---|
14596 | | - else |
---|
14597 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
14598 | | - /**/ |
---|
14599 | | - if ((mod & SHIFT) == SHIFT) |
---|
14600 | 15042 | { |
---|
14601 | | - mouseMode = mouseMode; |
---|
14602 | | - } else |
---|
14603 | | - { |
---|
14604 | | - mouseMode |= BACKFORTH; |
---|
| 15043 | +// if (isVR) |
---|
| 15044 | +// manipCamera.RotateInterest(0, -speed); |
---|
| 15045 | +// else |
---|
| 15046 | + if (isVR) |
---|
| 15047 | + ViewAngle(speed*delta); |
---|
| 15048 | + else |
---|
| 15049 | + manipCamera.Translate(0, speed*delta, getWidth()); |
---|
14605 | 15050 | } |
---|
| 15051 | + else |
---|
| 15052 | + { |
---|
| 15053 | + if (isVR) |
---|
| 15054 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15055 | + else |
---|
| 15056 | + manipCamera.RotatePosition(0, speed); |
---|
| 15057 | + } |
---|
| 15058 | + |
---|
| 15059 | + /**/ |
---|
| 15060 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15061 | +// { |
---|
| 15062 | +// mouseMode = mouseMode; |
---|
| 15063 | +// } else |
---|
| 15064 | +// { |
---|
| 15065 | +// mouseMode |= BACKFORTH; |
---|
| 15066 | +// } |
---|
14606 | 15067 | |
---|
| 15068 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15069 | + |
---|
14607 | 15070 | //prevX = X = anchorX; |
---|
14608 | 15071 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14609 | 15072 | } |
---|
.. | .. |
---|
14613 | 15076 | MODIFIERS |= COMMAND; |
---|
14614 | 15077 | /**/ |
---|
14615 | 15078 | if((mod&SHIFT) == SHIFT) |
---|
14616 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 15079 | + manipCamera.Translate(speed, 0, getWidth()); |
---|
14617 | 15080 | else |
---|
14618 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 15081 | + { |
---|
| 15082 | + if ((mouseMode&VR)!=0) |
---|
| 15083 | + manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15084 | + else |
---|
| 15085 | + manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15086 | + } |
---|
| 15087 | + |
---|
14619 | 15088 | /**/ |
---|
14620 | | - if ((mod & SHIFT) == SHIFT) |
---|
14621 | | - { |
---|
14622 | | - mouseMode = mouseMode; |
---|
14623 | | - } else |
---|
14624 | | - { |
---|
14625 | | - mouseMode |= ROTATE; |
---|
14626 | | - } // TRANSLATE; |
---|
| 15089 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15090 | +// { |
---|
| 15091 | +// mouseMode = mouseMode; |
---|
| 15092 | +// } else |
---|
| 15093 | +// { |
---|
| 15094 | +// mouseMode |= ROTATE; |
---|
| 15095 | +// } // TRANSLATE; |
---|
14627 | 15096 | |
---|
| 15097 | + //System.err.println("lookAt = " + manipCamera.lookAt); |
---|
| 15098 | + //System.err.println("location = " + manipCamera.location); |
---|
| 15099 | + |
---|
| 15100 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15101 | + |
---|
14628 | 15102 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14629 | 15103 | prevY = Y = anchorY; |
---|
14630 | 15104 | } |
---|
.. | .. |
---|
14634 | 15108 | MODIFIERS |= COMMAND; |
---|
14635 | 15109 | /**/ |
---|
14636 | 15110 | if((mod&SHIFT) == SHIFT) |
---|
14637 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 15111 | + manipCamera.Translate(-speed, 0, getWidth()); |
---|
14638 | 15112 | else |
---|
14639 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 15113 | + { |
---|
| 15114 | + if ((mouseMode&VR)!=0) |
---|
| 15115 | + manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15116 | + else |
---|
| 15117 | + manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0); |
---|
| 15118 | + } |
---|
| 15119 | + |
---|
14640 | 15120 | /**/ |
---|
14641 | | - if ((mod & SHIFT) == SHIFT) |
---|
14642 | | - { |
---|
14643 | | - mouseMode = mouseMode; |
---|
14644 | | - } else |
---|
14645 | | - { |
---|
14646 | | - mouseMode |= ROTATE; |
---|
14647 | | - } // TRANSLATE; |
---|
| 15121 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15122 | +// { |
---|
| 15123 | +// mouseMode = mouseMode; |
---|
| 15124 | +// } else |
---|
| 15125 | +// { |
---|
| 15126 | +// mouseMode |= ROTATE; |
---|
| 15127 | +// } // TRANSLATE; |
---|
14648 | 15128 | |
---|
| 15129 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15130 | + |
---|
14649 | 15131 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14650 | 15132 | prevY = Y = anchorY; |
---|
14651 | 15133 | } |
---|
.. | .. |
---|
14779 | 15261 | if ((mouseMode & ZOOM) != 0) |
---|
14780 | 15262 | { |
---|
14781 | 15263 | //if ((mouseMode & BACKFORTH) != 0) |
---|
| 15264 | + if ((modifiersex & SHIFT) == SHIFT) |
---|
| 15265 | + { |
---|
| 15266 | + ViewAngle(dy); |
---|
| 15267 | + } |
---|
| 15268 | + else |
---|
14782 | 15269 | if ((mouseMode & VR) != 0) |
---|
14783 | 15270 | manipCamera.BackForth(dx, dy, getWidth()); |
---|
14784 | 15271 | else |
---|
.. | .. |
---|
14849 | 15336 | |
---|
14850 | 15337 | public void mouseMoved(MouseEvent e) |
---|
14851 | 15338 | { |
---|
| 15339 | +//object.editWindow.frame. |
---|
| 15340 | + setCursor(Cursor.getDefaultCursor()); |
---|
| 15341 | + |
---|
14852 | 15342 | //System.out.println("mouseMoved: " + e); |
---|
14853 | 15343 | if (isRenderer) |
---|
14854 | 15344 | return; |
---|
.. | .. |
---|
15033 | 15523 | mouseMode |= ZOOM; |
---|
15034 | 15524 | } |
---|
15035 | 15525 | |
---|
15036 | | - boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
15037 | | - if (capsLocked) // || (modifiers & META) == META) |
---|
| 15526 | + //boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
| 15527 | + boolean vr = capsLocked && !lightMode; |
---|
| 15528 | + |
---|
| 15529 | + if (vr) // || (modifiers & META) == META) |
---|
15038 | 15530 | { |
---|
15039 | 15531 | mouseMode |= VR; // BACKFORTH; |
---|
15040 | 15532 | } |
---|
.. | .. |
---|
15046 | 15538 | { |
---|
15047 | 15539 | mouseMode |= SELECT; |
---|
15048 | 15540 | } |
---|
15049 | | - if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15541 | + if (//(modifiersex & SHIFT) == SHIFT || |
---|
| 15542 | + forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
15050 | 15543 | { |
---|
15051 | 15544 | mouseMode &= ~VR; |
---|
15052 | 15545 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
15090 | 15583 | float SATPOW = 1; // 2; // 0.5f; |
---|
15091 | 15584 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
15092 | 15585 | |
---|
| 15586 | +static BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); |
---|
| 15587 | + |
---|
| 15588 | +// Create a new blank cursor. |
---|
| 15589 | +static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor( |
---|
| 15590 | + cursorImg, new Point(0, 0), "blank cursor"); |
---|
| 15591 | + |
---|
15093 | 15592 | public void keyPressed(int key) |
---|
15094 | 15593 | { |
---|
| 15594 | +// Set the blank cursor to the JFrame. |
---|
| 15595 | +//object.editWindow.frame. |
---|
| 15596 | + setCursor(blankCursor); |
---|
| 15597 | + |
---|
15095 | 15598 | if (key >= '0' && key <= '5') |
---|
15096 | 15599 | clampbit = (key-'0'); |
---|
15097 | 15600 | |
---|
.. | .. |
---|
15148 | 15651 | case 'K': |
---|
15149 | 15652 | KOMPACTTEXTURE ^= true; |
---|
15150 | 15653 | //textures.clear(); |
---|
15151 | | - break; |
---|
15152 | | - case 'P': // Texture Projection macros |
---|
| 15654 | + // break; |
---|
| 15655 | + //case 'P': // Texture Projection macros |
---|
15153 | 15656 | // SAVETEXTURE ^= true; |
---|
15154 | 15657 | macromode = true; |
---|
15155 | 15658 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15250 | 15753 | RevertCamera(); |
---|
15251 | 15754 | repaint(); |
---|
15252 | 15755 | break; |
---|
15253 | | - case 'l': |
---|
15254 | | - //case 'L': |
---|
| 15756 | + //case 'l': |
---|
| 15757 | + case 'L': |
---|
15255 | 15758 | if (lightMode) |
---|
15256 | 15759 | { |
---|
15257 | 15760 | lightMode = false; |
---|
.. | .. |
---|
15270 | 15773 | targetLookAt.set(manipCamera.lookAt); |
---|
15271 | 15774 | repaint(); |
---|
15272 | 15775 | break; |
---|
15273 | | - case 'p': |
---|
| 15776 | + case 'P': // p': |
---|
15274 | 15777 | // c'est quoi ca au juste? spherical ^= true; |
---|
15275 | 15778 | Skinshader ^= true; programInitialized = false; |
---|
15276 | 15779 | repaint(); |
---|
.. | .. |
---|
15281 | 15784 | break; |
---|
15282 | 15785 | case 'm': |
---|
15283 | 15786 | { |
---|
15284 | | - PrintMemory(); |
---|
| 15787 | + //PrintMemory(); |
---|
| 15788 | + ToggleImageFlip(); |
---|
15285 | 15789 | break; |
---|
15286 | 15790 | } |
---|
15287 | 15791 | case 'M': |
---|
.. | .. |
---|
15308 | 15812 | repaint(); |
---|
15309 | 15813 | break; |
---|
15310 | 15814 | case 'O': |
---|
15311 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
15312 | | - repaint(); |
---|
15313 | | - break; |
---|
| 15815 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15816 | + //repaint(); |
---|
| 15817 | + //break; |
---|
15314 | 15818 | case 'o': |
---|
15315 | 15819 | OCCLUSION_CULLING ^= true; |
---|
15316 | 15820 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15317 | 15821 | break; |
---|
15318 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15822 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15319 | 15823 | case '1': |
---|
15320 | 15824 | case '2': |
---|
15321 | 15825 | case '3': |
---|
15322 | 15826 | case '4': |
---|
15323 | 15827 | case '5': |
---|
15324 | | - newenvy = Character.getNumericValue(key); |
---|
15325 | | - repaint(); |
---|
15326 | | - break; |
---|
15327 | 15828 | case '6': |
---|
15328 | 15829 | case '7': |
---|
15329 | 15830 | case '8': |
---|
15330 | 15831 | case '9': |
---|
15331 | | - BGcolor = (key - '6')/3.f; |
---|
| 15832 | + if (true) // envyoff) |
---|
| 15833 | + { |
---|
| 15834 | + BGcolor = (key - '1')/8.f; |
---|
| 15835 | + } |
---|
| 15836 | + else |
---|
| 15837 | + { |
---|
| 15838 | + //newenvy = Character.getNumericValue(key); |
---|
| 15839 | + } |
---|
15332 | 15840 | repaint(); |
---|
15333 | 15841 | break; |
---|
15334 | 15842 | case '!': |
---|
.. | .. |
---|
15398 | 15906 | // kompactbit = 6; |
---|
15399 | 15907 | // break; |
---|
15400 | 15908 | case ' ': |
---|
| 15909 | + capsLocked ^= true; |
---|
| 15910 | + repaint(); |
---|
| 15911 | + break; |
---|
| 15912 | + case 'l': |
---|
15401 | 15913 | lightMode ^= true; |
---|
| 15914 | + if (lightMode) |
---|
| 15915 | + { |
---|
| 15916 | + keepshadow = Globals.RENDERSHADOW; |
---|
| 15917 | + Globals.RENDERSHADOW = false; |
---|
| 15918 | + } |
---|
| 15919 | + else |
---|
| 15920 | + { |
---|
| 15921 | + Globals.RENDERSHADOW = keepshadow; |
---|
| 15922 | + } |
---|
| 15923 | + |
---|
15402 | 15924 | Globals.lighttouched = true; |
---|
15403 | 15925 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
15404 | 15926 | targetLookAt.set(manipCamera.lookAt); |
---|
.. | .. |
---|
15406 | 15928 | break; |
---|
15407 | 15929 | //case '`' : |
---|
15408 | 15930 | case ESC: |
---|
| 15931 | + if (FULLSCREEN) |
---|
| 15932 | + object.editWindow.ToggleFullScreen(); |
---|
| 15933 | + break; |
---|
| 15934 | + case 'p': |
---|
15409 | 15935 | RENDERPROGRAM += 1; |
---|
15410 | 15936 | RENDERPROGRAM %= 3; |
---|
15411 | 15937 | |
---|
.. | .. |
---|
15444 | 15970 | case ENTER: |
---|
15445 | 15971 | // object.editWindow.ScreenFit(); // Edit(); |
---|
15446 | 15972 | ToggleLive(); |
---|
| 15973 | + if (capsLocked) |
---|
| 15974 | + { |
---|
| 15975 | + Globals.WALK ^= true; |
---|
| 15976 | + } |
---|
15447 | 15977 | break; |
---|
15448 | 15978 | case DELETE: |
---|
15449 | 15979 | ClearSelection(); |
---|
.. | .. |
---|
15480 | 16010 | object.GetWindow().refreshContents(true); |
---|
15481 | 16011 | break; |
---|
15482 | 16012 | case '{': |
---|
15483 | | - manipCamera.shaper_fovy /= 1.1; |
---|
| 16013 | + double factor = 1.1; |
---|
| 16014 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16015 | + manipCamera.shaper_fovy /= factor; |
---|
15484 | 16016 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15485 | 16017 | repaint(); |
---|
15486 | 16018 | break; |
---|
15487 | 16019 | case '}': |
---|
15488 | | - manipCamera.shaper_fovy *= 1.1; |
---|
| 16020 | + factor = 1.1; |
---|
| 16021 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16022 | + manipCamera.shaper_fovy *= factor; |
---|
15489 | 16023 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15490 | 16024 | repaint(); |
---|
15491 | 16025 | break; |
---|
15492 | 16026 | case '[': |
---|
15493 | | - manipCamera.shaper_fovy /= 1.01; |
---|
| 16027 | + factor = 1.01; |
---|
| 16028 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16029 | + manipCamera.shaper_fovy /= factor; |
---|
15494 | 16030 | if (false) //manipCamera.hAspect == 0) |
---|
15495 | 16031 | { |
---|
15496 | 16032 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15506 | 16042 | break; |
---|
15507 | 16043 | case ']': |
---|
15508 | 16044 | //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1; |
---|
15509 | | - manipCamera.shaper_fovy *= 1.01; |
---|
| 16045 | + factor = 1.01; |
---|
| 16046 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16047 | + manipCamera.shaper_fovy *= factor; |
---|
15510 | 16048 | if (false) //manipCamera.hAspect == 0) |
---|
15511 | 16049 | { |
---|
15512 | 16050 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15544 | 16082 | } |
---|
15545 | 16083 | } |
---|
15546 | 16084 | |
---|
| 16085 | + boolean keys[] = new boolean[256]; |
---|
| 16086 | + int speedkey[] = new int[256]; |
---|
| 16087 | + int modifiers = 0; |
---|
| 16088 | + |
---|
15547 | 16089 | public void processKeyEvent(KeyEvent e) |
---|
15548 | 16090 | { |
---|
15549 | 16091 | switch (e.getID()) |
---|
15550 | 16092 | { |
---|
15551 | 16093 | case KeyEvent.KEY_PRESSED: |
---|
15552 | | - if (!autorepeat) |
---|
15553 | | - { |
---|
15554 | | - //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); |
---|
15555 | | - keyPressed(e.getKeyChar(), e.getModifiersEx()); |
---|
15556 | | - } |
---|
15557 | | - if (manipCamera == lightCamera) |
---|
15558 | | - { |
---|
15559 | | - switch (e.getKeyCode()) |
---|
15560 | | - { |
---|
15561 | | - case DOWN_ARROW: |
---|
15562 | | - lightCamera.DECAL /= 2; |
---|
15563 | | - repaint(); |
---|
15564 | | - break; |
---|
15565 | | - case UP_ARROW: |
---|
15566 | | - lightCamera.DECAL *= 2; |
---|
15567 | | - repaint(); |
---|
15568 | | - break; |
---|
15569 | | - case LEFT_ARROW: |
---|
15570 | | - lightCamera.SCALE /= 2; |
---|
15571 | | - repaint(); |
---|
15572 | | - break; |
---|
15573 | | - case RIGHT_ARROW: |
---|
15574 | | - lightCamera.SCALE *= 2; |
---|
15575 | | - repaint(); |
---|
15576 | | - break; |
---|
15577 | | - default: |
---|
15578 | | - break; |
---|
15579 | | - } |
---|
15580 | | - |
---|
15581 | | - System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); |
---|
15582 | | - } else |
---|
15583 | | - { |
---|
15584 | | - if (true) // !autorepeat) |
---|
15585 | | - { |
---|
15586 | | - boolean reset = true; |
---|
15587 | | - |
---|
15588 | | - switch (e.getKeyCode()) |
---|
15589 | | - { |
---|
15590 | | - case DOWN_ARROW: |
---|
15591 | | - GoDown(e.getModifiersEx()); |
---|
15592 | | - repaint(); |
---|
15593 | | - break; |
---|
15594 | | - case UP_ARROW: |
---|
15595 | | - GoUp(e.getModifiersEx()); |
---|
15596 | | - repaint(); |
---|
15597 | | - break; |
---|
15598 | | - case LEFT_ARROW: |
---|
15599 | | - GoLeft(e.getModifiersEx()); |
---|
15600 | | - repaint(); |
---|
15601 | | - break; |
---|
15602 | | - case RIGHT_ARROW: |
---|
15603 | | - GoRight(e.getModifiersEx()); |
---|
15604 | | - repaint(); |
---|
15605 | | - break; |
---|
15606 | | - default: |
---|
15607 | | - reset = false; |
---|
15608 | | - break; |
---|
15609 | | - } |
---|
15610 | | - |
---|
15611 | | - if (reset) |
---|
15612 | | - { |
---|
15613 | | - autorepeat = true; |
---|
15614 | | - |
---|
15615 | | - targetLookAt.set(manipCamera.lookAt); |
---|
15616 | | - } |
---|
15617 | | - } |
---|
15618 | | - } |
---|
| 16094 | + keys[e.getKeyCode()] = true; |
---|
| 16095 | + modifiers = e.getModifiersEx(); |
---|
| 16096 | + keyPressed(e.getKeyChar(), modifiers); |
---|
| 16097 | + //Globals.theRenderer.keyPressed(e.getKeyChar()); |
---|
| 16098 | + repaint(); |
---|
15619 | 16099 | break; |
---|
15620 | | - case KeyEvent.KEY_TYPED: |
---|
15621 | | - break; |
---|
| 16100 | +// if (!autorepeat) |
---|
| 16101 | +// { |
---|
| 16102 | +// //System.out.println("processKeyEvent: " + KeyEvent.getKeyText(e.getKeyCode())); |
---|
| 16103 | +// keyPressed(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16104 | +// } |
---|
| 16105 | +// if (manipCamera == lightCamera) |
---|
| 16106 | +// { |
---|
| 16107 | +// switch (e.getKeyCode()) |
---|
| 16108 | +// { |
---|
| 16109 | +// case DOWN_ARROW: |
---|
| 16110 | +// lightCamera.DECAL /= 2; |
---|
| 16111 | +// repaint(); |
---|
| 16112 | +// break; |
---|
| 16113 | +// case UP_ARROW: |
---|
| 16114 | +// lightCamera.DECAL *= 2; |
---|
| 16115 | +// repaint(); |
---|
| 16116 | +// break; |
---|
| 16117 | +// case LEFT_ARROW: |
---|
| 16118 | +// lightCamera.SCALE /= 2; |
---|
| 16119 | +// repaint(); |
---|
| 16120 | +// break; |
---|
| 16121 | +// case RIGHT_ARROW: |
---|
| 16122 | +// lightCamera.SCALE *= 2; |
---|
| 16123 | +// repaint(); |
---|
| 16124 | +// break; |
---|
| 16125 | +// default: |
---|
| 16126 | +// break; |
---|
| 16127 | +// } |
---|
| 16128 | +// |
---|
| 16129 | +// System.out.println("DECAL = " + lightCamera.DECAL + "; SCALE = " + lightCamera.SCALE); |
---|
| 16130 | +// } else |
---|
| 16131 | +// { |
---|
| 16132 | +// if (true) // !autorepeat) |
---|
| 16133 | +// { |
---|
| 16134 | +// boolean reset = true; |
---|
| 16135 | +// |
---|
| 16136 | +// switch (e.getKeyCode()) |
---|
| 16137 | +// { |
---|
| 16138 | +// case DOWN_ARROW: |
---|
| 16139 | +// GoDown(e.getModifiersEx()); |
---|
| 16140 | +// repaint(); |
---|
| 16141 | +// break; |
---|
| 16142 | +// case UP_ARROW: |
---|
| 16143 | +// GoUp(e.getModifiersEx()); |
---|
| 16144 | +// repaint(); |
---|
| 16145 | +// break; |
---|
| 16146 | +// case LEFT_ARROW: |
---|
| 16147 | +// GoLeft(e.getModifiersEx()); |
---|
| 16148 | +// repaint(); |
---|
| 16149 | +// break; |
---|
| 16150 | +// case RIGHT_ARROW: |
---|
| 16151 | +// GoRight(e.getModifiersEx()); |
---|
| 16152 | +// repaint(); |
---|
| 16153 | +// break; |
---|
| 16154 | +// default: |
---|
| 16155 | +// reset = false; |
---|
| 16156 | +// break; |
---|
| 16157 | +// } |
---|
| 16158 | +// |
---|
| 16159 | +// if (reset) |
---|
| 16160 | +// { |
---|
| 16161 | +// autorepeat = true; |
---|
| 16162 | +// |
---|
| 16163 | +// targetLookAt.set(manipCamera.lookAt); |
---|
| 16164 | +// } |
---|
| 16165 | +// } |
---|
| 16166 | +// } |
---|
| 16167 | +// break; |
---|
| 16168 | +// case KeyEvent.KEY_TYPED: |
---|
| 16169 | +// break; |
---|
15622 | 16170 | case KeyEvent.KEY_RELEASED: |
---|
15623 | | - { |
---|
15624 | | - switch (e.getKeyCode()) |
---|
15625 | | - { |
---|
15626 | | - case DOWN_ARROW: |
---|
15627 | | - case UP_ARROW: |
---|
15628 | | - case LEFT_ARROW: |
---|
15629 | | - case RIGHT_ARROW: |
---|
15630 | | - MODIFIERS &= ~COMMAND; |
---|
15631 | | - autorepeat = false; |
---|
15632 | | - break; |
---|
15633 | | - default: |
---|
15634 | | - break; |
---|
15635 | | - } |
---|
| 16171 | + keys[e.getKeyCode()] = false; |
---|
| 16172 | + modifiers = e.getModifiersEx(); |
---|
15636 | 16173 | keyReleased(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16174 | + repaint(); |
---|
15637 | 16175 | break; |
---|
15638 | | - } |
---|
| 16176 | +// { |
---|
| 16177 | +// switch (e.getKeyCode()) |
---|
| 16178 | +// { |
---|
| 16179 | +// case DOWN_ARROW: |
---|
| 16180 | +// case UP_ARROW: |
---|
| 16181 | +// case LEFT_ARROW: |
---|
| 16182 | +// case RIGHT_ARROW: |
---|
| 16183 | +// MODIFIERS &= ~COMMAND; |
---|
| 16184 | +// autorepeat = false; |
---|
| 16185 | +// break; |
---|
| 16186 | +// default: |
---|
| 16187 | +// break; |
---|
| 16188 | +// } |
---|
| 16189 | +// keyReleased(e.getKeyChar(), e.getModifiersEx()); |
---|
| 16190 | +// break; |
---|
| 16191 | +// } |
---|
15639 | 16192 | default: |
---|
15640 | 16193 | break; |
---|
15641 | 16194 | } |
---|
.. | .. |
---|
16026 | 16579 | { |
---|
16027 | 16580 | switch (hitSomething) |
---|
16028 | 16581 | { |
---|
16029 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16582 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16030 | 16583 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16031 | 16584 | break; |
---|
16032 | 16585 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16033 | 16586 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16034 | 16587 | break; |
---|
16035 | 16588 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16036 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16589 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16037 | 16590 | break; |
---|
16038 | 16591 | } |
---|
16039 | 16592 | |
---|
.. | .. |
---|
16052 | 16605 | if (hasMarquee) |
---|
16053 | 16606 | { |
---|
16054 | 16607 | gr.setXORMode(Color.white); |
---|
16055 | | - gr.setColor(Color.red); |
---|
| 16608 | + gr.setColor(Color.white); |
---|
16056 | 16609 | if (!firstime) |
---|
16057 | 16610 | { |
---|
16058 | 16611 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16211 | 16764 | |
---|
16212 | 16765 | public boolean mouseDrag(Event evt, int x, int y) |
---|
16213 | 16766 | { |
---|
16214 | | - //System.out.println("mouseDrag: " + evt); |
---|
| 16767 | + System.out.println("mouseDrag: " + evt); |
---|
| 16768 | + System.exit(0); |
---|
16215 | 16769 | /* |
---|
16216 | 16770 | drag = true; |
---|
16217 | 16771 | //System.out.println("Mouse DRAG"); |
---|
.. | .. |
---|
16330 | 16884 | public boolean mouseUp(Event evt, int x, int y) |
---|
16331 | 16885 | { |
---|
16332 | 16886 | System.out.println("mouseUp: " + evt); |
---|
| 16887 | + System.exit(0); |
---|
16333 | 16888 | /* |
---|
16334 | 16889 | locked = false; |
---|
16335 | 16890 | if (isRenderer) |
---|
.. | .. |
---|
16519 | 17074 | private /*static*/ boolean firstime; |
---|
16520 | 17075 | private /*static*/ cVector newView = new cVector(); |
---|
16521 | 17076 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 17077 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 17078 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16522 | 17079 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16523 | 17080 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16524 | 17081 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16531 | 17088 | { |
---|
16532 | 17089 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16533 | 17090 | |
---|
| 17091 | + int usedsuf = 0; |
---|
| 17092 | + |
---|
16534 | 17093 | for (int i = 0; i < suffixes.length; i++) |
---|
16535 | 17094 | { |
---|
16536 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16537 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16538 | | - mipmapped, |
---|
16539 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16540 | | - if (data == null) |
---|
| 17095 | + String[] suffixe = suffixes; |
---|
| 17096 | + String[] fallback = suffixes2; |
---|
| 17097 | + String[] fallfallback = suffixes3; |
---|
| 17098 | + |
---|
| 17099 | + for (int c=usedsuf; --c>=0;) |
---|
16541 | 17100 | { |
---|
16542 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 17101 | +// String[] temp = suffixe; |
---|
| 17102 | +// suffixe = fallback; |
---|
| 17103 | +// fallback = fallfallback; |
---|
| 17104 | +// fallfallback = temp; |
---|
16543 | 17105 | } |
---|
| 17106 | + |
---|
| 17107 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 17108 | + TextureData data; |
---|
| 17109 | + |
---|
| 17110 | + try |
---|
| 17111 | + { |
---|
| 17112 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17113 | + mipmapped, |
---|
| 17114 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17115 | + } |
---|
| 17116 | + catch (Exception e) |
---|
| 17117 | + { |
---|
| 17118 | + try |
---|
| 17119 | + { |
---|
| 17120 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 17121 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17122 | + mipmapped, |
---|
| 17123 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17124 | + } |
---|
| 17125 | + catch (Exception e2) |
---|
| 17126 | + { |
---|
| 17127 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 17128 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 17129 | + mipmapped, |
---|
| 17130 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 17131 | + } |
---|
| 17132 | + } |
---|
| 17133 | + |
---|
16544 | 17134 | //System.out.println("Target = " + targets[i]); |
---|
16545 | 17135 | cubemap.updateImage(data, targets[i]); |
---|
16546 | 17136 | } |
---|
16547 | 17137 | |
---|
16548 | 17138 | return cubemap; |
---|
16549 | 17139 | } |
---|
| 17140 | + |
---|
16550 | 17141 | int bigsphere = -1; |
---|
16551 | 17142 | |
---|
16552 | 17143 | float BGcolor = 0.5f; |
---|
16553 | 17144 | |
---|
16554 | | - private void DrawSkyBox(GL gl) |
---|
| 17145 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 17146 | + |
---|
| 17147 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16555 | 17148 | { |
---|
16556 | | - if (envyoff || cubemap == null) |
---|
| 17149 | + if (//envyoff || |
---|
| 17150 | + WIREFRAME || |
---|
| 17151 | + cubemap == null) |
---|
16557 | 17152 | { |
---|
16558 | 17153 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16559 | 17154 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16568 | 17163 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16569 | 17164 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16570 | 17165 | gl.glLoadIdentity(); |
---|
| 17166 | + gl.glScalef(1,ratio,1); |
---|
16571 | 17167 | |
---|
| 17168 | +// colorV[0] = 2; |
---|
| 17169 | +// colorV[1] = 2; |
---|
| 17170 | +// colorV[2] = 2; |
---|
| 17171 | +// colorV[3] = 1; |
---|
| 17172 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 17173 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 17174 | +// |
---|
| 17175 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 17176 | + |
---|
16572 | 17177 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16573 | 17178 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16574 | 17179 | |
---|
.. | .. |
---|
16600 | 17205 | { |
---|
16601 | 17206 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16602 | 17207 | } |
---|
| 17208 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16603 | 17209 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16604 | 17210 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16605 | 17211 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16640 | 17246 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16641 | 17247 | |
---|
16642 | 17248 | cubemap.disable(); |
---|
16643 | | - ////cubemap.unbind(); |
---|
| 17249 | + //cubemap.dispose(); |
---|
| 17250 | + |
---|
16644 | 17251 | if (CULLFACE) |
---|
16645 | 17252 | { |
---|
16646 | 17253 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16696 | 17303 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16697 | 17304 | } |
---|
16698 | 17305 | |
---|
16699 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 17306 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16700 | 17307 | |
---|
16701 | 17308 | float step = 2; // 0.1666f; //0.25f; |
---|
16702 | 17309 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16858 | 17465 | //new Exception().printStackTrace(); |
---|
16859 | 17466 | System.out.println("select buffer init"); |
---|
16860 | 17467 | // Use debug pipeline |
---|
16861 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17468 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16862 | 17469 | |
---|
16863 | 17470 | GL gl = drawable.getGL(); |
---|
16864 | 17471 | |
---|
.. | .. |
---|
16985 | 17592 | |
---|
16986 | 17593 | float depth = depths[y * TEX_SIZE + x]; |
---|
16987 | 17594 | |
---|
16988 | | - if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1) |
---|
| 17595 | + if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1) |
---|
16989 | 17596 | { |
---|
16990 | 17597 | pointselection = false; |
---|
16991 | 17598 | |
---|
.. | .. |
---|
17176 | 17783 | |
---|
17177 | 17784 | public void init(GLAutoDrawable drawable) |
---|
17178 | 17785 | { |
---|
| 17786 | + if (Globals.DEBUG) |
---|
17179 | 17787 | System.out.println("shadow buffer init"); |
---|
17180 | 17788 | |
---|
17181 | 17789 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17404 | 18012 | gl.glFlush(); |
---|
17405 | 18013 | |
---|
17406 | 18014 | /**/ |
---|
17407 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 18015 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17408 | 18016 | |
---|
17409 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 18017 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17410 | 18018 | |
---|
| 18019 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 18020 | + |
---|
| 18021 | + int[] pixels = selectsizebuffer.array(); |
---|
| 18022 | + |
---|
17411 | 18023 | double r = 0, g = 0, b = 0; |
---|
17412 | 18024 | |
---|
17413 | 18025 | double count = 0; |
---|
.. | .. |
---|
17418 | 18030 | |
---|
17419 | 18031 | double FACTOR = 1; |
---|
17420 | 18032 | |
---|
17421 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 18033 | + for (int i = 0; i < depths.length; i++) |
---|
17422 | 18034 | { |
---|
17423 | 18035 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17424 | 18036 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17501 | 18113 | |
---|
17502 | 18114 | double scale = ray.z; // 1; // cos |
---|
17503 | 18115 | |
---|
17504 | | - float depth = pixels[newindex]; |
---|
| 18116 | + float depth = depths[newindex]; |
---|
17505 | 18117 | |
---|
17506 | 18118 | /* |
---|
17507 | 18119 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17644 | 18256 | static boolean DEBUG_SELECTION = false; |
---|
17645 | 18257 | boolean OCCLUSION_CULLING = false; //true; |
---|
17646 | 18258 | public boolean lightMode = false; |
---|
| 18259 | + |
---|
| 18260 | + private boolean keepshadow; |
---|
| 18261 | + |
---|
| 18262 | + static public boolean capsLocked = false; // VR |
---|
| 18263 | + |
---|
17647 | 18264 | static public int indexcount = 0; |
---|
17648 | 18265 | /*static*/ cColor vertexOcclusion = new cColor(); |
---|
17649 | 18266 | //private int selection_view = -1; |
---|
.. | .. |
---|
17698 | 18315 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17699 | 18316 | static IntBuffer bigAAbuffer; |
---|
17700 | 18317 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17701 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 18318 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17702 | 18319 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17703 | 18320 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17704 | 18321 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17705 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18322 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18323 | + |
---|
| 18324 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 18325 | + |
---|
17706 | 18326 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17707 | 18327 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17708 | 18328 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|