.. | .. |
---|
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 | |
---|
.. | .. |
---|
130 | 168 | |
---|
131 | 169 | |
---|
132 | 170 | // OPTIONS |
---|
133 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
134 | 172 | boolean cameraLight = false; |
---|
135 | 173 | boolean UVdebug = false; |
---|
136 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
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 | { |
---|
.. | .. |
---|
4208 | 4332 | |
---|
4209 | 4333 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
4210 | 4334 | { |
---|
| 4335 | + new Exception().printStackTrace(); |
---|
4211 | 4336 | System.exit(0); |
---|
4212 | 4337 | com.sun.opengl.util.texture.Texture texture = null; |
---|
4213 | 4338 | |
---|
.. | .. |
---|
7901 | 8026 | String pigment = Object3D.GetPigment(tex); |
---|
7902 | 8027 | String bump = Object3D.GetBump(tex); |
---|
7903 | 8028 | |
---|
7904 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8029 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7905 | 8030 | { |
---|
7906 | 8031 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7907 | 8032 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7916 | 8041 | pigment = null; |
---|
7917 | 8042 | } |
---|
7918 | 8043 | |
---|
7919 | | - ReleaseTexture(bump, true); |
---|
7920 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
7921 | 8046 | } |
---|
7922 | 8047 | |
---|
7923 | | - 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) |
---|
7924 | 8107 | { |
---|
7925 | 8108 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7926 | 8109 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7931 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7932 | 8115 | |
---|
7933 | 8116 | if (tex != null) |
---|
7934 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7935 | 8118 | |
---|
7936 | 8119 | // //assert( texture != null ); |
---|
7937 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
8023 | 8206 | } |
---|
8024 | 8207 | } |
---|
8025 | 8208 | |
---|
8026 | | - /*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 |
---|
8027 | 8258 | { |
---|
8028 | 8259 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8029 | 8260 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8034 | 8265 | if (tex == null) |
---|
8035 | 8266 | { |
---|
8036 | 8267 | BindTexture(null,false,resolution); |
---|
8037 | | - BindTexture(null,true,resolution); |
---|
8038 | 8268 | return; |
---|
8039 | 8269 | } |
---|
8040 | 8270 | |
---|
8041 | 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 | + |
---|
8042 | 8304 | String bump = Object3D.GetBump(tex); |
---|
8043 | 8305 | |
---|
8044 | | - usedtextures.put(pigment, pigment); |
---|
8045 | | - usedtextures.put(bump, bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
8046 | 8307 | |
---|
8047 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8308 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8048 | 8309 | { |
---|
8049 | 8310 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8050 | 8311 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8054 | 8315 | { |
---|
8055 | 8316 | bump = null; |
---|
8056 | 8317 | } |
---|
8057 | | - if (pigment.equals("")) |
---|
8058 | | - { |
---|
8059 | | - pigment = null; |
---|
8060 | | - } |
---|
8061 | 8318 | |
---|
8062 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8063 | | - BindTexture(pigment, false, resolution); |
---|
8064 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8065 | | - BindTexture(bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
8066 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8067 | | - |
---|
8068 | | - return; // true; |
---|
8069 | 8322 | } |
---|
8070 | 8323 | |
---|
8071 | | - 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) |
---|
8072 | 8327 | { |
---|
8073 | | - 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; |
---|
8074 | 8347 | |
---|
8075 | 8348 | if (tex != null) |
---|
8076 | 8349 | { |
---|
8077 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8078 | 8352 | |
---|
8079 | | - String[] split = tex.split("Textures"); |
---|
8080 | | - if (split.length > 1) |
---|
8081 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8082 | | - else |
---|
8083 | | - if (!texname.startsWith("/")) |
---|
8084 | | - 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 | + } |
---|
8085 | 8370 | |
---|
8086 | 8371 | if (CACHETEXTURE) |
---|
8087 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8088 | | - |
---|
8089 | | - TextureData texturedata = null; |
---|
8090 | | - |
---|
8091 | | - if (texture == null || texture.resolution < resolution) |
---|
8092 | 8372 | { |
---|
8093 | | - 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("")) |
---|
8094 | 8406 | { |
---|
8095 | 8407 | assert(!bump); |
---|
8096 | 8408 | // if (bump) |
---|
.. | .. |
---|
8101 | 8413 | // } |
---|
8102 | 8414 | // else |
---|
8103 | 8415 | // { |
---|
8104 | | - texture = textures.get(tex); |
---|
8105 | | - if (texture == null) |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8417 | + if (texturecache == null) |
---|
8106 | 8418 | { |
---|
8107 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8419 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8108 | 8420 | } |
---|
| 8421 | + else |
---|
| 8422 | + new Exception().printStackTrace(); |
---|
8109 | 8423 | // } |
---|
8110 | 8424 | } else |
---|
8111 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8112 | 8426 | { |
---|
8113 | 8427 | assert(bump); |
---|
8114 | | - texture = textures.get(tex); |
---|
8115 | | - if (texture == null) |
---|
8116 | | - 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(); |
---|
8117 | 8433 | } else |
---|
8118 | 8434 | { |
---|
8119 | 8435 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8121 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
8122 | 8438 | //} else |
---|
8123 | 8439 | //{ |
---|
8124 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8125 | 8441 | { |
---|
8126 | | - texture = textures.get(tex); |
---|
8127 | | - if (texture == null) |
---|
8128 | | - 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(); |
---|
8129 | 8456 | } else |
---|
8130 | 8457 | { |
---|
8131 | 8458 | if (textureon) |
---|
.. | .. |
---|
8150 | 8477 | } |
---|
8151 | 8478 | |
---|
8152 | 8479 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8153 | | - if (!new File(cachename).exists()) |
---|
| 8480 | + if (!FileExists(cachename)) |
---|
8154 | 8481 | cachename = texname; |
---|
8155 | 8482 | else |
---|
8156 | 8483 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8172 | 8499 | } |
---|
8173 | 8500 | |
---|
8174 | 8501 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8175 | | - if (!new File(cachename).exists()) |
---|
| 8502 | + if (!FileExists(cachename)) |
---|
8176 | 8503 | cachename = texname; |
---|
8177 | 8504 | else |
---|
8178 | 8505 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8181 | 8508 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8182 | 8509 | |
---|
8183 | 8510 | |
---|
8184 | | - if (texturedata != null) |
---|
8185 | | - 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); |
---|
8186 | 8515 | //texture = GetTexture(tex, bump); |
---|
8187 | 8516 | } |
---|
| 8517 | + } |
---|
8188 | 8518 | } |
---|
8189 | 8519 | //} |
---|
8190 | 8520 | } |
---|
8191 | 8521 | |
---|
8192 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8193 | 8523 | { |
---|
8194 | 8524 | //return false; |
---|
8195 | 8525 | |
---|
8196 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8197 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8527 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8198 | 8528 | { |
---|
8199 | 8529 | // String ext = "_highres"; |
---|
8200 | 8530 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8211 | 8541 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8212 | 8542 | if (!cachefile.exists()) |
---|
8213 | 8543 | { |
---|
8214 | | - // cache to disk |
---|
8215 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8216 | | - //buffers[0]. |
---|
8217 | | - |
---|
8218 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8219 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8220 | | - |
---|
8221 | | - // squared size heuristic... |
---|
8222 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8544 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8223 | 8545 | { |
---|
8224 | | - for (int i=pixels.length; --i>=0;) |
---|
8225 | | - { |
---|
8226 | | - int i3 = i*3; |
---|
8227 | | - pixels[i] = 0xFF; |
---|
8228 | | - pixels[i] <<= 8; |
---|
8229 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8230 | | - pixels[i] <<= 8; |
---|
8231 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8232 | | - pixels[i] <<= 8; |
---|
8233 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8234 | | - } |
---|
8235 | | - |
---|
8236 | | - /* |
---|
8237 | | - int r=0,g=0,b=0,a=0; |
---|
8238 | | - for (int i=0; i<width; i++) |
---|
8239 | | - for (int j=0; j<height; j++) |
---|
8240 | | - { |
---|
8241 | | - int index = j*width+i; |
---|
8242 | | - int p = pixels[index]; |
---|
8243 | | - a = ((p>>24) & 0xFF); |
---|
8244 | | - r = ((p>>16) & 0xFF); |
---|
8245 | | - g = ((p>>8) & 0xFF); |
---|
8246 | | - b = (p & 0xFF); |
---|
8247 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8248 | | - } |
---|
8249 | | - /**/ |
---|
8250 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8251 | | - int height = width; |
---|
8252 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8253 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8546 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8547 | + |
---|
8254 | 8548 | ImageWriter writer = null; |
---|
8255 | 8549 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8256 | 8550 | if (iter.hasNext()) { |
---|
8257 | 8551 | writer = (ImageWriter)iter.next(); |
---|
8258 | 8552 | } |
---|
8259 | | - float compressionQuality = 0.9f; |
---|
| 8553 | + |
---|
| 8554 | + float compressionQuality = 0.85f; |
---|
8260 | 8555 | try |
---|
8261 | 8556 | { |
---|
8262 | 8557 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8273 | 8568 | } |
---|
8274 | 8569 | } |
---|
8275 | 8570 | } |
---|
8276 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
8277 | 8574 | //System.out.println("Texture = " + tex); |
---|
8278 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
8279 | 8576 | { |
---|
8280 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
8281 | 8578 | thetex.texture.disable(); |
---|
8282 | 8579 | thetex.texture.dispose(); |
---|
8283 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
8284 | 8581 | } |
---|
8285 | 8582 | |
---|
8286 | | - texture.texturedata = texturedata; |
---|
8287 | | - textures.put(texname, texture); |
---|
| 8583 | + //texture.texturedata = texturedata; |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
8288 | 8585 | |
---|
8289 | 8586 | // newtex = true; |
---|
8290 | 8587 | } |
---|
.. | .. |
---|
8300 | 8597 | } |
---|
8301 | 8598 | } |
---|
8302 | 8599 | |
---|
8303 | | - return texture; |
---|
| 8600 | + return texturecache; |
---|
8304 | 8601 | } |
---|
8305 | 8602 | |
---|
8306 | | - 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 |
---|
8307 | 8638 | { |
---|
8308 | 8639 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8309 | 8640 | |
---|
.. | .. |
---|
8321 | 8652 | return texture!=null?texture.texture:null; |
---|
8322 | 8653 | } |
---|
8323 | 8654 | |
---|
8324 | | - 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 |
---|
8325 | 8656 | { |
---|
8326 | 8657 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8327 | 8658 | |
---|
8328 | 8659 | return texture!=null?texture.texturedata:null; |
---|
8329 | 8660 | } |
---|
8330 | 8661 | |
---|
8331 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8332 | 8663 | { |
---|
8333 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8334 | 8665 | { |
---|
8335 | 8666 | return false; |
---|
8336 | 8667 | } |
---|
8337 | 8668 | |
---|
8338 | | - boolean newtex = false; |
---|
| 8669 | + //boolean newtex = false; |
---|
8339 | 8670 | |
---|
8340 | 8671 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8341 | 8672 | |
---|
.. | .. |
---|
8367 | 8698 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8368 | 8699 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8369 | 8700 | |
---|
8370 | | - return newtex; |
---|
| 8701 | + return true; // Warning: not used. |
---|
8371 | 8702 | } |
---|
8372 | 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 | + |
---|
8373 | 8770 | ShadowBuffer shadowPBuf; |
---|
8374 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
8375 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
8386 | 8783 | |
---|
8387 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8388 | 8785 | MAXSTACK = temp[0]; |
---|
8389 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8390 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8391 | 8789 | MAXSTACK = temp[0]; |
---|
8392 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8393 | 8792 | |
---|
8394 | 8793 | // Use debug pipeline |
---|
8395 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8397 | 8796 | gl = drawable.getGL(); // |
---|
8398 | 8797 | |
---|
8399 | 8798 | GL gl3 = getGL(); |
---|
8400 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8401 | 8801 | |
---|
8402 | 8802 | |
---|
8403 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8562 | 8962 | |
---|
8563 | 8963 | if (cubemap == null) |
---|
8564 | 8964 | { |
---|
8565 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
8566 | 8966 | } |
---|
8567 | 8967 | |
---|
8568 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
8838 | 9238 | |
---|
8839 | 9239 | void LoadEnvy(int which) |
---|
8840 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
8841 | 9243 | String name; |
---|
8842 | 9244 | String ext; |
---|
8843 | 9245 | |
---|
.. | .. |
---|
8849 | 9251 | cubemap = null; |
---|
8850 | 9252 | return; |
---|
8851 | 9253 | case 1: |
---|
8852 | | - name = "cubemaps/box_"; |
---|
8853 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
8854 | 9256 | reverseUP = false; |
---|
8855 | 9257 | break; |
---|
8856 | 9258 | case 2: |
---|
8857 | | - name = "cubemaps/uffizi_"; |
---|
8858 | | - ext = "png"; |
---|
8859 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
8860 | 9263 | case 3: |
---|
8861 | | - name = "cubemaps/CloudyHills_"; |
---|
8862 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
8863 | 9266 | reverseUP = false; |
---|
8864 | 9267 | break; |
---|
8865 | 9268 | case 4: |
---|
8866 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
8867 | 9270 | ext = "png"; |
---|
8868 | 9271 | reverseUP = false; |
---|
8869 | 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; |
---|
8870 | 9298 | default: |
---|
8871 | | - name = "cubemaps/rgb_"; |
---|
8872 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
8873 | 9302 | break; |
---|
8874 | 9303 | } |
---|
8875 | | - |
---|
8876 | | - try |
---|
8877 | | - { |
---|
8878 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8879 | | - } catch (IOException e) |
---|
8880 | | - { |
---|
8881 | | - throw new RuntimeException(e); |
---|
8882 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
8883 | 9306 | } |
---|
8884 | 9307 | |
---|
8885 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8911 | 9334 | static double[] model = new double[16]; |
---|
8912 | 9335 | double[] camera2light = new double[16]; |
---|
8913 | 9336 | double[] light2camera = new double[16]; |
---|
8914 | | - int newenvy = -1; |
---|
8915 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
8916 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8917 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
8918 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9205 | 9632 | jy8[3] = 0.5f; |
---|
9206 | 9633 | } |
---|
9207 | 9634 | |
---|
9208 | | - 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 |
---|
9209 | 9636 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9210 | 9637 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9211 | 9638 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9212 | 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 | + |
---|
9213 | 9664 | static int imagecount = 0; // movie generation |
---|
9214 | 9665 | |
---|
9215 | 9666 | static int jitter = 0; |
---|
.. | .. |
---|
9305 | 9756 | assert (parentcam != renderCamera); |
---|
9306 | 9757 | |
---|
9307 | 9758 | if (renderCamera != lightCamera) |
---|
9308 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9309 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9759 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9310 | 9761 | |
---|
9311 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9312 | 9763 | |
---|
.. | .. |
---|
9321 | 9772 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9322 | 9773 | |
---|
9323 | 9774 | if (renderCamera != lightCamera) |
---|
9324 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9325 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9775 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9326 | 9777 | |
---|
9327 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9328 | 9779 | |
---|
.. | .. |
---|
9368 | 9819 | rati = 1 / rati; |
---|
9369 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9370 | 9821 | } |
---|
9371 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
9372 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9373 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9374 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
9375 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9376 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9377 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
9394 | 9847 | //gl.glFlush(); |
---|
9395 | 9848 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9396 | 9849 | |
---|
9397 | | - if (ANIMATION && ABORTED) |
---|
| 9850 | + if (Globals.ANIMATION && ABORTED) |
---|
9398 | 9851 | { |
---|
9399 | 9852 | System.err.println(" ABORTED FRAME"); |
---|
9400 | 9853 | break; |
---|
.. | .. |
---|
9424 | 9877 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9425 | 9878 | |
---|
9426 | 9879 | // save image |
---|
9427 | | - if (ANIMATION && !ABORTED) |
---|
| 9880 | + if (Globals.ANIMATION && !ABORTED) |
---|
9428 | 9881 | { |
---|
9429 | 9882 | VPwidth = viewport[2]; |
---|
9430 | 9883 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9535 | 9988 | |
---|
9536 | 9989 | // imagecount++; |
---|
9537 | 9990 | |
---|
9538 | | - 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; |
---|
9539 | 9992 | |
---|
9540 | 9993 | if (!BOXMODE) |
---|
9541 | 9994 | { |
---|
9542 | | - 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) + ")"); |
---|
9543 | 9996 | } |
---|
9544 | 9997 | |
---|
9545 | 9998 | if (!BOXMODE) |
---|
.. | .. |
---|
9577 | 10030 | ABORTED = false; |
---|
9578 | 10031 | } |
---|
9579 | 10032 | else |
---|
9580 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 10033 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9581 | 10034 | |
---|
9582 | 10035 | if (false) |
---|
9583 | 10036 | { |
---|
.. | .. |
---|
10237 | 10690 | static boolean init = false; |
---|
10238 | 10691 | |
---|
10239 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
10240 | 10696 | |
---|
10241 | 10697 | public void display(GLAutoDrawable drawable) |
---|
10242 | 10698 | { |
---|
10243 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
10244 | 10700 | { |
---|
10245 | | - GrafreeD.wav.save(); |
---|
10246 | | - GrafreeD.savesound = false; |
---|
10247 | | - GrafreeD.hassound = false; |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(0); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
| 10705 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
| 10706 | + { |
---|
| 10707 | + Grafreed.wav.save(); |
---|
| 10708 | + Grafreed.savesound = false; |
---|
| 10709 | + Grafreed.hassound = false; |
---|
10248 | 10710 | } |
---|
10249 | 10711 | // if (DEBUG_SELECTION) |
---|
10250 | 10712 | // { |
---|
.. | .. |
---|
10320 | 10782 | ANTIALIAS = 0; |
---|
10321 | 10783 | //System.out.println("RESTART"); |
---|
10322 | 10784 | AAtimer.restart(); |
---|
| 10785 | + Globals.TIMERRUNNING = true; |
---|
10323 | 10786 | } |
---|
10324 | 10787 | } |
---|
10325 | 10788 | } |
---|
.. | .. |
---|
10374 | 10837 | Object3D theobject = object; |
---|
10375 | 10838 | Object3D theparent = object.parent; |
---|
10376 | 10839 | object.parent = null; |
---|
10377 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10840 | + object = (Object3D)Grafreed.clone(object); |
---|
10378 | 10841 | object.Stripify(); |
---|
10379 | 10842 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10380 | 10843 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10387 | 10850 | ambientOcclusion = false; |
---|
10388 | 10851 | } |
---|
10389 | 10852 | |
---|
10390 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10853 | + if (//Globals.lighttouched && |
---|
| 10854 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10391 | 10855 | { |
---|
10392 | 10856 | //if (RENDERSHADOW) // ? |
---|
10393 | 10857 | if (!IsFrozen()) |
---|
10394 | 10858 | { |
---|
10395 | 10859 | // dec 2012 |
---|
10396 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10860 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10397 | 10861 | { |
---|
10398 | 10862 | Globals.framecount++; |
---|
10399 | 10863 | shadowbuffer.display(); |
---|
.. | .. |
---|
10406 | 10870 | |
---|
10407 | 10871 | if (wait) |
---|
10408 | 10872 | { |
---|
10409 | | - Sleep(500); |
---|
| 10873 | + Sleep(200); // blocks everything |
---|
10410 | 10874 | |
---|
10411 | 10875 | wait = false; |
---|
10412 | 10876 | } |
---|
.. | .. |
---|
10520 | 10984 | |
---|
10521 | 10985 | // if (parentcam != renderCamera) // not a light |
---|
10522 | 10986 | if (cam != lightCamera) |
---|
10523 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10524 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10987 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10988 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10525 | 10989 | |
---|
10526 | 10990 | for (int j = 0; j < 4; j++) |
---|
10527 | 10991 | { |
---|
.. | .. |
---|
10535 | 10999 | |
---|
10536 | 11000 | // if (parentcam != renderCamera) // not a light |
---|
10537 | 11001 | if (cam != lightCamera) |
---|
10538 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10539 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 11002 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11003 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10540 | 11004 | |
---|
10541 | 11005 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10542 | 11006 | |
---|
.. | .. |
---|
10622 | 11086 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10623 | 11087 | } |
---|
10624 | 11088 | |
---|
10625 | | - if (newenvy > -1) |
---|
| 11089 | +// if (newenvy > -1) |
---|
| 11090 | +// { |
---|
| 11091 | +// LoadEnvy(newenvy); |
---|
| 11092 | +// } |
---|
| 11093 | +// |
---|
| 11094 | +// newenvy = -1; |
---|
| 11095 | + |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10626 | 11097 | { |
---|
10627 | | - LoadEnvy(newenvy); |
---|
| 11098 | + if (cubemaprgb == null) |
---|
| 11099 | + { |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11101 | + } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
10628 | 11104 | } |
---|
10629 | | - |
---|
10630 | | - newenvy = -1; |
---|
10631 | | - |
---|
| 11105 | + else |
---|
| 11106 | + { |
---|
| 11107 | + if (object.skyboxname != null) |
---|
| 11108 | + { |
---|
| 11109 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11110 | + { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
| 11113 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11114 | + loadedskyboxname = object.skyboxname; |
---|
| 11115 | + } |
---|
| 11116 | + } |
---|
| 11117 | + else |
---|
| 11118 | + { |
---|
| 11119 | + cubemapcustom = null; |
---|
| 11120 | + loadedskyboxname = null; |
---|
| 11121 | + } |
---|
| 11122 | + |
---|
| 11123 | + cubemap = cubemapcustom; |
---|
| 11124 | + } |
---|
| 11125 | + |
---|
10632 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
10633 | 11127 | //System.out.println("ratio = " + ratio); |
---|
10634 | 11128 | |
---|
.. | .. |
---|
10644 | 11138 | |
---|
10645 | 11139 | if (!IsFrozen() && !ambientOcclusion) |
---|
10646 | 11140 | { |
---|
10647 | | - DrawSkyBox(gl); |
---|
| 11141 | + DrawSkyBox(gl, (float)ratio); |
---|
10648 | 11142 | } |
---|
10649 | 11143 | |
---|
10650 | 11144 | //if (selection_view == -1) |
---|
.. | .. |
---|
10795 | 11289 | // Bump noise |
---|
10796 | 11290 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10797 | 11291 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10798 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11292 | + |
---|
| 11293 | + try |
---|
| 11294 | + { |
---|
| 11295 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11296 | + } |
---|
| 11297 | + catch (Exception e) |
---|
| 11298 | + { |
---|
| 11299 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11300 | + } |
---|
| 11301 | + |
---|
10799 | 11302 | |
---|
10800 | 11303 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10801 | 11304 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10818 | 11321 | |
---|
10819 | 11322 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10820 | 11323 | |
---|
10821 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10822 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10823 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11324 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11325 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11326 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10824 | 11327 | } else |
---|
10825 | 11328 | { |
---|
10826 | 11329 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10831 | 11334 | //System.out.println("BLENDING ON"); |
---|
10832 | 11335 | gl.glEnable(GL.GL_BLEND); |
---|
10833 | 11336 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10834 | | - |
---|
| 11337 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10835 | 11338 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10836 | 11339 | gl.glLoadIdentity(); |
---|
10837 | 11340 | |
---|
.. | .. |
---|
10920 | 11423 | System.err.println("parentcam != renderCamera"); |
---|
10921 | 11424 | |
---|
10922 | 11425 | // if (cam != lightCamera) |
---|
10923 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10924 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11426 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11427 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10925 | 11428 | } |
---|
10926 | 11429 | |
---|
10927 | 11430 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10942 | 11445 | if (true) // TODO |
---|
10943 | 11446 | { |
---|
10944 | 11447 | if (cam != lightCamera) |
---|
10945 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10946 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11448 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11449 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10947 | 11450 | } |
---|
10948 | 11451 | |
---|
10949 | 11452 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11080 | 11583 | } |
---|
11081 | 11584 | } |
---|
11082 | 11585 | |
---|
11083 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11586 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11084 | 11587 | { |
---|
11085 | 11588 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11086 | 11589 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11088 | 11591 | |
---|
11089 | 11592 | boolean texon = textureon; |
---|
11090 | 11593 | |
---|
11091 | | - if (RENDERPROGRAM > 0) |
---|
11092 | | - { |
---|
11093 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11094 | | - textureon = false; |
---|
11095 | | - } |
---|
| 11594 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11595 | + textureon = false; |
---|
| 11596 | + |
---|
11096 | 11597 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11097 | 11598 | //System.out.println("ALLO"); |
---|
11098 | 11599 | gl.glColorMask(false, false, false, false); |
---|
11099 | 11600 | DrawObject(gl); |
---|
11100 | | - if (RENDERPROGRAM > 0) |
---|
11101 | | - { |
---|
11102 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11103 | | - textureon = texon; |
---|
11104 | | - } |
---|
| 11601 | + |
---|
| 11602 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11603 | + textureon = texon; |
---|
| 11604 | + |
---|
11105 | 11605 | gl.glColorMask(true, true, true, true); |
---|
11106 | 11606 | |
---|
11107 | 11607 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11108 | | - //gl.glDepthMask(false); |
---|
| 11608 | + gl.glDepthMask(false); |
---|
11109 | 11609 | } |
---|
11110 | 11610 | |
---|
11111 | 11611 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11259 | 11759 | { |
---|
11260 | 11760 | renderpass++; |
---|
11261 | 11761 | // System.out.println("Draw object... "); |
---|
| 11762 | + STEP = 1; |
---|
11262 | 11763 | if (FAST) // in case there is no script |
---|
11263 | | - STEP = 16; |
---|
| 11764 | + STEP = 8; |
---|
| 11765 | + |
---|
| 11766 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11767 | + { |
---|
| 11768 | + STEP *= 4; |
---|
| 11769 | + } |
---|
11264 | 11770 | |
---|
11265 | 11771 | //object.FullInvariants(); |
---|
11266 | 11772 | |
---|
.. | .. |
---|
11274 | 11780 | e.printStackTrace(); |
---|
11275 | 11781 | } |
---|
11276 | 11782 | |
---|
11277 | | - if (GrafreeD.RENDERME > 0) |
---|
11278 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11783 | + if (Grafreed.RENDERME > 0) |
---|
| 11784 | + Grafreed.RENDERME--; // mechante magouille |
---|
11279 | 11785 | |
---|
11280 | 11786 | Globals.ONESTEP = false; |
---|
11281 | 11787 | } |
---|
11282 | 11788 | |
---|
11283 | 11789 | static boolean zoomonce = false; |
---|
11284 | 11790 | |
---|
| 11791 | + static void CreateSelectedPoint() |
---|
| 11792 | + { |
---|
| 11793 | + if (selectedpoint == null) |
---|
| 11794 | + { |
---|
| 11795 | + debugpointG = new Sphere(); |
---|
| 11796 | + debugpointP = new Sphere(); |
---|
| 11797 | + debugpointC = new Sphere(); |
---|
| 11798 | + debugpointR = new Sphere(); |
---|
| 11799 | + |
---|
| 11800 | + selectedpoint = new Superellipsoid(); |
---|
| 11801 | + |
---|
| 11802 | + for (int i=0; i<8; i++) |
---|
| 11803 | + { |
---|
| 11804 | + debugpoints[i] = new Sphere(); |
---|
| 11805 | + } |
---|
| 11806 | + } |
---|
| 11807 | + } |
---|
| 11808 | + |
---|
11285 | 11809 | void DrawObject(GL gl, boolean draw) |
---|
11286 | 11810 | { |
---|
| 11811 | + // To clear camera values |
---|
| 11812 | + ResetOptions(); |
---|
| 11813 | + |
---|
11287 | 11814 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11288 | 11815 | // DrawMode() = SELECTION; |
---|
11289 | 11816 | //GL gl = getGL(); |
---|
11290 | 11817 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11291 | 11818 | { |
---|
11292 | 11819 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11293 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11820 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11294 | 11821 | pingthread.StepToTarget(true); // true); |
---|
11295 | 11822 | // zoomonce = false; |
---|
11296 | 11823 | } |
---|
.. | .. |
---|
11345 | 11872 | |
---|
11346 | 11873 | usedtextures.clear(); |
---|
11347 | 11874 | |
---|
11348 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11875 | + try |
---|
| 11876 | + { |
---|
| 11877 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11878 | + } |
---|
| 11879 | + catch (Exception e) |
---|
| 11880 | + { |
---|
| 11881 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11882 | + } |
---|
11349 | 11883 | } |
---|
11350 | 11884 | //System.out.println("--> " + stackdepth); |
---|
11351 | 11885 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11355 | 11889 | |
---|
11356 | 11890 | if (DrawMode() == DEFAULT) |
---|
11357 | 11891 | { |
---|
11358 | | - if (DEBUG) |
---|
| 11892 | + if (Globals.DEBUG) |
---|
11359 | 11893 | { |
---|
| 11894 | + CreateSelectedPoint(); |
---|
11360 | 11895 | float radius = 0.05f; |
---|
11361 | 11896 | if (selectedpoint.radius != radius) |
---|
11362 | 11897 | { |
---|
.. | .. |
---|
11410 | 11945 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11411 | 11946 | |
---|
11412 | 11947 | if (CLEANCACHE) |
---|
11413 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11948 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11414 | 11949 | { |
---|
11415 | | - String tex = e.nextElement(); |
---|
| 11950 | + cTexture tex = e.nextElement(); |
---|
11416 | 11951 | |
---|
11417 | 11952 | // System.out.println("Texture --------- " + tex); |
---|
11418 | 11953 | |
---|
11419 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11954 | + if (tex.equals("WHITE_NOISE:")) |
---|
11420 | 11955 | continue; |
---|
11421 | 11956 | |
---|
11422 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11957 | + if (!usedtextures.contains(tex)) |
---|
11423 | 11958 | { |
---|
| 11959 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11424 | 11960 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11425 | | - textures.get(tex).texture.dispose(); |
---|
11426 | | - textures.remove(tex); |
---|
| 11961 | + if (gettex != null) |
---|
| 11962 | + { |
---|
| 11963 | + gettex.texture.dispose(); |
---|
| 11964 | + texturepigment.remove(tex); |
---|
| 11965 | + } |
---|
| 11966 | + |
---|
| 11967 | + gettex = texturebump.get(tex); |
---|
| 11968 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11969 | + if (gettex != null) |
---|
| 11970 | + { |
---|
| 11971 | + gettex.texture.dispose(); |
---|
| 11972 | + texturebump.remove(tex); |
---|
| 11973 | + } |
---|
11427 | 11974 | } |
---|
11428 | 11975 | } |
---|
11429 | 11976 | } |
---|
.. | .. |
---|
11436 | 11983 | if (checker != null && DrawMode() == DEFAULT) |
---|
11437 | 11984 | { |
---|
11438 | 11985 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11439 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11986 | + try |
---|
| 11987 | + { |
---|
| 11988 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11989 | + } |
---|
| 11990 | + catch (Exception e) |
---|
| 11991 | + { |
---|
| 11992 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11993 | + } |
---|
11440 | 11994 | // NEAREST |
---|
11441 | 11995 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11442 | 11996 | DrawChecker(gl); |
---|
.. | .. |
---|
11518 | 12072 | return; |
---|
11519 | 12073 | } |
---|
11520 | 12074 | |
---|
11521 | | - String string = obj.GetToolTip(); |
---|
| 12075 | + String string = obj.toString(); //.GetToolTip(); |
---|
11522 | 12076 | |
---|
11523 | 12077 | GL gl = GetGL(); |
---|
11524 | 12078 | |
---|
.. | .. |
---|
11835 | 12389 | //obj.TransformToWorld(light, light); |
---|
11836 | 12390 | for (int i = tp.size(); --i >= 0;) |
---|
11837 | 12391 | { |
---|
11838 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11839 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12392 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12393 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11840 | 12394 | } |
---|
11841 | 12395 | |
---|
11842 | 12396 | |
---|
.. | .. |
---|
11853 | 12407 | parentcam = cameras[0]; |
---|
11854 | 12408 | } |
---|
11855 | 12409 | |
---|
11856 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11857 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12410 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12411 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11858 | 12412 | |
---|
11859 | 12413 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11860 | 12414 | |
---|
.. | .. |
---|
11944 | 12498 | |
---|
11945 | 12499 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11946 | 12500 | |
---|
11947 | | - String program = |
---|
| 12501 | + String programmin = |
---|
| 12502 | + // Min shader |
---|
11948 | 12503 | "!!ARBfp1.0\n" + |
---|
| 12504 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12505 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12506 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12507 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12508 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12509 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12510 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12511 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12512 | + "TEMP temp;" + |
---|
| 12513 | + "TEMP light;" + |
---|
| 12514 | + "TEMP ndotl;" + |
---|
| 12515 | + "TEMP normal;" + |
---|
| 12516 | + "TEMP depth;" + |
---|
| 12517 | + "TEMP eye;" + |
---|
| 12518 | + "TEMP pos;" + |
---|
| 12519 | + |
---|
| 12520 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12521 | + Normalize("normal") + |
---|
| 12522 | + "MOV light, state.light[0].position;" + |
---|
| 12523 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12524 | + |
---|
| 12525 | + // shadow |
---|
| 12526 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12527 | + "MOV temp, pos;" + |
---|
| 12528 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12529 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12530 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12531 | + |
---|
| 12532 | + // No shadow when out of frustum |
---|
| 12533 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12534 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12535 | + |
---|
| 12536 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12537 | + |
---|
| 12538 | + // Backlit |
---|
| 12539 | + "MOV pos.w, zero123.y;" + |
---|
| 12540 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12541 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12542 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12543 | + Normalize("eye") + |
---|
| 12544 | + |
---|
| 12545 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12546 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12547 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12548 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12549 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12550 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12551 | + |
---|
| 12552 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12553 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12554 | + |
---|
| 12555 | + // Pigment |
---|
| 12556 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12557 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12558 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12559 | + |
---|
| 12560 | + "MUL temp, temp, zero123.z;" + |
---|
| 12561 | + |
---|
| 12562 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12563 | + |
---|
| 12564 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12565 | + "MOV result.color, temp;" + |
---|
| 12566 | + "END"; |
---|
| 12567 | + |
---|
| 12568 | + String programmax = |
---|
| 12569 | + "!!ARBfp1.0\n" + |
---|
| 12570 | + |
---|
11949 | 12571 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11950 | 12572 | "PARAM light2cam0 = program.env[10];" + |
---|
11951 | 12573 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12060 | 12682 | "TEMP shininess;" + |
---|
12061 | 12683 | "\n" + |
---|
12062 | 12684 | "MOV texSamp, one;" + |
---|
12063 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12064 | | - |
---|
| 12685 | + |
---|
12065 | 12686 | "MOV mapgrid.x, one2048th.x;" + |
---|
12066 | 12687 | "MOV temp, fragment.texcoord[1];" + |
---|
12067 | 12688 | /* |
---|
.. | .. |
---|
12082 | 12703 | "MUL temp, floor, mapgrid.x;" + |
---|
12083 | 12704 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12084 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12085 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12086 | 12707 | "") + |
---|
12087 | 12708 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12088 | 12709 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12089 | 12710 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12090 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12711 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12091 | 12712 | "") + |
---|
12092 | 12713 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12093 | 12714 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12094 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12715 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12095 | 12716 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12096 | 12717 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12097 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12098 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12099 | 12720 | "") + |
---|
12100 | 12721 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12101 | 12722 | //"MOV params, material;" + |
---|
.. | .. |
---|
12466 | 13087 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12467 | 13088 | "") + |
---|
12468 | 13089 | |
---|
12469 | | - // display shadow only (bump == 0) |
---|
| 13090 | + // display shadow only (fakedepth == 0) |
---|
12470 | 13091 | "SUB temp.x, half.x, shadow.x;" + |
---|
12471 | | - "MOV temp.y, -params6.x;" + |
---|
12472 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13092 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13093 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12473 | 13094 | "SUB temp.y, one.x, temp.z;" + |
---|
12474 | 13095 | "MUL temp.x, temp.x, temp.y;" + |
---|
12475 | 13096 | "KIL temp.x;" + |
---|
.. | .. |
---|
12598 | 13219 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12599 | 13220 | |
---|
12600 | 13221 | "SUB temp.x, one.x, ndotl.x;" + |
---|
12601 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
12602 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13222 | + // Tuning for default skin |
---|
| 13223 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13224 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13225 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12603 | 13226 | "MUL temp.x, temp.x, temp.y;" + |
---|
12604 | 13227 | |
---|
12605 | 13228 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12798 | 13421 | //once = true; |
---|
12799 | 13422 | } |
---|
12800 | 13423 | |
---|
12801 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
12802 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13424 | + String program = programmax; |
---|
| 13425 | + |
---|
| 13426 | + if (Globals.MINSHADER) |
---|
| 13427 | + { |
---|
| 13428 | + program = programmin; |
---|
| 13429 | + } |
---|
| 13430 | + |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
12803 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12804 | 13438 | |
---|
12805 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12846 | 13480 | "\n" + |
---|
12847 | 13481 | "END\n"; |
---|
12848 | 13482 | |
---|
12849 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
12850 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12851 | 13486 | |
---|
12852 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
12891 | 13526 | return out; |
---|
12892 | 13527 | } |
---|
12893 | 13528 | |
---|
12894 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13529 | + // Also does frustum culling |
---|
| 13530 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12895 | 13531 | { |
---|
12896 | 13532 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12897 | 13533 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12898 | 13534 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13535 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13536 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12899 | 13537 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12900 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12901 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12902 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12903 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13538 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13539 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12904 | 13540 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12905 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13541 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12906 | 13542 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12907 | 13543 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12908 | 13544 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12909 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13545 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12910 | 13546 | |
---|
12911 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12912 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13547 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13548 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12913 | 13549 | } |
---|
12914 | 13550 | |
---|
12915 | 13551 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12931 | 13567 | |
---|
12932 | 13568 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12933 | 13569 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13570 | + |
---|
| 13571 | + // Compare fragment depth in light space with shadowmap. |
---|
12934 | 13572 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12935 | 13573 | "SGE temp.y, temp.x, zero.x;" + |
---|
12936 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13574 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13575 | + |
---|
| 13576 | + // Reverse comparison |
---|
12937 | 13577 | "SUB temp.x, one.x, temp.x;" + |
---|
12938 | 13578 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12939 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13579 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12940 | 13580 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12941 | 13581 | |
---|
12942 | 13582 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12950 | 13590 | // No shadow for backface |
---|
12951 | 13591 | "DP3 temp.x, normal, lightd;" + |
---|
12952 | 13592 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13593 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13594 | + |
---|
| 13595 | + // No shadow when out of frustum |
---|
| 13596 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12953 | 13597 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12954 | 13598 | ""; |
---|
12955 | 13599 | } |
---|
.. | .. |
---|
13096 | 13740 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13097 | 13741 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13098 | 13742 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13099 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13743 | + |
---|
| 13744 | + //Object3D.cVector2[] vector2buffer; |
---|
13100 | 13745 | |
---|
13101 | 13746 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13102 | 13747 | // OUT : diff, spec |
---|
.. | .. |
---|
13112 | 13757 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13113 | 13758 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13114 | 13759 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13115 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13116 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13117 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13760 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13761 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13762 | + |
---|
| 13763 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13118 | 13764 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13119 | 13765 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13120 | 13766 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13508 | 14154 | public void mousePressed(MouseEvent e) |
---|
13509 | 14155 | { |
---|
13510 | 14156 | //System.out.println("mousePressed: " + e); |
---|
13511 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14157 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13512 | 14158 | } |
---|
13513 | 14159 | |
---|
13514 | 14160 | static long prevtime = 0; |
---|
.. | .. |
---|
13584 | 14230 | // mode |= META; |
---|
13585 | 14231 | //} |
---|
13586 | 14232 | |
---|
13587 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13588 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14233 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14234 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13589 | 14235 | anchorX = ax; |
---|
13590 | 14236 | anchorY = ay; |
---|
13591 | 14237 | prevX = px; |
---|
.. | .. |
---|
13619 | 14265 | else |
---|
13620 | 14266 | if (evt.getSource() == AAtimer) |
---|
13621 | 14267 | { |
---|
| 14268 | + Globals.TIMERRUNNING = false; |
---|
13622 | 14269 | if (mouseDown) |
---|
13623 | 14270 | { |
---|
13624 | 14271 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13644 | 14291 | // LIVE = waslive; |
---|
13645 | 14292 | // wasliveok = true; |
---|
13646 | 14293 | // waslive = false; |
---|
| 14294 | + |
---|
| 14295 | + // May 2019 Forget it: |
---|
| 14296 | + if (true) |
---|
| 14297 | + return; |
---|
13647 | 14298 | |
---|
13648 | 14299 | // source == timer |
---|
13649 | 14300 | if (mouseDown) |
---|
.. | .. |
---|
13674 | 14325 | |
---|
13675 | 14326 | // fev 2014??? |
---|
13676 | 14327 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13677 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14328 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13678 | 14329 | pingthread.StepToTarget(true); // true); |
---|
13679 | 14330 | } |
---|
13680 | 14331 | // if (!LIVE) |
---|
.. | .. |
---|
13683 | 14334 | |
---|
13684 | 14335 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13685 | 14336 | |
---|
13686 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14337 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13687 | 14338 | { |
---|
13688 | 14339 | if (!wasliveok) |
---|
13689 | 14340 | return; |
---|
13690 | 14341 | |
---|
13691 | 14342 | AAtimer.restart(); // |
---|
| 14343 | + Globals.TIMERRUNNING = true; |
---|
13692 | 14344 | |
---|
13693 | 14345 | // waslive = LIVE; |
---|
13694 | 14346 | // LIVE = false; |
---|
.. | .. |
---|
13700 | 14352 | // touched = true; // main DL |
---|
13701 | 14353 | if (isRenderer) |
---|
13702 | 14354 | { |
---|
13703 | | - SetMouseMode(modifiers); |
---|
| 14355 | + SetMouseMode(modifiers, modifiersex); |
---|
13704 | 14356 | } |
---|
13705 | 14357 | |
---|
13706 | 14358 | selectX = anchorX = x; |
---|
.. | .. |
---|
13713 | 14365 | clicked = true; |
---|
13714 | 14366 | hold = false; |
---|
13715 | 14367 | |
---|
13716 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14368 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13717 | 14369 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13718 | 14370 | { |
---|
13719 | 14371 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13738 | 14390 | drag = false; |
---|
13739 | 14391 | //System.out.println("Mouse DOWN"); |
---|
13740 | 14392 | editObj = false; |
---|
13741 | | - ClickInfo info = new ClickInfo(); |
---|
13742 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13743 | | - info.pane = this; |
---|
13744 | | - info.camera = renderCamera; |
---|
13745 | | - info.x = x; |
---|
13746 | | - info.y = y; |
---|
13747 | | - info.modifiers = modifiers; |
---|
13748 | | - editObj = object.doEditClick(info, 0); |
---|
| 14393 | + //ClickInfo info = new ClickInfo(); |
---|
| 14394 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14395 | + object.clickInfo.pane = this; |
---|
| 14396 | + object.clickInfo.camera = renderCamera; |
---|
| 14397 | + object.clickInfo.x = x; |
---|
| 14398 | + object.clickInfo.y = y; |
---|
| 14399 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14400 | + editObj = object.doEditClick(//info, |
---|
| 14401 | + 0); |
---|
13749 | 14402 | if (!editObj) |
---|
13750 | 14403 | { |
---|
13751 | 14404 | hasMarquee = true; |
---|
.. | .. |
---|
13761 | 14414 | |
---|
13762 | 14415 | public void mouseDragged(MouseEvent e) |
---|
13763 | 14416 | { |
---|
| 14417 | + Globals.MOUSEDRAGGED = true; |
---|
| 14418 | + |
---|
13764 | 14419 | //System.out.println("mouseDragged: " + e); |
---|
13765 | 14420 | if (isRenderer) |
---|
13766 | 14421 | movingcamera = true; |
---|
| 14422 | + |
---|
13767 | 14423 | //if (drawing) |
---|
13768 | 14424 | //return; |
---|
13769 | 14425 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
13773 | 14429 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13774 | 14430 | } |
---|
13775 | 14431 | else |
---|
13776 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14432 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13777 | 14433 | |
---|
13778 | 14434 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13779 | 14435 | } |
---|
.. | .. |
---|
13946 | 14602 | |
---|
13947 | 14603 | public void run() |
---|
13948 | 14604 | { |
---|
| 14605 | + new Exception().printStackTrace(); |
---|
13949 | 14606 | System.exit(0); |
---|
13950 | 14607 | for (;;) |
---|
13951 | 14608 | { |
---|
.. | .. |
---|
14009 | 14666 | { |
---|
14010 | 14667 | Globals.lighttouched = true; |
---|
14011 | 14668 | } |
---|
14012 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14669 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
14013 | 14670 | } |
---|
14014 | 14671 | //else |
---|
14015 | 14672 | } |
---|
.. | .. |
---|
14023 | 14680 | void GoDown(int mod) |
---|
14024 | 14681 | { |
---|
14025 | 14682 | MODIFIERS |= COMMAND; |
---|
14026 | | - /* |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14684 | + /**/ |
---|
14027 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
14028 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
14029 | 14692 | else |
---|
14030 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14031 | | - */ |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14694 | + /**/ |
---|
14032 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
14033 | 14696 | { |
---|
14034 | 14697 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14037 | 14700 | mouseMode |= BACKFORTH; |
---|
14038 | 14701 | } |
---|
14039 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
14040 | 14705 | //prevX = X = anchorX; |
---|
14041 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14042 | 14707 | } |
---|
.. | .. |
---|
14044 | 14709 | void GoUp(int mod) |
---|
14045 | 14710 | { |
---|
14046 | 14711 | MODIFIERS |= COMMAND; |
---|
14047 | | - /* |
---|
| 14712 | + /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
14048 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
14049 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
14050 | 14722 | else |
---|
14051 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14052 | | - */ |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 14724 | + /**/ |
---|
14053 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14054 | 14726 | { |
---|
14055 | 14727 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14058 | 14730 | mouseMode |= BACKFORTH; |
---|
14059 | 14731 | } |
---|
14060 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14061 | 14735 | //prevX = X = anchorX; |
---|
14062 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14063 | 14737 | } |
---|
.. | .. |
---|
14065 | 14739 | void GoLeft(int mod) |
---|
14066 | 14740 | { |
---|
14067 | 14741 | MODIFIERS |= COMMAND; |
---|
14068 | | - /* |
---|
| 14742 | + /**/ |
---|
14069 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
14070 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14071 | 14745 | else |
---|
14072 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14073 | | - */ |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
| 14752 | + /**/ |
---|
14074 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
14075 | 14754 | { |
---|
14076 | 14755 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14079 | 14758 | mouseMode |= ROTATE; |
---|
14080 | 14759 | } // TRANSLATE; |
---|
14081 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
14082 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14083 | 14764 | prevY = Y = anchorY; |
---|
14084 | 14765 | } |
---|
.. | .. |
---|
14086 | 14767 | void GoRight(int mod) |
---|
14087 | 14768 | { |
---|
14088 | 14769 | MODIFIERS |= COMMAND; |
---|
14089 | | - /* |
---|
| 14770 | + /**/ |
---|
14090 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
14091 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14092 | 14773 | else |
---|
14093 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14094 | | - */ |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
| 14781 | + /**/ |
---|
14095 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
14096 | 14783 | { |
---|
14097 | 14784 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14100 | 14787 | mouseMode |= ROTATE; |
---|
14101 | 14788 | } // TRANSLATE; |
---|
14102 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
14103 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14104 | 14793 | prevY = Y = anchorY; |
---|
14105 | 14794 | } |
---|
.. | .. |
---|
14109 | 14798 | int X, Y; |
---|
14110 | 14799 | boolean SX, SY; |
---|
14111 | 14800 | |
---|
14112 | | - void drag(int x, int y, int modifiers) |
---|
| 14801 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
14113 | 14802 | { |
---|
14114 | 14803 | if (IsFrozen()) |
---|
14115 | 14804 | { |
---|
.. | .. |
---|
14118 | 14807 | |
---|
14119 | 14808 | drag = true; // NEW |
---|
14120 | 14809 | |
---|
14121 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14810 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
14122 | 14811 | |
---|
14123 | 14812 | X = x; |
---|
14124 | 14813 | Y = y; |
---|
14125 | 14814 | // floating state for animation |
---|
14126 | | - MODIFIERS = modifiers; |
---|
14127 | | - modifiers &= ~1024; |
---|
| 14815 | + MODIFIERS = modifiersex; |
---|
| 14816 | + modifiersex &= ~1024; |
---|
14128 | 14817 | if (false) // modifiers != 0) |
---|
14129 | 14818 | { |
---|
14130 | 14819 | //new Exception().printStackTrace(); |
---|
14131 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14820 | + System.out.println("mouseDragged: " + modifiersex); |
---|
14132 | 14821 | System.out.println("SHIFT = " + SHIFT); |
---|
14133 | 14822 | System.out.println("CONTROL = " + COMMAND); |
---|
14134 | 14823 | System.out.println("META = " + META); |
---|
.. | .. |
---|
14141 | 14830 | if (editObj) |
---|
14142 | 14831 | { |
---|
14143 | 14832 | drag = true; |
---|
14144 | | - ClickInfo info = new ClickInfo(); |
---|
14145 | | - info.bounds.setBounds(0, 0, |
---|
| 14833 | + //ClickInfo info = new ClickInfo(); |
---|
| 14834 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14146 | 14835 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14147 | | - info.pane = this; |
---|
14148 | | - info.camera = renderCamera; |
---|
14149 | | - info.x = x; |
---|
14150 | | - info.y = y; |
---|
14151 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14836 | + object.clickInfo.pane = this; |
---|
| 14837 | + object.clickInfo.camera = renderCamera; |
---|
| 14838 | + object.clickInfo.x = x; |
---|
| 14839 | + object.clickInfo.y = y; |
---|
| 14840 | + object //.GetWindow().copy |
---|
| 14841 | + .doEditDrag(//info, |
---|
| 14842 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14152 | 14843 | } else |
---|
14153 | 14844 | { |
---|
14154 | 14845 | if (x < startX) |
---|
.. | .. |
---|
14297 | 14988 | } |
---|
14298 | 14989 | } |
---|
14299 | 14990 | |
---|
| 14991 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14992 | + |
---|
14300 | 14993 | public void mouseMoved(MouseEvent e) |
---|
14301 | 14994 | { |
---|
14302 | 14995 | //System.out.println("mouseMoved: " + e); |
---|
14303 | 14996 | if (isRenderer) |
---|
14304 | 14997 | return; |
---|
14305 | 14998 | |
---|
14306 | | - ClickInfo ci = new ClickInfo(); |
---|
14307 | | - ci.x = e.getX(); |
---|
14308 | | - ci.y = e.getY(); |
---|
14309 | | - ci.modifiers = e.getModifiersEx(); |
---|
14310 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14311 | | - ci.pane = this; |
---|
14312 | | - ci.camera = renderCamera; |
---|
| 14999 | + // Mouse cursor feedback |
---|
| 15000 | + object.clickInfo.x = e.getX(); |
---|
| 15001 | + object.clickInfo.y = e.getY(); |
---|
| 15002 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15003 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15004 | + object.clickInfo.pane = this; |
---|
| 15005 | + object.clickInfo.camera = renderCamera; |
---|
14313 | 15006 | if (!isRenderer) |
---|
14314 | 15007 | { |
---|
14315 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 15008 | + //ObjEditor editWindow = object.editWindow; |
---|
| 15009 | + //Object3D copy = editWindow.copy; |
---|
| 15010 | + if (object.doEditClick(//clickInfo, |
---|
| 15011 | + 0)) |
---|
14316 | 15012 | { |
---|
14317 | 15013 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14318 | 15014 | } else |
---|
.. | .. |
---|
14324 | 15020 | |
---|
14325 | 15021 | public void mouseReleased(MouseEvent e) |
---|
14326 | 15022 | { |
---|
| 15023 | + Globals.MOUSEDRAGGED = false; |
---|
| 15024 | + |
---|
14327 | 15025 | movingcamera = false; |
---|
| 15026 | + X = 0; // getBounds().width/2; |
---|
| 15027 | + Y = 0; // getBounds().height/2; |
---|
14328 | 15028 | //System.out.println("mouseReleased: " + e); |
---|
14329 | 15029 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14330 | 15030 | } |
---|
.. | .. |
---|
14347 | 15047 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
14348 | 15048 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
14349 | 15049 | |
---|
14350 | | - if (control || command || IsFrozen()) |
---|
| 15050 | +// No delay if (control || command || IsFrozen()) |
---|
14351 | 15051 | timeout = true; |
---|
14352 | | - else |
---|
| 15052 | +// ?? May 2019 else |
---|
14353 | 15053 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
14354 | 15054 | mouseDown = false; |
---|
14355 | 15055 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14459 | 15159 | System.out.println("keyReleased: " + e); |
---|
14460 | 15160 | } |
---|
14461 | 15161 | |
---|
14462 | | - void SetMouseMode(int modifiers) |
---|
| 15162 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14463 | 15163 | { |
---|
14464 | 15164 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14465 | 15165 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14471 | 15171 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14472 | 15172 | // return; |
---|
14473 | 15173 | //System.out.println("SetMode = " + modifiers); |
---|
14474 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 15174 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14475 | 15175 | { |
---|
14476 | 15176 | mouseMode |= ZOOM; |
---|
14477 | 15177 | } |
---|
14478 | 15178 | |
---|
14479 | 15179 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14480 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 15180 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14481 | 15181 | { |
---|
14482 | 15182 | mouseMode |= VR; // BACKFORTH; |
---|
14483 | 15183 | } |
---|
14484 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 15184 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14485 | 15185 | { |
---|
14486 | 15186 | mouseMode |= SELECT; |
---|
14487 | 15187 | } |
---|
14488 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 15188 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14489 | 15189 | { |
---|
14490 | 15190 | mouseMode |= SELECT; |
---|
14491 | 15191 | } |
---|
14492 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 15192 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14493 | 15193 | { |
---|
14494 | 15194 | mouseMode &= ~VR; |
---|
14495 | 15195 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14518 | 15218 | |
---|
14519 | 15219 | if (isRenderer) // |
---|
14520 | 15220 | { |
---|
14521 | | - SetMouseMode(modifiers); |
---|
| 15221 | + SetMouseMode(0, modifiers); |
---|
14522 | 15222 | } |
---|
14523 | 15223 | |
---|
14524 | 15224 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14580 | 15280 | // break; |
---|
14581 | 15281 | case 'T': |
---|
14582 | 15282 | CACHETEXTURE ^= true; |
---|
14583 | | - textures.clear(); |
---|
| 15283 | + texturepigment.clear(); |
---|
| 15284 | + texturebump.clear(); |
---|
14584 | 15285 | // repaint(); |
---|
14585 | 15286 | break; |
---|
14586 | 15287 | case 'Y': |
---|
.. | .. |
---|
14590 | 15291 | case 'K': |
---|
14591 | 15292 | KOMPACTTEXTURE ^= true; |
---|
14592 | 15293 | //textures.clear(); |
---|
14593 | | - break; |
---|
14594 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
14595 | 15296 | // SAVETEXTURE ^= true; |
---|
14596 | 15297 | macromode = true; |
---|
14597 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
14665 | 15366 | case 'E' : COMPACT ^= true; |
---|
14666 | 15367 | repaint(); |
---|
14667 | 15368 | break; |
---|
14668 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15369 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15370 | + //DEBUGHSB ^= true; |
---|
| 15371 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14669 | 15372 | repaint(); |
---|
14670 | 15373 | break; |
---|
14671 | 15374 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14690 | 15393 | RevertCamera(); |
---|
14691 | 15394 | repaint(); |
---|
14692 | 15395 | break; |
---|
14693 | | - case 'L': |
---|
14694 | 15396 | case 'l': |
---|
| 15397 | + //case 'L': |
---|
14695 | 15398 | if (lightMode) |
---|
14696 | 15399 | { |
---|
14697 | 15400 | lightMode = false; |
---|
.. | .. |
---|
14710 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
14711 | 15414 | repaint(); |
---|
14712 | 15415 | break; |
---|
14713 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
14714 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
14715 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
14716 | 15419 | repaint(); |
---|
.. | .. |
---|
14755 | 15458 | OCCLUSION_CULLING ^= true; |
---|
14756 | 15459 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14757 | 15460 | break; |
---|
14758 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15461 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14759 | 15462 | case '1': |
---|
14760 | 15463 | case '2': |
---|
14761 | 15464 | case '3': |
---|
14762 | 15465 | case '4': |
---|
14763 | 15466 | case '5': |
---|
14764 | | - newenvy = Character.getNumericValue(key); |
---|
14765 | | - repaint(); |
---|
14766 | | - break; |
---|
14767 | 15467 | case '6': |
---|
14768 | 15468 | case '7': |
---|
14769 | 15469 | case '8': |
---|
14770 | 15470 | case '9': |
---|
14771 | | - BGcolor = (key - '6')/3.f; |
---|
| 15471 | + if (true) // envyoff) |
---|
| 15472 | + { |
---|
| 15473 | + BGcolor = (key - '1')/8.f; |
---|
| 15474 | + } |
---|
| 15475 | + else |
---|
| 15476 | + { |
---|
| 15477 | + //newenvy = Character.getNumericValue(key); |
---|
| 15478 | + } |
---|
14772 | 15479 | repaint(); |
---|
14773 | 15480 | break; |
---|
14774 | 15481 | case '!': |
---|
.. | .. |
---|
14834 | 15541 | case '_': |
---|
14835 | 15542 | kompactbit = 5; |
---|
14836 | 15543 | break; |
---|
14837 | | - case '+': |
---|
14838 | | - kompactbit = 6; |
---|
14839 | | - break; |
---|
| 15544 | +// case '+': |
---|
| 15545 | +// kompactbit = 6; |
---|
| 15546 | +// break; |
---|
14840 | 15547 | case ' ': |
---|
14841 | 15548 | lightMode ^= true; |
---|
14842 | 15549 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14848 | 15555 | case ESC: |
---|
14849 | 15556 | RENDERPROGRAM += 1; |
---|
14850 | 15557 | RENDERPROGRAM %= 3; |
---|
| 15558 | + |
---|
14851 | 15559 | repaint(); |
---|
14852 | 15560 | break; |
---|
14853 | 15561 | case 'Z': |
---|
14854 | 15562 | //RESIZETEXTURE ^= true; |
---|
14855 | 15563 | //break; |
---|
14856 | 15564 | case 'z': |
---|
14857 | | - RENDERSHADOW ^= true; |
---|
| 15565 | + Globals.RENDERSHADOW ^= true; |
---|
14858 | 15566 | Globals.lighttouched = true; |
---|
14859 | 15567 | repaint(); |
---|
14860 | 15568 | break; |
---|
.. | .. |
---|
14887 | 15595 | case DELETE: |
---|
14888 | 15596 | ClearSelection(); |
---|
14889 | 15597 | break; |
---|
14890 | | - /* |
---|
14891 | 15598 | case '+': |
---|
| 15599 | + |
---|
| 15600 | + /* |
---|
14892 | 15601 | //fontsize += 1; |
---|
14893 | 15602 | bbzoom *= 2; |
---|
14894 | 15603 | repaint(); |
---|
.. | .. |
---|
14905 | 15614 | case '=': |
---|
14906 | 15615 | IncDepth(); |
---|
14907 | 15616 | //fontsize += 1; |
---|
14908 | | - object.editWindow.refreshContents(true); |
---|
| 15617 | + object.GetWindow().refreshContents(true); |
---|
14909 | 15618 | maskbit = 6; |
---|
14910 | 15619 | break; |
---|
14911 | 15620 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14912 | 15621 | DecDepth(); |
---|
14913 | 15622 | maskbit = 5; |
---|
14914 | 15623 | //if(fontsize > 1) fontsize -= 1; |
---|
14915 | | - if (object.editWindow == null) |
---|
14916 | | - new Exception().printStackTrace(); |
---|
14917 | | - else |
---|
14918 | | - object.editWindow.refreshContents(true); |
---|
| 15624 | +// if (object.editWindow == null) |
---|
| 15625 | +// new Exception().printStackTrace(); |
---|
| 15626 | +// else |
---|
| 15627 | + object.GetWindow().refreshContents(true); |
---|
14919 | 15628 | break; |
---|
14920 | 15629 | case '{': |
---|
14921 | 15630 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14978 | 15687 | //mode = ROTATE; |
---|
14979 | 15688 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14980 | 15689 | { |
---|
14981 | | - SetMouseMode(modifiers); |
---|
| 15690 | + SetMouseMode(0, modifiers); |
---|
14982 | 15691 | } |
---|
14983 | 15692 | } |
---|
14984 | 15693 | |
---|
.. | .. |
---|
15114 | 15823 | { |
---|
15115 | 15824 | //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
15116 | 15825 | //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
15117 | | - if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
| 15826 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
15118 | 15827 | { |
---|
15119 | 15828 | mouseMoved(e); |
---|
15120 | 15829 | } else |
---|
.. | .. |
---|
15139 | 15848 | } |
---|
15140 | 15849 | */ |
---|
15141 | 15850 | |
---|
15142 | | - object.editWindow.EditSelection(); |
---|
| 15851 | + object.GetWindow().EditSelection(false); |
---|
15143 | 15852 | } |
---|
15144 | 15853 | |
---|
15145 | 15854 | void SelectParent() |
---|
15146 | 15855 | { |
---|
| 15856 | + new Exception().printStackTrace(); |
---|
15147 | 15857 | System.exit(0); |
---|
15148 | 15858 | Composite group = (Composite) object; |
---|
15149 | 15859 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
15155 | 15865 | { |
---|
15156 | 15866 | //selectees.remove(i); |
---|
15157 | 15867 | System.out.println("select parent of " + elem); |
---|
15158 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15868 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15159 | 15869 | } else |
---|
15160 | 15870 | { |
---|
15161 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15871 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15162 | 15872 | } |
---|
15163 | 15873 | |
---|
15164 | 15874 | first = false; |
---|
.. | .. |
---|
15167 | 15877 | |
---|
15168 | 15878 | void SelectChildren() |
---|
15169 | 15879 | { |
---|
| 15880 | + new Exception().printStackTrace(); |
---|
15170 | 15881 | System.exit(0); |
---|
15171 | 15882 | /* |
---|
15172 | 15883 | Composite group = (Composite) object; |
---|
.. | .. |
---|
15199 | 15910 | for (int j = 0; j < group.children.size(); j++) |
---|
15200 | 15911 | { |
---|
15201 | 15912 | elem = (Object3D) group.children.elementAt(j); |
---|
15202 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15913 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15203 | 15914 | first = false; |
---|
15204 | 15915 | } |
---|
15205 | 15916 | } else |
---|
15206 | 15917 | { |
---|
15207 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15918 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15208 | 15919 | } |
---|
15209 | 15920 | |
---|
15210 | 15921 | first = false; |
---|
.. | .. |
---|
15215 | 15926 | { |
---|
15216 | 15927 | //Composite group = (Composite) object; |
---|
15217 | 15928 | Object3D group = object; |
---|
15218 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15929 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15219 | 15930 | } |
---|
15220 | 15931 | |
---|
15221 | 15932 | void ResetTransform(int mask) |
---|
15222 | 15933 | { |
---|
15223 | 15934 | //Composite group = (Composite) object; |
---|
15224 | 15935 | Object3D group = object; |
---|
15225 | | - group.editWindow.ResetTransform(mask); |
---|
| 15936 | + group.GetWindow().ResetTransform(mask); |
---|
15226 | 15937 | } |
---|
15227 | 15938 | |
---|
15228 | 15939 | void FlipTransform() |
---|
15229 | 15940 | { |
---|
15230 | 15941 | //Composite group = (Composite) object; |
---|
15231 | 15942 | Object3D group = object; |
---|
15232 | | - group.editWindow.FlipTransform(); |
---|
| 15943 | + group.GetWindow().FlipTransform(); |
---|
15233 | 15944 | // group.editWindow.ReduceMesh(true); |
---|
15234 | 15945 | } |
---|
15235 | 15946 | |
---|
.. | .. |
---|
15237 | 15948 | { |
---|
15238 | 15949 | //Composite group = (Composite) object; |
---|
15239 | 15950 | Object3D group = object; |
---|
15240 | | - group.editWindow.PrintMemory(); |
---|
| 15951 | + group.GetWindow().PrintMemory(); |
---|
15241 | 15952 | // group.editWindow.ReduceMesh(true); |
---|
15242 | 15953 | } |
---|
15243 | 15954 | |
---|
.. | .. |
---|
15245 | 15956 | { |
---|
15246 | 15957 | //Composite group = (Composite) object; |
---|
15247 | 15958 | Object3D group = object; |
---|
15248 | | - group.editWindow.ResetCentroid(); |
---|
| 15959 | + group.GetWindow().ResetCentroid(); |
---|
15249 | 15960 | } |
---|
15250 | 15961 | |
---|
15251 | 15962 | void IncDepth() |
---|
.. | .. |
---|
15327 | 16038 | |
---|
15328 | 16039 | int width = getBounds().width; |
---|
15329 | 16040 | int height = getBounds().height; |
---|
15330 | | - ClickInfo info = new ClickInfo(); |
---|
15331 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15332 | 16041 | //Image img = CreateImage(width, height); |
---|
15333 | 16042 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 16043 | + |
---|
15334 | 16044 | Graphics gr = g; // img.getGraphics(); |
---|
| 16045 | + |
---|
15335 | 16046 | if (!hasMarquee) |
---|
15336 | 16047 | { |
---|
15337 | 16048 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15403 | 16114 | } |
---|
15404 | 16115 | if (object != null && !hasMarquee) |
---|
15405 | 16116 | { |
---|
| 16117 | + if (object.clickInfo == null) |
---|
| 16118 | + object.clickInfo = new ClickInfo(); |
---|
| 16119 | + ClickInfo info = object.clickInfo; |
---|
| 16120 | + //ClickInfo info = new ClickInfo(); |
---|
| 16121 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16122 | + |
---|
15406 | 16123 | if (isRenderer) |
---|
15407 | 16124 | { |
---|
15408 | | - info.flags++; |
---|
| 16125 | + object.clickInfo.flags++; |
---|
15409 | 16126 | double frameAspect = (double) width / (double) height; |
---|
15410 | 16127 | if (frameAspect > renderCamera.aspect) |
---|
15411 | 16128 | { |
---|
15412 | 16129 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15413 | | - info.bounds.width -= width - desired; |
---|
15414 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16130 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16131 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15415 | 16132 | } else |
---|
15416 | 16133 | { |
---|
15417 | 16134 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15418 | | - info.bounds.height -= height - desired; |
---|
15419 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16135 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16136 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15420 | 16137 | } |
---|
15421 | 16138 | } |
---|
15422 | | - info.g = gr; |
---|
15423 | | - info.camera = renderCamera; |
---|
| 16139 | + |
---|
| 16140 | + object.clickInfo.g = gr; |
---|
| 16141 | + object.clickInfo.camera = renderCamera; |
---|
15424 | 16142 | /* |
---|
15425 | 16143 | // Memory intensive (brep.verticescopy) |
---|
15426 | 16144 | if (!(object instanceof Composite)) |
---|
15427 | 16145 | object.draw(info, 0, false); // SLOW : |
---|
15428 | 16146 | */ |
---|
15429 | | - if (!isRenderer) |
---|
| 16147 | + if (!isRenderer) // && drag) |
---|
15430 | 16148 | { |
---|
15431 | | - object.drawEditHandles(info, 0); |
---|
| 16149 | + Grafreed.Assert(object != null); |
---|
| 16150 | + Grafreed.Assert(object.selection != null); |
---|
| 16151 | + if (object.selection.Size() > 0) |
---|
| 16152 | + { |
---|
| 16153 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16154 | + |
---|
| 16155 | + object.clickInfo.DX = 0; |
---|
| 16156 | + object.clickInfo.DY = 0; |
---|
| 16157 | + object.clickInfo.W = 1; |
---|
| 16158 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16159 | + { |
---|
| 16160 | + info.DX = X; |
---|
| 16161 | + if (X != 0) |
---|
| 16162 | + info.DX -= info.bounds.width/2; |
---|
| 16163 | + |
---|
| 16164 | + info.DY = Y; |
---|
| 16165 | + if (Y != 0) |
---|
| 16166 | + info.DY -= info.bounds.height/2; |
---|
| 16167 | + } |
---|
| 16168 | + |
---|
| 16169 | + object.drawEditHandles(//info, |
---|
| 16170 | + 0); |
---|
| 16171 | + |
---|
| 16172 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16173 | + { |
---|
| 16174 | + switch (hitSomething) |
---|
| 16175 | + { |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
| 16177 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16178 | + break; |
---|
| 16179 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16180 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16181 | + break; |
---|
| 16182 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16183 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16184 | + break; |
---|
| 16185 | + } |
---|
| 16186 | + |
---|
| 16187 | + } |
---|
| 16188 | + } |
---|
15432 | 16189 | } |
---|
15433 | 16190 | } |
---|
| 16191 | + |
---|
15434 | 16192 | if (isRenderer) |
---|
15435 | 16193 | { |
---|
15436 | 16194 | //gr.setColor(Color.black); |
---|
15437 | 16195 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15438 | 16196 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15439 | 16197 | } |
---|
| 16198 | + |
---|
15440 | 16199 | if (hasMarquee) |
---|
15441 | 16200 | { |
---|
15442 | 16201 | gr.setXORMode(Color.white); |
---|
15443 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
15444 | 16203 | if (!firstime) |
---|
15445 | 16204 | { |
---|
15446 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
15549 | 16308 | public boolean mouseDown(Event evt, int x, int y) |
---|
15550 | 16309 | { |
---|
15551 | 16310 | System.out.println("mouseDown: " + evt); |
---|
| 16311 | + System.exit(0); |
---|
15552 | 16312 | /* |
---|
15553 | 16313 | locked = true; |
---|
15554 | 16314 | drag = false; |
---|
.. | .. |
---|
15592 | 16352 | { |
---|
15593 | 16353 | keyPressed(0, modifiers); |
---|
15594 | 16354 | } |
---|
15595 | | - clickStart(x, y, modifiers); |
---|
| 16355 | + // clickStart(x, y, modifiers); |
---|
15596 | 16356 | return true; |
---|
15597 | 16357 | } |
---|
15598 | 16358 | |
---|
.. | .. |
---|
15710 | 16470 | { |
---|
15711 | 16471 | keyReleased(0, 0); |
---|
15712 | 16472 | } |
---|
15713 | | - drag(x, y, modifiers); |
---|
| 16473 | + drag(x, y, 0, modifiers); |
---|
15714 | 16474 | return true; |
---|
15715 | 16475 | } |
---|
15716 | 16476 | |
---|
.. | .. |
---|
15842 | 16602 | Object3D object; |
---|
15843 | 16603 | static Object3D trackedobject; |
---|
15844 | 16604 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15845 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16605 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15846 | 16606 | /*static*/ Camera eyeCamera; |
---|
15847 | 16607 | /*static*/ Camera lightCamera; |
---|
15848 | 16608 | int cameracount; |
---|
.. | .. |
---|
15906 | 16666 | private /*static*/ boolean firstime; |
---|
15907 | 16667 | private /*static*/ cVector newView = new cVector(); |
---|
15908 | 16668 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16669 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16670 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15909 | 16671 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15910 | 16672 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15911 | 16673 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15918 | 16680 | { |
---|
15919 | 16681 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15920 | 16682 | |
---|
| 16683 | + int usedsuf = 0; |
---|
| 16684 | + |
---|
15921 | 16685 | for (int i = 0; i < suffixes.length; i++) |
---|
15922 | 16686 | { |
---|
15923 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15924 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15925 | | - mipmapped, |
---|
15926 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15927 | | - if (data == null) |
---|
| 16687 | + String[] suffixe = suffixes; |
---|
| 16688 | + String[] fallback = suffixes2; |
---|
| 16689 | + String[] fallfallback = suffixes3; |
---|
| 16690 | + |
---|
| 16691 | + for (int c=usedsuf; --c>=0;) |
---|
15928 | 16692 | { |
---|
15929 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16693 | +// String[] temp = suffixe; |
---|
| 16694 | +// suffixe = fallback; |
---|
| 16695 | +// fallback = fallfallback; |
---|
| 16696 | +// fallfallback = temp; |
---|
15930 | 16697 | } |
---|
| 16698 | + |
---|
| 16699 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16700 | + TextureData data; |
---|
| 16701 | + |
---|
| 16702 | + try |
---|
| 16703 | + { |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e) |
---|
| 16709 | + { |
---|
| 16710 | + try |
---|
| 16711 | + { |
---|
| 16712 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16713 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16714 | + mipmapped, |
---|
| 16715 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16716 | + } |
---|
| 16717 | + catch (Exception e2) |
---|
| 16718 | + { |
---|
| 16719 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16720 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16721 | + mipmapped, |
---|
| 16722 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16723 | + } |
---|
| 16724 | + } |
---|
| 16725 | + |
---|
15931 | 16726 | //System.out.println("Target = " + targets[i]); |
---|
15932 | 16727 | cubemap.updateImage(data, targets[i]); |
---|
15933 | 16728 | } |
---|
15934 | 16729 | |
---|
15935 | 16730 | return cubemap; |
---|
15936 | 16731 | } |
---|
| 16732 | + |
---|
15937 | 16733 | int bigsphere = -1; |
---|
15938 | 16734 | |
---|
15939 | 16735 | float BGcolor = 0.5f; |
---|
15940 | 16736 | |
---|
15941 | | - private void DrawSkyBox(GL gl) |
---|
| 16737 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16738 | + |
---|
| 16739 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15942 | 16740 | { |
---|
15943 | | - if (envyoff || cubemap == null) |
---|
| 16741 | + if (//envyoff || |
---|
| 16742 | + WIREFRAME || |
---|
| 16743 | + cubemap == null) |
---|
15944 | 16744 | { |
---|
15945 | 16745 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15946 | 16746 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15955 | 16755 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15956 | 16756 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15957 | 16757 | gl.glLoadIdentity(); |
---|
| 16758 | + gl.glScalef(1,ratio,1); |
---|
15958 | 16759 | |
---|
| 16760 | +// colorV[0] = 2; |
---|
| 16761 | +// colorV[1] = 2; |
---|
| 16762 | +// colorV[2] = 2; |
---|
| 16763 | +// colorV[3] = 1; |
---|
| 16764 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16765 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16766 | +// |
---|
| 16767 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16768 | + |
---|
15959 | 16769 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15960 | 16770 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15961 | 16771 | |
---|
.. | .. |
---|
15987 | 16797 | { |
---|
15988 | 16798 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
15989 | 16799 | } |
---|
| 16800 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
15990 | 16801 | gl.glMultMatrixd(viewrot_1, 0); |
---|
15991 | 16802 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
15992 | 16803 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16027 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16028 | 16839 | |
---|
16029 | 16840 | cubemap.disable(); |
---|
16030 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
16031 | 16843 | if (CULLFACE) |
---|
16032 | 16844 | { |
---|
16033 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16127 | 16939 | cStatic.objectstack[materialdepth++] = checker; |
---|
16128 | 16940 | //System.out.println("material " + material); |
---|
16129 | 16941 | //Applet3D.tracein(this, selected); |
---|
16130 | | - vector2buffer = checker.projectedVertices; |
---|
| 16942 | + //vector2buffer = checker.projectedVertices; |
---|
16131 | 16943 | |
---|
16132 | 16944 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16133 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16945 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16134 | 16946 | |
---|
16135 | 16947 | materialdepth -= 1; |
---|
16136 | 16948 | if (materialdepth > 0) |
---|
16137 | 16949 | { |
---|
16138 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16139 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16950 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16951 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16140 | 16952 | } |
---|
16141 | 16953 | //checker.GetMaterial().opacity = 1f; |
---|
16142 | 16954 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16222 | 17034 | } |
---|
16223 | 17035 | } |
---|
16224 | 17036 | |
---|
| 17037 | + private Object3D GetFolder() |
---|
| 17038 | + { |
---|
| 17039 | + Object3D folder = object.GetWindow().copy; |
---|
| 17040 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17041 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17042 | + return folder; |
---|
| 17043 | + } |
---|
| 17044 | + |
---|
16225 | 17045 | class SelectBuffer implements GLEventListener |
---|
16226 | 17046 | { |
---|
16227 | 17047 | |
---|
.. | .. |
---|
16237 | 17057 | //new Exception().printStackTrace(); |
---|
16238 | 17058 | System.out.println("select buffer init"); |
---|
16239 | 17059 | // Use debug pipeline |
---|
16240 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17060 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16241 | 17061 | |
---|
16242 | 17062 | GL gl = drawable.getGL(); |
---|
16243 | 17063 | |
---|
.. | .. |
---|
16280 | 17100 | { |
---|
16281 | 17101 | if (!selection) |
---|
16282 | 17102 | { |
---|
| 17103 | + new Exception().printStackTrace(); |
---|
16283 | 17104 | System.exit(0); |
---|
16284 | 17105 | return; |
---|
16285 | 17106 | } |
---|
.. | .. |
---|
16300 | 17121 | |
---|
16301 | 17122 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16302 | 17123 | |
---|
| 17124 | + if (PAINTMODE) |
---|
| 17125 | + { |
---|
| 17126 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17127 | + { |
---|
| 17128 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17129 | + |
---|
| 17130 | + // Make what you paint not selectable. |
---|
| 17131 | + paintobj.ResetSelectable(); |
---|
| 17132 | + } |
---|
| 17133 | + } |
---|
| 17134 | + |
---|
16303 | 17135 | //int tmp = selection_view; |
---|
16304 | 17136 | //selection_view = -1; |
---|
16305 | 17137 | int temp = DrawMode(); |
---|
.. | .. |
---|
16311 | 17143 | // temp = DEFAULT; // patch for selection debug |
---|
16312 | 17144 | Globals.drawMode = temp; // WARNING |
---|
16313 | 17145 | |
---|
| 17146 | + if (PAINTMODE) |
---|
| 17147 | + { |
---|
| 17148 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17149 | + { |
---|
| 17150 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17151 | + |
---|
| 17152 | + // Revert. |
---|
| 17153 | + paintobj.RestoreSelectable(); |
---|
| 17154 | + } |
---|
| 17155 | + } |
---|
| 17156 | + |
---|
16314 | 17157 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16315 | 17158 | |
---|
16316 | 17159 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16358 | 17201 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16359 | 17202 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16360 | 17203 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17204 | + |
---|
| 17205 | + CreateSelectedPoint(); |
---|
16361 | 17206 | |
---|
16362 | 17207 | // Will fit the mesh !!! |
---|
16363 | 17208 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16407 | 17252 | 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])); |
---|
16408 | 17253 | } |
---|
16409 | 17254 | |
---|
16410 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17255 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16411 | 17256 | } |
---|
16412 | 17257 | } |
---|
16413 | 17258 | |
---|
16414 | 17259 | if (!movingcamera && !PAINTMODE) |
---|
16415 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17260 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16416 | 17261 | |
---|
16417 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17262 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16418 | 17263 | { |
---|
16419 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17264 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16420 | 17265 | |
---|
16421 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17266 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17267 | + { |
---|
| 17268 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16422 | 17269 | |
---|
16423 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16424 | | - |
---|
16425 | | - group.add(paintobj); // link |
---|
16426 | | - |
---|
16427 | | - object.editWindow.SnapObject(group); |
---|
16428 | | - |
---|
16429 | | - Object3D folder = object.editWindow.copy; |
---|
16430 | | - |
---|
16431 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16432 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16433 | | - |
---|
16434 | | - folder.add(group); |
---|
16435 | | - |
---|
16436 | | - object.editWindow.ResetModel(); |
---|
16437 | | - object.editWindow.refreshContents(); |
---|
| 17270 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17271 | + |
---|
| 17272 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17273 | + |
---|
| 17274 | + inst.add(paintobj); // link |
---|
| 17275 | + |
---|
| 17276 | + object.GetWindow().SnapObject(inst); |
---|
| 17277 | + |
---|
| 17278 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17279 | + |
---|
| 17280 | + folder.add(inst); |
---|
| 17281 | + |
---|
| 17282 | + object.GetWindow().ResetModel(); |
---|
| 17283 | + object.GetWindow().refreshContents(); |
---|
| 17284 | + } |
---|
16438 | 17285 | } |
---|
16439 | 17286 | else |
---|
16440 | 17287 | paintcount = 0; |
---|
.. | .. |
---|
16473 | 17320 | //System.out.println("objects[color] = " + objects[color]); |
---|
16474 | 17321 | //objects[color].Select(); |
---|
16475 | 17322 | indexcount = 0; |
---|
| 17323 | + ObjEditor window = object.GetWindow(); |
---|
| 17324 | + if (window != null && deselect) |
---|
| 17325 | + { |
---|
| 17326 | + window.Select(null, deselect, true); |
---|
| 17327 | + } |
---|
16476 | 17328 | object.Select(color, deselect); |
---|
16477 | 17329 | } |
---|
16478 | 17330 | |
---|
.. | .. |
---|
16523 | 17375 | |
---|
16524 | 17376 | public void init(GLAutoDrawable drawable) |
---|
16525 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
16526 | 17379 | System.out.println("shadow buffer init"); |
---|
16527 | 17380 | |
---|
16528 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
16572 | 17425 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16573 | 17426 | } |
---|
16574 | 17427 | |
---|
16575 | | - if (!RENDERSHADOW) |
---|
| 17428 | + if (!Globals.RENDERSHADOW) |
---|
16576 | 17429 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16577 | 17430 | |
---|
16578 | 17431 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16582 | 17435 | //gl.glColorMask(false, false, false, false); |
---|
16583 | 17436 | |
---|
16584 | 17437 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16585 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17438 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16586 | 17439 | { |
---|
16587 | 17440 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16588 | 17441 | |
---|
.. | .. |
---|
16751 | 17604 | gl.glFlush(); |
---|
16752 | 17605 | |
---|
16753 | 17606 | /**/ |
---|
16754 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
16755 | 17608 | |
---|
16756 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
16757 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
16758 | 17615 | double r = 0, g = 0, b = 0; |
---|
16759 | 17616 | |
---|
16760 | 17617 | double count = 0; |
---|
.. | .. |
---|
16765 | 17622 | |
---|
16766 | 17623 | double FACTOR = 1; |
---|
16767 | 17624 | |
---|
16768 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
16769 | 17626 | { |
---|
16770 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
16771 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
16848 | 17705 | |
---|
16849 | 17706 | double scale = ray.z; // 1; // cos |
---|
16850 | 17707 | |
---|
16851 | | - float depth = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
16852 | 17709 | |
---|
16853 | 17710 | /* |
---|
16854 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
16998 | 17855 | int AAbuffersize = 0; |
---|
16999 | 17856 | |
---|
17000 | 17857 | //double[] selectedpoint = new double[3]; |
---|
17001 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17858 | + static Superellipsoid selectedpoint; |
---|
17002 | 17859 | static Sphere previousselectedpoint = null; |
---|
17003 | | - static Sphere debugpointG = new Sphere(); |
---|
17004 | | - static Sphere debugpointP = new Sphere(); |
---|
17005 | | - static Sphere debugpointC = new Sphere(); |
---|
17006 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17860 | + static Sphere debugpointG; |
---|
| 17861 | + static Sphere debugpointP; |
---|
| 17862 | + static Sphere debugpointC; |
---|
| 17863 | + static Sphere debugpointR; |
---|
17007 | 17864 | |
---|
17008 | 17865 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17009 | 17866 | |
---|
17010 | | - static |
---|
17011 | | - { |
---|
17012 | | - for (int i=0; i<8; i++) |
---|
17013 | | - { |
---|
17014 | | - debugpoints[i] = new Sphere(); |
---|
17015 | | - } |
---|
17016 | | - } |
---|
17017 | | - |
---|
17018 | 17867 | static void InitPoints(float radius) |
---|
17019 | 17868 | { |
---|
17020 | 17869 | for (int i=0; i<8; i++) |
---|
.. | .. |
---|
17053 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17054 | 17903 | static IntBuffer bigAAbuffer; |
---|
17055 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17056 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17057 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17058 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17059 | 17908 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17060 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
17061 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17062 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17063 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|