.. | .. |
---|
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; |
---|
.. | .. |
---|
61 | 97 | //boolean REDUCETEXTURE = true; |
---|
62 | 98 | boolean CACHETEXTURE = true; |
---|
63 | 99 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
65 | 101 | boolean COMPRESSTEXTURE = false; |
---|
66 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
149 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 190 | |
---|
153 | 191 | void SetAsGLRenderer(boolean b) |
---|
154 | 192 | { |
---|
.. | .. |
---|
325 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
326 | 364 | //System.out.println("material " + material); |
---|
327 | 365 | //Applet3D.tracein(this, selected); |
---|
328 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
329 | 367 | if (obj instanceof Camera) |
---|
330 | 368 | { |
---|
331 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
334 | 372 | display.options1[2] = material.shadowbias; |
---|
335 | 373 | display.options1[3] = material.aniso; |
---|
336 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
337 | 380 | display.options2[0] = material.opacity; |
---|
338 | 381 | display.options2[1] = material.diffuse; |
---|
339 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
340 | 386 | |
---|
341 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
342 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
343 | 392 | display.options4[1] = material.subsurface; |
---|
344 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
345 | 397 | |
---|
346 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
347 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
357 | 409 | /**/ |
---|
358 | 410 | } else |
---|
359 | 411 | { |
---|
360 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
361 | 413 | } |
---|
362 | 414 | } else |
---|
363 | 415 | { |
---|
.. | .. |
---|
381 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
382 | 434 | //System.out.println("material " + material); |
---|
383 | 435 | //Applet3D.tracein("selected ", selected); |
---|
384 | | - display.vector2buffer = obj.projectedVertices; |
---|
385 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
386 | 438 | } |
---|
387 | 439 | } |
---|
388 | 440 | |
---|
.. | .. |
---|
399 | 451 | materialdepth -= 1; |
---|
400 | 452 | if (materialdepth > 0) |
---|
401 | 453 | { |
---|
402 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
403 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
404 | 456 | } |
---|
405 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
406 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
420 | 472 | materialdepth -= 1; |
---|
421 | 473 | if (materialdepth > 0) |
---|
422 | 474 | { |
---|
423 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
424 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
425 | 477 | } |
---|
426 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
427 | 479 | //else |
---|
.. | .. |
---|
462 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 515 | { |
---|
464 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
466 | 520 | if (!hasnorm) |
---|
467 | 521 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
469 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1244 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1245 | } |
---|
1192 | 1246 | } |
---|
| 1247 | + |
---|
1193 | 1248 | if (flipV) |
---|
1194 | 1249 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1250 | else |
---|
1196 | 1251 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
1197 | 1253 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1254 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1255 | |
---|
.. | .. |
---|
1213 | 1269 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1270 | } |
---|
1215 | 1271 | } |
---|
| 1272 | + |
---|
1216 | 1273 | if (flipV) |
---|
1217 | 1274 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1275 | else |
---|
1219 | 1276 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
1220 | 1278 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1279 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1280 | |
---|
.. | .. |
---|
1244 | 1302 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1303 | else |
---|
1246 | 1304 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
1247 | 1306 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1307 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
1249 | 1309 | count2 += 2; |
---|
1250 | 1310 | count3 += 3; |
---|
1251 | 1311 | } |
---|
.. | .. |
---|
1601 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1602 | 1662 | } |
---|
1603 | 1663 | |
---|
1604 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1605 | 1665 | { |
---|
1606 | 1666 | CameraPane display = this; |
---|
1607 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1628 | 1688 | |
---|
1629 | 1689 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1630 | 1690 | |
---|
1631 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
1632 | 1692 | |
---|
1633 | 1693 | /**/ |
---|
1634 | 1694 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1636 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1637 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1638 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1639 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
1640 | 1700 | |
---|
1641 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1642 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1744 | 1804 | display.modelParams7[2] = 0; |
---|
1745 | 1805 | display.modelParams7[3] = 0; |
---|
1746 | 1806 | |
---|
1747 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1748 | 1808 | |
---|
1749 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1750 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1751 | 1811 | { |
---|
1752 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1888 | 1948 | void PushMatrix(double[][] matrix) |
---|
1889 | 1949 | { |
---|
1890 | 1950 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1892 | 1952 | } |
---|
1893 | 1953 | |
---|
1894 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
2042 | 2102 | //System.err.println("Oeil on"); |
---|
2043 | 2103 | OEIL = true; |
---|
2044 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2045 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2046 | 2106 | //pingthread.StepToTarget(true); |
---|
2047 | 2107 | } |
---|
2048 | 2108 | |
---|
.. | .. |
---|
2140 | 2200 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
2141 | 2201 | |
---|
2142 | 2202 | if (!Globals.isLIVE()) // save sound |
---|
2143 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2203 | + Grafreed.savesound = true; // wav.save(); |
---|
2144 | 2204 | // else |
---|
2145 | 2205 | repaint(); // start loop // may 2013 |
---|
2146 | 2206 | } |
---|
.. | .. |
---|
2257 | 2317 | |
---|
2258 | 2318 | void ToggleDebug() |
---|
2259 | 2319 | { |
---|
2260 | | - DEBUG ^= true; |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
2261 | 2321 | } |
---|
2262 | 2322 | |
---|
2263 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
2265 | 2325 | LOOKAT ^= true; |
---|
2266 | 2326 | } |
---|
2267 | 2327 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
2269 | 2329 | { |
---|
2270 | 2330 | SWITCH ^= true; |
---|
2271 | 2331 | } |
---|
.. | .. |
---|
2275 | 2335 | HANDLES ^= true; |
---|
2276 | 2336 | } |
---|
2277 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2278 | 2340 | void TogglePaint() |
---|
2279 | 2341 | { |
---|
2280 | 2342 | PAINTMODE ^= true; |
---|
2281 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2282 | 2349 | } |
---|
2283 | 2350 | |
---|
2284 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2374 | 2441 | { |
---|
2375 | 2442 | return currentGL; |
---|
2376 | 2443 | } |
---|
2377 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2378 | 2460 | /**/ |
---|
2379 | 2461 | class CacheTexture |
---|
2380 | 2462 | { |
---|
.. | .. |
---|
2383 | 2465 | |
---|
2384 | 2466 | int resolution; |
---|
2385 | 2467 | |
---|
2386 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2387 | 2469 | { |
---|
2388 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2389 | 2472 | resolution = res; |
---|
2390 | 2473 | } |
---|
2391 | 2474 | } |
---|
2392 | 2475 | /**/ |
---|
2393 | 2476 | |
---|
2394 | 2477 | // TEXTURE static Texture texture; |
---|
2395 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2396 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2397 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2398 | 2483 | int pigmentdepth = 0; |
---|
2399 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2400 | 2485 | int bumpdepth = 0; |
---|
2401 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2403 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2404 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2405 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2406 | 2491 | |
---|
2407 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2408 | 2493 | { |
---|
2409 | 2494 | TextureData texturedata = null; |
---|
2410 | 2495 | |
---|
.. | .. |
---|
2423 | 2508 | if (bump) |
---|
2424 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2425 | 2510 | |
---|
2426 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2427 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2428 | 2513 | |
---|
2429 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2430 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2431 | 2516 | |
---|
2432 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2433 | 2539 | } |
---|
2434 | 2540 | |
---|
2435 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3502 | 3608 | |
---|
3503 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3504 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3505 | 3613 | // |
---|
3506 | 3614 | if (false) // compressbit > 0) |
---|
3507 | 3615 | { |
---|
.. | .. |
---|
7900 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7901 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7902 | 8010 | |
---|
7903 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7904 | 8012 | { |
---|
7905 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7906 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7915 | 8023 | pigment = null; |
---|
7916 | 8024 | } |
---|
7917 | 8025 | |
---|
7918 | | - ReleaseTexture(bump, true); |
---|
7919 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7920 | 8028 | } |
---|
7921 | 8029 | |
---|
7922 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8031 | + { |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7923 | 8089 | { |
---|
7924 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7925 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7930 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7931 | 8097 | |
---|
7932 | 8098 | if (tex != null) |
---|
7933 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7934 | 8100 | |
---|
7935 | 8101 | // //assert( texture != null ); |
---|
7936 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8022 | 8188 | } |
---|
8023 | 8189 | } |
---|
8024 | 8190 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8191 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8192 | + { |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
| 8234 | + |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
| 8237 | + } |
---|
| 8238 | + |
---|
| 8239 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8240 | { |
---|
8027 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8242 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8033 | 8247 | if (tex == null) |
---|
8034 | 8248 | { |
---|
8035 | 8249 | BindTexture(null,false,resolution); |
---|
8036 | | - BindTexture(null,true,resolution); |
---|
8037 | 8250 | return; |
---|
8038 | 8251 | } |
---|
8039 | 8252 | |
---|
8040 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
8041 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8042 | 8287 | |
---|
8043 | | - usedtextures.put(pigment, pigment); |
---|
8044 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8045 | 8289 | |
---|
8046 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8047 | 8291 | { |
---|
8048 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8049 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8053 | 8297 | { |
---|
8054 | 8298 | bump = null; |
---|
8055 | 8299 | } |
---|
8056 | | - if (pigment.equals("")) |
---|
8057 | | - { |
---|
8058 | | - pigment = null; |
---|
8059 | | - } |
---|
8060 | 8300 | |
---|
8061 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8062 | | - BindTexture(pigment, false, resolution); |
---|
8063 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8064 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8065 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8066 | | - |
---|
8067 | | - return; // true; |
---|
8068 | 8304 | } |
---|
8069 | 8305 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
8071 | 8309 | { |
---|
8072 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8073 | 8329 | |
---|
8074 | 8330 | if (tex != null) |
---|
8075 | 8331 | { |
---|
8076 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8077 | 8334 | |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
8078 | 8342 | // String[] split = tex.split("Textures"); |
---|
8079 | 8343 | // if (split.length > 1) |
---|
8080 | 8344 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8345 | // else |
---|
8082 | 8346 | // if (!texname.startsWith("/")) |
---|
8083 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8085 | 8349 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8350 | + texname = fallbackTextureName; |
---|
8087 | 8351 | } |
---|
8088 | 8352 | |
---|
8089 | 8353 | if (CACHETEXTURE) |
---|
8090 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8091 | | - |
---|
8092 | | - TextureData texturedata = null; |
---|
8093 | | - |
---|
8094 | | - if (texture == null || texture.resolution < resolution) |
---|
8095 | 8354 | { |
---|
8096 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8097 | 8388 | { |
---|
8098 | 8389 | assert(!bump); |
---|
8099 | 8390 | // if (bump) |
---|
.. | .. |
---|
8104 | 8395 | // } |
---|
8105 | 8396 | // else |
---|
8106 | 8397 | // { |
---|
8107 | | - texture = textures.get(tex); |
---|
8108 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8109 | 8400 | { |
---|
8110 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8111 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8112 | 8405 | // } |
---|
8113 | 8406 | } else |
---|
8114 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8115 | 8408 | { |
---|
8116 | 8409 | assert(bump); |
---|
8117 | | - texture = textures.get(tex); |
---|
8118 | | - if (texture == null) |
---|
8119 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
8120 | 8415 | } else |
---|
8121 | 8416 | { |
---|
8122 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8124 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8125 | 8420 | //} else |
---|
8126 | 8421 | //{ |
---|
8127 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8128 | 8423 | { |
---|
8129 | | - texture = textures.get(tex); |
---|
8130 | | - if (texture == null) |
---|
8131 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
8132 | 8429 | } else |
---|
8133 | 8430 | { |
---|
8134 | 8431 | if (textureon) |
---|
.. | .. |
---|
8153 | 8450 | } |
---|
8154 | 8451 | |
---|
8155 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
8157 | 8454 | cachename = texname; |
---|
8158 | 8455 | else |
---|
8159 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8472 | } |
---|
8176 | 8473 | |
---|
8177 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
8179 | 8476 | cachename = texname; |
---|
8180 | 8477 | else |
---|
8181 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8184 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8482 | |
---|
8186 | 8483 | |
---|
8187 | | - if (texturedata != null) |
---|
8188 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8484 | + if (texturedata == null) |
---|
| 8485 | + throw new Exception(); |
---|
| 8486 | + |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8189 | 8488 | //texture = GetTexture(tex, bump); |
---|
8190 | 8489 | } |
---|
8191 | 8490 | } |
---|
8192 | 8491 | //} |
---|
8193 | 8492 | } |
---|
8194 | 8493 | |
---|
8195 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8196 | 8495 | { |
---|
8197 | 8496 | //return false; |
---|
8198 | 8497 | |
---|
8199 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8200 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8201 | 8500 | { |
---|
8202 | 8501 | // String ext = "_highres"; |
---|
8203 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8214 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8215 | 8514 | if (!cachefile.exists()) |
---|
8216 | 8515 | { |
---|
8217 | | - // cache to disk |
---|
8218 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8219 | | - //buffers[0]. |
---|
8220 | | - |
---|
8221 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8222 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8223 | | - |
---|
8224 | | - // squared size heuristic... |
---|
8225 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8226 | 8517 | { |
---|
8227 | | - for (int i=pixels.length; --i>=0;) |
---|
8228 | | - { |
---|
8229 | | - int i3 = i*3; |
---|
8230 | | - pixels[i] = 0xFF; |
---|
8231 | | - pixels[i] <<= 8; |
---|
8232 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8233 | | - pixels[i] <<= 8; |
---|
8234 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8235 | | - pixels[i] <<= 8; |
---|
8236 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8237 | | - } |
---|
8238 | | - |
---|
8239 | | - /* |
---|
8240 | | - int r=0,g=0,b=0,a=0; |
---|
8241 | | - for (int i=0; i<width; i++) |
---|
8242 | | - for (int j=0; j<height; j++) |
---|
8243 | | - { |
---|
8244 | | - int index = j*width+i; |
---|
8245 | | - int p = pixels[index]; |
---|
8246 | | - a = ((p>>24) & 0xFF); |
---|
8247 | | - r = ((p>>16) & 0xFF); |
---|
8248 | | - g = ((p>>8) & 0xFF); |
---|
8249 | | - b = (p & 0xFF); |
---|
8250 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8251 | | - } |
---|
8252 | | - /**/ |
---|
8253 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8254 | | - int height = width; |
---|
8255 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8256 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8257 | 8520 | ImageWriter writer = null; |
---|
8258 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8259 | 8522 | if (iter.hasNext()) { |
---|
8260 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8261 | 8524 | } |
---|
8262 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8263 | 8527 | try |
---|
8264 | 8528 | { |
---|
8265 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8276 | 8540 | } |
---|
8277 | 8541 | } |
---|
8278 | 8542 | } |
---|
8279 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8280 | 8546 | //System.out.println("Texture = " + tex); |
---|
8281 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8282 | 8548 | { |
---|
8283 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8284 | 8550 | thetex.texture.disable(); |
---|
8285 | 8551 | thetex.texture.dispose(); |
---|
8286 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8287 | 8553 | } |
---|
8288 | 8554 | |
---|
8289 | | - texture.texturedata = texturedata; |
---|
8290 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8291 | 8557 | |
---|
8292 | 8558 | // newtex = true; |
---|
8293 | 8559 | } |
---|
.. | .. |
---|
8303 | 8569 | } |
---|
8304 | 8570 | } |
---|
8305 | 8571 | |
---|
8306 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8307 | 8573 | } |
---|
8308 | 8574 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8610 | { |
---|
8311 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8612 | |
---|
.. | .. |
---|
8324 | 8624 | return texture!=null?texture.texture:null; |
---|
8325 | 8625 | } |
---|
8326 | 8626 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8628 | { |
---|
8329 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8630 | |
---|
8331 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8632 | } |
---|
8333 | 8633 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8635 | { |
---|
8336 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8637 | { |
---|
8338 | 8638 | return false; |
---|
8339 | 8639 | } |
---|
8340 | 8640 | |
---|
8341 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8342 | 8642 | |
---|
8343 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8344 | 8644 | |
---|
.. | .. |
---|
8370 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8371 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8372 | 8672 | |
---|
8373 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8374 | 8674 | } |
---|
8375 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8376 | 8742 | ShadowBuffer shadowPBuf; |
---|
8377 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8378 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
9208 | 9574 | jy8[3] = 0.5f; |
---|
9209 | 9575 | } |
---|
9210 | 9576 | |
---|
9211 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9212 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9213 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9214 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9215 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
9216 | 9606 | static int imagecount = 0; // movie generation |
---|
9217 | 9607 | |
---|
9218 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
9308 | 9698 | assert (parentcam != renderCamera); |
---|
9309 | 9699 | |
---|
9310 | 9700 | if (renderCamera != lightCamera) |
---|
9311 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9312 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9313 | 9703 | |
---|
9314 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9315 | 9705 | |
---|
.. | .. |
---|
9324 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9325 | 9715 | |
---|
9326 | 9716 | if (renderCamera != lightCamera) |
---|
9327 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9328 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9329 | 9719 | |
---|
9330 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9331 | 9721 | |
---|
.. | .. |
---|
9542 | 9932 | |
---|
9543 | 9933 | if (!BOXMODE) |
---|
9544 | 9934 | { |
---|
9545 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9935 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9546 | 9936 | } |
---|
9547 | 9937 | |
---|
9548 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
9580 | 9970 | ABORTED = false; |
---|
9581 | 9971 | } |
---|
9582 | 9972 | else |
---|
9583 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9584 | 9974 | |
---|
9585 | 9975 | if (false) |
---|
9586 | 9976 | { |
---|
.. | .. |
---|
10243 | 10633 | |
---|
10244 | 10634 | public void display(GLAutoDrawable drawable) |
---|
10245 | 10635 | { |
---|
10246 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
10247 | 10637 | { |
---|
10248 | | - GrafreeD.wav.save(); |
---|
10249 | | - GrafreeD.savesound = false; |
---|
10250 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
10251 | 10641 | } |
---|
10252 | 10642 | // if (DEBUG_SELECTION) |
---|
10253 | 10643 | // { |
---|
.. | .. |
---|
10323 | 10713 | ANTIALIAS = 0; |
---|
10324 | 10714 | //System.out.println("RESTART"); |
---|
10325 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
10326 | 10717 | } |
---|
10327 | 10718 | } |
---|
10328 | 10719 | } |
---|
.. | .. |
---|
10377 | 10768 | Object3D theobject = object; |
---|
10378 | 10769 | Object3D theparent = object.parent; |
---|
10379 | 10770 | object.parent = null; |
---|
10380 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
10381 | 10772 | object.Stripify(); |
---|
10382 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10383 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10390 | 10781 | ambientOcclusion = false; |
---|
10391 | 10782 | } |
---|
10392 | 10783 | |
---|
10393 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10394 | 10786 | { |
---|
10395 | 10787 | //if (RENDERSHADOW) // ? |
---|
10396 | 10788 | if (!IsFrozen()) |
---|
10397 | 10789 | { |
---|
10398 | 10790 | // dec 2012 |
---|
10399 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10400 | 10792 | { |
---|
10401 | 10793 | Globals.framecount++; |
---|
10402 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
10523 | 10915 | |
---|
10524 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10917 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10528 | 10920 | |
---|
10529 | 10921 | for (int j = 0; j < 4; j++) |
---|
10530 | 10922 | { |
---|
.. | .. |
---|
10538 | 10930 | |
---|
10539 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
10540 | 10932 | if (cam != lightCamera) |
---|
10541 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10542 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10543 | 10935 | |
---|
10544 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10545 | 10937 | |
---|
.. | .. |
---|
10798 | 11190 | // Bump noise |
---|
10799 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11193 | + |
---|
| 11194 | + try |
---|
| 11195 | + { |
---|
| 11196 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11197 | + } |
---|
| 11198 | + catch (Exception e) |
---|
| 11199 | + { |
---|
| 11200 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11201 | + } |
---|
| 11202 | + |
---|
10802 | 11203 | |
---|
10803 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10821 | 11222 | |
---|
10822 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10823 | 11224 | |
---|
10824 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10825 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10826 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10827 | 11228 | } else |
---|
10828 | 11229 | { |
---|
10829 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10834 | 11235 | //System.out.println("BLENDING ON"); |
---|
10835 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10836 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10837 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10838 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10839 | 11240 | gl.glLoadIdentity(); |
---|
10840 | 11241 | |
---|
.. | .. |
---|
10923 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10924 | 11325 | |
---|
10925 | 11326 | // if (cam != lightCamera) |
---|
10926 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10927 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10928 | 11329 | } |
---|
10929 | 11330 | |
---|
10930 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10945 | 11346 | if (true) // TODO |
---|
10946 | 11347 | { |
---|
10947 | 11348 | if (cam != lightCamera) |
---|
10948 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10949 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10950 | 11351 | } |
---|
10951 | 11352 | |
---|
10952 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11083 | 11484 | } |
---|
11084 | 11485 | } |
---|
11085 | 11486 | |
---|
11086 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11087 | 11488 | { |
---|
11088 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11089 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11091 | 11492 | |
---|
11092 | 11493 | boolean texon = textureon; |
---|
11093 | 11494 | |
---|
11094 | | - if (RENDERPROGRAM > 0) |
---|
11095 | | - { |
---|
11096 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11097 | | - textureon = false; |
---|
11098 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11099 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11100 | 11499 | //System.out.println("ALLO"); |
---|
11101 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11102 | 11501 | DrawObject(gl); |
---|
11103 | | - if (RENDERPROGRAM > 0) |
---|
11104 | | - { |
---|
11105 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11106 | | - textureon = texon; |
---|
11107 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11108 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11109 | 11507 | |
---|
11110 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11111 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11112 | 11510 | } |
---|
11113 | 11511 | |
---|
11114 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11283 | 11681 | e.printStackTrace(); |
---|
11284 | 11682 | } |
---|
11285 | 11683 | |
---|
11286 | | - if (GrafreeD.RENDERME > 0) |
---|
11287 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
11288 | 11686 | |
---|
11289 | 11687 | Globals.ONESTEP = false; |
---|
11290 | 11688 | } |
---|
11291 | 11689 | |
---|
11292 | 11690 | static boolean zoomonce = false; |
---|
11293 | 11691 | |
---|
| 11692 | + static void CreateSelectedPoint() |
---|
| 11693 | + { |
---|
| 11694 | + if (selectedpoint == null) |
---|
| 11695 | + { |
---|
| 11696 | + debugpointG = new Sphere(); |
---|
| 11697 | + debugpointP = new Sphere(); |
---|
| 11698 | + debugpointC = new Sphere(); |
---|
| 11699 | + debugpointR = new Sphere(); |
---|
| 11700 | + |
---|
| 11701 | + selectedpoint = new Superellipsoid(); |
---|
| 11702 | + |
---|
| 11703 | + for (int i=0; i<8; i++) |
---|
| 11704 | + { |
---|
| 11705 | + debugpoints[i] = new Sphere(); |
---|
| 11706 | + } |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + |
---|
11294 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
11295 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
11296 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11297 | 11716 | // DrawMode() = SELECTION; |
---|
11298 | 11717 | //GL gl = getGL(); |
---|
11299 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11300 | 11719 | { |
---|
11301 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11302 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11303 | 11722 | pingthread.StepToTarget(true); // true); |
---|
11304 | 11723 | // zoomonce = false; |
---|
11305 | 11724 | } |
---|
.. | .. |
---|
11354 | 11773 | |
---|
11355 | 11774 | usedtextures.clear(); |
---|
11356 | 11775 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11776 | + try |
---|
| 11777 | + { |
---|
| 11778 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11779 | + } |
---|
| 11780 | + catch (Exception e) |
---|
| 11781 | + { |
---|
| 11782 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11783 | + } |
---|
11358 | 11784 | } |
---|
11359 | 11785 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11364 | 11790 | |
---|
11365 | 11791 | if (DrawMode() == DEFAULT) |
---|
11366 | 11792 | { |
---|
11367 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
11368 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
11369 | 11796 | float radius = 0.05f; |
---|
11370 | 11797 | if (selectedpoint.radius != radius) |
---|
11371 | 11798 | { |
---|
.. | .. |
---|
11419 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11420 | 11847 | |
---|
11421 | 11848 | if (CLEANCACHE) |
---|
11422 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11423 | 11850 | { |
---|
11424 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11425 | 11852 | |
---|
11426 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11427 | 11854 | |
---|
11428 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11429 | 11856 | continue; |
---|
11430 | 11857 | |
---|
11431 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11432 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11433 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11434 | | - textures.get(tex).texture.dispose(); |
---|
11435 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
11436 | 11875 | } |
---|
11437 | 11876 | } |
---|
11438 | 11877 | } |
---|
.. | .. |
---|
11445 | 11884 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11885 | { |
---|
11447 | 11886 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11887 | + try |
---|
| 11888 | + { |
---|
| 11889 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11890 | + } |
---|
| 11891 | + catch (Exception e) |
---|
| 11892 | + { |
---|
| 11893 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11894 | + } |
---|
11449 | 11895 | // NEAREST |
---|
11450 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11897 | DrawChecker(gl); |
---|
.. | .. |
---|
11527 | 11973 | return; |
---|
11528 | 11974 | } |
---|
11529 | 11975 | |
---|
11530 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
11531 | 11977 | |
---|
11532 | 11978 | GL gl = GetGL(); |
---|
11533 | 11979 | |
---|
.. | .. |
---|
11844 | 12290 | //obj.TransformToWorld(light, light); |
---|
11845 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
11846 | 12292 | { |
---|
11847 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11848 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11849 | 12295 | } |
---|
11850 | 12296 | |
---|
11851 | 12297 | |
---|
.. | .. |
---|
11862 | 12308 | parentcam = cameras[0]; |
---|
11863 | 12309 | } |
---|
11864 | 12310 | |
---|
11865 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11866 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11867 | 12313 | |
---|
11868 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11869 | 12315 | |
---|
.. | .. |
---|
11954 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11955 | 12401 | |
---|
11956 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
11957 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12437 | + |
---|
| 12438 | + "MUL temp, temp, zero123.z;" + |
---|
| 12439 | + |
---|
| 12440 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12441 | + |
---|
| 12442 | + "MOV result.color, temp;" + |
---|
| 12443 | + "END"; |
---|
| 12444 | + |
---|
| 12445 | + String program2 = |
---|
| 12446 | + "!!ARBfp1.0\n" + |
---|
| 12447 | + |
---|
11958 | 12448 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11959 | 12449 | "PARAM light2cam0 = program.env[10];" + |
---|
11960 | 12450 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12069 | 12559 | "TEMP shininess;" + |
---|
12070 | 12560 | "\n" + |
---|
12071 | 12561 | "MOV texSamp, one;" + |
---|
12072 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12073 | | - |
---|
| 12562 | + |
---|
12074 | 12563 | "MOV mapgrid.x, one2048th.x;" + |
---|
12075 | 12564 | "MOV temp, fragment.texcoord[1];" + |
---|
12076 | 12565 | /* |
---|
.. | .. |
---|
12475 | 12964 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12476 | 12965 | "") + |
---|
12477 | 12966 | |
---|
12478 | | - // display shadow only (bump == 0) |
---|
| 12967 | + // display shadow only (fakedepth == 0) |
---|
12479 | 12968 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12969 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12970 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12482 | 12971 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 12972 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 12973 | "KIL temp.x;" + |
---|
.. | .. |
---|
12809 | 13298 | //once = true; |
---|
12810 | 13299 | } |
---|
12811 | 13300 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13301 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 13302 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 13303 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 13304 | |
---|
.. | .. |
---|
12942 | 13431 | |
---|
12943 | 13432 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 13433 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13434 | + |
---|
| 13435 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 13436 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 13437 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13438 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13439 | + |
---|
| 13440 | + // Reverse comparison |
---|
12948 | 13441 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 13442 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13443 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 13444 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 13445 | |
---|
12953 | 13446 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 13454 | // No shadow for backface |
---|
12962 | 13455 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 13456 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13457 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13458 | + |
---|
| 13459 | + // No shadow when out of frustum |
---|
| 13460 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 13461 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 13462 | ""; |
---|
12966 | 13463 | } |
---|
.. | .. |
---|
13107 | 13604 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13108 | 13605 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13109 | 13606 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13110 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13607 | + |
---|
| 13608 | + //Object3D.cVector2[] vector2buffer; |
---|
13111 | 13609 | |
---|
13112 | 13610 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13113 | 13611 | // OUT : diff, spec |
---|
.. | .. |
---|
13123 | 13621 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13124 | 13622 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13125 | 13623 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13126 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13127 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13128 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13624 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13625 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13626 | + |
---|
| 13627 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13129 | 13628 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13130 | 13629 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13131 | 13630 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13630 | 14129 | else |
---|
13631 | 14130 | if (evt.getSource() == AAtimer) |
---|
13632 | 14131 | { |
---|
| 14132 | + Globals.TIMERRUNNING = false; |
---|
13633 | 14133 | if (mouseDown) |
---|
13634 | 14134 | { |
---|
13635 | 14135 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13689 | 14189 | |
---|
13690 | 14190 | // fev 2014??? |
---|
13691 | 14191 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13692 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14192 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13693 | 14193 | pingthread.StepToTarget(true); // true); |
---|
13694 | 14194 | } |
---|
13695 | 14195 | // if (!LIVE) |
---|
.. | .. |
---|
13704 | 14204 | return; |
---|
13705 | 14205 | |
---|
13706 | 14206 | AAtimer.restart(); // |
---|
| 14207 | + Globals.TIMERRUNNING = true; |
---|
13707 | 14208 | |
---|
13708 | 14209 | // waslive = LIVE; |
---|
13709 | 14210 | // LIVE = false; |
---|
.. | .. |
---|
13776 | 14277 | |
---|
13777 | 14278 | public void mouseDragged(MouseEvent e) |
---|
13778 | 14279 | { |
---|
| 14280 | + Globals.MOUSEDRAGGED = true; |
---|
| 14281 | + |
---|
13779 | 14282 | //System.out.println("mouseDragged: " + e); |
---|
13780 | 14283 | if (isRenderer) |
---|
13781 | 14284 | movingcamera = true; |
---|
| 14285 | + |
---|
13782 | 14286 | //if (drawing) |
---|
13783 | 14287 | //return; |
---|
13784 | 14288 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14039 | 14543 | void GoDown(int mod) |
---|
14040 | 14544 | { |
---|
14041 | 14545 | MODIFIERS |= COMMAND; |
---|
14042 | | - /* |
---|
| 14546 | + /**/ |
---|
14043 | 14547 | if((mod&SHIFT) == SHIFT) |
---|
14044 | 14548 | manipCamera.RotatePosition(0, -speed); |
---|
14045 | 14549 | else |
---|
14046 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14047 | | - */ |
---|
| 14550 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14551 | + /**/ |
---|
14048 | 14552 | if ((mod & SHIFT) == SHIFT) |
---|
14049 | 14553 | { |
---|
14050 | 14554 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14060 | 14564 | void GoUp(int mod) |
---|
14061 | 14565 | { |
---|
14062 | 14566 | MODIFIERS |= COMMAND; |
---|
14063 | | - /* |
---|
| 14567 | + /**/ |
---|
14064 | 14568 | if((mod&SHIFT) == SHIFT) |
---|
14065 | 14569 | manipCamera.RotatePosition(0, speed); |
---|
14066 | 14570 | else |
---|
14067 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14068 | | - */ |
---|
| 14571 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14572 | + /**/ |
---|
14069 | 14573 | if ((mod & SHIFT) == SHIFT) |
---|
14070 | 14574 | { |
---|
14071 | 14575 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14081 | 14585 | void GoLeft(int mod) |
---|
14082 | 14586 | { |
---|
14083 | 14587 | MODIFIERS |= COMMAND; |
---|
14084 | | - /* |
---|
| 14588 | + /**/ |
---|
14085 | 14589 | if((mod&SHIFT) == SHIFT) |
---|
14086 | | - manipCamera.RotatePosition(speed, 0); |
---|
14087 | | - else |
---|
14088 | 14590 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14089 | | - */ |
---|
| 14591 | + else |
---|
| 14592 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14593 | + /**/ |
---|
14090 | 14594 | if ((mod & SHIFT) == SHIFT) |
---|
14091 | 14595 | { |
---|
14092 | 14596 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14102 | 14606 | void GoRight(int mod) |
---|
14103 | 14607 | { |
---|
14104 | 14608 | MODIFIERS |= COMMAND; |
---|
14105 | | - /* |
---|
| 14609 | + /**/ |
---|
14106 | 14610 | if((mod&SHIFT) == SHIFT) |
---|
14107 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14108 | | - else |
---|
14109 | 14611 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14110 | | - */ |
---|
| 14612 | + else |
---|
| 14613 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14614 | + /**/ |
---|
14111 | 14615 | if ((mod & SHIFT) == SHIFT) |
---|
14112 | 14616 | { |
---|
14113 | 14617 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14164 | 14668 | info.camera = renderCamera; |
---|
14165 | 14669 | info.x = x; |
---|
14166 | 14670 | info.y = y; |
---|
14167 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14671 | + object.GetWindow().copy |
---|
| 14672 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14168 | 14673 | } else |
---|
14169 | 14674 | { |
---|
14170 | 14675 | if (x < startX) |
---|
.. | .. |
---|
14328 | 14833 | ci.camera = renderCamera; |
---|
14329 | 14834 | if (!isRenderer) |
---|
14330 | 14835 | { |
---|
14331 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14836 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14837 | + //Object3D copy = editWindow.copy; |
---|
| 14838 | + if (object.doEditClick(ci, 0)) |
---|
14332 | 14839 | { |
---|
14333 | 14840 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14334 | 14841 | } else |
---|
.. | .. |
---|
14340 | 14847 | |
---|
14341 | 14848 | public void mouseReleased(MouseEvent e) |
---|
14342 | 14849 | { |
---|
| 14850 | + Globals.MOUSEDRAGGED = false; |
---|
| 14851 | + |
---|
14343 | 14852 | movingcamera = false; |
---|
| 14853 | + X = 0; // getBounds().width/2; |
---|
| 14854 | + Y = 0; // getBounds().height/2; |
---|
14344 | 14855 | //System.out.println("mouseReleased: " + e); |
---|
14345 | 14856 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14346 | 14857 | } |
---|
.. | .. |
---|
14596 | 15107 | // break; |
---|
14597 | 15108 | case 'T': |
---|
14598 | 15109 | CACHETEXTURE ^= true; |
---|
14599 | | - textures.clear(); |
---|
| 15110 | + texturepigment.clear(); |
---|
| 15111 | + texturebump.clear(); |
---|
14600 | 15112 | // repaint(); |
---|
14601 | 15113 | break; |
---|
14602 | 15114 | case 'Y': |
---|
.. | .. |
---|
14681 | 15193 | case 'E' : COMPACT ^= true; |
---|
14682 | 15194 | repaint(); |
---|
14683 | 15195 | break; |
---|
14684 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15196 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15197 | + //DEBUGHSB ^= true; |
---|
| 15198 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14685 | 15199 | repaint(); |
---|
14686 | 15200 | break; |
---|
14687 | 15201 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14706 | 15220 | RevertCamera(); |
---|
14707 | 15221 | repaint(); |
---|
14708 | 15222 | break; |
---|
14709 | | - case 'L': |
---|
14710 | 15223 | case 'l': |
---|
| 15224 | + //case 'L': |
---|
14711 | 15225 | if (lightMode) |
---|
14712 | 15226 | { |
---|
14713 | 15227 | lightMode = false; |
---|
.. | .. |
---|
14850 | 15364 | case '_': |
---|
14851 | 15365 | kompactbit = 5; |
---|
14852 | 15366 | break; |
---|
14853 | | - case '+': |
---|
14854 | | - kompactbit = 6; |
---|
14855 | | - break; |
---|
| 15367 | +// case '+': |
---|
| 15368 | +// kompactbit = 6; |
---|
| 15369 | +// break; |
---|
14856 | 15370 | case ' ': |
---|
14857 | 15371 | lightMode ^= true; |
---|
14858 | 15372 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14864 | 15378 | case ESC: |
---|
14865 | 15379 | RENDERPROGRAM += 1; |
---|
14866 | 15380 | RENDERPROGRAM %= 3; |
---|
| 15381 | + |
---|
14867 | 15382 | repaint(); |
---|
14868 | 15383 | break; |
---|
14869 | 15384 | case 'Z': |
---|
14870 | 15385 | //RESIZETEXTURE ^= true; |
---|
14871 | 15386 | //break; |
---|
14872 | 15387 | case 'z': |
---|
14873 | | - RENDERSHADOW ^= true; |
---|
| 15388 | + Globals.RENDERSHADOW ^= true; |
---|
14874 | 15389 | Globals.lighttouched = true; |
---|
14875 | 15390 | repaint(); |
---|
14876 | 15391 | break; |
---|
.. | .. |
---|
14903 | 15418 | case DELETE: |
---|
14904 | 15419 | ClearSelection(); |
---|
14905 | 15420 | break; |
---|
14906 | | - /* |
---|
14907 | 15421 | case '+': |
---|
| 15422 | + |
---|
| 15423 | + /* |
---|
14908 | 15424 | //fontsize += 1; |
---|
14909 | 15425 | bbzoom *= 2; |
---|
14910 | 15426 | repaint(); |
---|
.. | .. |
---|
14921 | 15437 | case '=': |
---|
14922 | 15438 | IncDepth(); |
---|
14923 | 15439 | //fontsize += 1; |
---|
14924 | | - object.editWindow.refreshContents(true); |
---|
| 15440 | + object.GetWindow().refreshContents(true); |
---|
14925 | 15441 | maskbit = 6; |
---|
14926 | 15442 | break; |
---|
14927 | 15443 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14928 | 15444 | DecDepth(); |
---|
14929 | 15445 | maskbit = 5; |
---|
14930 | 15446 | //if(fontsize > 1) fontsize -= 1; |
---|
14931 | | - if (object.editWindow == null) |
---|
14932 | | - new Exception().printStackTrace(); |
---|
14933 | | - else |
---|
14934 | | - object.editWindow.refreshContents(true); |
---|
| 15447 | +// if (object.editWindow == null) |
---|
| 15448 | +// new Exception().printStackTrace(); |
---|
| 15449 | +// else |
---|
| 15450 | + object.GetWindow().refreshContents(true); |
---|
14935 | 15451 | break; |
---|
14936 | 15452 | case '{': |
---|
14937 | 15453 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15155 | 15671 | } |
---|
15156 | 15672 | */ |
---|
15157 | 15673 | |
---|
15158 | | - object.editWindow.EditSelection(); |
---|
| 15674 | + object.GetWindow().EditSelection(false); |
---|
15159 | 15675 | } |
---|
15160 | 15676 | |
---|
15161 | 15677 | void SelectParent() |
---|
.. | .. |
---|
15172 | 15688 | { |
---|
15173 | 15689 | //selectees.remove(i); |
---|
15174 | 15690 | System.out.println("select parent of " + elem); |
---|
15175 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15691 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15176 | 15692 | } else |
---|
15177 | 15693 | { |
---|
15178 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15694 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15179 | 15695 | } |
---|
15180 | 15696 | |
---|
15181 | 15697 | first = false; |
---|
.. | .. |
---|
15217 | 15733 | for (int j = 0; j < group.children.size(); j++) |
---|
15218 | 15734 | { |
---|
15219 | 15735 | elem = (Object3D) group.children.elementAt(j); |
---|
15220 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15736 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15221 | 15737 | first = false; |
---|
15222 | 15738 | } |
---|
15223 | 15739 | } else |
---|
15224 | 15740 | { |
---|
15225 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15741 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15226 | 15742 | } |
---|
15227 | 15743 | |
---|
15228 | 15744 | first = false; |
---|
.. | .. |
---|
15233 | 15749 | { |
---|
15234 | 15750 | //Composite group = (Composite) object; |
---|
15235 | 15751 | Object3D group = object; |
---|
15236 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15752 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15237 | 15753 | } |
---|
15238 | 15754 | |
---|
15239 | 15755 | void ResetTransform(int mask) |
---|
15240 | 15756 | { |
---|
15241 | 15757 | //Composite group = (Composite) object; |
---|
15242 | 15758 | Object3D group = object; |
---|
15243 | | - group.editWindow.ResetTransform(mask); |
---|
| 15759 | + group.GetWindow().ResetTransform(mask); |
---|
15244 | 15760 | } |
---|
15245 | 15761 | |
---|
15246 | 15762 | void FlipTransform() |
---|
15247 | 15763 | { |
---|
15248 | 15764 | //Composite group = (Composite) object; |
---|
15249 | 15765 | Object3D group = object; |
---|
15250 | | - group.editWindow.FlipTransform(); |
---|
| 15766 | + group.GetWindow().FlipTransform(); |
---|
15251 | 15767 | // group.editWindow.ReduceMesh(true); |
---|
15252 | 15768 | } |
---|
15253 | 15769 | |
---|
.. | .. |
---|
15255 | 15771 | { |
---|
15256 | 15772 | //Composite group = (Composite) object; |
---|
15257 | 15773 | Object3D group = object; |
---|
15258 | | - group.editWindow.PrintMemory(); |
---|
| 15774 | + group.GetWindow().PrintMemory(); |
---|
15259 | 15775 | // group.editWindow.ReduceMesh(true); |
---|
15260 | 15776 | } |
---|
15261 | 15777 | |
---|
.. | .. |
---|
15263 | 15779 | { |
---|
15264 | 15780 | //Composite group = (Composite) object; |
---|
15265 | 15781 | Object3D group = object; |
---|
15266 | | - group.editWindow.ResetCentroid(); |
---|
| 15782 | + group.GetWindow().ResetCentroid(); |
---|
15267 | 15783 | } |
---|
15268 | 15784 | |
---|
15269 | 15785 | void IncDepth() |
---|
.. | .. |
---|
15349 | 15865 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15350 | 15866 | //Image img = CreateImage(width, height); |
---|
15351 | 15867 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15868 | + |
---|
15352 | 15869 | Graphics gr = g; // img.getGraphics(); |
---|
| 15870 | + |
---|
15353 | 15871 | if (!hasMarquee) |
---|
15354 | 15872 | { |
---|
15355 | 15873 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15437 | 15955 | info.bounds.y += (height - desired) / 2; |
---|
15438 | 15956 | } |
---|
15439 | 15957 | } |
---|
| 15958 | + |
---|
15440 | 15959 | info.g = gr; |
---|
15441 | 15960 | info.camera = renderCamera; |
---|
15442 | 15961 | /* |
---|
.. | .. |
---|
15446 | 15965 | */ |
---|
15447 | 15966 | if (!isRenderer) |
---|
15448 | 15967 | { |
---|
15449 | | - object.drawEditHandles(info, 0); |
---|
| 15968 | + Grafreed.Assert(object != null); |
---|
| 15969 | + Grafreed.Assert(object.selection != null); |
---|
| 15970 | + if (object.selection.Size() > 0) |
---|
| 15971 | + { |
---|
| 15972 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15973 | + |
---|
| 15974 | + info.DX = 0; |
---|
| 15975 | + info.DY = 0; |
---|
| 15976 | + info.W = 1; |
---|
| 15977 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15978 | + { |
---|
| 15979 | + info.DX = X; |
---|
| 15980 | + if (X != 0) |
---|
| 15981 | + info.DX -= info.bounds.width/2; |
---|
| 15982 | + |
---|
| 15983 | + info.DY = Y; |
---|
| 15984 | + if (Y != 0) |
---|
| 15985 | + info.DY -= info.bounds.height/2; |
---|
| 15986 | + } |
---|
| 15987 | + |
---|
| 15988 | + object.drawEditHandles(info, 0); |
---|
| 15989 | + |
---|
| 15990 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15991 | + { |
---|
| 15992 | + switch (hitSomething) |
---|
| 15993 | + { |
---|
| 15994 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15995 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15996 | + break; |
---|
| 15997 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15998 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15999 | + break; |
---|
| 16000 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16001 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16002 | + break; |
---|
| 16003 | + } |
---|
| 16004 | + |
---|
| 16005 | + } |
---|
| 16006 | + } |
---|
15450 | 16007 | } |
---|
15451 | 16008 | } |
---|
| 16009 | + |
---|
15452 | 16010 | if (isRenderer) |
---|
15453 | 16011 | { |
---|
15454 | 16012 | //gr.setColor(Color.black); |
---|
15455 | 16013 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15456 | 16014 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15457 | 16015 | } |
---|
| 16016 | + |
---|
15458 | 16017 | if (hasMarquee) |
---|
15459 | 16018 | { |
---|
15460 | 16019 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15861 | 16420 | Object3D object; |
---|
15862 | 16421 | static Object3D trackedobject; |
---|
15863 | 16422 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15864 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16423 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15865 | 16424 | /*static*/ Camera eyeCamera; |
---|
15866 | 16425 | /*static*/ Camera lightCamera; |
---|
15867 | 16426 | int cameracount; |
---|
.. | .. |
---|
16146 | 16705 | cStatic.objectstack[materialdepth++] = checker; |
---|
16147 | 16706 | //System.out.println("material " + material); |
---|
16148 | 16707 | //Applet3D.tracein(this, selected); |
---|
16149 | | - vector2buffer = checker.projectedVertices; |
---|
| 16708 | + //vector2buffer = checker.projectedVertices; |
---|
16150 | 16709 | |
---|
16151 | 16710 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16152 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16711 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16153 | 16712 | |
---|
16154 | 16713 | materialdepth -= 1; |
---|
16155 | 16714 | if (materialdepth > 0) |
---|
16156 | 16715 | { |
---|
16157 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16158 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16716 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16717 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16159 | 16718 | } |
---|
16160 | 16719 | //checker.GetMaterial().opacity = 1f; |
---|
16161 | 16720 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16241 | 16800 | } |
---|
16242 | 16801 | } |
---|
16243 | 16802 | |
---|
| 16803 | + private Object3D GetFolder() |
---|
| 16804 | + { |
---|
| 16805 | + Object3D folder = object.GetWindow().copy; |
---|
| 16806 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16807 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16808 | + return folder; |
---|
| 16809 | + } |
---|
| 16810 | + |
---|
16244 | 16811 | class SelectBuffer implements GLEventListener |
---|
16245 | 16812 | { |
---|
16246 | 16813 | |
---|
.. | .. |
---|
16320 | 16887 | |
---|
16321 | 16888 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16322 | 16889 | |
---|
| 16890 | + if (PAINTMODE) |
---|
| 16891 | + { |
---|
| 16892 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16893 | + { |
---|
| 16894 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16895 | + |
---|
| 16896 | + // Make what you paint not selectable. |
---|
| 16897 | + paintobj.ResetSelectable(); |
---|
| 16898 | + } |
---|
| 16899 | + } |
---|
| 16900 | + |
---|
16323 | 16901 | //int tmp = selection_view; |
---|
16324 | 16902 | //selection_view = -1; |
---|
16325 | 16903 | int temp = DrawMode(); |
---|
.. | .. |
---|
16331 | 16909 | // temp = DEFAULT; // patch for selection debug |
---|
16332 | 16910 | Globals.drawMode = temp; // WARNING |
---|
16333 | 16911 | |
---|
| 16912 | + if (PAINTMODE) |
---|
| 16913 | + { |
---|
| 16914 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16915 | + { |
---|
| 16916 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16917 | + |
---|
| 16918 | + // Revert. |
---|
| 16919 | + paintobj.RestoreSelectable(); |
---|
| 16920 | + } |
---|
| 16921 | + } |
---|
| 16922 | + |
---|
16334 | 16923 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16335 | 16924 | |
---|
16336 | 16925 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16378 | 16967 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16379 | 16968 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16380 | 16969 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16970 | + |
---|
| 16971 | + CreateSelectedPoint(); |
---|
16381 | 16972 | |
---|
16382 | 16973 | // Will fit the mesh !!! |
---|
16383 | 16974 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16427 | 17018 | 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])); |
---|
16428 | 17019 | } |
---|
16429 | 17020 | |
---|
16430 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 17021 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16431 | 17022 | } |
---|
16432 | 17023 | } |
---|
16433 | 17024 | |
---|
16434 | 17025 | if (!movingcamera && !PAINTMODE) |
---|
16435 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17026 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16436 | 17027 | |
---|
16437 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17028 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16438 | 17029 | { |
---|
16439 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17030 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16440 | 17031 | |
---|
16441 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17032 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17033 | + { |
---|
| 17034 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16442 | 17035 | |
---|
16443 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16444 | | - |
---|
16445 | | - group.add(paintobj); // link |
---|
16446 | | - |
---|
16447 | | - object.editWindow.SnapObject(group); |
---|
16448 | | - |
---|
16449 | | - Object3D folder = object.editWindow.copy; |
---|
16450 | | - |
---|
16451 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16452 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16453 | | - |
---|
16454 | | - folder.add(group); |
---|
16455 | | - |
---|
16456 | | - object.editWindow.ResetModel(); |
---|
16457 | | - object.editWindow.refreshContents(); |
---|
| 17036 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17037 | + |
---|
| 17038 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17039 | + |
---|
| 17040 | + inst.add(paintobj); // link |
---|
| 17041 | + |
---|
| 17042 | + object.GetWindow().SnapObject(inst); |
---|
| 17043 | + |
---|
| 17044 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17045 | + |
---|
| 17046 | + folder.add(inst); |
---|
| 17047 | + |
---|
| 17048 | + object.GetWindow().ResetModel(); |
---|
| 17049 | + object.GetWindow().refreshContents(); |
---|
| 17050 | + } |
---|
16458 | 17051 | } |
---|
16459 | 17052 | else |
---|
16460 | 17053 | paintcount = 0; |
---|
.. | .. |
---|
16493 | 17086 | //System.out.println("objects[color] = " + objects[color]); |
---|
16494 | 17087 | //objects[color].Select(); |
---|
16495 | 17088 | indexcount = 0; |
---|
| 17089 | + ObjEditor window = object.GetWindow(); |
---|
| 17090 | + if (window != null && deselect) |
---|
| 17091 | + { |
---|
| 17092 | + window.Select(null, deselect, true); |
---|
| 17093 | + } |
---|
16496 | 17094 | object.Select(color, deselect); |
---|
16497 | 17095 | } |
---|
16498 | 17096 | |
---|
.. | .. |
---|
16592 | 17190 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16593 | 17191 | } |
---|
16594 | 17192 | |
---|
16595 | | - if (!RENDERSHADOW) |
---|
| 17193 | + if (!Globals.RENDERSHADOW) |
---|
16596 | 17194 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16597 | 17195 | |
---|
16598 | 17196 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16602 | 17200 | //gl.glColorMask(false, false, false, false); |
---|
16603 | 17201 | |
---|
16604 | 17202 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16605 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17203 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16606 | 17204 | { |
---|
16607 | 17205 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16608 | 17206 | |
---|
.. | .. |
---|
17018 | 17616 | int AAbuffersize = 0; |
---|
17019 | 17617 | |
---|
17020 | 17618 | //double[] selectedpoint = new double[3]; |
---|
17021 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17619 | + static Superellipsoid selectedpoint; |
---|
17022 | 17620 | static Sphere previousselectedpoint = null; |
---|
17023 | | - static Sphere debugpointG = new Sphere(); |
---|
17024 | | - static Sphere debugpointP = new Sphere(); |
---|
17025 | | - static Sphere debugpointC = new Sphere(); |
---|
17026 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17621 | + static Sphere debugpointG; |
---|
| 17622 | + static Sphere debugpointP; |
---|
| 17623 | + static Sphere debugpointC; |
---|
| 17624 | + static Sphere debugpointR; |
---|
17027 | 17625 | |
---|
17028 | 17626 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17029 | 17627 | |
---|
17030 | | - static |
---|
17031 | | - { |
---|
17032 | | - for (int i=0; i<8; i++) |
---|
17033 | | - { |
---|
17034 | | - debugpoints[i] = new Sphere(); |
---|
17035 | | - } |
---|
17036 | | - } |
---|
17037 | | - |
---|
17038 | 17628 | static void InitPoints(float radius) |
---|
17039 | 17629 | { |
---|
17040 | 17630 | for (int i=0; i<8; i++) |
---|