.. | .. |
---|
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; |
---|
.. | .. |
---|
327 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
328 | 364 | //System.out.println("material " + material); |
---|
329 | 365 | //Applet3D.tracein(this, selected); |
---|
330 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
331 | 367 | if (obj instanceof Camera) |
---|
332 | 368 | { |
---|
333 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
336 | 372 | display.options1[2] = material.shadowbias; |
---|
337 | 373 | display.options1[3] = material.aniso; |
---|
338 | 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]); |
---|
339 | 380 | display.options2[0] = material.opacity; |
---|
340 | 381 | display.options2[1] = material.diffuse; |
---|
341 | 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]); |
---|
342 | 386 | |
---|
343 | 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]); |
---|
344 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
345 | 392 | display.options4[1] = material.subsurface; |
---|
346 | 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]); |
---|
347 | 397 | |
---|
348 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
349 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
359 | 409 | /**/ |
---|
360 | 410 | } else |
---|
361 | 411 | { |
---|
362 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
363 | 413 | } |
---|
364 | 414 | } else |
---|
365 | 415 | { |
---|
.. | .. |
---|
383 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
384 | 434 | //System.out.println("material " + material); |
---|
385 | 435 | //Applet3D.tracein("selected ", selected); |
---|
386 | | - display.vector2buffer = obj.projectedVertices; |
---|
387 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
388 | 438 | } |
---|
389 | 439 | } |
---|
390 | 440 | |
---|
.. | .. |
---|
401 | 451 | materialdepth -= 1; |
---|
402 | 452 | if (materialdepth > 0) |
---|
403 | 453 | { |
---|
404 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
405 | | - 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); |
---|
406 | 456 | } |
---|
407 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
408 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
422 | 472 | materialdepth -= 1; |
---|
423 | 473 | if (materialdepth > 0) |
---|
424 | 474 | { |
---|
425 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
426 | | - 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); |
---|
427 | 477 | } |
---|
428 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
429 | 479 | //else |
---|
.. | .. |
---|
464 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
465 | 515 | { |
---|
466 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
467 | | - 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 | + ; |
---|
468 | 520 | if (!hasnorm) |
---|
469 | 521 | { |
---|
470 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
471 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
472 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
473 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1192 | 1244 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1193 | 1245 | } |
---|
1194 | 1246 | } |
---|
| 1247 | + |
---|
1195 | 1248 | if (flipV) |
---|
1196 | 1249 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1197 | 1250 | else |
---|
1198 | 1251 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
1199 | 1253 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1200 | 1254 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1201 | 1255 | |
---|
.. | .. |
---|
1215 | 1269 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1216 | 1270 | } |
---|
1217 | 1271 | } |
---|
| 1272 | + |
---|
1218 | 1273 | if (flipV) |
---|
1219 | 1274 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1220 | 1275 | else |
---|
1221 | 1276 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
1222 | 1278 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1223 | 1279 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1224 | 1280 | |
---|
.. | .. |
---|
1246 | 1302 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1247 | 1303 | else |
---|
1248 | 1304 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
1249 | 1306 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1250 | 1307 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
1251 | 1309 | count2 += 2; |
---|
1252 | 1310 | count3 += 3; |
---|
1253 | 1311 | } |
---|
.. | .. |
---|
1603 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1604 | 1662 | } |
---|
1605 | 1663 | |
---|
1606 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1607 | 1665 | { |
---|
1608 | 1666 | CameraPane display = this; |
---|
1609 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1638 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1639 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1640 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1641 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
1642 | 1700 | |
---|
1643 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1644 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1746 | 1804 | display.modelParams7[2] = 0; |
---|
1747 | 1805 | display.modelParams7[3] = 0; |
---|
1748 | 1806 | |
---|
1749 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1750 | 1808 | |
---|
1751 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1752 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1753 | 1811 | { |
---|
1754 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1890 | 1948 | void PushMatrix(double[][] matrix) |
---|
1891 | 1949 | { |
---|
1892 | 1950 | // GrafreeD.tracein(matrix); |
---|
1893 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1894 | 1952 | } |
---|
1895 | 1953 | |
---|
1896 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
2044 | 2102 | //System.err.println("Oeil on"); |
---|
2045 | 2103 | OEIL = true; |
---|
2046 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2047 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2048 | 2106 | //pingthread.StepToTarget(true); |
---|
2049 | 2107 | } |
---|
2050 | 2108 | |
---|
.. | .. |
---|
2259 | 2317 | |
---|
2260 | 2318 | void ToggleDebug() |
---|
2261 | 2319 | { |
---|
2262 | | - DEBUG ^= true; |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
2263 | 2321 | } |
---|
2264 | 2322 | |
---|
2265 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
2277 | 2335 | HANDLES ^= true; |
---|
2278 | 2336 | } |
---|
2279 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2280 | 2340 | void TogglePaint() |
---|
2281 | 2341 | { |
---|
2282 | 2342 | PAINTMODE ^= true; |
---|
2283 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2284 | 2349 | } |
---|
2285 | 2350 | |
---|
2286 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2377 | 2442 | return currentGL; |
---|
2378 | 2443 | } |
---|
2379 | 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 | + |
---|
2380 | 2460 | /**/ |
---|
2381 | 2461 | class CacheTexture |
---|
2382 | 2462 | { |
---|
.. | .. |
---|
2385 | 2465 | |
---|
2386 | 2466 | int resolution; |
---|
2387 | 2467 | |
---|
2388 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2389 | 2469 | { |
---|
2390 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2391 | 2472 | resolution = res; |
---|
2392 | 2473 | } |
---|
2393 | 2474 | } |
---|
2394 | 2475 | /**/ |
---|
2395 | 2476 | |
---|
2396 | 2477 | // TEXTURE static Texture texture; |
---|
2397 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2398 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2399 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 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 | + |
---|
2400 | 2483 | int pigmentdepth = 0; |
---|
2401 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2485 | int bumpdepth = 0; |
---|
2403 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2404 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2405 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2406 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2407 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2408 | 2491 | |
---|
2409 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2410 | 2493 | { |
---|
2411 | 2494 | TextureData texturedata = null; |
---|
2412 | 2495 | |
---|
.. | .. |
---|
2425 | 2508 | if (bump) |
---|
2426 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2427 | 2510 | |
---|
2428 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2429 | | - 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); |
---|
2430 | 2513 | |
---|
2431 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2432 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 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); |
---|
2433 | 2516 | |
---|
2434 | | - 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; |
---|
2435 | 2539 | } |
---|
2436 | 2540 | |
---|
2437 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3504 | 3608 | |
---|
3505 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3506 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3507 | 3613 | // |
---|
3508 | 3614 | if (false) // compressbit > 0) |
---|
3509 | 3615 | { |
---|
.. | .. |
---|
7902 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7903 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7904 | 8010 | |
---|
7905 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7906 | 8012 | { |
---|
7907 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7908 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7917 | 8023 | pigment = null; |
---|
7918 | 8024 | } |
---|
7919 | 8025 | |
---|
7920 | | - ReleaseTexture(bump, true); |
---|
7921 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7922 | 8028 | } |
---|
7923 | 8029 | |
---|
7924 | | - 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) |
---|
7925 | 8089 | { |
---|
7926 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7927 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7932 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7933 | 8097 | |
---|
7934 | 8098 | if (tex != null) |
---|
7935 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7936 | 8100 | |
---|
7937 | 8101 | // //assert( texture != null ); |
---|
7938 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8026 | 8190 | |
---|
8027 | 8191 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8028 | 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 |
---|
| 8240 | + { |
---|
8029 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8030 | 8242 | ambientOcclusion ) // || !textureon) |
---|
8031 | 8243 | { |
---|
.. | .. |
---|
8035 | 8247 | if (tex == null) |
---|
8036 | 8248 | { |
---|
8037 | 8249 | BindTexture(null,false,resolution); |
---|
8038 | | - BindTexture(null,true,resolution); |
---|
8039 | 8250 | return; |
---|
8040 | 8251 | } |
---|
8041 | 8252 | |
---|
8042 | 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 | + |
---|
8043 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8044 | 8287 | |
---|
8045 | | - usedtextures.put(pigment, pigment); |
---|
8046 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8047 | 8289 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8291 | { |
---|
8050 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8055 | 8297 | { |
---|
8056 | 8298 | bump = null; |
---|
8057 | 8299 | } |
---|
8058 | | - if (pigment.equals("")) |
---|
8059 | | - { |
---|
8060 | | - pigment = null; |
---|
8061 | | - } |
---|
8062 | 8300 | |
---|
8063 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8064 | | - BindTexture(pigment, false, resolution); |
---|
8065 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8066 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8067 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8068 | | - |
---|
8069 | | - return; // true; |
---|
8070 | 8304 | } |
---|
8071 | 8305 | |
---|
8072 | 8306 | java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
.. | .. |
---|
8089 | 8323 | return fileExists; |
---|
8090 | 8324 | } |
---|
8091 | 8325 | |
---|
8092 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8093 | 8327 | { |
---|
8094 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8095 | 8329 | |
---|
8096 | 8330 | if (tex != null) |
---|
8097 | 8331 | { |
---|
8098 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8334 | + |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
8099 | 8339 | |
---|
8100 | 8340 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8101 | 8341 | |
---|
.. | .. |
---|
8105 | 8345 | // else |
---|
8106 | 8346 | // if (!texname.startsWith("/")) |
---|
8107 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8108 | | - if (!FileExists(tex)) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8109 | 8349 | { |
---|
8110 | 8350 | texname = fallbackTextureName; |
---|
8111 | 8351 | } |
---|
8112 | 8352 | |
---|
8113 | 8353 | if (CACHETEXTURE) |
---|
8114 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8115 | | - |
---|
8116 | | - TextureData texturedata = null; |
---|
8117 | | - |
---|
8118 | | - if (texture == null || texture.resolution < resolution) |
---|
8119 | 8354 | { |
---|
8120 | | - 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("")) |
---|
8121 | 8388 | { |
---|
8122 | 8389 | assert(!bump); |
---|
8123 | 8390 | // if (bump) |
---|
.. | .. |
---|
8128 | 8395 | // } |
---|
8129 | 8396 | // else |
---|
8130 | 8397 | // { |
---|
8131 | | - texture = textures.get(tex); |
---|
8132 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8133 | 8400 | { |
---|
8134 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8135 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8136 | 8405 | // } |
---|
8137 | 8406 | } else |
---|
8138 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8139 | 8408 | { |
---|
8140 | 8409 | assert(bump); |
---|
8141 | | - texture = textures.get(tex); |
---|
8142 | | - if (texture == null) |
---|
8143 | | - 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(); |
---|
8144 | 8415 | } else |
---|
8145 | 8416 | { |
---|
8146 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8148 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8149 | 8420 | //} else |
---|
8150 | 8421 | //{ |
---|
8151 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8152 | 8423 | { |
---|
8153 | | - texture = textures.get(tex); |
---|
8154 | | - if (texture == null) |
---|
8155 | | - 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(); |
---|
8156 | 8429 | } else |
---|
8157 | 8430 | { |
---|
8158 | 8431 | if (textureon) |
---|
.. | .. |
---|
8211 | 8484 | if (texturedata == null) |
---|
8212 | 8485 | throw new Exception(); |
---|
8213 | 8486 | |
---|
8214 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8215 | 8488 | //texture = GetTexture(tex, bump); |
---|
8216 | 8489 | } |
---|
8217 | 8490 | } |
---|
8218 | 8491 | //} |
---|
8219 | 8492 | } |
---|
8220 | 8493 | |
---|
8221 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8222 | 8495 | { |
---|
8223 | 8496 | //return false; |
---|
8224 | 8497 | |
---|
8225 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8226 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8227 | 8500 | { |
---|
8228 | 8501 | // String ext = "_highres"; |
---|
8229 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8240 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8241 | 8514 | if (!cachefile.exists()) |
---|
8242 | 8515 | { |
---|
8243 | | - // cache to disk |
---|
8244 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8245 | | - //buffers[0]. |
---|
8246 | | - |
---|
8247 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8248 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8249 | | - |
---|
8250 | | - // squared size heuristic... |
---|
8251 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8252 | 8517 | { |
---|
8253 | | - for (int i=pixels.length; --i>=0;) |
---|
8254 | | - { |
---|
8255 | | - int i3 = i*3; |
---|
8256 | | - pixels[i] = 0xFF; |
---|
8257 | | - pixels[i] <<= 8; |
---|
8258 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8259 | | - pixels[i] <<= 8; |
---|
8260 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8261 | | - pixels[i] <<= 8; |
---|
8262 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8263 | | - } |
---|
8264 | | - |
---|
8265 | | - /* |
---|
8266 | | - int r=0,g=0,b=0,a=0; |
---|
8267 | | - for (int i=0; i<width; i++) |
---|
8268 | | - for (int j=0; j<height; j++) |
---|
8269 | | - { |
---|
8270 | | - int index = j*width+i; |
---|
8271 | | - int p = pixels[index]; |
---|
8272 | | - a = ((p>>24) & 0xFF); |
---|
8273 | | - r = ((p>>16) & 0xFF); |
---|
8274 | | - g = ((p>>8) & 0xFF); |
---|
8275 | | - b = (p & 0xFF); |
---|
8276 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8277 | | - } |
---|
8278 | | - /**/ |
---|
8279 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8280 | | - int height = width; |
---|
8281 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8282 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8283 | 8520 | ImageWriter writer = null; |
---|
8284 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8285 | 8522 | if (iter.hasNext()) { |
---|
8286 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8287 | 8524 | } |
---|
8288 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8289 | 8527 | try |
---|
8290 | 8528 | { |
---|
8291 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8302 | 8540 | } |
---|
8303 | 8541 | } |
---|
8304 | 8542 | } |
---|
8305 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8306 | 8546 | //System.out.println("Texture = " + tex); |
---|
8307 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8308 | 8548 | { |
---|
8309 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8310 | 8550 | thetex.texture.disable(); |
---|
8311 | 8551 | thetex.texture.dispose(); |
---|
8312 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8313 | 8553 | } |
---|
8314 | 8554 | |
---|
8315 | | - texture.texturedata = texturedata; |
---|
8316 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8317 | 8557 | |
---|
8318 | 8558 | // newtex = true; |
---|
8319 | 8559 | } |
---|
.. | .. |
---|
8329 | 8569 | } |
---|
8330 | 8570 | } |
---|
8331 | 8571 | |
---|
8332 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8333 | 8573 | } |
---|
8334 | 8574 | |
---|
8335 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 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 |
---|
8336 | 8610 | { |
---|
8337 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8338 | 8612 | |
---|
.. | .. |
---|
8350 | 8624 | return texture!=null?texture.texture:null; |
---|
8351 | 8625 | } |
---|
8352 | 8626 | |
---|
8353 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8354 | 8628 | { |
---|
8355 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8356 | 8630 | |
---|
8357 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8358 | 8632 | } |
---|
8359 | 8633 | |
---|
8360 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8361 | 8635 | { |
---|
8362 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8363 | 8637 | { |
---|
8364 | 8638 | return false; |
---|
8365 | 8639 | } |
---|
8366 | 8640 | |
---|
8367 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8368 | 8642 | |
---|
8369 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8370 | 8644 | |
---|
.. | .. |
---|
8396 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8397 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8398 | 8672 | |
---|
8399 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8400 | 8674 | } |
---|
8401 | 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 | + |
---|
8402 | 8742 | ShadowBuffer shadowPBuf; |
---|
8403 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8404 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
9234 | 9574 | jy8[3] = 0.5f; |
---|
9235 | 9575 | } |
---|
9236 | 9576 | |
---|
9237 | | - 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 |
---|
9238 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9239 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9240 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9241 | 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 | + |
---|
9242 | 9606 | static int imagecount = 0; // movie generation |
---|
9243 | 9607 | |
---|
9244 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
9335 | 9699 | |
---|
9336 | 9700 | if (renderCamera != lightCamera) |
---|
9337 | 9701 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9338 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9339 | 9703 | |
---|
9340 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9341 | 9705 | |
---|
.. | .. |
---|
9351 | 9715 | |
---|
9352 | 9716 | if (renderCamera != lightCamera) |
---|
9353 | 9717 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9354 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9355 | 9719 | |
---|
9356 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9357 | 9721 | |
---|
.. | .. |
---|
10349 | 10713 | ANTIALIAS = 0; |
---|
10350 | 10714 | //System.out.println("RESTART"); |
---|
10351 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
10352 | 10717 | } |
---|
10353 | 10718 | } |
---|
10354 | 10719 | } |
---|
.. | .. |
---|
10416 | 10781 | ambientOcclusion = false; |
---|
10417 | 10782 | } |
---|
10418 | 10783 | |
---|
10419 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10420 | 10786 | { |
---|
10421 | 10787 | //if (RENDERSHADOW) // ? |
---|
10422 | 10788 | if (!IsFrozen()) |
---|
.. | .. |
---|
10550 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
10551 | 10917 | if (cam != lightCamera) |
---|
10552 | 10918 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10553 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10554 | 10920 | |
---|
10555 | 10921 | for (int j = 0; j < 4; j++) |
---|
10556 | 10922 | { |
---|
.. | .. |
---|
10565 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
10566 | 10932 | if (cam != lightCamera) |
---|
10567 | 10933 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10568 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10569 | 10935 | |
---|
10570 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10571 | 10937 | |
---|
.. | .. |
---|
10856 | 11222 | |
---|
10857 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10858 | 11224 | |
---|
10859 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10860 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10861 | | -//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); |
---|
10862 | 11228 | } else |
---|
10863 | 11229 | { |
---|
10864 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10869 | 11235 | //System.out.println("BLENDING ON"); |
---|
10870 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10871 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10872 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10873 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10874 | 11240 | gl.glLoadIdentity(); |
---|
10875 | 11241 | |
---|
.. | .. |
---|
10959 | 11325 | |
---|
10960 | 11326 | // if (cam != lightCamera) |
---|
10961 | 11327 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10962 | | - LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10963 | 11329 | } |
---|
10964 | 11330 | |
---|
10965 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10981 | 11347 | { |
---|
10982 | 11348 | if (cam != lightCamera) |
---|
10983 | 11349 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10984 | | - LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013 |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10985 | 11351 | } |
---|
10986 | 11352 | |
---|
10987 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11118 | 11484 | } |
---|
11119 | 11485 | } |
---|
11120 | 11486 | |
---|
11121 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11122 | 11488 | { |
---|
11123 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11124 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11126 | 11492 | |
---|
11127 | 11493 | boolean texon = textureon; |
---|
11128 | 11494 | |
---|
11129 | | - if (RENDERPROGRAM > 0) |
---|
11130 | | - { |
---|
11131 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11132 | | - textureon = false; |
---|
11133 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11134 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11135 | 11499 | //System.out.println("ALLO"); |
---|
11136 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11137 | 11501 | DrawObject(gl); |
---|
11138 | | - if (RENDERPROGRAM > 0) |
---|
11139 | | - { |
---|
11140 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11141 | | - textureon = texon; |
---|
11142 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11143 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11144 | 11507 | |
---|
11145 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11146 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11147 | 11510 | } |
---|
11148 | 11511 | |
---|
11149 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11326 | 11689 | |
---|
11327 | 11690 | static boolean zoomonce = false; |
---|
11328 | 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 | + |
---|
11329 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
11330 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
11331 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11332 | 11716 | // DrawMode() = SELECTION; |
---|
11333 | 11717 | //GL gl = getGL(); |
---|
11334 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11335 | 11719 | { |
---|
11336 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11337 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11338 | 11722 | pingthread.StepToTarget(true); // true); |
---|
11339 | 11723 | // zoomonce = false; |
---|
11340 | 11724 | } |
---|
.. | .. |
---|
11406 | 11790 | |
---|
11407 | 11791 | if (DrawMode() == DEFAULT) |
---|
11408 | 11792 | { |
---|
11409 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
11410 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
11411 | 11796 | float radius = 0.05f; |
---|
11412 | 11797 | if (selectedpoint.radius != radius) |
---|
11413 | 11798 | { |
---|
.. | .. |
---|
11461 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11462 | 11847 | |
---|
11463 | 11848 | if (CLEANCACHE) |
---|
11464 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11465 | 11850 | { |
---|
11466 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11467 | 11852 | |
---|
11468 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11469 | 11854 | |
---|
11470 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11471 | 11856 | continue; |
---|
11472 | 11857 | |
---|
11473 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11474 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11475 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11476 | | - textures.get(tex).texture.dispose(); |
---|
11477 | | - 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 | + } |
---|
11478 | 11875 | } |
---|
11479 | 11876 | } |
---|
11480 | 11877 | } |
---|
.. | .. |
---|
11912 | 12309 | } |
---|
11913 | 12310 | |
---|
11914 | 12311 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11915 | | - LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013 |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11916 | 12313 | |
---|
11917 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11918 | 12315 | |
---|
.. | .. |
---|
12003 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12004 | 12401 | |
---|
12005 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12006 | 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 | + |
---|
12007 | 12448 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12008 | 12449 | "PARAM light2cam0 = program.env[10];" + |
---|
12009 | 12450 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12118 | 12559 | "TEMP shininess;" + |
---|
12119 | 12560 | "\n" + |
---|
12120 | 12561 | "MOV texSamp, one;" + |
---|
12121 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12122 | | - |
---|
| 12562 | + |
---|
12123 | 12563 | "MOV mapgrid.x, one2048th.x;" + |
---|
12124 | 12564 | "MOV temp, fragment.texcoord[1];" + |
---|
12125 | 12565 | /* |
---|
.. | .. |
---|
12524 | 12964 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12525 | 12965 | "") + |
---|
12526 | 12966 | |
---|
12527 | | - // display shadow only (bump == 0) |
---|
| 12967 | + // display shadow only (fakedepth == 0) |
---|
12528 | 12968 | "SUB temp.x, half.x, shadow.x;" + |
---|
12529 | 12969 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12530 | 12970 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13016 | 13456 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13017 | 13457 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13018 | 13458 | |
---|
13019 | | - // No shadow when out of frustrum |
---|
| 13459 | + // No shadow when out of frustum |
---|
13020 | 13460 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13021 | 13461 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13022 | 13462 | ""; |
---|
.. | .. |
---|
13164 | 13604 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13165 | 13605 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13166 | 13606 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13167 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13607 | + |
---|
| 13608 | + //Object3D.cVector2[] vector2buffer; |
---|
13168 | 13609 | |
---|
13169 | 13610 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13170 | 13611 | // OUT : diff, spec |
---|
.. | .. |
---|
13180 | 13621 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13181 | 13622 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13182 | 13623 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13183 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13184 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13185 | | - //"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 |
---|
13186 | 13628 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13187 | 13629 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13188 | 13630 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13687 | 14129 | else |
---|
13688 | 14130 | if (evt.getSource() == AAtimer) |
---|
13689 | 14131 | { |
---|
| 14132 | + Globals.TIMERRUNNING = false; |
---|
13690 | 14133 | if (mouseDown) |
---|
13691 | 14134 | { |
---|
13692 | 14135 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13746 | 14189 | |
---|
13747 | 14190 | // fev 2014??? |
---|
13748 | 14191 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13749 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14192 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13750 | 14193 | pingthread.StepToTarget(true); // true); |
---|
13751 | 14194 | } |
---|
13752 | 14195 | // if (!LIVE) |
---|
.. | .. |
---|
13761 | 14204 | return; |
---|
13762 | 14205 | |
---|
13763 | 14206 | AAtimer.restart(); // |
---|
| 14207 | + Globals.TIMERRUNNING = true; |
---|
13764 | 14208 | |
---|
13765 | 14209 | // waslive = LIVE; |
---|
13766 | 14210 | // LIVE = false; |
---|
.. | .. |
---|
13833 | 14277 | |
---|
13834 | 14278 | public void mouseDragged(MouseEvent e) |
---|
13835 | 14279 | { |
---|
| 14280 | + Globals.MOUSEDRAGGED = true; |
---|
| 14281 | + |
---|
13836 | 14282 | //System.out.println("mouseDragged: " + e); |
---|
13837 | 14283 | if (isRenderer) |
---|
13838 | 14284 | movingcamera = true; |
---|
.. | .. |
---|
14097 | 14543 | void GoDown(int mod) |
---|
14098 | 14544 | { |
---|
14099 | 14545 | MODIFIERS |= COMMAND; |
---|
14100 | | - /* |
---|
| 14546 | + /**/ |
---|
14101 | 14547 | if((mod&SHIFT) == SHIFT) |
---|
14102 | 14548 | manipCamera.RotatePosition(0, -speed); |
---|
14103 | 14549 | else |
---|
14104 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14105 | | - */ |
---|
| 14550 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14551 | + /**/ |
---|
14106 | 14552 | if ((mod & SHIFT) == SHIFT) |
---|
14107 | 14553 | { |
---|
14108 | 14554 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14118 | 14564 | void GoUp(int mod) |
---|
14119 | 14565 | { |
---|
14120 | 14566 | MODIFIERS |= COMMAND; |
---|
14121 | | - /* |
---|
| 14567 | + /**/ |
---|
14122 | 14568 | if((mod&SHIFT) == SHIFT) |
---|
14123 | 14569 | manipCamera.RotatePosition(0, speed); |
---|
14124 | 14570 | else |
---|
14125 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14126 | | - */ |
---|
| 14571 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14572 | + /**/ |
---|
14127 | 14573 | if ((mod & SHIFT) == SHIFT) |
---|
14128 | 14574 | { |
---|
14129 | 14575 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14139 | 14585 | void GoLeft(int mod) |
---|
14140 | 14586 | { |
---|
14141 | 14587 | MODIFIERS |= COMMAND; |
---|
14142 | | - /* |
---|
| 14588 | + /**/ |
---|
14143 | 14589 | if((mod&SHIFT) == SHIFT) |
---|
14144 | | - manipCamera.RotatePosition(speed, 0); |
---|
14145 | | - else |
---|
14146 | 14590 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14147 | | - */ |
---|
| 14591 | + else |
---|
| 14592 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14593 | + /**/ |
---|
14148 | 14594 | if ((mod & SHIFT) == SHIFT) |
---|
14149 | 14595 | { |
---|
14150 | 14596 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14160 | 14606 | void GoRight(int mod) |
---|
14161 | 14607 | { |
---|
14162 | 14608 | MODIFIERS |= COMMAND; |
---|
14163 | | - /* |
---|
| 14609 | + /**/ |
---|
14164 | 14610 | if((mod&SHIFT) == SHIFT) |
---|
14165 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14166 | | - else |
---|
14167 | 14611 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14168 | | - */ |
---|
| 14612 | + else |
---|
| 14613 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14614 | + /**/ |
---|
14169 | 14615 | if ((mod & SHIFT) == SHIFT) |
---|
14170 | 14616 | { |
---|
14171 | 14617 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14222 | 14668 | info.camera = renderCamera; |
---|
14223 | 14669 | info.x = x; |
---|
14224 | 14670 | info.y = y; |
---|
14225 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14671 | + object.GetWindow().copy |
---|
| 14672 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14226 | 14673 | } else |
---|
14227 | 14674 | { |
---|
14228 | 14675 | if (x < startX) |
---|
.. | .. |
---|
14386 | 14833 | ci.camera = renderCamera; |
---|
14387 | 14834 | if (!isRenderer) |
---|
14388 | 14835 | { |
---|
14389 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14836 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14837 | + //Object3D copy = editWindow.copy; |
---|
| 14838 | + if (object.doEditClick(ci, 0)) |
---|
14390 | 14839 | { |
---|
14391 | 14840 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14392 | 14841 | } else |
---|
.. | .. |
---|
14398 | 14847 | |
---|
14399 | 14848 | public void mouseReleased(MouseEvent e) |
---|
14400 | 14849 | { |
---|
| 14850 | + Globals.MOUSEDRAGGED = false; |
---|
| 14851 | + |
---|
14401 | 14852 | movingcamera = false; |
---|
14402 | | - X = Y = 0; |
---|
| 14853 | + X = 0; // getBounds().width/2; |
---|
| 14854 | + Y = 0; // getBounds().height/2; |
---|
14403 | 14855 | //System.out.println("mouseReleased: " + e); |
---|
14404 | 14856 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14405 | 14857 | } |
---|
.. | .. |
---|
14655 | 15107 | // break; |
---|
14656 | 15108 | case 'T': |
---|
14657 | 15109 | CACHETEXTURE ^= true; |
---|
14658 | | - textures.clear(); |
---|
| 15110 | + texturepigment.clear(); |
---|
| 15111 | + texturebump.clear(); |
---|
14659 | 15112 | // repaint(); |
---|
14660 | 15113 | break; |
---|
14661 | 15114 | case 'Y': |
---|
.. | .. |
---|
14740 | 15193 | case 'E' : COMPACT ^= true; |
---|
14741 | 15194 | repaint(); |
---|
14742 | 15195 | break; |
---|
14743 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15196 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15197 | + //DEBUGHSB ^= true; |
---|
| 15198 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14744 | 15199 | repaint(); |
---|
14745 | 15200 | break; |
---|
14746 | 15201 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14765 | 15220 | RevertCamera(); |
---|
14766 | 15221 | repaint(); |
---|
14767 | 15222 | break; |
---|
14768 | | - case 'L': |
---|
14769 | 15223 | case 'l': |
---|
| 15224 | + //case 'L': |
---|
14770 | 15225 | if (lightMode) |
---|
14771 | 15226 | { |
---|
14772 | 15227 | lightMode = false; |
---|
.. | .. |
---|
14909 | 15364 | case '_': |
---|
14910 | 15365 | kompactbit = 5; |
---|
14911 | 15366 | break; |
---|
14912 | | - case '+': |
---|
14913 | | - kompactbit = 6; |
---|
14914 | | - break; |
---|
| 15367 | +// case '+': |
---|
| 15368 | +// kompactbit = 6; |
---|
| 15369 | +// break; |
---|
14915 | 15370 | case ' ': |
---|
14916 | 15371 | lightMode ^= true; |
---|
14917 | 15372 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14923 | 15378 | case ESC: |
---|
14924 | 15379 | RENDERPROGRAM += 1; |
---|
14925 | 15380 | RENDERPROGRAM %= 3; |
---|
| 15381 | + |
---|
14926 | 15382 | repaint(); |
---|
14927 | 15383 | break; |
---|
14928 | 15384 | case 'Z': |
---|
.. | .. |
---|
14962 | 15418 | case DELETE: |
---|
14963 | 15419 | ClearSelection(); |
---|
14964 | 15420 | break; |
---|
14965 | | - /* |
---|
14966 | 15421 | case '+': |
---|
| 15422 | + |
---|
| 15423 | + /* |
---|
14967 | 15424 | //fontsize += 1; |
---|
14968 | 15425 | bbzoom *= 2; |
---|
14969 | 15426 | repaint(); |
---|
.. | .. |
---|
14980 | 15437 | case '=': |
---|
14981 | 15438 | IncDepth(); |
---|
14982 | 15439 | //fontsize += 1; |
---|
14983 | | - object.editWindow.refreshContents(true); |
---|
| 15440 | + object.GetWindow().refreshContents(true); |
---|
14984 | 15441 | maskbit = 6; |
---|
14985 | 15442 | break; |
---|
14986 | 15443 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14987 | 15444 | DecDepth(); |
---|
14988 | 15445 | maskbit = 5; |
---|
14989 | 15446 | //if(fontsize > 1) fontsize -= 1; |
---|
14990 | | - if (object.editWindow == null) |
---|
14991 | | - new Exception().printStackTrace(); |
---|
14992 | | - else |
---|
14993 | | - object.editWindow.refreshContents(true); |
---|
| 15447 | +// if (object.editWindow == null) |
---|
| 15448 | +// new Exception().printStackTrace(); |
---|
| 15449 | +// else |
---|
| 15450 | + object.GetWindow().refreshContents(true); |
---|
14994 | 15451 | break; |
---|
14995 | 15452 | case '{': |
---|
14996 | 15453 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15214 | 15671 | } |
---|
15215 | 15672 | */ |
---|
15216 | 15673 | |
---|
15217 | | - object.editWindow.EditSelection(); |
---|
| 15674 | + object.GetWindow().EditSelection(false); |
---|
15218 | 15675 | } |
---|
15219 | 15676 | |
---|
15220 | 15677 | void SelectParent() |
---|
.. | .. |
---|
15231 | 15688 | { |
---|
15232 | 15689 | //selectees.remove(i); |
---|
15233 | 15690 | System.out.println("select parent of " + elem); |
---|
15234 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15691 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15235 | 15692 | } else |
---|
15236 | 15693 | { |
---|
15237 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15694 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15238 | 15695 | } |
---|
15239 | 15696 | |
---|
15240 | 15697 | first = false; |
---|
.. | .. |
---|
15276 | 15733 | for (int j = 0; j < group.children.size(); j++) |
---|
15277 | 15734 | { |
---|
15278 | 15735 | elem = (Object3D) group.children.elementAt(j); |
---|
15279 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15736 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15280 | 15737 | first = false; |
---|
15281 | 15738 | } |
---|
15282 | 15739 | } else |
---|
15283 | 15740 | { |
---|
15284 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15741 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15285 | 15742 | } |
---|
15286 | 15743 | |
---|
15287 | 15744 | first = false; |
---|
.. | .. |
---|
15292 | 15749 | { |
---|
15293 | 15750 | //Composite group = (Composite) object; |
---|
15294 | 15751 | Object3D group = object; |
---|
15295 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15752 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15296 | 15753 | } |
---|
15297 | 15754 | |
---|
15298 | 15755 | void ResetTransform(int mask) |
---|
15299 | 15756 | { |
---|
15300 | 15757 | //Composite group = (Composite) object; |
---|
15301 | 15758 | Object3D group = object; |
---|
15302 | | - group.editWindow.ResetTransform(mask); |
---|
| 15759 | + group.GetWindow().ResetTransform(mask); |
---|
15303 | 15760 | } |
---|
15304 | 15761 | |
---|
15305 | 15762 | void FlipTransform() |
---|
15306 | 15763 | { |
---|
15307 | 15764 | //Composite group = (Composite) object; |
---|
15308 | 15765 | Object3D group = object; |
---|
15309 | | - group.editWindow.FlipTransform(); |
---|
| 15766 | + group.GetWindow().FlipTransform(); |
---|
15310 | 15767 | // group.editWindow.ReduceMesh(true); |
---|
15311 | 15768 | } |
---|
15312 | 15769 | |
---|
.. | .. |
---|
15314 | 15771 | { |
---|
15315 | 15772 | //Composite group = (Composite) object; |
---|
15316 | 15773 | Object3D group = object; |
---|
15317 | | - group.editWindow.PrintMemory(); |
---|
| 15774 | + group.GetWindow().PrintMemory(); |
---|
15318 | 15775 | // group.editWindow.ReduceMesh(true); |
---|
15319 | 15776 | } |
---|
15320 | 15777 | |
---|
.. | .. |
---|
15322 | 15779 | { |
---|
15323 | 15780 | //Composite group = (Composite) object; |
---|
15324 | 15781 | Object3D group = object; |
---|
15325 | | - group.editWindow.ResetCentroid(); |
---|
| 15782 | + group.GetWindow().ResetCentroid(); |
---|
15326 | 15783 | } |
---|
15327 | 15784 | |
---|
15328 | 15785 | void IncDepth() |
---|
.. | .. |
---|
15498 | 15955 | info.bounds.y += (height - desired) / 2; |
---|
15499 | 15956 | } |
---|
15500 | 15957 | } |
---|
| 15958 | + |
---|
15501 | 15959 | info.g = gr; |
---|
15502 | 15960 | info.camera = renderCamera; |
---|
15503 | 15961 | /* |
---|
.. | .. |
---|
15507 | 15965 | */ |
---|
15508 | 15966 | if (!isRenderer) |
---|
15509 | 15967 | { |
---|
15510 | | - object.drawEditHandles(info, 0); |
---|
15511 | | - |
---|
15512 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15968 | + Grafreed.Assert(object != null); |
---|
| 15969 | + Grafreed.Assert(object.selection != null); |
---|
| 15970 | + if (object.selection.Size() > 0) |
---|
15513 | 15971 | { |
---|
15514 | | - switch (object.selection.get(0).hitSomething) |
---|
| 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) |
---|
15515 | 15978 | { |
---|
15516 | | - case Object3D.hitCenter: gr.setColor(Color.pink); break; |
---|
15517 | | - case Object3D.hitRotate: gr.setColor(Color.green); break; |
---|
15518 | | - case Object3D.hitScale: gr.setColor(Color.cyan); break; |
---|
| 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; |
---|
15519 | 15986 | } |
---|
15520 | | - |
---|
15521 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 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 | + } |
---|
15522 | 16006 | } |
---|
15523 | 16007 | } |
---|
15524 | 16008 | } |
---|
.. | .. |
---|
16221 | 16705 | cStatic.objectstack[materialdepth++] = checker; |
---|
16222 | 16706 | //System.out.println("material " + material); |
---|
16223 | 16707 | //Applet3D.tracein(this, selected); |
---|
16224 | | - vector2buffer = checker.projectedVertices; |
---|
| 16708 | + //vector2buffer = checker.projectedVertices; |
---|
16225 | 16709 | |
---|
16226 | 16710 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16227 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16711 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16228 | 16712 | |
---|
16229 | 16713 | materialdepth -= 1; |
---|
16230 | 16714 | if (materialdepth > 0) |
---|
16231 | 16715 | { |
---|
16232 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16233 | | - 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); |
---|
16234 | 16718 | } |
---|
16235 | 16719 | //checker.GetMaterial().opacity = 1f; |
---|
16236 | 16720 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16316 | 16800 | } |
---|
16317 | 16801 | } |
---|
16318 | 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 | + |
---|
16319 | 16811 | class SelectBuffer implements GLEventListener |
---|
16320 | 16812 | { |
---|
16321 | 16813 | |
---|
.. | .. |
---|
16395 | 16887 | |
---|
16396 | 16888 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16397 | 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 | + |
---|
16398 | 16901 | //int tmp = selection_view; |
---|
16399 | 16902 | //selection_view = -1; |
---|
16400 | 16903 | int temp = DrawMode(); |
---|
.. | .. |
---|
16406 | 16909 | // temp = DEFAULT; // patch for selection debug |
---|
16407 | 16910 | Globals.drawMode = temp; // WARNING |
---|
16408 | 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 | + |
---|
16409 | 16923 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16410 | 16924 | |
---|
16411 | 16925 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16453 | 16967 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16454 | 16968 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16455 | 16969 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16970 | + |
---|
| 16971 | + CreateSelectedPoint(); |
---|
16456 | 16972 | |
---|
16457 | 16973 | // Will fit the mesh !!! |
---|
16458 | 16974 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16507 | 17023 | } |
---|
16508 | 17024 | |
---|
16509 | 17025 | if (!movingcamera && !PAINTMODE) |
---|
16510 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17026 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16511 | 17027 | |
---|
16512 | | - 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) |
---|
16513 | 17029 | { |
---|
16514 | | - 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); |
---|
16515 | 17031 | |
---|
16516 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17032 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17033 | + { |
---|
| 17034 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16517 | 17035 | |
---|
16518 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16519 | | - |
---|
16520 | | - group.add(paintobj); // link |
---|
16521 | | - |
---|
16522 | | - object.editWindow.SnapObject(group); |
---|
16523 | | - |
---|
16524 | | - Object3D folder = object.editWindow.copy; |
---|
16525 | | - |
---|
16526 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16527 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16528 | | - |
---|
16529 | | - folder.add(group); |
---|
16530 | | - |
---|
16531 | | - object.editWindow.ResetModel(); |
---|
16532 | | - 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 | + } |
---|
16533 | 17051 | } |
---|
16534 | 17052 | else |
---|
16535 | 17053 | paintcount = 0; |
---|
.. | .. |
---|
16568 | 17086 | //System.out.println("objects[color] = " + objects[color]); |
---|
16569 | 17087 | //objects[color].Select(); |
---|
16570 | 17088 | indexcount = 0; |
---|
| 17089 | + ObjEditor window = object.GetWindow(); |
---|
| 17090 | + if (window != null && deselect) |
---|
| 17091 | + { |
---|
| 17092 | + window.Select(null, deselect, true); |
---|
| 17093 | + } |
---|
16571 | 17094 | object.Select(color, deselect); |
---|
16572 | 17095 | } |
---|
16573 | 17096 | |
---|
.. | .. |
---|
17093 | 17616 | int AAbuffersize = 0; |
---|
17094 | 17617 | |
---|
17095 | 17618 | //double[] selectedpoint = new double[3]; |
---|
17096 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17619 | + static Superellipsoid selectedpoint; |
---|
17097 | 17620 | static Sphere previousselectedpoint = null; |
---|
17098 | | - static Sphere debugpointG = new Sphere(); |
---|
17099 | | - static Sphere debugpointP = new Sphere(); |
---|
17100 | | - static Sphere debugpointC = new Sphere(); |
---|
17101 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17621 | + static Sphere debugpointG; |
---|
| 17622 | + static Sphere debugpointP; |
---|
| 17623 | + static Sphere debugpointC; |
---|
| 17624 | + static Sphere debugpointR; |
---|
17102 | 17625 | |
---|
17103 | 17626 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17104 | 17627 | |
---|
17105 | | - static |
---|
17106 | | - { |
---|
17107 | | - for (int i=0; i<8; i++) |
---|
17108 | | - { |
---|
17109 | | - debugpoints[i] = new Sphere(); |
---|
17110 | | - } |
---|
17111 | | - } |
---|
17112 | | - |
---|
17113 | 17628 | static void InitPoints(float radius) |
---|
17114 | 17629 | { |
---|
17115 | 17630 | for (int i=0; i<8; i++) |
---|