.. | .. |
---|
37 | 37 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 38 | static int materialdepth = 0; |
---|
39 | 39 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 40 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 41 | |
---|
43 | 42 | // camera change fix |
---|
.. | .. |
---|
45 | 44 | static boolean ABORTED = false; |
---|
46 | 45 | |
---|
47 | 46 | static int STEP = 1; |
---|
| 47 | + |
---|
| 48 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 49 | + { |
---|
| 50 | + int[] pixels = new int[bytes.length/3]; |
---|
| 51 | + for (int i=pixels.length; --i>=0;) |
---|
| 52 | + { |
---|
| 53 | + int i3 = i*3; |
---|
| 54 | + pixels[i] = 0xFF; |
---|
| 55 | + pixels[i] <<= 8; |
---|
| 56 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 57 | + pixels[i] <<= 8; |
---|
| 58 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 61 | + } |
---|
| 62 | + /* |
---|
| 63 | + int r=0,g=0,b=0,a=0; |
---|
| 64 | + for (int i=0; i<width; i++) |
---|
| 65 | + for (int j=0; j<height; j++) |
---|
| 66 | + { |
---|
| 67 | + int index = j*width+i; |
---|
| 68 | + int p = pixels[index]; |
---|
| 69 | + a = ((p>>24) & 0xFF); |
---|
| 70 | + r = ((p>>16) & 0xFF); |
---|
| 71 | + g = ((p>>8) & 0xFF); |
---|
| 72 | + b = (p & 0xFF); |
---|
| 73 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 74 | + } |
---|
| 75 | + /**/ |
---|
| 76 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 77 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 78 | + return rendImage; |
---|
| 79 | + } |
---|
48 | 80 | |
---|
49 | 81 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 82 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
61 | 93 | //boolean REDUCETEXTURE = true; |
---|
62 | 94 | boolean CACHETEXTURE = true; |
---|
63 | 95 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 96 | + boolean MIPMAP = true; // false; // true; |
---|
65 | 97 | boolean COMPRESSTEXTURE = false; |
---|
66 | 98 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 99 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
327 | 359 | cStatic.objectstack[materialdepth++] = obj; |
---|
328 | 360 | //System.out.println("material " + material); |
---|
329 | 361 | //Applet3D.tracein(this, selected); |
---|
330 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 362 | + //display.vector2buffer = obj.projectedVertices; |
---|
331 | 363 | if (obj instanceof Camera) |
---|
332 | 364 | { |
---|
333 | 365 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
336 | 368 | display.options1[2] = material.shadowbias; |
---|
337 | 369 | display.options1[3] = material.aniso; |
---|
338 | 370 | display.options1[4] = material.anisoV; |
---|
| 371 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 372 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 373 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 374 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 375 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
339 | 376 | display.options2[0] = material.opacity; |
---|
340 | 377 | display.options2[1] = material.diffuse; |
---|
341 | 378 | display.options2[2] = material.factor; |
---|
| 379 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 380 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 381 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
342 | 382 | |
---|
343 | 383 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 384 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 385 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 386 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
344 | 387 | display.options4[0] = material.cameralight/0.2f; |
---|
345 | 388 | display.options4[1] = material.subsurface; |
---|
346 | 389 | display.options4[2] = material.sheen; |
---|
| 390 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 391 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 392 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
347 | 393 | |
---|
348 | 394 | // if (display.CURRENTANTIALIAS > 0) |
---|
349 | 395 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
359 | 405 | /**/ |
---|
360 | 406 | } else |
---|
361 | 407 | { |
---|
362 | | - DrawMaterial(material, selected); |
---|
| 408 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
363 | 409 | } |
---|
364 | 410 | } else |
---|
365 | 411 | { |
---|
.. | .. |
---|
383 | 429 | cStatic.objectstack[materialdepth++] = obj; |
---|
384 | 430 | //System.out.println("material " + material); |
---|
385 | 431 | //Applet3D.tracein("selected ", selected); |
---|
386 | | - display.vector2buffer = obj.projectedVertices; |
---|
387 | | - display.DrawMaterial(material, selected); |
---|
| 432 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 433 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
388 | 434 | } |
---|
389 | 435 | } |
---|
390 | 436 | |
---|
.. | .. |
---|
401 | 447 | materialdepth -= 1; |
---|
402 | 448 | if (materialdepth > 0) |
---|
403 | 449 | { |
---|
404 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
405 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 450 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 451 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
406 | 452 | } |
---|
407 | 453 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
408 | 454 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
422 | 468 | materialdepth -= 1; |
---|
423 | 469 | if (materialdepth > 0) |
---|
424 | 470 | { |
---|
425 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
426 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 471 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 472 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
427 | 473 | } |
---|
428 | 474 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
429 | 475 | //else |
---|
.. | .. |
---|
464 | 510 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
465 | 511 | { |
---|
466 | 512 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
467 | | - boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 513 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 514 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 515 | + ; |
---|
468 | 516 | if (!hasnorm) |
---|
469 | 517 | { |
---|
470 | | - // System.out.println("FUCK!!"); |
---|
| 518 | + // System.out.println("Mesh normal"); |
---|
471 | 519 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
472 | 520 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
473 | 521 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1192 | 1240 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1193 | 1241 | } |
---|
1194 | 1242 | } |
---|
| 1243 | + |
---|
1195 | 1244 | if (flipV) |
---|
1196 | 1245 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1197 | 1246 | else |
---|
1198 | 1247 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1248 | + |
---|
1199 | 1249 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1200 | 1250 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1201 | 1251 | |
---|
.. | .. |
---|
1215 | 1265 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1216 | 1266 | } |
---|
1217 | 1267 | } |
---|
| 1268 | + |
---|
1218 | 1269 | if (flipV) |
---|
1219 | 1270 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1220 | 1271 | else |
---|
1221 | 1272 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1273 | + |
---|
1222 | 1274 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1223 | 1275 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1224 | 1276 | |
---|
.. | .. |
---|
1246 | 1298 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1247 | 1299 | else |
---|
1248 | 1300 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1301 | + |
---|
1249 | 1302 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1250 | 1303 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1304 | + |
---|
1251 | 1305 | count2 += 2; |
---|
1252 | 1306 | count3 += 3; |
---|
1253 | 1307 | } |
---|
.. | .. |
---|
1603 | 1657 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1604 | 1658 | } |
---|
1605 | 1659 | |
---|
1606 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1660 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1607 | 1661 | { |
---|
1608 | 1662 | CameraPane display = this; |
---|
1609 | 1663 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1638 | 1692 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1639 | 1693 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1640 | 1694 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1641 | | - colorV[3] = material.opacity; |
---|
| 1695 | + colorV[3] = 1; // material.opacity; |
---|
1642 | 1696 | |
---|
1643 | 1697 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1644 | 1698 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1746 | 1800 | display.modelParams7[2] = 0; |
---|
1747 | 1801 | display.modelParams7[3] = 0; |
---|
1748 | 1802 | |
---|
1749 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1803 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1750 | 1804 | |
---|
1751 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1805 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1752 | 1806 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1753 | 1807 | { |
---|
1754 | 1808 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1890 | 1944 | void PushMatrix(double[][] matrix) |
---|
1891 | 1945 | { |
---|
1892 | 1946 | // GrafreeD.tracein(matrix); |
---|
1893 | | - PushMatrix(matrix,1); |
---|
| 1947 | + PushMatrix(matrix, 1); |
---|
1894 | 1948 | } |
---|
1895 | 1949 | |
---|
1896 | 1950 | void PushMatrix() |
---|
.. | .. |
---|
2044 | 2098 | //System.err.println("Oeil on"); |
---|
2045 | 2099 | OEIL = true; |
---|
2046 | 2100 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2047 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2101 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2048 | 2102 | //pingthread.StepToTarget(true); |
---|
2049 | 2103 | } |
---|
2050 | 2104 | |
---|
.. | .. |
---|
2259 | 2313 | |
---|
2260 | 2314 | void ToggleDebug() |
---|
2261 | 2315 | { |
---|
2262 | | - DEBUG ^= true; |
---|
| 2316 | + Globals.DEBUG ^= true; |
---|
2263 | 2317 | } |
---|
2264 | 2318 | |
---|
2265 | 2319 | void ToggleLookAt() |
---|
.. | .. |
---|
2277 | 2331 | HANDLES ^= true; |
---|
2278 | 2332 | } |
---|
2279 | 2333 | |
---|
| 2334 | + Object3D paintFolder; |
---|
| 2335 | + |
---|
2280 | 2336 | void TogglePaint() |
---|
2281 | 2337 | { |
---|
2282 | 2338 | PAINTMODE ^= true; |
---|
2283 | 2339 | paintcount = 0; |
---|
| 2340 | + |
---|
| 2341 | + if (PAINTMODE) |
---|
| 2342 | + { |
---|
| 2343 | + paintFolder = GetFolder(); |
---|
| 2344 | + } |
---|
2284 | 2345 | } |
---|
2285 | 2346 | |
---|
2286 | 2347 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2377 | 2438 | return currentGL; |
---|
2378 | 2439 | } |
---|
2379 | 2440 | |
---|
| 2441 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2442 | + { |
---|
| 2443 | + Grafreed.Assert(texturedata != null); |
---|
| 2444 | + |
---|
| 2445 | + int width = texturedata.getWidth(); |
---|
| 2446 | + int height = texturedata.getHeight(); |
---|
| 2447 | + |
---|
| 2448 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2449 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2450 | + |
---|
| 2451 | + byte[] bytes = bytebuf.array(); |
---|
| 2452 | + |
---|
| 2453 | + return CreateBim(bytes, width, height); |
---|
| 2454 | + } |
---|
| 2455 | + |
---|
2380 | 2456 | /**/ |
---|
2381 | 2457 | class CacheTexture |
---|
2382 | 2458 | { |
---|
.. | .. |
---|
2385 | 2461 | |
---|
2386 | 2462 | int resolution; |
---|
2387 | 2463 | |
---|
2388 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2464 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2389 | 2465 | { |
---|
2390 | | - texture = tex; |
---|
| 2466 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2467 | + texturedata = texdata; |
---|
2391 | 2468 | resolution = res; |
---|
2392 | 2469 | } |
---|
2393 | 2470 | } |
---|
2394 | 2471 | /**/ |
---|
2395 | 2472 | |
---|
2396 | 2473 | // 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>(); |
---|
| 2474 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2475 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2476 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2477 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2478 | + |
---|
2400 | 2479 | int pigmentdepth = 0; |
---|
2401 | 2480 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2481 | int bumpdepth = 0; |
---|
2403 | 2482 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2404 | 2483 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2405 | 2484 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2406 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2485 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2407 | 2486 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2408 | 2487 | |
---|
2409 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2488 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2410 | 2489 | { |
---|
2411 | 2490 | TextureData texturedata = null; |
---|
2412 | 2491 | |
---|
.. | .. |
---|
2425 | 2504 | if (bump) |
---|
2426 | 2505 | texturedata = ConvertBump(texturedata, false); |
---|
2427 | 2506 | |
---|
2428 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2429 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2507 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2508 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2430 | 2509 | |
---|
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); |
---|
| 2510 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2511 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2433 | 2512 | |
---|
2434 | | - return texture; |
---|
| 2513 | + return texturedata; |
---|
| 2514 | + } |
---|
| 2515 | + |
---|
| 2516 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2517 | + { |
---|
| 2518 | + TextureData texturedata = null; |
---|
| 2519 | + |
---|
| 2520 | + try |
---|
| 2521 | + { |
---|
| 2522 | + texturedata = |
---|
| 2523 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2524 | + bim, |
---|
| 2525 | + true); |
---|
| 2526 | + } catch (Exception e) |
---|
| 2527 | + { |
---|
| 2528 | + throw new javax.media.opengl.GLException(e); |
---|
| 2529 | + } |
---|
| 2530 | + |
---|
| 2531 | + if (bump) |
---|
| 2532 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2533 | + |
---|
| 2534 | + return texturedata; |
---|
2435 | 2535 | } |
---|
2436 | 2536 | |
---|
2437 | 2537 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3504 | 3604 | |
---|
3505 | 3605 | System.out.println("LOADING TEXTURE : " + name); |
---|
3506 | 3606 | |
---|
| 3607 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3608 | + |
---|
3507 | 3609 | // |
---|
3508 | 3610 | if (false) // compressbit > 0) |
---|
3509 | 3611 | { |
---|
.. | .. |
---|
7902 | 8004 | String pigment = Object3D.GetPigment(tex); |
---|
7903 | 8005 | String bump = Object3D.GetBump(tex); |
---|
7904 | 8006 | |
---|
7905 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8007 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7906 | 8008 | { |
---|
7907 | 8009 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7908 | 8010 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7917 | 8019 | pigment = null; |
---|
7918 | 8020 | } |
---|
7919 | 8021 | |
---|
7920 | | - ReleaseTexture(bump, true); |
---|
7921 | | - ReleaseTexture(pigment, false); |
---|
| 8022 | + ReleaseTexture(tex, true); |
---|
| 8023 | + ReleaseTexture(tex, false); |
---|
7922 | 8024 | } |
---|
7923 | 8025 | |
---|
7924 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8026 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8027 | + { |
---|
| 8028 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8029 | + { |
---|
| 8030 | + return; |
---|
| 8031 | + } |
---|
| 8032 | + |
---|
| 8033 | + if (tex == null) |
---|
| 8034 | + { |
---|
| 8035 | + ReleaseTexture(null, false); |
---|
| 8036 | + return; |
---|
| 8037 | + } |
---|
| 8038 | + |
---|
| 8039 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8040 | + |
---|
| 8041 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8042 | + { |
---|
| 8043 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8044 | + // System.out.println("; bump = " + bump); |
---|
| 8045 | + } |
---|
| 8046 | + |
---|
| 8047 | + if (pigment.equals("")) |
---|
| 8048 | + { |
---|
| 8049 | + pigment = null; |
---|
| 8050 | + } |
---|
| 8051 | + |
---|
| 8052 | + ReleaseTexture(tex, false); |
---|
| 8053 | + } |
---|
| 8054 | + |
---|
| 8055 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8056 | + { |
---|
| 8057 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8058 | + { |
---|
| 8059 | + return; |
---|
| 8060 | + } |
---|
| 8061 | + |
---|
| 8062 | + if (tex == null) |
---|
| 8063 | + { |
---|
| 8064 | + ReleaseTexture(null, true); |
---|
| 8065 | + return; |
---|
| 8066 | + } |
---|
| 8067 | + |
---|
| 8068 | + String bump = Object3D.GetBump(tex); |
---|
| 8069 | + |
---|
| 8070 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8071 | + { |
---|
| 8072 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8073 | + // System.out.println("; bump = " + bump); |
---|
| 8074 | + } |
---|
| 8075 | + |
---|
| 8076 | + if (bump.equals("")) |
---|
| 8077 | + { |
---|
| 8078 | + bump = null; |
---|
| 8079 | + } |
---|
| 8080 | + |
---|
| 8081 | + ReleaseTexture(tex, true); |
---|
| 8082 | + } |
---|
| 8083 | + |
---|
| 8084 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7925 | 8085 | { |
---|
7926 | 8086 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7927 | 8087 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7932 | 8092 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7933 | 8093 | |
---|
7934 | 8094 | if (tex != null) |
---|
7935 | | - texture = textures.get(tex); |
---|
| 8095 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7936 | 8096 | |
---|
7937 | 8097 | // //assert( texture != null ); |
---|
7938 | 8098 | // if (texture == null) |
---|
.. | .. |
---|
8026 | 8186 | |
---|
8027 | 8187 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8028 | 8188 | { |
---|
| 8189 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8190 | +// ambientOcclusion ) // || !textureon) |
---|
| 8191 | +// { |
---|
| 8192 | +// return; // false; |
---|
| 8193 | +// } |
---|
| 8194 | +// |
---|
| 8195 | +// if (tex == null) |
---|
| 8196 | +// { |
---|
| 8197 | +// BindTexture(null,false,resolution); |
---|
| 8198 | +// BindTexture(null,true,resolution); |
---|
| 8199 | +// return; |
---|
| 8200 | +// } |
---|
| 8201 | +// |
---|
| 8202 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8203 | +// String bump = Object3D.GetBump(tex); |
---|
| 8204 | +// |
---|
| 8205 | +// usedtextures.add(pigment); |
---|
| 8206 | +// usedtextures.add(bump); |
---|
| 8207 | +// |
---|
| 8208 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8209 | +// { |
---|
| 8210 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8211 | +// // System.out.println("; bump = " + bump); |
---|
| 8212 | +// } |
---|
| 8213 | +// |
---|
| 8214 | +// if (bump.equals("")) |
---|
| 8215 | +// { |
---|
| 8216 | +// bump = null; |
---|
| 8217 | +// } |
---|
| 8218 | +// if (pigment.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// pigment = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// |
---|
| 8223 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8224 | +// BindTexture(pigment, false, resolution); |
---|
| 8225 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8226 | +// BindTexture(bump, true, resolution); |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// |
---|
| 8229 | +// return; // true; |
---|
| 8230 | + |
---|
| 8231 | + BindPigmentTexture(tex, resolution); |
---|
| 8232 | + BindBumpTexture(tex, resolution); |
---|
| 8233 | + } |
---|
| 8234 | + |
---|
| 8235 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8236 | + { |
---|
8029 | 8237 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8030 | 8238 | ambientOcclusion ) // || !textureon) |
---|
8031 | 8239 | { |
---|
.. | .. |
---|
8035 | 8243 | if (tex == null) |
---|
8036 | 8244 | { |
---|
8037 | 8245 | BindTexture(null,false,resolution); |
---|
8038 | | - BindTexture(null,true,resolution); |
---|
8039 | 8246 | return; |
---|
8040 | 8247 | } |
---|
8041 | 8248 | |
---|
8042 | 8249 | String pigment = Object3D.GetPigment(tex); |
---|
| 8250 | + |
---|
| 8251 | + usedtextures.add(tex); |
---|
| 8252 | + |
---|
| 8253 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8254 | + { |
---|
| 8255 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8256 | + // System.out.println("; bump = " + bump); |
---|
| 8257 | + } |
---|
| 8258 | + |
---|
| 8259 | + if (pigment.equals("")) |
---|
| 8260 | + { |
---|
| 8261 | + pigment = null; |
---|
| 8262 | + } |
---|
| 8263 | + |
---|
| 8264 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8265 | + BindTexture(tex, false, resolution); |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8269 | + { |
---|
| 8270 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8271 | + ambientOcclusion ) // || !textureon) |
---|
| 8272 | + { |
---|
| 8273 | + return; // false; |
---|
| 8274 | + } |
---|
| 8275 | + |
---|
| 8276 | + if (tex == null) |
---|
| 8277 | + { |
---|
| 8278 | + BindTexture(null,true,resolution); |
---|
| 8279 | + return; |
---|
| 8280 | + } |
---|
| 8281 | + |
---|
8043 | 8282 | String bump = Object3D.GetBump(tex); |
---|
8044 | 8283 | |
---|
8045 | | - usedtextures.put(pigment, pigment); |
---|
8046 | | - usedtextures.put(bump, bump); |
---|
| 8284 | + usedtextures.add(tex); |
---|
8047 | 8285 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8286 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8287 | { |
---|
8050 | 8288 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8289 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8055 | 8293 | { |
---|
8056 | 8294 | bump = null; |
---|
8057 | 8295 | } |
---|
8058 | | - if (pigment.equals("")) |
---|
8059 | | - { |
---|
8060 | | - pigment = null; |
---|
8061 | | - } |
---|
8062 | 8296 | |
---|
8063 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8064 | | - BindTexture(pigment, false, resolution); |
---|
8065 | 8297 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8066 | | - BindTexture(bump, true, resolution); |
---|
| 8298 | + BindTexture(tex, true, resolution); |
---|
8067 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8068 | | - |
---|
8069 | | - return; // true; |
---|
8070 | 8300 | } |
---|
8071 | 8301 | |
---|
8072 | 8302 | java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
.. | .. |
---|
8089 | 8319 | return fileExists; |
---|
8090 | 8320 | } |
---|
8091 | 8321 | |
---|
8092 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8322 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8093 | 8323 | { |
---|
8094 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8324 | + CacheTexture texturecache = null; |
---|
8095 | 8325 | |
---|
8096 | 8326 | if (tex != null) |
---|
8097 | 8327 | { |
---|
8098 | | - String texname = tex; |
---|
| 8328 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8329 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8330 | + |
---|
| 8331 | + if (texname.equals("") && texdata == null) |
---|
| 8332 | + { |
---|
| 8333 | + return null; |
---|
| 8334 | + } |
---|
8099 | 8335 | |
---|
8100 | 8336 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8101 | 8337 | |
---|
.. | .. |
---|
8105 | 8341 | // else |
---|
8106 | 8342 | // if (!texname.startsWith("/")) |
---|
8107 | 8343 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8108 | | - if (!FileExists(tex)) |
---|
| 8344 | + if (!FileExists(texname)) |
---|
8109 | 8345 | { |
---|
8110 | 8346 | texname = fallbackTextureName; |
---|
8111 | 8347 | } |
---|
8112 | 8348 | |
---|
8113 | 8349 | if (CACHETEXTURE) |
---|
8114 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8115 | | - |
---|
8116 | | - TextureData texturedata = null; |
---|
8117 | | - |
---|
8118 | | - if (texture == null || texture.resolution < resolution) |
---|
8119 | 8350 | { |
---|
8120 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8351 | + if (texdata == null) |
---|
| 8352 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8353 | + else |
---|
| 8354 | + texturecache = bimtextures.get(texdata); |
---|
| 8355 | + } |
---|
| 8356 | + |
---|
| 8357 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8358 | + { |
---|
| 8359 | + TextureData texturedata = null; |
---|
| 8360 | + |
---|
| 8361 | + if (texdata != null) |
---|
| 8362 | + { |
---|
| 8363 | + BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8364 | + |
---|
| 8365 | + CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8366 | + |
---|
| 8367 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8368 | + bimtextures.put(texdata, texturecache); |
---|
| 8369 | + } |
---|
| 8370 | + else |
---|
| 8371 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8121 | 8372 | { |
---|
8122 | 8373 | assert(!bump); |
---|
8123 | 8374 | // if (bump) |
---|
.. | .. |
---|
8128 | 8379 | // } |
---|
8129 | 8380 | // else |
---|
8130 | 8381 | // { |
---|
8131 | | - texture = textures.get(tex); |
---|
8132 | | - if (texture == null) |
---|
| 8382 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8383 | + if (texturecache == null) |
---|
8133 | 8384 | { |
---|
8134 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8385 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8135 | 8386 | } |
---|
| 8387 | + else |
---|
| 8388 | + new Exception().printStackTrace(); |
---|
8136 | 8389 | // } |
---|
8137 | 8390 | } else |
---|
8138 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8391 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8139 | 8392 | { |
---|
8140 | 8393 | assert(bump); |
---|
8141 | | - texture = textures.get(tex); |
---|
8142 | | - if (texture == null) |
---|
8143 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8394 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8395 | + if (texturecache == null) |
---|
| 8396 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8397 | + else |
---|
| 8398 | + new Exception().printStackTrace(); |
---|
8144 | 8399 | } else |
---|
8145 | 8400 | { |
---|
8146 | 8401 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8148 | 8403 | // texture = GetResourceTexture("default.png"); |
---|
8149 | 8404 | //} else |
---|
8150 | 8405 | //{ |
---|
8151 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8406 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8152 | 8407 | { |
---|
8153 | | - texture = textures.get(tex); |
---|
8154 | | - if (texture == null) |
---|
8155 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8408 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8409 | + if (texturecache == null) |
---|
| 8410 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8411 | + else |
---|
| 8412 | + new Exception().printStackTrace(); |
---|
8156 | 8413 | } else |
---|
8157 | 8414 | { |
---|
8158 | 8415 | if (textureon) |
---|
.. | .. |
---|
8211 | 8468 | if (texturedata == null) |
---|
8212 | 8469 | throw new Exception(); |
---|
8213 | 8470 | |
---|
8214 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8471 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8215 | 8472 | //texture = GetTexture(tex, bump); |
---|
8216 | 8473 | } |
---|
8217 | 8474 | } |
---|
8218 | 8475 | //} |
---|
8219 | 8476 | } |
---|
8220 | 8477 | |
---|
8221 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8478 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8222 | 8479 | { |
---|
8223 | 8480 | //return false; |
---|
8224 | 8481 | |
---|
8225 | 8482 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8226 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8483 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8227 | 8484 | { |
---|
8228 | 8485 | // String ext = "_highres"; |
---|
8229 | 8486 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8240 | 8497 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8241 | 8498 | if (!cachefile.exists()) |
---|
8242 | 8499 | { |
---|
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)) |
---|
| 8500 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8252 | 8501 | { |
---|
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); |
---|
| 8502 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8503 | + |
---|
8283 | 8504 | ImageWriter writer = null; |
---|
8284 | 8505 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8285 | 8506 | if (iter.hasNext()) { |
---|
8286 | 8507 | writer = (ImageWriter)iter.next(); |
---|
8287 | 8508 | } |
---|
8288 | | - float compressionQuality = 0.9f; |
---|
| 8509 | + |
---|
| 8510 | + float compressionQuality = 0.85f; |
---|
8289 | 8511 | try |
---|
8290 | 8512 | { |
---|
8291 | 8513 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8302 | 8524 | } |
---|
8303 | 8525 | } |
---|
8304 | 8526 | } |
---|
8305 | | - |
---|
| 8527 | + |
---|
| 8528 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8529 | + |
---|
8306 | 8530 | //System.out.println("Texture = " + tex); |
---|
8307 | | - if (textures.containsKey(texname)) |
---|
| 8531 | + if (textures.containsKey(tex)) |
---|
8308 | 8532 | { |
---|
8309 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8533 | + CacheTexture thetex = textures.get(tex); |
---|
8310 | 8534 | thetex.texture.disable(); |
---|
8311 | 8535 | thetex.texture.dispose(); |
---|
8312 | | - textures.remove(texname); |
---|
| 8536 | + textures.remove(tex); |
---|
8313 | 8537 | } |
---|
8314 | 8538 | |
---|
8315 | | - texture.texturedata = texturedata; |
---|
8316 | | - textures.put(texname, texture); |
---|
| 8539 | + //texture.texturedata = texturedata; |
---|
| 8540 | + textures.put(tex, texturecache); |
---|
8317 | 8541 | |
---|
8318 | 8542 | // newtex = true; |
---|
8319 | 8543 | } |
---|
.. | .. |
---|
8329 | 8553 | } |
---|
8330 | 8554 | } |
---|
8331 | 8555 | |
---|
8332 | | - return texture; |
---|
| 8556 | + return texturecache; |
---|
8333 | 8557 | } |
---|
8334 | 8558 | |
---|
8335 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8559 | + static void EmbedTextures(cTexture tex) |
---|
| 8560 | + { |
---|
| 8561 | + if (tex.pigmentdata == null) |
---|
| 8562 | + { |
---|
| 8563 | + String texname = Object3D.GetPigment(tex); |
---|
| 8564 | + |
---|
| 8565 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8566 | + |
---|
| 8567 | + if (texturecache != null) |
---|
| 8568 | + { |
---|
| 8569 | + tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8570 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8571 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8572 | + } |
---|
| 8573 | + } |
---|
| 8574 | + |
---|
| 8575 | + if (tex.bumpdata == null) |
---|
| 8576 | + { |
---|
| 8577 | + String texname = Object3D.GetBump(tex); |
---|
| 8578 | + |
---|
| 8579 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8580 | + |
---|
| 8581 | + if (texturecache != null) |
---|
| 8582 | + { |
---|
| 8583 | + tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8584 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8585 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8586 | + } |
---|
| 8587 | + } |
---|
| 8588 | + } |
---|
| 8589 | + |
---|
| 8590 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8336 | 8591 | { |
---|
8337 | 8592 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8338 | 8593 | |
---|
.. | .. |
---|
8350 | 8605 | return texture!=null?texture.texture:null; |
---|
8351 | 8606 | } |
---|
8352 | 8607 | |
---|
8353 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8608 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8354 | 8609 | { |
---|
8355 | 8610 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8356 | 8611 | |
---|
8357 | 8612 | return texture!=null?texture.texturedata:null; |
---|
8358 | 8613 | } |
---|
8359 | 8614 | |
---|
8360 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8615 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8361 | 8616 | { |
---|
8362 | 8617 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8363 | 8618 | { |
---|
8364 | 8619 | return false; |
---|
8365 | 8620 | } |
---|
8366 | 8621 | |
---|
8367 | | - boolean newtex = false; |
---|
| 8622 | + //boolean newtex = false; |
---|
8368 | 8623 | |
---|
8369 | 8624 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8370 | 8625 | |
---|
.. | .. |
---|
8396 | 8651 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8397 | 8652 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8398 | 8653 | |
---|
8399 | | - return newtex; |
---|
| 8654 | + return true; // Warning: not used. |
---|
8400 | 8655 | } |
---|
8401 | 8656 | |
---|
8402 | 8657 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
9234 | 9489 | jy8[3] = 0.5f; |
---|
9235 | 9490 | } |
---|
9236 | 9491 | |
---|
9237 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9492 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9238 | 9493 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9239 | 9494 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9240 | 9495 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9241 | 9496 | |
---|
| 9497 | + void ResetOptions() |
---|
| 9498 | + { |
---|
| 9499 | + options1[0] = 100; |
---|
| 9500 | + options1[1] = 0.025f; |
---|
| 9501 | + options1[2] = 0.01f; |
---|
| 9502 | + options1[3] = 0; |
---|
| 9503 | + options1[4] = 0; |
---|
| 9504 | + |
---|
| 9505 | + options2[0] = 0; |
---|
| 9506 | + options2[1] = 0.75f; |
---|
| 9507 | + options2[2] = 0; |
---|
| 9508 | + options2[3] = 0; |
---|
| 9509 | + |
---|
| 9510 | + options3[0] = 1; |
---|
| 9511 | + options3[1] = 1; |
---|
| 9512 | + options3[2] = 1; |
---|
| 9513 | + options3[3] = 0; |
---|
| 9514 | + |
---|
| 9515 | + options4[0] = 1; |
---|
| 9516 | + options4[1] = 0; |
---|
| 9517 | + options4[2] = 1; |
---|
| 9518 | + options4[3] = 0; |
---|
| 9519 | + } |
---|
| 9520 | + |
---|
9242 | 9521 | static int imagecount = 0; // movie generation |
---|
9243 | 9522 | |
---|
9244 | 9523 | static int jitter = 0; |
---|
.. | .. |
---|
9335 | 9614 | |
---|
9336 | 9615 | if (renderCamera != lightCamera) |
---|
9337 | 9616 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9338 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 9617 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9339 | 9618 | |
---|
9340 | 9619 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9341 | 9620 | |
---|
.. | .. |
---|
9351 | 9630 | |
---|
9352 | 9631 | if (renderCamera != lightCamera) |
---|
9353 | 9632 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9354 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 9633 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9355 | 9634 | |
---|
9356 | 9635 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9357 | 9636 | |
---|
.. | .. |
---|
10349 | 10628 | ANTIALIAS = 0; |
---|
10350 | 10629 | //System.out.println("RESTART"); |
---|
10351 | 10630 | AAtimer.restart(); |
---|
| 10631 | + Globals.TIMERRUNNING = true; |
---|
10352 | 10632 | } |
---|
10353 | 10633 | } |
---|
10354 | 10634 | } |
---|
.. | .. |
---|
10416 | 10696 | ambientOcclusion = false; |
---|
10417 | 10697 | } |
---|
10418 | 10698 | |
---|
10419 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10699 | + if (//Globals.lighttouched && |
---|
| 10700 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10420 | 10701 | { |
---|
10421 | 10702 | //if (RENDERSHADOW) // ? |
---|
10422 | 10703 | if (!IsFrozen()) |
---|
.. | .. |
---|
10550 | 10831 | // if (parentcam != renderCamera) // not a light |
---|
10551 | 10832 | if (cam != lightCamera) |
---|
10552 | 10833 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10553 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 10834 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10554 | 10835 | |
---|
10555 | 10836 | for (int j = 0; j < 4; j++) |
---|
10556 | 10837 | { |
---|
.. | .. |
---|
10565 | 10846 | // if (parentcam != renderCamera) // not a light |
---|
10566 | 10847 | if (cam != lightCamera) |
---|
10567 | 10848 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10568 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 10849 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10569 | 10850 | |
---|
10570 | 10851 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10571 | 10852 | |
---|
.. | .. |
---|
10856 | 11137 | |
---|
10857 | 11138 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10858 | 11139 | |
---|
10859 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10860 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10861 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11140 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11141 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11142 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10862 | 11143 | } else |
---|
10863 | 11144 | { |
---|
10864 | 11145 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10869 | 11150 | //System.out.println("BLENDING ON"); |
---|
10870 | 11151 | gl.glEnable(GL.GL_BLEND); |
---|
10871 | 11152 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10872 | | - |
---|
| 11153 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10873 | 11154 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10874 | 11155 | gl.glLoadIdentity(); |
---|
10875 | 11156 | |
---|
.. | .. |
---|
10959 | 11240 | |
---|
10960 | 11241 | // if (cam != lightCamera) |
---|
10961 | 11242 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10962 | | - LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
| 11243 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10963 | 11244 | } |
---|
10964 | 11245 | |
---|
10965 | 11246 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10981 | 11262 | { |
---|
10982 | 11263 | if (cam != lightCamera) |
---|
10983 | 11264 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10984 | | - LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013 |
---|
| 11265 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10985 | 11266 | } |
---|
10986 | 11267 | |
---|
10987 | 11268 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11326 | 11607 | |
---|
11327 | 11608 | static boolean zoomonce = false; |
---|
11328 | 11609 | |
---|
| 11610 | + static void CreateSelectedPoint() |
---|
| 11611 | + { |
---|
| 11612 | + if (selectedpoint == null) |
---|
| 11613 | + { |
---|
| 11614 | + debugpointG = new Sphere(); |
---|
| 11615 | + debugpointP = new Sphere(); |
---|
| 11616 | + debugpointC = new Sphere(); |
---|
| 11617 | + debugpointR = new Sphere(); |
---|
| 11618 | + |
---|
| 11619 | + selectedpoint = new Superellipsoid(); |
---|
| 11620 | + |
---|
| 11621 | + for (int i=0; i<8; i++) |
---|
| 11622 | + { |
---|
| 11623 | + debugpoints[i] = new Sphere(); |
---|
| 11624 | + } |
---|
| 11625 | + } |
---|
| 11626 | + } |
---|
| 11627 | + |
---|
11329 | 11628 | void DrawObject(GL gl, boolean draw) |
---|
11330 | 11629 | { |
---|
| 11630 | + // To clear camera values |
---|
| 11631 | + ResetOptions(); |
---|
| 11632 | + |
---|
11331 | 11633 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11332 | 11634 | // DrawMode() = SELECTION; |
---|
11333 | 11635 | //GL gl = getGL(); |
---|
11334 | 11636 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11335 | 11637 | { |
---|
11336 | 11638 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11337 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11639 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11338 | 11640 | pingthread.StepToTarget(true); // true); |
---|
11339 | 11641 | // zoomonce = false; |
---|
11340 | 11642 | } |
---|
.. | .. |
---|
11406 | 11708 | |
---|
11407 | 11709 | if (DrawMode() == DEFAULT) |
---|
11408 | 11710 | { |
---|
11409 | | - if (DEBUG) |
---|
| 11711 | + if (Globals.DEBUG) |
---|
11410 | 11712 | { |
---|
| 11713 | + CreateSelectedPoint(); |
---|
11411 | 11714 | float radius = 0.05f; |
---|
11412 | 11715 | if (selectedpoint.radius != radius) |
---|
11413 | 11716 | { |
---|
.. | .. |
---|
11461 | 11764 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11462 | 11765 | |
---|
11463 | 11766 | if (CLEANCACHE) |
---|
11464 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11767 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11465 | 11768 | { |
---|
11466 | | - String tex = e.nextElement(); |
---|
| 11769 | + cTexture tex = e.nextElement(); |
---|
11467 | 11770 | |
---|
11468 | 11771 | // System.out.println("Texture --------- " + tex); |
---|
11469 | 11772 | |
---|
11470 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11773 | + if (tex.equals("WHITE_NOISE:")) |
---|
11471 | 11774 | continue; |
---|
11472 | 11775 | |
---|
11473 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11776 | + if (!usedtextures.contains(tex)) |
---|
11474 | 11777 | { |
---|
| 11778 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11475 | 11779 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11476 | | - textures.get(tex).texture.dispose(); |
---|
11477 | | - textures.remove(tex); |
---|
| 11780 | + if (gettex != null) |
---|
| 11781 | + { |
---|
| 11782 | + gettex.texture.dispose(); |
---|
| 11783 | + texturepigment.remove(tex); |
---|
| 11784 | + } |
---|
| 11785 | + |
---|
| 11786 | + gettex = texturebump.get(tex); |
---|
| 11787 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11788 | + if (gettex != null) |
---|
| 11789 | + { |
---|
| 11790 | + gettex.texture.dispose(); |
---|
| 11791 | + texturebump.remove(tex); |
---|
| 11792 | + } |
---|
11478 | 11793 | } |
---|
11479 | 11794 | } |
---|
11480 | 11795 | } |
---|
.. | .. |
---|
11912 | 12227 | } |
---|
11913 | 12228 | |
---|
11914 | 12229 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11915 | | - LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013 |
---|
| 12230 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11916 | 12231 | |
---|
11917 | 12232 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11918 | 12233 | |
---|
.. | .. |
---|
13164 | 13479 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13165 | 13480 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13166 | 13481 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13167 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13482 | + |
---|
| 13483 | + //Object3D.cVector2[] vector2buffer; |
---|
13168 | 13484 | |
---|
13169 | 13485 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13170 | 13486 | // OUT : diff, spec |
---|
.. | .. |
---|
13180 | 13496 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13181 | 13497 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13182 | 13498 | //"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;" + |
---|
| 13499 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13500 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13501 | + |
---|
| 13502 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13186 | 13503 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13187 | 13504 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13188 | 13505 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13687 | 14004 | else |
---|
13688 | 14005 | if (evt.getSource() == AAtimer) |
---|
13689 | 14006 | { |
---|
| 14007 | + Globals.TIMERRUNNING = false; |
---|
13690 | 14008 | if (mouseDown) |
---|
13691 | 14009 | { |
---|
13692 | 14010 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13746 | 14064 | |
---|
13747 | 14065 | // fev 2014??? |
---|
13748 | 14066 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13749 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14067 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13750 | 14068 | pingthread.StepToTarget(true); // true); |
---|
13751 | 14069 | } |
---|
13752 | 14070 | // if (!LIVE) |
---|
.. | .. |
---|
13761 | 14079 | return; |
---|
13762 | 14080 | |
---|
13763 | 14081 | AAtimer.restart(); // |
---|
| 14082 | + Globals.TIMERRUNNING = true; |
---|
13764 | 14083 | |
---|
13765 | 14084 | // waslive = LIVE; |
---|
13766 | 14085 | // LIVE = false; |
---|
.. | .. |
---|
13833 | 14152 | |
---|
13834 | 14153 | public void mouseDragged(MouseEvent e) |
---|
13835 | 14154 | { |
---|
| 14155 | + Globals.MOUSEDRAGGED = true; |
---|
| 14156 | + |
---|
13836 | 14157 | //System.out.println("mouseDragged: " + e); |
---|
13837 | 14158 | if (isRenderer) |
---|
13838 | 14159 | movingcamera = true; |
---|
.. | .. |
---|
14097 | 14418 | void GoDown(int mod) |
---|
14098 | 14419 | { |
---|
14099 | 14420 | MODIFIERS |= COMMAND; |
---|
14100 | | - /* |
---|
| 14421 | + /**/ |
---|
14101 | 14422 | if((mod&SHIFT) == SHIFT) |
---|
14102 | 14423 | manipCamera.RotatePosition(0, -speed); |
---|
14103 | 14424 | else |
---|
14104 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14105 | | - */ |
---|
| 14425 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14426 | + /**/ |
---|
14106 | 14427 | if ((mod & SHIFT) == SHIFT) |
---|
14107 | 14428 | { |
---|
14108 | 14429 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14118 | 14439 | void GoUp(int mod) |
---|
14119 | 14440 | { |
---|
14120 | 14441 | MODIFIERS |= COMMAND; |
---|
14121 | | - /* |
---|
| 14442 | + /**/ |
---|
14122 | 14443 | if((mod&SHIFT) == SHIFT) |
---|
14123 | 14444 | manipCamera.RotatePosition(0, speed); |
---|
14124 | 14445 | else |
---|
14125 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14126 | | - */ |
---|
| 14446 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14447 | + /**/ |
---|
14127 | 14448 | if ((mod & SHIFT) == SHIFT) |
---|
14128 | 14449 | { |
---|
14129 | 14450 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14139 | 14460 | void GoLeft(int mod) |
---|
14140 | 14461 | { |
---|
14141 | 14462 | MODIFIERS |= COMMAND; |
---|
14142 | | - /* |
---|
| 14463 | + /**/ |
---|
14143 | 14464 | if((mod&SHIFT) == SHIFT) |
---|
14144 | | - manipCamera.RotatePosition(speed, 0); |
---|
14145 | | - else |
---|
14146 | 14465 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14147 | | - */ |
---|
| 14466 | + else |
---|
| 14467 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14468 | + /**/ |
---|
14148 | 14469 | if ((mod & SHIFT) == SHIFT) |
---|
14149 | 14470 | { |
---|
14150 | 14471 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14160 | 14481 | void GoRight(int mod) |
---|
14161 | 14482 | { |
---|
14162 | 14483 | MODIFIERS |= COMMAND; |
---|
14163 | | - /* |
---|
| 14484 | + /**/ |
---|
14164 | 14485 | if((mod&SHIFT) == SHIFT) |
---|
14165 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14166 | | - else |
---|
14167 | 14486 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14168 | | - */ |
---|
| 14487 | + else |
---|
| 14488 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14489 | + /**/ |
---|
14169 | 14490 | if ((mod & SHIFT) == SHIFT) |
---|
14170 | 14491 | { |
---|
14171 | 14492 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14222 | 14543 | info.camera = renderCamera; |
---|
14223 | 14544 | info.x = x; |
---|
14224 | 14545 | info.y = y; |
---|
14225 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14546 | + object.GetWindow().copy |
---|
| 14547 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14226 | 14548 | } else |
---|
14227 | 14549 | { |
---|
14228 | 14550 | if (x < startX) |
---|
.. | .. |
---|
14386 | 14708 | ci.camera = renderCamera; |
---|
14387 | 14709 | if (!isRenderer) |
---|
14388 | 14710 | { |
---|
14389 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14711 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14712 | + //Object3D copy = editWindow.copy; |
---|
| 14713 | + if (object.doEditClick(ci, 0)) |
---|
14390 | 14714 | { |
---|
14391 | 14715 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14392 | 14716 | } else |
---|
.. | .. |
---|
14398 | 14722 | |
---|
14399 | 14723 | public void mouseReleased(MouseEvent e) |
---|
14400 | 14724 | { |
---|
| 14725 | + Globals.MOUSEDRAGGED = false; |
---|
| 14726 | + |
---|
14401 | 14727 | movingcamera = false; |
---|
14402 | | - X = Y = 0; |
---|
| 14728 | + X = 0; // getBounds().width/2; |
---|
| 14729 | + Y = 0; // getBounds().height/2; |
---|
14403 | 14730 | //System.out.println("mouseReleased: " + e); |
---|
14404 | 14731 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14405 | 14732 | } |
---|
.. | .. |
---|
14655 | 14982 | // break; |
---|
14656 | 14983 | case 'T': |
---|
14657 | 14984 | CACHETEXTURE ^= true; |
---|
14658 | | - textures.clear(); |
---|
| 14985 | + texturepigment.clear(); |
---|
| 14986 | + texturebump.clear(); |
---|
14659 | 14987 | // repaint(); |
---|
14660 | 14988 | break; |
---|
14661 | 14989 | case 'Y': |
---|
.. | .. |
---|
14740 | 15068 | case 'E' : COMPACT ^= true; |
---|
14741 | 15069 | repaint(); |
---|
14742 | 15070 | break; |
---|
14743 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15071 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15072 | + //DEBUGHSB ^= true; |
---|
| 15073 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14744 | 15074 | repaint(); |
---|
14745 | 15075 | break; |
---|
14746 | 15076 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14765 | 15095 | RevertCamera(); |
---|
14766 | 15096 | repaint(); |
---|
14767 | 15097 | break; |
---|
14768 | | - case 'L': |
---|
14769 | 15098 | case 'l': |
---|
| 15099 | + //case 'L': |
---|
14770 | 15100 | if (lightMode) |
---|
14771 | 15101 | { |
---|
14772 | 15102 | lightMode = false; |
---|
.. | .. |
---|
14909 | 15239 | case '_': |
---|
14910 | 15240 | kompactbit = 5; |
---|
14911 | 15241 | break; |
---|
14912 | | - case '+': |
---|
14913 | | - kompactbit = 6; |
---|
14914 | | - break; |
---|
| 15242 | +// case '+': |
---|
| 15243 | +// kompactbit = 6; |
---|
| 15244 | +// break; |
---|
14915 | 15245 | case ' ': |
---|
14916 | 15246 | lightMode ^= true; |
---|
14917 | 15247 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14923 | 15253 | case ESC: |
---|
14924 | 15254 | RENDERPROGRAM += 1; |
---|
14925 | 15255 | RENDERPROGRAM %= 3; |
---|
| 15256 | + |
---|
14926 | 15257 | repaint(); |
---|
14927 | 15258 | break; |
---|
14928 | 15259 | case 'Z': |
---|
.. | .. |
---|
14962 | 15293 | case DELETE: |
---|
14963 | 15294 | ClearSelection(); |
---|
14964 | 15295 | break; |
---|
14965 | | - /* |
---|
14966 | 15296 | case '+': |
---|
| 15297 | + |
---|
| 15298 | + /* |
---|
14967 | 15299 | //fontsize += 1; |
---|
14968 | 15300 | bbzoom *= 2; |
---|
14969 | 15301 | repaint(); |
---|
.. | .. |
---|
14980 | 15312 | case '=': |
---|
14981 | 15313 | IncDepth(); |
---|
14982 | 15314 | //fontsize += 1; |
---|
14983 | | - object.editWindow.refreshContents(true); |
---|
| 15315 | + object.GetWindow().refreshContents(true); |
---|
14984 | 15316 | maskbit = 6; |
---|
14985 | 15317 | break; |
---|
14986 | 15318 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14987 | 15319 | DecDepth(); |
---|
14988 | 15320 | maskbit = 5; |
---|
14989 | 15321 | //if(fontsize > 1) fontsize -= 1; |
---|
14990 | | - if (object.editWindow == null) |
---|
14991 | | - new Exception().printStackTrace(); |
---|
14992 | | - else |
---|
14993 | | - object.editWindow.refreshContents(true); |
---|
| 15322 | +// if (object.editWindow == null) |
---|
| 15323 | +// new Exception().printStackTrace(); |
---|
| 15324 | +// else |
---|
| 15325 | + object.GetWindow().refreshContents(true); |
---|
14994 | 15326 | break; |
---|
14995 | 15327 | case '{': |
---|
14996 | 15328 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15214 | 15546 | } |
---|
15215 | 15547 | */ |
---|
15216 | 15548 | |
---|
15217 | | - object.editWindow.EditSelection(); |
---|
| 15549 | + object.GetWindow().EditSelection(false); |
---|
15218 | 15550 | } |
---|
15219 | 15551 | |
---|
15220 | 15552 | void SelectParent() |
---|
.. | .. |
---|
15231 | 15563 | { |
---|
15232 | 15564 | //selectees.remove(i); |
---|
15233 | 15565 | System.out.println("select parent of " + elem); |
---|
15234 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15566 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15235 | 15567 | } else |
---|
15236 | 15568 | { |
---|
15237 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15569 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15238 | 15570 | } |
---|
15239 | 15571 | |
---|
15240 | 15572 | first = false; |
---|
.. | .. |
---|
15276 | 15608 | for (int j = 0; j < group.children.size(); j++) |
---|
15277 | 15609 | { |
---|
15278 | 15610 | elem = (Object3D) group.children.elementAt(j); |
---|
15279 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15611 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15280 | 15612 | first = false; |
---|
15281 | 15613 | } |
---|
15282 | 15614 | } else |
---|
15283 | 15615 | { |
---|
15284 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15616 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15285 | 15617 | } |
---|
15286 | 15618 | |
---|
15287 | 15619 | first = false; |
---|
.. | .. |
---|
15292 | 15624 | { |
---|
15293 | 15625 | //Composite group = (Composite) object; |
---|
15294 | 15626 | Object3D group = object; |
---|
15295 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15627 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15296 | 15628 | } |
---|
15297 | 15629 | |
---|
15298 | 15630 | void ResetTransform(int mask) |
---|
15299 | 15631 | { |
---|
15300 | 15632 | //Composite group = (Composite) object; |
---|
15301 | 15633 | Object3D group = object; |
---|
15302 | | - group.editWindow.ResetTransform(mask); |
---|
| 15634 | + group.GetWindow().ResetTransform(mask); |
---|
15303 | 15635 | } |
---|
15304 | 15636 | |
---|
15305 | 15637 | void FlipTransform() |
---|
15306 | 15638 | { |
---|
15307 | 15639 | //Composite group = (Composite) object; |
---|
15308 | 15640 | Object3D group = object; |
---|
15309 | | - group.editWindow.FlipTransform(); |
---|
| 15641 | + group.GetWindow().FlipTransform(); |
---|
15310 | 15642 | // group.editWindow.ReduceMesh(true); |
---|
15311 | 15643 | } |
---|
15312 | 15644 | |
---|
.. | .. |
---|
15314 | 15646 | { |
---|
15315 | 15647 | //Composite group = (Composite) object; |
---|
15316 | 15648 | Object3D group = object; |
---|
15317 | | - group.editWindow.PrintMemory(); |
---|
| 15649 | + group.GetWindow().PrintMemory(); |
---|
15318 | 15650 | // group.editWindow.ReduceMesh(true); |
---|
15319 | 15651 | } |
---|
15320 | 15652 | |
---|
.. | .. |
---|
15322 | 15654 | { |
---|
15323 | 15655 | //Composite group = (Composite) object; |
---|
15324 | 15656 | Object3D group = object; |
---|
15325 | | - group.editWindow.ResetCentroid(); |
---|
| 15657 | + group.GetWindow().ResetCentroid(); |
---|
15326 | 15658 | } |
---|
15327 | 15659 | |
---|
15328 | 15660 | void IncDepth() |
---|
.. | .. |
---|
15498 | 15830 | info.bounds.y += (height - desired) / 2; |
---|
15499 | 15831 | } |
---|
15500 | 15832 | } |
---|
| 15833 | + |
---|
15501 | 15834 | info.g = gr; |
---|
15502 | 15835 | info.camera = renderCamera; |
---|
15503 | 15836 | /* |
---|
.. | .. |
---|
15507 | 15840 | */ |
---|
15508 | 15841 | if (!isRenderer) |
---|
15509 | 15842 | { |
---|
15510 | | - object.drawEditHandles(info, 0); |
---|
15511 | | - |
---|
15512 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15843 | + Grafreed.Assert(object != null); |
---|
| 15844 | + Grafreed.Assert(object.selection != null); |
---|
| 15845 | + if (object.selection.Size() > 0) |
---|
15513 | 15846 | { |
---|
15514 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15847 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15848 | + |
---|
| 15849 | + info.DX = 0; |
---|
| 15850 | + info.DY = 0; |
---|
| 15851 | + info.W = 1; |
---|
| 15852 | + if (hitSomething == Object3D.hitCenter) |
---|
15515 | 15853 | { |
---|
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; |
---|
| 15854 | + info.DX = X; |
---|
| 15855 | + if (X != 0) |
---|
| 15856 | + info.DX -= info.bounds.width/2; |
---|
| 15857 | + |
---|
| 15858 | + info.DY = Y; |
---|
| 15859 | + if (Y != 0) |
---|
| 15860 | + info.DY -= info.bounds.height/2; |
---|
15519 | 15861 | } |
---|
15520 | | - |
---|
15521 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15862 | + |
---|
| 15863 | + object.drawEditHandles(info, 0); |
---|
| 15864 | + |
---|
| 15865 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15866 | + { |
---|
| 15867 | + switch (hitSomething) |
---|
| 15868 | + { |
---|
| 15869 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15870 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15871 | + break; |
---|
| 15872 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15873 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15874 | + break; |
---|
| 15875 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15876 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15877 | + break; |
---|
| 15878 | + } |
---|
| 15879 | + |
---|
| 15880 | + } |
---|
15522 | 15881 | } |
---|
15523 | 15882 | } |
---|
15524 | 15883 | } |
---|
.. | .. |
---|
16221 | 16580 | cStatic.objectstack[materialdepth++] = checker; |
---|
16222 | 16581 | //System.out.println("material " + material); |
---|
16223 | 16582 | //Applet3D.tracein(this, selected); |
---|
16224 | | - vector2buffer = checker.projectedVertices; |
---|
| 16583 | + //vector2buffer = checker.projectedVertices; |
---|
16225 | 16584 | |
---|
16226 | 16585 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16227 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16586 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16228 | 16587 | |
---|
16229 | 16588 | materialdepth -= 1; |
---|
16230 | 16589 | if (materialdepth > 0) |
---|
16231 | 16590 | { |
---|
16232 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16233 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16591 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16592 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16234 | 16593 | } |
---|
16235 | 16594 | //checker.GetMaterial().opacity = 1f; |
---|
16236 | 16595 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16316 | 16675 | } |
---|
16317 | 16676 | } |
---|
16318 | 16677 | |
---|
| 16678 | + private Object3D GetFolder() |
---|
| 16679 | + { |
---|
| 16680 | + Object3D folder = object.GetWindow().copy; |
---|
| 16681 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16682 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16683 | + return folder; |
---|
| 16684 | + } |
---|
| 16685 | + |
---|
16319 | 16686 | class SelectBuffer implements GLEventListener |
---|
16320 | 16687 | { |
---|
16321 | 16688 | |
---|
.. | .. |
---|
16395 | 16762 | |
---|
16396 | 16763 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16397 | 16764 | |
---|
| 16765 | + if (PAINTMODE) |
---|
| 16766 | + { |
---|
| 16767 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16768 | + { |
---|
| 16769 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16770 | + |
---|
| 16771 | + // Make what you paint not selectable. |
---|
| 16772 | + paintobj.ResetSelectable(); |
---|
| 16773 | + } |
---|
| 16774 | + } |
---|
| 16775 | + |
---|
16398 | 16776 | //int tmp = selection_view; |
---|
16399 | 16777 | //selection_view = -1; |
---|
16400 | 16778 | int temp = DrawMode(); |
---|
.. | .. |
---|
16406 | 16784 | // temp = DEFAULT; // patch for selection debug |
---|
16407 | 16785 | Globals.drawMode = temp; // WARNING |
---|
16408 | 16786 | |
---|
| 16787 | + if (PAINTMODE) |
---|
| 16788 | + { |
---|
| 16789 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16790 | + { |
---|
| 16791 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16792 | + |
---|
| 16793 | + // Revert. |
---|
| 16794 | + paintobj.RestoreSelectable(); |
---|
| 16795 | + } |
---|
| 16796 | + } |
---|
| 16797 | + |
---|
16409 | 16798 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16410 | 16799 | |
---|
16411 | 16800 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16453 | 16842 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16454 | 16843 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16455 | 16844 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16845 | + |
---|
| 16846 | + CreateSelectedPoint(); |
---|
16456 | 16847 | |
---|
16457 | 16848 | // Will fit the mesh !!! |
---|
16458 | 16849 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16507 | 16898 | } |
---|
16508 | 16899 | |
---|
16509 | 16900 | if (!movingcamera && !PAINTMODE) |
---|
16510 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16901 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16511 | 16902 | |
---|
16512 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16903 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16513 | 16904 | { |
---|
16514 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16905 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16515 | 16906 | |
---|
16516 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16907 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16908 | + { |
---|
| 16909 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16517 | 16910 | |
---|
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(); |
---|
| 16911 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16912 | + |
---|
| 16913 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16914 | + |
---|
| 16915 | + inst.add(paintobj); // link |
---|
| 16916 | + |
---|
| 16917 | + object.GetWindow().SnapObject(inst); |
---|
| 16918 | + |
---|
| 16919 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16920 | + |
---|
| 16921 | + folder.add(inst); |
---|
| 16922 | + |
---|
| 16923 | + object.GetWindow().ResetModel(); |
---|
| 16924 | + object.GetWindow().refreshContents(); |
---|
| 16925 | + } |
---|
16533 | 16926 | } |
---|
16534 | 16927 | else |
---|
16535 | 16928 | paintcount = 0; |
---|
.. | .. |
---|
16568 | 16961 | //System.out.println("objects[color] = " + objects[color]); |
---|
16569 | 16962 | //objects[color].Select(); |
---|
16570 | 16963 | indexcount = 0; |
---|
| 16964 | + ObjEditor window = object.GetWindow(); |
---|
| 16965 | + if (window != null && deselect) |
---|
| 16966 | + { |
---|
| 16967 | + window.Select(null, deselect, true); |
---|
| 16968 | + } |
---|
16571 | 16969 | object.Select(color, deselect); |
---|
16572 | 16970 | } |
---|
16573 | 16971 | |
---|
.. | .. |
---|
17093 | 17491 | int AAbuffersize = 0; |
---|
17094 | 17492 | |
---|
17095 | 17493 | //double[] selectedpoint = new double[3]; |
---|
17096 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17494 | + static Superellipsoid selectedpoint; |
---|
17097 | 17495 | 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(); |
---|
| 17496 | + static Sphere debugpointG; |
---|
| 17497 | + static Sphere debugpointP; |
---|
| 17498 | + static Sphere debugpointC; |
---|
| 17499 | + static Sphere debugpointR; |
---|
17102 | 17500 | |
---|
17103 | 17501 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17104 | 17502 | |
---|
17105 | | - static |
---|
17106 | | - { |
---|
17107 | | - for (int i=0; i<8; i++) |
---|
17108 | | - { |
---|
17109 | | - debugpoints[i] = new Sphere(); |
---|
17110 | | - } |
---|
17111 | | - } |
---|
17112 | | - |
---|
17113 | 17503 | static void InitPoints(float radius) |
---|
17114 | 17504 | { |
---|
17115 | 17505 | for (int i=0; i<8; i++) |
---|