.. | .. |
---|
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 | |
---|
.. | .. |
---|
335 | 390 | display.options1[2] = material.shadowbias; |
---|
336 | 391 | display.options1[3] = material.aniso; |
---|
337 | 392 | display.options1[4] = material.anisoV; |
---|
| 393 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 394 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 395 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 396 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 397 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
338 | 398 | display.options2[0] = material.opacity; |
---|
339 | 399 | display.options2[1] = material.diffuse; |
---|
340 | 400 | display.options2[2] = material.factor; |
---|
| 401 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 402 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 403 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
341 | 404 | |
---|
342 | 405 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 406 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 407 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 408 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
343 | 409 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 410 | display.options4[1] = material.subsurface; |
---|
345 | 411 | display.options4[2] = material.sheen; |
---|
| 412 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 413 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 414 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
346 | 415 | |
---|
347 | 416 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 417 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
473 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
474 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
475 | 544 | LA.vecNormalize(obj.v2); |
---|
476 | | - 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); |
---|
477 | 547 | } |
---|
478 | 548 | |
---|
479 | 549 | // P |
---|
.. | .. |
---|
495 | 565 | y += ny * obj.NORMALPUSH; |
---|
496 | 566 | z += nz * obj.NORMALPUSH; |
---|
497 | 567 | |
---|
498 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
499 | 569 | } |
---|
500 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
501 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
527 | 597 | y += ny * obj.NORMALPUSH; |
---|
528 | 598 | z += nz * obj.NORMALPUSH; |
---|
529 | 599 | |
---|
530 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
531 | 601 | } |
---|
532 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
533 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
575 | 645 | y += ny * obj.NORMALPUSH; |
---|
576 | 646 | z += nz * obj.NORMALPUSH; |
---|
577 | 647 | |
---|
578 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
579 | 649 | } |
---|
580 | 650 | |
---|
581 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
811 | 881 | //// tris.postdraw(this); |
---|
812 | 882 | } |
---|
813 | 883 | |
---|
814 | | - static Camera localcamera = new Camera(); |
---|
| 884 | + static Camera localAOcamera = new Camera(); |
---|
815 | 885 | static cVector from = new cVector(); |
---|
816 | 886 | static cVector to = new cVector(); |
---|
817 | 887 | |
---|
.. | .. |
---|
820 | 890 | CameraPane cp = this; |
---|
821 | 891 | |
---|
822 | 892 | Camera keep = cp.RenderCamera(); |
---|
823 | | - cp.renderCamera = localcamera; |
---|
| 893 | + cp.renderCamera = localAOcamera; |
---|
824 | 894 | |
---|
825 | 895 | if (br.trimmed) |
---|
826 | 896 | { |
---|
.. | .. |
---|
838 | 908 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
839 | 909 | LA.xformPos(from, transform, from); |
---|
840 | 910 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
841 | | - localcamera.setAim(from, to); |
---|
| 911 | + localAOcamera.setAim(from, to); |
---|
842 | 912 | |
---|
843 | 913 | CameraPane.occlusionbuffer.display(); |
---|
844 | 914 | |
---|
.. | .. |
---|
872 | 942 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
873 | 943 | LA.xformPos(from, transform, from); |
---|
874 | 944 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
875 | | - localcamera.setAim(from, to); |
---|
| 945 | + localAOcamera.setAim(from, to); |
---|
876 | 946 | |
---|
877 | 947 | CameraPane.occlusionbuffer.display(); |
---|
878 | 948 | |
---|
.. | .. |
---|
1181 | 1251 | { |
---|
1182 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1183 | 1253 | { |
---|
1184 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1185 | 1255 | } else |
---|
1186 | 1256 | { |
---|
1187 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1188 | 1258 | } |
---|
1189 | 1259 | |
---|
1190 | 1260 | if (c != null) |
---|
.. | .. |
---|
1208 | 1278 | { |
---|
1209 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1210 | 1280 | { |
---|
1211 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1212 | 1282 | } else |
---|
1213 | 1283 | { |
---|
1214 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1215 | 1285 | } |
---|
1216 | 1286 | if (c != null) |
---|
1217 | 1287 | { |
---|
.. | .. |
---|
1236 | 1306 | { |
---|
1237 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1238 | 1308 | { |
---|
1239 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1240 | 1310 | } else |
---|
1241 | 1311 | { |
---|
1242 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1243 | 1313 | } |
---|
1244 | 1314 | if (c != null) |
---|
1245 | 1315 | { |
---|
.. | .. |
---|
1421 | 1491 | { |
---|
1422 | 1492 | if (!selectmode) |
---|
1423 | 1493 | { |
---|
1424 | | - 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); |
---|
1425 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1426 | 1496 | |
---|
1427 | 1497 | if (flipV) |
---|
.. | .. |
---|
1433 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1434 | 1504 | } |
---|
1435 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1436 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1437 | 1509 | { |
---|
1438 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1500 | 1572 | { |
---|
1501 | 1573 | return; |
---|
1502 | 1574 | } |
---|
1503 | | - |
---|
1504 | | - float[] colorV = new float[3]; |
---|
1505 | 1575 | |
---|
1506 | 1576 | if (false) // marked) |
---|
1507 | 1577 | { |
---|
.. | .. |
---|
1750 | 1820 | |
---|
1751 | 1821 | display.modelParams7[0] = 0; |
---|
1752 | 1822 | display.modelParams7[1] = 1000; |
---|
1753 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1754 | 1824 | display.modelParams7[3] = 0; |
---|
1755 | 1825 | |
---|
1756 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
1983 | 2053 | switch(viewcode) |
---|
1984 | 2054 | { |
---|
1985 | 2055 | case 0: return "main"; |
---|
1986 | | - case 1: return "one"; |
---|
1987 | | - case 2: return "two"; |
---|
1988 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
1989 | 2059 | case 4: return "light"; |
---|
1990 | 2060 | } |
---|
1991 | 2061 | |
---|
.. | .. |
---|
2051 | 2121 | //System.err.println("Oeil on"); |
---|
2052 | 2122 | OEIL = true; |
---|
2053 | 2123 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2124 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2125 | //pingthread.StepToTarget(true); |
---|
2056 | 2126 | } |
---|
2057 | 2127 | |
---|
.. | .. |
---|
2284 | 2354 | HANDLES ^= true; |
---|
2285 | 2355 | } |
---|
2286 | 2356 | |
---|
| 2357 | + Object3D paintFolder; |
---|
| 2358 | + |
---|
2287 | 2359 | void TogglePaint() |
---|
2288 | 2360 | { |
---|
2289 | 2361 | PAINTMODE ^= true; |
---|
2290 | 2362 | paintcount = 0; |
---|
| 2363 | + |
---|
| 2364 | + if (PAINTMODE) |
---|
| 2365 | + { |
---|
| 2366 | + paintFolder = GetFolder(); |
---|
| 2367 | + } |
---|
2291 | 2368 | } |
---|
2292 | 2369 | |
---|
2293 | 2370 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2384 | 2461 | return currentGL; |
---|
2385 | 2462 | } |
---|
2386 | 2463 | |
---|
| 2464 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2465 | + { |
---|
| 2466 | + Grafreed.Assert(texturedata != null); |
---|
| 2467 | + |
---|
| 2468 | + int width = texturedata.getWidth(); |
---|
| 2469 | + int height = texturedata.getHeight(); |
---|
| 2470 | + |
---|
| 2471 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2472 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2473 | + |
---|
| 2474 | + byte[] bytes = bytebuf.array(); |
---|
| 2475 | + |
---|
| 2476 | + return CreateBim(bytes, width, height); |
---|
| 2477 | + } |
---|
| 2478 | + |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2387 | 2491 | /**/ |
---|
2388 | 2492 | class CacheTexture |
---|
2389 | 2493 | { |
---|
.. | .. |
---|
2392 | 2496 | |
---|
2393 | 2497 | int resolution; |
---|
2394 | 2498 | |
---|
2395 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2499 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2396 | 2500 | { |
---|
2397 | | - texture = tex; |
---|
| 2501 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2502 | + texturedata = texdata; |
---|
2398 | 2503 | resolution = res; |
---|
2399 | 2504 | } |
---|
2400 | 2505 | } |
---|
2401 | 2506 | /**/ |
---|
2402 | 2507 | |
---|
2403 | 2508 | // TEXTURE static Texture texture; |
---|
2404 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2405 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2406 | | - 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 | + |
---|
2407 | 2514 | int pigmentdepth = 0; |
---|
2408 | 2515 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2516 | int bumpdepth = 0; |
---|
2410 | 2517 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2411 | 2518 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2412 | 2519 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2413 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2520 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2414 | 2521 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2415 | 2522 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2523 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2417 | 2524 | { |
---|
2418 | 2525 | TextureData texturedata = null; |
---|
2419 | 2526 | |
---|
.. | .. |
---|
2423 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2424 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2425 | 2532 | true, |
---|
2426 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2427 | 2534 | } catch (java.io.IOException e) |
---|
2428 | 2535 | { |
---|
2429 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2432 | 2539 | if (bump) |
---|
2433 | 2540 | texturedata = ConvertBump(texturedata, false); |
---|
2434 | 2541 | |
---|
2435 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2436 | | - 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); |
---|
2437 | 2544 | |
---|
2438 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2439 | | - 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); |
---|
2440 | 2547 | |
---|
2441 | | - 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; |
---|
2442 | 2570 | } |
---|
2443 | 2571 | |
---|
2444 | 2572 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3511 | 3639 | |
---|
3512 | 3640 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3641 | |
---|
| 3642 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3643 | + |
---|
3514 | 3644 | // |
---|
3515 | 3645 | if (false) // compressbit > 0) |
---|
3516 | 3646 | { |
---|
.. | .. |
---|
7909 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8040 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8041 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8043 | { |
---|
7914 | 8044 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8045 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7924 | 8054 | pigment = null; |
---|
7925 | 8055 | } |
---|
7926 | 8056 | |
---|
7927 | | - ReleaseTexture(bump, true); |
---|
7928 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, true); |
---|
| 8058 | + ReleaseTexture(tex, false); |
---|
7929 | 8059 | } |
---|
7930 | 8060 | |
---|
7931 | 8061 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7943 | 8073 | |
---|
7944 | 8074 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8075 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8076 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8077 | { |
---|
7948 | 8078 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8079 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7954 | 8084 | pigment = null; |
---|
7955 | 8085 | } |
---|
7956 | 8086 | |
---|
7957 | | - ReleaseTexture(pigment, false); |
---|
| 8087 | + ReleaseTexture(tex, false); |
---|
7958 | 8088 | } |
---|
7959 | 8089 | |
---|
7960 | 8090 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7972 | 8102 | |
---|
7973 | 8103 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8104 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8105 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8106 | { |
---|
7977 | 8107 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8108 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7983 | 8113 | bump = null; |
---|
7984 | 8114 | } |
---|
7985 | 8115 | |
---|
7986 | | - ReleaseTexture(bump, true); |
---|
| 8116 | + ReleaseTexture(tex, true); |
---|
7987 | 8117 | } |
---|
7988 | 8118 | |
---|
7989 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8119 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7990 | 8120 | { |
---|
7991 | 8121 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7992 | 8122 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7997 | 8127 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7998 | 8128 | |
---|
7999 | 8129 | if (tex != null) |
---|
8000 | | - texture = textures.get(tex); |
---|
| 8130 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8001 | 8131 | |
---|
8002 | 8132 | // //assert( texture != null ); |
---|
8003 | 8133 | // if (texture == null) |
---|
.. | .. |
---|
8091 | 8221 | |
---|
8092 | 8222 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8223 | { |
---|
8094 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8095 | | - ambientOcclusion ) // || !textureon) |
---|
8096 | | - { |
---|
8097 | | - return; // false; |
---|
8098 | | - } |
---|
8099 | | - |
---|
8100 | | - if (tex == null) |
---|
8101 | | - { |
---|
8102 | | - BindTexture(null,false,resolution); |
---|
8103 | | - BindTexture(null,true,resolution); |
---|
8104 | | - return; |
---|
8105 | | - } |
---|
| 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; |
---|
8106 | 8265 | |
---|
8107 | | - String pigment = Object3D.GetPigment(tex); |
---|
8108 | | - String bump = Object3D.GetBump(tex); |
---|
8109 | | - |
---|
8110 | | - usedtextures.put(pigment, pigment); |
---|
8111 | | - usedtextures.put(bump, bump); |
---|
8112 | | - |
---|
8113 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8114 | | - { |
---|
8115 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8116 | | - // System.out.println("; bump = " + bump); |
---|
8117 | | - } |
---|
8118 | | - |
---|
8119 | | - if (bump.equals("")) |
---|
8120 | | - { |
---|
8121 | | - bump = null; |
---|
8122 | | - } |
---|
8123 | | - if (pigment.equals("")) |
---|
8124 | | - { |
---|
8125 | | - pigment = null; |
---|
8126 | | - } |
---|
8127 | | - |
---|
8128 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8129 | | - BindTexture(pigment, false, resolution); |
---|
8130 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8131 | | - BindTexture(bump, true, resolution); |
---|
8132 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8133 | | - |
---|
8134 | | - return; // true; |
---|
| 8266 | + BindPigmentTexture(tex, resolution); |
---|
| 8267 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8268 | } |
---|
8136 | 8269 | |
---|
8137 | 8270 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8150 | 8283 | |
---|
8151 | 8284 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8285 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8286 | + usedtextures.add(tex); |
---|
8154 | 8287 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8288 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8289 | { |
---|
8157 | 8290 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8291 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8297 | } |
---|
8165 | 8298 | |
---|
8166 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8300 | + BindTexture(tex, false, resolution); |
---|
8168 | 8301 | } |
---|
8169 | 8302 | |
---|
8170 | 8303 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8183 | 8316 | |
---|
8184 | 8317 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8318 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8319 | + usedtextures.add(tex); |
---|
8187 | 8320 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8321 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8322 | { |
---|
8190 | 8323 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8324 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8330 | } |
---|
8198 | 8331 | |
---|
8199 | 8332 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8333 | + BindTexture(tex, true, resolution); |
---|
8201 | 8334 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8335 | } |
---|
8203 | 8336 | |
---|
.. | .. |
---|
8221 | 8354 | return fileExists; |
---|
8222 | 8355 | } |
---|
8223 | 8356 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8357 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8358 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8359 | + CacheTexture texturecache = null; |
---|
8227 | 8360 | |
---|
8228 | 8361 | if (tex != null) |
---|
8229 | 8362 | { |
---|
8230 | | - 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 | + } |
---|
8231 | 8370 | |
---|
8232 | 8371 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8233 | 8372 | |
---|
.. | .. |
---|
8237 | 8376 | // else |
---|
8238 | 8377 | // if (!texname.startsWith("/")) |
---|
8239 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8240 | | - if (!FileExists(tex)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8241 | 8380 | { |
---|
8242 | 8381 | texname = fallbackTextureName; |
---|
8243 | 8382 | } |
---|
8244 | 8383 | |
---|
8245 | 8384 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8385 | { |
---|
8252 | | - 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("")) |
---|
8253 | 8419 | { |
---|
8254 | 8420 | assert(!bump); |
---|
8255 | 8421 | // if (bump) |
---|
.. | .. |
---|
8260 | 8426 | // } |
---|
8261 | 8427 | // else |
---|
8262 | 8428 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8429 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8430 | + if (texturecache == null) |
---|
8265 | 8431 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8432 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8433 | } |
---|
| 8434 | + else |
---|
| 8435 | + new Exception().printStackTrace(); |
---|
8268 | 8436 | // } |
---|
8269 | 8437 | } else |
---|
8270 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8438 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8439 | { |
---|
8272 | 8440 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - 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(); |
---|
8276 | 8446 | } else |
---|
8277 | 8447 | { |
---|
8278 | 8448 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8280 | 8450 | // texture = GetResourceTexture("default.png"); |
---|
8281 | 8451 | //} else |
---|
8282 | 8452 | //{ |
---|
8283 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8453 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8284 | 8454 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - 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(); |
---|
8288 | 8469 | } else |
---|
8289 | 8470 | { |
---|
8290 | 8471 | if (textureon) |
---|
.. | .. |
---|
8343 | 8524 | if (texturedata == null) |
---|
8344 | 8525 | throw new Exception(); |
---|
8345 | 8526 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8527 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8347 | 8528 | //texture = GetTexture(tex, bump); |
---|
8348 | 8529 | } |
---|
| 8530 | + } |
---|
8349 | 8531 | } |
---|
8350 | 8532 | //} |
---|
8351 | 8533 | } |
---|
8352 | 8534 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8535 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8536 | { |
---|
8355 | 8537 | //return false; |
---|
8356 | 8538 | |
---|
8357 | 8539 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8540 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8541 | { |
---|
8360 | 8542 | // String ext = "_highres"; |
---|
8361 | 8543 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8554 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8555 | if (!cachefile.exists()) |
---|
8374 | 8556 | { |
---|
8375 | | - // cache to disk |
---|
8376 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8377 | | - //buffers[0]. |
---|
8378 | | - |
---|
8379 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8380 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8381 | | - |
---|
8382 | | - // squared size heuristic... |
---|
8383 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8557 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8558 | { |
---|
8385 | | - for (int i=pixels.length; --i>=0;) |
---|
8386 | | - { |
---|
8387 | | - int i3 = i*3; |
---|
8388 | | - pixels[i] = 0xFF; |
---|
8389 | | - pixels[i] <<= 8; |
---|
8390 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8391 | | - pixels[i] <<= 8; |
---|
8392 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8393 | | - pixels[i] <<= 8; |
---|
8394 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8395 | | - } |
---|
8396 | | - |
---|
8397 | | - /* |
---|
8398 | | - int r=0,g=0,b=0,a=0; |
---|
8399 | | - for (int i=0; i<width; i++) |
---|
8400 | | - for (int j=0; j<height; j++) |
---|
8401 | | - { |
---|
8402 | | - int index = j*width+i; |
---|
8403 | | - int p = pixels[index]; |
---|
8404 | | - a = ((p>>24) & 0xFF); |
---|
8405 | | - r = ((p>>16) & 0xFF); |
---|
8406 | | - g = ((p>>8) & 0xFF); |
---|
8407 | | - b = (p & 0xFF); |
---|
8408 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8409 | | - } |
---|
8410 | | - /**/ |
---|
8411 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8412 | | - int height = width; |
---|
8413 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8414 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8559 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8560 | + |
---|
8415 | 8561 | ImageWriter writer = null; |
---|
8416 | 8562 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8563 | if (iter.hasNext()) { |
---|
8418 | 8564 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8565 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8566 | + |
---|
| 8567 | + float compressionQuality = 0.85f; |
---|
8421 | 8568 | try |
---|
8422 | 8569 | { |
---|
8423 | 8570 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8434 | 8581 | } |
---|
8435 | 8582 | } |
---|
8436 | 8583 | } |
---|
8437 | | - |
---|
| 8584 | + |
---|
| 8585 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8586 | + |
---|
8438 | 8587 | //System.out.println("Texture = " + tex); |
---|
8439 | | - if (textures.containsKey(texname)) |
---|
| 8588 | + if (textures.containsKey(tex)) |
---|
8440 | 8589 | { |
---|
8441 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8590 | + CacheTexture thetex = textures.get(tex); |
---|
8442 | 8591 | thetex.texture.disable(); |
---|
8443 | 8592 | thetex.texture.dispose(); |
---|
8444 | | - textures.remove(texname); |
---|
| 8593 | + textures.remove(tex); |
---|
8445 | 8594 | } |
---|
8446 | 8595 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8596 | + //texture.texturedata = texturedata; |
---|
| 8597 | + textures.put(tex, texturecache); |
---|
8449 | 8598 | |
---|
8450 | 8599 | // newtex = true; |
---|
8451 | 8600 | } |
---|
.. | .. |
---|
8461 | 8610 | } |
---|
8462 | 8611 | } |
---|
8463 | 8612 | |
---|
8464 | | - return texture; |
---|
| 8613 | + return texturecache; |
---|
8465 | 8614 | } |
---|
8466 | 8615 | |
---|
8467 | | - 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 |
---|
8468 | 8651 | { |
---|
8469 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8470 | 8653 | |
---|
.. | .. |
---|
8482 | 8665 | return texture!=null?texture.texture:null; |
---|
8483 | 8666 | } |
---|
8484 | 8667 | |
---|
8485 | | - 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 |
---|
8486 | 8669 | { |
---|
8487 | 8670 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8488 | 8671 | |
---|
8489 | 8672 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8673 | } |
---|
8491 | 8674 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8675 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8676 | { |
---|
8494 | 8677 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8678 | { |
---|
8496 | 8679 | return false; |
---|
8497 | 8680 | } |
---|
8498 | 8681 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8682 | + //boolean newtex = false; |
---|
8500 | 8683 | |
---|
8501 | 8684 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8502 | 8685 | |
---|
.. | .. |
---|
8528 | 8711 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8712 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8713 | |
---|
8531 | | - return newtex; |
---|
| 8714 | + return true; // Warning: not used. |
---|
8532 | 8715 | } |
---|
8533 | 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 | + |
---|
8534 | 8783 | ShadowBuffer shadowPBuf; |
---|
8535 | 8784 | AntialiasBuffer antialiasPBuf; |
---|
8536 | 8785 | int MAXSTACK; |
---|
.. | .. |
---|
8547 | 8796 | |
---|
8548 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8549 | 8798 | MAXSTACK = temp[0]; |
---|
8550 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8551 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8552 | 8802 | MAXSTACK = temp[0]; |
---|
8553 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8554 | 8805 | |
---|
8555 | 8806 | // Use debug pipeline |
---|
8556 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8558 | 8809 | gl = drawable.getGL(); // |
---|
8559 | 8810 | |
---|
8560 | 8811 | GL gl3 = getGL(); |
---|
8561 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8562 | 8814 | |
---|
8563 | 8815 | |
---|
8564 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8723 | 8975 | |
---|
8724 | 8976 | if (cubemap == null) |
---|
8725 | 8977 | { |
---|
8726 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8727 | 8979 | } |
---|
8728 | 8980 | |
---|
8729 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
8999 | 9251 | |
---|
9000 | 9252 | void LoadEnvy(int which) |
---|
9001 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9002 | 9256 | String name; |
---|
9003 | 9257 | String ext; |
---|
9004 | 9258 | |
---|
.. | .. |
---|
9010 | 9264 | cubemap = null; |
---|
9011 | 9265 | return; |
---|
9012 | 9266 | case 1: |
---|
9013 | | - name = "cubemaps/box_"; |
---|
9014 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9015 | 9269 | reverseUP = false; |
---|
9016 | 9270 | break; |
---|
9017 | 9271 | case 2: |
---|
9018 | | - name = "cubemaps/uffizi_"; |
---|
9019 | | - ext = "png"; |
---|
9020 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9021 | 9276 | case 3: |
---|
9022 | | - name = "cubemaps/CloudyHills_"; |
---|
9023 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9024 | 9279 | reverseUP = false; |
---|
9025 | 9280 | break; |
---|
9026 | 9281 | case 4: |
---|
9027 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9028 | 9283 | ext = "png"; |
---|
9029 | 9284 | reverseUP = false; |
---|
9030 | 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; |
---|
9031 | 9311 | default: |
---|
9032 | | - name = "cubemaps/rgb_"; |
---|
9033 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9034 | 9315 | break; |
---|
9035 | 9316 | } |
---|
9036 | | - |
---|
9037 | | - try |
---|
9038 | | - { |
---|
9039 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9040 | | - } catch (IOException e) |
---|
9041 | | - { |
---|
9042 | | - throw new RuntimeException(e); |
---|
9043 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9044 | 9319 | } |
---|
9045 | 9320 | |
---|
9046 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9072 | 9347 | static double[] model = new double[16]; |
---|
9073 | 9348 | double[] camera2light = new double[16]; |
---|
9074 | 9349 | double[] light2camera = new double[16]; |
---|
9075 | | - int newenvy = -1; |
---|
9076 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9077 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9078 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9079 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9366 | 9645 | jy8[3] = 0.5f; |
---|
9367 | 9646 | } |
---|
9368 | 9647 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9648 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9649 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9650 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9651 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9652 | |
---|
| 9653 | + void ResetOptions() |
---|
| 9654 | + { |
---|
| 9655 | + options1[0] = 100; |
---|
| 9656 | + options1[1] = 0.025f; |
---|
| 9657 | + options1[2] = 0.01f; |
---|
| 9658 | + options1[3] = 0; |
---|
| 9659 | + options1[4] = 0; |
---|
| 9660 | + |
---|
| 9661 | + options2[0] = 0; |
---|
| 9662 | + options2[1] = 0.75f; |
---|
| 9663 | + options2[2] = 0; |
---|
| 9664 | + options2[3] = 0; |
---|
| 9665 | + |
---|
| 9666 | + options3[0] = 1; |
---|
| 9667 | + options3[1] = 1; |
---|
| 9668 | + options3[2] = 1; |
---|
| 9669 | + options3[3] = 0; |
---|
| 9670 | + |
---|
| 9671 | + options4[0] = 1; |
---|
| 9672 | + options4[1] = 0; |
---|
| 9673 | + options4[2] = 1; |
---|
| 9674 | + options4[3] = 0; |
---|
| 9675 | + } |
---|
| 9676 | + |
---|
9374 | 9677 | static int imagecount = 0; // movie generation |
---|
9375 | 9678 | |
---|
9376 | 9679 | static int jitter = 0; |
---|
.. | .. |
---|
9467 | 9770 | |
---|
9468 | 9771 | if (renderCamera != lightCamera) |
---|
9469 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9470 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9471 | 9774 | |
---|
9472 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9473 | 9776 | |
---|
.. | .. |
---|
9483 | 9786 | |
---|
9484 | 9787 | if (renderCamera != lightCamera) |
---|
9485 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9486 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9487 | 9790 | |
---|
9488 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9489 | 9792 | |
---|
.. | .. |
---|
9529 | 9832 | rati = 1 / rati; |
---|
9530 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9531 | 9834 | } |
---|
9532 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9533 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9534 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9535 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9536 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9537 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9538 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10398 | 10703 | static boolean init = false; |
---|
10399 | 10704 | |
---|
10400 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10401 | 10709 | |
---|
10402 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10403 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10404 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10405 | 10719 | { |
---|
10406 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10481 | 10795 | ANTIALIAS = 0; |
---|
10482 | 10796 | //System.out.println("RESTART"); |
---|
10483 | 10797 | AAtimer.restart(); |
---|
| 10798 | + Globals.TIMERRUNNING = true; |
---|
10484 | 10799 | } |
---|
10485 | 10800 | } |
---|
10486 | 10801 | } |
---|
.. | .. |
---|
10568 | 10883 | |
---|
10569 | 10884 | if (wait) |
---|
10570 | 10885 | { |
---|
10571 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10572 | 10887 | |
---|
10573 | 10888 | wait = false; |
---|
10574 | 10889 | } |
---|
.. | .. |
---|
10683 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10684 | 10999 | if (cam != lightCamera) |
---|
10685 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10686 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10687 | 11002 | |
---|
10688 | 11003 | for (int j = 0; j < 4; j++) |
---|
10689 | 11004 | { |
---|
.. | .. |
---|
10698 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10699 | 11014 | if (cam != lightCamera) |
---|
10700 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10701 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10702 | 11017 | |
---|
10703 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10704 | 11019 | |
---|
.. | .. |
---|
10784 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10785 | 11100 | } |
---|
10786 | 11101 | |
---|
10787 | | - 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")) |
---|
10788 | 11110 | { |
---|
10789 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
10790 | 11117 | } |
---|
10791 | | - |
---|
10792 | | - newenvy = -1; |
---|
10793 | | - |
---|
| 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 | + |
---|
10794 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
10795 | 11140 | //System.out.println("ratio = " + ratio); |
---|
10796 | 11141 | |
---|
.. | .. |
---|
10806 | 11151 | |
---|
10807 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
10808 | 11153 | { |
---|
10809 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
10810 | 11155 | } |
---|
10811 | 11156 | |
---|
10812 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
10989 | 11334 | |
---|
10990 | 11335 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10991 | 11336 | |
---|
10992 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10993 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10994 | | -//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); |
---|
10995 | 11340 | } else |
---|
10996 | 11341 | { |
---|
10997 | 11342 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11002 | 11347 | //System.out.println("BLENDING ON"); |
---|
11003 | 11348 | gl.glEnable(GL.GL_BLEND); |
---|
11004 | 11349 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11005 | | - |
---|
| 11350 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11006 | 11351 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11007 | 11352 | gl.glLoadIdentity(); |
---|
11008 | 11353 | |
---|
.. | .. |
---|
11092 | 11437 | |
---|
11093 | 11438 | // if (cam != lightCamera) |
---|
11094 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11095 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11096 | 11441 | } |
---|
11097 | 11442 | |
---|
11098 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11251 | 11596 | } |
---|
11252 | 11597 | } |
---|
11253 | 11598 | |
---|
11254 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11599 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11255 | 11600 | { |
---|
11256 | 11601 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11257 | 11602 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11259 | 11604 | |
---|
11260 | 11605 | boolean texon = textureon; |
---|
11261 | 11606 | |
---|
11262 | | - if (RENDERPROGRAM > 0) |
---|
11263 | | - { |
---|
11264 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11265 | | - textureon = false; |
---|
11266 | | - } |
---|
| 11607 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11608 | + textureon = false; |
---|
| 11609 | + |
---|
11267 | 11610 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11268 | 11611 | //System.out.println("ALLO"); |
---|
11269 | 11612 | gl.glColorMask(false, false, false, false); |
---|
11270 | 11613 | DrawObject(gl); |
---|
11271 | | - if (RENDERPROGRAM > 0) |
---|
11272 | | - { |
---|
11273 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11274 | | - textureon = texon; |
---|
11275 | | - } |
---|
| 11614 | + |
---|
| 11615 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11616 | + textureon = texon; |
---|
| 11617 | + |
---|
11276 | 11618 | gl.glColorMask(true, true, true, true); |
---|
11277 | 11619 | |
---|
11278 | 11620 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11279 | | - //gl.glDepthMask(false); |
---|
| 11621 | + gl.glDepthMask(false); |
---|
11280 | 11622 | } |
---|
11281 | 11623 | |
---|
11282 | 11624 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11479 | 11821 | |
---|
11480 | 11822 | void DrawObject(GL gl, boolean draw) |
---|
11481 | 11823 | { |
---|
| 11824 | + // To clear camera values |
---|
| 11825 | + ResetOptions(); |
---|
| 11826 | + |
---|
11482 | 11827 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11483 | 11828 | // DrawMode() = SELECTION; |
---|
11484 | 11829 | //GL gl = getGL(); |
---|
11485 | 11830 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11486 | 11831 | { |
---|
11487 | 11832 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11488 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11833 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11489 | 11834 | pingthread.StepToTarget(true); // true); |
---|
11490 | 11835 | // zoomonce = false; |
---|
11491 | 11836 | } |
---|
.. | .. |
---|
11613 | 11958 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11614 | 11959 | |
---|
11615 | 11960 | if (CLEANCACHE) |
---|
11616 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11961 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11617 | 11962 | { |
---|
11618 | | - String tex = e.nextElement(); |
---|
| 11963 | + cTexture tex = e.nextElement(); |
---|
11619 | 11964 | |
---|
11620 | 11965 | // System.out.println("Texture --------- " + tex); |
---|
11621 | 11966 | |
---|
11622 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11967 | + if (tex.equals("WHITE_NOISE:")) |
---|
11623 | 11968 | continue; |
---|
11624 | 11969 | |
---|
11625 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11970 | + if (!usedtextures.contains(tex)) |
---|
11626 | 11971 | { |
---|
| 11972 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11627 | 11973 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11628 | | - textures.get(tex).texture.dispose(); |
---|
11629 | | - 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 | + } |
---|
11630 | 11987 | } |
---|
11631 | 11988 | } |
---|
11632 | 11989 | } |
---|
.. | .. |
---|
12046 | 12403 | for (int i = tp.size(); --i >= 0;) |
---|
12047 | 12404 | { |
---|
12048 | 12405 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12049 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12406 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12050 | 12407 | } |
---|
12051 | 12408 | |
---|
12052 | 12409 | |
---|
.. | .. |
---|
12154 | 12511 | |
---|
12155 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12156 | 12513 | |
---|
12157 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12158 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
| 12520 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12521 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12522 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12523 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12524 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12525 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12526 | + "TEMP temp;" + |
---|
| 12527 | + "TEMP light;" + |
---|
| 12528 | + "TEMP ndotl;" + |
---|
| 12529 | + "TEMP normal;" + |
---|
| 12530 | + "TEMP depth;" + |
---|
| 12531 | + "TEMP eye;" + |
---|
| 12532 | + "TEMP pos;" + |
---|
| 12533 | + |
---|
| 12534 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
| 12535 | + Normalize("normal") + |
---|
| 12536 | + "MOV light, state.light[0].position;" + |
---|
| 12537 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12538 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
| 12539 | + |
---|
| 12540 | + // shadow |
---|
| 12541 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12542 | + "MOV temp, pos;" + |
---|
| 12543 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12544 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12545 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12546 | + |
---|
| 12547 | + // No shadow when out of frustum |
---|
| 12548 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12549 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12552 | + |
---|
| 12553 | + // Backlit |
---|
| 12554 | + "MOV pos.w, zero12t.y;" + // one |
---|
| 12555 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12556 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12557 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12558 | + Normalize("eye") + |
---|
| 12559 | + |
---|
| 12560 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12561 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12562 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12563 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12564 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12565 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12566 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12567 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12568 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
| 12569 | + |
---|
| 12570 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12571 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12572 | + |
---|
| 12573 | + // Pigment |
---|
| 12574 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12575 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12576 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
| 12577 | + |
---|
| 12578 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12579 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
| 12580 | + |
---|
| 12581 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12582 | + |
---|
| 12583 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
| 12584 | + "MOV result.color, temp;" + |
---|
| 12585 | + "END"; |
---|
| 12586 | + |
---|
| 12587 | + String programmax = |
---|
| 12588 | + "!!ARBfp1.0\n" + |
---|
| 12589 | + |
---|
12159 | 12590 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12160 | 12591 | "PARAM light2cam0 = program.env[10];" + |
---|
12161 | 12592 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12181 | 12612 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12182 | 12613 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12183 | 12614 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12184 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12615 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12185 | 12616 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12186 | 12617 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12187 | 12618 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12270 | 12701 | "TEMP shininess;" + |
---|
12271 | 12702 | "\n" + |
---|
12272 | 12703 | "MOV texSamp, one;" + |
---|
12273 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12274 | | - |
---|
| 12704 | + |
---|
12275 | 12705 | "MOV mapgrid.x, one2048th.x;" + |
---|
12276 | 12706 | "MOV temp, fragment.texcoord[1];" + |
---|
12277 | 12707 | /* |
---|
.. | .. |
---|
12292 | 12722 | "MUL temp, floor, mapgrid.x;" + |
---|
12293 | 12723 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12294 | 12724 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12295 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12725 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12296 | 12726 | "") + |
---|
12297 | 12727 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12298 | 12728 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12299 | 12729 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12300 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12730 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12301 | 12731 | "") + |
---|
12302 | 12732 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12303 | 12733 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12304 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12734 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12305 | 12735 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12306 | 12736 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12307 | 12737 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12308 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12738 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12309 | 12739 | "") + |
---|
12310 | 12740 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12311 | 12741 | //"MOV params, material;" + |
---|
.. | .. |
---|
12427 | 12857 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12428 | 12858 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12429 | 12859 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12430 | | - "KIL alpha.a;" + |
---|
| 12860 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12431 | 12861 | /* |
---|
12432 | 12862 | "MUL temp.xy, temp, two;" + |
---|
12433 | 12863 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12513 | 12943 | "SUB bump0, bump0, half;" + |
---|
12514 | 12944 | "ADD bump, bump, bump0;" + |
---|
12515 | 12945 | |
---|
12516 | | - "MOV temp.x, texSamp.a;" + |
---|
12517 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12518 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12519 | | - "MOV texSamp.a, temp.x;" + |
---|
12520 | | - |
---|
12521 | 12946 | // double-sided |
---|
12522 | 12947 | /**/ |
---|
12523 | 12948 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12527 | 12952 | "ADD temp.x, temp.x, one.x;" + |
---|
12528 | 12953 | "MUL normal, normal, temp.xxxx;":"" |
---|
12529 | 12954 | ) + |
---|
12530 | | - /**/ |
---|
12531 | | -//// Normalize("normal") + |
---|
12532 | | -//// "MAX normal.z, eps.x, normal.z;" + |
---|
12533 | | -// Normalize("normal") + |
---|
12534 | | - "MOV normald, normal;" + |
---|
12535 | | - "MOV normals, normal;" + |
---|
| 12955 | + /**/ |
---|
| 12956 | + |
---|
| 12957 | + "MOV temp, fragment.texcoord[4];" + |
---|
12536 | 12958 | |
---|
12537 | 12959 | // UV base |
---|
12538 | 12960 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12539 | 12961 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12540 | 12962 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12541 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12542 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12543 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12963 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12964 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12965 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12966 | + Normalize("UP") + |
---|
| 12967 | + |
---|
12544 | 12968 | "XPD V, normal, UP;" + |
---|
12545 | 12969 | Normalize("V") + |
---|
12546 | 12970 | "XPD U, V, normal;" + |
---|
12547 | 12971 | Normalize("U") + |
---|
12548 | 12972 | |
---|
| 12973 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12974 | + |
---|
| 12975 | +// "MAD normal, -temp.x, U, normal;" + |
---|
| 12976 | +// "MAD normal, -temp.y, V, normal;" + |
---|
| 12977 | +// Normalize("normal") + |
---|
| 12978 | + |
---|
| 12979 | +//// "MAX normal.z, eps.x, normal.z;" + |
---|
| 12980 | +// Normalize("normal") + |
---|
| 12981 | + "MOV normald, normal;" + |
---|
| 12982 | + "MOV normals, normal;" + |
---|
| 12983 | + |
---|
12549 | 12984 | // parallax mapping |
---|
| 12985 | + |
---|
| 12986 | + "DP3 temp2.x, V, eye;" + |
---|
| 12987 | + "DP3 temp2.y, U, eye;" + |
---|
| 12988 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12989 | + "RCP temp2.z, temp2.z;" + |
---|
| 12990 | + |
---|
| 12991 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12992 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12993 | + "RCP temp2.w, temp2.w;" + |
---|
| 12994 | + |
---|
| 12995 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12996 | + // "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12997 | + // "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12998 | + |
---|
| 12999 | + // "MOV texSamp, U;" + |
---|
| 13000 | + |
---|
| 13001 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 13002 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 13003 | + |
---|
| 13004 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 13005 | + |
---|
| 13006 | + "SUB temp, temp, temp2;" + |
---|
| 13007 | + |
---|
| 13008 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13009 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13010 | + |
---|
| 13011 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13012 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13013 | + |
---|
| 13014 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13015 | + |
---|
| 13016 | +// parallax mapping |
---|
| 13017 | + |
---|
| 13018 | + "MOV temp.x, texSamp.a;" + |
---|
| 13019 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13020 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13021 | + "MOV texSamp.a, temp.x;" + |
---|
12550 | 13022 | |
---|
12551 | 13023 | //"MOV temp, fragment.texcoord[0];" + |
---|
12552 | 13024 | // |
---|
.. | .. |
---|
12676 | 13148 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12677 | 13149 | "") + |
---|
12678 | 13150 | |
---|
12679 | | - // display shadow only (bump == 0) |
---|
| 13151 | + // display shadow only (fakedepth == 0) |
---|
12680 | 13152 | "SUB temp.x, half.x, shadow.x;" + |
---|
12681 | 13153 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12682 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13154 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12683 | 13155 | "SUB temp.y, one.x, temp.z;" + |
---|
12684 | 13156 | "MUL temp.x, temp.x, temp.y;" + |
---|
12685 | 13157 | "KIL temp.x;" + |
---|
.. | .. |
---|
13010 | 13482 | //once = true; |
---|
13011 | 13483 | } |
---|
13012 | 13484 | |
---|
13013 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13014 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13485 | + String program = programmax; |
---|
| 13486 | + |
---|
| 13487 | + if (Globals.MINSHADER) |
---|
| 13488 | + { |
---|
| 13489 | + program = programmin; |
---|
| 13490 | + } |
---|
| 13491 | + |
---|
| 13492 | + if (Globals.DEBUG) |
---|
| 13493 | + { |
---|
| 13494 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13495 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13496 | + } |
---|
| 13497 | + |
---|
13015 | 13498 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13016 | 13499 | |
---|
13017 | 13500 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13058 | 13541 | "\n" + |
---|
13059 | 13542 | "END\n"; |
---|
13060 | 13543 | |
---|
13061 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13544 | + if (Globals.DEBUG) |
---|
| 13545 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13062 | 13546 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13063 | 13547 | |
---|
13064 | 13548 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13103 | 13587 | return out; |
---|
13104 | 13588 | } |
---|
13105 | 13589 | |
---|
13106 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13590 | + // Also does frustum culling |
---|
| 13591 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13107 | 13592 | { |
---|
13108 | 13593 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13109 | 13594 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13110 | 13595 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13596 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13597 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13111 | 13598 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13112 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13113 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13114 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13115 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13599 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13600 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13116 | 13601 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13117 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13602 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13118 | 13603 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13119 | 13604 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13120 | 13605 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13121 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13606 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13122 | 13607 | |
---|
13123 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13124 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13608 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13609 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13125 | 13610 | } |
---|
13126 | 13611 | |
---|
13127 | 13612 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13168 | 13653 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13169 | 13654 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13170 | 13655 | |
---|
13171 | | - // No shadow when out of frustrum |
---|
| 13656 | + // No shadow when out of frustum |
---|
13172 | 13657 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13173 | 13658 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13174 | 13659 | ""; |
---|
.. | .. |
---|
13315 | 13800 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13316 | 13801 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13317 | 13802 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13318 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13803 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13319 | 13804 | |
---|
13320 | 13805 | //Object3D.cVector2[] vector2buffer; |
---|
13321 | 13806 | |
---|
.. | .. |
---|
13333 | 13818 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13334 | 13819 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13335 | 13820 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13336 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13337 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13338 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13821 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13822 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13823 | + |
---|
| 13824 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13339 | 13825 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13340 | 13826 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13341 | 13827 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13481 | 13967 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13482 | 13968 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13483 | 13969 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13484 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13970 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13485 | 13971 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13486 | 13972 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13487 | 13973 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13542 | 14028 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13543 | 14029 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13544 | 14030 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13545 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14031 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13546 | 14032 | "MOV result.texcoord, temp;" + |
---|
13547 | 14033 | // border fade |
---|
13548 | 14034 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13589 | 14075 | |
---|
13590 | 14076 | //"ADD temp.z, temp.z, one;" + |
---|
13591 | 14077 | |
---|
13592 | | - "MOV result.color, temp;" |
---|
| 14078 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14079 | + |
---|
| 14080 | + "MOV result.color, temp;" // Normal |
---|
13593 | 14081 | : "MOV result.color, vertex.color;") + |
---|
13594 | 14082 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13595 | 14083 | : "") + |
---|
.. | .. |
---|
13840 | 14328 | else |
---|
13841 | 14329 | if (evt.getSource() == AAtimer) |
---|
13842 | 14330 | { |
---|
| 14331 | + Globals.TIMERRUNNING = false; |
---|
13843 | 14332 | if (mouseDown) |
---|
13844 | 14333 | { |
---|
13845 | 14334 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13899 | 14388 | |
---|
13900 | 14389 | // fev 2014??? |
---|
13901 | 14390 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13902 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14391 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13903 | 14392 | pingthread.StepToTarget(true); // true); |
---|
13904 | 14393 | } |
---|
13905 | 14394 | // if (!LIVE) |
---|
.. | .. |
---|
13914 | 14403 | return; |
---|
13915 | 14404 | |
---|
13916 | 14405 | AAtimer.restart(); // |
---|
| 14406 | + Globals.TIMERRUNNING = true; |
---|
13917 | 14407 | |
---|
13918 | 14408 | // waslive = LIVE; |
---|
13919 | 14409 | // LIVE = false; |
---|
.. | .. |
---|
13963 | 14453 | drag = false; |
---|
13964 | 14454 | //System.out.println("Mouse DOWN"); |
---|
13965 | 14455 | editObj = false; |
---|
13966 | | - ClickInfo info = new ClickInfo(); |
---|
13967 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13968 | | - info.pane = this; |
---|
13969 | | - info.camera = renderCamera; |
---|
13970 | | - info.x = x; |
---|
13971 | | - info.y = y; |
---|
13972 | | - info.modifiers = modifiersex; |
---|
13973 | | - editObj = object.doEditClick(info, 0); |
---|
| 14456 | + //ClickInfo info = new ClickInfo(); |
---|
| 14457 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14458 | + object.clickInfo.pane = this; |
---|
| 14459 | + object.clickInfo.camera = renderCamera; |
---|
| 14460 | + object.clickInfo.x = x; |
---|
| 14461 | + object.clickInfo.y = y; |
---|
| 14462 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14463 | + editObj = object.doEditClick(//info, |
---|
| 14464 | + 0); |
---|
13974 | 14465 | if (!editObj) |
---|
13975 | 14466 | { |
---|
13976 | 14467 | hasMarquee = true; |
---|
.. | .. |
---|
14245 | 14736 | } |
---|
14246 | 14737 | } |
---|
14247 | 14738 | PingThread pingthread = new PingThread(); |
---|
14248 | | - int delta = 5; |
---|
14249 | | - int speed = 5; |
---|
| 14739 | + int delta = 2; |
---|
| 14740 | + int speed = 10; |
---|
14250 | 14741 | boolean autorepeat = false; |
---|
14251 | 14742 | |
---|
14252 | 14743 | void GoDown(int mod) |
---|
14253 | 14744 | { |
---|
14254 | 14745 | MODIFIERS |= COMMAND; |
---|
14255 | | - /* |
---|
| 14746 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14747 | + /**/ |
---|
14256 | 14748 | if((mod&SHIFT) == SHIFT) |
---|
14257 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14749 | + { |
---|
| 14750 | + if (isVR) |
---|
| 14751 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14752 | + else |
---|
| 14753 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14754 | + } |
---|
14258 | 14755 | else |
---|
14259 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14260 | | - */ |
---|
| 14756 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14757 | + /**/ |
---|
14261 | 14758 | if ((mod & SHIFT) == SHIFT) |
---|
14262 | 14759 | { |
---|
14263 | 14760 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14266 | 14763 | mouseMode |= BACKFORTH; |
---|
14267 | 14764 | } |
---|
14268 | 14765 | |
---|
| 14766 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14767 | + |
---|
14269 | 14768 | //prevX = X = anchorX; |
---|
14270 | 14769 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14271 | 14770 | } |
---|
.. | .. |
---|
14273 | 14772 | void GoUp(int mod) |
---|
14274 | 14773 | { |
---|
14275 | 14774 | MODIFIERS |= COMMAND; |
---|
14276 | | - /* |
---|
| 14775 | + /**/ |
---|
| 14776 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14777 | + |
---|
14277 | 14778 | if((mod&SHIFT) == SHIFT) |
---|
14278 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14779 | + { |
---|
| 14780 | + if (isVR) |
---|
| 14781 | + manipCamera.RotateInterest(0, speed); |
---|
| 14782 | + else |
---|
| 14783 | + manipCamera.RotatePosition(0, speed); |
---|
| 14784 | + } |
---|
14279 | 14785 | else |
---|
14280 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14281 | | - */ |
---|
| 14786 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14787 | + /**/ |
---|
14282 | 14788 | if ((mod & SHIFT) == SHIFT) |
---|
14283 | 14789 | { |
---|
14284 | 14790 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14287 | 14793 | mouseMode |= BACKFORTH; |
---|
14288 | 14794 | } |
---|
14289 | 14795 | |
---|
| 14796 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14797 | + |
---|
14290 | 14798 | //prevX = X = anchorX; |
---|
14291 | 14799 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14292 | 14800 | } |
---|
.. | .. |
---|
14294 | 14802 | void GoLeft(int mod) |
---|
14295 | 14803 | { |
---|
14296 | 14804 | MODIFIERS |= COMMAND; |
---|
14297 | | - /* |
---|
| 14805 | + /**/ |
---|
14298 | 14806 | if((mod&SHIFT) == SHIFT) |
---|
14299 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14807 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14300 | 14808 | else |
---|
14301 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14302 | | - */ |
---|
| 14809 | + { |
---|
| 14810 | + if ((mouseMode&VR)!=0) |
---|
| 14811 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14812 | + else |
---|
| 14813 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14814 | + } |
---|
| 14815 | + /**/ |
---|
14303 | 14816 | if ((mod & SHIFT) == SHIFT) |
---|
14304 | 14817 | { |
---|
14305 | 14818 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14308 | 14821 | mouseMode |= ROTATE; |
---|
14309 | 14822 | } // TRANSLATE; |
---|
14310 | 14823 | |
---|
| 14824 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14825 | + |
---|
14311 | 14826 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14312 | 14827 | prevY = Y = anchorY; |
---|
14313 | 14828 | } |
---|
.. | .. |
---|
14315 | 14830 | void GoRight(int mod) |
---|
14316 | 14831 | { |
---|
14317 | 14832 | MODIFIERS |= COMMAND; |
---|
14318 | | - /* |
---|
| 14833 | + /**/ |
---|
14319 | 14834 | if((mod&SHIFT) == SHIFT) |
---|
14320 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14835 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14321 | 14836 | else |
---|
14322 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14323 | | - */ |
---|
| 14837 | + { |
---|
| 14838 | + if ((mouseMode&VR)!=0) |
---|
| 14839 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14840 | + else |
---|
| 14841 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14842 | + } |
---|
| 14843 | + |
---|
| 14844 | + /**/ |
---|
14324 | 14845 | if ((mod & SHIFT) == SHIFT) |
---|
14325 | 14846 | { |
---|
14326 | 14847 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14329 | 14850 | mouseMode |= ROTATE; |
---|
14330 | 14851 | } // TRANSLATE; |
---|
14331 | 14852 | |
---|
| 14853 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14854 | + |
---|
14332 | 14855 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14333 | 14856 | prevY = Y = anchorY; |
---|
14334 | 14857 | } |
---|
.. | .. |
---|
14370 | 14893 | if (editObj) |
---|
14371 | 14894 | { |
---|
14372 | 14895 | drag = true; |
---|
14373 | | - ClickInfo info = new ClickInfo(); |
---|
14374 | | - info.bounds.setBounds(0, 0, |
---|
| 14896 | + //ClickInfo info = new ClickInfo(); |
---|
| 14897 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14375 | 14898 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14376 | | - info.pane = this; |
---|
14377 | | - info.camera = renderCamera; |
---|
14378 | | - info.x = x; |
---|
14379 | | - info.y = y; |
---|
14380 | | - object.GetWindow().copy |
---|
14381 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14899 | + object.clickInfo.pane = this; |
---|
| 14900 | + object.clickInfo.camera = renderCamera; |
---|
| 14901 | + object.clickInfo.x = x; |
---|
| 14902 | + object.clickInfo.y = y; |
---|
| 14903 | + object //.GetWindow().copy |
---|
| 14904 | + .doEditDrag(//info, |
---|
| 14905 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14382 | 14906 | } else |
---|
14383 | 14907 | { |
---|
14384 | 14908 | if (x < startX) |
---|
.. | .. |
---|
14527 | 15051 | } |
---|
14528 | 15052 | } |
---|
14529 | 15053 | |
---|
| 15054 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15055 | + |
---|
14530 | 15056 | public void mouseMoved(MouseEvent e) |
---|
14531 | 15057 | { |
---|
14532 | 15058 | //System.out.println("mouseMoved: " + e); |
---|
14533 | 15059 | if (isRenderer) |
---|
14534 | 15060 | return; |
---|
14535 | 15061 | |
---|
14536 | | - ClickInfo ci = new ClickInfo(); |
---|
14537 | | - ci.x = e.getX(); |
---|
14538 | | - ci.y = e.getY(); |
---|
14539 | | - ci.modifiers = e.getModifiersEx(); |
---|
14540 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14541 | | - ci.pane = this; |
---|
14542 | | - ci.camera = renderCamera; |
---|
| 15062 | + // Mouse cursor feedback |
---|
| 15063 | + object.clickInfo.x = e.getX(); |
---|
| 15064 | + object.clickInfo.y = e.getY(); |
---|
| 15065 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15066 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15067 | + object.clickInfo.pane = this; |
---|
| 15068 | + object.clickInfo.camera = renderCamera; |
---|
14543 | 15069 | if (!isRenderer) |
---|
14544 | 15070 | { |
---|
14545 | 15071 | //ObjEditor editWindow = object.editWindow; |
---|
14546 | 15072 | //Object3D copy = editWindow.copy; |
---|
14547 | | - if (object.doEditClick(ci, 0)) |
---|
| 15073 | + if (object.doEditClick(//clickInfo, |
---|
| 15074 | + 0)) |
---|
14548 | 15075 | { |
---|
14549 | 15076 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14550 | 15077 | } else |
---|
.. | .. |
---|
14559 | 15086 | Globals.MOUSEDRAGGED = false; |
---|
14560 | 15087 | |
---|
14561 | 15088 | movingcamera = false; |
---|
14562 | | - X = Y = 0; |
---|
| 15089 | + X = 0; // getBounds().width/2; |
---|
| 15090 | + Y = 0; // getBounds().height/2; |
---|
14563 | 15091 | //System.out.println("mouseReleased: " + e); |
---|
14564 | 15092 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14565 | 15093 | } |
---|
.. | .. |
---|
14815 | 15343 | // break; |
---|
14816 | 15344 | case 'T': |
---|
14817 | 15345 | CACHETEXTURE ^= true; |
---|
14818 | | - textures.clear(); |
---|
| 15346 | + texturepigment.clear(); |
---|
| 15347 | + texturebump.clear(); |
---|
14819 | 15348 | // repaint(); |
---|
14820 | 15349 | break; |
---|
14821 | 15350 | case 'Y': |
---|
.. | .. |
---|
14825 | 15354 | case 'K': |
---|
14826 | 15355 | KOMPACTTEXTURE ^= true; |
---|
14827 | 15356 | //textures.clear(); |
---|
14828 | | - break; |
---|
14829 | | - case 'P': // Texture Projection macros |
---|
| 15357 | + // break; |
---|
| 15358 | + //case 'P': // Texture Projection macros |
---|
14830 | 15359 | // SAVETEXTURE ^= true; |
---|
14831 | 15360 | macromode = true; |
---|
14832 | 15361 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14900 | 15429 | case 'E' : COMPACT ^= true; |
---|
14901 | 15430 | repaint(); |
---|
14902 | 15431 | break; |
---|
14903 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15432 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15433 | + //DEBUGHSB ^= true; |
---|
| 15434 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14904 | 15435 | repaint(); |
---|
14905 | 15436 | break; |
---|
14906 | 15437 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14926 | 15457 | repaint(); |
---|
14927 | 15458 | break; |
---|
14928 | 15459 | case 'l': |
---|
14929 | | - lightMode ^= true; |
---|
14930 | | - Globals.lighttouched = true; |
---|
14931 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14932 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14933 | | - repaint(); |
---|
14934 | | - break; |
---|
14935 | | - case 'L': |
---|
| 15460 | + //case 'L': |
---|
14936 | 15461 | if (lightMode) |
---|
14937 | 15462 | { |
---|
14938 | 15463 | lightMode = false; |
---|
.. | .. |
---|
14951 | 15476 | targetLookAt.set(manipCamera.lookAt); |
---|
14952 | 15477 | repaint(); |
---|
14953 | 15478 | break; |
---|
14954 | | - case 'p': |
---|
| 15479 | + case 'P': // p': |
---|
14955 | 15480 | // c'est quoi ca au juste? spherical ^= true; |
---|
14956 | 15481 | Skinshader ^= true; programInitialized = false; |
---|
14957 | 15482 | repaint(); |
---|
.. | .. |
---|
14989 | 15514 | repaint(); |
---|
14990 | 15515 | break; |
---|
14991 | 15516 | case 'O': |
---|
14992 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15517 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
14993 | 15518 | repaint(); |
---|
14994 | 15519 | break; |
---|
14995 | 15520 | case 'o': |
---|
14996 | 15521 | OCCLUSION_CULLING ^= true; |
---|
14997 | 15522 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14998 | 15523 | break; |
---|
14999 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15524 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15000 | 15525 | case '1': |
---|
15001 | 15526 | case '2': |
---|
15002 | 15527 | case '3': |
---|
15003 | 15528 | case '4': |
---|
15004 | 15529 | case '5': |
---|
15005 | | - newenvy = Character.getNumericValue(key); |
---|
15006 | | - repaint(); |
---|
15007 | | - break; |
---|
15008 | 15530 | case '6': |
---|
15009 | 15531 | case '7': |
---|
15010 | 15532 | case '8': |
---|
15011 | 15533 | case '9': |
---|
15012 | | - BGcolor = (key - '6')/3.f; |
---|
| 15534 | + if (true) // envyoff) |
---|
| 15535 | + { |
---|
| 15536 | + BGcolor = (key - '1')/8.f; |
---|
| 15537 | + } |
---|
| 15538 | + else |
---|
| 15539 | + { |
---|
| 15540 | + //newenvy = Character.getNumericValue(key); |
---|
| 15541 | + } |
---|
15013 | 15542 | repaint(); |
---|
15014 | 15543 | break; |
---|
15015 | 15544 | case '!': |
---|
.. | .. |
---|
15075 | 15604 | case '_': |
---|
15076 | 15605 | kompactbit = 5; |
---|
15077 | 15606 | break; |
---|
15078 | | - case '+': |
---|
15079 | | - kompactbit = 6; |
---|
15080 | | - break; |
---|
| 15607 | +// case '+': |
---|
| 15608 | +// kompactbit = 6; |
---|
| 15609 | +// break; |
---|
15081 | 15610 | case ' ': |
---|
15082 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15611 | + lightMode ^= true; |
---|
| 15612 | + Globals.lighttouched = true; |
---|
| 15613 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15614 | + targetLookAt.set(manipCamera.lookAt); |
---|
15083 | 15615 | repaint(); |
---|
15084 | 15616 | break; |
---|
15085 | 15617 | //case '`' : |
---|
.. | .. |
---|
15126 | 15658 | case DELETE: |
---|
15127 | 15659 | ClearSelection(); |
---|
15128 | 15660 | break; |
---|
15129 | | - /* |
---|
15130 | 15661 | case '+': |
---|
| 15662 | + |
---|
| 15663 | + /* |
---|
15131 | 15664 | //fontsize += 1; |
---|
15132 | 15665 | bbzoom *= 2; |
---|
15133 | 15666 | repaint(); |
---|
.. | .. |
---|
15144 | 15677 | case '=': |
---|
15145 | 15678 | IncDepth(); |
---|
15146 | 15679 | //fontsize += 1; |
---|
15147 | | - object.editWindow.refreshContents(true); |
---|
| 15680 | + object.GetWindow().refreshContents(true); |
---|
15148 | 15681 | maskbit = 6; |
---|
15149 | 15682 | break; |
---|
15150 | 15683 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15151 | 15684 | DecDepth(); |
---|
15152 | 15685 | maskbit = 5; |
---|
15153 | 15686 | //if(fontsize > 1) fontsize -= 1; |
---|
15154 | | - if (object.editWindow == null) |
---|
15155 | | - new Exception().printStackTrace(); |
---|
15156 | | - else |
---|
15157 | | - object.editWindow.refreshContents(true); |
---|
| 15687 | +// if (object.editWindow == null) |
---|
| 15688 | +// new Exception().printStackTrace(); |
---|
| 15689 | +// else |
---|
| 15690 | + object.GetWindow().refreshContents(true); |
---|
15158 | 15691 | break; |
---|
15159 | 15692 | case '{': |
---|
15160 | 15693 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15378 | 15911 | } |
---|
15379 | 15912 | */ |
---|
15380 | 15913 | |
---|
15381 | | - object.editWindow.EditSelection(false); |
---|
| 15914 | + object.GetWindow().EditSelection(false); |
---|
15382 | 15915 | } |
---|
15383 | 15916 | |
---|
15384 | 15917 | void SelectParent() |
---|
.. | .. |
---|
15395 | 15928 | { |
---|
15396 | 15929 | //selectees.remove(i); |
---|
15397 | 15930 | System.out.println("select parent of " + elem); |
---|
15398 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15931 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15399 | 15932 | } else |
---|
15400 | 15933 | { |
---|
15401 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15934 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15402 | 15935 | } |
---|
15403 | 15936 | |
---|
15404 | 15937 | first = false; |
---|
.. | .. |
---|
15440 | 15973 | for (int j = 0; j < group.children.size(); j++) |
---|
15441 | 15974 | { |
---|
15442 | 15975 | elem = (Object3D) group.children.elementAt(j); |
---|
15443 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15976 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15444 | 15977 | first = false; |
---|
15445 | 15978 | } |
---|
15446 | 15979 | } else |
---|
15447 | 15980 | { |
---|
15448 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15981 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15449 | 15982 | } |
---|
15450 | 15983 | |
---|
15451 | 15984 | first = false; |
---|
.. | .. |
---|
15456 | 15989 | { |
---|
15457 | 15990 | //Composite group = (Composite) object; |
---|
15458 | 15991 | Object3D group = object; |
---|
15459 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15992 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15460 | 15993 | } |
---|
15461 | 15994 | |
---|
15462 | 15995 | void ResetTransform(int mask) |
---|
15463 | 15996 | { |
---|
15464 | 15997 | //Composite group = (Composite) object; |
---|
15465 | 15998 | Object3D group = object; |
---|
15466 | | - group.editWindow.ResetTransform(mask); |
---|
| 15999 | + group.GetWindow().ResetTransform(mask); |
---|
15467 | 16000 | } |
---|
15468 | 16001 | |
---|
15469 | 16002 | void FlipTransform() |
---|
15470 | 16003 | { |
---|
15471 | 16004 | //Composite group = (Composite) object; |
---|
15472 | 16005 | Object3D group = object; |
---|
15473 | | - group.editWindow.FlipTransform(); |
---|
| 16006 | + group.GetWindow().FlipTransform(); |
---|
15474 | 16007 | // group.editWindow.ReduceMesh(true); |
---|
15475 | 16008 | } |
---|
15476 | 16009 | |
---|
.. | .. |
---|
15478 | 16011 | { |
---|
15479 | 16012 | //Composite group = (Composite) object; |
---|
15480 | 16013 | Object3D group = object; |
---|
15481 | | - group.editWindow.PrintMemory(); |
---|
| 16014 | + group.GetWindow().PrintMemory(); |
---|
15482 | 16015 | // group.editWindow.ReduceMesh(true); |
---|
15483 | 16016 | } |
---|
15484 | 16017 | |
---|
.. | .. |
---|
15486 | 16019 | { |
---|
15487 | 16020 | //Composite group = (Composite) object; |
---|
15488 | 16021 | Object3D group = object; |
---|
15489 | | - group.editWindow.ResetCentroid(); |
---|
| 16022 | + group.GetWindow().ResetCentroid(); |
---|
15490 | 16023 | } |
---|
15491 | 16024 | |
---|
15492 | 16025 | void IncDepth() |
---|
.. | .. |
---|
15568 | 16101 | |
---|
15569 | 16102 | int width = getBounds().width; |
---|
15570 | 16103 | int height = getBounds().height; |
---|
15571 | | - ClickInfo info = new ClickInfo(); |
---|
15572 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15573 | 16104 | //Image img = CreateImage(width, height); |
---|
15574 | 16105 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15575 | 16106 | |
---|
.. | .. |
---|
15646 | 16177 | } |
---|
15647 | 16178 | if (object != null && !hasMarquee) |
---|
15648 | 16179 | { |
---|
| 16180 | + if (object.clickInfo == null) |
---|
| 16181 | + object.clickInfo = new ClickInfo(); |
---|
| 16182 | + ClickInfo info = object.clickInfo; |
---|
| 16183 | + //ClickInfo info = new ClickInfo(); |
---|
| 16184 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16185 | + |
---|
15649 | 16186 | if (isRenderer) |
---|
15650 | 16187 | { |
---|
15651 | | - info.flags++; |
---|
| 16188 | + object.clickInfo.flags++; |
---|
15652 | 16189 | double frameAspect = (double) width / (double) height; |
---|
15653 | 16190 | if (frameAspect > renderCamera.aspect) |
---|
15654 | 16191 | { |
---|
15655 | 16192 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15656 | | - info.bounds.width -= width - desired; |
---|
15657 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16193 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16194 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15658 | 16195 | } else |
---|
15659 | 16196 | { |
---|
15660 | 16197 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15661 | | - info.bounds.height -= height - desired; |
---|
15662 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16198 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16199 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15663 | 16200 | } |
---|
15664 | 16201 | } |
---|
15665 | | - info.g = gr; |
---|
15666 | | - info.camera = renderCamera; |
---|
| 16202 | + |
---|
| 16203 | + object.clickInfo.g = gr; |
---|
| 16204 | + object.clickInfo.camera = renderCamera; |
---|
15667 | 16205 | /* |
---|
15668 | 16206 | // Memory intensive (brep.verticescopy) |
---|
15669 | 16207 | if (!(object instanceof Composite)) |
---|
15670 | 16208 | object.draw(info, 0, false); // SLOW : |
---|
15671 | 16209 | */ |
---|
15672 | | - if (!isRenderer) |
---|
| 16210 | + if (!isRenderer) // && drag) |
---|
15673 | 16211 | { |
---|
15674 | | - object.drawEditHandles(info, 0); |
---|
15675 | | - |
---|
15676 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16212 | + Grafreed.Assert(object != null); |
---|
| 16213 | + Grafreed.Assert(object.selection != null); |
---|
| 16214 | + if (object.selection.Size() > 0) |
---|
15677 | 16215 | { |
---|
15678 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16216 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16217 | + |
---|
| 16218 | + object.clickInfo.DX = 0; |
---|
| 16219 | + object.clickInfo.DY = 0; |
---|
| 16220 | + object.clickInfo.W = 1; |
---|
| 16221 | + if (hitSomething == Object3D.hitCenter) |
---|
15679 | 16222 | { |
---|
15680 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15681 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15682 | | - break; |
---|
15683 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15684 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15685 | | - break; |
---|
15686 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15687 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15688 | | - break; |
---|
| 16223 | + info.DX = X; |
---|
| 16224 | + if (X != 0) |
---|
| 16225 | + info.DX -= info.bounds.width/2; |
---|
| 16226 | + |
---|
| 16227 | + info.DY = Y; |
---|
| 16228 | + if (Y != 0) |
---|
| 16229 | + info.DY -= info.bounds.height/2; |
---|
15689 | 16230 | } |
---|
15690 | | - |
---|
| 16231 | + |
---|
| 16232 | + object.drawEditHandles(//info, |
---|
| 16233 | + 0); |
---|
| 16234 | + |
---|
| 16235 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16236 | + { |
---|
| 16237 | + switch (hitSomething) |
---|
| 16238 | + { |
---|
| 16239 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16240 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16241 | + break; |
---|
| 16242 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16243 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16244 | + break; |
---|
| 16245 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16246 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16247 | + break; |
---|
| 16248 | + } |
---|
| 16249 | + |
---|
| 16250 | + } |
---|
15691 | 16251 | } |
---|
15692 | 16252 | } |
---|
15693 | 16253 | } |
---|
.. | .. |
---|
15702 | 16262 | if (hasMarquee) |
---|
15703 | 16263 | { |
---|
15704 | 16264 | gr.setXORMode(Color.white); |
---|
15705 | | - gr.setColor(Color.red); |
---|
| 16265 | + gr.setColor(Color.white); |
---|
15706 | 16266 | if (!firstime) |
---|
15707 | 16267 | { |
---|
15708 | 16268 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16169 | 16729 | private /*static*/ boolean firstime; |
---|
16170 | 16730 | private /*static*/ cVector newView = new cVector(); |
---|
16171 | 16731 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16732 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16733 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16172 | 16734 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16173 | 16735 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16174 | 16736 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16181 | 16743 | { |
---|
16182 | 16744 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16183 | 16745 | |
---|
| 16746 | + int usedsuf = 0; |
---|
| 16747 | + |
---|
16184 | 16748 | for (int i = 0; i < suffixes.length; i++) |
---|
16185 | 16749 | { |
---|
16186 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16187 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16188 | | - mipmapped, |
---|
16189 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16190 | | - if (data == null) |
---|
| 16750 | + String[] suffixe = suffixes; |
---|
| 16751 | + String[] fallback = suffixes2; |
---|
| 16752 | + String[] fallfallback = suffixes3; |
---|
| 16753 | + |
---|
| 16754 | + for (int c=usedsuf; --c>=0;) |
---|
16191 | 16755 | { |
---|
16192 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16756 | +// String[] temp = suffixe; |
---|
| 16757 | +// suffixe = fallback; |
---|
| 16758 | +// fallback = fallfallback; |
---|
| 16759 | +// fallfallback = temp; |
---|
16193 | 16760 | } |
---|
| 16761 | + |
---|
| 16762 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16763 | + TextureData data; |
---|
| 16764 | + |
---|
| 16765 | + try |
---|
| 16766 | + { |
---|
| 16767 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16768 | + mipmapped, |
---|
| 16769 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16770 | + } |
---|
| 16771 | + catch (Exception e) |
---|
| 16772 | + { |
---|
| 16773 | + try |
---|
| 16774 | + { |
---|
| 16775 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16776 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16777 | + mipmapped, |
---|
| 16778 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16779 | + } |
---|
| 16780 | + catch (Exception e2) |
---|
| 16781 | + { |
---|
| 16782 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16783 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16784 | + mipmapped, |
---|
| 16785 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16786 | + } |
---|
| 16787 | + } |
---|
| 16788 | + |
---|
16194 | 16789 | //System.out.println("Target = " + targets[i]); |
---|
16195 | 16790 | cubemap.updateImage(data, targets[i]); |
---|
16196 | 16791 | } |
---|
16197 | 16792 | |
---|
16198 | 16793 | return cubemap; |
---|
16199 | 16794 | } |
---|
| 16795 | + |
---|
16200 | 16796 | int bigsphere = -1; |
---|
16201 | 16797 | |
---|
16202 | 16798 | float BGcolor = 0.5f; |
---|
16203 | 16799 | |
---|
16204 | | - private void DrawSkyBox(GL gl) |
---|
| 16800 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16801 | + |
---|
| 16802 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16205 | 16803 | { |
---|
16206 | | - if (envyoff || cubemap == null) |
---|
| 16804 | + if (//envyoff || |
---|
| 16805 | + WIREFRAME || |
---|
| 16806 | + cubemap == null) |
---|
16207 | 16807 | { |
---|
16208 | 16808 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16209 | 16809 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16218 | 16818 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16219 | 16819 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16220 | 16820 | gl.glLoadIdentity(); |
---|
| 16821 | + gl.glScalef(1,ratio,1); |
---|
16221 | 16822 | |
---|
| 16823 | +// colorV[0] = 2; |
---|
| 16824 | +// colorV[1] = 2; |
---|
| 16825 | +// colorV[2] = 2; |
---|
| 16826 | +// colorV[3] = 1; |
---|
| 16827 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16828 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16829 | +// |
---|
| 16830 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16831 | + |
---|
16222 | 16832 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16223 | 16833 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16224 | 16834 | |
---|
.. | .. |
---|
16250 | 16860 | { |
---|
16251 | 16861 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16252 | 16862 | } |
---|
| 16863 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16253 | 16864 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16254 | 16865 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16255 | 16866 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16290 | 16901 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16291 | 16902 | |
---|
16292 | 16903 | cubemap.disable(); |
---|
16293 | | - ////cubemap.unbind(); |
---|
| 16904 | + //cubemap.dispose(); |
---|
| 16905 | + |
---|
16294 | 16906 | if (CULLFACE) |
---|
16295 | 16907 | { |
---|
16296 | 16908 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16346 | 16958 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16347 | 16959 | } |
---|
16348 | 16960 | |
---|
16349 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16961 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16350 | 16962 | |
---|
16351 | 16963 | float step = 2; // 0.1666f; //0.25f; |
---|
16352 | 16964 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16485 | 17097 | } |
---|
16486 | 17098 | } |
---|
16487 | 17099 | |
---|
| 17100 | + private Object3D GetFolder() |
---|
| 17101 | + { |
---|
| 17102 | + Object3D folder = object.GetWindow().copy; |
---|
| 17103 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17104 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17105 | + return folder; |
---|
| 17106 | + } |
---|
| 17107 | + |
---|
16488 | 17108 | class SelectBuffer implements GLEventListener |
---|
16489 | 17109 | { |
---|
16490 | 17110 | |
---|
.. | .. |
---|
16500 | 17120 | //new Exception().printStackTrace(); |
---|
16501 | 17121 | System.out.println("select buffer init"); |
---|
16502 | 17122 | // Use debug pipeline |
---|
16503 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17123 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16504 | 17124 | |
---|
16505 | 17125 | GL gl = drawable.getGL(); |
---|
16506 | 17126 | |
---|
.. | .. |
---|
16564 | 17184 | |
---|
16565 | 17185 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16566 | 17186 | |
---|
| 17187 | + if (PAINTMODE) |
---|
| 17188 | + { |
---|
| 17189 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17190 | + { |
---|
| 17191 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17192 | + |
---|
| 17193 | + // Make what you paint not selectable. |
---|
| 17194 | + paintobj.ResetSelectable(); |
---|
| 17195 | + } |
---|
| 17196 | + } |
---|
| 17197 | + |
---|
16567 | 17198 | //int tmp = selection_view; |
---|
16568 | 17199 | //selection_view = -1; |
---|
16569 | 17200 | int temp = DrawMode(); |
---|
.. | .. |
---|
16575 | 17206 | // temp = DEFAULT; // patch for selection debug |
---|
16576 | 17207 | Globals.drawMode = temp; // WARNING |
---|
16577 | 17208 | |
---|
| 17209 | + if (PAINTMODE) |
---|
| 17210 | + { |
---|
| 17211 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17212 | + { |
---|
| 17213 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17214 | + |
---|
| 17215 | + // Revert. |
---|
| 17216 | + paintobj.RestoreSelectable(); |
---|
| 17217 | + } |
---|
| 17218 | + } |
---|
| 17219 | + |
---|
16578 | 17220 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16579 | 17221 | |
---|
16580 | 17222 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16678 | 17320 | } |
---|
16679 | 17321 | |
---|
16680 | 17322 | if (!movingcamera && !PAINTMODE) |
---|
16681 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17323 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16682 | 17324 | |
---|
16683 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17325 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16684 | 17326 | { |
---|
16685 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17327 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16686 | 17328 | |
---|
16687 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17329 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17330 | + { |
---|
| 17331 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16688 | 17332 | |
---|
16689 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16690 | | - |
---|
16691 | | - group.add(paintobj); // link |
---|
16692 | | - |
---|
16693 | | - object.editWindow.SnapObject(group); |
---|
16694 | | - |
---|
16695 | | - Object3D folder = object.editWindow.copy; |
---|
16696 | | - |
---|
16697 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16698 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16699 | | - |
---|
16700 | | - folder.add(group); |
---|
16701 | | - |
---|
16702 | | - object.editWindow.ResetModel(); |
---|
16703 | | - object.editWindow.refreshContents(); |
---|
| 17333 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17334 | + |
---|
| 17335 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17336 | + |
---|
| 17337 | + inst.add(paintobj); // link |
---|
| 17338 | + |
---|
| 17339 | + object.GetWindow().SnapObject(inst); |
---|
| 17340 | + |
---|
| 17341 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17342 | + |
---|
| 17343 | + folder.add(inst); |
---|
| 17344 | + |
---|
| 17345 | + object.GetWindow().ResetModel(); |
---|
| 17346 | + object.GetWindow().refreshContents(); |
---|
| 17347 | + } |
---|
16704 | 17348 | } |
---|
16705 | 17349 | else |
---|
16706 | 17350 | paintcount = 0; |
---|
.. | .. |
---|
16739 | 17383 | //System.out.println("objects[color] = " + objects[color]); |
---|
16740 | 17384 | //objects[color].Select(); |
---|
16741 | 17385 | indexcount = 0; |
---|
| 17386 | + ObjEditor window = object.GetWindow(); |
---|
| 17387 | + if (window != null && deselect) |
---|
| 17388 | + { |
---|
| 17389 | + window.Select(null, deselect, true); |
---|
| 17390 | + } |
---|
16742 | 17391 | object.Select(color, deselect); |
---|
16743 | 17392 | } |
---|
16744 | 17393 | |
---|
.. | .. |
---|
16789 | 17438 | |
---|
16790 | 17439 | public void init(GLAutoDrawable drawable) |
---|
16791 | 17440 | { |
---|
| 17441 | + if (Globals.DEBUG) |
---|
16792 | 17442 | System.out.println("shadow buffer init"); |
---|
16793 | 17443 | |
---|
16794 | 17444 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17017 | 17667 | gl.glFlush(); |
---|
17018 | 17668 | |
---|
17019 | 17669 | /**/ |
---|
17020 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17670 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17021 | 17671 | |
---|
17022 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17672 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17023 | 17673 | |
---|
| 17674 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17675 | + |
---|
| 17676 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17677 | + |
---|
17024 | 17678 | double r = 0, g = 0, b = 0; |
---|
17025 | 17679 | |
---|
17026 | 17680 | double count = 0; |
---|
.. | .. |
---|
17031 | 17685 | |
---|
17032 | 17686 | double FACTOR = 1; |
---|
17033 | 17687 | |
---|
17034 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17688 | + for (int i = 0; i < depths.length; i++) |
---|
17035 | 17689 | { |
---|
17036 | 17690 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17037 | 17691 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17114 | 17768 | |
---|
17115 | 17769 | double scale = ray.z; // 1; // cos |
---|
17116 | 17770 | |
---|
17117 | | - float depth = pixels[newindex]; |
---|
| 17771 | + float depth = depths[newindex]; |
---|
17118 | 17772 | |
---|
17119 | 17773 | /* |
---|
17120 | 17774 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17311 | 17965 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17312 | 17966 | static IntBuffer bigAAbuffer; |
---|
17313 | 17967 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17314 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17968 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17315 | 17969 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17316 | 17970 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17317 | 17971 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17318 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17972 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17973 | + |
---|
| 17974 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17975 | + |
---|
17319 | 17976 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17320 | 17977 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17321 | 17978 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|