.. | .. |
---|
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 | |
---|
2401 | | - private void GetRemoteZip(String url, String name, boolean unzip, boolean save) |
---|
| 2464 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
2402 | 2465 | { |
---|
2403 | | - java.net.URL u; |
---|
2404 | | - InputStream is = null; |
---|
2405 | | - DataInputStream dis; |
---|
2406 | | - java.util.zip.ZipInputStream zis; |
---|
2407 | | - //String s; |
---|
| 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 | + } |
---|
2408 | 2478 | |
---|
2409 | | - System.out.println("GetRemoteZip " + name); |
---|
2410 | | - |
---|
2411 | | - int total = 0; // dis.available(); |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
2412 | 2482 | |
---|
2413 | | - byte[] bytes = new byte[16384]; |
---|
2414 | | - |
---|
2415 | | - try |
---|
2416 | | - { |
---|
2417 | | - u = new java.net.URL(url + name); |
---|
2418 | | - is = u.openStream(); |
---|
2419 | | - |
---|
2420 | | - System.out.println(url + name); |
---|
2421 | | - |
---|
2422 | | - if (unzip) |
---|
2423 | | - { |
---|
2424 | | - //dis = new DataInputStream(new BufferedInputStream(is)); |
---|
2425 | | - zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is)); |
---|
2426 | | - //while ((s = dis.readLine()) != null) |
---|
2427 | | - |
---|
2428 | | - if (save) |
---|
2429 | | - new java.io.File(name).mkdirs(); |
---|
2430 | | - |
---|
2431 | | - // FileOutputStream stream = new FileOutputStream("test.zip"); |
---|
2432 | | - // |
---|
2433 | | - // int count; |
---|
2434 | | - // |
---|
2435 | | - // while ((count = dis.read(bytes)) != -1) |
---|
2436 | | - // { |
---|
2437 | | - // //System.out.println(s); |
---|
2438 | | - // System.out.println(count); |
---|
2439 | | - // total += count; |
---|
2440 | | - // stream.write(bytes); |
---|
2441 | | - // } |
---|
2442 | | - // |
---|
2443 | | - // stream.close(); |
---|
2444 | | - |
---|
2445 | | - // now iterate through each item in the stream. The get next |
---|
2446 | | - // entry call will return a ZipEntry for each file in the |
---|
2447 | | - // stream |
---|
2448 | | - java.util.zip.ZipEntry entry; |
---|
2449 | | - while((entry = zis.getNextEntry())!=null) |
---|
2450 | | - { |
---|
2451 | | - if (entry.getName().endsWith(".gsm")) |
---|
2452 | | - { |
---|
2453 | | - continue; |
---|
2454 | | - } |
---|
2455 | | - |
---|
2456 | | - String s = String.format("Entry: %s len %d added %TD", |
---|
2457 | | - entry.getName(), entry.getSize(), |
---|
2458 | | - new java.util.Date(entry.getTime())); |
---|
2459 | | - System.out.println(s); |
---|
2460 | | - |
---|
2461 | | - if (save) |
---|
2462 | | - { |
---|
2463 | | - // Once we get the entry from the stream, the stream is |
---|
2464 | | - // positioned read to read the raw data, and we keep |
---|
2465 | | - // reading until read returns 0 or less. |
---|
2466 | | - String outpath = name + "/" + entry.getName(); |
---|
2467 | | - FileOutputStream output = null; |
---|
2468 | | - try |
---|
2469 | | - { |
---|
2470 | | - output = new FileOutputStream(outpath); |
---|
2471 | | - int len = 0; |
---|
2472 | | - while ((len = zis.read(bytes)) > 0) |
---|
2473 | | - { |
---|
2474 | | - output.write(bytes, 0, len); |
---|
2475 | | - } |
---|
2476 | | - } |
---|
2477 | | - finally |
---|
2478 | | - { |
---|
2479 | | - // we must always close the output file |
---|
2480 | | - if(output!=null) output.close(); |
---|
2481 | | - } |
---|
2482 | | - } |
---|
2483 | | - } |
---|
2484 | | - } |
---|
2485 | | - } |
---|
2486 | | - catch (java.net.MalformedURLException mue) |
---|
2487 | | - { |
---|
2488 | | - System.err.println("Ouch - a MalformedURLException happened."); |
---|
2489 | | - mue.printStackTrace(); |
---|
2490 | | - //System.exit(2); |
---|
2491 | | - } |
---|
2492 | | - catch (IOException ioe) |
---|
2493 | | - { |
---|
2494 | | - //System.err.println("Oops - an IOException happened."); |
---|
2495 | | - //ioe.printStackTrace(); |
---|
2496 | | - //System.exit(3); |
---|
2497 | | - } |
---|
2498 | | - finally |
---|
2499 | | - { |
---|
2500 | | - try |
---|
2501 | | - { |
---|
2502 | | - if (is != null) |
---|
2503 | | - is.close(); |
---|
2504 | | - } |
---|
2505 | | - catch (IOException ioe) |
---|
2506 | | - { |
---|
2507 | | - } |
---|
2508 | | - } |
---|
2509 | | - |
---|
2510 | | - // System.out.println("length = " + total); |
---|
2511 | | - |
---|
2512 | | -// try |
---|
2513 | | -// { |
---|
2514 | | -// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); |
---|
2515 | | -// } |
---|
2516 | | -// catch (Exception e) |
---|
2517 | | -// { |
---|
2518 | | -// e.printStackTrace(); |
---|
2519 | | -// } |
---|
2520 | | - |
---|
| 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); |
---|
2521 | 2489 | } |
---|
2522 | 2490 | |
---|
2523 | 2491 | /**/ |
---|
.. | .. |
---|
2528 | 2496 | |
---|
2529 | 2497 | int resolution; |
---|
2530 | 2498 | |
---|
2531 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2499 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2532 | 2500 | { |
---|
2533 | | - texture = tex; |
---|
| 2501 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2502 | + texturedata = texdata; |
---|
2534 | 2503 | resolution = res; |
---|
2535 | 2504 | } |
---|
2536 | 2505 | } |
---|
2537 | 2506 | /**/ |
---|
2538 | 2507 | |
---|
2539 | 2508 | // TEXTURE static Texture texture; |
---|
2540 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2541 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2542 | | - 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 | + |
---|
2543 | 2514 | int pigmentdepth = 0; |
---|
2544 | 2515 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2545 | 2516 | int bumpdepth = 0; |
---|
2546 | 2517 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2547 | 2518 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2548 | 2519 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2549 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2520 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2550 | 2521 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2551 | 2522 | |
---|
2552 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2523 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2553 | 2524 | { |
---|
2554 | 2525 | TextureData texturedata = null; |
---|
2555 | 2526 | |
---|
.. | .. |
---|
2559 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2560 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2561 | 2532 | true, |
---|
2562 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2563 | 2534 | } catch (java.io.IOException e) |
---|
2564 | 2535 | { |
---|
2565 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2568 | 2539 | if (bump) |
---|
2569 | 2540 | texturedata = ConvertBump(texturedata, false); |
---|
2570 | 2541 | |
---|
2571 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2572 | | - 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); |
---|
2573 | 2544 | |
---|
2574 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2575 | | - 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); |
---|
2576 | 2547 | |
---|
2577 | | - 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; |
---|
2578 | 2570 | } |
---|
2579 | 2571 | |
---|
2580 | 2572 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3647 | 3639 | |
---|
3648 | 3640 | System.out.println("LOADING TEXTURE : " + name); |
---|
3649 | 3641 | |
---|
| 3642 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3643 | + |
---|
3650 | 3644 | // |
---|
3651 | 3645 | if (false) // compressbit > 0) |
---|
3652 | 3646 | { |
---|
.. | .. |
---|
8045 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
8046 | 8040 | String bump = Object3D.GetBump(tex); |
---|
8047 | 8041 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8043 | { |
---|
8050 | 8044 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8045 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8060 | 8054 | pigment = null; |
---|
8061 | 8055 | } |
---|
8062 | 8056 | |
---|
8063 | | - ReleaseTexture(bump, true); |
---|
8064 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, true); |
---|
| 8058 | + ReleaseTexture(tex, false); |
---|
8065 | 8059 | } |
---|
8066 | 8060 | |
---|
8067 | 8061 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8079 | 8073 | |
---|
8080 | 8074 | String pigment = Object3D.GetPigment(tex); |
---|
8081 | 8075 | |
---|
8082 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8076 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8083 | 8077 | { |
---|
8084 | 8078 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8085 | 8079 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8090 | 8084 | pigment = null; |
---|
8091 | 8085 | } |
---|
8092 | 8086 | |
---|
8093 | | - ReleaseTexture(pigment, false); |
---|
| 8087 | + ReleaseTexture(tex, false); |
---|
8094 | 8088 | } |
---|
8095 | 8089 | |
---|
8096 | 8090 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8108 | 8102 | |
---|
8109 | 8103 | String bump = Object3D.GetBump(tex); |
---|
8110 | 8104 | |
---|
8111 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8105 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8112 | 8106 | { |
---|
8113 | 8107 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8114 | 8108 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8119 | 8113 | bump = null; |
---|
8120 | 8114 | } |
---|
8121 | 8115 | |
---|
8122 | | - ReleaseTexture(bump, true); |
---|
| 8116 | + ReleaseTexture(tex, true); |
---|
8123 | 8117 | } |
---|
8124 | 8118 | |
---|
8125 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8119 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8126 | 8120 | { |
---|
8127 | 8121 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8128 | 8122 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8133 | 8127 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8134 | 8128 | |
---|
8135 | 8129 | if (tex != null) |
---|
8136 | | - texture = textures.get(tex); |
---|
| 8130 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8137 | 8131 | |
---|
8138 | 8132 | // //assert( texture != null ); |
---|
8139 | 8133 | // if (texture == null) |
---|
.. | .. |
---|
8227 | 8221 | |
---|
8228 | 8222 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8229 | 8223 | { |
---|
8230 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8231 | | - ambientOcclusion ) // || !textureon) |
---|
8232 | | - { |
---|
8233 | | - return; // false; |
---|
8234 | | - } |
---|
8235 | | - |
---|
8236 | | - if (tex == null) |
---|
8237 | | - { |
---|
8238 | | - BindTexture(null,false,resolution); |
---|
8239 | | - BindTexture(null,true,resolution); |
---|
8240 | | - return; |
---|
8241 | | - } |
---|
| 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; |
---|
8242 | 8265 | |
---|
8243 | | - String pigment = Object3D.GetPigment(tex); |
---|
8244 | | - String bump = Object3D.GetBump(tex); |
---|
8245 | | - |
---|
8246 | | - usedtextures.put(pigment, pigment); |
---|
8247 | | - usedtextures.put(bump, bump); |
---|
8248 | | - |
---|
8249 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8250 | | - { |
---|
8251 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8252 | | - // System.out.println("; bump = " + bump); |
---|
8253 | | - } |
---|
8254 | | - |
---|
8255 | | - if (bump.equals("")) |
---|
8256 | | - { |
---|
8257 | | - bump = null; |
---|
8258 | | - } |
---|
8259 | | - if (pigment.equals("")) |
---|
8260 | | - { |
---|
8261 | | - pigment = null; |
---|
8262 | | - } |
---|
8263 | | - |
---|
8264 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8265 | | - BindTexture(pigment, false, resolution); |
---|
8266 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8267 | | - BindTexture(bump, true, resolution); |
---|
8268 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8269 | | - |
---|
8270 | | - return; // true; |
---|
| 8266 | + BindPigmentTexture(tex, resolution); |
---|
| 8267 | + BindBumpTexture(tex, resolution); |
---|
8271 | 8268 | } |
---|
8272 | 8269 | |
---|
8273 | 8270 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8286 | 8283 | |
---|
8287 | 8284 | String pigment = Object3D.GetPigment(tex); |
---|
8288 | 8285 | |
---|
8289 | | - usedtextures.put(pigment, pigment); |
---|
| 8286 | + usedtextures.add(tex); |
---|
8290 | 8287 | |
---|
8291 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8288 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8292 | 8289 | { |
---|
8293 | 8290 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8294 | 8291 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8300 | 8297 | } |
---|
8301 | 8298 | |
---|
8302 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8303 | | - BindTexture(pigment, false, resolution); |
---|
| 8300 | + BindTexture(tex, false, resolution); |
---|
8304 | 8301 | } |
---|
8305 | 8302 | |
---|
8306 | 8303 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8319 | 8316 | |
---|
8320 | 8317 | String bump = Object3D.GetBump(tex); |
---|
8321 | 8318 | |
---|
8322 | | - usedtextures.put(bump, bump); |
---|
| 8319 | + usedtextures.add(tex); |
---|
8323 | 8320 | |
---|
8324 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8321 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8325 | 8322 | { |
---|
8326 | 8323 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8327 | 8324 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8333 | 8330 | } |
---|
8334 | 8331 | |
---|
8335 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8336 | | - BindTexture(bump, true, resolution); |
---|
| 8333 | + BindTexture(tex, true, resolution); |
---|
8337 | 8334 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8338 | 8335 | } |
---|
8339 | 8336 | |
---|
.. | .. |
---|
8357 | 8354 | return fileExists; |
---|
8358 | 8355 | } |
---|
8359 | 8356 | |
---|
8360 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8357 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8361 | 8358 | { |
---|
8362 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8359 | + CacheTexture texturecache = null; |
---|
8363 | 8360 | |
---|
8364 | 8361 | if (tex != null) |
---|
8365 | 8362 | { |
---|
8366 | | - 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 | + } |
---|
8367 | 8370 | |
---|
8368 | 8371 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8369 | 8372 | |
---|
.. | .. |
---|
8373 | 8376 | // else |
---|
8374 | 8377 | // if (!texname.startsWith("/")) |
---|
8375 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8376 | | - if (!FileExists(tex)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8377 | 8380 | { |
---|
8378 | 8381 | texname = fallbackTextureName; |
---|
8379 | 8382 | } |
---|
8380 | 8383 | |
---|
8381 | 8384 | if (CACHETEXTURE) |
---|
8382 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8383 | | - |
---|
8384 | | - TextureData texturedata = null; |
---|
8385 | | - |
---|
8386 | | - if (texture == null || texture.resolution < resolution) |
---|
8387 | 8385 | { |
---|
8388 | | - 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("")) |
---|
8389 | 8419 | { |
---|
8390 | 8420 | assert(!bump); |
---|
8391 | 8421 | // if (bump) |
---|
.. | .. |
---|
8396 | 8426 | // } |
---|
8397 | 8427 | // else |
---|
8398 | 8428 | // { |
---|
8399 | | - texture = textures.get(tex); |
---|
8400 | | - if (texture == null) |
---|
| 8429 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8430 | + if (texturecache == null) |
---|
8401 | 8431 | { |
---|
8402 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8432 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8403 | 8433 | } |
---|
| 8434 | + else |
---|
| 8435 | + new Exception().printStackTrace(); |
---|
8404 | 8436 | // } |
---|
8405 | 8437 | } else |
---|
8406 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8438 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8407 | 8439 | { |
---|
8408 | 8440 | assert(bump); |
---|
8409 | | - texture = textures.get(tex); |
---|
8410 | | - if (texture == null) |
---|
8411 | | - 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(); |
---|
8412 | 8446 | } else |
---|
8413 | 8447 | { |
---|
8414 | 8448 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8416 | 8450 | // texture = GetResourceTexture("default.png"); |
---|
8417 | 8451 | //} else |
---|
8418 | 8452 | //{ |
---|
8419 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8453 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8420 | 8454 | { |
---|
8421 | | - texture = textures.get(tex); |
---|
8422 | | - if (texture == null) |
---|
8423 | | - 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(); |
---|
8424 | 8469 | } else |
---|
8425 | 8470 | { |
---|
8426 | 8471 | if (textureon) |
---|
.. | .. |
---|
8479 | 8524 | if (texturedata == null) |
---|
8480 | 8525 | throw new Exception(); |
---|
8481 | 8526 | |
---|
8482 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8527 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8483 | 8528 | //texture = GetTexture(tex, bump); |
---|
8484 | 8529 | } |
---|
| 8530 | + } |
---|
8485 | 8531 | } |
---|
8486 | 8532 | //} |
---|
8487 | 8533 | } |
---|
8488 | 8534 | |
---|
8489 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8535 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8490 | 8536 | { |
---|
8491 | 8537 | //return false; |
---|
8492 | 8538 | |
---|
8493 | 8539 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8494 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8540 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8495 | 8541 | { |
---|
8496 | 8542 | // String ext = "_highres"; |
---|
8497 | 8543 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8508 | 8554 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8509 | 8555 | if (!cachefile.exists()) |
---|
8510 | 8556 | { |
---|
8511 | | - // cache to disk |
---|
8512 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8513 | | - //buffers[0]. |
---|
8514 | | - |
---|
8515 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8516 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8517 | | - |
---|
8518 | | - // squared size heuristic... |
---|
8519 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8557 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8520 | 8558 | { |
---|
8521 | | - for (int i=pixels.length; --i>=0;) |
---|
8522 | | - { |
---|
8523 | | - int i3 = i*3; |
---|
8524 | | - pixels[i] = 0xFF; |
---|
8525 | | - pixels[i] <<= 8; |
---|
8526 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8527 | | - pixels[i] <<= 8; |
---|
8528 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8529 | | - pixels[i] <<= 8; |
---|
8530 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8531 | | - } |
---|
8532 | | - |
---|
8533 | | - /* |
---|
8534 | | - int r=0,g=0,b=0,a=0; |
---|
8535 | | - for (int i=0; i<width; i++) |
---|
8536 | | - for (int j=0; j<height; j++) |
---|
8537 | | - { |
---|
8538 | | - int index = j*width+i; |
---|
8539 | | - int p = pixels[index]; |
---|
8540 | | - a = ((p>>24) & 0xFF); |
---|
8541 | | - r = ((p>>16) & 0xFF); |
---|
8542 | | - g = ((p>>8) & 0xFF); |
---|
8543 | | - b = (p & 0xFF); |
---|
8544 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8545 | | - } |
---|
8546 | | - /**/ |
---|
8547 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8548 | | - int height = width; |
---|
8549 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8550 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8559 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8560 | + |
---|
8551 | 8561 | ImageWriter writer = null; |
---|
8552 | 8562 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8553 | 8563 | if (iter.hasNext()) { |
---|
8554 | 8564 | writer = (ImageWriter)iter.next(); |
---|
8555 | 8565 | } |
---|
8556 | | - float compressionQuality = 0.9f; |
---|
| 8566 | + |
---|
| 8567 | + float compressionQuality = 0.85f; |
---|
8557 | 8568 | try |
---|
8558 | 8569 | { |
---|
8559 | 8570 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8570 | 8581 | } |
---|
8571 | 8582 | } |
---|
8572 | 8583 | } |
---|
8573 | | - |
---|
| 8584 | + |
---|
| 8585 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8586 | + |
---|
8574 | 8587 | //System.out.println("Texture = " + tex); |
---|
8575 | | - if (textures.containsKey(texname)) |
---|
| 8588 | + if (textures.containsKey(tex)) |
---|
8576 | 8589 | { |
---|
8577 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8590 | + CacheTexture thetex = textures.get(tex); |
---|
8578 | 8591 | thetex.texture.disable(); |
---|
8579 | 8592 | thetex.texture.dispose(); |
---|
8580 | | - textures.remove(texname); |
---|
| 8593 | + textures.remove(tex); |
---|
8581 | 8594 | } |
---|
8582 | 8595 | |
---|
8583 | | - texture.texturedata = texturedata; |
---|
8584 | | - textures.put(texname, texture); |
---|
| 8596 | + //texture.texturedata = texturedata; |
---|
| 8597 | + textures.put(tex, texturecache); |
---|
8585 | 8598 | |
---|
8586 | 8599 | // newtex = true; |
---|
8587 | 8600 | } |
---|
.. | .. |
---|
8597 | 8610 | } |
---|
8598 | 8611 | } |
---|
8599 | 8612 | |
---|
8600 | | - return texture; |
---|
| 8613 | + return texturecache; |
---|
8601 | 8614 | } |
---|
8602 | 8615 | |
---|
8603 | | - 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 |
---|
8604 | 8651 | { |
---|
8605 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8606 | 8653 | |
---|
.. | .. |
---|
8618 | 8665 | return texture!=null?texture.texture:null; |
---|
8619 | 8666 | } |
---|
8620 | 8667 | |
---|
8621 | | - 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 |
---|
8622 | 8669 | { |
---|
8623 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8624 | 8671 | |
---|
8625 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8626 | 8673 | } |
---|
8627 | 8674 | |
---|
8628 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8629 | 8676 | { |
---|
8630 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8631 | 8678 | { |
---|
8632 | 8679 | return false; |
---|
8633 | 8680 | } |
---|
8634 | 8681 | |
---|
8635 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8636 | 8683 | |
---|
8637 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8638 | 8685 | |
---|
.. | .. |
---|
8664 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8665 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8666 | 8713 | |
---|
8667 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8668 | 8715 | } |
---|
8669 | 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 | + |
---|
8670 | 8783 | ShadowBuffer shadowPBuf; |
---|
8671 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8672 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8683 | 8796 | |
---|
8684 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8685 | 8798 | MAXSTACK = temp[0]; |
---|
8686 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8687 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8688 | 8802 | MAXSTACK = temp[0]; |
---|
8689 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8690 | 8805 | |
---|
8691 | 8806 | // Use debug pipeline |
---|
8692 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8694 | 8809 | gl = drawable.getGL(); // |
---|
8695 | 8810 | |
---|
8696 | 8811 | GL gl3 = getGL(); |
---|
8697 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8698 | 8814 | |
---|
8699 | 8815 | |
---|
8700 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8859 | 8975 | |
---|
8860 | 8976 | if (cubemap == null) |
---|
8861 | 8977 | { |
---|
8862 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8863 | 8979 | } |
---|
8864 | 8980 | |
---|
8865 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9135 | 9251 | |
---|
9136 | 9252 | void LoadEnvy(int which) |
---|
9137 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9138 | 9256 | String name; |
---|
9139 | 9257 | String ext; |
---|
9140 | 9258 | |
---|
.. | .. |
---|
9146 | 9264 | cubemap = null; |
---|
9147 | 9265 | return; |
---|
9148 | 9266 | case 1: |
---|
9149 | | - name = "cubemaps/box_"; |
---|
9150 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9151 | 9269 | reverseUP = false; |
---|
9152 | 9270 | break; |
---|
9153 | 9271 | case 2: |
---|
9154 | | - name = "cubemaps/uffizi_"; |
---|
9155 | | - ext = "png"; |
---|
9156 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9157 | 9276 | case 3: |
---|
9158 | | - name = "cubemaps/CloudyHills_"; |
---|
9159 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9160 | 9279 | reverseUP = false; |
---|
9161 | 9280 | break; |
---|
9162 | 9281 | case 4: |
---|
9163 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9164 | 9283 | ext = "png"; |
---|
9165 | 9284 | reverseUP = false; |
---|
9166 | 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; |
---|
9167 | 9311 | default: |
---|
9168 | | - name = "cubemaps/rgb_"; |
---|
9169 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9170 | 9315 | break; |
---|
9171 | 9316 | } |
---|
9172 | | - |
---|
9173 | | - try |
---|
9174 | | - { |
---|
9175 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9176 | | - } catch (IOException e) |
---|
9177 | | - { |
---|
9178 | | - throw new RuntimeException(e); |
---|
9179 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9180 | 9319 | } |
---|
9181 | 9320 | |
---|
9182 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9208 | 9347 | static double[] model = new double[16]; |
---|
9209 | 9348 | double[] camera2light = new double[16]; |
---|
9210 | 9349 | double[] light2camera = new double[16]; |
---|
9211 | | - int newenvy = -1; |
---|
9212 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9213 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9214 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9215 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9627 | 9770 | |
---|
9628 | 9771 | if (renderCamera != lightCamera) |
---|
9629 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9630 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9631 | 9774 | |
---|
9632 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9633 | 9776 | |
---|
.. | .. |
---|
9643 | 9786 | |
---|
9644 | 9787 | if (renderCamera != lightCamera) |
---|
9645 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9646 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9647 | 9790 | |
---|
9648 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9649 | 9792 | |
---|
.. | .. |
---|
9689 | 9832 | rati = 1 / rati; |
---|
9690 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9691 | 9834 | } |
---|
9692 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9693 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9694 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9695 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9696 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9697 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9698 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10558 | 10703 | static boolean init = false; |
---|
10559 | 10704 | |
---|
10560 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10561 | 10709 | |
---|
10562 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10563 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10564 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10565 | 10719 | { |
---|
10566 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10729 | 10883 | |
---|
10730 | 10884 | if (wait) |
---|
10731 | 10885 | { |
---|
10732 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10733 | 10887 | |
---|
10734 | 10888 | wait = false; |
---|
10735 | 10889 | } |
---|
.. | .. |
---|
10844 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10845 | 10999 | if (cam != lightCamera) |
---|
10846 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10847 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10848 | 11002 | |
---|
10849 | 11003 | for (int j = 0; j < 4; j++) |
---|
10850 | 11004 | { |
---|
.. | .. |
---|
10859 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10860 | 11014 | if (cam != lightCamera) |
---|
10861 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10862 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10863 | 11017 | |
---|
10864 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10865 | 11019 | |
---|
.. | .. |
---|
10945 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10946 | 11100 | } |
---|
10947 | 11101 | |
---|
10948 | | - 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")) |
---|
10949 | 11110 | { |
---|
10950 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
10951 | 11117 | } |
---|
10952 | | - |
---|
10953 | | - newenvy = -1; |
---|
10954 | | - |
---|
| 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 | + |
---|
10955 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
10956 | 11140 | //System.out.println("ratio = " + ratio); |
---|
10957 | 11141 | |
---|
.. | .. |
---|
10967 | 11151 | |
---|
10968 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
10969 | 11153 | { |
---|
10970 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
10971 | 11155 | } |
---|
10972 | 11156 | |
---|
10973 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
11150 | 11334 | |
---|
11151 | 11335 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11152 | 11336 | |
---|
11153 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11154 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
11155 | | -//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); |
---|
11156 | 11340 | } else |
---|
11157 | 11341 | { |
---|
11158 | 11342 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11163 | 11347 | //System.out.println("BLENDING ON"); |
---|
11164 | 11348 | gl.glEnable(GL.GL_BLEND); |
---|
11165 | 11349 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11166 | | - |
---|
| 11350 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11167 | 11351 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11168 | 11352 | gl.glLoadIdentity(); |
---|
11169 | 11353 | |
---|
.. | .. |
---|
11253 | 11437 | |
---|
11254 | 11438 | // if (cam != lightCamera) |
---|
11255 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11256 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11257 | 11441 | } |
---|
11258 | 11442 | |
---|
11259 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11412 | 11596 | } |
---|
11413 | 11597 | } |
---|
11414 | 11598 | |
---|
11415 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11416 | 11600 | { |
---|
11417 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11418 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11420 | 11604 | |
---|
11421 | 11605 | boolean texon = textureon; |
---|
11422 | 11606 | |
---|
11423 | | - if (RENDERPROGRAM > 0) |
---|
11424 | | - { |
---|
11425 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11426 | | - textureon = false; |
---|
11427 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
11428 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11429 | 11611 | //System.out.println("ALLO"); |
---|
11430 | 11612 | gl.glColorMask(false, false, false, false); |
---|
11431 | 11613 | DrawObject(gl); |
---|
11432 | | - if (RENDERPROGRAM > 0) |
---|
11433 | | - { |
---|
11434 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11435 | | - textureon = texon; |
---|
11436 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
11437 | 11618 | gl.glColorMask(true, true, true, true); |
---|
11438 | 11619 | |
---|
11439 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11440 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
11441 | 11622 | } |
---|
11442 | 11623 | |
---|
11443 | 11624 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11649 | 11830 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11650 | 11831 | { |
---|
11651 | 11832 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11652 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11833 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11653 | 11834 | pingthread.StepToTarget(true); // true); |
---|
11654 | 11835 | // zoomonce = false; |
---|
11655 | 11836 | } |
---|
.. | .. |
---|
11777 | 11958 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11778 | 11959 | |
---|
11779 | 11960 | if (CLEANCACHE) |
---|
11780 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11961 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11781 | 11962 | { |
---|
11782 | | - String tex = e.nextElement(); |
---|
| 11963 | + cTexture tex = e.nextElement(); |
---|
11783 | 11964 | |
---|
11784 | 11965 | // System.out.println("Texture --------- " + tex); |
---|
11785 | 11966 | |
---|
11786 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11967 | + if (tex.equals("WHITE_NOISE:")) |
---|
11787 | 11968 | continue; |
---|
11788 | 11969 | |
---|
11789 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11970 | + if (!usedtextures.contains(tex)) |
---|
11790 | 11971 | { |
---|
| 11972 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11791 | 11973 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11792 | | - textures.get(tex).texture.dispose(); |
---|
11793 | | - 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 | + } |
---|
11794 | 11987 | } |
---|
11795 | 11988 | } |
---|
11796 | 11989 | } |
---|
.. | .. |
---|
12318 | 12511 | |
---|
12319 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12320 | 12513 | |
---|
12321 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12322 | 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 | + |
---|
12323 | 12584 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12324 | 12585 | "PARAM light2cam0 = program.env[10];" + |
---|
12325 | 12586 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12345 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12346 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12347 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12348 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12349 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12350 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12351 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12434 | 12695 | "TEMP shininess;" + |
---|
12435 | 12696 | "\n" + |
---|
12436 | 12697 | "MOV texSamp, one;" + |
---|
12437 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12438 | | - |
---|
| 12698 | + |
---|
12439 | 12699 | "MOV mapgrid.x, one2048th.x;" + |
---|
12440 | 12700 | "MOV temp, fragment.texcoord[1];" + |
---|
12441 | 12701 | /* |
---|
.. | .. |
---|
12456 | 12716 | "MUL temp, floor, mapgrid.x;" + |
---|
12457 | 12717 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12458 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12459 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12460 | 12720 | "") + |
---|
12461 | 12721 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12462 | 12722 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12463 | 12723 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12464 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12724 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12465 | 12725 | "") + |
---|
12466 | 12726 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12467 | 12727 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12468 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12728 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12469 | 12729 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12470 | 12730 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12471 | 12731 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12472 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12732 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12473 | 12733 | "") + |
---|
12474 | 12734 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12475 | 12735 | //"MOV params, material;" + |
---|
.. | .. |
---|
12591 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12592 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12593 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12594 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12595 | 12855 | /* |
---|
12596 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12597 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12677 | 12937 | "SUB bump0, bump0, half;" + |
---|
12678 | 12938 | "ADD bump, bump, bump0;" + |
---|
12679 | 12939 | |
---|
12680 | | - "MOV temp.x, texSamp.a;" + |
---|
12681 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12682 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12683 | | - "MOV texSamp.a, temp.x;" + |
---|
12684 | | - |
---|
12685 | 12940 | // double-sided |
---|
12686 | 12941 | /**/ |
---|
12687 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12698 | 12953 | "MOV normald, normal;" + |
---|
12699 | 12954 | "MOV normals, normal;" + |
---|
12700 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12701 | 12958 | // UV base |
---|
12702 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12703 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12704 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12705 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12706 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12707 | | - "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 | + |
---|
12708 | 12967 | "XPD V, normal, UP;" + |
---|
12709 | 12968 | Normalize("V") + |
---|
12710 | 12969 | "XPD U, V, normal;" + |
---|
12711 | 12970 | Normalize("U") + |
---|
12712 | 12971 | |
---|
12713 | 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 texSamp.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;" + |
---|
12714 | 13012 | |
---|
12715 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12716 | 13014 | // |
---|
.. | .. |
---|
12840 | 13138 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12841 | 13139 | "") + |
---|
12842 | 13140 | |
---|
12843 | | - // display shadow only (bump == 0) |
---|
| 13141 | + // display shadow only (fakedepth == 0) |
---|
12844 | 13142 | "SUB temp.x, half.x, shadow.x;" + |
---|
12845 | 13143 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12846 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13144 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12847 | 13145 | "SUB temp.y, one.x, temp.z;" + |
---|
12848 | 13146 | "MUL temp.x, temp.x, temp.y;" + |
---|
12849 | 13147 | "KIL temp.x;" + |
---|
.. | .. |
---|
13174 | 13472 | //once = true; |
---|
13175 | 13473 | } |
---|
13176 | 13474 | |
---|
13177 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13178 | | - 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 | + |
---|
13179 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13180 | 13489 | |
---|
13181 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13222 | 13531 | "\n" + |
---|
13223 | 13532 | "END\n"; |
---|
13224 | 13533 | |
---|
13225 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13226 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13227 | 13537 | |
---|
13228 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13267 | 13577 | return out; |
---|
13268 | 13578 | } |
---|
13269 | 13579 | |
---|
13270 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13580 | + // Also does frustum culling |
---|
| 13581 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13271 | 13582 | { |
---|
13272 | 13583 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13273 | 13584 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13274 | 13585 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13586 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13587 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13275 | 13588 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13276 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13277 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13278 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13279 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13589 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13590 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13280 | 13591 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13281 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13592 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13282 | 13593 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13283 | 13594 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13284 | 13595 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13285 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13596 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13286 | 13597 | |
---|
13287 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13288 | | - //"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;"; |
---|
13289 | 13600 | } |
---|
13290 | 13601 | |
---|
13291 | 13602 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13332 | 13643 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13333 | 13644 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13334 | 13645 | |
---|
13335 | | - // No shadow when out of frustrum |
---|
| 13646 | + // No shadow when out of frustum |
---|
13336 | 13647 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13337 | 13648 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13338 | 13649 | ""; |
---|
.. | .. |
---|
13479 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13480 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13481 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13482 | | - /*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 |
---|
13483 | 13794 | |
---|
13484 | 13795 | //Object3D.cVector2[] vector2buffer; |
---|
13485 | 13796 | |
---|
.. | .. |
---|
13646 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13647 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13648 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13649 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13650 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13651 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13652 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13707 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13708 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13709 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13710 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13711 | 14022 | "MOV result.texcoord, temp;" + |
---|
13712 | 14023 | // border fade |
---|
13713 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13754 | 14065 | |
---|
13755 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
13756 | 14067 | |
---|
13757 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
13758 | 14071 | : "MOV result.color, vertex.color;") + |
---|
13759 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13760 | 14073 | : "") + |
---|
.. | .. |
---|
14065 | 14378 | |
---|
14066 | 14379 | // fev 2014??? |
---|
14067 | 14380 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
14068 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14381 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
14069 | 14382 | pingthread.StepToTarget(true); // true); |
---|
14070 | 14383 | } |
---|
14071 | 14384 | // if (!LIVE) |
---|
.. | .. |
---|
14130 | 14443 | drag = false; |
---|
14131 | 14444 | //System.out.println("Mouse DOWN"); |
---|
14132 | 14445 | editObj = false; |
---|
14133 | | - ClickInfo info = new ClickInfo(); |
---|
14134 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14135 | | - info.pane = this; |
---|
14136 | | - info.camera = renderCamera; |
---|
14137 | | - info.x = x; |
---|
14138 | | - info.y = y; |
---|
14139 | | - info.modifiers = modifiersex; |
---|
14140 | | - 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); |
---|
14141 | 14455 | if (!editObj) |
---|
14142 | 14456 | { |
---|
14143 | 14457 | hasMarquee = true; |
---|
.. | .. |
---|
14419 | 14733 | void GoDown(int mod) |
---|
14420 | 14734 | { |
---|
14421 | 14735 | MODIFIERS |= COMMAND; |
---|
14422 | | - /* |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14737 | + /**/ |
---|
14423 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
14424 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
14425 | 14745 | else |
---|
14426 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14427 | | - */ |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14747 | + /**/ |
---|
14428 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
14429 | 14749 | { |
---|
14430 | 14750 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14433 | 14753 | mouseMode |= BACKFORTH; |
---|
14434 | 14754 | } |
---|
14435 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
14436 | 14758 | //prevX = X = anchorX; |
---|
14437 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14438 | 14760 | } |
---|
.. | .. |
---|
14440 | 14762 | void GoUp(int mod) |
---|
14441 | 14763 | { |
---|
14442 | 14764 | MODIFIERS |= COMMAND; |
---|
14443 | | - /* |
---|
| 14765 | + /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
14444 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
14445 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
14446 | 14775 | else |
---|
14447 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14448 | | - */ |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14777 | + /**/ |
---|
14449 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
14450 | 14779 | { |
---|
14451 | 14780 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14454 | 14783 | mouseMode |= BACKFORTH; |
---|
14455 | 14784 | } |
---|
14456 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
14457 | 14788 | //prevX = X = anchorX; |
---|
14458 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14459 | 14790 | } |
---|
.. | .. |
---|
14461 | 14792 | void GoLeft(int mod) |
---|
14462 | 14793 | { |
---|
14463 | 14794 | MODIFIERS |= COMMAND; |
---|
14464 | | - /* |
---|
| 14795 | + /**/ |
---|
14465 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
14466 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14467 | 14798 | else |
---|
14468 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14469 | | - */ |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
| 14805 | + /**/ |
---|
14470 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
14471 | 14807 | { |
---|
14472 | 14808 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14475 | 14811 | mouseMode |= ROTATE; |
---|
14476 | 14812 | } // TRANSLATE; |
---|
14477 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
14478 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14479 | 14817 | prevY = Y = anchorY; |
---|
14480 | 14818 | } |
---|
.. | .. |
---|
14482 | 14820 | void GoRight(int mod) |
---|
14483 | 14821 | { |
---|
14484 | 14822 | MODIFIERS |= COMMAND; |
---|
14485 | | - /* |
---|
| 14823 | + /**/ |
---|
14486 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
14487 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14488 | 14826 | else |
---|
14489 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14490 | | - */ |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
| 14834 | + /**/ |
---|
14491 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
14492 | 14836 | { |
---|
14493 | 14837 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14496 | 14840 | mouseMode |= ROTATE; |
---|
14497 | 14841 | } // TRANSLATE; |
---|
14498 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
14499 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14500 | 14846 | prevY = Y = anchorY; |
---|
14501 | 14847 | } |
---|
.. | .. |
---|
14537 | 14883 | if (editObj) |
---|
14538 | 14884 | { |
---|
14539 | 14885 | drag = true; |
---|
14540 | | - ClickInfo info = new ClickInfo(); |
---|
14541 | | - info.bounds.setBounds(0, 0, |
---|
| 14886 | + //ClickInfo info = new ClickInfo(); |
---|
| 14887 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14542 | 14888 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14543 | | - info.pane = this; |
---|
14544 | | - info.camera = renderCamera; |
---|
14545 | | - info.x = x; |
---|
14546 | | - info.y = y; |
---|
14547 | | - object.GetWindow().copy |
---|
14548 | | - .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); |
---|
14549 | 14896 | } else |
---|
14550 | 14897 | { |
---|
14551 | 14898 | if (x < startX) |
---|
.. | .. |
---|
14694 | 15041 | } |
---|
14695 | 15042 | } |
---|
14696 | 15043 | |
---|
| 15044 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15045 | + |
---|
14697 | 15046 | public void mouseMoved(MouseEvent e) |
---|
14698 | 15047 | { |
---|
14699 | 15048 | //System.out.println("mouseMoved: " + e); |
---|
14700 | 15049 | if (isRenderer) |
---|
14701 | 15050 | return; |
---|
14702 | 15051 | |
---|
14703 | | - ClickInfo ci = new ClickInfo(); |
---|
14704 | | - ci.x = e.getX(); |
---|
14705 | | - ci.y = e.getY(); |
---|
14706 | | - ci.modifiers = e.getModifiersEx(); |
---|
14707 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14708 | | - ci.pane = this; |
---|
14709 | | - 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; |
---|
14710 | 15059 | if (!isRenderer) |
---|
14711 | 15060 | { |
---|
14712 | 15061 | //ObjEditor editWindow = object.editWindow; |
---|
14713 | 15062 | //Object3D copy = editWindow.copy; |
---|
14714 | | - if (object.doEditClick(ci, 0)) |
---|
| 15063 | + if (object.doEditClick(//clickInfo, |
---|
| 15064 | + 0)) |
---|
14715 | 15065 | { |
---|
14716 | 15066 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14717 | 15067 | } else |
---|
.. | .. |
---|
14726 | 15076 | Globals.MOUSEDRAGGED = false; |
---|
14727 | 15077 | |
---|
14728 | 15078 | movingcamera = false; |
---|
14729 | | - X = Y = 0; |
---|
| 15079 | + X = 0; // getBounds().width/2; |
---|
| 15080 | + Y = 0; // getBounds().height/2; |
---|
14730 | 15081 | //System.out.println("mouseReleased: " + e); |
---|
14731 | 15082 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14732 | 15083 | } |
---|
.. | .. |
---|
14982 | 15333 | // break; |
---|
14983 | 15334 | case 'T': |
---|
14984 | 15335 | CACHETEXTURE ^= true; |
---|
14985 | | - textures.clear(); |
---|
| 15336 | + texturepigment.clear(); |
---|
| 15337 | + texturebump.clear(); |
---|
14986 | 15338 | // repaint(); |
---|
14987 | 15339 | break; |
---|
14988 | 15340 | case 'Y': |
---|
.. | .. |
---|
14992 | 15344 | case 'K': |
---|
14993 | 15345 | KOMPACTTEXTURE ^= true; |
---|
14994 | 15346 | //textures.clear(); |
---|
14995 | | - break; |
---|
14996 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
14997 | 15349 | // SAVETEXTURE ^= true; |
---|
14998 | 15350 | macromode = true; |
---|
14999 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15067 | 15419 | case 'E' : COMPACT ^= true; |
---|
15068 | 15420 | repaint(); |
---|
15069 | 15421 | break; |
---|
15070 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15422 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15423 | + //DEBUGHSB ^= true; |
---|
| 15424 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
15071 | 15425 | repaint(); |
---|
15072 | 15426 | break; |
---|
15073 | 15427 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
15093 | 15447 | repaint(); |
---|
15094 | 15448 | break; |
---|
15095 | 15449 | case 'l': |
---|
15096 | | - lightMode ^= true; |
---|
15097 | | - Globals.lighttouched = true; |
---|
15098 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
15099 | | - targetLookAt.set(manipCamera.lookAt); |
---|
15100 | | - repaint(); |
---|
15101 | | - break; |
---|
15102 | | - case 'L': |
---|
| 15450 | + //case 'L': |
---|
15103 | 15451 | if (lightMode) |
---|
15104 | 15452 | { |
---|
15105 | 15453 | lightMode = false; |
---|
.. | .. |
---|
15118 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
15119 | 15467 | repaint(); |
---|
15120 | 15468 | break; |
---|
15121 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
15122 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
15123 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
15124 | 15472 | repaint(); |
---|
.. | .. |
---|
15163 | 15511 | OCCLUSION_CULLING ^= true; |
---|
15164 | 15512 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15165 | 15513 | break; |
---|
15166 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15514 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15167 | 15515 | case '1': |
---|
15168 | 15516 | case '2': |
---|
15169 | 15517 | case '3': |
---|
15170 | 15518 | case '4': |
---|
15171 | 15519 | case '5': |
---|
15172 | | - newenvy = Character.getNumericValue(key); |
---|
15173 | | - repaint(); |
---|
15174 | | - break; |
---|
15175 | 15520 | case '6': |
---|
15176 | 15521 | case '7': |
---|
15177 | 15522 | case '8': |
---|
15178 | 15523 | case '9': |
---|
15179 | | - 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 | + } |
---|
15180 | 15532 | repaint(); |
---|
15181 | 15533 | break; |
---|
15182 | 15534 | case '!': |
---|
.. | .. |
---|
15246 | 15598 | // kompactbit = 6; |
---|
15247 | 15599 | // break; |
---|
15248 | 15600 | case ' ': |
---|
15249 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15601 | + lightMode ^= true; |
---|
| 15602 | + Globals.lighttouched = true; |
---|
| 15603 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15604 | + targetLookAt.set(manipCamera.lookAt); |
---|
15250 | 15605 | repaint(); |
---|
15251 | 15606 | break; |
---|
15252 | 15607 | //case '`' : |
---|
.. | .. |
---|
15295 | 15650 | break; |
---|
15296 | 15651 | case '+': |
---|
15297 | 15652 | |
---|
15298 | | - //for (int i=0; i<0x7FFFFFFF; i++) |
---|
15299 | | - { |
---|
15300 | | - //String.format("%08X", i); // "7caca905" |
---|
15301 | | - GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true); |
---|
15302 | | - } |
---|
15303 | | - |
---|
15304 | 15653 | /* |
---|
15305 | 15654 | //fontsize += 1; |
---|
15306 | 15655 | bbzoom *= 2; |
---|
.. | .. |
---|
15318 | 15667 | case '=': |
---|
15319 | 15668 | IncDepth(); |
---|
15320 | 15669 | //fontsize += 1; |
---|
15321 | | - object.editWindow.refreshContents(true); |
---|
| 15670 | + object.GetWindow().refreshContents(true); |
---|
15322 | 15671 | maskbit = 6; |
---|
15323 | 15672 | break; |
---|
15324 | 15673 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15325 | 15674 | DecDepth(); |
---|
15326 | 15675 | maskbit = 5; |
---|
15327 | 15676 | //if(fontsize > 1) fontsize -= 1; |
---|
15328 | | - if (object.editWindow == null) |
---|
15329 | | - new Exception().printStackTrace(); |
---|
15330 | | - else |
---|
15331 | | - object.editWindow.refreshContents(true); |
---|
| 15677 | +// if (object.editWindow == null) |
---|
| 15678 | +// new Exception().printStackTrace(); |
---|
| 15679 | +// else |
---|
| 15680 | + object.GetWindow().refreshContents(true); |
---|
15332 | 15681 | break; |
---|
15333 | 15682 | case '{': |
---|
15334 | 15683 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15552 | 15901 | } |
---|
15553 | 15902 | */ |
---|
15554 | 15903 | |
---|
15555 | | - object.editWindow.EditSelection(false); |
---|
| 15904 | + object.GetWindow().EditSelection(false); |
---|
15556 | 15905 | } |
---|
15557 | 15906 | |
---|
15558 | 15907 | void SelectParent() |
---|
.. | .. |
---|
15569 | 15918 | { |
---|
15570 | 15919 | //selectees.remove(i); |
---|
15571 | 15920 | System.out.println("select parent of " + elem); |
---|
15572 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15921 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15573 | 15922 | } else |
---|
15574 | 15923 | { |
---|
15575 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15924 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15576 | 15925 | } |
---|
15577 | 15926 | |
---|
15578 | 15927 | first = false; |
---|
.. | .. |
---|
15614 | 15963 | for (int j = 0; j < group.children.size(); j++) |
---|
15615 | 15964 | { |
---|
15616 | 15965 | elem = (Object3D) group.children.elementAt(j); |
---|
15617 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15966 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15618 | 15967 | first = false; |
---|
15619 | 15968 | } |
---|
15620 | 15969 | } else |
---|
15621 | 15970 | { |
---|
15622 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15971 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15623 | 15972 | } |
---|
15624 | 15973 | |
---|
15625 | 15974 | first = false; |
---|
.. | .. |
---|
15630 | 15979 | { |
---|
15631 | 15980 | //Composite group = (Composite) object; |
---|
15632 | 15981 | Object3D group = object; |
---|
15633 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15982 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15634 | 15983 | } |
---|
15635 | 15984 | |
---|
15636 | 15985 | void ResetTransform(int mask) |
---|
15637 | 15986 | { |
---|
15638 | 15987 | //Composite group = (Composite) object; |
---|
15639 | 15988 | Object3D group = object; |
---|
15640 | | - group.editWindow.ResetTransform(mask); |
---|
| 15989 | + group.GetWindow().ResetTransform(mask); |
---|
15641 | 15990 | } |
---|
15642 | 15991 | |
---|
15643 | 15992 | void FlipTransform() |
---|
15644 | 15993 | { |
---|
15645 | 15994 | //Composite group = (Composite) object; |
---|
15646 | 15995 | Object3D group = object; |
---|
15647 | | - group.editWindow.FlipTransform(); |
---|
| 15996 | + group.GetWindow().FlipTransform(); |
---|
15648 | 15997 | // group.editWindow.ReduceMesh(true); |
---|
15649 | 15998 | } |
---|
15650 | 15999 | |
---|
.. | .. |
---|
15652 | 16001 | { |
---|
15653 | 16002 | //Composite group = (Composite) object; |
---|
15654 | 16003 | Object3D group = object; |
---|
15655 | | - group.editWindow.PrintMemory(); |
---|
| 16004 | + group.GetWindow().PrintMemory(); |
---|
15656 | 16005 | // group.editWindow.ReduceMesh(true); |
---|
15657 | 16006 | } |
---|
15658 | 16007 | |
---|
.. | .. |
---|
15660 | 16009 | { |
---|
15661 | 16010 | //Composite group = (Composite) object; |
---|
15662 | 16011 | Object3D group = object; |
---|
15663 | | - group.editWindow.ResetCentroid(); |
---|
| 16012 | + group.GetWindow().ResetCentroid(); |
---|
15664 | 16013 | } |
---|
15665 | 16014 | |
---|
15666 | 16015 | void IncDepth() |
---|
.. | .. |
---|
15742 | 16091 | |
---|
15743 | 16092 | int width = getBounds().width; |
---|
15744 | 16093 | int height = getBounds().height; |
---|
15745 | | - ClickInfo info = new ClickInfo(); |
---|
15746 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15747 | 16094 | //Image img = CreateImage(width, height); |
---|
15748 | 16095 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15749 | 16096 | |
---|
.. | .. |
---|
15820 | 16167 | } |
---|
15821 | 16168 | if (object != null && !hasMarquee) |
---|
15822 | 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 | + |
---|
15823 | 16176 | if (isRenderer) |
---|
15824 | 16177 | { |
---|
15825 | | - info.flags++; |
---|
| 16178 | + object.clickInfo.flags++; |
---|
15826 | 16179 | double frameAspect = (double) width / (double) height; |
---|
15827 | 16180 | if (frameAspect > renderCamera.aspect) |
---|
15828 | 16181 | { |
---|
15829 | 16182 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15830 | | - info.bounds.width -= width - desired; |
---|
15831 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16183 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16184 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15832 | 16185 | } else |
---|
15833 | 16186 | { |
---|
15834 | 16187 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15835 | | - info.bounds.height -= height - desired; |
---|
15836 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16188 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16189 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15837 | 16190 | } |
---|
15838 | 16191 | } |
---|
15839 | | - info.g = gr; |
---|
15840 | | - info.camera = renderCamera; |
---|
| 16192 | + |
---|
| 16193 | + object.clickInfo.g = gr; |
---|
| 16194 | + object.clickInfo.camera = renderCamera; |
---|
15841 | 16195 | /* |
---|
15842 | 16196 | // Memory intensive (brep.verticescopy) |
---|
15843 | 16197 | if (!(object instanceof Composite)) |
---|
15844 | 16198 | object.draw(info, 0, false); // SLOW : |
---|
15845 | 16199 | */ |
---|
15846 | | - if (!isRenderer) |
---|
| 16200 | + if (!isRenderer) // && drag) |
---|
15847 | 16201 | { |
---|
15848 | | - object.drawEditHandles(info, 0); |
---|
15849 | | - |
---|
15850 | | - 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) |
---|
15851 | 16205 | { |
---|
15852 | | - 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) |
---|
15853 | 16212 | { |
---|
15854 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15855 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15856 | | - break; |
---|
15857 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15858 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15859 | | - break; |
---|
15860 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15861 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15862 | | - 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; |
---|
15863 | 16220 | } |
---|
15864 | | - |
---|
| 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 | + } |
---|
15865 | 16241 | } |
---|
15866 | 16242 | } |
---|
15867 | 16243 | } |
---|
.. | .. |
---|
15876 | 16252 | if (hasMarquee) |
---|
15877 | 16253 | { |
---|
15878 | 16254 | gr.setXORMode(Color.white); |
---|
15879 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
15880 | 16256 | if (!firstime) |
---|
15881 | 16257 | { |
---|
15882 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16343 | 16719 | private /*static*/ boolean firstime; |
---|
16344 | 16720 | private /*static*/ cVector newView = new cVector(); |
---|
16345 | 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"}; |
---|
16346 | 16724 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16347 | 16725 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16348 | 16726 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16355 | 16733 | { |
---|
16356 | 16734 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16357 | 16735 | |
---|
| 16736 | + int usedsuf = 0; |
---|
| 16737 | + |
---|
16358 | 16738 | for (int i = 0; i < suffixes.length; i++) |
---|
16359 | 16739 | { |
---|
16360 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16361 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16362 | | - mipmapped, |
---|
16363 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16364 | | - if (data == null) |
---|
| 16740 | + String[] suffixe = suffixes; |
---|
| 16741 | + String[] fallback = suffixes2; |
---|
| 16742 | + String[] fallfallback = suffixes3; |
---|
| 16743 | + |
---|
| 16744 | + for (int c=usedsuf; --c>=0;) |
---|
16365 | 16745 | { |
---|
16366 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16746 | +// String[] temp = suffixe; |
---|
| 16747 | +// suffixe = fallback; |
---|
| 16748 | +// fallback = fallfallback; |
---|
| 16749 | +// fallfallback = temp; |
---|
16367 | 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 | + |
---|
16368 | 16779 | //System.out.println("Target = " + targets[i]); |
---|
16369 | 16780 | cubemap.updateImage(data, targets[i]); |
---|
16370 | 16781 | } |
---|
16371 | 16782 | |
---|
16372 | 16783 | return cubemap; |
---|
16373 | 16784 | } |
---|
| 16785 | + |
---|
16374 | 16786 | int bigsphere = -1; |
---|
16375 | 16787 | |
---|
16376 | 16788 | float BGcolor = 0.5f; |
---|
16377 | 16789 | |
---|
16378 | | - private void DrawSkyBox(GL gl) |
---|
| 16790 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16791 | + |
---|
| 16792 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16379 | 16793 | { |
---|
16380 | | - if (envyoff || cubemap == null) |
---|
| 16794 | + if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
| 16796 | + cubemap == null) |
---|
16381 | 16797 | { |
---|
16382 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16383 | 16799 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16392 | 16808 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16393 | 16809 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16394 | 16810 | gl.glLoadIdentity(); |
---|
| 16811 | + gl.glScalef(1,ratio,1); |
---|
16395 | 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 | + |
---|
16396 | 16822 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16397 | 16823 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16398 | 16824 | |
---|
.. | .. |
---|
16424 | 16850 | { |
---|
16425 | 16851 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16426 | 16852 | } |
---|
| 16853 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16427 | 16854 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16428 | 16855 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16429 | 16856 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16464 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16465 | 16892 | |
---|
16466 | 16893 | cubemap.disable(); |
---|
16467 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
16468 | 16896 | if (CULLFACE) |
---|
16469 | 16897 | { |
---|
16470 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16520 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16521 | 16949 | } |
---|
16522 | 16950 | |
---|
16523 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16524 | 16952 | |
---|
16525 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16526 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16659 | 17087 | } |
---|
16660 | 17088 | } |
---|
16661 | 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 | + |
---|
16662 | 17098 | class SelectBuffer implements GLEventListener |
---|
16663 | 17099 | { |
---|
16664 | 17100 | |
---|
.. | .. |
---|
16674 | 17110 | //new Exception().printStackTrace(); |
---|
16675 | 17111 | System.out.println("select buffer init"); |
---|
16676 | 17112 | // Use debug pipeline |
---|
16677 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17113 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16678 | 17114 | |
---|
16679 | 17115 | GL gl = drawable.getGL(); |
---|
16680 | 17116 | |
---|
.. | .. |
---|
16738 | 17174 | |
---|
16739 | 17175 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16740 | 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 | + |
---|
16741 | 17188 | //int tmp = selection_view; |
---|
16742 | 17189 | //selection_view = -1; |
---|
16743 | 17190 | int temp = DrawMode(); |
---|
.. | .. |
---|
16749 | 17196 | // temp = DEFAULT; // patch for selection debug |
---|
16750 | 17197 | Globals.drawMode = temp; // WARNING |
---|
16751 | 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 | + |
---|
16752 | 17210 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16753 | 17211 | |
---|
16754 | 17212 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16852 | 17310 | } |
---|
16853 | 17311 | |
---|
16854 | 17312 | if (!movingcamera && !PAINTMODE) |
---|
16855 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17313 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16856 | 17314 | |
---|
16857 | | - 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) |
---|
16858 | 17316 | { |
---|
16859 | | - 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); |
---|
16860 | 17318 | |
---|
16861 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17319 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17320 | + { |
---|
| 17321 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16862 | 17322 | |
---|
16863 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16864 | | - |
---|
16865 | | - group.add(paintobj); // link |
---|
16866 | | - |
---|
16867 | | - object.editWindow.SnapObject(group); |
---|
16868 | | - |
---|
16869 | | - Object3D folder = object.editWindow.copy; |
---|
16870 | | - |
---|
16871 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16872 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16873 | | - |
---|
16874 | | - folder.add(group); |
---|
16875 | | - |
---|
16876 | | - object.editWindow.ResetModel(); |
---|
16877 | | - 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 | + } |
---|
16878 | 17338 | } |
---|
16879 | 17339 | else |
---|
16880 | 17340 | paintcount = 0; |
---|
.. | .. |
---|
16968 | 17428 | |
---|
16969 | 17429 | public void init(GLAutoDrawable drawable) |
---|
16970 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
16971 | 17432 | System.out.println("shadow buffer init"); |
---|
16972 | 17433 | |
---|
16973 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17196 | 17657 | gl.glFlush(); |
---|
17197 | 17658 | |
---|
17198 | 17659 | /**/ |
---|
17199 | | - 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); |
---|
17200 | 17661 | |
---|
17201 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17202 | 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 | + |
---|
17203 | 17668 | double r = 0, g = 0, b = 0; |
---|
17204 | 17669 | |
---|
17205 | 17670 | double count = 0; |
---|
.. | .. |
---|
17210 | 17675 | |
---|
17211 | 17676 | double FACTOR = 1; |
---|
17212 | 17677 | |
---|
17213 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
17214 | 17679 | { |
---|
17215 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17216 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17293 | 17758 | |
---|
17294 | 17759 | double scale = ray.z; // 1; // cos |
---|
17295 | 17760 | |
---|
17296 | | - float depth = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
17297 | 17762 | |
---|
17298 | 17763 | /* |
---|
17299 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17490 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17491 | 17956 | static IntBuffer bigAAbuffer; |
---|
17492 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17493 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17494 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17495 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17496 | 17961 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17497 | | - 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 | + |
---|
17498 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17499 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17500 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|