.. | .. |
---|
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 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 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 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
56 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 95 | |
---|
62 | 96 | boolean DISPLAYTEXT = false; |
---|
63 | 97 | //boolean REDUCETEXTURE = true; |
---|
64 | 98 | boolean CACHETEXTURE = true; |
---|
65 | 99 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
67 | 101 | boolean COMPRESSTEXTURE = false; |
---|
68 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
76 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
77 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
78 | 112 | static GLContext glcontext = null; |
---|
79 | | - /*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 | + |
---|
80 | 118 | boolean reverseUP = false; |
---|
81 | 119 | static boolean frozen = false; |
---|
82 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
86 | 124 | static boolean FULLSCREEN = false; |
---|
87 | 125 | static boolean SUPPORT = true; |
---|
88 | 126 | static boolean INERTIA = true; |
---|
89 | | -static boolean FAST = true; // false; |
---|
| 127 | +static boolean FAST = false; |
---|
90 | 128 | static boolean SLOWPOSE = false; |
---|
91 | 129 | static boolean FOOTCONTACT = true; |
---|
92 | 130 | |
---|
.. | .. |
---|
108 | 146 | static boolean OEIL = true; |
---|
109 | 147 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
110 | 148 | static boolean LOOKAT = true; |
---|
111 | | -static boolean RANDOM = true; // false; |
---|
| 149 | +static boolean SWITCH = true; // false; |
---|
112 | 150 | static boolean HANDLES = false; // selection doesn't work!! |
---|
113 | 151 | static boolean PAINTMODE = false; |
---|
114 | 152 | |
---|
.. | .. |
---|
139 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
140 | 178 | boolean anisotropy = true; |
---|
141 | 179 | boolean softshadow = true; // slower but better false; |
---|
142 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
143 | 181 | |
---|
144 | 182 | boolean macromode = false; |
---|
145 | 183 | |
---|
.. | .. |
---|
150 | 188 | defaultcaps.setAccumGreenBits(16); |
---|
151 | 189 | defaultcaps.setAccumBlueBits(16); |
---|
152 | 190 | defaultcaps.setAccumAlphaBits(16); |
---|
| 191 | + } |
---|
| 192 | + |
---|
| 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 | + } |
---|
153 | 206 | } |
---|
154 | 207 | |
---|
155 | 208 | void SetAsGLRenderer(boolean b) |
---|
.. | .. |
---|
170 | 223 | |
---|
171 | 224 | SetCamera(cam); |
---|
172 | 225 | |
---|
173 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
174 | 228 | |
---|
175 | 229 | object = o; |
---|
176 | 230 | |
---|
.. | .. |
---|
327 | 381 | cStatic.objectstack[materialdepth++] = obj; |
---|
328 | 382 | //System.out.println("material " + material); |
---|
329 | 383 | //Applet3D.tracein(this, selected); |
---|
330 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 384 | + //display.vector2buffer = obj.projectedVertices; |
---|
331 | 385 | if (obj instanceof Camera) |
---|
332 | 386 | { |
---|
333 | 387 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
336 | 390 | display.options1[2] = material.shadowbias; |
---|
337 | 391 | display.options1[3] = material.aniso; |
---|
338 | 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]); |
---|
339 | 398 | display.options2[0] = material.opacity; |
---|
340 | 399 | display.options2[1] = material.diffuse; |
---|
341 | 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]); |
---|
342 | 404 | |
---|
343 | 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]); |
---|
344 | 409 | display.options4[0] = material.cameralight/0.2f; |
---|
345 | 410 | display.options4[1] = material.subsurface; |
---|
346 | 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]); |
---|
347 | 415 | |
---|
348 | 416 | // if (display.CURRENTANTIALIAS > 0) |
---|
349 | 417 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
359 | 427 | /**/ |
---|
360 | 428 | } else |
---|
361 | 429 | { |
---|
362 | | - DrawMaterial(material, selected); |
---|
| 430 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
363 | 431 | } |
---|
364 | 432 | } else |
---|
365 | 433 | { |
---|
.. | .. |
---|
383 | 451 | cStatic.objectstack[materialdepth++] = obj; |
---|
384 | 452 | //System.out.println("material " + material); |
---|
385 | 453 | //Applet3D.tracein("selected ", selected); |
---|
386 | | - display.vector2buffer = obj.projectedVertices; |
---|
387 | | - display.DrawMaterial(material, selected); |
---|
| 454 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 455 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
388 | 456 | } |
---|
389 | 457 | } |
---|
390 | 458 | |
---|
.. | .. |
---|
401 | 469 | materialdepth -= 1; |
---|
402 | 470 | if (materialdepth > 0) |
---|
403 | 471 | { |
---|
404 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
405 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 472 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 473 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
406 | 474 | } |
---|
407 | 475 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
408 | 476 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
422 | 490 | materialdepth -= 1; |
---|
423 | 491 | if (materialdepth > 0) |
---|
424 | 492 | { |
---|
425 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
426 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 493 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 494 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
427 | 495 | } |
---|
428 | 496 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
429 | 497 | //else |
---|
.. | .. |
---|
464 | 532 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
465 | 533 | { |
---|
466 | 534 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
467 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 535 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 536 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 537 | + ; |
---|
468 | 538 | if (!hasnorm) |
---|
469 | 539 | { |
---|
470 | | - // System.out.println("FUCK!!"); |
---|
| 540 | + // System.out.println("Mesh normal"); |
---|
471 | 541 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
472 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
473 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1192 | 1262 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1193 | 1263 | } |
---|
1194 | 1264 | } |
---|
| 1265 | + |
---|
1195 | 1266 | if (flipV) |
---|
1196 | 1267 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1197 | 1268 | else |
---|
1198 | 1269 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1270 | + |
---|
1199 | 1271 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1200 | 1272 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1201 | 1273 | |
---|
.. | .. |
---|
1215 | 1287 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1216 | 1288 | } |
---|
1217 | 1289 | } |
---|
| 1290 | + |
---|
1218 | 1291 | if (flipV) |
---|
1219 | 1292 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1220 | 1293 | else |
---|
1221 | 1294 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1295 | + |
---|
1222 | 1296 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1223 | 1297 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1224 | 1298 | |
---|
.. | .. |
---|
1246 | 1320 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1247 | 1321 | else |
---|
1248 | 1322 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1323 | + |
---|
1249 | 1324 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1250 | 1325 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1326 | + |
---|
1251 | 1327 | count2 += 2; |
---|
1252 | 1328 | count3 += 3; |
---|
1253 | 1329 | } |
---|
.. | .. |
---|
1426 | 1502 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1427 | 1503 | } |
---|
1428 | 1504 | |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
1429 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
1430 | 1508 | { |
---|
1431 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
1493 | 1571 | { |
---|
1494 | 1572 | return; |
---|
1495 | 1573 | } |
---|
1496 | | - |
---|
1497 | | - float[] colorV = new float[3]; |
---|
1498 | 1574 | |
---|
1499 | 1575 | if (false) // marked) |
---|
1500 | 1576 | { |
---|
.. | .. |
---|
1603 | 1679 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1604 | 1680 | } |
---|
1605 | 1681 | |
---|
1606 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1682 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1607 | 1683 | { |
---|
1608 | 1684 | CameraPane display = this; |
---|
1609 | 1685 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1630 | 1706 | |
---|
1631 | 1707 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1632 | 1708 | |
---|
1633 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1709 | + float[] colorV = Grafreed.colorV; |
---|
1634 | 1710 | |
---|
1635 | 1711 | /**/ |
---|
1636 | 1712 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1638 | 1714 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1639 | 1715 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1640 | 1716 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1641 | | - colorV[3] = material.opacity; |
---|
| 1717 | + colorV[3] = 1; // material.opacity; |
---|
1642 | 1718 | |
---|
1643 | 1719 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1644 | 1720 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1746 | 1822 | display.modelParams7[2] = 0; |
---|
1747 | 1823 | display.modelParams7[3] = 0; |
---|
1748 | 1824 | |
---|
1749 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1825 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1750 | 1826 | |
---|
1751 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1827 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1752 | 1828 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1753 | 1829 | { |
---|
1754 | 1830 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1890 | 1966 | void PushMatrix(double[][] matrix) |
---|
1891 | 1967 | { |
---|
1892 | 1968 | // GrafreeD.tracein(matrix); |
---|
1893 | | - PushMatrix(matrix,1); |
---|
| 1969 | + PushMatrix(matrix, 1); |
---|
1894 | 1970 | } |
---|
1895 | 1971 | |
---|
1896 | 1972 | void PushMatrix() |
---|
.. | .. |
---|
2044 | 2120 | //System.err.println("Oeil on"); |
---|
2045 | 2121 | OEIL = true; |
---|
2046 | 2122 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2047 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2123 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2048 | 2124 | //pingthread.StepToTarget(true); |
---|
2049 | 2125 | } |
---|
2050 | 2126 | |
---|
.. | .. |
---|
2142 | 2218 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
2143 | 2219 | |
---|
2144 | 2220 | if (!Globals.isLIVE()) // save sound |
---|
2145 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2221 | + Grafreed.savesound = true; // wav.save(); |
---|
2146 | 2222 | // else |
---|
2147 | 2223 | repaint(); // start loop // may 2013 |
---|
2148 | 2224 | } |
---|
.. | .. |
---|
2259 | 2335 | |
---|
2260 | 2336 | void ToggleDebug() |
---|
2261 | 2337 | { |
---|
2262 | | - DEBUG ^= true; |
---|
| 2338 | + Globals.DEBUG ^= true; |
---|
2263 | 2339 | } |
---|
2264 | 2340 | |
---|
2265 | 2341 | void ToggleLookAt() |
---|
.. | .. |
---|
2267 | 2343 | LOOKAT ^= true; |
---|
2268 | 2344 | } |
---|
2269 | 2345 | |
---|
2270 | | - void ToggleRandom() |
---|
| 2346 | + void ToggleSwitch() |
---|
2271 | 2347 | { |
---|
2272 | | - RANDOM ^= true; |
---|
| 2348 | + SWITCH ^= true; |
---|
2273 | 2349 | } |
---|
2274 | 2350 | |
---|
2275 | 2351 | void ToggleHandles() |
---|
.. | .. |
---|
2277 | 2353 | HANDLES ^= true; |
---|
2278 | 2354 | } |
---|
2279 | 2355 | |
---|
| 2356 | + Object3D paintFolder; |
---|
| 2357 | + |
---|
2280 | 2358 | void TogglePaint() |
---|
2281 | 2359 | { |
---|
2282 | 2360 | PAINTMODE ^= true; |
---|
2283 | 2361 | paintcount = 0; |
---|
| 2362 | + |
---|
| 2363 | + if (PAINTMODE) |
---|
| 2364 | + { |
---|
| 2365 | + paintFolder = GetFolder(); |
---|
| 2366 | + } |
---|
2284 | 2367 | } |
---|
2285 | 2368 | |
---|
2286 | 2369 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2376 | 2459 | { |
---|
2377 | 2460 | return currentGL; |
---|
2378 | 2461 | } |
---|
2379 | | - |
---|
| 2462 | + |
---|
| 2463 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2464 | + { |
---|
| 2465 | + Grafreed.Assert(texturedata != null); |
---|
| 2466 | + |
---|
| 2467 | + int width = texturedata.getWidth(); |
---|
| 2468 | + int height = texturedata.getHeight(); |
---|
| 2469 | + |
---|
| 2470 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2471 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2472 | + |
---|
| 2473 | + byte[] bytes = bytebuf.array(); |
---|
| 2474 | + |
---|
| 2475 | + return CreateBim(bytes, width, height); |
---|
| 2476 | + } |
---|
| 2477 | + |
---|
2380 | 2478 | /**/ |
---|
2381 | 2479 | class CacheTexture |
---|
2382 | 2480 | { |
---|
.. | .. |
---|
2385 | 2483 | |
---|
2386 | 2484 | int resolution; |
---|
2387 | 2485 | |
---|
2388 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2486 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2389 | 2487 | { |
---|
2390 | | - texture = tex; |
---|
| 2488 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2489 | + texturedata = texdata; |
---|
2391 | 2490 | resolution = res; |
---|
2392 | 2491 | } |
---|
2393 | 2492 | } |
---|
2394 | 2493 | /**/ |
---|
2395 | 2494 | |
---|
2396 | 2495 | // TEXTURE static Texture texture; |
---|
2397 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2398 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2399 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2496 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2497 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2498 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2499 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2500 | + |
---|
2400 | 2501 | int pigmentdepth = 0; |
---|
2401 | 2502 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2503 | int bumpdepth = 0; |
---|
2403 | 2504 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2404 | 2505 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2405 | 2506 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2406 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2507 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2407 | 2508 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2408 | 2509 | |
---|
2409 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2510 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2410 | 2511 | { |
---|
2411 | 2512 | TextureData texturedata = null; |
---|
2412 | 2513 | |
---|
.. | .. |
---|
2416 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2417 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2418 | 2519 | true, |
---|
2419 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2420 | 2521 | } catch (java.io.IOException e) |
---|
2421 | 2522 | { |
---|
2422 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2425 | 2526 | if (bump) |
---|
2426 | 2527 | texturedata = ConvertBump(texturedata, false); |
---|
2427 | 2528 | |
---|
2428 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2429 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2529 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2530 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2430 | 2531 | |
---|
2431 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2432 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2532 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2533 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2433 | 2534 | |
---|
2434 | | - return texture; |
---|
| 2535 | + return texturedata; |
---|
| 2536 | + } |
---|
| 2537 | + |
---|
| 2538 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2539 | + { |
---|
| 2540 | + TextureData texturedata = null; |
---|
| 2541 | + |
---|
| 2542 | + try |
---|
| 2543 | + { |
---|
| 2544 | + texturedata = |
---|
| 2545 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2546 | + bim, |
---|
| 2547 | + true); |
---|
| 2548 | + } catch (Exception e) |
---|
| 2549 | + { |
---|
| 2550 | + throw new javax.media.opengl.GLException(e); |
---|
| 2551 | + } |
---|
| 2552 | + |
---|
| 2553 | + if (bump) |
---|
| 2554 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2555 | + |
---|
| 2556 | + return texturedata; |
---|
2435 | 2557 | } |
---|
2436 | 2558 | |
---|
2437 | 2559 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3504 | 3626 | |
---|
3505 | 3627 | System.out.println("LOADING TEXTURE : " + name); |
---|
3506 | 3628 | |
---|
| 3629 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3630 | + |
---|
3507 | 3631 | // |
---|
3508 | 3632 | if (false) // compressbit > 0) |
---|
3509 | 3633 | { |
---|
.. | .. |
---|
7902 | 8026 | String pigment = Object3D.GetPigment(tex); |
---|
7903 | 8027 | String bump = Object3D.GetBump(tex); |
---|
7904 | 8028 | |
---|
7905 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8029 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7906 | 8030 | { |
---|
7907 | 8031 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7908 | 8032 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7917 | 8041 | pigment = null; |
---|
7918 | 8042 | } |
---|
7919 | 8043 | |
---|
7920 | | - ReleaseTexture(bump, true); |
---|
7921 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
7922 | 8046 | } |
---|
7923 | 8047 | |
---|
7924 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8048 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8049 | + { |
---|
| 8050 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8051 | + { |
---|
| 8052 | + return; |
---|
| 8053 | + } |
---|
| 8054 | + |
---|
| 8055 | + if (tex == null) |
---|
| 8056 | + { |
---|
| 8057 | + ReleaseTexture(null, false); |
---|
| 8058 | + return; |
---|
| 8059 | + } |
---|
| 8060 | + |
---|
| 8061 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8062 | + |
---|
| 8063 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8064 | + { |
---|
| 8065 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8066 | + // System.out.println("; bump = " + bump); |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + if (pigment.equals("")) |
---|
| 8070 | + { |
---|
| 8071 | + pigment = null; |
---|
| 8072 | + } |
---|
| 8073 | + |
---|
| 8074 | + ReleaseTexture(tex, false); |
---|
| 8075 | + } |
---|
| 8076 | + |
---|
| 8077 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8078 | + { |
---|
| 8079 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8080 | + { |
---|
| 8081 | + return; |
---|
| 8082 | + } |
---|
| 8083 | + |
---|
| 8084 | + if (tex == null) |
---|
| 8085 | + { |
---|
| 8086 | + ReleaseTexture(null, true); |
---|
| 8087 | + return; |
---|
| 8088 | + } |
---|
| 8089 | + |
---|
| 8090 | + String bump = Object3D.GetBump(tex); |
---|
| 8091 | + |
---|
| 8092 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8093 | + { |
---|
| 8094 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8095 | + // System.out.println("; bump = " + bump); |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + if (bump.equals("")) |
---|
| 8099 | + { |
---|
| 8100 | + bump = null; |
---|
| 8101 | + } |
---|
| 8102 | + |
---|
| 8103 | + ReleaseTexture(tex, true); |
---|
| 8104 | + } |
---|
| 8105 | + |
---|
| 8106 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7925 | 8107 | { |
---|
7926 | 8108 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7927 | 8109 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7932 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7933 | 8115 | |
---|
7934 | 8116 | if (tex != null) |
---|
7935 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7936 | 8118 | |
---|
7937 | 8119 | // //assert( texture != null ); |
---|
7938 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
8024 | 8206 | } |
---|
8025 | 8207 | } |
---|
8026 | 8208 | |
---|
8027 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8209 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8210 | + { |
---|
| 8211 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8212 | +// ambientOcclusion ) // || !textureon) |
---|
| 8213 | +// { |
---|
| 8214 | +// return; // false; |
---|
| 8215 | +// } |
---|
| 8216 | +// |
---|
| 8217 | +// if (tex == null) |
---|
| 8218 | +// { |
---|
| 8219 | +// BindTexture(null,false,resolution); |
---|
| 8220 | +// BindTexture(null,true,resolution); |
---|
| 8221 | +// return; |
---|
| 8222 | +// } |
---|
| 8223 | +// |
---|
| 8224 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8225 | +// String bump = Object3D.GetBump(tex); |
---|
| 8226 | +// |
---|
| 8227 | +// usedtextures.add(pigment); |
---|
| 8228 | +// usedtextures.add(bump); |
---|
| 8229 | +// |
---|
| 8230 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8231 | +// { |
---|
| 8232 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8233 | +// // System.out.println("; bump = " + bump); |
---|
| 8234 | +// } |
---|
| 8235 | +// |
---|
| 8236 | +// if (bump.equals("")) |
---|
| 8237 | +// { |
---|
| 8238 | +// bump = null; |
---|
| 8239 | +// } |
---|
| 8240 | +// if (pigment.equals("")) |
---|
| 8241 | +// { |
---|
| 8242 | +// pigment = null; |
---|
| 8243 | +// } |
---|
| 8244 | +// |
---|
| 8245 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8246 | +// BindTexture(pigment, false, resolution); |
---|
| 8247 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8248 | +// BindTexture(bump, true, resolution); |
---|
| 8249 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8250 | +// |
---|
| 8251 | +// return; // true; |
---|
| 8252 | + |
---|
| 8253 | + BindPigmentTexture(tex, resolution); |
---|
| 8254 | + BindBumpTexture(tex, resolution); |
---|
| 8255 | + } |
---|
| 8256 | + |
---|
| 8257 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8028 | 8258 | { |
---|
8029 | 8259 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8030 | 8260 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8035 | 8265 | if (tex == null) |
---|
8036 | 8266 | { |
---|
8037 | 8267 | BindTexture(null,false,resolution); |
---|
8038 | | - BindTexture(null,true,resolution); |
---|
8039 | 8268 | return; |
---|
8040 | 8269 | } |
---|
8041 | 8270 | |
---|
8042 | 8271 | String pigment = Object3D.GetPigment(tex); |
---|
| 8272 | + |
---|
| 8273 | + usedtextures.add(tex); |
---|
| 8274 | + |
---|
| 8275 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8276 | + { |
---|
| 8277 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8278 | + // System.out.println("; bump = " + bump); |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + if (pigment.equals("")) |
---|
| 8282 | + { |
---|
| 8283 | + pigment = null; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
| 8286 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8287 | + BindTexture(tex, false, resolution); |
---|
| 8288 | + } |
---|
| 8289 | + |
---|
| 8290 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8291 | + { |
---|
| 8292 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8293 | + ambientOcclusion ) // || !textureon) |
---|
| 8294 | + { |
---|
| 8295 | + return; // false; |
---|
| 8296 | + } |
---|
| 8297 | + |
---|
| 8298 | + if (tex == null) |
---|
| 8299 | + { |
---|
| 8300 | + BindTexture(null,true,resolution); |
---|
| 8301 | + return; |
---|
| 8302 | + } |
---|
| 8303 | + |
---|
8043 | 8304 | String bump = Object3D.GetBump(tex); |
---|
8044 | 8305 | |
---|
8045 | | - usedtextures.put(pigment, pigment); |
---|
8046 | | - usedtextures.put(bump, bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
8047 | 8307 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8308 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8309 | { |
---|
8050 | 8310 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8311 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8055 | 8315 | { |
---|
8056 | 8316 | bump = null; |
---|
8057 | 8317 | } |
---|
8058 | | - if (pigment.equals("")) |
---|
8059 | | - { |
---|
8060 | | - pigment = null; |
---|
8061 | | - } |
---|
8062 | 8318 | |
---|
8063 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8064 | | - BindTexture(pigment, false, resolution); |
---|
8065 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8066 | | - BindTexture(bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
8067 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8068 | | - |
---|
8069 | | - return; // true; |
---|
8070 | 8322 | } |
---|
8071 | 8323 | |
---|
8072 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8324 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8325 | + |
---|
| 8326 | + private boolean FileExists(String tex) |
---|
8073 | 8327 | { |
---|
8074 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + if (missingTextures.contains(tex)) |
---|
| 8329 | + { |
---|
| 8330 | + return false; |
---|
| 8331 | + } |
---|
| 8332 | + |
---|
| 8333 | + boolean fileExists = new File(tex).exists(); |
---|
| 8334 | + |
---|
| 8335 | + if (!fileExists) |
---|
| 8336 | + { |
---|
| 8337 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8338 | + missingTextures.add(tex); |
---|
| 8339 | + } |
---|
| 8340 | + |
---|
| 8341 | + return fileExists; |
---|
| 8342 | + } |
---|
| 8343 | + |
---|
| 8344 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8345 | + { |
---|
| 8346 | + CacheTexture texturecache = null; |
---|
8075 | 8347 | |
---|
8076 | 8348 | if (tex != null) |
---|
8077 | 8349 | { |
---|
8078 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8079 | 8352 | |
---|
8080 | | - String[] split = tex.split("Textures"); |
---|
8081 | | - if (split.length > 1) |
---|
8082 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8083 | | - else |
---|
8084 | | - if (!texname.startsWith("/")) |
---|
8085 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8353 | + if (texname.equals("") && texdata == null) |
---|
| 8354 | + { |
---|
| 8355 | + return null; |
---|
| 8356 | + } |
---|
| 8357 | + |
---|
| 8358 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8359 | + |
---|
| 8360 | +// String[] split = tex.split("Textures"); |
---|
| 8361 | +// if (split.length > 1) |
---|
| 8362 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8363 | +// else |
---|
| 8364 | +// if (!texname.startsWith("/")) |
---|
| 8365 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
| 8367 | + { |
---|
| 8368 | + texname = fallbackTextureName; |
---|
| 8369 | + } |
---|
8086 | 8370 | |
---|
8087 | 8371 | if (CACHETEXTURE) |
---|
8088 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8089 | | - |
---|
8090 | | - TextureData texturedata = null; |
---|
8091 | | - |
---|
8092 | | - if (texture == null || texture.resolution < resolution) |
---|
8093 | 8372 | { |
---|
8094 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8373 | + if (texdata == null) |
---|
| 8374 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8375 | + else |
---|
| 8376 | + texturecache = bimtextures.get(texdata); |
---|
| 8377 | + } |
---|
| 8378 | + |
---|
| 8379 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8380 | + { |
---|
| 8381 | + TextureData texturedata = null; |
---|
| 8382 | + |
---|
| 8383 | + if (texdata != null && textureon) |
---|
| 8384 | + { |
---|
| 8385 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8386 | + |
---|
| 8387 | + try |
---|
| 8388 | + { |
---|
| 8389 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8390 | + } |
---|
| 8391 | + catch (Exception e) |
---|
| 8392 | + { |
---|
| 8393 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8394 | + } |
---|
| 8395 | + |
---|
| 8396 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8397 | + bimtextures.put(texdata, texturecache); |
---|
| 8398 | + |
---|
| 8399 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8400 | + |
---|
| 8401 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8402 | + //bim2 = bim; |
---|
| 8403 | + } |
---|
| 8404 | + else |
---|
| 8405 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8095 | 8406 | { |
---|
8096 | 8407 | assert(!bump); |
---|
8097 | 8408 | // if (bump) |
---|
.. | .. |
---|
8102 | 8413 | // } |
---|
8103 | 8414 | // else |
---|
8104 | 8415 | // { |
---|
8105 | | - texture = textures.get(tex); |
---|
8106 | | - if (texture == null) |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8417 | + if (texturecache == null) |
---|
8107 | 8418 | { |
---|
8108 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8419 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8109 | 8420 | } |
---|
| 8421 | + else |
---|
| 8422 | + new Exception().printStackTrace(); |
---|
8110 | 8423 | // } |
---|
8111 | 8424 | } else |
---|
8112 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8113 | 8426 | { |
---|
8114 | 8427 | assert(bump); |
---|
8115 | | - texture = textures.get(tex); |
---|
8116 | | - if (texture == null) |
---|
8117 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8428 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8429 | + if (texturecache == null) |
---|
| 8430 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8431 | + else |
---|
| 8432 | + new Exception().printStackTrace(); |
---|
8118 | 8433 | } else |
---|
8119 | 8434 | { |
---|
8120 | 8435 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8122 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
8123 | 8438 | //} else |
---|
8124 | 8439 | //{ |
---|
8125 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8126 | 8441 | { |
---|
8127 | | - texture = textures.get(tex); |
---|
8128 | | - if (texture == null) |
---|
8129 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8442 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8443 | + if (texturecache == null) |
---|
| 8444 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8445 | + else |
---|
| 8446 | + new Exception().printStackTrace(); |
---|
| 8447 | + } else |
---|
| 8448 | + { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
8130 | 8456 | } else |
---|
8131 | 8457 | { |
---|
8132 | 8458 | if (textureon) |
---|
.. | .. |
---|
8151 | 8477 | } |
---|
8152 | 8478 | |
---|
8153 | 8479 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8154 | | - if (!new File(cachename).exists()) |
---|
| 8480 | + if (!FileExists(cachename)) |
---|
8155 | 8481 | cachename = texname; |
---|
8156 | 8482 | else |
---|
8157 | 8483 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8173 | 8499 | } |
---|
8174 | 8500 | |
---|
8175 | 8501 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8176 | | - if (!new File(cachename).exists()) |
---|
| 8502 | + if (!FileExists(cachename)) |
---|
8177 | 8503 | cachename = texname; |
---|
8178 | 8504 | else |
---|
8179 | 8505 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8182 | 8508 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8183 | 8509 | |
---|
8184 | 8510 | |
---|
8185 | | - if (texturedata != null) |
---|
8186 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8511 | + if (texturedata == null) |
---|
| 8512 | + throw new Exception(); |
---|
| 8513 | + |
---|
| 8514 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8187 | 8515 | //texture = GetTexture(tex, bump); |
---|
8188 | 8516 | } |
---|
| 8517 | + } |
---|
8189 | 8518 | } |
---|
8190 | 8519 | //} |
---|
8191 | 8520 | } |
---|
8192 | 8521 | |
---|
8193 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8194 | 8523 | { |
---|
8195 | 8524 | //return false; |
---|
8196 | 8525 | |
---|
8197 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8198 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8527 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8199 | 8528 | { |
---|
8200 | 8529 | // String ext = "_highres"; |
---|
8201 | 8530 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8212 | 8541 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8213 | 8542 | if (!cachefile.exists()) |
---|
8214 | 8543 | { |
---|
8215 | | - // cache to disk |
---|
8216 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8217 | | - //buffers[0]. |
---|
8218 | | - |
---|
8219 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8220 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8221 | | - |
---|
8222 | | - // squared size heuristic... |
---|
8223 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8544 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8224 | 8545 | { |
---|
8225 | | - for (int i=pixels.length; --i>=0;) |
---|
8226 | | - { |
---|
8227 | | - int i3 = i*3; |
---|
8228 | | - pixels[i] = 0xFF; |
---|
8229 | | - pixels[i] <<= 8; |
---|
8230 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8231 | | - pixels[i] <<= 8; |
---|
8232 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8233 | | - pixels[i] <<= 8; |
---|
8234 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8235 | | - } |
---|
8236 | | - |
---|
8237 | | - /* |
---|
8238 | | - int r=0,g=0,b=0,a=0; |
---|
8239 | | - for (int i=0; i<width; i++) |
---|
8240 | | - for (int j=0; j<height; j++) |
---|
8241 | | - { |
---|
8242 | | - int index = j*width+i; |
---|
8243 | | - int p = pixels[index]; |
---|
8244 | | - a = ((p>>24) & 0xFF); |
---|
8245 | | - r = ((p>>16) & 0xFF); |
---|
8246 | | - g = ((p>>8) & 0xFF); |
---|
8247 | | - b = (p & 0xFF); |
---|
8248 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8249 | | - } |
---|
8250 | | - /**/ |
---|
8251 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8252 | | - int height = width; |
---|
8253 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8254 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8546 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8547 | + |
---|
8255 | 8548 | ImageWriter writer = null; |
---|
8256 | 8549 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8257 | 8550 | if (iter.hasNext()) { |
---|
8258 | 8551 | writer = (ImageWriter)iter.next(); |
---|
8259 | 8552 | } |
---|
8260 | | - float compressionQuality = 0.9f; |
---|
| 8553 | + |
---|
| 8554 | + float compressionQuality = 0.85f; |
---|
8261 | 8555 | try |
---|
8262 | 8556 | { |
---|
8263 | 8557 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8274 | 8568 | } |
---|
8275 | 8569 | } |
---|
8276 | 8570 | } |
---|
8277 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
8278 | 8574 | //System.out.println("Texture = " + tex); |
---|
8279 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
8280 | 8576 | { |
---|
8281 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
8282 | 8578 | thetex.texture.disable(); |
---|
8283 | 8579 | thetex.texture.dispose(); |
---|
8284 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
8285 | 8581 | } |
---|
8286 | 8582 | |
---|
8287 | | - texture.texturedata = texturedata; |
---|
8288 | | - textures.put(texname, texture); |
---|
| 8583 | + //texture.texturedata = texturedata; |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
8289 | 8585 | |
---|
8290 | 8586 | // newtex = true; |
---|
8291 | 8587 | } |
---|
.. | .. |
---|
8301 | 8597 | } |
---|
8302 | 8598 | } |
---|
8303 | 8599 | |
---|
8304 | | - return texture; |
---|
| 8600 | + return texturecache; |
---|
8305 | 8601 | } |
---|
8306 | 8602 | |
---|
8307 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8603 | + static void EmbedTextures(cTexture tex) |
---|
| 8604 | + { |
---|
| 8605 | + if (tex.pigmentdata == null) |
---|
| 8606 | + { |
---|
| 8607 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8608 | + |
---|
| 8609 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8610 | + |
---|
| 8611 | + if (texturecache != null) |
---|
| 8612 | + { |
---|
| 8613 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8614 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8615 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8616 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8617 | + ; |
---|
| 8618 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + if (tex.bumpdata == null) |
---|
| 8623 | + { |
---|
| 8624 | + //String texname = Object3D.GetBump(tex); |
---|
| 8625 | + |
---|
| 8626 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8627 | + |
---|
| 8628 | + if (texturecache != null) |
---|
| 8629 | + { |
---|
| 8630 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8631 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8632 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8633 | + } |
---|
| 8634 | + } |
---|
| 8635 | + } |
---|
| 8636 | + |
---|
| 8637 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8308 | 8638 | { |
---|
8309 | 8639 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8310 | 8640 | |
---|
.. | .. |
---|
8322 | 8652 | return texture!=null?texture.texture:null; |
---|
8323 | 8653 | } |
---|
8324 | 8654 | |
---|
8325 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8655 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8326 | 8656 | { |
---|
8327 | 8657 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8328 | 8658 | |
---|
8329 | 8659 | return texture!=null?texture.texturedata:null; |
---|
8330 | 8660 | } |
---|
8331 | 8661 | |
---|
8332 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8333 | 8663 | { |
---|
8334 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8335 | 8665 | { |
---|
8336 | 8666 | return false; |
---|
8337 | 8667 | } |
---|
8338 | 8668 | |
---|
8339 | | - boolean newtex = false; |
---|
| 8669 | + //boolean newtex = false; |
---|
8340 | 8670 | |
---|
8341 | 8671 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8342 | 8672 | |
---|
.. | .. |
---|
8368 | 8698 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8369 | 8699 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8370 | 8700 | |
---|
8371 | | - return newtex; |
---|
| 8701 | + return true; // Warning: not used. |
---|
8372 | 8702 | } |
---|
8373 | 8703 | |
---|
| 8704 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8705 | + { |
---|
| 8706 | + try |
---|
| 8707 | + { |
---|
| 8708 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8709 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8710 | + ImageWriter writer = writers.next(); |
---|
| 8711 | + |
---|
| 8712 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8713 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8714 | + param.setCompressionQuality(quality); |
---|
| 8715 | + |
---|
| 8716 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8717 | + writer.setOutput(ios); |
---|
| 8718 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8719 | + |
---|
| 8720 | + byte[] data = baos.toByteArray(); |
---|
| 8721 | + writer.dispose(); |
---|
| 8722 | + return data; |
---|
| 8723 | + } |
---|
| 8724 | + catch (Exception e) |
---|
| 8725 | + { |
---|
| 8726 | + e.printStackTrace(); |
---|
| 8727 | + return null; |
---|
| 8728 | + } |
---|
| 8729 | + } |
---|
| 8730 | + |
---|
| 8731 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8732 | + { |
---|
| 8733 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8734 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8735 | + ImageReader reader = writers.next(); |
---|
| 8736 | + |
---|
| 8737 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8738 | + |
---|
| 8739 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8740 | + param.setDestination(bim); |
---|
| 8741 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8742 | + |
---|
| 8743 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8744 | + reader.setInput(ios); |
---|
| 8745 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8746 | + reader.dispose(); |
---|
| 8747 | + |
---|
| 8748 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8749 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8750 | +// byte[] bytes = data.getData(); |
---|
| 8751 | +// |
---|
| 8752 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8753 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8754 | +// { |
---|
| 8755 | +// int i3 = i*3; |
---|
| 8756 | +// pixels[i] = 0xFF; |
---|
| 8757 | +// pixels[i] <<= 8; |
---|
| 8758 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8759 | +// pixels[i] <<= 8; |
---|
| 8760 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8761 | +// pixels[i] <<= 8; |
---|
| 8762 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8763 | +// } |
---|
| 8764 | +// |
---|
| 8765 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8766 | + |
---|
| 8767 | + return bim; |
---|
| 8768 | + } |
---|
| 8769 | + |
---|
8374 | 8770 | ShadowBuffer shadowPBuf; |
---|
8375 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
8376 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
8387 | 8783 | |
---|
8388 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8389 | 8785 | MAXSTACK = temp[0]; |
---|
8390 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8391 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8392 | 8789 | MAXSTACK = temp[0]; |
---|
8393 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8394 | 8792 | |
---|
8395 | 8793 | // Use debug pipeline |
---|
8396 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8398 | 8796 | gl = drawable.getGL(); // |
---|
8399 | 8797 | |
---|
8400 | 8798 | GL gl3 = getGL(); |
---|
8401 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8402 | 8801 | |
---|
8403 | 8802 | |
---|
8404 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8563 | 8962 | |
---|
8564 | 8963 | if (cubemap == null) |
---|
8565 | 8964 | { |
---|
8566 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
8567 | 8966 | } |
---|
8568 | 8967 | |
---|
8569 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
8839 | 9238 | |
---|
8840 | 9239 | void LoadEnvy(int which) |
---|
8841 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
8842 | 9243 | String name; |
---|
8843 | 9244 | String ext; |
---|
8844 | 9245 | |
---|
.. | .. |
---|
8850 | 9251 | cubemap = null; |
---|
8851 | 9252 | return; |
---|
8852 | 9253 | case 1: |
---|
8853 | | - name = "cubemaps/box_"; |
---|
8854 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
8855 | 9256 | reverseUP = false; |
---|
8856 | 9257 | break; |
---|
8857 | 9258 | case 2: |
---|
8858 | | - name = "cubemaps/uffizi_"; |
---|
8859 | | - ext = "png"; |
---|
8860 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
8861 | 9263 | case 3: |
---|
8862 | | - name = "cubemaps/CloudyHills_"; |
---|
8863 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
8864 | 9266 | reverseUP = false; |
---|
8865 | 9267 | break; |
---|
8866 | 9268 | case 4: |
---|
8867 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
8868 | 9270 | ext = "png"; |
---|
8869 | 9271 | reverseUP = false; |
---|
8870 | 9272 | break; |
---|
| 9273 | + case 5: |
---|
| 9274 | + name = "cubemaps/skycube/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 6: |
---|
| 9279 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 7: |
---|
| 9284 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
| 9288 | + case 8: |
---|
| 9289 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9290 | + ext = "jpg"; |
---|
| 9291 | + reverseUP = false; |
---|
| 9292 | + break; |
---|
| 9293 | + case 9: |
---|
| 9294 | + name = "cubemaps/UnionSquare/"; |
---|
| 9295 | + ext = "jpg"; |
---|
| 9296 | + reverseUP = false; |
---|
| 9297 | + break; |
---|
8871 | 9298 | default: |
---|
8872 | | - name = "cubemaps/rgb_"; |
---|
8873 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
8874 | 9302 | break; |
---|
8875 | 9303 | } |
---|
8876 | | - |
---|
8877 | | - try |
---|
8878 | | - { |
---|
8879 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8880 | | - } catch (IOException e) |
---|
8881 | | - { |
---|
8882 | | - throw new RuntimeException(e); |
---|
8883 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
8884 | 9306 | } |
---|
8885 | 9307 | |
---|
8886 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8912 | 9334 | static double[] model = new double[16]; |
---|
8913 | 9335 | double[] camera2light = new double[16]; |
---|
8914 | 9336 | double[] light2camera = new double[16]; |
---|
8915 | | - int newenvy = -1; |
---|
8916 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
8917 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8918 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
8919 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9206 | 9632 | jy8[3] = 0.5f; |
---|
9207 | 9633 | } |
---|
9208 | 9634 | |
---|
9209 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9635 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9210 | 9636 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9211 | 9637 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9212 | 9638 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9213 | 9639 | |
---|
| 9640 | + void ResetOptions() |
---|
| 9641 | + { |
---|
| 9642 | + options1[0] = 100; |
---|
| 9643 | + options1[1] = 0.025f; |
---|
| 9644 | + options1[2] = 0.01f; |
---|
| 9645 | + options1[3] = 0; |
---|
| 9646 | + options1[4] = 0; |
---|
| 9647 | + |
---|
| 9648 | + options2[0] = 0; |
---|
| 9649 | + options2[1] = 0.75f; |
---|
| 9650 | + options2[2] = 0; |
---|
| 9651 | + options2[3] = 0; |
---|
| 9652 | + |
---|
| 9653 | + options3[0] = 1; |
---|
| 9654 | + options3[1] = 1; |
---|
| 9655 | + options3[2] = 1; |
---|
| 9656 | + options3[3] = 0; |
---|
| 9657 | + |
---|
| 9658 | + options4[0] = 1; |
---|
| 9659 | + options4[1] = 0; |
---|
| 9660 | + options4[2] = 1; |
---|
| 9661 | + options4[3] = 0; |
---|
| 9662 | + } |
---|
| 9663 | + |
---|
9214 | 9664 | static int imagecount = 0; // movie generation |
---|
9215 | 9665 | |
---|
9216 | 9666 | static int jitter = 0; |
---|
.. | .. |
---|
9306 | 9756 | assert (parentcam != renderCamera); |
---|
9307 | 9757 | |
---|
9308 | 9758 | if (renderCamera != lightCamera) |
---|
9309 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9310 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9759 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9311 | 9761 | |
---|
9312 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9313 | 9763 | |
---|
.. | .. |
---|
9322 | 9772 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9323 | 9773 | |
---|
9324 | 9774 | if (renderCamera != lightCamera) |
---|
9325 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9326 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9775 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9327 | 9777 | |
---|
9328 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9329 | 9779 | |
---|
.. | .. |
---|
9369 | 9819 | rati = 1 / rati; |
---|
9370 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9371 | 9821 | } |
---|
9372 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
9373 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9374 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9375 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
9376 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9377 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9378 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
9395 | 9847 | //gl.glFlush(); |
---|
9396 | 9848 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9397 | 9849 | |
---|
9398 | | - if (ANIMATION && ABORTED) |
---|
| 9850 | + if (Globals.ANIMATION && ABORTED) |
---|
9399 | 9851 | { |
---|
9400 | 9852 | System.err.println(" ABORTED FRAME"); |
---|
9401 | 9853 | break; |
---|
.. | .. |
---|
9425 | 9877 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9426 | 9878 | |
---|
9427 | 9879 | // save image |
---|
9428 | | - if (ANIMATION && !ABORTED) |
---|
| 9880 | + if (Globals.ANIMATION && !ABORTED) |
---|
9429 | 9881 | { |
---|
9430 | 9882 | VPwidth = viewport[2]; |
---|
9431 | 9883 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9536 | 9988 | |
---|
9537 | 9989 | // imagecount++; |
---|
9538 | 9990 | |
---|
9539 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9991 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
9540 | 9992 | |
---|
9541 | 9993 | if (!BOXMODE) |
---|
9542 | 9994 | { |
---|
9543 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9995 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9544 | 9996 | } |
---|
9545 | 9997 | |
---|
9546 | 9998 | if (!BOXMODE) |
---|
.. | .. |
---|
9578 | 10030 | ABORTED = false; |
---|
9579 | 10031 | } |
---|
9580 | 10032 | else |
---|
9581 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10033 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9582 | 10034 | |
---|
9583 | 10035 | if (false) |
---|
9584 | 10036 | { |
---|
.. | .. |
---|
10241 | 10693 | |
---|
10242 | 10694 | public void display(GLAutoDrawable drawable) |
---|
10243 | 10695 | { |
---|
10244 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10696 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
10245 | 10697 | { |
---|
10246 | | - GrafreeD.wav.save(); |
---|
10247 | | - GrafreeD.savesound = false; |
---|
10248 | | - GrafreeD.hassound = false; |
---|
| 10698 | + Grafreed.wav.save(); |
---|
| 10699 | + Grafreed.savesound = false; |
---|
| 10700 | + Grafreed.hassound = false; |
---|
10249 | 10701 | } |
---|
10250 | 10702 | // if (DEBUG_SELECTION) |
---|
10251 | 10703 | // { |
---|
.. | .. |
---|
10321 | 10773 | ANTIALIAS = 0; |
---|
10322 | 10774 | //System.out.println("RESTART"); |
---|
10323 | 10775 | AAtimer.restart(); |
---|
| 10776 | + Globals.TIMERRUNNING = true; |
---|
10324 | 10777 | } |
---|
10325 | 10778 | } |
---|
10326 | 10779 | } |
---|
.. | .. |
---|
10375 | 10828 | Object3D theobject = object; |
---|
10376 | 10829 | Object3D theparent = object.parent; |
---|
10377 | 10830 | object.parent = null; |
---|
10378 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10831 | + object = (Object3D)Grafreed.clone(object); |
---|
10379 | 10832 | object.Stripify(); |
---|
10380 | 10833 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10381 | 10834 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10388 | 10841 | ambientOcclusion = false; |
---|
10389 | 10842 | } |
---|
10390 | 10843 | |
---|
10391 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10844 | + if (//Globals.lighttouched && |
---|
| 10845 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10392 | 10846 | { |
---|
10393 | 10847 | //if (RENDERSHADOW) // ? |
---|
10394 | 10848 | if (!IsFrozen()) |
---|
10395 | 10849 | { |
---|
10396 | 10850 | // dec 2012 |
---|
10397 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10851 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10398 | 10852 | { |
---|
10399 | 10853 | Globals.framecount++; |
---|
10400 | 10854 | shadowbuffer.display(); |
---|
.. | .. |
---|
10407 | 10861 | |
---|
10408 | 10862 | if (wait) |
---|
10409 | 10863 | { |
---|
10410 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
10411 | 10865 | |
---|
10412 | 10866 | wait = false; |
---|
10413 | 10867 | } |
---|
.. | .. |
---|
10521 | 10975 | |
---|
10522 | 10976 | // if (parentcam != renderCamera) // not a light |
---|
10523 | 10977 | if (cam != lightCamera) |
---|
10524 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10525 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10978 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10979 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10526 | 10980 | |
---|
10527 | 10981 | for (int j = 0; j < 4; j++) |
---|
10528 | 10982 | { |
---|
.. | .. |
---|
10536 | 10990 | |
---|
10537 | 10991 | // if (parentcam != renderCamera) // not a light |
---|
10538 | 10992 | if (cam != lightCamera) |
---|
10539 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10540 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10993 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10994 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10541 | 10995 | |
---|
10542 | 10996 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10543 | 10997 | |
---|
.. | .. |
---|
10623 | 11077 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10624 | 11078 | } |
---|
10625 | 11079 | |
---|
10626 | | - if (newenvy > -1) |
---|
| 11080 | +// if (newenvy > -1) |
---|
| 11081 | +// { |
---|
| 11082 | +// LoadEnvy(newenvy); |
---|
| 11083 | +// } |
---|
| 11084 | +// |
---|
| 11085 | +// newenvy = -1; |
---|
| 11086 | + |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10627 | 11088 | { |
---|
10628 | | - LoadEnvy(newenvy); |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
10629 | 11095 | } |
---|
10630 | | - |
---|
10631 | | - newenvy = -1; |
---|
10632 | | - |
---|
| 11096 | + else |
---|
| 11097 | + { |
---|
| 11098 | + if (object.skyboxname != null) |
---|
| 11099 | + { |
---|
| 11100 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11101 | + { |
---|
| 11102 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11103 | + cubemap.dispose(); |
---|
| 11104 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11105 | + loadedskyboxname = object.skyboxname; |
---|
| 11106 | + } |
---|
| 11107 | + } |
---|
| 11108 | + else |
---|
| 11109 | + { |
---|
| 11110 | + cubemapcustom = null; |
---|
| 11111 | + loadedskyboxname = null; |
---|
| 11112 | + } |
---|
| 11113 | + |
---|
| 11114 | + cubemap = cubemapcustom; |
---|
| 11115 | + } |
---|
| 11116 | + |
---|
10633 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
10634 | 11118 | //System.out.println("ratio = " + ratio); |
---|
10635 | 11119 | |
---|
.. | .. |
---|
10645 | 11129 | |
---|
10646 | 11130 | if (!IsFrozen() && !ambientOcclusion) |
---|
10647 | 11131 | { |
---|
10648 | | - DrawSkyBox(gl); |
---|
| 11132 | + DrawSkyBox(gl, (float)ratio); |
---|
10649 | 11133 | } |
---|
10650 | 11134 | |
---|
10651 | 11135 | //if (selection_view == -1) |
---|
.. | .. |
---|
10796 | 11280 | // Bump noise |
---|
10797 | 11281 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10798 | 11282 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10799 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11283 | + |
---|
| 11284 | + try |
---|
| 11285 | + { |
---|
| 11286 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11287 | + } |
---|
| 11288 | + catch (Exception e) |
---|
| 11289 | + { |
---|
| 11290 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11291 | + } |
---|
| 11292 | + |
---|
10800 | 11293 | |
---|
10801 | 11294 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10802 | 11295 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10819 | 11312 | |
---|
10820 | 11313 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10821 | 11314 | |
---|
10822 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10823 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10824 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11315 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11316 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11317 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10825 | 11318 | } else |
---|
10826 | 11319 | { |
---|
10827 | 11320 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10832 | 11325 | //System.out.println("BLENDING ON"); |
---|
10833 | 11326 | gl.glEnable(GL.GL_BLEND); |
---|
10834 | 11327 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10835 | | - |
---|
| 11328 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10836 | 11329 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10837 | 11330 | gl.glLoadIdentity(); |
---|
10838 | 11331 | |
---|
.. | .. |
---|
10921 | 11414 | System.err.println("parentcam != renderCamera"); |
---|
10922 | 11415 | |
---|
10923 | 11416 | // if (cam != lightCamera) |
---|
10924 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10925 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11417 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10926 | 11419 | } |
---|
10927 | 11420 | |
---|
10928 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10943 | 11436 | if (true) // TODO |
---|
10944 | 11437 | { |
---|
10945 | 11438 | if (cam != lightCamera) |
---|
10946 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10947 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11439 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11440 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10948 | 11441 | } |
---|
10949 | 11442 | |
---|
10950 | 11443 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11081 | 11574 | } |
---|
11082 | 11575 | } |
---|
11083 | 11576 | |
---|
11084 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11577 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11085 | 11578 | { |
---|
11086 | 11579 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11087 | 11580 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11089 | 11582 | |
---|
11090 | 11583 | boolean texon = textureon; |
---|
11091 | 11584 | |
---|
11092 | | - if (RENDERPROGRAM > 0) |
---|
11093 | | - { |
---|
11094 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11095 | | - textureon = false; |
---|
11096 | | - } |
---|
| 11585 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11586 | + textureon = false; |
---|
| 11587 | + |
---|
11097 | 11588 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11098 | 11589 | //System.out.println("ALLO"); |
---|
11099 | 11590 | gl.glColorMask(false, false, false, false); |
---|
11100 | 11591 | DrawObject(gl); |
---|
11101 | | - if (RENDERPROGRAM > 0) |
---|
11102 | | - { |
---|
11103 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11104 | | - textureon = texon; |
---|
11105 | | - } |
---|
| 11592 | + |
---|
| 11593 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11594 | + textureon = texon; |
---|
| 11595 | + |
---|
11106 | 11596 | gl.glColorMask(true, true, true, true); |
---|
11107 | 11597 | |
---|
11108 | 11598 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11109 | | - //gl.glDepthMask(false); |
---|
| 11599 | + gl.glDepthMask(false); |
---|
11110 | 11600 | } |
---|
11111 | 11601 | |
---|
11112 | 11602 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11260 | 11750 | { |
---|
11261 | 11751 | renderpass++; |
---|
11262 | 11752 | // System.out.println("Draw object... "); |
---|
| 11753 | + STEP = 1; |
---|
11263 | 11754 | if (FAST) // in case there is no script |
---|
11264 | | - STEP = 16; |
---|
| 11755 | + STEP = 8; |
---|
| 11756 | + |
---|
| 11757 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11758 | + { |
---|
| 11759 | + STEP *= 4; |
---|
| 11760 | + } |
---|
11265 | 11761 | |
---|
11266 | 11762 | //object.FullInvariants(); |
---|
11267 | 11763 | |
---|
.. | .. |
---|
11275 | 11771 | e.printStackTrace(); |
---|
11276 | 11772 | } |
---|
11277 | 11773 | |
---|
11278 | | - if (GrafreeD.RENDERME > 0) |
---|
11279 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11774 | + if (Grafreed.RENDERME > 0) |
---|
| 11775 | + Grafreed.RENDERME--; // mechante magouille |
---|
11280 | 11776 | |
---|
11281 | 11777 | Globals.ONESTEP = false; |
---|
11282 | 11778 | } |
---|
11283 | 11779 | |
---|
11284 | 11780 | static boolean zoomonce = false; |
---|
11285 | 11781 | |
---|
| 11782 | + static void CreateSelectedPoint() |
---|
| 11783 | + { |
---|
| 11784 | + if (selectedpoint == null) |
---|
| 11785 | + { |
---|
| 11786 | + debugpointG = new Sphere(); |
---|
| 11787 | + debugpointP = new Sphere(); |
---|
| 11788 | + debugpointC = new Sphere(); |
---|
| 11789 | + debugpointR = new Sphere(); |
---|
| 11790 | + |
---|
| 11791 | + selectedpoint = new Superellipsoid(); |
---|
| 11792 | + |
---|
| 11793 | + for (int i=0; i<8; i++) |
---|
| 11794 | + { |
---|
| 11795 | + debugpoints[i] = new Sphere(); |
---|
| 11796 | + } |
---|
| 11797 | + } |
---|
| 11798 | + } |
---|
| 11799 | + |
---|
11286 | 11800 | void DrawObject(GL gl, boolean draw) |
---|
11287 | 11801 | { |
---|
| 11802 | + // To clear camera values |
---|
| 11803 | + ResetOptions(); |
---|
| 11804 | + |
---|
11288 | 11805 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11289 | 11806 | // DrawMode() = SELECTION; |
---|
11290 | 11807 | //GL gl = getGL(); |
---|
11291 | 11808 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11292 | 11809 | { |
---|
11293 | 11810 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11294 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11811 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11295 | 11812 | pingthread.StepToTarget(true); // true); |
---|
11296 | 11813 | // zoomonce = false; |
---|
11297 | 11814 | } |
---|
.. | .. |
---|
11346 | 11863 | |
---|
11347 | 11864 | usedtextures.clear(); |
---|
11348 | 11865 | |
---|
11349 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11866 | + try |
---|
| 11867 | + { |
---|
| 11868 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11869 | + } |
---|
| 11870 | + catch (Exception e) |
---|
| 11871 | + { |
---|
| 11872 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11873 | + } |
---|
11350 | 11874 | } |
---|
11351 | 11875 | //System.out.println("--> " + stackdepth); |
---|
11352 | 11876 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11356 | 11880 | |
---|
11357 | 11881 | if (DrawMode() == DEFAULT) |
---|
11358 | 11882 | { |
---|
11359 | | - if (DEBUG) |
---|
| 11883 | + if (Globals.DEBUG) |
---|
11360 | 11884 | { |
---|
| 11885 | + CreateSelectedPoint(); |
---|
11361 | 11886 | float radius = 0.05f; |
---|
11362 | 11887 | if (selectedpoint.radius != radius) |
---|
11363 | 11888 | { |
---|
.. | .. |
---|
11411 | 11936 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11412 | 11937 | |
---|
11413 | 11938 | if (CLEANCACHE) |
---|
11414 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11939 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11415 | 11940 | { |
---|
11416 | | - String tex = e.nextElement(); |
---|
| 11941 | + cTexture tex = e.nextElement(); |
---|
11417 | 11942 | |
---|
11418 | 11943 | // System.out.println("Texture --------- " + tex); |
---|
11419 | 11944 | |
---|
11420 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11945 | + if (tex.equals("WHITE_NOISE:")) |
---|
11421 | 11946 | continue; |
---|
11422 | 11947 | |
---|
11423 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11948 | + if (!usedtextures.contains(tex)) |
---|
11424 | 11949 | { |
---|
| 11950 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11425 | 11951 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11426 | | - textures.get(tex).texture.dispose(); |
---|
11427 | | - textures.remove(tex); |
---|
| 11952 | + if (gettex != null) |
---|
| 11953 | + { |
---|
| 11954 | + gettex.texture.dispose(); |
---|
| 11955 | + texturepigment.remove(tex); |
---|
| 11956 | + } |
---|
| 11957 | + |
---|
| 11958 | + gettex = texturebump.get(tex); |
---|
| 11959 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11960 | + if (gettex != null) |
---|
| 11961 | + { |
---|
| 11962 | + gettex.texture.dispose(); |
---|
| 11963 | + texturebump.remove(tex); |
---|
| 11964 | + } |
---|
11428 | 11965 | } |
---|
11429 | 11966 | } |
---|
11430 | 11967 | } |
---|
.. | .. |
---|
11437 | 11974 | if (checker != null && DrawMode() == DEFAULT) |
---|
11438 | 11975 | { |
---|
11439 | 11976 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11440 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11977 | + try |
---|
| 11978 | + { |
---|
| 11979 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11980 | + } |
---|
| 11981 | + catch (Exception e) |
---|
| 11982 | + { |
---|
| 11983 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11984 | + } |
---|
11441 | 11985 | // NEAREST |
---|
11442 | 11986 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11443 | 11987 | DrawChecker(gl); |
---|
.. | .. |
---|
11519 | 12063 | return; |
---|
11520 | 12064 | } |
---|
11521 | 12065 | |
---|
11522 | | - String string = obj.GetToolTip(); |
---|
| 12066 | + String string = obj.toString(); //.GetToolTip(); |
---|
11523 | 12067 | |
---|
11524 | 12068 | GL gl = GetGL(); |
---|
11525 | 12069 | |
---|
.. | .. |
---|
11836 | 12380 | //obj.TransformToWorld(light, light); |
---|
11837 | 12381 | for (int i = tp.size(); --i >= 0;) |
---|
11838 | 12382 | { |
---|
11839 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11840 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12383 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12384 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11841 | 12385 | } |
---|
11842 | 12386 | |
---|
11843 | 12387 | |
---|
.. | .. |
---|
11854 | 12398 | parentcam = cameras[0]; |
---|
11855 | 12399 | } |
---|
11856 | 12400 | |
---|
11857 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11858 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12401 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12402 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11859 | 12403 | |
---|
11860 | 12404 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11861 | 12405 | |
---|
.. | .. |
---|
11945 | 12489 | |
---|
11946 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11947 | 12491 | |
---|
11948 | | - String program = |
---|
| 12492 | + String programmin = |
---|
| 12493 | + // Min shader |
---|
11949 | 12494 | "!!ARBfp1.0\n" + |
---|
| 12495 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12496 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12497 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12498 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12499 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12500 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12501 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12502 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12503 | + "TEMP temp;" + |
---|
| 12504 | + "TEMP light;" + |
---|
| 12505 | + "TEMP ndotl;" + |
---|
| 12506 | + "TEMP normal;" + |
---|
| 12507 | + "TEMP depth;" + |
---|
| 12508 | + "TEMP eye;" + |
---|
| 12509 | + "TEMP pos;" + |
---|
| 12510 | + |
---|
| 12511 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12512 | + Normalize("normal") + |
---|
| 12513 | + "MOV light, state.light[0].position;" + |
---|
| 12514 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12515 | + |
---|
| 12516 | + // shadow |
---|
| 12517 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12518 | + "MOV temp, pos;" + |
---|
| 12519 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12520 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12521 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12522 | + |
---|
| 12523 | + // No shadow when out of frustum |
---|
| 12524 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12525 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12526 | + |
---|
| 12527 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12528 | + |
---|
| 12529 | + // Backlit |
---|
| 12530 | + "MOV pos.w, zero123.y;" + |
---|
| 12531 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12532 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12533 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12534 | + Normalize("eye") + |
---|
| 12535 | + |
---|
| 12536 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12537 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12538 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12539 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12540 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12541 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12542 | + |
---|
| 12543 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12544 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12545 | + |
---|
| 12546 | + // Pigment |
---|
| 12547 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12548 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12549 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL temp, temp, zero123.z;" + |
---|
| 12552 | + |
---|
| 12553 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12554 | + |
---|
| 12555 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12556 | + "MOV result.color, temp;" + |
---|
| 12557 | + "END"; |
---|
| 12558 | + |
---|
| 12559 | + String programmax = |
---|
| 12560 | + "!!ARBfp1.0\n" + |
---|
| 12561 | + |
---|
11950 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11951 | 12563 | "PARAM light2cam0 = program.env[10];" + |
---|
11952 | 12564 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12061 | 12673 | "TEMP shininess;" + |
---|
12062 | 12674 | "\n" + |
---|
12063 | 12675 | "MOV texSamp, one;" + |
---|
12064 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12065 | | - |
---|
| 12676 | + |
---|
12066 | 12677 | "MOV mapgrid.x, one2048th.x;" + |
---|
12067 | 12678 | "MOV temp, fragment.texcoord[1];" + |
---|
12068 | 12679 | /* |
---|
.. | .. |
---|
12083 | 12694 | "MUL temp, floor, mapgrid.x;" + |
---|
12084 | 12695 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12085 | 12696 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12086 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12697 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12087 | 12698 | "") + |
---|
12088 | 12699 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12089 | 12700 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12090 | 12701 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12091 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12092 | 12703 | "") + |
---|
12093 | 12704 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12094 | 12705 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12095 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12096 | 12707 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12097 | 12708 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12098 | 12709 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12099 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12710 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12100 | 12711 | "") + |
---|
12101 | 12712 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12102 | 12713 | //"MOV params, material;" + |
---|
.. | .. |
---|
12467 | 13078 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12468 | 13079 | "") + |
---|
12469 | 13080 | |
---|
12470 | | - // display shadow only (bump == 0) |
---|
| 13081 | + // display shadow only (fakedepth == 0) |
---|
12471 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
12472 | | - "MOV temp.y, -params6.x;" + |
---|
12473 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13083 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12474 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
12475 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
12476 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
12599 | 13210 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12600 | 13211 | |
---|
12601 | 13212 | "SUB temp.x, one.x, ndotl.x;" + |
---|
12602 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
12603 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13213 | + // Tuning for default skin |
---|
| 13214 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13215 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13216 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12604 | 13217 | "MUL temp.x, temp.x, temp.y;" + |
---|
12605 | 13218 | |
---|
12606 | 13219 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12748 | 13361 | "MUL final.y, fragment.texcoord[0].x, c256;" + |
---|
12749 | 13362 | "FLR final.x, final.y;" + |
---|
12750 | 13363 | "SUB final.y, final.y, final.x;" + |
---|
12751 | | - //"MUL final.x, final.x, c256i;" + |
---|
| 13364 | + "MUL final.x, final.x, c256i;" + |
---|
12752 | 13365 | "MOV final.z, zero.x;" + |
---|
12753 | 13366 | "MOV final.a, one.w;":"" |
---|
12754 | 13367 | ) + |
---|
.. | .. |
---|
12756 | 13369 | "MUL final.y, fragment.texcoord[0].y, c256;" + |
---|
12757 | 13370 | "FLR final.x, final.y;" + |
---|
12758 | 13371 | "SUB final.y, final.y, final.x;" + |
---|
12759 | | - //"MUL final.x, final.x, c256i;" + |
---|
| 13372 | + "MUL final.x, final.x, c256i;" + |
---|
12760 | 13373 | "MOV final.z, zero.x;" + |
---|
12761 | 13374 | "MOV final.a, one.w;":"" |
---|
12762 | 13375 | ) + |
---|
.. | .. |
---|
12799 | 13412 | //once = true; |
---|
12800 | 13413 | } |
---|
12801 | 13414 | |
---|
12802 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
12803 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
| 13422 | + if (Globals.DEBUG) |
---|
| 13423 | + { |
---|
| 13424 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13425 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13426 | + } |
---|
| 13427 | + |
---|
12804 | 13428 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12805 | 13429 | |
---|
12806 | 13430 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12847 | 13471 | "\n" + |
---|
12848 | 13472 | "END\n"; |
---|
12849 | 13473 | |
---|
12850 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13474 | + if (Globals.DEBUG) |
---|
| 13475 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
12851 | 13476 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12852 | 13477 | |
---|
12853 | 13478 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12892 | 13517 | return out; |
---|
12893 | 13518 | } |
---|
12894 | 13519 | |
---|
12895 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13520 | + // Also does frustum culling |
---|
| 13521 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12896 | 13522 | { |
---|
12897 | 13523 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12898 | 13524 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12899 | 13525 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13526 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13527 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12900 | 13528 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12901 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12902 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12903 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12904 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13529 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13530 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12905 | 13531 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12906 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13532 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12907 | 13533 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12908 | 13534 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12909 | 13535 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12910 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13536 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12911 | 13537 | |
---|
12912 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12913 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13538 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13539 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12914 | 13540 | } |
---|
12915 | 13541 | |
---|
12916 | 13542 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12932 | 13558 | |
---|
12933 | 13559 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12934 | 13560 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13561 | + |
---|
| 13562 | + // Compare fragment depth in light space with shadowmap. |
---|
12935 | 13563 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12936 | 13564 | "SGE temp.y, temp.x, zero.x;" + |
---|
12937 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13565 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13566 | + |
---|
| 13567 | + // Reverse comparison |
---|
12938 | 13568 | "SUB temp.x, one.x, temp.x;" + |
---|
12939 | 13569 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12940 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13570 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12941 | 13571 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12942 | 13572 | |
---|
12943 | 13573 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12951 | 13581 | // No shadow for backface |
---|
12952 | 13582 | "DP3 temp.x, normal, lightd;" + |
---|
12953 | 13583 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13584 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13585 | + |
---|
| 13586 | + // No shadow when out of frustum |
---|
| 13587 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12954 | 13588 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12955 | 13589 | ""; |
---|
12956 | 13590 | } |
---|
.. | .. |
---|
13097 | 13731 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13098 | 13732 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13099 | 13733 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13100 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13734 | + |
---|
| 13735 | + //Object3D.cVector2[] vector2buffer; |
---|
13101 | 13736 | |
---|
13102 | 13737 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13103 | 13738 | // OUT : diff, spec |
---|
.. | .. |
---|
13113 | 13748 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13114 | 13749 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13115 | 13750 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13116 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13117 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13118 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13751 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13752 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13753 | + |
---|
| 13754 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13119 | 13755 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13120 | 13756 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13121 | 13757 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13509 | 14145 | public void mousePressed(MouseEvent e) |
---|
13510 | 14146 | { |
---|
13511 | 14147 | //System.out.println("mousePressed: " + e); |
---|
13512 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14148 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13513 | 14149 | } |
---|
13514 | 14150 | |
---|
13515 | 14151 | static long prevtime = 0; |
---|
.. | .. |
---|
13585 | 14221 | // mode |= META; |
---|
13586 | 14222 | //} |
---|
13587 | 14223 | |
---|
13588 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13589 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14224 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14225 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13590 | 14226 | anchorX = ax; |
---|
13591 | 14227 | anchorY = ay; |
---|
13592 | 14228 | prevX = px; |
---|
.. | .. |
---|
13620 | 14256 | else |
---|
13621 | 14257 | if (evt.getSource() == AAtimer) |
---|
13622 | 14258 | { |
---|
| 14259 | + Globals.TIMERRUNNING = false; |
---|
13623 | 14260 | if (mouseDown) |
---|
13624 | 14261 | { |
---|
13625 | 14262 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13645 | 14282 | // LIVE = waslive; |
---|
13646 | 14283 | // wasliveok = true; |
---|
13647 | 14284 | // waslive = false; |
---|
| 14285 | + |
---|
| 14286 | + // May 2019 Forget it: |
---|
| 14287 | + if (true) |
---|
| 14288 | + return; |
---|
13648 | 14289 | |
---|
13649 | 14290 | // source == timer |
---|
13650 | 14291 | if (mouseDown) |
---|
.. | .. |
---|
13675 | 14316 | |
---|
13676 | 14317 | // fev 2014??? |
---|
13677 | 14318 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13678 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14319 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13679 | 14320 | pingthread.StepToTarget(true); // true); |
---|
13680 | 14321 | } |
---|
13681 | 14322 | // if (!LIVE) |
---|
.. | .. |
---|
13684 | 14325 | |
---|
13685 | 14326 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13686 | 14327 | |
---|
13687 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14328 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13688 | 14329 | { |
---|
13689 | 14330 | if (!wasliveok) |
---|
13690 | 14331 | return; |
---|
13691 | 14332 | |
---|
13692 | 14333 | AAtimer.restart(); // |
---|
| 14334 | + Globals.TIMERRUNNING = true; |
---|
13693 | 14335 | |
---|
13694 | 14336 | // waslive = LIVE; |
---|
13695 | 14337 | // LIVE = false; |
---|
.. | .. |
---|
13701 | 14343 | // touched = true; // main DL |
---|
13702 | 14344 | if (isRenderer) |
---|
13703 | 14345 | { |
---|
13704 | | - SetMouseMode(modifiers); |
---|
| 14346 | + SetMouseMode(modifiers, modifiersex); |
---|
13705 | 14347 | } |
---|
13706 | 14348 | |
---|
13707 | 14349 | selectX = anchorX = x; |
---|
.. | .. |
---|
13714 | 14356 | clicked = true; |
---|
13715 | 14357 | hold = false; |
---|
13716 | 14358 | |
---|
13717 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14359 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13718 | 14360 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13719 | 14361 | { |
---|
13720 | 14362 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13739 | 14381 | drag = false; |
---|
13740 | 14382 | //System.out.println("Mouse DOWN"); |
---|
13741 | 14383 | editObj = false; |
---|
13742 | | - ClickInfo info = new ClickInfo(); |
---|
13743 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13744 | | - info.pane = this; |
---|
13745 | | - info.camera = renderCamera; |
---|
13746 | | - info.x = x; |
---|
13747 | | - info.y = y; |
---|
13748 | | - info.modifiers = modifiers; |
---|
13749 | | - editObj = object.doEditClick(info, 0); |
---|
| 14384 | + //ClickInfo info = new ClickInfo(); |
---|
| 14385 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14386 | + object.clickInfo.pane = this; |
---|
| 14387 | + object.clickInfo.camera = renderCamera; |
---|
| 14388 | + object.clickInfo.x = x; |
---|
| 14389 | + object.clickInfo.y = y; |
---|
| 14390 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14391 | + editObj = object.doEditClick(//info, |
---|
| 14392 | + 0); |
---|
13750 | 14393 | if (!editObj) |
---|
13751 | 14394 | { |
---|
13752 | 14395 | hasMarquee = true; |
---|
.. | .. |
---|
13762 | 14405 | |
---|
13763 | 14406 | public void mouseDragged(MouseEvent e) |
---|
13764 | 14407 | { |
---|
| 14408 | + Globals.MOUSEDRAGGED = true; |
---|
| 14409 | + |
---|
13765 | 14410 | //System.out.println("mouseDragged: " + e); |
---|
13766 | 14411 | if (isRenderer) |
---|
13767 | 14412 | movingcamera = true; |
---|
| 14413 | + |
---|
13768 | 14414 | //if (drawing) |
---|
13769 | 14415 | //return; |
---|
13770 | 14416 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
13774 | 14420 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13775 | 14421 | } |
---|
13776 | 14422 | else |
---|
13777 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14423 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13778 | 14424 | |
---|
13779 | 14425 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13780 | 14426 | } |
---|
.. | .. |
---|
14011 | 14657 | { |
---|
14012 | 14658 | Globals.lighttouched = true; |
---|
14013 | 14659 | } |
---|
14014 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14660 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
14015 | 14661 | } |
---|
14016 | 14662 | //else |
---|
14017 | 14663 | } |
---|
.. | .. |
---|
14025 | 14671 | void GoDown(int mod) |
---|
14026 | 14672 | { |
---|
14027 | 14673 | MODIFIERS |= COMMAND; |
---|
14028 | | - /* |
---|
| 14674 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14675 | + /**/ |
---|
14029 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14030 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14677 | + { |
---|
| 14678 | + if (isVR) |
---|
| 14679 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14680 | + else |
---|
| 14681 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14682 | + } |
---|
14031 | 14683 | else |
---|
14032 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14033 | | - */ |
---|
| 14684 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14685 | + /**/ |
---|
14034 | 14686 | if ((mod & SHIFT) == SHIFT) |
---|
14035 | 14687 | { |
---|
14036 | 14688 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14039 | 14691 | mouseMode |= BACKFORTH; |
---|
14040 | 14692 | } |
---|
14041 | 14693 | |
---|
| 14694 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14695 | + |
---|
14042 | 14696 | //prevX = X = anchorX; |
---|
14043 | 14697 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14044 | 14698 | } |
---|
.. | .. |
---|
14046 | 14700 | void GoUp(int mod) |
---|
14047 | 14701 | { |
---|
14048 | 14702 | MODIFIERS |= COMMAND; |
---|
14049 | | - /* |
---|
| 14703 | + /**/ |
---|
| 14704 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14705 | + |
---|
14050 | 14706 | if((mod&SHIFT) == SHIFT) |
---|
14051 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14707 | + { |
---|
| 14708 | + if (isVR) |
---|
| 14709 | + manipCamera.RotateInterest(0, speed); |
---|
| 14710 | + else |
---|
| 14711 | + manipCamera.RotatePosition(0, speed); |
---|
| 14712 | + } |
---|
14052 | 14713 | else |
---|
14053 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14054 | | - */ |
---|
| 14714 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14715 | + /**/ |
---|
14055 | 14716 | if ((mod & SHIFT) == SHIFT) |
---|
14056 | 14717 | { |
---|
14057 | 14718 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14060 | 14721 | mouseMode |= BACKFORTH; |
---|
14061 | 14722 | } |
---|
14062 | 14723 | |
---|
| 14724 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14725 | + |
---|
14063 | 14726 | //prevX = X = anchorX; |
---|
14064 | 14727 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14065 | 14728 | } |
---|
.. | .. |
---|
14067 | 14730 | void GoLeft(int mod) |
---|
14068 | 14731 | { |
---|
14069 | 14732 | MODIFIERS |= COMMAND; |
---|
14070 | | - /* |
---|
| 14733 | + /**/ |
---|
14071 | 14734 | if((mod&SHIFT) == SHIFT) |
---|
14072 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14735 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14073 | 14736 | else |
---|
14074 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14075 | | - */ |
---|
| 14737 | + { |
---|
| 14738 | + if ((mouseMode&VR)!=0) |
---|
| 14739 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14740 | + else |
---|
| 14741 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14742 | + } |
---|
| 14743 | + /**/ |
---|
14076 | 14744 | if ((mod & SHIFT) == SHIFT) |
---|
14077 | 14745 | { |
---|
14078 | 14746 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14081 | 14749 | mouseMode |= ROTATE; |
---|
14082 | 14750 | } // TRANSLATE; |
---|
14083 | 14751 | |
---|
| 14752 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14753 | + |
---|
14084 | 14754 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14085 | 14755 | prevY = Y = anchorY; |
---|
14086 | 14756 | } |
---|
.. | .. |
---|
14088 | 14758 | void GoRight(int mod) |
---|
14089 | 14759 | { |
---|
14090 | 14760 | MODIFIERS |= COMMAND; |
---|
14091 | | - /* |
---|
| 14761 | + /**/ |
---|
14092 | 14762 | if((mod&SHIFT) == SHIFT) |
---|
14093 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14763 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14094 | 14764 | else |
---|
14095 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14096 | | - */ |
---|
| 14765 | + { |
---|
| 14766 | + if ((mouseMode&VR)!=0) |
---|
| 14767 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14768 | + else |
---|
| 14769 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14770 | + } |
---|
| 14771 | + |
---|
| 14772 | + /**/ |
---|
14097 | 14773 | if ((mod & SHIFT) == SHIFT) |
---|
14098 | 14774 | { |
---|
14099 | 14775 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14102 | 14778 | mouseMode |= ROTATE; |
---|
14103 | 14779 | } // TRANSLATE; |
---|
14104 | 14780 | |
---|
| 14781 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14782 | + |
---|
14105 | 14783 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14106 | 14784 | prevY = Y = anchorY; |
---|
14107 | 14785 | } |
---|
.. | .. |
---|
14111 | 14789 | int X, Y; |
---|
14112 | 14790 | boolean SX, SY; |
---|
14113 | 14791 | |
---|
14114 | | - void drag(int x, int y, int modifiers) |
---|
| 14792 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
14115 | 14793 | { |
---|
14116 | 14794 | if (IsFrozen()) |
---|
14117 | 14795 | { |
---|
.. | .. |
---|
14120 | 14798 | |
---|
14121 | 14799 | drag = true; // NEW |
---|
14122 | 14800 | |
---|
14123 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14801 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
14124 | 14802 | |
---|
14125 | 14803 | X = x; |
---|
14126 | 14804 | Y = y; |
---|
14127 | 14805 | // floating state for animation |
---|
14128 | | - MODIFIERS = modifiers; |
---|
14129 | | - modifiers &= ~1024; |
---|
| 14806 | + MODIFIERS = modifiersex; |
---|
| 14807 | + modifiersex &= ~1024; |
---|
14130 | 14808 | if (false) // modifiers != 0) |
---|
14131 | 14809 | { |
---|
14132 | 14810 | //new Exception().printStackTrace(); |
---|
14133 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14811 | + System.out.println("mouseDragged: " + modifiersex); |
---|
14134 | 14812 | System.out.println("SHIFT = " + SHIFT); |
---|
14135 | 14813 | System.out.println("CONTROL = " + COMMAND); |
---|
14136 | 14814 | System.out.println("META = " + META); |
---|
.. | .. |
---|
14143 | 14821 | if (editObj) |
---|
14144 | 14822 | { |
---|
14145 | 14823 | drag = true; |
---|
14146 | | - ClickInfo info = new ClickInfo(); |
---|
14147 | | - info.bounds.setBounds(0, 0, |
---|
| 14824 | + //ClickInfo info = new ClickInfo(); |
---|
| 14825 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14148 | 14826 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14149 | | - info.pane = this; |
---|
14150 | | - info.camera = renderCamera; |
---|
14151 | | - info.x = x; |
---|
14152 | | - info.y = y; |
---|
14153 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14827 | + object.clickInfo.pane = this; |
---|
| 14828 | + object.clickInfo.camera = renderCamera; |
---|
| 14829 | + object.clickInfo.x = x; |
---|
| 14830 | + object.clickInfo.y = y; |
---|
| 14831 | + object //.GetWindow().copy |
---|
| 14832 | + .doEditDrag(//info, |
---|
| 14833 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14154 | 14834 | } else |
---|
14155 | 14835 | { |
---|
14156 | 14836 | if (x < startX) |
---|
.. | .. |
---|
14299 | 14979 | } |
---|
14300 | 14980 | } |
---|
14301 | 14981 | |
---|
| 14982 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14983 | + |
---|
14302 | 14984 | public void mouseMoved(MouseEvent e) |
---|
14303 | 14985 | { |
---|
14304 | 14986 | //System.out.println("mouseMoved: " + e); |
---|
14305 | 14987 | if (isRenderer) |
---|
14306 | 14988 | return; |
---|
14307 | 14989 | |
---|
14308 | | - ClickInfo ci = new ClickInfo(); |
---|
14309 | | - ci.x = e.getX(); |
---|
14310 | | - ci.y = e.getY(); |
---|
14311 | | - ci.modifiers = e.getModifiersEx(); |
---|
14312 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14313 | | - ci.pane = this; |
---|
14314 | | - ci.camera = renderCamera; |
---|
| 14990 | + // Mouse cursor feedback |
---|
| 14991 | + object.clickInfo.x = e.getX(); |
---|
| 14992 | + object.clickInfo.y = e.getY(); |
---|
| 14993 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14994 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14995 | + object.clickInfo.pane = this; |
---|
| 14996 | + object.clickInfo.camera = renderCamera; |
---|
14315 | 14997 | if (!isRenderer) |
---|
14316 | 14998 | { |
---|
14317 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14999 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15000 | + //Object3D copy = editWindow.copy; |
---|
| 15001 | + if (object.doEditClick(//clickInfo, |
---|
| 15002 | + 0)) |
---|
14318 | 15003 | { |
---|
14319 | 15004 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14320 | 15005 | } else |
---|
.. | .. |
---|
14326 | 15011 | |
---|
14327 | 15012 | public void mouseReleased(MouseEvent e) |
---|
14328 | 15013 | { |
---|
| 15014 | + Globals.MOUSEDRAGGED = false; |
---|
| 15015 | + |
---|
14329 | 15016 | movingcamera = false; |
---|
| 15017 | + X = 0; // getBounds().width/2; |
---|
| 15018 | + Y = 0; // getBounds().height/2; |
---|
14330 | 15019 | //System.out.println("mouseReleased: " + e); |
---|
14331 | 15020 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14332 | 15021 | } |
---|
.. | .. |
---|
14349 | 15038 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
14350 | 15039 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
14351 | 15040 | |
---|
14352 | | - if (control || command || IsFrozen()) |
---|
| 15041 | +// No delay if (control || command || IsFrozen()) |
---|
14353 | 15042 | timeout = true; |
---|
14354 | | - else |
---|
| 15043 | +// ?? May 2019 else |
---|
14355 | 15044 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
14356 | 15045 | mouseDown = false; |
---|
14357 | 15046 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14461 | 15150 | System.out.println("keyReleased: " + e); |
---|
14462 | 15151 | } |
---|
14463 | 15152 | |
---|
14464 | | - void SetMouseMode(int modifiers) |
---|
| 15153 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14465 | 15154 | { |
---|
14466 | 15155 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14467 | 15156 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14473 | 15162 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14474 | 15163 | // return; |
---|
14475 | 15164 | //System.out.println("SetMode = " + modifiers); |
---|
14476 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15165 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14477 | 15166 | { |
---|
14478 | 15167 | mouseMode |= ZOOM; |
---|
14479 | 15168 | } |
---|
14480 | 15169 | |
---|
14481 | 15170 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14482 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15171 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14483 | 15172 | { |
---|
14484 | 15173 | mouseMode |= VR; // BACKFORTH; |
---|
14485 | 15174 | } |
---|
14486 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15175 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14487 | 15176 | { |
---|
14488 | 15177 | mouseMode |= SELECT; |
---|
14489 | 15178 | } |
---|
14490 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15179 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14491 | 15180 | { |
---|
14492 | 15181 | mouseMode |= SELECT; |
---|
14493 | 15182 | } |
---|
14494 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15183 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14495 | 15184 | { |
---|
14496 | 15185 | mouseMode &= ~VR; |
---|
14497 | 15186 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14520 | 15209 | |
---|
14521 | 15210 | if (isRenderer) // |
---|
14522 | 15211 | { |
---|
14523 | | - SetMouseMode(modifiers); |
---|
| 15212 | + SetMouseMode(0, modifiers); |
---|
14524 | 15213 | } |
---|
14525 | 15214 | |
---|
14526 | 15215 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14582 | 15271 | // break; |
---|
14583 | 15272 | case 'T': |
---|
14584 | 15273 | CACHETEXTURE ^= true; |
---|
14585 | | - textures.clear(); |
---|
| 15274 | + texturepigment.clear(); |
---|
| 15275 | + texturebump.clear(); |
---|
14586 | 15276 | // repaint(); |
---|
14587 | 15277 | break; |
---|
14588 | 15278 | case 'Y': |
---|
.. | .. |
---|
14667 | 15357 | case 'E' : COMPACT ^= true; |
---|
14668 | 15358 | repaint(); |
---|
14669 | 15359 | break; |
---|
14670 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15360 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15361 | + //DEBUGHSB ^= true; |
---|
| 15362 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14671 | 15363 | repaint(); |
---|
14672 | 15364 | break; |
---|
14673 | 15365 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14692 | 15384 | RevertCamera(); |
---|
14693 | 15385 | repaint(); |
---|
14694 | 15386 | break; |
---|
14695 | | - case 'L': |
---|
14696 | 15387 | case 'l': |
---|
| 15388 | + //case 'L': |
---|
14697 | 15389 | if (lightMode) |
---|
14698 | 15390 | { |
---|
14699 | 15391 | lightMode = false; |
---|
.. | .. |
---|
14757 | 15449 | OCCLUSION_CULLING ^= true; |
---|
14758 | 15450 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14759 | 15451 | break; |
---|
14760 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15452 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14761 | 15453 | case '1': |
---|
14762 | 15454 | case '2': |
---|
14763 | 15455 | case '3': |
---|
14764 | 15456 | case '4': |
---|
14765 | 15457 | case '5': |
---|
14766 | | - newenvy = Character.getNumericValue(key); |
---|
14767 | | - repaint(); |
---|
14768 | | - break; |
---|
14769 | 15458 | case '6': |
---|
14770 | 15459 | case '7': |
---|
14771 | 15460 | case '8': |
---|
14772 | 15461 | case '9': |
---|
14773 | | - BGcolor = (key - '6')/3.f; |
---|
| 15462 | + if (true) // envyoff) |
---|
| 15463 | + { |
---|
| 15464 | + BGcolor = (key - '1')/8.f; |
---|
| 15465 | + } |
---|
| 15466 | + else |
---|
| 15467 | + { |
---|
| 15468 | + //newenvy = Character.getNumericValue(key); |
---|
| 15469 | + } |
---|
14774 | 15470 | repaint(); |
---|
14775 | 15471 | break; |
---|
14776 | 15472 | case '!': |
---|
.. | .. |
---|
14836 | 15532 | case '_': |
---|
14837 | 15533 | kompactbit = 5; |
---|
14838 | 15534 | break; |
---|
14839 | | - case '+': |
---|
14840 | | - kompactbit = 6; |
---|
14841 | | - break; |
---|
| 15535 | +// case '+': |
---|
| 15536 | +// kompactbit = 6; |
---|
| 15537 | +// break; |
---|
14842 | 15538 | case ' ': |
---|
14843 | 15539 | lightMode ^= true; |
---|
14844 | 15540 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14850 | 15546 | case ESC: |
---|
14851 | 15547 | RENDERPROGRAM += 1; |
---|
14852 | 15548 | RENDERPROGRAM %= 3; |
---|
| 15549 | + |
---|
14853 | 15550 | repaint(); |
---|
14854 | 15551 | break; |
---|
14855 | 15552 | case 'Z': |
---|
14856 | 15553 | //RESIZETEXTURE ^= true; |
---|
14857 | 15554 | //break; |
---|
14858 | 15555 | case 'z': |
---|
14859 | | - RENDERSHADOW ^= true; |
---|
| 15556 | + Globals.RENDERSHADOW ^= true; |
---|
14860 | 15557 | Globals.lighttouched = true; |
---|
14861 | 15558 | repaint(); |
---|
14862 | 15559 | break; |
---|
.. | .. |
---|
14889 | 15586 | case DELETE: |
---|
14890 | 15587 | ClearSelection(); |
---|
14891 | 15588 | break; |
---|
14892 | | - /* |
---|
14893 | 15589 | case '+': |
---|
| 15590 | + |
---|
| 15591 | + /* |
---|
14894 | 15592 | //fontsize += 1; |
---|
14895 | 15593 | bbzoom *= 2; |
---|
14896 | 15594 | repaint(); |
---|
.. | .. |
---|
14907 | 15605 | case '=': |
---|
14908 | 15606 | IncDepth(); |
---|
14909 | 15607 | //fontsize += 1; |
---|
14910 | | - object.editWindow.refreshContents(true); |
---|
| 15608 | + object.GetWindow().refreshContents(true); |
---|
14911 | 15609 | maskbit = 6; |
---|
14912 | 15610 | break; |
---|
14913 | 15611 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14914 | 15612 | DecDepth(); |
---|
14915 | 15613 | maskbit = 5; |
---|
14916 | 15614 | //if(fontsize > 1) fontsize -= 1; |
---|
14917 | | - if (object.editWindow == null) |
---|
14918 | | - new Exception().printStackTrace(); |
---|
14919 | | - else |
---|
14920 | | - object.editWindow.refreshContents(true); |
---|
| 15615 | +// if (object.editWindow == null) |
---|
| 15616 | +// new Exception().printStackTrace(); |
---|
| 15617 | +// else |
---|
| 15618 | + object.GetWindow().refreshContents(true); |
---|
14921 | 15619 | break; |
---|
14922 | 15620 | case '{': |
---|
14923 | 15621 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14980 | 15678 | //mode = ROTATE; |
---|
14981 | 15679 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14982 | 15680 | { |
---|
14983 | | - SetMouseMode(modifiers); |
---|
| 15681 | + SetMouseMode(0, modifiers); |
---|
14984 | 15682 | } |
---|
14985 | 15683 | } |
---|
14986 | 15684 | |
---|
.. | .. |
---|
15116 | 15814 | { |
---|
15117 | 15815 | //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
15118 | 15816 | //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
15119 | | - if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
| 15817 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
15120 | 15818 | { |
---|
15121 | 15819 | mouseMoved(e); |
---|
15122 | 15820 | } else |
---|
.. | .. |
---|
15141 | 15839 | } |
---|
15142 | 15840 | */ |
---|
15143 | 15841 | |
---|
15144 | | - object.editWindow.EditSelection(); |
---|
| 15842 | + object.GetWindow().EditSelection(false); |
---|
15145 | 15843 | } |
---|
15146 | 15844 | |
---|
15147 | 15845 | void SelectParent() |
---|
.. | .. |
---|
15158 | 15856 | { |
---|
15159 | 15857 | //selectees.remove(i); |
---|
15160 | 15858 | System.out.println("select parent of " + elem); |
---|
15161 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15859 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15162 | 15860 | } else |
---|
15163 | 15861 | { |
---|
15164 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15862 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15165 | 15863 | } |
---|
15166 | 15864 | |
---|
15167 | 15865 | first = false; |
---|
.. | .. |
---|
15203 | 15901 | for (int j = 0; j < group.children.size(); j++) |
---|
15204 | 15902 | { |
---|
15205 | 15903 | elem = (Object3D) group.children.elementAt(j); |
---|
15206 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15904 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15207 | 15905 | first = false; |
---|
15208 | 15906 | } |
---|
15209 | 15907 | } else |
---|
15210 | 15908 | { |
---|
15211 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15909 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15212 | 15910 | } |
---|
15213 | 15911 | |
---|
15214 | 15912 | first = false; |
---|
.. | .. |
---|
15219 | 15917 | { |
---|
15220 | 15918 | //Composite group = (Composite) object; |
---|
15221 | 15919 | Object3D group = object; |
---|
15222 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15920 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15223 | 15921 | } |
---|
15224 | 15922 | |
---|
15225 | 15923 | void ResetTransform(int mask) |
---|
15226 | 15924 | { |
---|
15227 | 15925 | //Composite group = (Composite) object; |
---|
15228 | 15926 | Object3D group = object; |
---|
15229 | | - group.editWindow.ResetTransform(mask); |
---|
| 15927 | + group.GetWindow().ResetTransform(mask); |
---|
15230 | 15928 | } |
---|
15231 | 15929 | |
---|
15232 | 15930 | void FlipTransform() |
---|
15233 | 15931 | { |
---|
15234 | 15932 | //Composite group = (Composite) object; |
---|
15235 | 15933 | Object3D group = object; |
---|
15236 | | - group.editWindow.FlipTransform(); |
---|
| 15934 | + group.GetWindow().FlipTransform(); |
---|
15237 | 15935 | // group.editWindow.ReduceMesh(true); |
---|
15238 | 15936 | } |
---|
15239 | 15937 | |
---|
.. | .. |
---|
15241 | 15939 | { |
---|
15242 | 15940 | //Composite group = (Composite) object; |
---|
15243 | 15941 | Object3D group = object; |
---|
15244 | | - group.editWindow.PrintMemory(); |
---|
| 15942 | + group.GetWindow().PrintMemory(); |
---|
15245 | 15943 | // group.editWindow.ReduceMesh(true); |
---|
15246 | 15944 | } |
---|
15247 | 15945 | |
---|
.. | .. |
---|
15249 | 15947 | { |
---|
15250 | 15948 | //Composite group = (Composite) object; |
---|
15251 | 15949 | Object3D group = object; |
---|
15252 | | - group.editWindow.ResetCentroid(); |
---|
| 15950 | + group.GetWindow().ResetCentroid(); |
---|
15253 | 15951 | } |
---|
15254 | 15952 | |
---|
15255 | 15953 | void IncDepth() |
---|
.. | .. |
---|
15331 | 16029 | |
---|
15332 | 16030 | int width = getBounds().width; |
---|
15333 | 16031 | int height = getBounds().height; |
---|
15334 | | - ClickInfo info = new ClickInfo(); |
---|
15335 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15336 | 16032 | //Image img = CreateImage(width, height); |
---|
15337 | 16033 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16034 | + |
---|
15338 | 16035 | Graphics gr = g; // img.getGraphics(); |
---|
| 16036 | + |
---|
15339 | 16037 | if (!hasMarquee) |
---|
15340 | 16038 | { |
---|
15341 | 16039 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15407 | 16105 | } |
---|
15408 | 16106 | if (object != null && !hasMarquee) |
---|
15409 | 16107 | { |
---|
| 16108 | + if (object.clickInfo == null) |
---|
| 16109 | + object.clickInfo = new ClickInfo(); |
---|
| 16110 | + ClickInfo info = object.clickInfo; |
---|
| 16111 | + //ClickInfo info = new ClickInfo(); |
---|
| 16112 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16113 | + |
---|
15410 | 16114 | if (isRenderer) |
---|
15411 | 16115 | { |
---|
15412 | | - info.flags++; |
---|
| 16116 | + object.clickInfo.flags++; |
---|
15413 | 16117 | double frameAspect = (double) width / (double) height; |
---|
15414 | 16118 | if (frameAspect > renderCamera.aspect) |
---|
15415 | 16119 | { |
---|
15416 | 16120 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15417 | | - info.bounds.width -= width - desired; |
---|
15418 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16121 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16122 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15419 | 16123 | } else |
---|
15420 | 16124 | { |
---|
15421 | 16125 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15422 | | - info.bounds.height -= height - desired; |
---|
15423 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16126 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16127 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15424 | 16128 | } |
---|
15425 | 16129 | } |
---|
15426 | | - info.g = gr; |
---|
15427 | | - info.camera = renderCamera; |
---|
| 16130 | + |
---|
| 16131 | + object.clickInfo.g = gr; |
---|
| 16132 | + object.clickInfo.camera = renderCamera; |
---|
15428 | 16133 | /* |
---|
15429 | 16134 | // Memory intensive (brep.verticescopy) |
---|
15430 | 16135 | if (!(object instanceof Composite)) |
---|
15431 | 16136 | object.draw(info, 0, false); // SLOW : |
---|
15432 | 16137 | */ |
---|
15433 | | - if (!isRenderer) |
---|
| 16138 | + if (!isRenderer) // && drag) |
---|
15434 | 16139 | { |
---|
15435 | | - object.drawEditHandles(info, 0); |
---|
| 16140 | + Grafreed.Assert(object != null); |
---|
| 16141 | + Grafreed.Assert(object.selection != null); |
---|
| 16142 | + if (object.selection.Size() > 0) |
---|
| 16143 | + { |
---|
| 16144 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16145 | + |
---|
| 16146 | + object.clickInfo.DX = 0; |
---|
| 16147 | + object.clickInfo.DY = 0; |
---|
| 16148 | + object.clickInfo.W = 1; |
---|
| 16149 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16150 | + { |
---|
| 16151 | + info.DX = X; |
---|
| 16152 | + if (X != 0) |
---|
| 16153 | + info.DX -= info.bounds.width/2; |
---|
| 16154 | + |
---|
| 16155 | + info.DY = Y; |
---|
| 16156 | + if (Y != 0) |
---|
| 16157 | + info.DY -= info.bounds.height/2; |
---|
| 16158 | + } |
---|
| 16159 | + |
---|
| 16160 | + object.drawEditHandles(//info, |
---|
| 16161 | + 0); |
---|
| 16162 | + |
---|
| 16163 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16164 | + { |
---|
| 16165 | + switch (hitSomething) |
---|
| 16166 | + { |
---|
| 16167 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16168 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16169 | + break; |
---|
| 16170 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16171 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16172 | + break; |
---|
| 16173 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16174 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16175 | + break; |
---|
| 16176 | + } |
---|
| 16177 | + |
---|
| 16178 | + } |
---|
| 16179 | + } |
---|
15436 | 16180 | } |
---|
15437 | 16181 | } |
---|
| 16182 | + |
---|
15438 | 16183 | if (isRenderer) |
---|
15439 | 16184 | { |
---|
15440 | 16185 | //gr.setColor(Color.black); |
---|
15441 | 16186 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15442 | 16187 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15443 | 16188 | } |
---|
| 16189 | + |
---|
15444 | 16190 | if (hasMarquee) |
---|
15445 | 16191 | { |
---|
15446 | 16192 | gr.setXORMode(Color.white); |
---|
15447 | | - gr.setColor(Color.red); |
---|
| 16193 | + gr.setColor(Color.white); |
---|
15448 | 16194 | if (!firstime) |
---|
15449 | 16195 | { |
---|
15450 | 16196 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
15553 | 16299 | public boolean mouseDown(Event evt, int x, int y) |
---|
15554 | 16300 | { |
---|
15555 | 16301 | System.out.println("mouseDown: " + evt); |
---|
| 16302 | + System.exit(0); |
---|
15556 | 16303 | /* |
---|
15557 | 16304 | locked = true; |
---|
15558 | 16305 | drag = false; |
---|
.. | .. |
---|
15596 | 16343 | { |
---|
15597 | 16344 | keyPressed(0, modifiers); |
---|
15598 | 16345 | } |
---|
15599 | | - clickStart(x, y, modifiers); |
---|
| 16346 | + // clickStart(x, y, modifiers); |
---|
15600 | 16347 | return true; |
---|
15601 | 16348 | } |
---|
15602 | 16349 | |
---|
.. | .. |
---|
15714 | 16461 | { |
---|
15715 | 16462 | keyReleased(0, 0); |
---|
15716 | 16463 | } |
---|
15717 | | - drag(x, y, modifiers); |
---|
| 16464 | + drag(x, y, 0, modifiers); |
---|
15718 | 16465 | return true; |
---|
15719 | 16466 | } |
---|
15720 | 16467 | |
---|
.. | .. |
---|
15846 | 16593 | Object3D object; |
---|
15847 | 16594 | static Object3D trackedobject; |
---|
15848 | 16595 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15849 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16596 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15850 | 16597 | /*static*/ Camera eyeCamera; |
---|
15851 | 16598 | /*static*/ Camera lightCamera; |
---|
15852 | 16599 | int cameracount; |
---|
.. | .. |
---|
15910 | 16657 | private /*static*/ boolean firstime; |
---|
15911 | 16658 | private /*static*/ cVector newView = new cVector(); |
---|
15912 | 16659 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16660 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16661 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15913 | 16662 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15914 | 16663 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15915 | 16664 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15922 | 16671 | { |
---|
15923 | 16672 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15924 | 16673 | |
---|
| 16674 | + int usedsuf = 0; |
---|
| 16675 | + |
---|
15925 | 16676 | for (int i = 0; i < suffixes.length; i++) |
---|
15926 | 16677 | { |
---|
15927 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15928 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15929 | | - mipmapped, |
---|
15930 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15931 | | - if (data == null) |
---|
| 16678 | + String[] suffixe = suffixes; |
---|
| 16679 | + String[] fallback = suffixes2; |
---|
| 16680 | + String[] fallfallback = suffixes3; |
---|
| 16681 | + |
---|
| 16682 | + for (int c=usedsuf; --c>=0;) |
---|
15932 | 16683 | { |
---|
15933 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16684 | +// String[] temp = suffixe; |
---|
| 16685 | +// suffixe = fallback; |
---|
| 16686 | +// fallback = fallfallback; |
---|
| 16687 | +// fallfallback = temp; |
---|
15934 | 16688 | } |
---|
| 16689 | + |
---|
| 16690 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16691 | + TextureData data; |
---|
| 16692 | + |
---|
| 16693 | + try |
---|
| 16694 | + { |
---|
| 16695 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16696 | + mipmapped, |
---|
| 16697 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16698 | + } |
---|
| 16699 | + catch (Exception e) |
---|
| 16700 | + { |
---|
| 16701 | + try |
---|
| 16702 | + { |
---|
| 16703 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e2) |
---|
| 16709 | + { |
---|
| 16710 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16711 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16712 | + mipmapped, |
---|
| 16713 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16714 | + } |
---|
| 16715 | + } |
---|
| 16716 | + |
---|
15935 | 16717 | //System.out.println("Target = " + targets[i]); |
---|
15936 | 16718 | cubemap.updateImage(data, targets[i]); |
---|
15937 | 16719 | } |
---|
15938 | 16720 | |
---|
15939 | 16721 | return cubemap; |
---|
15940 | 16722 | } |
---|
| 16723 | + |
---|
15941 | 16724 | int bigsphere = -1; |
---|
15942 | 16725 | |
---|
15943 | 16726 | float BGcolor = 0.5f; |
---|
15944 | 16727 | |
---|
15945 | | - private void DrawSkyBox(GL gl) |
---|
| 16728 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16729 | + |
---|
| 16730 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15946 | 16731 | { |
---|
15947 | | - if (envyoff || cubemap == null) |
---|
| 16732 | + if (//envyoff || |
---|
| 16733 | + WIREFRAME || |
---|
| 16734 | + cubemap == null) |
---|
15948 | 16735 | { |
---|
15949 | 16736 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15950 | 16737 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15959 | 16746 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15960 | 16747 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15961 | 16748 | gl.glLoadIdentity(); |
---|
| 16749 | + gl.glScalef(1,ratio,1); |
---|
15962 | 16750 | |
---|
| 16751 | +// colorV[0] = 2; |
---|
| 16752 | +// colorV[1] = 2; |
---|
| 16753 | +// colorV[2] = 2; |
---|
| 16754 | +// colorV[3] = 1; |
---|
| 16755 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16756 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16757 | +// |
---|
| 16758 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16759 | + |
---|
15963 | 16760 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15964 | 16761 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15965 | 16762 | |
---|
.. | .. |
---|
15991 | 16788 | { |
---|
15992 | 16789 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
15993 | 16790 | } |
---|
| 16791 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
15994 | 16792 | gl.glMultMatrixd(viewrot_1, 0); |
---|
15995 | 16793 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
15996 | 16794 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16031 | 16829 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16032 | 16830 | |
---|
16033 | 16831 | cubemap.disable(); |
---|
16034 | | - ////cubemap.unbind(); |
---|
| 16832 | + //cubemap.dispose(); |
---|
| 16833 | + |
---|
16035 | 16834 | if (CULLFACE) |
---|
16036 | 16835 | { |
---|
16037 | 16836 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16131 | 16930 | cStatic.objectstack[materialdepth++] = checker; |
---|
16132 | 16931 | //System.out.println("material " + material); |
---|
16133 | 16932 | //Applet3D.tracein(this, selected); |
---|
16134 | | - vector2buffer = checker.projectedVertices; |
---|
| 16933 | + //vector2buffer = checker.projectedVertices; |
---|
16135 | 16934 | |
---|
16136 | 16935 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16137 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16936 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16138 | 16937 | |
---|
16139 | 16938 | materialdepth -= 1; |
---|
16140 | 16939 | if (materialdepth > 0) |
---|
16141 | 16940 | { |
---|
16142 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16143 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16941 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16942 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16144 | 16943 | } |
---|
16145 | 16944 | //checker.GetMaterial().opacity = 1f; |
---|
16146 | 16945 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16226 | 17025 | } |
---|
16227 | 17026 | } |
---|
16228 | 17027 | |
---|
| 17028 | + private Object3D GetFolder() |
---|
| 17029 | + { |
---|
| 17030 | + Object3D folder = object.GetWindow().copy; |
---|
| 17031 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17032 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17033 | + return folder; |
---|
| 17034 | + } |
---|
| 17035 | + |
---|
16229 | 17036 | class SelectBuffer implements GLEventListener |
---|
16230 | 17037 | { |
---|
16231 | 17038 | |
---|
.. | .. |
---|
16241 | 17048 | //new Exception().printStackTrace(); |
---|
16242 | 17049 | System.out.println("select buffer init"); |
---|
16243 | 17050 | // Use debug pipeline |
---|
16244 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17051 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16245 | 17052 | |
---|
16246 | 17053 | GL gl = drawable.getGL(); |
---|
16247 | 17054 | |
---|
.. | .. |
---|
16305 | 17112 | |
---|
16306 | 17113 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16307 | 17114 | |
---|
| 17115 | + if (PAINTMODE) |
---|
| 17116 | + { |
---|
| 17117 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17118 | + { |
---|
| 17119 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17120 | + |
---|
| 17121 | + // Make what you paint not selectable. |
---|
| 17122 | + paintobj.ResetSelectable(); |
---|
| 17123 | + } |
---|
| 17124 | + } |
---|
| 17125 | + |
---|
16308 | 17126 | //int tmp = selection_view; |
---|
16309 | 17127 | //selection_view = -1; |
---|
16310 | 17128 | int temp = DrawMode(); |
---|
.. | .. |
---|
16316 | 17134 | // temp = DEFAULT; // patch for selection debug |
---|
16317 | 17135 | Globals.drawMode = temp; // WARNING |
---|
16318 | 17136 | |
---|
| 17137 | + if (PAINTMODE) |
---|
| 17138 | + { |
---|
| 17139 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17140 | + { |
---|
| 17141 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17142 | + |
---|
| 17143 | + // Revert. |
---|
| 17144 | + paintobj.RestoreSelectable(); |
---|
| 17145 | + } |
---|
| 17146 | + } |
---|
| 17147 | + |
---|
16319 | 17148 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16320 | 17149 | |
---|
16321 | 17150 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16363 | 17192 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16364 | 17193 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16365 | 17194 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17195 | + |
---|
| 17196 | + CreateSelectedPoint(); |
---|
16366 | 17197 | |
---|
16367 | 17198 | // Will fit the mesh !!! |
---|
16368 | 17199 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16412 | 17243 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
16413 | 17244 | } |
---|
16414 | 17245 | |
---|
16415 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17246 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16416 | 17247 | } |
---|
16417 | 17248 | } |
---|
16418 | 17249 | |
---|
16419 | 17250 | if (!movingcamera && !PAINTMODE) |
---|
16420 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17251 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16421 | 17252 | |
---|
16422 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17253 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16423 | 17254 | { |
---|
16424 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17255 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16425 | 17256 | |
---|
16426 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17257 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17258 | + { |
---|
| 17259 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16427 | 17260 | |
---|
16428 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16429 | | - |
---|
16430 | | - group.add(paintobj); // link |
---|
16431 | | - |
---|
16432 | | - object.editWindow.SnapObject(group); |
---|
16433 | | - |
---|
16434 | | - Object3D folder = object.editWindow.copy; |
---|
16435 | | - |
---|
16436 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16437 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16438 | | - |
---|
16439 | | - folder.add(group); |
---|
16440 | | - |
---|
16441 | | - object.editWindow.ResetModel(); |
---|
16442 | | - object.editWindow.refreshContents(); |
---|
| 17261 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17262 | + |
---|
| 17263 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17264 | + |
---|
| 17265 | + inst.add(paintobj); // link |
---|
| 17266 | + |
---|
| 17267 | + object.GetWindow().SnapObject(inst); |
---|
| 17268 | + |
---|
| 17269 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17270 | + |
---|
| 17271 | + folder.add(inst); |
---|
| 17272 | + |
---|
| 17273 | + object.GetWindow().ResetModel(); |
---|
| 17274 | + object.GetWindow().refreshContents(); |
---|
| 17275 | + } |
---|
16443 | 17276 | } |
---|
16444 | 17277 | else |
---|
16445 | 17278 | paintcount = 0; |
---|
.. | .. |
---|
16478 | 17311 | //System.out.println("objects[color] = " + objects[color]); |
---|
16479 | 17312 | //objects[color].Select(); |
---|
16480 | 17313 | indexcount = 0; |
---|
| 17314 | + ObjEditor window = object.GetWindow(); |
---|
| 17315 | + if (window != null && deselect) |
---|
| 17316 | + { |
---|
| 17317 | + window.Select(null, deselect, true); |
---|
| 17318 | + } |
---|
16481 | 17319 | object.Select(color, deselect); |
---|
16482 | 17320 | } |
---|
16483 | 17321 | |
---|
.. | .. |
---|
16528 | 17366 | |
---|
16529 | 17367 | public void init(GLAutoDrawable drawable) |
---|
16530 | 17368 | { |
---|
| 17369 | + if (Globals.DEBUG) |
---|
16531 | 17370 | System.out.println("shadow buffer init"); |
---|
16532 | 17371 | |
---|
16533 | 17372 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
16577 | 17416 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16578 | 17417 | } |
---|
16579 | 17418 | |
---|
16580 | | - if (!RENDERSHADOW) |
---|
| 17419 | + if (!Globals.RENDERSHADOW) |
---|
16581 | 17420 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16582 | 17421 | |
---|
16583 | 17422 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16587 | 17426 | //gl.glColorMask(false, false, false, false); |
---|
16588 | 17427 | |
---|
16589 | 17428 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16590 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17429 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16591 | 17430 | { |
---|
16592 | 17431 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16593 | 17432 | |
---|
.. | .. |
---|
16756 | 17595 | gl.glFlush(); |
---|
16757 | 17596 | |
---|
16758 | 17597 | /**/ |
---|
16759 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17598 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
16760 | 17599 | |
---|
16761 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17600 | + float[] depths = occlusiondepthbuffer.array(); |
---|
16762 | 17601 | |
---|
| 17602 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17603 | + |
---|
| 17604 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17605 | + |
---|
16763 | 17606 | double r = 0, g = 0, b = 0; |
---|
16764 | 17607 | |
---|
16765 | 17608 | double count = 0; |
---|
.. | .. |
---|
16770 | 17613 | |
---|
16771 | 17614 | double FACTOR = 1; |
---|
16772 | 17615 | |
---|
16773 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17616 | + for (int i = 0; i < depths.length; i++) |
---|
16774 | 17617 | { |
---|
16775 | 17618 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
16776 | 17619 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
16853 | 17696 | |
---|
16854 | 17697 | double scale = ray.z; // 1; // cos |
---|
16855 | 17698 | |
---|
16856 | | - float depth = pixels[newindex]; |
---|
| 17699 | + float depth = depths[newindex]; |
---|
16857 | 17700 | |
---|
16858 | 17701 | /* |
---|
16859 | 17702 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17003 | 17846 | int AAbuffersize = 0; |
---|
17004 | 17847 | |
---|
17005 | 17848 | //double[] selectedpoint = new double[3]; |
---|
17006 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17849 | + static Superellipsoid selectedpoint; |
---|
17007 | 17850 | static Sphere previousselectedpoint = null; |
---|
17008 | | - static Sphere debugpointG = new Sphere(); |
---|
17009 | | - static Sphere debugpointP = new Sphere(); |
---|
17010 | | - static Sphere debugpointC = new Sphere(); |
---|
17011 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17851 | + static Sphere debugpointG; |
---|
| 17852 | + static Sphere debugpointP; |
---|
| 17853 | + static Sphere debugpointC; |
---|
| 17854 | + static Sphere debugpointR; |
---|
17012 | 17855 | |
---|
17013 | 17856 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17014 | 17857 | |
---|
17015 | | - static |
---|
17016 | | - { |
---|
17017 | | - for (int i=0; i<8; i++) |
---|
17018 | | - { |
---|
17019 | | - debugpoints[i] = new Sphere(); |
---|
17020 | | - } |
---|
17021 | | - } |
---|
17022 | | - |
---|
17023 | 17858 | static void InitPoints(float radius) |
---|
17024 | 17859 | { |
---|
17025 | 17860 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
17058 | 17893 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17059 | 17894 | static IntBuffer bigAAbuffer; |
---|
17060 | 17895 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17061 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17896 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17062 | 17897 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17063 | 17898 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17064 | 17899 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17065 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17900 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17901 | + |
---|
| 17902 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17903 | + |
---|
17066 | 17904 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17067 | 17905 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17068 | 17906 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|