.. | .. |
---|
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 | { |
---|
.. | .. |
---|
44 | 48 | static boolean ABORTED = false; |
---|
45 | 49 | |
---|
46 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
47 | 84 | |
---|
48 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
60 | 97 | //boolean REDUCETEXTURE = true; |
---|
61 | 98 | boolean CACHETEXTURE = true; |
---|
62 | 99 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
64 | 101 | boolean COMPRESSTEXTURE = false; |
---|
65 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
73 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
74 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
75 | 112 | static GLContext glcontext = null; |
---|
76 | | - /*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 | + |
---|
77 | 118 | boolean reverseUP = false; |
---|
78 | 119 | static boolean frozen = false; |
---|
79 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
127 | 168 | |
---|
128 | 169 | |
---|
129 | 170 | // OPTIONS |
---|
130 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
131 | 172 | boolean cameraLight = false; |
---|
132 | 173 | boolean UVdebug = false; |
---|
133 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
136 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
137 | 178 | boolean anisotropy = true; |
---|
138 | 179 | boolean softshadow = true; // slower but better false; |
---|
139 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
140 | 181 | |
---|
141 | 182 | boolean macromode = false; |
---|
142 | 183 | |
---|
.. | .. |
---|
150 | 191 | } |
---|
151 | 192 | |
---|
152 | 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 | + } |
---|
153 | 207 | |
---|
154 | 208 | void SetAsGLRenderer(boolean b) |
---|
155 | 209 | { |
---|
.. | .. |
---|
169 | 223 | |
---|
170 | 224 | SetCamera(cam); |
---|
171 | 225 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 228 | |
---|
174 | 229 | object = o; |
---|
175 | 230 | |
---|
.. | .. |
---|
487 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
488 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
489 | 544 | LA.vecNormalize(obj.v2); |
---|
490 | | - 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); |
---|
491 | 547 | } |
---|
492 | 548 | |
---|
493 | 549 | // P |
---|
.. | .. |
---|
509 | 565 | y += ny * obj.NORMALPUSH; |
---|
510 | 566 | z += nz * obj.NORMALPUSH; |
---|
511 | 567 | |
---|
512 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
513 | 569 | } |
---|
514 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
515 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
541 | 597 | y += ny * obj.NORMALPUSH; |
---|
542 | 598 | z += nz * obj.NORMALPUSH; |
---|
543 | 599 | |
---|
544 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
545 | 601 | } |
---|
546 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
547 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
589 | 645 | y += ny * obj.NORMALPUSH; |
---|
590 | 646 | z += nz * obj.NORMALPUSH; |
---|
591 | 647 | |
---|
592 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
593 | 649 | } |
---|
594 | 650 | |
---|
595 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
1195 | 1251 | { |
---|
1196 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1197 | 1253 | { |
---|
1198 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1199 | 1255 | } else |
---|
1200 | 1256 | { |
---|
1201 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1202 | 1258 | } |
---|
1203 | 1259 | |
---|
1204 | 1260 | if (c != null) |
---|
.. | .. |
---|
1222 | 1278 | { |
---|
1223 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1224 | 1280 | { |
---|
1225 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1226 | 1282 | } else |
---|
1227 | 1283 | { |
---|
1228 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1229 | 1285 | } |
---|
1230 | 1286 | if (c != null) |
---|
1231 | 1287 | { |
---|
.. | .. |
---|
1250 | 1306 | { |
---|
1251 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1252 | 1308 | { |
---|
1253 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1254 | 1310 | } else |
---|
1255 | 1311 | { |
---|
1256 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1257 | 1313 | } |
---|
1258 | 1314 | if (c != null) |
---|
1259 | 1315 | { |
---|
.. | .. |
---|
1435 | 1491 | { |
---|
1436 | 1492 | if (!selectmode) |
---|
1437 | 1493 | { |
---|
1438 | | - 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); |
---|
1439 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1440 | 1496 | |
---|
1441 | 1497 | if (flipV) |
---|
.. | .. |
---|
1447 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1448 | 1504 | } |
---|
1449 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1450 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1451 | 1509 | { |
---|
1452 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1514 | 1572 | { |
---|
1515 | 1573 | return; |
---|
1516 | 1574 | } |
---|
1517 | | - |
---|
1518 | | - float[] colorV = new float[3]; |
---|
1519 | 1575 | |
---|
1520 | 1576 | if (false) // marked) |
---|
1521 | 1577 | { |
---|
.. | .. |
---|
1764 | 1820 | |
---|
1765 | 1821 | display.modelParams7[0] = 0; |
---|
1766 | 1822 | display.modelParams7[1] = 1000; |
---|
1767 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1768 | 1824 | display.modelParams7[3] = 0; |
---|
1769 | 1825 | |
---|
1770 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
1997 | 2053 | switch(viewcode) |
---|
1998 | 2054 | { |
---|
1999 | 2055 | case 0: return "main"; |
---|
2000 | | - case 1: return "one"; |
---|
2001 | | - case 2: return "two"; |
---|
2002 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2003 | 2059 | case 4: return "light"; |
---|
2004 | 2060 | } |
---|
2005 | 2061 | |
---|
.. | .. |
---|
2065 | 2121 | //System.err.println("Oeil on"); |
---|
2066 | 2122 | OEIL = true; |
---|
2067 | 2123 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2068 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2124 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2069 | 2125 | //pingthread.StepToTarget(true); |
---|
2070 | 2126 | } |
---|
2071 | 2127 | |
---|
.. | .. |
---|
2298 | 2354 | HANDLES ^= true; |
---|
2299 | 2355 | } |
---|
2300 | 2356 | |
---|
| 2357 | + Object3D paintFolder; |
---|
| 2358 | + |
---|
2301 | 2359 | void TogglePaint() |
---|
2302 | 2360 | { |
---|
2303 | 2361 | PAINTMODE ^= true; |
---|
2304 | 2362 | paintcount = 0; |
---|
| 2363 | + |
---|
| 2364 | + if (PAINTMODE) |
---|
| 2365 | + { |
---|
| 2366 | + paintFolder = GetFolder(); |
---|
| 2367 | + } |
---|
2305 | 2368 | } |
---|
2306 | 2369 | |
---|
2307 | 2370 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2398 | 2461 | return currentGL; |
---|
2399 | 2462 | } |
---|
2400 | 2463 | |
---|
| 2464 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2465 | + { |
---|
| 2466 | + Grafreed.Assert(texturedata != null); |
---|
| 2467 | + |
---|
| 2468 | + int width = texturedata.getWidth(); |
---|
| 2469 | + int height = texturedata.getHeight(); |
---|
| 2470 | + |
---|
| 2471 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2472 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2473 | + |
---|
| 2474 | + byte[] bytes = bytebuf.array(); |
---|
| 2475 | + |
---|
| 2476 | + return CreateBim(bytes, width, height); |
---|
| 2477 | + } |
---|
| 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 | + |
---|
2401 | 2491 | /**/ |
---|
2402 | 2492 | class CacheTexture |
---|
2403 | 2493 | { |
---|
.. | .. |
---|
2406 | 2496 | |
---|
2407 | 2497 | int resolution; |
---|
2408 | 2498 | |
---|
2409 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2499 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2410 | 2500 | { |
---|
2411 | | - texture = tex; |
---|
| 2501 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2502 | + texturedata = texdata; |
---|
2412 | 2503 | resolution = res; |
---|
2413 | 2504 | } |
---|
2414 | 2505 | } |
---|
2415 | 2506 | /**/ |
---|
2416 | 2507 | |
---|
2417 | 2508 | // TEXTURE static Texture texture; |
---|
2418 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2419 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2420 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2509 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2510 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2511 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2512 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2513 | + |
---|
2421 | 2514 | int pigmentdepth = 0; |
---|
2422 | 2515 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2423 | 2516 | int bumpdepth = 0; |
---|
2424 | 2517 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2425 | 2518 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2426 | 2519 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2427 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2520 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2428 | 2521 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2429 | 2522 | |
---|
2430 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2523 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2431 | 2524 | { |
---|
2432 | 2525 | TextureData texturedata = null; |
---|
2433 | 2526 | |
---|
.. | .. |
---|
2437 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2438 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2439 | 2532 | true, |
---|
2440 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2441 | 2534 | } catch (java.io.IOException e) |
---|
2442 | 2535 | { |
---|
2443 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2446 | 2539 | if (bump) |
---|
2447 | 2540 | texturedata = ConvertBump(texturedata, false); |
---|
2448 | 2541 | |
---|
2449 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2450 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2542 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2543 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2451 | 2544 | |
---|
2452 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2453 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2545 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2546 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2454 | 2547 | |
---|
2455 | | - return texture; |
---|
| 2548 | + return texturedata; |
---|
| 2549 | + } |
---|
| 2550 | + |
---|
| 2551 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2552 | + { |
---|
| 2553 | + TextureData texturedata = null; |
---|
| 2554 | + |
---|
| 2555 | + try |
---|
| 2556 | + { |
---|
| 2557 | + texturedata = |
---|
| 2558 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2559 | + bim, |
---|
| 2560 | + true); |
---|
| 2561 | + } catch (Exception e) |
---|
| 2562 | + { |
---|
| 2563 | + throw new javax.media.opengl.GLException(e); |
---|
| 2564 | + } |
---|
| 2565 | + |
---|
| 2566 | + if (bump) |
---|
| 2567 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2568 | + |
---|
| 2569 | + return texturedata; |
---|
2456 | 2570 | } |
---|
2457 | 2571 | |
---|
2458 | 2572 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3525 | 3639 | |
---|
3526 | 3640 | System.out.println("LOADING TEXTURE : " + name); |
---|
3527 | 3641 | |
---|
| 3642 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3643 | + |
---|
3528 | 3644 | // |
---|
3529 | 3645 | if (false) // compressbit > 0) |
---|
3530 | 3646 | { |
---|
.. | .. |
---|
7923 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
7924 | 8040 | String bump = Object3D.GetBump(tex); |
---|
7925 | 8041 | |
---|
7926 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7927 | 8043 | { |
---|
7928 | 8044 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7929 | 8045 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7938 | 8054 | pigment = null; |
---|
7939 | 8055 | } |
---|
7940 | 8056 | |
---|
7941 | | - ReleaseTexture(bump, true); |
---|
7942 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, true); |
---|
| 8058 | + ReleaseTexture(tex, false); |
---|
7943 | 8059 | } |
---|
7944 | 8060 | |
---|
7945 | 8061 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7957 | 8073 | |
---|
7958 | 8074 | String pigment = Object3D.GetPigment(tex); |
---|
7959 | 8075 | |
---|
7960 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8076 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7961 | 8077 | { |
---|
7962 | 8078 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7963 | 8079 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7968 | 8084 | pigment = null; |
---|
7969 | 8085 | } |
---|
7970 | 8086 | |
---|
7971 | | - ReleaseTexture(pigment, false); |
---|
| 8087 | + ReleaseTexture(tex, false); |
---|
7972 | 8088 | } |
---|
7973 | 8089 | |
---|
7974 | 8090 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7986 | 8102 | |
---|
7987 | 8103 | String bump = Object3D.GetBump(tex); |
---|
7988 | 8104 | |
---|
7989 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8105 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7990 | 8106 | { |
---|
7991 | 8107 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7992 | 8108 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7997 | 8113 | bump = null; |
---|
7998 | 8114 | } |
---|
7999 | 8115 | |
---|
8000 | | - ReleaseTexture(bump, true); |
---|
| 8116 | + ReleaseTexture(tex, true); |
---|
8001 | 8117 | } |
---|
8002 | 8118 | |
---|
8003 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8119 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8004 | 8120 | { |
---|
8005 | 8121 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8006 | 8122 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8011 | 8127 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8012 | 8128 | |
---|
8013 | 8129 | if (tex != null) |
---|
8014 | | - texture = textures.get(tex); |
---|
| 8130 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8015 | 8131 | |
---|
8016 | 8132 | // //assert( texture != null ); |
---|
8017 | 8133 | // if (texture == null) |
---|
.. | .. |
---|
8105 | 8221 | |
---|
8106 | 8222 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8107 | 8223 | { |
---|
8108 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8109 | | - ambientOcclusion ) // || !textureon) |
---|
8110 | | - { |
---|
8111 | | - return; // false; |
---|
8112 | | - } |
---|
8113 | | - |
---|
8114 | | - if (tex == null) |
---|
8115 | | - { |
---|
8116 | | - BindTexture(null,false,resolution); |
---|
8117 | | - BindTexture(null,true,resolution); |
---|
8118 | | - return; |
---|
8119 | | - } |
---|
| 8224 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8225 | +// ambientOcclusion ) // || !textureon) |
---|
| 8226 | +// { |
---|
| 8227 | +// return; // false; |
---|
| 8228 | +// } |
---|
| 8229 | +// |
---|
| 8230 | +// if (tex == null) |
---|
| 8231 | +// { |
---|
| 8232 | +// BindTexture(null,false,resolution); |
---|
| 8233 | +// BindTexture(null,true,resolution); |
---|
| 8234 | +// return; |
---|
| 8235 | +// } |
---|
| 8236 | +// |
---|
| 8237 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8238 | +// String bump = Object3D.GetBump(tex); |
---|
| 8239 | +// |
---|
| 8240 | +// usedtextures.add(pigment); |
---|
| 8241 | +// usedtextures.add(bump); |
---|
| 8242 | +// |
---|
| 8243 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8244 | +// { |
---|
| 8245 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8246 | +// // System.out.println("; bump = " + bump); |
---|
| 8247 | +// } |
---|
| 8248 | +// |
---|
| 8249 | +// if (bump.equals("")) |
---|
| 8250 | +// { |
---|
| 8251 | +// bump = null; |
---|
| 8252 | +// } |
---|
| 8253 | +// if (pigment.equals("")) |
---|
| 8254 | +// { |
---|
| 8255 | +// pigment = null; |
---|
| 8256 | +// } |
---|
| 8257 | +// |
---|
| 8258 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8259 | +// BindTexture(pigment, false, resolution); |
---|
| 8260 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8261 | +// BindTexture(bump, true, resolution); |
---|
| 8262 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8263 | +// |
---|
| 8264 | +// return; // true; |
---|
8120 | 8265 | |
---|
8121 | | - String pigment = Object3D.GetPigment(tex); |
---|
8122 | | - String bump = Object3D.GetBump(tex); |
---|
8123 | | - |
---|
8124 | | - usedtextures.put(pigment, pigment); |
---|
8125 | | - usedtextures.put(bump, bump); |
---|
8126 | | - |
---|
8127 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8128 | | - { |
---|
8129 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8130 | | - // System.out.println("; bump = " + bump); |
---|
8131 | | - } |
---|
8132 | | - |
---|
8133 | | - if (bump.equals("")) |
---|
8134 | | - { |
---|
8135 | | - bump = null; |
---|
8136 | | - } |
---|
8137 | | - if (pigment.equals("")) |
---|
8138 | | - { |
---|
8139 | | - pigment = null; |
---|
8140 | | - } |
---|
8141 | | - |
---|
8142 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8143 | | - BindTexture(pigment, false, resolution); |
---|
8144 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8145 | | - BindTexture(bump, true, resolution); |
---|
8146 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8147 | | - |
---|
8148 | | - return; // true; |
---|
| 8266 | + BindPigmentTexture(tex, resolution); |
---|
| 8267 | + BindBumpTexture(tex, resolution); |
---|
8149 | 8268 | } |
---|
8150 | 8269 | |
---|
8151 | 8270 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8164 | 8283 | |
---|
8165 | 8284 | String pigment = Object3D.GetPigment(tex); |
---|
8166 | 8285 | |
---|
8167 | | - usedtextures.put(pigment, pigment); |
---|
| 8286 | + usedtextures.add(tex); |
---|
8168 | 8287 | |
---|
8169 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8288 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8170 | 8289 | { |
---|
8171 | 8290 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8172 | 8291 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8178 | 8297 | } |
---|
8179 | 8298 | |
---|
8180 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8181 | | - BindTexture(pigment, false, resolution); |
---|
| 8300 | + BindTexture(tex, false, resolution); |
---|
8182 | 8301 | } |
---|
8183 | 8302 | |
---|
8184 | 8303 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8197 | 8316 | |
---|
8198 | 8317 | String bump = Object3D.GetBump(tex); |
---|
8199 | 8318 | |
---|
8200 | | - usedtextures.put(bump, bump); |
---|
| 8319 | + usedtextures.add(tex); |
---|
8201 | 8320 | |
---|
8202 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8321 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8203 | 8322 | { |
---|
8204 | 8323 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8205 | 8324 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8211 | 8330 | } |
---|
8212 | 8331 | |
---|
8213 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8214 | | - BindTexture(bump, true, resolution); |
---|
| 8333 | + BindTexture(tex, true, resolution); |
---|
8215 | 8334 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8216 | 8335 | } |
---|
8217 | 8336 | |
---|
.. | .. |
---|
8235 | 8354 | return fileExists; |
---|
8236 | 8355 | } |
---|
8237 | 8356 | |
---|
8238 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8357 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8239 | 8358 | { |
---|
8240 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8359 | + CacheTexture texturecache = null; |
---|
8241 | 8360 | |
---|
8242 | 8361 | if (tex != null) |
---|
8243 | 8362 | { |
---|
8244 | | - String texname = tex; |
---|
| 8363 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8364 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8365 | + |
---|
| 8366 | + if (texname.equals("") && texdata == null) |
---|
| 8367 | + { |
---|
| 8368 | + return null; |
---|
| 8369 | + } |
---|
8245 | 8370 | |
---|
8246 | 8371 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8247 | 8372 | |
---|
.. | .. |
---|
8251 | 8376 | // else |
---|
8252 | 8377 | // if (!texname.startsWith("/")) |
---|
8253 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8254 | | - if (!FileExists(tex)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8255 | 8380 | { |
---|
8256 | 8381 | texname = fallbackTextureName; |
---|
8257 | 8382 | } |
---|
8258 | 8383 | |
---|
8259 | 8384 | if (CACHETEXTURE) |
---|
8260 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8261 | | - |
---|
8262 | | - TextureData texturedata = null; |
---|
8263 | | - |
---|
8264 | | - if (texture == null || texture.resolution < resolution) |
---|
8265 | 8385 | { |
---|
8266 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8386 | + if (texdata == null) |
---|
| 8387 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8388 | + else |
---|
| 8389 | + texturecache = bimtextures.get(texdata); |
---|
| 8390 | + } |
---|
| 8391 | + |
---|
| 8392 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8393 | + { |
---|
| 8394 | + TextureData texturedata = null; |
---|
| 8395 | + |
---|
| 8396 | + if (texdata != null && textureon) |
---|
| 8397 | + { |
---|
| 8398 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8399 | + |
---|
| 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 | + } |
---|
| 8408 | + |
---|
| 8409 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 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; |
---|
| 8416 | + } |
---|
| 8417 | + else |
---|
| 8418 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8267 | 8419 | { |
---|
8268 | 8420 | assert(!bump); |
---|
8269 | 8421 | // if (bump) |
---|
.. | .. |
---|
8274 | 8426 | // } |
---|
8275 | 8427 | // else |
---|
8276 | 8428 | // { |
---|
8277 | | - texture = textures.get(tex); |
---|
8278 | | - if (texture == null) |
---|
| 8429 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8430 | + if (texturecache == null) |
---|
8279 | 8431 | { |
---|
8280 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8432 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8281 | 8433 | } |
---|
| 8434 | + else |
---|
| 8435 | + new Exception().printStackTrace(); |
---|
8282 | 8436 | // } |
---|
8283 | 8437 | } else |
---|
8284 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8438 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8285 | 8439 | { |
---|
8286 | 8440 | assert(bump); |
---|
8287 | | - texture = textures.get(tex); |
---|
8288 | | - if (texture == null) |
---|
8289 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8441 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8442 | + if (texturecache == null) |
---|
| 8443 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8444 | + else |
---|
| 8445 | + new Exception().printStackTrace(); |
---|
8290 | 8446 | } else |
---|
8291 | 8447 | { |
---|
8292 | 8448 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8294 | 8450 | // texture = GetResourceTexture("default.png"); |
---|
8295 | 8451 | //} else |
---|
8296 | 8452 | //{ |
---|
8297 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8453 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8298 | 8454 | { |
---|
8299 | | - texture = textures.get(tex); |
---|
8300 | | - if (texture == null) |
---|
8301 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8455 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8456 | + if (texturecache == null) |
---|
| 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); |
---|
| 8467 | + else |
---|
| 8468 | + new Exception().printStackTrace(); |
---|
8302 | 8469 | } else |
---|
8303 | 8470 | { |
---|
8304 | 8471 | if (textureon) |
---|
.. | .. |
---|
8357 | 8524 | if (texturedata == null) |
---|
8358 | 8525 | throw new Exception(); |
---|
8359 | 8526 | |
---|
8360 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8527 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8361 | 8528 | //texture = GetTexture(tex, bump); |
---|
8362 | 8529 | } |
---|
| 8530 | + } |
---|
8363 | 8531 | } |
---|
8364 | 8532 | //} |
---|
8365 | 8533 | } |
---|
8366 | 8534 | |
---|
8367 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8535 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8368 | 8536 | { |
---|
8369 | 8537 | //return false; |
---|
8370 | 8538 | |
---|
8371 | 8539 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8372 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8540 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8373 | 8541 | { |
---|
8374 | 8542 | // String ext = "_highres"; |
---|
8375 | 8543 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8386 | 8554 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8387 | 8555 | if (!cachefile.exists()) |
---|
8388 | 8556 | { |
---|
8389 | | - // cache to disk |
---|
8390 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8391 | | - //buffers[0]. |
---|
8392 | | - |
---|
8393 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8394 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8395 | | - |
---|
8396 | | - // squared size heuristic... |
---|
8397 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8557 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8398 | 8558 | { |
---|
8399 | | - for (int i=pixels.length; --i>=0;) |
---|
8400 | | - { |
---|
8401 | | - int i3 = i*3; |
---|
8402 | | - pixels[i] = 0xFF; |
---|
8403 | | - pixels[i] <<= 8; |
---|
8404 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8405 | | - pixels[i] <<= 8; |
---|
8406 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8407 | | - pixels[i] <<= 8; |
---|
8408 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8409 | | - } |
---|
8410 | | - |
---|
8411 | | - /* |
---|
8412 | | - int r=0,g=0,b=0,a=0; |
---|
8413 | | - for (int i=0; i<width; i++) |
---|
8414 | | - for (int j=0; j<height; j++) |
---|
8415 | | - { |
---|
8416 | | - int index = j*width+i; |
---|
8417 | | - int p = pixels[index]; |
---|
8418 | | - a = ((p>>24) & 0xFF); |
---|
8419 | | - r = ((p>>16) & 0xFF); |
---|
8420 | | - g = ((p>>8) & 0xFF); |
---|
8421 | | - b = (p & 0xFF); |
---|
8422 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8423 | | - } |
---|
8424 | | - /**/ |
---|
8425 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8426 | | - int height = width; |
---|
8427 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8428 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8559 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8560 | + |
---|
8429 | 8561 | ImageWriter writer = null; |
---|
8430 | 8562 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8431 | 8563 | if (iter.hasNext()) { |
---|
8432 | 8564 | writer = (ImageWriter)iter.next(); |
---|
8433 | 8565 | } |
---|
8434 | | - float compressionQuality = 0.9f; |
---|
| 8566 | + |
---|
| 8567 | + float compressionQuality = 0.85f; |
---|
8435 | 8568 | try |
---|
8436 | 8569 | { |
---|
8437 | 8570 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8448 | 8581 | } |
---|
8449 | 8582 | } |
---|
8450 | 8583 | } |
---|
8451 | | - |
---|
| 8584 | + |
---|
| 8585 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8586 | + |
---|
8452 | 8587 | //System.out.println("Texture = " + tex); |
---|
8453 | | - if (textures.containsKey(texname)) |
---|
| 8588 | + if (textures.containsKey(tex)) |
---|
8454 | 8589 | { |
---|
8455 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8590 | + CacheTexture thetex = textures.get(tex); |
---|
8456 | 8591 | thetex.texture.disable(); |
---|
8457 | 8592 | thetex.texture.dispose(); |
---|
8458 | | - textures.remove(texname); |
---|
| 8593 | + textures.remove(tex); |
---|
8459 | 8594 | } |
---|
8460 | 8595 | |
---|
8461 | | - texture.texturedata = texturedata; |
---|
8462 | | - textures.put(texname, texture); |
---|
| 8596 | + //texture.texturedata = texturedata; |
---|
| 8597 | + textures.put(tex, texturecache); |
---|
8463 | 8598 | |
---|
8464 | 8599 | // newtex = true; |
---|
8465 | 8600 | } |
---|
.. | .. |
---|
8475 | 8610 | } |
---|
8476 | 8611 | } |
---|
8477 | 8612 | |
---|
8478 | | - return texture; |
---|
| 8613 | + return texturecache; |
---|
8479 | 8614 | } |
---|
8480 | 8615 | |
---|
8481 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8616 | + static void EmbedTextures(cTexture tex) |
---|
| 8617 | + { |
---|
| 8618 | + if (tex.pigmentdata == null) |
---|
| 8619 | + { |
---|
| 8620 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8621 | + |
---|
| 8622 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8623 | + |
---|
| 8624 | + if (texturecache != null) |
---|
| 8625 | + { |
---|
| 8626 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 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); |
---|
| 8632 | + } |
---|
| 8633 | + } |
---|
| 8634 | + |
---|
| 8635 | + if (tex.bumpdata == null) |
---|
| 8636 | + { |
---|
| 8637 | + //String texname = Object3D.GetBump(tex); |
---|
| 8638 | + |
---|
| 8639 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8640 | + |
---|
| 8641 | + if (texturecache != null) |
---|
| 8642 | + { |
---|
| 8643 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8644 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8645 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8646 | + } |
---|
| 8647 | + } |
---|
| 8648 | + } |
---|
| 8649 | + |
---|
| 8650 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8482 | 8651 | { |
---|
8483 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8484 | 8653 | |
---|
.. | .. |
---|
8496 | 8665 | return texture!=null?texture.texture:null; |
---|
8497 | 8666 | } |
---|
8498 | 8667 | |
---|
8499 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8668 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8500 | 8669 | { |
---|
8501 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8502 | 8671 | |
---|
8503 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8504 | 8673 | } |
---|
8505 | 8674 | |
---|
8506 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8507 | 8676 | { |
---|
8508 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8509 | 8678 | { |
---|
8510 | 8679 | return false; |
---|
8511 | 8680 | } |
---|
8512 | 8681 | |
---|
8513 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8514 | 8683 | |
---|
8515 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8516 | 8685 | |
---|
.. | .. |
---|
8542 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8543 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8544 | 8713 | |
---|
8545 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8546 | 8715 | } |
---|
8547 | 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 | + |
---|
8548 | 8783 | ShadowBuffer shadowPBuf; |
---|
8549 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8550 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8561 | 8796 | |
---|
8562 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8563 | 8798 | MAXSTACK = temp[0]; |
---|
8564 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8565 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8566 | 8802 | MAXSTACK = temp[0]; |
---|
8567 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8568 | 8805 | |
---|
8569 | 8806 | // Use debug pipeline |
---|
8570 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8572 | 8809 | gl = drawable.getGL(); // |
---|
8573 | 8810 | |
---|
8574 | 8811 | GL gl3 = getGL(); |
---|
8575 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8576 | 8814 | |
---|
8577 | 8815 | |
---|
8578 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8737 | 8975 | |
---|
8738 | 8976 | if (cubemap == null) |
---|
8739 | 8977 | { |
---|
8740 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8741 | 8979 | } |
---|
8742 | 8980 | |
---|
8743 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9013 | 9251 | |
---|
9014 | 9252 | void LoadEnvy(int which) |
---|
9015 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9016 | 9256 | String name; |
---|
9017 | 9257 | String ext; |
---|
9018 | 9258 | |
---|
.. | .. |
---|
9024 | 9264 | cubemap = null; |
---|
9025 | 9265 | return; |
---|
9026 | 9266 | case 1: |
---|
9027 | | - name = "cubemaps/box_"; |
---|
9028 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9029 | 9269 | reverseUP = false; |
---|
9030 | 9270 | break; |
---|
9031 | 9271 | case 2: |
---|
9032 | | - name = "cubemaps/uffizi_"; |
---|
9033 | | - ext = "png"; |
---|
9034 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9035 | 9276 | case 3: |
---|
9036 | | - name = "cubemaps/CloudyHills_"; |
---|
9037 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9038 | 9279 | reverseUP = false; |
---|
9039 | 9280 | break; |
---|
9040 | 9281 | case 4: |
---|
9041 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9042 | 9283 | ext = "png"; |
---|
9043 | 9284 | reverseUP = false; |
---|
9044 | 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; |
---|
9045 | 9311 | default: |
---|
9046 | | - name = "cubemaps/rgb_"; |
---|
9047 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9048 | 9315 | break; |
---|
9049 | 9316 | } |
---|
9050 | | - |
---|
9051 | | - try |
---|
9052 | | - { |
---|
9053 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9054 | | - } catch (IOException e) |
---|
9055 | | - { |
---|
9056 | | - throw new RuntimeException(e); |
---|
9057 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9058 | 9319 | } |
---|
9059 | 9320 | |
---|
9060 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9086 | 9347 | static double[] model = new double[16]; |
---|
9087 | 9348 | double[] camera2light = new double[16]; |
---|
9088 | 9349 | double[] light2camera = new double[16]; |
---|
9089 | | - int newenvy = -1; |
---|
9090 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9091 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9092 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9093 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9505 | 9770 | |
---|
9506 | 9771 | if (renderCamera != lightCamera) |
---|
9507 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9508 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9509 | 9774 | |
---|
9510 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9511 | 9776 | |
---|
.. | .. |
---|
9521 | 9786 | |
---|
9522 | 9787 | if (renderCamera != lightCamera) |
---|
9523 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9524 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9525 | 9790 | |
---|
9526 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9527 | 9792 | |
---|
.. | .. |
---|
9567 | 9832 | rati = 1 / rati; |
---|
9568 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9569 | 9834 | } |
---|
9570 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9571 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9572 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9573 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9574 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9575 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9576 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10436 | 10703 | static boolean init = false; |
---|
10437 | 10704 | |
---|
10438 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10439 | 10709 | |
---|
10440 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10441 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10442 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10443 | 10719 | { |
---|
10444 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10607 | 10883 | |
---|
10608 | 10884 | if (wait) |
---|
10609 | 10885 | { |
---|
10610 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10611 | 10887 | |
---|
10612 | 10888 | wait = false; |
---|
10613 | 10889 | } |
---|
.. | .. |
---|
10722 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10723 | 10999 | if (cam != lightCamera) |
---|
10724 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10725 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10726 | 11002 | |
---|
10727 | 11003 | for (int j = 0; j < 4; j++) |
---|
10728 | 11004 | { |
---|
.. | .. |
---|
10737 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10738 | 11014 | if (cam != lightCamera) |
---|
10739 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10740 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10741 | 11017 | |
---|
10742 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10743 | 11019 | |
---|
.. | .. |
---|
10823 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10824 | 11100 | } |
---|
10825 | 11101 | |
---|
10826 | | - 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")) |
---|
10827 | 11110 | { |
---|
10828 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
10829 | 11117 | } |
---|
10830 | | - |
---|
10831 | | - newenvy = -1; |
---|
10832 | | - |
---|
| 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 | + |
---|
10833 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
10834 | 11140 | //System.out.println("ratio = " + ratio); |
---|
10835 | 11141 | |
---|
.. | .. |
---|
10845 | 11151 | |
---|
10846 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
10847 | 11153 | { |
---|
10848 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
10849 | 11155 | } |
---|
10850 | 11156 | |
---|
10851 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
11028 | 11334 | |
---|
11029 | 11335 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11030 | 11336 | |
---|
11031 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11032 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
11033 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11337 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11338 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11339 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
11034 | 11340 | } else |
---|
11035 | 11341 | { |
---|
11036 | 11342 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11041 | 11347 | //System.out.println("BLENDING ON"); |
---|
11042 | 11348 | gl.glEnable(GL.GL_BLEND); |
---|
11043 | 11349 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11044 | | - |
---|
| 11350 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11045 | 11351 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11046 | 11352 | gl.glLoadIdentity(); |
---|
11047 | 11353 | |
---|
.. | .. |
---|
11131 | 11437 | |
---|
11132 | 11438 | // if (cam != lightCamera) |
---|
11133 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11134 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11135 | 11441 | } |
---|
11136 | 11442 | |
---|
11137 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11290 | 11596 | } |
---|
11291 | 11597 | } |
---|
11292 | 11598 | |
---|
11293 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11294 | 11600 | { |
---|
11295 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11296 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11298 | 11604 | |
---|
11299 | 11605 | boolean texon = textureon; |
---|
11300 | 11606 | |
---|
11301 | | - if (RENDERPROGRAM > 0) |
---|
11302 | | - { |
---|
11303 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11304 | | - textureon = false; |
---|
11305 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
11306 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11307 | 11611 | //System.out.println("ALLO"); |
---|
11308 | 11612 | gl.glColorMask(false, false, false, false); |
---|
11309 | 11613 | DrawObject(gl); |
---|
11310 | | - if (RENDERPROGRAM > 0) |
---|
11311 | | - { |
---|
11312 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11313 | | - textureon = texon; |
---|
11314 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
11315 | 11618 | gl.glColorMask(true, true, true, true); |
---|
11316 | 11619 | |
---|
11317 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11318 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
11319 | 11622 | } |
---|
11320 | 11623 | |
---|
11321 | 11624 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11527 | 11830 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11528 | 11831 | { |
---|
11529 | 11832 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11530 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11833 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11531 | 11834 | pingthread.StepToTarget(true); // true); |
---|
11532 | 11835 | // zoomonce = false; |
---|
11533 | 11836 | } |
---|
.. | .. |
---|
11655 | 11958 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11656 | 11959 | |
---|
11657 | 11960 | if (CLEANCACHE) |
---|
11658 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11961 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11659 | 11962 | { |
---|
11660 | | - String tex = e.nextElement(); |
---|
| 11963 | + cTexture tex = e.nextElement(); |
---|
11661 | 11964 | |
---|
11662 | 11965 | // System.out.println("Texture --------- " + tex); |
---|
11663 | 11966 | |
---|
11664 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11967 | + if (tex.equals("WHITE_NOISE:")) |
---|
11665 | 11968 | continue; |
---|
11666 | 11969 | |
---|
11667 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11970 | + if (!usedtextures.contains(tex)) |
---|
11668 | 11971 | { |
---|
| 11972 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11669 | 11973 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11670 | | - textures.get(tex).texture.dispose(); |
---|
11671 | | - textures.remove(tex); |
---|
| 11974 | + if (gettex != null) |
---|
| 11975 | + { |
---|
| 11976 | + gettex.texture.dispose(); |
---|
| 11977 | + texturepigment.remove(tex); |
---|
| 11978 | + } |
---|
| 11979 | + |
---|
| 11980 | + gettex = texturebump.get(tex); |
---|
| 11981 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11982 | + if (gettex != null) |
---|
| 11983 | + { |
---|
| 11984 | + gettex.texture.dispose(); |
---|
| 11985 | + texturebump.remove(tex); |
---|
| 11986 | + } |
---|
11672 | 11987 | } |
---|
11673 | 11988 | } |
---|
11674 | 11989 | } |
---|
.. | .. |
---|
12196 | 12511 | |
---|
12197 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12198 | 12513 | |
---|
12199 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12200 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12520 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12521 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12522 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12523 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12524 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12525 | + "TEMP temp;" + |
---|
| 12526 | + "TEMP light;" + |
---|
| 12527 | + "TEMP ndotl;" + |
---|
| 12528 | + "TEMP normal;" + |
---|
| 12529 | + "TEMP depth;" + |
---|
| 12530 | + "TEMP eye;" + |
---|
| 12531 | + "TEMP pos;" + |
---|
| 12532 | + |
---|
| 12533 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12534 | + Normalize("normal") + |
---|
| 12535 | + "MOV light, state.light[0].position;" + |
---|
| 12536 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12537 | + |
---|
| 12538 | + // shadow |
---|
| 12539 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12540 | + "MOV temp, pos;" + |
---|
| 12541 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12542 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12543 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12544 | + |
---|
| 12545 | + // No shadow when out of frustum |
---|
| 12546 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12547 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12548 | + |
---|
| 12549 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12550 | + |
---|
| 12551 | + // Backlit |
---|
| 12552 | + "MOV pos.w, zero123.y;" + |
---|
| 12553 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12554 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12555 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12556 | + Normalize("eye") + |
---|
| 12557 | + |
---|
| 12558 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12559 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12560 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12561 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12562 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12563 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12564 | + |
---|
| 12565 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12566 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12567 | + |
---|
| 12568 | + // Pigment |
---|
| 12569 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12570 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12571 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12572 | + |
---|
| 12573 | + "MUL temp, temp, zero123.z;" + |
---|
| 12574 | + |
---|
| 12575 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12576 | + |
---|
| 12577 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12578 | + "MOV result.color, temp;" + |
---|
| 12579 | + "END"; |
---|
| 12580 | + |
---|
| 12581 | + String programmax = |
---|
| 12582 | + "!!ARBfp1.0\n" + |
---|
| 12583 | + |
---|
12201 | 12584 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12202 | 12585 | "PARAM light2cam0 = program.env[10];" + |
---|
12203 | 12586 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12223 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12224 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12225 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12226 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12227 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12228 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12229 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12312 | 12695 | "TEMP shininess;" + |
---|
12313 | 12696 | "\n" + |
---|
12314 | 12697 | "MOV texSamp, one;" + |
---|
12315 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12316 | | - |
---|
| 12698 | + |
---|
12317 | 12699 | "MOV mapgrid.x, one2048th.x;" + |
---|
12318 | 12700 | "MOV temp, fragment.texcoord[1];" + |
---|
12319 | 12701 | /* |
---|
.. | .. |
---|
12334 | 12716 | "MUL temp, floor, mapgrid.x;" + |
---|
12335 | 12717 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12336 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12337 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12338 | 12720 | "") + |
---|
12339 | 12721 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12340 | 12722 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12341 | 12723 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12342 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12724 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12343 | 12725 | "") + |
---|
12344 | 12726 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12345 | 12727 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12346 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12728 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12347 | 12729 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12348 | 12730 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12349 | 12731 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12350 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12732 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12351 | 12733 | "") + |
---|
12352 | 12734 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12353 | 12735 | //"MOV params, material;" + |
---|
.. | .. |
---|
12469 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12470 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12471 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12472 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12473 | 12855 | /* |
---|
12474 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12475 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12555 | 12937 | "SUB bump0, bump0, half;" + |
---|
12556 | 12938 | "ADD bump, bump, bump0;" + |
---|
12557 | 12939 | |
---|
12558 | | - "MOV temp.x, texSamp.a;" + |
---|
12559 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12560 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12561 | | - "MOV texSamp.a, temp.x;" + |
---|
12562 | | - |
---|
12563 | 12940 | // double-sided |
---|
12564 | 12941 | /**/ |
---|
12565 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12576 | 12953 | "MOV normald, normal;" + |
---|
12577 | 12954 | "MOV normals, normal;" + |
---|
12578 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12579 | 12958 | // UV base |
---|
12580 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12581 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12582 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12583 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12584 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12585 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12962 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12963 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12964 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12965 | + Normalize("UP") + |
---|
| 12966 | + |
---|
12586 | 12967 | "XPD V, normal, UP;" + |
---|
12587 | 12968 | Normalize("V") + |
---|
12588 | 12969 | "XPD U, V, normal;" + |
---|
12589 | 12970 | Normalize("U") + |
---|
12590 | 12971 | |
---|
12591 | 12972 | // parallax mapping |
---|
| 12973 | + |
---|
| 12974 | + "DP3 temp2.x, V, eye;" + |
---|
| 12975 | + "DP3 temp2.y, U, eye;" + |
---|
| 12976 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12977 | + "RCP temp2.z, temp2.z;" + |
---|
| 12978 | + |
---|
| 12979 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12980 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12981 | + "RCP temp2.w, temp2.w;" + |
---|
| 12982 | + |
---|
| 12983 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12984 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12985 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12986 | + |
---|
| 12987 | + //"MOV texSamp, U;" + |
---|
| 12988 | + |
---|
| 12989 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12990 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12991 | + |
---|
| 12992 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12993 | + |
---|
| 12994 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12995 | + |
---|
| 12996 | + "SUB temp, temp, temp2;" + |
---|
| 12997 | + |
---|
| 12998 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 12999 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13000 | + |
---|
| 13001 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13002 | + "MUL temp.xyz, half, texSamp;" + |
---|
| 13003 | + |
---|
| 13004 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13005 | + |
---|
| 13006 | +// parallax mapping |
---|
| 13007 | + |
---|
| 13008 | + "MOV temp.x, texSamp.a;" + |
---|
| 13009 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13010 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13011 | + "MOV texSamp.a, temp.x;" + |
---|
12592 | 13012 | |
---|
12593 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12594 | 13014 | // |
---|
.. | .. |
---|
12718 | 13138 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12719 | 13139 | "") + |
---|
12720 | 13140 | |
---|
12721 | | - // display shadow only (bump == 0) |
---|
| 13141 | + // display shadow only (fakedepth == 0) |
---|
12722 | 13142 | "SUB temp.x, half.x, shadow.x;" + |
---|
12723 | 13143 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12724 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13144 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12725 | 13145 | "SUB temp.y, one.x, temp.z;" + |
---|
12726 | 13146 | "MUL temp.x, temp.x, temp.y;" + |
---|
12727 | 13147 | "KIL temp.x;" + |
---|
.. | .. |
---|
13052 | 13472 | //once = true; |
---|
13053 | 13473 | } |
---|
13054 | 13474 | |
---|
13055 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13056 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13475 | + String program = programmax; |
---|
| 13476 | + |
---|
| 13477 | + if (Globals.MINSHADER) |
---|
| 13478 | + { |
---|
| 13479 | + program = programmin; |
---|
| 13480 | + } |
---|
| 13481 | + |
---|
| 13482 | + if (Globals.DEBUG) |
---|
| 13483 | + { |
---|
| 13484 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13485 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
13057 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13058 | 13489 | |
---|
13059 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13100 | 13531 | "\n" + |
---|
13101 | 13532 | "END\n"; |
---|
13102 | 13533 | |
---|
13103 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13104 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13105 | 13537 | |
---|
13106 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13145 | 13577 | return out; |
---|
13146 | 13578 | } |
---|
13147 | 13579 | |
---|
13148 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13580 | + // Also does frustum culling |
---|
| 13581 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13149 | 13582 | { |
---|
13150 | 13583 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13151 | 13584 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13152 | 13585 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13586 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13587 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13153 | 13588 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13154 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13155 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13156 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13157 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13589 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13590 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13158 | 13591 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13159 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13592 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13160 | 13593 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13161 | 13594 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13162 | 13595 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13163 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13596 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13164 | 13597 | |
---|
13165 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13166 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13598 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13599 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13167 | 13600 | } |
---|
13168 | 13601 | |
---|
13169 | 13602 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13210 | 13643 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13211 | 13644 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13212 | 13645 | |
---|
13213 | | - // No shadow when out of frustrum |
---|
| 13646 | + // No shadow when out of frustum |
---|
13214 | 13647 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13215 | 13648 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13216 | 13649 | ""; |
---|
.. | .. |
---|
13357 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13358 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13359 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13360 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13793 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13361 | 13794 | |
---|
13362 | 13795 | //Object3D.cVector2[] vector2buffer; |
---|
13363 | 13796 | |
---|
.. | .. |
---|
13524 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13525 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13526 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13527 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13528 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13529 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13530 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13585 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13586 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13587 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13588 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13589 | 14022 | "MOV result.texcoord, temp;" + |
---|
13590 | 14023 | // border fade |
---|
13591 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13632 | 14065 | |
---|
13633 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
13634 | 14067 | |
---|
13635 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
13636 | 14071 | : "MOV result.color, vertex.color;") + |
---|
13637 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13638 | 14073 | : "") + |
---|
.. | .. |
---|
13943 | 14378 | |
---|
13944 | 14379 | // fev 2014??? |
---|
13945 | 14380 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13946 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14381 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13947 | 14382 | pingthread.StepToTarget(true); // true); |
---|
13948 | 14383 | } |
---|
13949 | 14384 | // if (!LIVE) |
---|
.. | .. |
---|
14008 | 14443 | drag = false; |
---|
14009 | 14444 | //System.out.println("Mouse DOWN"); |
---|
14010 | 14445 | editObj = false; |
---|
14011 | | - ClickInfo info = new ClickInfo(); |
---|
14012 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14013 | | - info.pane = this; |
---|
14014 | | - info.camera = renderCamera; |
---|
14015 | | - info.x = x; |
---|
14016 | | - info.y = y; |
---|
14017 | | - info.modifiers = modifiersex; |
---|
14018 | | - editObj = object.doEditClick(info, 0); |
---|
| 14446 | + //ClickInfo info = new ClickInfo(); |
---|
| 14447 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14448 | + object.clickInfo.pane = this; |
---|
| 14449 | + object.clickInfo.camera = renderCamera; |
---|
| 14450 | + object.clickInfo.x = x; |
---|
| 14451 | + object.clickInfo.y = y; |
---|
| 14452 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14453 | + editObj = object.doEditClick(//info, |
---|
| 14454 | + 0); |
---|
14019 | 14455 | if (!editObj) |
---|
14020 | 14456 | { |
---|
14021 | 14457 | hasMarquee = true; |
---|
.. | .. |
---|
14297 | 14733 | void GoDown(int mod) |
---|
14298 | 14734 | { |
---|
14299 | 14735 | MODIFIERS |= COMMAND; |
---|
14300 | | - /* |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14737 | + /**/ |
---|
14301 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
14302 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
14303 | 14745 | else |
---|
14304 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14305 | | - */ |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14747 | + /**/ |
---|
14306 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
14307 | 14749 | { |
---|
14308 | 14750 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14311 | 14753 | mouseMode |= BACKFORTH; |
---|
14312 | 14754 | } |
---|
14313 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
14314 | 14758 | //prevX = X = anchorX; |
---|
14315 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14316 | 14760 | } |
---|
.. | .. |
---|
14318 | 14762 | void GoUp(int mod) |
---|
14319 | 14763 | { |
---|
14320 | 14764 | MODIFIERS |= COMMAND; |
---|
14321 | | - /* |
---|
| 14765 | + /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
14322 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
14323 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
14324 | 14775 | else |
---|
14325 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14326 | | - */ |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14777 | + /**/ |
---|
14327 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
14328 | 14779 | { |
---|
14329 | 14780 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14332 | 14783 | mouseMode |= BACKFORTH; |
---|
14333 | 14784 | } |
---|
14334 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
14335 | 14788 | //prevX = X = anchorX; |
---|
14336 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14337 | 14790 | } |
---|
.. | .. |
---|
14339 | 14792 | void GoLeft(int mod) |
---|
14340 | 14793 | { |
---|
14341 | 14794 | MODIFIERS |= COMMAND; |
---|
14342 | | - /* |
---|
| 14795 | + /**/ |
---|
14343 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
14344 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14345 | 14798 | else |
---|
14346 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14347 | | - */ |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
| 14805 | + /**/ |
---|
14348 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
14349 | 14807 | { |
---|
14350 | 14808 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14353 | 14811 | mouseMode |= ROTATE; |
---|
14354 | 14812 | } // TRANSLATE; |
---|
14355 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
14356 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14357 | 14817 | prevY = Y = anchorY; |
---|
14358 | 14818 | } |
---|
.. | .. |
---|
14360 | 14820 | void GoRight(int mod) |
---|
14361 | 14821 | { |
---|
14362 | 14822 | MODIFIERS |= COMMAND; |
---|
14363 | | - /* |
---|
| 14823 | + /**/ |
---|
14364 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
14365 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14366 | 14826 | else |
---|
14367 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14368 | | - */ |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
| 14834 | + /**/ |
---|
14369 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
14370 | 14836 | { |
---|
14371 | 14837 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14374 | 14840 | mouseMode |= ROTATE; |
---|
14375 | 14841 | } // TRANSLATE; |
---|
14376 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
14377 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14378 | 14846 | prevY = Y = anchorY; |
---|
14379 | 14847 | } |
---|
.. | .. |
---|
14415 | 14883 | if (editObj) |
---|
14416 | 14884 | { |
---|
14417 | 14885 | drag = true; |
---|
14418 | | - ClickInfo info = new ClickInfo(); |
---|
14419 | | - info.bounds.setBounds(0, 0, |
---|
| 14886 | + //ClickInfo info = new ClickInfo(); |
---|
| 14887 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14420 | 14888 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14421 | | - info.pane = this; |
---|
14422 | | - info.camera = renderCamera; |
---|
14423 | | - info.x = x; |
---|
14424 | | - info.y = y; |
---|
14425 | | - object.GetWindow().copy |
---|
14426 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14889 | + object.clickInfo.pane = this; |
---|
| 14890 | + object.clickInfo.camera = renderCamera; |
---|
| 14891 | + object.clickInfo.x = x; |
---|
| 14892 | + object.clickInfo.y = y; |
---|
| 14893 | + object //.GetWindow().copy |
---|
| 14894 | + .doEditDrag(//info, |
---|
| 14895 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14427 | 14896 | } else |
---|
14428 | 14897 | { |
---|
14429 | 14898 | if (x < startX) |
---|
.. | .. |
---|
14572 | 15041 | } |
---|
14573 | 15042 | } |
---|
14574 | 15043 | |
---|
| 15044 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15045 | + |
---|
14575 | 15046 | public void mouseMoved(MouseEvent e) |
---|
14576 | 15047 | { |
---|
14577 | 15048 | //System.out.println("mouseMoved: " + e); |
---|
14578 | 15049 | if (isRenderer) |
---|
14579 | 15050 | return; |
---|
14580 | 15051 | |
---|
14581 | | - ClickInfo ci = new ClickInfo(); |
---|
14582 | | - ci.x = e.getX(); |
---|
14583 | | - ci.y = e.getY(); |
---|
14584 | | - ci.modifiers = e.getModifiersEx(); |
---|
14585 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14586 | | - ci.pane = this; |
---|
14587 | | - ci.camera = renderCamera; |
---|
| 15052 | + // Mouse cursor feedback |
---|
| 15053 | + object.clickInfo.x = e.getX(); |
---|
| 15054 | + object.clickInfo.y = e.getY(); |
---|
| 15055 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15056 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15057 | + object.clickInfo.pane = this; |
---|
| 15058 | + object.clickInfo.camera = renderCamera; |
---|
14588 | 15059 | if (!isRenderer) |
---|
14589 | 15060 | { |
---|
14590 | 15061 | //ObjEditor editWindow = object.editWindow; |
---|
14591 | 15062 | //Object3D copy = editWindow.copy; |
---|
14592 | | - if (object.doEditClick(ci, 0)) |
---|
| 15063 | + if (object.doEditClick(//clickInfo, |
---|
| 15064 | + 0)) |
---|
14593 | 15065 | { |
---|
14594 | 15066 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14595 | 15067 | } else |
---|
.. | .. |
---|
14604 | 15076 | Globals.MOUSEDRAGGED = false; |
---|
14605 | 15077 | |
---|
14606 | 15078 | movingcamera = false; |
---|
14607 | | - X = Y = 0; |
---|
| 15079 | + X = 0; // getBounds().width/2; |
---|
| 15080 | + Y = 0; // getBounds().height/2; |
---|
14608 | 15081 | //System.out.println("mouseReleased: " + e); |
---|
14609 | 15082 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14610 | 15083 | } |
---|
.. | .. |
---|
14860 | 15333 | // break; |
---|
14861 | 15334 | case 'T': |
---|
14862 | 15335 | CACHETEXTURE ^= true; |
---|
14863 | | - textures.clear(); |
---|
| 15336 | + texturepigment.clear(); |
---|
| 15337 | + texturebump.clear(); |
---|
14864 | 15338 | // repaint(); |
---|
14865 | 15339 | break; |
---|
14866 | 15340 | case 'Y': |
---|
.. | .. |
---|
14870 | 15344 | case 'K': |
---|
14871 | 15345 | KOMPACTTEXTURE ^= true; |
---|
14872 | 15346 | //textures.clear(); |
---|
14873 | | - break; |
---|
14874 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
14875 | 15349 | // SAVETEXTURE ^= true; |
---|
14876 | 15350 | macromode = true; |
---|
14877 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14945 | 15419 | case 'E' : COMPACT ^= true; |
---|
14946 | 15420 | repaint(); |
---|
14947 | 15421 | break; |
---|
14948 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15422 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15423 | + //DEBUGHSB ^= true; |
---|
| 15424 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14949 | 15425 | repaint(); |
---|
14950 | 15426 | break; |
---|
14951 | 15427 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14971 | 15447 | repaint(); |
---|
14972 | 15448 | break; |
---|
14973 | 15449 | case 'l': |
---|
14974 | | - lightMode ^= true; |
---|
14975 | | - Globals.lighttouched = true; |
---|
14976 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14977 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14978 | | - repaint(); |
---|
14979 | | - break; |
---|
14980 | | - case 'L': |
---|
| 15450 | + //case 'L': |
---|
14981 | 15451 | if (lightMode) |
---|
14982 | 15452 | { |
---|
14983 | 15453 | lightMode = false; |
---|
.. | .. |
---|
14996 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
14997 | 15467 | repaint(); |
---|
14998 | 15468 | break; |
---|
14999 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
15000 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
15001 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
15002 | 15472 | repaint(); |
---|
.. | .. |
---|
15041 | 15511 | OCCLUSION_CULLING ^= true; |
---|
15042 | 15512 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15043 | 15513 | break; |
---|
15044 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15514 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15045 | 15515 | case '1': |
---|
15046 | 15516 | case '2': |
---|
15047 | 15517 | case '3': |
---|
15048 | 15518 | case '4': |
---|
15049 | 15519 | case '5': |
---|
15050 | | - newenvy = Character.getNumericValue(key); |
---|
15051 | | - repaint(); |
---|
15052 | | - break; |
---|
15053 | 15520 | case '6': |
---|
15054 | 15521 | case '7': |
---|
15055 | 15522 | case '8': |
---|
15056 | 15523 | case '9': |
---|
15057 | | - BGcolor = (key - '6')/3.f; |
---|
| 15524 | + if (true) // envyoff) |
---|
| 15525 | + { |
---|
| 15526 | + BGcolor = (key - '1')/8.f; |
---|
| 15527 | + } |
---|
| 15528 | + else |
---|
| 15529 | + { |
---|
| 15530 | + //newenvy = Character.getNumericValue(key); |
---|
| 15531 | + } |
---|
15058 | 15532 | repaint(); |
---|
15059 | 15533 | break; |
---|
15060 | 15534 | case '!': |
---|
.. | .. |
---|
15124 | 15598 | // kompactbit = 6; |
---|
15125 | 15599 | // break; |
---|
15126 | 15600 | case ' ': |
---|
15127 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15601 | + lightMode ^= true; |
---|
| 15602 | + Globals.lighttouched = true; |
---|
| 15603 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15604 | + targetLookAt.set(manipCamera.lookAt); |
---|
15128 | 15605 | repaint(); |
---|
15129 | 15606 | break; |
---|
15130 | 15607 | //case '`' : |
---|
.. | .. |
---|
15172 | 15649 | ClearSelection(); |
---|
15173 | 15650 | break; |
---|
15174 | 15651 | case '+': |
---|
| 15652 | + |
---|
15175 | 15653 | /* |
---|
15176 | 15654 | //fontsize += 1; |
---|
15177 | 15655 | bbzoom *= 2; |
---|
.. | .. |
---|
15189 | 15667 | case '=': |
---|
15190 | 15668 | IncDepth(); |
---|
15191 | 15669 | //fontsize += 1; |
---|
15192 | | - object.editWindow.refreshContents(true); |
---|
| 15670 | + object.GetWindow().refreshContents(true); |
---|
15193 | 15671 | maskbit = 6; |
---|
15194 | 15672 | break; |
---|
15195 | 15673 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15196 | 15674 | DecDepth(); |
---|
15197 | 15675 | maskbit = 5; |
---|
15198 | 15676 | //if(fontsize > 1) fontsize -= 1; |
---|
15199 | | - if (object.editWindow == null) |
---|
15200 | | - new Exception().printStackTrace(); |
---|
15201 | | - else |
---|
15202 | | - object.editWindow.refreshContents(true); |
---|
| 15677 | +// if (object.editWindow == null) |
---|
| 15678 | +// new Exception().printStackTrace(); |
---|
| 15679 | +// else |
---|
| 15680 | + object.GetWindow().refreshContents(true); |
---|
15203 | 15681 | break; |
---|
15204 | 15682 | case '{': |
---|
15205 | 15683 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15423 | 15901 | } |
---|
15424 | 15902 | */ |
---|
15425 | 15903 | |
---|
15426 | | - object.editWindow.EditSelection(false); |
---|
| 15904 | + object.GetWindow().EditSelection(false); |
---|
15427 | 15905 | } |
---|
15428 | 15906 | |
---|
15429 | 15907 | void SelectParent() |
---|
.. | .. |
---|
15440 | 15918 | { |
---|
15441 | 15919 | //selectees.remove(i); |
---|
15442 | 15920 | System.out.println("select parent of " + elem); |
---|
15443 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15921 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15444 | 15922 | } else |
---|
15445 | 15923 | { |
---|
15446 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15924 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15447 | 15925 | } |
---|
15448 | 15926 | |
---|
15449 | 15927 | first = false; |
---|
.. | .. |
---|
15485 | 15963 | for (int j = 0; j < group.children.size(); j++) |
---|
15486 | 15964 | { |
---|
15487 | 15965 | elem = (Object3D) group.children.elementAt(j); |
---|
15488 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15966 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15489 | 15967 | first = false; |
---|
15490 | 15968 | } |
---|
15491 | 15969 | } else |
---|
15492 | 15970 | { |
---|
15493 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15971 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15494 | 15972 | } |
---|
15495 | 15973 | |
---|
15496 | 15974 | first = false; |
---|
.. | .. |
---|
15501 | 15979 | { |
---|
15502 | 15980 | //Composite group = (Composite) object; |
---|
15503 | 15981 | Object3D group = object; |
---|
15504 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15982 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15505 | 15983 | } |
---|
15506 | 15984 | |
---|
15507 | 15985 | void ResetTransform(int mask) |
---|
15508 | 15986 | { |
---|
15509 | 15987 | //Composite group = (Composite) object; |
---|
15510 | 15988 | Object3D group = object; |
---|
15511 | | - group.editWindow.ResetTransform(mask); |
---|
| 15989 | + group.GetWindow().ResetTransform(mask); |
---|
15512 | 15990 | } |
---|
15513 | 15991 | |
---|
15514 | 15992 | void FlipTransform() |
---|
15515 | 15993 | { |
---|
15516 | 15994 | //Composite group = (Composite) object; |
---|
15517 | 15995 | Object3D group = object; |
---|
15518 | | - group.editWindow.FlipTransform(); |
---|
| 15996 | + group.GetWindow().FlipTransform(); |
---|
15519 | 15997 | // group.editWindow.ReduceMesh(true); |
---|
15520 | 15998 | } |
---|
15521 | 15999 | |
---|
.. | .. |
---|
15523 | 16001 | { |
---|
15524 | 16002 | //Composite group = (Composite) object; |
---|
15525 | 16003 | Object3D group = object; |
---|
15526 | | - group.editWindow.PrintMemory(); |
---|
| 16004 | + group.GetWindow().PrintMemory(); |
---|
15527 | 16005 | // group.editWindow.ReduceMesh(true); |
---|
15528 | 16006 | } |
---|
15529 | 16007 | |
---|
.. | .. |
---|
15531 | 16009 | { |
---|
15532 | 16010 | //Composite group = (Composite) object; |
---|
15533 | 16011 | Object3D group = object; |
---|
15534 | | - group.editWindow.ResetCentroid(); |
---|
| 16012 | + group.GetWindow().ResetCentroid(); |
---|
15535 | 16013 | } |
---|
15536 | 16014 | |
---|
15537 | 16015 | void IncDepth() |
---|
.. | .. |
---|
15613 | 16091 | |
---|
15614 | 16092 | int width = getBounds().width; |
---|
15615 | 16093 | int height = getBounds().height; |
---|
15616 | | - ClickInfo info = new ClickInfo(); |
---|
15617 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15618 | 16094 | //Image img = CreateImage(width, height); |
---|
15619 | 16095 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15620 | 16096 | |
---|
.. | .. |
---|
15691 | 16167 | } |
---|
15692 | 16168 | if (object != null && !hasMarquee) |
---|
15693 | 16169 | { |
---|
| 16170 | + if (object.clickInfo == null) |
---|
| 16171 | + object.clickInfo = new ClickInfo(); |
---|
| 16172 | + ClickInfo info = object.clickInfo; |
---|
| 16173 | + //ClickInfo info = new ClickInfo(); |
---|
| 16174 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16175 | + |
---|
15694 | 16176 | if (isRenderer) |
---|
15695 | 16177 | { |
---|
15696 | | - info.flags++; |
---|
| 16178 | + object.clickInfo.flags++; |
---|
15697 | 16179 | double frameAspect = (double) width / (double) height; |
---|
15698 | 16180 | if (frameAspect > renderCamera.aspect) |
---|
15699 | 16181 | { |
---|
15700 | 16182 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15701 | | - info.bounds.width -= width - desired; |
---|
15702 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16183 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16184 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15703 | 16185 | } else |
---|
15704 | 16186 | { |
---|
15705 | 16187 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15706 | | - info.bounds.height -= height - desired; |
---|
15707 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16188 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16189 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15708 | 16190 | } |
---|
15709 | 16191 | } |
---|
15710 | | - info.g = gr; |
---|
15711 | | - info.camera = renderCamera; |
---|
| 16192 | + |
---|
| 16193 | + object.clickInfo.g = gr; |
---|
| 16194 | + object.clickInfo.camera = renderCamera; |
---|
15712 | 16195 | /* |
---|
15713 | 16196 | // Memory intensive (brep.verticescopy) |
---|
15714 | 16197 | if (!(object instanceof Composite)) |
---|
15715 | 16198 | object.draw(info, 0, false); // SLOW : |
---|
15716 | 16199 | */ |
---|
15717 | | - if (!isRenderer) |
---|
| 16200 | + if (!isRenderer) // && drag) |
---|
15718 | 16201 | { |
---|
15719 | | - object.drawEditHandles(info, 0); |
---|
15720 | | - |
---|
15721 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16202 | + Grafreed.Assert(object != null); |
---|
| 16203 | + Grafreed.Assert(object.selection != null); |
---|
| 16204 | + if (object.selection.Size() > 0) |
---|
15722 | 16205 | { |
---|
15723 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16206 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16207 | + |
---|
| 16208 | + object.clickInfo.DX = 0; |
---|
| 16209 | + object.clickInfo.DY = 0; |
---|
| 16210 | + object.clickInfo.W = 1; |
---|
| 16211 | + if (hitSomething == Object3D.hitCenter) |
---|
15724 | 16212 | { |
---|
15725 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15726 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15727 | | - break; |
---|
15728 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15729 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15730 | | - break; |
---|
15731 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15732 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15733 | | - break; |
---|
| 16213 | + info.DX = X; |
---|
| 16214 | + if (X != 0) |
---|
| 16215 | + info.DX -= info.bounds.width/2; |
---|
| 16216 | + |
---|
| 16217 | + info.DY = Y; |
---|
| 16218 | + if (Y != 0) |
---|
| 16219 | + info.DY -= info.bounds.height/2; |
---|
15734 | 16220 | } |
---|
15735 | | - |
---|
| 16221 | + |
---|
| 16222 | + object.drawEditHandles(//info, |
---|
| 16223 | + 0); |
---|
| 16224 | + |
---|
| 16225 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16226 | + { |
---|
| 16227 | + switch (hitSomething) |
---|
| 16228 | + { |
---|
| 16229 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16230 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16231 | + break; |
---|
| 16232 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16233 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16234 | + break; |
---|
| 16235 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16236 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16237 | + break; |
---|
| 16238 | + } |
---|
| 16239 | + |
---|
| 16240 | + } |
---|
15736 | 16241 | } |
---|
15737 | 16242 | } |
---|
15738 | 16243 | } |
---|
.. | .. |
---|
15747 | 16252 | if (hasMarquee) |
---|
15748 | 16253 | { |
---|
15749 | 16254 | gr.setXORMode(Color.white); |
---|
15750 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
15751 | 16256 | if (!firstime) |
---|
15752 | 16257 | { |
---|
15753 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16214 | 16719 | private /*static*/ boolean firstime; |
---|
16215 | 16720 | private /*static*/ cVector newView = new cVector(); |
---|
16216 | 16721 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16722 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16723 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16217 | 16724 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16218 | 16725 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16219 | 16726 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16226 | 16733 | { |
---|
16227 | 16734 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16228 | 16735 | |
---|
| 16736 | + int usedsuf = 0; |
---|
| 16737 | + |
---|
16229 | 16738 | for (int i = 0; i < suffixes.length; i++) |
---|
16230 | 16739 | { |
---|
16231 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16232 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16233 | | - mipmapped, |
---|
16234 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16235 | | - if (data == null) |
---|
| 16740 | + String[] suffixe = suffixes; |
---|
| 16741 | + String[] fallback = suffixes2; |
---|
| 16742 | + String[] fallfallback = suffixes3; |
---|
| 16743 | + |
---|
| 16744 | + for (int c=usedsuf; --c>=0;) |
---|
16236 | 16745 | { |
---|
16237 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16746 | +// String[] temp = suffixe; |
---|
| 16747 | +// suffixe = fallback; |
---|
| 16748 | +// fallback = fallfallback; |
---|
| 16749 | +// fallfallback = temp; |
---|
16238 | 16750 | } |
---|
| 16751 | + |
---|
| 16752 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16753 | + TextureData data; |
---|
| 16754 | + |
---|
| 16755 | + try |
---|
| 16756 | + { |
---|
| 16757 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16758 | + mipmapped, |
---|
| 16759 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16760 | + } |
---|
| 16761 | + catch (Exception e) |
---|
| 16762 | + { |
---|
| 16763 | + try |
---|
| 16764 | + { |
---|
| 16765 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16766 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16767 | + mipmapped, |
---|
| 16768 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16769 | + } |
---|
| 16770 | + catch (Exception e2) |
---|
| 16771 | + { |
---|
| 16772 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16773 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16774 | + mipmapped, |
---|
| 16775 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16776 | + } |
---|
| 16777 | + } |
---|
| 16778 | + |
---|
16239 | 16779 | //System.out.println("Target = " + targets[i]); |
---|
16240 | 16780 | cubemap.updateImage(data, targets[i]); |
---|
16241 | 16781 | } |
---|
16242 | 16782 | |
---|
16243 | 16783 | return cubemap; |
---|
16244 | 16784 | } |
---|
| 16785 | + |
---|
16245 | 16786 | int bigsphere = -1; |
---|
16246 | 16787 | |
---|
16247 | 16788 | float BGcolor = 0.5f; |
---|
16248 | 16789 | |
---|
16249 | | - private void DrawSkyBox(GL gl) |
---|
| 16790 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16791 | + |
---|
| 16792 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16250 | 16793 | { |
---|
16251 | | - if (envyoff || cubemap == null) |
---|
| 16794 | + if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
| 16796 | + cubemap == null) |
---|
16252 | 16797 | { |
---|
16253 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16254 | 16799 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16263 | 16808 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16264 | 16809 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16265 | 16810 | gl.glLoadIdentity(); |
---|
| 16811 | + gl.glScalef(1,ratio,1); |
---|
16266 | 16812 | |
---|
| 16813 | +// colorV[0] = 2; |
---|
| 16814 | +// colorV[1] = 2; |
---|
| 16815 | +// colorV[2] = 2; |
---|
| 16816 | +// colorV[3] = 1; |
---|
| 16817 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16818 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16819 | +// |
---|
| 16820 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16821 | + |
---|
16267 | 16822 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16268 | 16823 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16269 | 16824 | |
---|
.. | .. |
---|
16295 | 16850 | { |
---|
16296 | 16851 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16297 | 16852 | } |
---|
| 16853 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16298 | 16854 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16299 | 16855 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16300 | 16856 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16335 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16336 | 16892 | |
---|
16337 | 16893 | cubemap.disable(); |
---|
16338 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
16339 | 16896 | if (CULLFACE) |
---|
16340 | 16897 | { |
---|
16341 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16391 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16392 | 16949 | } |
---|
16393 | 16950 | |
---|
16394 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16395 | 16952 | |
---|
16396 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16397 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16530 | 17087 | } |
---|
16531 | 17088 | } |
---|
16532 | 17089 | |
---|
| 17090 | + private Object3D GetFolder() |
---|
| 17091 | + { |
---|
| 17092 | + Object3D folder = object.GetWindow().copy; |
---|
| 17093 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17094 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17095 | + return folder; |
---|
| 17096 | + } |
---|
| 17097 | + |
---|
16533 | 17098 | class SelectBuffer implements GLEventListener |
---|
16534 | 17099 | { |
---|
16535 | 17100 | |
---|
.. | .. |
---|
16545 | 17110 | //new Exception().printStackTrace(); |
---|
16546 | 17111 | System.out.println("select buffer init"); |
---|
16547 | 17112 | // Use debug pipeline |
---|
16548 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17113 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16549 | 17114 | |
---|
16550 | 17115 | GL gl = drawable.getGL(); |
---|
16551 | 17116 | |
---|
.. | .. |
---|
16609 | 17174 | |
---|
16610 | 17175 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16611 | 17176 | |
---|
| 17177 | + if (PAINTMODE) |
---|
| 17178 | + { |
---|
| 17179 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17180 | + { |
---|
| 17181 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17182 | + |
---|
| 17183 | + // Make what you paint not selectable. |
---|
| 17184 | + paintobj.ResetSelectable(); |
---|
| 17185 | + } |
---|
| 17186 | + } |
---|
| 17187 | + |
---|
16612 | 17188 | //int tmp = selection_view; |
---|
16613 | 17189 | //selection_view = -1; |
---|
16614 | 17190 | int temp = DrawMode(); |
---|
.. | .. |
---|
16620 | 17196 | // temp = DEFAULT; // patch for selection debug |
---|
16621 | 17197 | Globals.drawMode = temp; // WARNING |
---|
16622 | 17198 | |
---|
| 17199 | + if (PAINTMODE) |
---|
| 17200 | + { |
---|
| 17201 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17202 | + { |
---|
| 17203 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17204 | + |
---|
| 17205 | + // Revert. |
---|
| 17206 | + paintobj.RestoreSelectable(); |
---|
| 17207 | + } |
---|
| 17208 | + } |
---|
| 17209 | + |
---|
16623 | 17210 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16624 | 17211 | |
---|
16625 | 17212 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16723 | 17310 | } |
---|
16724 | 17311 | |
---|
16725 | 17312 | if (!movingcamera && !PAINTMODE) |
---|
16726 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17313 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16727 | 17314 | |
---|
16728 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17315 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16729 | 17316 | { |
---|
16730 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17317 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16731 | 17318 | |
---|
16732 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17319 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17320 | + { |
---|
| 17321 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16733 | 17322 | |
---|
16734 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16735 | | - |
---|
16736 | | - group.add(paintobj); // link |
---|
16737 | | - |
---|
16738 | | - object.editWindow.SnapObject(group); |
---|
16739 | | - |
---|
16740 | | - Object3D folder = object.editWindow.copy; |
---|
16741 | | - |
---|
16742 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16743 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16744 | | - |
---|
16745 | | - folder.add(group); |
---|
16746 | | - |
---|
16747 | | - object.editWindow.ResetModel(); |
---|
16748 | | - object.editWindow.refreshContents(); |
---|
| 17323 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17324 | + |
---|
| 17325 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17326 | + |
---|
| 17327 | + inst.add(paintobj); // link |
---|
| 17328 | + |
---|
| 17329 | + object.GetWindow().SnapObject(inst); |
---|
| 17330 | + |
---|
| 17331 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17332 | + |
---|
| 17333 | + folder.add(inst); |
---|
| 17334 | + |
---|
| 17335 | + object.GetWindow().ResetModel(); |
---|
| 17336 | + object.GetWindow().refreshContents(); |
---|
| 17337 | + } |
---|
16749 | 17338 | } |
---|
16750 | 17339 | else |
---|
16751 | 17340 | paintcount = 0; |
---|
.. | .. |
---|
16839 | 17428 | |
---|
16840 | 17429 | public void init(GLAutoDrawable drawable) |
---|
16841 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
16842 | 17432 | System.out.println("shadow buffer init"); |
---|
16843 | 17433 | |
---|
16844 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17067 | 17657 | gl.glFlush(); |
---|
17068 | 17658 | |
---|
17069 | 17659 | /**/ |
---|
17070 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17660 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17071 | 17661 | |
---|
17072 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17073 | 17663 | |
---|
| 17664 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17665 | + |
---|
| 17666 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17667 | + |
---|
17074 | 17668 | double r = 0, g = 0, b = 0; |
---|
17075 | 17669 | |
---|
17076 | 17670 | double count = 0; |
---|
.. | .. |
---|
17081 | 17675 | |
---|
17082 | 17676 | double FACTOR = 1; |
---|
17083 | 17677 | |
---|
17084 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
17085 | 17679 | { |
---|
17086 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17087 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17164 | 17758 | |
---|
17165 | 17759 | double scale = ray.z; // 1; // cos |
---|
17166 | 17760 | |
---|
17167 | | - float depth = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
17168 | 17762 | |
---|
17169 | 17763 | /* |
---|
17170 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17361 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17362 | 17956 | static IntBuffer bigAAbuffer; |
---|
17363 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17364 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17365 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17366 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17367 | 17961 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17368 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17962 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17963 | + |
---|
| 17964 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17965 | + |
---|
17369 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17370 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17371 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|