.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
93 | 97 | //boolean REDUCETEXTURE = true; |
---|
94 | 98 | boolean CACHETEXTURE = true; |
---|
95 | 99 | boolean CLEANCACHE = false; // true; |
---|
96 | | - boolean MIPMAP = true; // false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
97 | 101 | boolean COMPRESSTEXTURE = false; |
---|
98 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
99 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
106 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
107 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
108 | 112 | static GLContext glcontext = null; |
---|
109 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
110 | 118 | boolean reverseUP = false; |
---|
111 | 119 | static boolean frozen = false; |
---|
112 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
160 | 168 | |
---|
161 | 169 | |
---|
162 | 170 | // OPTIONS |
---|
163 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
164 | 172 | boolean cameraLight = false; |
---|
165 | 173 | boolean UVdebug = false; |
---|
166 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
169 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
170 | 178 | boolean anisotropy = true; |
---|
171 | 179 | boolean softshadow = true; // slower but better false; |
---|
172 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
173 | 181 | |
---|
174 | 182 | boolean macromode = false; |
---|
175 | 183 | |
---|
.. | .. |
---|
183 | 191 | } |
---|
184 | 192 | |
---|
185 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 194 | + |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
186 | 207 | |
---|
187 | 208 | void SetAsGLRenderer(boolean b) |
---|
188 | 209 | { |
---|
.. | .. |
---|
202 | 223 | |
---|
203 | 224 | SetCamera(cam); |
---|
204 | 225 | |
---|
205 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
206 | 228 | |
---|
207 | 229 | object = o; |
---|
208 | 230 | |
---|
.. | .. |
---|
520 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
521 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
522 | 544 | LA.vecNormalize(obj.v2); |
---|
523 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 545 | + |
---|
| 546 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
524 | 547 | } |
---|
525 | 548 | |
---|
526 | 549 | // P |
---|
.. | .. |
---|
542 | 565 | y += ny * obj.NORMALPUSH; |
---|
543 | 566 | z += nz * obj.NORMALPUSH; |
---|
544 | 567 | |
---|
545 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
546 | 569 | } |
---|
547 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
548 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
574 | 597 | y += ny * obj.NORMALPUSH; |
---|
575 | 598 | z += nz * obj.NORMALPUSH; |
---|
576 | 599 | |
---|
577 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
578 | 601 | } |
---|
579 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
580 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
622 | 645 | y += ny * obj.NORMALPUSH; |
---|
623 | 646 | z += nz * obj.NORMALPUSH; |
---|
624 | 647 | |
---|
625 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
626 | 649 | } |
---|
627 | 650 | |
---|
628 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
858 | 881 | //// tris.postdraw(this); |
---|
859 | 882 | } |
---|
860 | 883 | |
---|
861 | | - static Camera localcamera = new Camera(); |
---|
| 884 | + static Camera localAOcamera = new Camera(); |
---|
862 | 885 | static cVector from = new cVector(); |
---|
863 | 886 | static cVector to = new cVector(); |
---|
864 | 887 | |
---|
.. | .. |
---|
867 | 890 | CameraPane cp = this; |
---|
868 | 891 | |
---|
869 | 892 | Camera keep = cp.RenderCamera(); |
---|
870 | | - cp.renderCamera = localcamera; |
---|
| 893 | + cp.renderCamera = localAOcamera; |
---|
871 | 894 | |
---|
872 | 895 | if (br.trimmed) |
---|
873 | 896 | { |
---|
.. | .. |
---|
885 | 908 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
886 | 909 | LA.xformPos(from, transform, from); |
---|
887 | 910 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
888 | | - localcamera.setAim(from, to); |
---|
| 911 | + localAOcamera.setAim(from, to); |
---|
889 | 912 | |
---|
890 | 913 | CameraPane.occlusionbuffer.display(); |
---|
891 | 914 | |
---|
.. | .. |
---|
919 | 942 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
920 | 943 | LA.xformPos(from, transform, from); |
---|
921 | 944 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
922 | | - localcamera.setAim(from, to); |
---|
| 945 | + localAOcamera.setAim(from, to); |
---|
923 | 946 | |
---|
924 | 947 | CameraPane.occlusionbuffer.display(); |
---|
925 | 948 | |
---|
.. | .. |
---|
1228 | 1251 | { |
---|
1229 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1230 | 1253 | { |
---|
1231 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1232 | 1255 | } else |
---|
1233 | 1256 | { |
---|
1234 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1235 | 1258 | } |
---|
1236 | 1259 | |
---|
1237 | 1260 | if (c != null) |
---|
.. | .. |
---|
1255 | 1278 | { |
---|
1256 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1257 | 1280 | { |
---|
1258 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1259 | 1282 | } else |
---|
1260 | 1283 | { |
---|
1261 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1262 | 1285 | } |
---|
1263 | 1286 | if (c != null) |
---|
1264 | 1287 | { |
---|
.. | .. |
---|
1283 | 1306 | { |
---|
1284 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1285 | 1308 | { |
---|
1286 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1287 | 1310 | } else |
---|
1288 | 1311 | { |
---|
1289 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1290 | 1313 | } |
---|
1291 | 1314 | if (c != null) |
---|
1292 | 1315 | { |
---|
.. | .. |
---|
1468 | 1491 | { |
---|
1469 | 1492 | if (!selectmode) |
---|
1470 | 1493 | { |
---|
1471 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1472 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1473 | 1496 | |
---|
1474 | 1497 | if (flipV) |
---|
.. | .. |
---|
1480 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1481 | 1504 | } |
---|
1482 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1483 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1484 | 1509 | { |
---|
1485 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1547 | 1572 | { |
---|
1548 | 1573 | return; |
---|
1549 | 1574 | } |
---|
1550 | | - |
---|
1551 | | - float[] colorV = new float[3]; |
---|
1552 | 1575 | |
---|
1553 | 1576 | if (false) // marked) |
---|
1554 | 1577 | { |
---|
.. | .. |
---|
1797 | 1820 | |
---|
1798 | 1821 | display.modelParams7[0] = 0; |
---|
1799 | 1822 | display.modelParams7[1] = 1000; |
---|
1800 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1801 | 1824 | display.modelParams7[3] = 0; |
---|
1802 | 1825 | |
---|
1803 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2030 | 2053 | switch(viewcode) |
---|
2031 | 2054 | { |
---|
2032 | 2055 | case 0: return "main"; |
---|
2033 | | - case 1: return "one"; |
---|
2034 | | - case 2: return "two"; |
---|
2035 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2036 | 2059 | case 4: return "light"; |
---|
2037 | 2060 | } |
---|
2038 | 2061 | |
---|
.. | .. |
---|
2453 | 2476 | return CreateBim(bytes, width, height); |
---|
2454 | 2477 | } |
---|
2455 | 2478 | |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2456 | 2491 | /**/ |
---|
2457 | 2492 | class CacheTexture |
---|
2458 | 2493 | { |
---|
.. | .. |
---|
2495 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2496 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2497 | 2532 | true, |
---|
2498 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2499 | 2534 | } catch (java.io.IOException e) |
---|
2500 | 2535 | { |
---|
2501 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8341 | 8376 | // else |
---|
8342 | 8377 | // if (!texname.startsWith("/")) |
---|
8343 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8344 | | - if (!FileExists(texname)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8345 | 8380 | { |
---|
8346 | 8381 | texname = fallbackTextureName; |
---|
8347 | 8382 | } |
---|
.. | .. |
---|
8358 | 8393 | { |
---|
8359 | 8394 | TextureData texturedata = null; |
---|
8360 | 8395 | |
---|
8361 | | - if (texdata != null) |
---|
| 8396 | + if (texdata != null && textureon) |
---|
8362 | 8397 | { |
---|
8363 | | - BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8398 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
8364 | 8399 | |
---|
8365 | | - CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8400 | + try |
---|
| 8401 | + { |
---|
| 8402 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8403 | + } |
---|
| 8404 | + catch (Exception e) |
---|
| 8405 | + { |
---|
| 8406 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8407 | + } |
---|
8366 | 8408 | |
---|
8367 | 8409 | texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
8368 | 8410 | bimtextures.put(texdata, texturecache); |
---|
| 8411 | + |
---|
| 8412 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8413 | + |
---|
| 8414 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8415 | + //bim2 = bim; |
---|
8369 | 8416 | } |
---|
8370 | 8417 | else |
---|
8371 | 8418 | if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
.. | .. |
---|
8408 | 8455 | // texturecache = textures.get(texname); // suspicious |
---|
8409 | 8456 | if (texturecache == null) |
---|
8410 | 8457 | texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8458 | + else |
---|
| 8459 | + new Exception().printStackTrace(); |
---|
| 8460 | + } else |
---|
| 8461 | + { |
---|
| 8462 | + if (texname.startsWith("@")) |
---|
| 8463 | + { |
---|
| 8464 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8465 | + if (texturecache == null) |
---|
| 8466 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
8411 | 8467 | else |
---|
8412 | 8468 | new Exception().printStackTrace(); |
---|
8413 | 8469 | } else |
---|
.. | .. |
---|
8471 | 8527 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8472 | 8528 | //texture = GetTexture(tex, bump); |
---|
8473 | 8529 | } |
---|
| 8530 | + } |
---|
8474 | 8531 | } |
---|
8475 | 8532 | //} |
---|
8476 | 8533 | } |
---|
.. | .. |
---|
8560 | 8617 | { |
---|
8561 | 8618 | if (tex.pigmentdata == null) |
---|
8562 | 8619 | { |
---|
8563 | | - String texname = Object3D.GetPigment(tex); |
---|
| 8620 | + //String texname = Object3D.GetPigment(tex); |
---|
8564 | 8621 | |
---|
8565 | 8622 | CacheTexture texturecache = texturepigment.get(tex); |
---|
8566 | 8623 | |
---|
8567 | 8624 | if (texturecache != null) |
---|
8568 | 8625 | { |
---|
8569 | | - tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8570 | 8626 | tex.pw = texturecache.texturedata.getWidth(); |
---|
8571 | 8627 | tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8628 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8629 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8630 | + ; |
---|
| 8631 | + //, tex.pw, tex.ph), 0.5f); |
---|
8572 | 8632 | } |
---|
8573 | 8633 | } |
---|
8574 | 8634 | |
---|
8575 | 8635 | if (tex.bumpdata == null) |
---|
8576 | 8636 | { |
---|
8577 | | - String texname = Object3D.GetBump(tex); |
---|
| 8637 | + //String texname = Object3D.GetBump(tex); |
---|
8578 | 8638 | |
---|
8579 | 8639 | CacheTexture texturecache = texturebump.get(tex); |
---|
8580 | 8640 | |
---|
8581 | 8641 | if (texturecache != null) |
---|
8582 | 8642 | { |
---|
8583 | | - tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
8584 | 8643 | tex.bw = texturecache.texturedata.getWidth(); |
---|
8585 | 8644 | tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8645 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
8586 | 8646 | } |
---|
8587 | 8647 | } |
---|
8588 | 8648 | } |
---|
.. | .. |
---|
8654 | 8714 | return true; // Warning: not used. |
---|
8655 | 8715 | } |
---|
8656 | 8716 | |
---|
| 8717 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8718 | + { |
---|
| 8719 | + try |
---|
| 8720 | + { |
---|
| 8721 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8722 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8723 | + ImageWriter writer = writers.next(); |
---|
| 8724 | + |
---|
| 8725 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8726 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8727 | + param.setCompressionQuality(quality); |
---|
| 8728 | + |
---|
| 8729 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8730 | + writer.setOutput(ios); |
---|
| 8731 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8732 | + |
---|
| 8733 | + byte[] data = baos.toByteArray(); |
---|
| 8734 | + writer.dispose(); |
---|
| 8735 | + return data; |
---|
| 8736 | + } |
---|
| 8737 | + catch (Exception e) |
---|
| 8738 | + { |
---|
| 8739 | + e.printStackTrace(); |
---|
| 8740 | + return null; |
---|
| 8741 | + } |
---|
| 8742 | + } |
---|
| 8743 | + |
---|
| 8744 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8745 | + { |
---|
| 8746 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8747 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8748 | + ImageReader reader = writers.next(); |
---|
| 8749 | + |
---|
| 8750 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8751 | + |
---|
| 8752 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8753 | + param.setDestination(bim); |
---|
| 8754 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8755 | + |
---|
| 8756 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8757 | + reader.setInput(ios); |
---|
| 8758 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8759 | + reader.dispose(); |
---|
| 8760 | + |
---|
| 8761 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8762 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8763 | +// byte[] bytes = data.getData(); |
---|
| 8764 | +// |
---|
| 8765 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8766 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8767 | +// { |
---|
| 8768 | +// int i3 = i*3; |
---|
| 8769 | +// pixels[i] = 0xFF; |
---|
| 8770 | +// pixels[i] <<= 8; |
---|
| 8771 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8772 | +// pixels[i] <<= 8; |
---|
| 8773 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8774 | +// pixels[i] <<= 8; |
---|
| 8775 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8776 | +// } |
---|
| 8777 | +// |
---|
| 8778 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8779 | + |
---|
| 8780 | + return bim; |
---|
| 8781 | + } |
---|
| 8782 | + |
---|
8657 | 8783 | ShadowBuffer shadowPBuf; |
---|
8658 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8659 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8670 | 8796 | |
---|
8671 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8672 | 8798 | MAXSTACK = temp[0]; |
---|
8673 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8674 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8675 | 8802 | MAXSTACK = temp[0]; |
---|
8676 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8677 | 8805 | |
---|
8678 | 8806 | // Use debug pipeline |
---|
8679 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8681 | 8809 | gl = drawable.getGL(); // |
---|
8682 | 8810 | |
---|
8683 | 8811 | GL gl3 = getGL(); |
---|
8684 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8685 | 8814 | |
---|
8686 | 8815 | |
---|
8687 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8846 | 8975 | |
---|
8847 | 8976 | if (cubemap == null) |
---|
8848 | 8977 | { |
---|
8849 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8850 | 8979 | } |
---|
8851 | 8980 | |
---|
8852 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9122 | 9251 | |
---|
9123 | 9252 | void LoadEnvy(int which) |
---|
9124 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9125 | 9256 | String name; |
---|
9126 | 9257 | String ext; |
---|
9127 | 9258 | |
---|
.. | .. |
---|
9133 | 9264 | cubemap = null; |
---|
9134 | 9265 | return; |
---|
9135 | 9266 | case 1: |
---|
9136 | | - name = "cubemaps/box_"; |
---|
9137 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9138 | 9269 | reverseUP = false; |
---|
9139 | 9270 | break; |
---|
9140 | 9271 | case 2: |
---|
9141 | | - name = "cubemaps/uffizi_"; |
---|
9142 | | - ext = "png"; |
---|
9143 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9144 | 9276 | case 3: |
---|
9145 | | - name = "cubemaps/CloudyHills_"; |
---|
9146 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9147 | 9279 | reverseUP = false; |
---|
9148 | 9280 | break; |
---|
9149 | 9281 | case 4: |
---|
9150 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9151 | 9283 | ext = "png"; |
---|
9152 | 9284 | reverseUP = false; |
---|
9153 | 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; |
---|
9154 | 9311 | default: |
---|
9155 | | - name = "cubemaps/rgb_"; |
---|
9156 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9157 | 9315 | break; |
---|
9158 | 9316 | } |
---|
9159 | | - |
---|
9160 | | - try |
---|
9161 | | - { |
---|
9162 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9163 | | - } catch (IOException e) |
---|
9164 | | - { |
---|
9165 | | - throw new RuntimeException(e); |
---|
9166 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9167 | 9319 | } |
---|
9168 | 9320 | |
---|
9169 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9195 | 9347 | static double[] model = new double[16]; |
---|
9196 | 9348 | double[] camera2light = new double[16]; |
---|
9197 | 9349 | double[] light2camera = new double[16]; |
---|
9198 | | - int newenvy = -1; |
---|
9199 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9200 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9201 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9202 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9614 | 9770 | |
---|
9615 | 9771 | if (renderCamera != lightCamera) |
---|
9616 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9617 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9618 | 9774 | |
---|
9619 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9620 | 9776 | |
---|
.. | .. |
---|
9630 | 9786 | |
---|
9631 | 9787 | if (renderCamera != lightCamera) |
---|
9632 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9633 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9634 | 9790 | |
---|
9635 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9636 | 9792 | |
---|
.. | .. |
---|
9676 | 9832 | rati = 1 / rati; |
---|
9677 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9678 | 9834 | } |
---|
9679 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9680 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9681 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9682 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9683 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9684 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9685 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10545 | 10703 | static boolean init = false; |
---|
10546 | 10704 | |
---|
10547 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10548 | 10709 | |
---|
10549 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10550 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10551 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10552 | 10719 | { |
---|
10553 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10716 | 10883 | |
---|
10717 | 10884 | if (wait) |
---|
10718 | 10885 | { |
---|
10719 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10720 | 10887 | |
---|
10721 | 10888 | wait = false; |
---|
10722 | 10889 | } |
---|
.. | .. |
---|
10831 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10832 | 10999 | if (cam != lightCamera) |
---|
10833 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10834 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10835 | 11002 | |
---|
10836 | 11003 | for (int j = 0; j < 4; j++) |
---|
10837 | 11004 | { |
---|
.. | .. |
---|
10846 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10847 | 11014 | if (cam != lightCamera) |
---|
10848 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10849 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10850 | 11017 | |
---|
10851 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10852 | 11019 | |
---|
.. | .. |
---|
10932 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10933 | 11100 | } |
---|
10934 | 11101 | |
---|
10935 | | - if (newenvy > -1) |
---|
| 11102 | +// if (newenvy > -1) |
---|
| 11103 | +// { |
---|
| 11104 | +// LoadEnvy(newenvy); |
---|
| 11105 | +// } |
---|
| 11106 | +// |
---|
| 11107 | +// newenvy = -1; |
---|
| 11108 | + |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10936 | 11110 | { |
---|
10937 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
10938 | 11117 | } |
---|
10939 | | - |
---|
10940 | | - newenvy = -1; |
---|
10941 | | - |
---|
| 11118 | + else |
---|
| 11119 | + { |
---|
| 11120 | + if (object.skyboxname != null) |
---|
| 11121 | + { |
---|
| 11122 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11123 | + { |
---|
| 11124 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11125 | + cubemap.dispose(); |
---|
| 11126 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11127 | + loadedskyboxname = object.skyboxname; |
---|
| 11128 | + } |
---|
| 11129 | + } |
---|
| 11130 | + else |
---|
| 11131 | + { |
---|
| 11132 | + cubemapcustom = null; |
---|
| 11133 | + loadedskyboxname = null; |
---|
| 11134 | + } |
---|
| 11135 | + |
---|
| 11136 | + cubemap = cubemapcustom; |
---|
| 11137 | + } |
---|
| 11138 | + |
---|
10942 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
10943 | 11140 | //System.out.println("ratio = " + ratio); |
---|
10944 | 11141 | |
---|
.. | .. |
---|
10954 | 11151 | |
---|
10955 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
10956 | 11153 | { |
---|
10957 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
10958 | 11155 | } |
---|
10959 | 11156 | |
---|
10960 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
11240 | 11437 | |
---|
11241 | 11438 | // if (cam != lightCamera) |
---|
11242 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11243 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11244 | 11441 | } |
---|
11245 | 11442 | |
---|
11246 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11399 | 11596 | } |
---|
11400 | 11597 | } |
---|
11401 | 11598 | |
---|
11402 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11403 | 11600 | { |
---|
11404 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11405 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11407 | 11604 | |
---|
11408 | 11605 | boolean texon = textureon; |
---|
11409 | 11606 | |
---|
11410 | | - if (RENDERPROGRAM > 0) |
---|
11411 | | - { |
---|
11412 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11413 | | - textureon = false; |
---|
11414 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
11415 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11416 | 11611 | //System.out.println("ALLO"); |
---|
11417 | 11612 | gl.glColorMask(false, false, false, false); |
---|
11418 | 11613 | DrawObject(gl); |
---|
11419 | | - if (RENDERPROGRAM > 0) |
---|
11420 | | - { |
---|
11421 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11422 | | - textureon = texon; |
---|
11423 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
11424 | 11618 | gl.glColorMask(true, true, true, true); |
---|
11425 | 11619 | |
---|
11426 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11427 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
11428 | 11622 | } |
---|
11429 | 11623 | |
---|
11430 | 11624 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
12317 | 12511 | |
---|
12318 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12319 | 12513 | |
---|
12320 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12321 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
| 12520 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12521 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12522 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12523 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12524 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12525 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12526 | + "TEMP temp;" + |
---|
| 12527 | + "TEMP light;" + |
---|
| 12528 | + "TEMP ndotl;" + |
---|
| 12529 | + "TEMP normal;" + |
---|
| 12530 | + "TEMP depth;" + |
---|
| 12531 | + "TEMP eye;" + |
---|
| 12532 | + "TEMP pos;" + |
---|
| 12533 | + |
---|
| 12534 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
| 12535 | + Normalize("normal") + |
---|
| 12536 | + "MOV light, state.light[0].position;" + |
---|
| 12537 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12538 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
| 12539 | + |
---|
| 12540 | + // shadow |
---|
| 12541 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12542 | + "MOV temp, pos;" + |
---|
| 12543 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12544 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12545 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12546 | + |
---|
| 12547 | + // No shadow when out of frustum |
---|
| 12548 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12549 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12552 | + |
---|
| 12553 | + // Backlit |
---|
| 12554 | + "MOV pos.w, zero12t.y;" + // one |
---|
| 12555 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12556 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12557 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12558 | + Normalize("eye") + |
---|
| 12559 | + |
---|
| 12560 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12561 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12562 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12563 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12564 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12565 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12566 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12567 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12568 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
| 12569 | + |
---|
| 12570 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12571 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12572 | + |
---|
| 12573 | + // Pigment |
---|
| 12574 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12575 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12576 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
| 12577 | + |
---|
| 12578 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12579 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
| 12580 | + |
---|
| 12581 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12582 | + |
---|
| 12583 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
| 12584 | + "MOV result.color, temp;" + |
---|
| 12585 | + "END"; |
---|
| 12586 | + |
---|
| 12587 | + String programmax = |
---|
| 12588 | + "!!ARBfp1.0\n" + |
---|
| 12589 | + |
---|
12322 | 12590 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12323 | 12591 | "PARAM light2cam0 = program.env[10];" + |
---|
12324 | 12592 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12344 | 12612 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12345 | 12613 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12346 | 12614 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12347 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12615 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12348 | 12616 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12349 | 12617 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12350 | 12618 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12433 | 12701 | "TEMP shininess;" + |
---|
12434 | 12702 | "\n" + |
---|
12435 | 12703 | "MOV texSamp, one;" + |
---|
12436 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12437 | | - |
---|
| 12704 | + |
---|
12438 | 12705 | "MOV mapgrid.x, one2048th.x;" + |
---|
12439 | 12706 | "MOV temp, fragment.texcoord[1];" + |
---|
12440 | 12707 | /* |
---|
.. | .. |
---|
12455 | 12722 | "MUL temp, floor, mapgrid.x;" + |
---|
12456 | 12723 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12457 | 12724 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12458 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12725 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12459 | 12726 | "") + |
---|
12460 | 12727 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12461 | 12728 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12462 | 12729 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12463 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12730 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12464 | 12731 | "") + |
---|
12465 | 12732 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12466 | 12733 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12467 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12734 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12468 | 12735 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12469 | 12736 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12470 | 12737 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12471 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12738 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12472 | 12739 | "") + |
---|
12473 | 12740 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12474 | 12741 | //"MOV params, material;" + |
---|
.. | .. |
---|
12590 | 12857 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12591 | 12858 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12592 | 12859 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12593 | | - "KIL alpha.a;" + |
---|
| 12860 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12594 | 12861 | /* |
---|
12595 | 12862 | "MUL temp.xy, temp, two;" + |
---|
12596 | 12863 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12676 | 12943 | "SUB bump0, bump0, half;" + |
---|
12677 | 12944 | "ADD bump, bump, bump0;" + |
---|
12678 | 12945 | |
---|
12679 | | - "MOV temp.x, texSamp.a;" + |
---|
12680 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12681 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12682 | | - "MOV texSamp.a, temp.x;" + |
---|
12683 | | - |
---|
12684 | 12946 | // double-sided |
---|
12685 | 12947 | /**/ |
---|
12686 | 12948 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12690 | 12952 | "ADD temp.x, temp.x, one.x;" + |
---|
12691 | 12953 | "MUL normal, normal, temp.xxxx;":"" |
---|
12692 | 12954 | ) + |
---|
12693 | | - /**/ |
---|
12694 | | -//// Normalize("normal") + |
---|
12695 | | -//// "MAX normal.z, eps.x, normal.z;" + |
---|
12696 | | -// Normalize("normal") + |
---|
12697 | | - "MOV normald, normal;" + |
---|
12698 | | - "MOV normals, normal;" + |
---|
| 12955 | + /**/ |
---|
| 12956 | + |
---|
| 12957 | + "MOV temp, fragment.texcoord[4];" + |
---|
12699 | 12958 | |
---|
12700 | 12959 | // UV base |
---|
12701 | 12960 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12702 | 12961 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12703 | 12962 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12704 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12705 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12706 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12963 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12964 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12965 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12966 | + Normalize("UP") + |
---|
| 12967 | + |
---|
12707 | 12968 | "XPD V, normal, UP;" + |
---|
12708 | 12969 | Normalize("V") + |
---|
12709 | 12970 | "XPD U, V, normal;" + |
---|
12710 | 12971 | Normalize("U") + |
---|
12711 | 12972 | |
---|
| 12973 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12974 | + |
---|
| 12975 | +// "MAD normal, -temp.x, U, normal;" + |
---|
| 12976 | +// "MAD normal, -temp.y, V, normal;" + |
---|
| 12977 | +// Normalize("normal") + |
---|
| 12978 | + |
---|
| 12979 | +//// "MAX normal.z, eps.x, normal.z;" + |
---|
| 12980 | +// Normalize("normal") + |
---|
| 12981 | + "MOV normald, normal;" + |
---|
| 12982 | + "MOV normals, normal;" + |
---|
| 12983 | + |
---|
12712 | 12984 | // parallax mapping |
---|
| 12985 | + |
---|
| 12986 | + "DP3 temp2.x, V, eye;" + |
---|
| 12987 | + "DP3 temp2.y, U, eye;" + |
---|
| 12988 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12989 | + "RCP temp2.z, temp2.z;" + |
---|
| 12990 | + |
---|
| 12991 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12992 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12993 | + "RCP temp2.w, temp2.w;" + |
---|
| 12994 | + |
---|
| 12995 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12996 | + // "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12997 | + // "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12998 | + |
---|
| 12999 | + // "MOV texSamp, U;" + |
---|
| 13000 | + |
---|
| 13001 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 13002 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 13003 | + |
---|
| 13004 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 13005 | + |
---|
| 13006 | + "SUB temp, temp, temp2;" + |
---|
| 13007 | + |
---|
| 13008 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13009 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13010 | + |
---|
| 13011 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13012 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13013 | + |
---|
| 13014 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13015 | + |
---|
| 13016 | +// parallax mapping |
---|
| 13017 | + |
---|
| 13018 | + "MOV temp.x, texSamp.a;" + |
---|
| 13019 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13020 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13021 | + "MOV texSamp.a, temp.x;" + |
---|
12713 | 13022 | |
---|
12714 | 13023 | //"MOV temp, fragment.texcoord[0];" + |
---|
12715 | 13024 | // |
---|
.. | .. |
---|
12839 | 13148 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12840 | 13149 | "") + |
---|
12841 | 13150 | |
---|
12842 | | - // display shadow only (bump == 0) |
---|
| 13151 | + // display shadow only (fakedepth == 0) |
---|
12843 | 13152 | "SUB temp.x, half.x, shadow.x;" + |
---|
12844 | 13153 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12845 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13154 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12846 | 13155 | "SUB temp.y, one.x, temp.z;" + |
---|
12847 | 13156 | "MUL temp.x, temp.x, temp.y;" + |
---|
12848 | 13157 | "KIL temp.x;" + |
---|
.. | .. |
---|
13173 | 13482 | //once = true; |
---|
13174 | 13483 | } |
---|
13175 | 13484 | |
---|
13176 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13177 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13485 | + String program = programmax; |
---|
| 13486 | + |
---|
| 13487 | + if (Globals.MINSHADER) |
---|
| 13488 | + { |
---|
| 13489 | + program = programmin; |
---|
| 13490 | + } |
---|
| 13491 | + |
---|
| 13492 | + if (Globals.DEBUG) |
---|
| 13493 | + { |
---|
| 13494 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13495 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13496 | + } |
---|
| 13497 | + |
---|
13178 | 13498 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13179 | 13499 | |
---|
13180 | 13500 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13221 | 13541 | "\n" + |
---|
13222 | 13542 | "END\n"; |
---|
13223 | 13543 | |
---|
13224 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13544 | + if (Globals.DEBUG) |
---|
| 13545 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13225 | 13546 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13226 | 13547 | |
---|
13227 | 13548 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13266 | 13587 | return out; |
---|
13267 | 13588 | } |
---|
13268 | 13589 | |
---|
13269 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13590 | + // Also does frustum culling |
---|
| 13591 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13270 | 13592 | { |
---|
13271 | 13593 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13272 | 13594 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13273 | 13595 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13596 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13597 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13274 | 13598 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13275 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13276 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13277 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13278 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13599 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13600 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13279 | 13601 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13280 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13602 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13281 | 13603 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13282 | 13604 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13283 | 13605 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13284 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13606 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13285 | 13607 | |
---|
13286 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13287 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13608 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13609 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13288 | 13610 | } |
---|
13289 | 13611 | |
---|
13290 | 13612 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13331 | 13653 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13332 | 13654 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13333 | 13655 | |
---|
13334 | | - // No shadow when out of frustrum |
---|
| 13656 | + // No shadow when out of frustum |
---|
13335 | 13657 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13336 | 13658 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13337 | 13659 | ""; |
---|
.. | .. |
---|
13478 | 13800 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13479 | 13801 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13480 | 13802 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13481 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13803 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13482 | 13804 | |
---|
13483 | 13805 | //Object3D.cVector2[] vector2buffer; |
---|
13484 | 13806 | |
---|
.. | .. |
---|
13645 | 13967 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13646 | 13968 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13647 | 13969 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13648 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13970 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13649 | 13971 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13650 | 13972 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13651 | 13973 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13706 | 14028 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13707 | 14029 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13708 | 14030 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13709 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14031 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13710 | 14032 | "MOV result.texcoord, temp;" + |
---|
13711 | 14033 | // border fade |
---|
13712 | 14034 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13753 | 14075 | |
---|
13754 | 14076 | //"ADD temp.z, temp.z, one;" + |
---|
13755 | 14077 | |
---|
13756 | | - "MOV result.color, temp;" |
---|
| 14078 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14079 | + |
---|
| 14080 | + "MOV result.color, temp;" // Normal |
---|
13757 | 14081 | : "MOV result.color, vertex.color;") + |
---|
13758 | 14082 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13759 | 14083 | : "") + |
---|
.. | .. |
---|
14129 | 14453 | drag = false; |
---|
14130 | 14454 | //System.out.println("Mouse DOWN"); |
---|
14131 | 14455 | editObj = false; |
---|
14132 | | - ClickInfo info = new ClickInfo(); |
---|
14133 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14134 | | - info.pane = this; |
---|
14135 | | - info.camera = renderCamera; |
---|
14136 | | - info.x = x; |
---|
14137 | | - info.y = y; |
---|
14138 | | - info.modifiers = modifiersex; |
---|
14139 | | - editObj = object.doEditClick(info, 0); |
---|
| 14456 | + //ClickInfo info = new ClickInfo(); |
---|
| 14457 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14458 | + object.clickInfo.pane = this; |
---|
| 14459 | + object.clickInfo.camera = renderCamera; |
---|
| 14460 | + object.clickInfo.x = x; |
---|
| 14461 | + object.clickInfo.y = y; |
---|
| 14462 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14463 | + editObj = object.doEditClick(//info, |
---|
| 14464 | + 0); |
---|
14140 | 14465 | if (!editObj) |
---|
14141 | 14466 | { |
---|
14142 | 14467 | hasMarquee = true; |
---|
.. | .. |
---|
14411 | 14736 | } |
---|
14412 | 14737 | } |
---|
14413 | 14738 | PingThread pingthread = new PingThread(); |
---|
14414 | | - int delta = 5; |
---|
14415 | | - int speed = 5; |
---|
| 14739 | + int delta = 2; |
---|
| 14740 | + int speed = 10; |
---|
14416 | 14741 | boolean autorepeat = false; |
---|
14417 | 14742 | |
---|
14418 | 14743 | void GoDown(int mod) |
---|
14419 | 14744 | { |
---|
14420 | 14745 | MODIFIERS |= COMMAND; |
---|
| 14746 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14421 | 14747 | /**/ |
---|
14422 | 14748 | if((mod&SHIFT) == SHIFT) |
---|
14423 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14749 | + { |
---|
| 14750 | + if (isVR) |
---|
| 14751 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14752 | + else |
---|
| 14753 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14754 | + } |
---|
14424 | 14755 | else |
---|
14425 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14756 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14426 | 14757 | /**/ |
---|
14427 | 14758 | if ((mod & SHIFT) == SHIFT) |
---|
14428 | 14759 | { |
---|
.. | .. |
---|
14432 | 14763 | mouseMode |= BACKFORTH; |
---|
14433 | 14764 | } |
---|
14434 | 14765 | |
---|
| 14766 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14767 | + |
---|
14435 | 14768 | //prevX = X = anchorX; |
---|
14436 | 14769 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14437 | 14770 | } |
---|
.. | .. |
---|
14440 | 14773 | { |
---|
14441 | 14774 | MODIFIERS |= COMMAND; |
---|
14442 | 14775 | /**/ |
---|
| 14776 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14777 | + |
---|
14443 | 14778 | if((mod&SHIFT) == SHIFT) |
---|
14444 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14779 | + { |
---|
| 14780 | + if (isVR) |
---|
| 14781 | + manipCamera.RotateInterest(0, speed); |
---|
| 14782 | + else |
---|
| 14783 | + manipCamera.RotatePosition(0, speed); |
---|
| 14784 | + } |
---|
14445 | 14785 | else |
---|
14446 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14786 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14447 | 14787 | /**/ |
---|
14448 | 14788 | if ((mod & SHIFT) == SHIFT) |
---|
14449 | 14789 | { |
---|
.. | .. |
---|
14453 | 14793 | mouseMode |= BACKFORTH; |
---|
14454 | 14794 | } |
---|
14455 | 14795 | |
---|
| 14796 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14797 | + |
---|
14456 | 14798 | //prevX = X = anchorX; |
---|
14457 | 14799 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14458 | 14800 | } |
---|
.. | .. |
---|
14462 | 14804 | MODIFIERS |= COMMAND; |
---|
14463 | 14805 | /**/ |
---|
14464 | 14806 | if((mod&SHIFT) == SHIFT) |
---|
14465 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14807 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14466 | 14808 | else |
---|
14467 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14809 | + { |
---|
| 14810 | + if ((mouseMode&VR)!=0) |
---|
| 14811 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14812 | + else |
---|
| 14813 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14814 | + } |
---|
14468 | 14815 | /**/ |
---|
14469 | 14816 | if ((mod & SHIFT) == SHIFT) |
---|
14470 | 14817 | { |
---|
.. | .. |
---|
14474 | 14821 | mouseMode |= ROTATE; |
---|
14475 | 14822 | } // TRANSLATE; |
---|
14476 | 14823 | |
---|
| 14824 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14825 | + |
---|
14477 | 14826 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14478 | 14827 | prevY = Y = anchorY; |
---|
14479 | 14828 | } |
---|
.. | .. |
---|
14483 | 14832 | MODIFIERS |= COMMAND; |
---|
14484 | 14833 | /**/ |
---|
14485 | 14834 | if((mod&SHIFT) == SHIFT) |
---|
14486 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14835 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14487 | 14836 | else |
---|
14488 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14837 | + { |
---|
| 14838 | + if ((mouseMode&VR)!=0) |
---|
| 14839 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14840 | + else |
---|
| 14841 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14842 | + } |
---|
| 14843 | + |
---|
14489 | 14844 | /**/ |
---|
14490 | 14845 | if ((mod & SHIFT) == SHIFT) |
---|
14491 | 14846 | { |
---|
.. | .. |
---|
14495 | 14850 | mouseMode |= ROTATE; |
---|
14496 | 14851 | } // TRANSLATE; |
---|
14497 | 14852 | |
---|
| 14853 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14854 | + |
---|
14498 | 14855 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14499 | 14856 | prevY = Y = anchorY; |
---|
14500 | 14857 | } |
---|
.. | .. |
---|
14536 | 14893 | if (editObj) |
---|
14537 | 14894 | { |
---|
14538 | 14895 | drag = true; |
---|
14539 | | - ClickInfo info = new ClickInfo(); |
---|
14540 | | - info.bounds.setBounds(0, 0, |
---|
| 14896 | + //ClickInfo info = new ClickInfo(); |
---|
| 14897 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14541 | 14898 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14542 | | - info.pane = this; |
---|
14543 | | - info.camera = renderCamera; |
---|
14544 | | - info.x = x; |
---|
14545 | | - info.y = y; |
---|
14546 | | - object.GetWindow().copy |
---|
14547 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14899 | + object.clickInfo.pane = this; |
---|
| 14900 | + object.clickInfo.camera = renderCamera; |
---|
| 14901 | + object.clickInfo.x = x; |
---|
| 14902 | + object.clickInfo.y = y; |
---|
| 14903 | + object //.GetWindow().copy |
---|
| 14904 | + .doEditDrag(//info, |
---|
| 14905 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14548 | 14906 | } else |
---|
14549 | 14907 | { |
---|
14550 | 14908 | if (x < startX) |
---|
.. | .. |
---|
14693 | 15051 | } |
---|
14694 | 15052 | } |
---|
14695 | 15053 | |
---|
| 15054 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15055 | + |
---|
14696 | 15056 | public void mouseMoved(MouseEvent e) |
---|
14697 | 15057 | { |
---|
14698 | 15058 | //System.out.println("mouseMoved: " + e); |
---|
14699 | 15059 | if (isRenderer) |
---|
14700 | 15060 | return; |
---|
14701 | 15061 | |
---|
14702 | | - ClickInfo ci = new ClickInfo(); |
---|
14703 | | - ci.x = e.getX(); |
---|
14704 | | - ci.y = e.getY(); |
---|
14705 | | - ci.modifiers = e.getModifiersEx(); |
---|
14706 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14707 | | - ci.pane = this; |
---|
14708 | | - ci.camera = renderCamera; |
---|
| 15062 | + // Mouse cursor feedback |
---|
| 15063 | + object.clickInfo.x = e.getX(); |
---|
| 15064 | + object.clickInfo.y = e.getY(); |
---|
| 15065 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15066 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15067 | + object.clickInfo.pane = this; |
---|
| 15068 | + object.clickInfo.camera = renderCamera; |
---|
14709 | 15069 | if (!isRenderer) |
---|
14710 | 15070 | { |
---|
14711 | 15071 | //ObjEditor editWindow = object.editWindow; |
---|
14712 | 15072 | //Object3D copy = editWindow.copy; |
---|
14713 | | - if (object.doEditClick(ci, 0)) |
---|
| 15073 | + if (object.doEditClick(//clickInfo, |
---|
| 15074 | + 0)) |
---|
14714 | 15075 | { |
---|
14715 | 15076 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14716 | 15077 | } else |
---|
.. | .. |
---|
14993 | 15354 | case 'K': |
---|
14994 | 15355 | KOMPACTTEXTURE ^= true; |
---|
14995 | 15356 | //textures.clear(); |
---|
14996 | | - break; |
---|
14997 | | - case 'P': // Texture Projection macros |
---|
| 15357 | + // break; |
---|
| 15358 | + //case 'P': // Texture Projection macros |
---|
14998 | 15359 | // SAVETEXTURE ^= true; |
---|
14999 | 15360 | macromode = true; |
---|
15000 | 15361 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15115 | 15476 | targetLookAt.set(manipCamera.lookAt); |
---|
15116 | 15477 | repaint(); |
---|
15117 | 15478 | break; |
---|
15118 | | - case 'p': |
---|
| 15479 | + case 'P': // p': |
---|
15119 | 15480 | // c'est quoi ca au juste? spherical ^= true; |
---|
15120 | 15481 | Skinshader ^= true; programInitialized = false; |
---|
15121 | 15482 | repaint(); |
---|
.. | .. |
---|
15153 | 15514 | repaint(); |
---|
15154 | 15515 | break; |
---|
15155 | 15516 | case 'O': |
---|
15156 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15517 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
15157 | 15518 | repaint(); |
---|
15158 | 15519 | break; |
---|
15159 | 15520 | case 'o': |
---|
15160 | 15521 | OCCLUSION_CULLING ^= true; |
---|
15161 | 15522 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15162 | 15523 | break; |
---|
15163 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15524 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15164 | 15525 | case '1': |
---|
15165 | 15526 | case '2': |
---|
15166 | 15527 | case '3': |
---|
15167 | 15528 | case '4': |
---|
15168 | 15529 | case '5': |
---|
15169 | | - newenvy = Character.getNumericValue(key); |
---|
15170 | | - repaint(); |
---|
15171 | | - break; |
---|
15172 | 15530 | case '6': |
---|
15173 | 15531 | case '7': |
---|
15174 | 15532 | case '8': |
---|
15175 | 15533 | case '9': |
---|
15176 | | - BGcolor = (key - '6')/3.f; |
---|
| 15534 | + if (true) // envyoff) |
---|
| 15535 | + { |
---|
| 15536 | + BGcolor = (key - '1')/8.f; |
---|
| 15537 | + } |
---|
| 15538 | + else |
---|
| 15539 | + { |
---|
| 15540 | + //newenvy = Character.getNumericValue(key); |
---|
| 15541 | + } |
---|
15177 | 15542 | repaint(); |
---|
15178 | 15543 | break; |
---|
15179 | 15544 | case '!': |
---|
.. | .. |
---|
15736 | 16101 | |
---|
15737 | 16102 | int width = getBounds().width; |
---|
15738 | 16103 | int height = getBounds().height; |
---|
15739 | | - ClickInfo info = new ClickInfo(); |
---|
15740 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15741 | 16104 | //Image img = CreateImage(width, height); |
---|
15742 | 16105 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15743 | 16106 | |
---|
.. | .. |
---|
15814 | 16177 | } |
---|
15815 | 16178 | if (object != null && !hasMarquee) |
---|
15816 | 16179 | { |
---|
| 16180 | + if (object.clickInfo == null) |
---|
| 16181 | + object.clickInfo = new ClickInfo(); |
---|
| 16182 | + ClickInfo info = object.clickInfo; |
---|
| 16183 | + //ClickInfo info = new ClickInfo(); |
---|
| 16184 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16185 | + |
---|
15817 | 16186 | if (isRenderer) |
---|
15818 | 16187 | { |
---|
15819 | | - info.flags++; |
---|
| 16188 | + object.clickInfo.flags++; |
---|
15820 | 16189 | double frameAspect = (double) width / (double) height; |
---|
15821 | 16190 | if (frameAspect > renderCamera.aspect) |
---|
15822 | 16191 | { |
---|
15823 | 16192 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15824 | | - info.bounds.width -= width - desired; |
---|
15825 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16193 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16194 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15826 | 16195 | } else |
---|
15827 | 16196 | { |
---|
15828 | 16197 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15829 | | - info.bounds.height -= height - desired; |
---|
15830 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16198 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16199 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15831 | 16200 | } |
---|
15832 | 16201 | } |
---|
15833 | 16202 | |
---|
15834 | | - info.g = gr; |
---|
15835 | | - info.camera = renderCamera; |
---|
| 16203 | + object.clickInfo.g = gr; |
---|
| 16204 | + object.clickInfo.camera = renderCamera; |
---|
15836 | 16205 | /* |
---|
15837 | 16206 | // Memory intensive (brep.verticescopy) |
---|
15838 | 16207 | if (!(object instanceof Composite)) |
---|
15839 | 16208 | object.draw(info, 0, false); // SLOW : |
---|
15840 | 16209 | */ |
---|
15841 | | - if (!isRenderer) |
---|
| 16210 | + if (!isRenderer) // && drag) |
---|
15842 | 16211 | { |
---|
15843 | 16212 | Grafreed.Assert(object != null); |
---|
15844 | 16213 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15846 | 16215 | { |
---|
15847 | 16216 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15848 | 16217 | |
---|
15849 | | - info.DX = 0; |
---|
15850 | | - info.DY = 0; |
---|
15851 | | - info.W = 1; |
---|
| 16218 | + object.clickInfo.DX = 0; |
---|
| 16219 | + object.clickInfo.DY = 0; |
---|
| 16220 | + object.clickInfo.W = 1; |
---|
15852 | 16221 | if (hitSomething == Object3D.hitCenter) |
---|
15853 | 16222 | { |
---|
15854 | 16223 | info.DX = X; |
---|
.. | .. |
---|
15860 | 16229 | info.DY -= info.bounds.height/2; |
---|
15861 | 16230 | } |
---|
15862 | 16231 | |
---|
15863 | | - object.drawEditHandles(info, 0); |
---|
| 16232 | + object.drawEditHandles(//info, |
---|
| 16233 | + 0); |
---|
15864 | 16234 | |
---|
15865 | 16235 | if (drag && (X != 0 || Y != 0)) |
---|
15866 | 16236 | { |
---|
15867 | 16237 | switch (hitSomething) |
---|
15868 | 16238 | { |
---|
15869 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16239 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
15870 | 16240 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15871 | 16241 | break; |
---|
15872 | 16242 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
15892 | 16262 | if (hasMarquee) |
---|
15893 | 16263 | { |
---|
15894 | 16264 | gr.setXORMode(Color.white); |
---|
15895 | | - gr.setColor(Color.red); |
---|
| 16265 | + gr.setColor(Color.white); |
---|
15896 | 16266 | if (!firstime) |
---|
15897 | 16267 | { |
---|
15898 | 16268 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16359 | 16729 | private /*static*/ boolean firstime; |
---|
16360 | 16730 | private /*static*/ cVector newView = new cVector(); |
---|
16361 | 16731 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16732 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16733 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16362 | 16734 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16363 | 16735 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16364 | 16736 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16371 | 16743 | { |
---|
16372 | 16744 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16373 | 16745 | |
---|
| 16746 | + int usedsuf = 0; |
---|
| 16747 | + |
---|
16374 | 16748 | for (int i = 0; i < suffixes.length; i++) |
---|
16375 | 16749 | { |
---|
16376 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16377 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16378 | | - mipmapped, |
---|
16379 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16380 | | - if (data == null) |
---|
| 16750 | + String[] suffixe = suffixes; |
---|
| 16751 | + String[] fallback = suffixes2; |
---|
| 16752 | + String[] fallfallback = suffixes3; |
---|
| 16753 | + |
---|
| 16754 | + for (int c=usedsuf; --c>=0;) |
---|
16381 | 16755 | { |
---|
16382 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16756 | +// String[] temp = suffixe; |
---|
| 16757 | +// suffixe = fallback; |
---|
| 16758 | +// fallback = fallfallback; |
---|
| 16759 | +// fallfallback = temp; |
---|
16383 | 16760 | } |
---|
| 16761 | + |
---|
| 16762 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16763 | + TextureData data; |
---|
| 16764 | + |
---|
| 16765 | + try |
---|
| 16766 | + { |
---|
| 16767 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16768 | + mipmapped, |
---|
| 16769 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16770 | + } |
---|
| 16771 | + catch (Exception e) |
---|
| 16772 | + { |
---|
| 16773 | + try |
---|
| 16774 | + { |
---|
| 16775 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16776 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16777 | + mipmapped, |
---|
| 16778 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16779 | + } |
---|
| 16780 | + catch (Exception e2) |
---|
| 16781 | + { |
---|
| 16782 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16783 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16784 | + mipmapped, |
---|
| 16785 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16786 | + } |
---|
| 16787 | + } |
---|
| 16788 | + |
---|
16384 | 16789 | //System.out.println("Target = " + targets[i]); |
---|
16385 | 16790 | cubemap.updateImage(data, targets[i]); |
---|
16386 | 16791 | } |
---|
16387 | 16792 | |
---|
16388 | 16793 | return cubemap; |
---|
16389 | 16794 | } |
---|
| 16795 | + |
---|
16390 | 16796 | int bigsphere = -1; |
---|
16391 | 16797 | |
---|
16392 | 16798 | float BGcolor = 0.5f; |
---|
16393 | 16799 | |
---|
16394 | | - private void DrawSkyBox(GL gl) |
---|
| 16800 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16801 | + |
---|
| 16802 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16395 | 16803 | { |
---|
16396 | | - if (envyoff || cubemap == null) |
---|
| 16804 | + if (//envyoff || |
---|
| 16805 | + WIREFRAME || |
---|
| 16806 | + cubemap == null) |
---|
16397 | 16807 | { |
---|
16398 | 16808 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16399 | 16809 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16408 | 16818 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16409 | 16819 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16410 | 16820 | gl.glLoadIdentity(); |
---|
| 16821 | + gl.glScalef(1,ratio,1); |
---|
16411 | 16822 | |
---|
| 16823 | +// colorV[0] = 2; |
---|
| 16824 | +// colorV[1] = 2; |
---|
| 16825 | +// colorV[2] = 2; |
---|
| 16826 | +// colorV[3] = 1; |
---|
| 16827 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16828 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16829 | +// |
---|
| 16830 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16831 | + |
---|
16412 | 16832 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16413 | 16833 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16414 | 16834 | |
---|
.. | .. |
---|
16440 | 16860 | { |
---|
16441 | 16861 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16442 | 16862 | } |
---|
| 16863 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16443 | 16864 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16444 | 16865 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16445 | 16866 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16480 | 16901 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16481 | 16902 | |
---|
16482 | 16903 | cubemap.disable(); |
---|
16483 | | - ////cubemap.unbind(); |
---|
| 16904 | + //cubemap.dispose(); |
---|
| 16905 | + |
---|
16484 | 16906 | if (CULLFACE) |
---|
16485 | 16907 | { |
---|
16486 | 16908 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16536 | 16958 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16537 | 16959 | } |
---|
16538 | 16960 | |
---|
16539 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16961 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16540 | 16962 | |
---|
16541 | 16963 | float step = 2; // 0.1666f; //0.25f; |
---|
16542 | 16964 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16698 | 17120 | //new Exception().printStackTrace(); |
---|
16699 | 17121 | System.out.println("select buffer init"); |
---|
16700 | 17122 | // Use debug pipeline |
---|
16701 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17123 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16702 | 17124 | |
---|
16703 | 17125 | GL gl = drawable.getGL(); |
---|
16704 | 17126 | |
---|
.. | .. |
---|
17016 | 17438 | |
---|
17017 | 17439 | public void init(GLAutoDrawable drawable) |
---|
17018 | 17440 | { |
---|
| 17441 | + if (Globals.DEBUG) |
---|
17019 | 17442 | System.out.println("shadow buffer init"); |
---|
17020 | 17443 | |
---|
17021 | 17444 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17244 | 17667 | gl.glFlush(); |
---|
17245 | 17668 | |
---|
17246 | 17669 | /**/ |
---|
17247 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17670 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17248 | 17671 | |
---|
17249 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17672 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17250 | 17673 | |
---|
| 17674 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17675 | + |
---|
| 17676 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17677 | + |
---|
17251 | 17678 | double r = 0, g = 0, b = 0; |
---|
17252 | 17679 | |
---|
17253 | 17680 | double count = 0; |
---|
.. | .. |
---|
17258 | 17685 | |
---|
17259 | 17686 | double FACTOR = 1; |
---|
17260 | 17687 | |
---|
17261 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17688 | + for (int i = 0; i < depths.length; i++) |
---|
17262 | 17689 | { |
---|
17263 | 17690 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17264 | 17691 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17341 | 17768 | |
---|
17342 | 17769 | double scale = ray.z; // 1; // cos |
---|
17343 | 17770 | |
---|
17344 | | - float depth = pixels[newindex]; |
---|
| 17771 | + float depth = depths[newindex]; |
---|
17345 | 17772 | |
---|
17346 | 17773 | /* |
---|
17347 | 17774 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17538 | 17965 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17539 | 17966 | static IntBuffer bigAAbuffer; |
---|
17540 | 17967 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17541 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17968 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17542 | 17969 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17543 | 17970 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17544 | 17971 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17545 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17972 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17973 | + |
---|
| 17974 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17975 | + |
---|
17546 | 17976 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17547 | 17977 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17548 | 17978 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|