.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
61 | 97 | //boolean REDUCETEXTURE = true; |
---|
62 | 98 | boolean CACHETEXTURE = true; |
---|
63 | 99 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
65 | 101 | boolean COMPRESSTEXTURE = false; |
---|
66 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
149 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 190 | |
---|
153 | 191 | void SetAsGLRenderer(boolean b) |
---|
154 | 192 | { |
---|
.. | .. |
---|
325 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
326 | 364 | //System.out.println("material " + material); |
---|
327 | 365 | //Applet3D.tracein(this, selected); |
---|
328 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
329 | 367 | if (obj instanceof Camera) |
---|
330 | 368 | { |
---|
331 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
334 | 372 | display.options1[2] = material.shadowbias; |
---|
335 | 373 | display.options1[3] = material.aniso; |
---|
336 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
337 | 380 | display.options2[0] = material.opacity; |
---|
338 | 381 | display.options2[1] = material.diffuse; |
---|
339 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
340 | 386 | |
---|
341 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
342 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
343 | 392 | display.options4[1] = material.subsurface; |
---|
344 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
345 | 397 | |
---|
346 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
347 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
357 | 409 | /**/ |
---|
358 | 410 | } else |
---|
359 | 411 | { |
---|
360 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
361 | 413 | } |
---|
362 | 414 | } else |
---|
363 | 415 | { |
---|
.. | .. |
---|
381 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
382 | 434 | //System.out.println("material " + material); |
---|
383 | 435 | //Applet3D.tracein("selected ", selected); |
---|
384 | | - display.vector2buffer = obj.projectedVertices; |
---|
385 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
386 | 438 | } |
---|
387 | 439 | } |
---|
388 | 440 | |
---|
.. | .. |
---|
399 | 451 | materialdepth -= 1; |
---|
400 | 452 | if (materialdepth > 0) |
---|
401 | 453 | { |
---|
402 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
403 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
404 | 456 | } |
---|
405 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
406 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
420 | 472 | materialdepth -= 1; |
---|
421 | 473 | if (materialdepth > 0) |
---|
422 | 474 | { |
---|
423 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
424 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
425 | 477 | } |
---|
426 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
427 | 479 | //else |
---|
.. | .. |
---|
462 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 515 | { |
---|
464 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
466 | 520 | if (!hasnorm) |
---|
467 | 521 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
469 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1244 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1245 | } |
---|
1192 | 1246 | } |
---|
| 1247 | + |
---|
1193 | 1248 | if (flipV) |
---|
1194 | 1249 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1250 | else |
---|
1196 | 1251 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
1197 | 1253 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1254 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1255 | |
---|
.. | .. |
---|
1213 | 1269 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1270 | } |
---|
1215 | 1271 | } |
---|
| 1272 | + |
---|
1216 | 1273 | if (flipV) |
---|
1217 | 1274 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1275 | else |
---|
1219 | 1276 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
1220 | 1278 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1279 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1280 | |
---|
.. | .. |
---|
1244 | 1302 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1303 | else |
---|
1246 | 1304 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
1247 | 1306 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1307 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
1249 | 1309 | count2 += 2; |
---|
1250 | 1310 | count3 += 3; |
---|
1251 | 1311 | } |
---|
.. | .. |
---|
1601 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1602 | 1662 | } |
---|
1603 | 1663 | |
---|
1604 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1605 | 1665 | { |
---|
1606 | 1666 | CameraPane display = this; |
---|
1607 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1636 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1637 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1638 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1639 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
1640 | 1700 | |
---|
1641 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1642 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1744 | 1804 | display.modelParams7[2] = 0; |
---|
1745 | 1805 | display.modelParams7[3] = 0; |
---|
1746 | 1806 | |
---|
1747 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1748 | 1808 | |
---|
1749 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1750 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1751 | 1811 | { |
---|
1752 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1888 | 1948 | void PushMatrix(double[][] matrix) |
---|
1889 | 1949 | { |
---|
1890 | 1950 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1892 | 1952 | } |
---|
1893 | 1953 | |
---|
1894 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
2042 | 2102 | //System.err.println("Oeil on"); |
---|
2043 | 2103 | OEIL = true; |
---|
2044 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2045 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2046 | 2106 | //pingthread.StepToTarget(true); |
---|
2047 | 2107 | } |
---|
2048 | 2108 | |
---|
.. | .. |
---|
2257 | 2317 | |
---|
2258 | 2318 | void ToggleDebug() |
---|
2259 | 2319 | { |
---|
2260 | | - DEBUG ^= true; |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
2261 | 2321 | } |
---|
2262 | 2322 | |
---|
2263 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
2265 | 2325 | LOOKAT ^= true; |
---|
2266 | 2326 | } |
---|
2267 | 2327 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
2269 | 2329 | { |
---|
2270 | 2330 | SWITCH ^= true; |
---|
2271 | 2331 | } |
---|
.. | .. |
---|
2275 | 2335 | HANDLES ^= true; |
---|
2276 | 2336 | } |
---|
2277 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2278 | 2340 | void TogglePaint() |
---|
2279 | 2341 | { |
---|
2280 | 2342 | PAINTMODE ^= true; |
---|
2281 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2282 | 2349 | } |
---|
2283 | 2350 | |
---|
2284 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2374 | 2441 | { |
---|
2375 | 2442 | return currentGL; |
---|
2376 | 2443 | } |
---|
2377 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2378 | 2460 | /**/ |
---|
2379 | 2461 | class CacheTexture |
---|
2380 | 2462 | { |
---|
.. | .. |
---|
2383 | 2465 | |
---|
2384 | 2466 | int resolution; |
---|
2385 | 2467 | |
---|
2386 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2387 | 2469 | { |
---|
2388 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2389 | 2472 | resolution = res; |
---|
2390 | 2473 | } |
---|
2391 | 2474 | } |
---|
2392 | 2475 | /**/ |
---|
2393 | 2476 | |
---|
2394 | 2477 | // TEXTURE static Texture texture; |
---|
2395 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2396 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2397 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2398 | 2483 | int pigmentdepth = 0; |
---|
2399 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2400 | 2485 | int bumpdepth = 0; |
---|
2401 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2403 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2404 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2405 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2406 | 2491 | |
---|
2407 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2408 | 2493 | { |
---|
2409 | 2494 | TextureData texturedata = null; |
---|
2410 | 2495 | |
---|
.. | .. |
---|
2423 | 2508 | if (bump) |
---|
2424 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2425 | 2510 | |
---|
2426 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2427 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2428 | 2513 | |
---|
2429 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2430 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2431 | 2516 | |
---|
2432 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2433 | 2539 | } |
---|
2434 | 2540 | |
---|
2435 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3502 | 3608 | |
---|
3503 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3504 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3505 | 3613 | // |
---|
3506 | 3614 | if (false) // compressbit > 0) |
---|
3507 | 3615 | { |
---|
.. | .. |
---|
7900 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7901 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7902 | 8010 | |
---|
7903 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7904 | 8012 | { |
---|
7905 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7906 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7915 | 8023 | pigment = null; |
---|
7916 | 8024 | } |
---|
7917 | 8025 | |
---|
7918 | | - ReleaseTexture(bump, true); |
---|
7919 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7920 | 8028 | } |
---|
7921 | 8029 | |
---|
7922 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8031 | + { |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7923 | 8089 | { |
---|
7924 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7925 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7930 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7931 | 8097 | |
---|
7932 | 8098 | if (tex != null) |
---|
7933 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7934 | 8100 | |
---|
7935 | 8101 | // //assert( texture != null ); |
---|
7936 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8024 | 8190 | |
---|
8025 | 8191 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 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 | + { |
---|
8027 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8242 | ambientOcclusion ) // || !textureon) |
---|
8029 | 8243 | { |
---|
.. | .. |
---|
8033 | 8247 | if (tex == null) |
---|
8034 | 8248 | { |
---|
8035 | 8249 | BindTexture(null,false,resolution); |
---|
8036 | | - BindTexture(null,true,resolution); |
---|
8037 | 8250 | return; |
---|
8038 | 8251 | } |
---|
8039 | 8252 | |
---|
8040 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
8041 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8042 | 8287 | |
---|
8043 | | - usedtextures.put(pigment, pigment); |
---|
8044 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8045 | 8289 | |
---|
8046 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8047 | 8291 | { |
---|
8048 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8049 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8053 | 8297 | { |
---|
8054 | 8298 | bump = null; |
---|
8055 | 8299 | } |
---|
8056 | | - if (pigment.equals("")) |
---|
8057 | | - { |
---|
8058 | | - pigment = null; |
---|
8059 | | - } |
---|
8060 | 8300 | |
---|
8061 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8062 | | - BindTexture(pigment, false, resolution); |
---|
8063 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8064 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8065 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8066 | | - |
---|
8067 | | - return; // true; |
---|
8068 | 8304 | } |
---|
8069 | 8305 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
8071 | 8309 | { |
---|
8072 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8073 | 8329 | |
---|
8074 | 8330 | if (tex != null) |
---|
8075 | 8331 | { |
---|
8076 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8077 | 8334 | |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
8078 | 8342 | // String[] split = tex.split("Textures"); |
---|
8079 | 8343 | // if (split.length > 1) |
---|
8080 | 8344 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8345 | // else |
---|
8082 | 8346 | // if (!texname.startsWith("/")) |
---|
8083 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8085 | 8349 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8350 | + texname = fallbackTextureName; |
---|
8087 | 8351 | } |
---|
8088 | 8352 | |
---|
8089 | 8353 | if (CACHETEXTURE) |
---|
8090 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8091 | | - |
---|
8092 | | - TextureData texturedata = null; |
---|
8093 | | - |
---|
8094 | | - if (texture == null || texture.resolution < resolution) |
---|
8095 | 8354 | { |
---|
8096 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8097 | 8388 | { |
---|
8098 | 8389 | assert(!bump); |
---|
8099 | 8390 | // if (bump) |
---|
.. | .. |
---|
8104 | 8395 | // } |
---|
8105 | 8396 | // else |
---|
8106 | 8397 | // { |
---|
8107 | | - texture = textures.get(tex); |
---|
8108 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8109 | 8400 | { |
---|
8110 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8111 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8112 | 8405 | // } |
---|
8113 | 8406 | } else |
---|
8114 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8115 | 8408 | { |
---|
8116 | 8409 | assert(bump); |
---|
8117 | | - texture = textures.get(tex); |
---|
8118 | | - if (texture == null) |
---|
8119 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
8120 | 8415 | } else |
---|
8121 | 8416 | { |
---|
8122 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8124 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8125 | 8420 | //} else |
---|
8126 | 8421 | //{ |
---|
8127 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8128 | 8423 | { |
---|
8129 | | - texture = textures.get(tex); |
---|
8130 | | - if (texture == null) |
---|
8131 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
8132 | 8429 | } else |
---|
8133 | 8430 | { |
---|
8134 | 8431 | if (textureon) |
---|
.. | .. |
---|
8153 | 8450 | } |
---|
8154 | 8451 | |
---|
8155 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
8157 | 8454 | cachename = texname; |
---|
8158 | 8455 | else |
---|
8159 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8472 | } |
---|
8176 | 8473 | |
---|
8177 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
8179 | 8476 | cachename = texname; |
---|
8180 | 8477 | else |
---|
8181 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8187 | 8484 | if (texturedata == null) |
---|
8188 | 8485 | throw new Exception(); |
---|
8189 | 8486 | |
---|
8190 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8191 | 8488 | //texture = GetTexture(tex, bump); |
---|
8192 | 8489 | } |
---|
8193 | 8490 | } |
---|
8194 | 8491 | //} |
---|
8195 | 8492 | } |
---|
8196 | 8493 | |
---|
8197 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8198 | 8495 | { |
---|
8199 | 8496 | //return false; |
---|
8200 | 8497 | |
---|
8201 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8202 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8203 | 8500 | { |
---|
8204 | 8501 | // String ext = "_highres"; |
---|
8205 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8216 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8217 | 8514 | if (!cachefile.exists()) |
---|
8218 | 8515 | { |
---|
8219 | | - // cache to disk |
---|
8220 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8221 | | - //buffers[0]. |
---|
8222 | | - |
---|
8223 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8224 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8225 | | - |
---|
8226 | | - // squared size heuristic... |
---|
8227 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8228 | 8517 | { |
---|
8229 | | - for (int i=pixels.length; --i>=0;) |
---|
8230 | | - { |
---|
8231 | | - int i3 = i*3; |
---|
8232 | | - pixels[i] = 0xFF; |
---|
8233 | | - pixels[i] <<= 8; |
---|
8234 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8235 | | - pixels[i] <<= 8; |
---|
8236 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8237 | | - pixels[i] <<= 8; |
---|
8238 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8239 | | - } |
---|
8240 | | - |
---|
8241 | | - /* |
---|
8242 | | - int r=0,g=0,b=0,a=0; |
---|
8243 | | - for (int i=0; i<width; i++) |
---|
8244 | | - for (int j=0; j<height; j++) |
---|
8245 | | - { |
---|
8246 | | - int index = j*width+i; |
---|
8247 | | - int p = pixels[index]; |
---|
8248 | | - a = ((p>>24) & 0xFF); |
---|
8249 | | - r = ((p>>16) & 0xFF); |
---|
8250 | | - g = ((p>>8) & 0xFF); |
---|
8251 | | - b = (p & 0xFF); |
---|
8252 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8253 | | - } |
---|
8254 | | - /**/ |
---|
8255 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8256 | | - int height = width; |
---|
8257 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8258 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8259 | 8520 | ImageWriter writer = null; |
---|
8260 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8261 | 8522 | if (iter.hasNext()) { |
---|
8262 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8263 | 8524 | } |
---|
8264 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8265 | 8527 | try |
---|
8266 | 8528 | { |
---|
8267 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8278 | 8540 | } |
---|
8279 | 8541 | } |
---|
8280 | 8542 | } |
---|
8281 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8282 | 8546 | //System.out.println("Texture = " + tex); |
---|
8283 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8284 | 8548 | { |
---|
8285 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8286 | 8550 | thetex.texture.disable(); |
---|
8287 | 8551 | thetex.texture.dispose(); |
---|
8288 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8289 | 8553 | } |
---|
8290 | 8554 | |
---|
8291 | | - texture.texturedata = texturedata; |
---|
8292 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8293 | 8557 | |
---|
8294 | 8558 | // newtex = true; |
---|
8295 | 8559 | } |
---|
.. | .. |
---|
8305 | 8569 | } |
---|
8306 | 8570 | } |
---|
8307 | 8571 | |
---|
8308 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8309 | 8573 | } |
---|
8310 | 8574 | |
---|
8311 | | - 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 |
---|
8312 | 8610 | { |
---|
8313 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8314 | 8612 | |
---|
.. | .. |
---|
8326 | 8624 | return texture!=null?texture.texture:null; |
---|
8327 | 8625 | } |
---|
8328 | 8626 | |
---|
8329 | | - 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 |
---|
8330 | 8628 | { |
---|
8331 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8332 | 8630 | |
---|
8333 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8334 | 8632 | } |
---|
8335 | 8633 | |
---|
8336 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8337 | 8635 | { |
---|
8338 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8339 | 8637 | { |
---|
8340 | 8638 | return false; |
---|
8341 | 8639 | } |
---|
8342 | 8640 | |
---|
8343 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8344 | 8642 | |
---|
8345 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8346 | 8644 | |
---|
.. | .. |
---|
8372 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8373 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8374 | 8672 | |
---|
8375 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8376 | 8674 | } |
---|
8377 | 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 | + |
---|
8378 | 8742 | ShadowBuffer shadowPBuf; |
---|
8379 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8380 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
9210 | 9574 | jy8[3] = 0.5f; |
---|
9211 | 9575 | } |
---|
9212 | 9576 | |
---|
9213 | | - 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 |
---|
9214 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9215 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9216 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9217 | 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 | + |
---|
9218 | 9606 | static int imagecount = 0; // movie generation |
---|
9219 | 9607 | |
---|
9220 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
9310 | 9698 | assert (parentcam != renderCamera); |
---|
9311 | 9699 | |
---|
9312 | 9700 | if (renderCamera != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9315 | 9703 | |
---|
9316 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9317 | 9705 | |
---|
.. | .. |
---|
9326 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9327 | 9715 | |
---|
9328 | 9716 | if (renderCamera != lightCamera) |
---|
9329 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9330 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9331 | 9719 | |
---|
9332 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9333 | 9721 | |
---|
.. | .. |
---|
10325 | 10713 | ANTIALIAS = 0; |
---|
10326 | 10714 | //System.out.println("RESTART"); |
---|
10327 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
10328 | 10717 | } |
---|
10329 | 10718 | } |
---|
10330 | 10719 | } |
---|
.. | .. |
---|
10392 | 10781 | ambientOcclusion = false; |
---|
10393 | 10782 | } |
---|
10394 | 10783 | |
---|
10395 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10396 | 10786 | { |
---|
10397 | 10787 | //if (RENDERSHADOW) // ? |
---|
10398 | 10788 | if (!IsFrozen()) |
---|
10399 | 10789 | { |
---|
10400 | 10790 | // dec 2012 |
---|
10401 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10402 | 10792 | { |
---|
10403 | 10793 | Globals.framecount++; |
---|
10404 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
10525 | 10915 | |
---|
10526 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
10527 | 10917 | if (cam != lightCamera) |
---|
10528 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10529 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10530 | 10920 | |
---|
10531 | 10921 | for (int j = 0; j < 4; j++) |
---|
10532 | 10922 | { |
---|
.. | .. |
---|
10540 | 10930 | |
---|
10541 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
10542 | 10932 | if (cam != lightCamera) |
---|
10543 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10544 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10545 | 10935 | |
---|
10546 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10547 | 10937 | |
---|
.. | .. |
---|
10832 | 11222 | |
---|
10833 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10834 | 11224 | |
---|
10835 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10836 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10837 | | -//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); |
---|
10838 | 11228 | } else |
---|
10839 | 11229 | { |
---|
10840 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10845 | 11235 | //System.out.println("BLENDING ON"); |
---|
10846 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10847 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10848 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10849 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10850 | 11240 | gl.glLoadIdentity(); |
---|
10851 | 11241 | |
---|
.. | .. |
---|
10934 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10935 | 11325 | |
---|
10936 | 11326 | // if (cam != lightCamera) |
---|
10937 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10938 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10939 | 11329 | } |
---|
10940 | 11330 | |
---|
10941 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10956 | 11346 | if (true) // TODO |
---|
10957 | 11347 | { |
---|
10958 | 11348 | if (cam != lightCamera) |
---|
10959 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10960 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10961 | 11351 | } |
---|
10962 | 11352 | |
---|
10963 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11094 | 11484 | } |
---|
11095 | 11485 | } |
---|
11096 | 11486 | |
---|
11097 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11098 | 11488 | { |
---|
11099 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11100 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11102 | 11492 | |
---|
11103 | 11493 | boolean texon = textureon; |
---|
11104 | 11494 | |
---|
11105 | | - if (RENDERPROGRAM > 0) |
---|
11106 | | - { |
---|
11107 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11108 | | - textureon = false; |
---|
11109 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11110 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11111 | 11499 | //System.out.println("ALLO"); |
---|
11112 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11113 | 11501 | DrawObject(gl); |
---|
11114 | | - if (RENDERPROGRAM > 0) |
---|
11115 | | - { |
---|
11116 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11117 | | - textureon = texon; |
---|
11118 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11119 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11120 | 11507 | |
---|
11121 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11122 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11123 | 11510 | } |
---|
11124 | 11511 | |
---|
11125 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11302 | 11689 | |
---|
11303 | 11690 | static boolean zoomonce = false; |
---|
11304 | 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 | + |
---|
11305 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
11306 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
11307 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11308 | 11716 | // DrawMode() = SELECTION; |
---|
11309 | 11717 | //GL gl = getGL(); |
---|
11310 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11311 | 11719 | { |
---|
11312 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11313 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11314 | 11722 | pingthread.StepToTarget(true); // true); |
---|
11315 | 11723 | // zoomonce = false; |
---|
11316 | 11724 | } |
---|
.. | .. |
---|
11382 | 11790 | |
---|
11383 | 11791 | if (DrawMode() == DEFAULT) |
---|
11384 | 11792 | { |
---|
11385 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
11386 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
11387 | 11796 | float radius = 0.05f; |
---|
11388 | 11797 | if (selectedpoint.radius != radius) |
---|
11389 | 11798 | { |
---|
.. | .. |
---|
11437 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11438 | 11847 | |
---|
11439 | 11848 | if (CLEANCACHE) |
---|
11440 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11441 | 11850 | { |
---|
11442 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11443 | 11852 | |
---|
11444 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11445 | 11854 | |
---|
11446 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11447 | 11856 | continue; |
---|
11448 | 11857 | |
---|
11449 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11450 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11451 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11452 | | - textures.get(tex).texture.dispose(); |
---|
11453 | | - 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 | + } |
---|
11454 | 11875 | } |
---|
11455 | 11876 | } |
---|
11456 | 11877 | } |
---|
.. | .. |
---|
11552 | 11973 | return; |
---|
11553 | 11974 | } |
---|
11554 | 11975 | |
---|
11555 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
11556 | 11977 | |
---|
11557 | 11978 | GL gl = GetGL(); |
---|
11558 | 11979 | |
---|
.. | .. |
---|
11869 | 12290 | //obj.TransformToWorld(light, light); |
---|
11870 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
11871 | 12292 | { |
---|
11872 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11873 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11874 | 12295 | } |
---|
11875 | 12296 | |
---|
11876 | 12297 | |
---|
.. | .. |
---|
11887 | 12308 | parentcam = cameras[0]; |
---|
11888 | 12309 | } |
---|
11889 | 12310 | |
---|
11890 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11891 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11892 | 12313 | |
---|
11893 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11894 | 12315 | |
---|
.. | .. |
---|
13140 | 13561 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13141 | 13562 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13142 | 13563 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13143 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13564 | + |
---|
| 13565 | + //Object3D.cVector2[] vector2buffer; |
---|
13144 | 13566 | |
---|
13145 | 13567 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13146 | 13568 | // OUT : diff, spec |
---|
.. | .. |
---|
13156 | 13578 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13157 | 13579 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13158 | 13580 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13159 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13160 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13161 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13581 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13582 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13583 | + |
---|
| 13584 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13162 | 13585 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13163 | 13586 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13164 | 13587 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13663 | 14086 | else |
---|
13664 | 14087 | if (evt.getSource() == AAtimer) |
---|
13665 | 14088 | { |
---|
| 14089 | + Globals.TIMERRUNNING = false; |
---|
13666 | 14090 | if (mouseDown) |
---|
13667 | 14091 | { |
---|
13668 | 14092 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13722 | 14146 | |
---|
13723 | 14147 | // fev 2014??? |
---|
13724 | 14148 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13725 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14149 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13726 | 14150 | pingthread.StepToTarget(true); // true); |
---|
13727 | 14151 | } |
---|
13728 | 14152 | // if (!LIVE) |
---|
.. | .. |
---|
13737 | 14161 | return; |
---|
13738 | 14162 | |
---|
13739 | 14163 | AAtimer.restart(); // |
---|
| 14164 | + Globals.TIMERRUNNING = true; |
---|
13740 | 14165 | |
---|
13741 | 14166 | // waslive = LIVE; |
---|
13742 | 14167 | // LIVE = false; |
---|
.. | .. |
---|
13809 | 14234 | |
---|
13810 | 14235 | public void mouseDragged(MouseEvent e) |
---|
13811 | 14236 | { |
---|
| 14237 | + Globals.MOUSEDRAGGED = true; |
---|
| 14238 | + |
---|
13812 | 14239 | //System.out.println("mouseDragged: " + e); |
---|
13813 | 14240 | if (isRenderer) |
---|
13814 | 14241 | movingcamera = true; |
---|
| 14242 | + |
---|
13815 | 14243 | //if (drawing) |
---|
13816 | 14244 | //return; |
---|
13817 | 14245 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14072 | 14500 | void GoDown(int mod) |
---|
14073 | 14501 | { |
---|
14074 | 14502 | MODIFIERS |= COMMAND; |
---|
14075 | | - /* |
---|
| 14503 | + /**/ |
---|
14076 | 14504 | if((mod&SHIFT) == SHIFT) |
---|
14077 | 14505 | manipCamera.RotatePosition(0, -speed); |
---|
14078 | 14506 | else |
---|
14079 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14080 | | - */ |
---|
| 14507 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14508 | + /**/ |
---|
14081 | 14509 | if ((mod & SHIFT) == SHIFT) |
---|
14082 | 14510 | { |
---|
14083 | 14511 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14093 | 14521 | void GoUp(int mod) |
---|
14094 | 14522 | { |
---|
14095 | 14523 | MODIFIERS |= COMMAND; |
---|
14096 | | - /* |
---|
| 14524 | + /**/ |
---|
14097 | 14525 | if((mod&SHIFT) == SHIFT) |
---|
14098 | 14526 | manipCamera.RotatePosition(0, speed); |
---|
14099 | 14527 | else |
---|
14100 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14101 | | - */ |
---|
| 14528 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14529 | + /**/ |
---|
14102 | 14530 | if ((mod & SHIFT) == SHIFT) |
---|
14103 | 14531 | { |
---|
14104 | 14532 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14114 | 14542 | void GoLeft(int mod) |
---|
14115 | 14543 | { |
---|
14116 | 14544 | MODIFIERS |= COMMAND; |
---|
14117 | | - /* |
---|
| 14545 | + /**/ |
---|
14118 | 14546 | if((mod&SHIFT) == SHIFT) |
---|
14119 | | - manipCamera.RotatePosition(speed, 0); |
---|
14120 | | - else |
---|
14121 | 14547 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14122 | | - */ |
---|
| 14548 | + else |
---|
| 14549 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14550 | + /**/ |
---|
14123 | 14551 | if ((mod & SHIFT) == SHIFT) |
---|
14124 | 14552 | { |
---|
14125 | 14553 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14135 | 14563 | void GoRight(int mod) |
---|
14136 | 14564 | { |
---|
14137 | 14565 | MODIFIERS |= COMMAND; |
---|
14138 | | - /* |
---|
| 14566 | + /**/ |
---|
14139 | 14567 | if((mod&SHIFT) == SHIFT) |
---|
14140 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14141 | | - else |
---|
14142 | 14568 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14143 | | - */ |
---|
| 14569 | + else |
---|
| 14570 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14571 | + /**/ |
---|
14144 | 14572 | if ((mod & SHIFT) == SHIFT) |
---|
14145 | 14573 | { |
---|
14146 | 14574 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14197 | 14625 | info.camera = renderCamera; |
---|
14198 | 14626 | info.x = x; |
---|
14199 | 14627 | info.y = y; |
---|
14200 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14628 | + object.GetWindow().copy |
---|
| 14629 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14201 | 14630 | } else |
---|
14202 | 14631 | { |
---|
14203 | 14632 | if (x < startX) |
---|
.. | .. |
---|
14361 | 14790 | ci.camera = renderCamera; |
---|
14362 | 14791 | if (!isRenderer) |
---|
14363 | 14792 | { |
---|
14364 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14793 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14794 | + //Object3D copy = editWindow.copy; |
---|
| 14795 | + if (object.doEditClick(ci, 0)) |
---|
14365 | 14796 | { |
---|
14366 | 14797 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14367 | 14798 | } else |
---|
.. | .. |
---|
14373 | 14804 | |
---|
14374 | 14805 | public void mouseReleased(MouseEvent e) |
---|
14375 | 14806 | { |
---|
| 14807 | + Globals.MOUSEDRAGGED = false; |
---|
| 14808 | + |
---|
14376 | 14809 | movingcamera = false; |
---|
14377 | | - X = Y = 0; |
---|
| 14810 | + X = 0; // getBounds().width/2; |
---|
| 14811 | + Y = 0; // getBounds().height/2; |
---|
14378 | 14812 | //System.out.println("mouseReleased: " + e); |
---|
14379 | 14813 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14380 | 14814 | } |
---|
.. | .. |
---|
14630 | 15064 | // break; |
---|
14631 | 15065 | case 'T': |
---|
14632 | 15066 | CACHETEXTURE ^= true; |
---|
14633 | | - textures.clear(); |
---|
| 15067 | + texturepigment.clear(); |
---|
| 15068 | + texturebump.clear(); |
---|
14634 | 15069 | // repaint(); |
---|
14635 | 15070 | break; |
---|
14636 | 15071 | case 'Y': |
---|
.. | .. |
---|
14715 | 15150 | case 'E' : COMPACT ^= true; |
---|
14716 | 15151 | repaint(); |
---|
14717 | 15152 | break; |
---|
14718 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15153 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15154 | + //DEBUGHSB ^= true; |
---|
| 15155 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14719 | 15156 | repaint(); |
---|
14720 | 15157 | break; |
---|
14721 | 15158 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14740 | 15177 | RevertCamera(); |
---|
14741 | 15178 | repaint(); |
---|
14742 | 15179 | break; |
---|
14743 | | - case 'L': |
---|
14744 | 15180 | case 'l': |
---|
| 15181 | + //case 'L': |
---|
14745 | 15182 | if (lightMode) |
---|
14746 | 15183 | { |
---|
14747 | 15184 | lightMode = false; |
---|
.. | .. |
---|
14884 | 15321 | case '_': |
---|
14885 | 15322 | kompactbit = 5; |
---|
14886 | 15323 | break; |
---|
14887 | | - case '+': |
---|
14888 | | - kompactbit = 6; |
---|
14889 | | - break; |
---|
| 15324 | +// case '+': |
---|
| 15325 | +// kompactbit = 6; |
---|
| 15326 | +// break; |
---|
14890 | 15327 | case ' ': |
---|
14891 | 15328 | lightMode ^= true; |
---|
14892 | 15329 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14898 | 15335 | case ESC: |
---|
14899 | 15336 | RENDERPROGRAM += 1; |
---|
14900 | 15337 | RENDERPROGRAM %= 3; |
---|
| 15338 | + |
---|
14901 | 15339 | repaint(); |
---|
14902 | 15340 | break; |
---|
14903 | 15341 | case 'Z': |
---|
.. | .. |
---|
14937 | 15375 | case DELETE: |
---|
14938 | 15376 | ClearSelection(); |
---|
14939 | 15377 | break; |
---|
14940 | | - /* |
---|
14941 | 15378 | case '+': |
---|
| 15379 | + |
---|
| 15380 | + /* |
---|
14942 | 15381 | //fontsize += 1; |
---|
14943 | 15382 | bbzoom *= 2; |
---|
14944 | 15383 | repaint(); |
---|
.. | .. |
---|
14955 | 15394 | case '=': |
---|
14956 | 15395 | IncDepth(); |
---|
14957 | 15396 | //fontsize += 1; |
---|
14958 | | - object.editWindow.refreshContents(true); |
---|
| 15397 | + object.GetWindow().refreshContents(true); |
---|
14959 | 15398 | maskbit = 6; |
---|
14960 | 15399 | break; |
---|
14961 | 15400 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14962 | 15401 | DecDepth(); |
---|
14963 | 15402 | maskbit = 5; |
---|
14964 | 15403 | //if(fontsize > 1) fontsize -= 1; |
---|
14965 | | - if (object.editWindow == null) |
---|
14966 | | - new Exception().printStackTrace(); |
---|
14967 | | - else |
---|
14968 | | - object.editWindow.refreshContents(true); |
---|
| 15404 | +// if (object.editWindow == null) |
---|
| 15405 | +// new Exception().printStackTrace(); |
---|
| 15406 | +// else |
---|
| 15407 | + object.GetWindow().refreshContents(true); |
---|
14969 | 15408 | break; |
---|
14970 | 15409 | case '{': |
---|
14971 | 15410 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15189 | 15628 | } |
---|
15190 | 15629 | */ |
---|
15191 | 15630 | |
---|
15192 | | - object.editWindow.EditSelection(); |
---|
| 15631 | + object.GetWindow().EditSelection(false); |
---|
15193 | 15632 | } |
---|
15194 | 15633 | |
---|
15195 | 15634 | void SelectParent() |
---|
.. | .. |
---|
15206 | 15645 | { |
---|
15207 | 15646 | //selectees.remove(i); |
---|
15208 | 15647 | System.out.println("select parent of " + elem); |
---|
15209 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15648 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15210 | 15649 | } else |
---|
15211 | 15650 | { |
---|
15212 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15651 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15213 | 15652 | } |
---|
15214 | 15653 | |
---|
15215 | 15654 | first = false; |
---|
.. | .. |
---|
15251 | 15690 | for (int j = 0; j < group.children.size(); j++) |
---|
15252 | 15691 | { |
---|
15253 | 15692 | elem = (Object3D) group.children.elementAt(j); |
---|
15254 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15693 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15255 | 15694 | first = false; |
---|
15256 | 15695 | } |
---|
15257 | 15696 | } else |
---|
15258 | 15697 | { |
---|
15259 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15698 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15260 | 15699 | } |
---|
15261 | 15700 | |
---|
15262 | 15701 | first = false; |
---|
.. | .. |
---|
15267 | 15706 | { |
---|
15268 | 15707 | //Composite group = (Composite) object; |
---|
15269 | 15708 | Object3D group = object; |
---|
15270 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15709 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15271 | 15710 | } |
---|
15272 | 15711 | |
---|
15273 | 15712 | void ResetTransform(int mask) |
---|
15274 | 15713 | { |
---|
15275 | 15714 | //Composite group = (Composite) object; |
---|
15276 | 15715 | Object3D group = object; |
---|
15277 | | - group.editWindow.ResetTransform(mask); |
---|
| 15716 | + group.GetWindow().ResetTransform(mask); |
---|
15278 | 15717 | } |
---|
15279 | 15718 | |
---|
15280 | 15719 | void FlipTransform() |
---|
15281 | 15720 | { |
---|
15282 | 15721 | //Composite group = (Composite) object; |
---|
15283 | 15722 | Object3D group = object; |
---|
15284 | | - group.editWindow.FlipTransform(); |
---|
| 15723 | + group.GetWindow().FlipTransform(); |
---|
15285 | 15724 | // group.editWindow.ReduceMesh(true); |
---|
15286 | 15725 | } |
---|
15287 | 15726 | |
---|
.. | .. |
---|
15289 | 15728 | { |
---|
15290 | 15729 | //Composite group = (Composite) object; |
---|
15291 | 15730 | Object3D group = object; |
---|
15292 | | - group.editWindow.PrintMemory(); |
---|
| 15731 | + group.GetWindow().PrintMemory(); |
---|
15293 | 15732 | // group.editWindow.ReduceMesh(true); |
---|
15294 | 15733 | } |
---|
15295 | 15734 | |
---|
.. | .. |
---|
15297 | 15736 | { |
---|
15298 | 15737 | //Composite group = (Composite) object; |
---|
15299 | 15738 | Object3D group = object; |
---|
15300 | | - group.editWindow.ResetCentroid(); |
---|
| 15739 | + group.GetWindow().ResetCentroid(); |
---|
15301 | 15740 | } |
---|
15302 | 15741 | |
---|
15303 | 15742 | void IncDepth() |
---|
.. | .. |
---|
15473 | 15912 | info.bounds.y += (height - desired) / 2; |
---|
15474 | 15913 | } |
---|
15475 | 15914 | } |
---|
| 15915 | + |
---|
15476 | 15916 | info.g = gr; |
---|
15477 | 15917 | info.camera = renderCamera; |
---|
15478 | 15918 | /* |
---|
.. | .. |
---|
15482 | 15922 | */ |
---|
15483 | 15923 | if (!isRenderer) |
---|
15484 | 15924 | { |
---|
15485 | | - object.drawEditHandles(info, 0); |
---|
15486 | | - |
---|
15487 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15925 | + Grafreed.Assert(object != null); |
---|
| 15926 | + Grafreed.Assert(object.selection != null); |
---|
| 15927 | + if (object.selection.Size() > 0) |
---|
15488 | 15928 | { |
---|
15489 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15929 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15930 | + |
---|
| 15931 | + info.DX = 0; |
---|
| 15932 | + info.DY = 0; |
---|
| 15933 | + info.W = 1; |
---|
| 15934 | + if (hitSomething == Object3D.hitCenter) |
---|
15490 | 15935 | { |
---|
15491 | | - case Object3D.hitCenter: gr.setColor(Color.pink); break; |
---|
15492 | | - case Object3D.hitRotate: gr.setColor(Color.green); break; |
---|
15493 | | - case Object3D.hitScale: gr.setColor(Color.cyan); break; |
---|
| 15936 | + info.DX = X; |
---|
| 15937 | + if (X != 0) |
---|
| 15938 | + info.DX -= info.bounds.width/2; |
---|
| 15939 | + |
---|
| 15940 | + info.DY = Y; |
---|
| 15941 | + if (Y != 0) |
---|
| 15942 | + info.DY -= info.bounds.height/2; |
---|
15494 | 15943 | } |
---|
15495 | | - |
---|
15496 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15944 | + |
---|
| 15945 | + object.drawEditHandles(info, 0); |
---|
| 15946 | + |
---|
| 15947 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15948 | + { |
---|
| 15949 | + switch (hitSomething) |
---|
| 15950 | + { |
---|
| 15951 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15952 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15953 | + break; |
---|
| 15954 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15955 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15956 | + break; |
---|
| 15957 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15958 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15959 | + break; |
---|
| 15960 | + } |
---|
| 15961 | + |
---|
| 15962 | + } |
---|
15497 | 15963 | } |
---|
15498 | 15964 | } |
---|
15499 | 15965 | } |
---|
.. | .. |
---|
15911 | 16377 | Object3D object; |
---|
15912 | 16378 | static Object3D trackedobject; |
---|
15913 | 16379 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15914 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16380 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15915 | 16381 | /*static*/ Camera eyeCamera; |
---|
15916 | 16382 | /*static*/ Camera lightCamera; |
---|
15917 | 16383 | int cameracount; |
---|
.. | .. |
---|
16196 | 16662 | cStatic.objectstack[materialdepth++] = checker; |
---|
16197 | 16663 | //System.out.println("material " + material); |
---|
16198 | 16664 | //Applet3D.tracein(this, selected); |
---|
16199 | | - vector2buffer = checker.projectedVertices; |
---|
| 16665 | + //vector2buffer = checker.projectedVertices; |
---|
16200 | 16666 | |
---|
16201 | 16667 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16202 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16668 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16203 | 16669 | |
---|
16204 | 16670 | materialdepth -= 1; |
---|
16205 | 16671 | if (materialdepth > 0) |
---|
16206 | 16672 | { |
---|
16207 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16208 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16673 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16674 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16209 | 16675 | } |
---|
16210 | 16676 | //checker.GetMaterial().opacity = 1f; |
---|
16211 | 16677 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16291 | 16757 | } |
---|
16292 | 16758 | } |
---|
16293 | 16759 | |
---|
| 16760 | + private Object3D GetFolder() |
---|
| 16761 | + { |
---|
| 16762 | + Object3D folder = object.GetWindow().copy; |
---|
| 16763 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16764 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16765 | + return folder; |
---|
| 16766 | + } |
---|
| 16767 | + |
---|
16294 | 16768 | class SelectBuffer implements GLEventListener |
---|
16295 | 16769 | { |
---|
16296 | 16770 | |
---|
.. | .. |
---|
16370 | 16844 | |
---|
16371 | 16845 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16372 | 16846 | |
---|
| 16847 | + if (PAINTMODE) |
---|
| 16848 | + { |
---|
| 16849 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16850 | + { |
---|
| 16851 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16852 | + |
---|
| 16853 | + // Make what you paint not selectable. |
---|
| 16854 | + paintobj.ResetSelectable(); |
---|
| 16855 | + } |
---|
| 16856 | + } |
---|
| 16857 | + |
---|
16373 | 16858 | //int tmp = selection_view; |
---|
16374 | 16859 | //selection_view = -1; |
---|
16375 | 16860 | int temp = DrawMode(); |
---|
.. | .. |
---|
16381 | 16866 | // temp = DEFAULT; // patch for selection debug |
---|
16382 | 16867 | Globals.drawMode = temp; // WARNING |
---|
16383 | 16868 | |
---|
| 16869 | + if (PAINTMODE) |
---|
| 16870 | + { |
---|
| 16871 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16872 | + { |
---|
| 16873 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16874 | + |
---|
| 16875 | + // Revert. |
---|
| 16876 | + paintobj.RestoreSelectable(); |
---|
| 16877 | + } |
---|
| 16878 | + } |
---|
| 16879 | + |
---|
16384 | 16880 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16385 | 16881 | |
---|
16386 | 16882 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16428 | 16924 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16429 | 16925 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16430 | 16926 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16927 | + |
---|
| 16928 | + CreateSelectedPoint(); |
---|
16431 | 16929 | |
---|
16432 | 16930 | // Will fit the mesh !!! |
---|
16433 | 16931 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16482 | 16980 | } |
---|
16483 | 16981 | |
---|
16484 | 16982 | if (!movingcamera && !PAINTMODE) |
---|
16485 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16983 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16486 | 16984 | |
---|
16487 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16985 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16488 | 16986 | { |
---|
16489 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16987 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16490 | 16988 | |
---|
16491 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16989 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16990 | + { |
---|
| 16991 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16492 | 16992 | |
---|
16493 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16494 | | - |
---|
16495 | | - group.add(paintobj); // link |
---|
16496 | | - |
---|
16497 | | - object.editWindow.SnapObject(group); |
---|
16498 | | - |
---|
16499 | | - Object3D folder = object.editWindow.copy; |
---|
16500 | | - |
---|
16501 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16502 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16503 | | - |
---|
16504 | | - folder.add(group); |
---|
16505 | | - |
---|
16506 | | - object.editWindow.ResetModel(); |
---|
16507 | | - object.editWindow.refreshContents(); |
---|
| 16993 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16994 | + |
---|
| 16995 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16996 | + |
---|
| 16997 | + inst.add(paintobj); // link |
---|
| 16998 | + |
---|
| 16999 | + object.GetWindow().SnapObject(inst); |
---|
| 17000 | + |
---|
| 17001 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17002 | + |
---|
| 17003 | + folder.add(inst); |
---|
| 17004 | + |
---|
| 17005 | + object.GetWindow().ResetModel(); |
---|
| 17006 | + object.GetWindow().refreshContents(); |
---|
| 17007 | + } |
---|
16508 | 17008 | } |
---|
16509 | 17009 | else |
---|
16510 | 17010 | paintcount = 0; |
---|
.. | .. |
---|
16543 | 17043 | //System.out.println("objects[color] = " + objects[color]); |
---|
16544 | 17044 | //objects[color].Select(); |
---|
16545 | 17045 | indexcount = 0; |
---|
| 17046 | + ObjEditor window = object.GetWindow(); |
---|
| 17047 | + if (window != null && deselect) |
---|
| 17048 | + { |
---|
| 17049 | + window.Select(null, deselect, true); |
---|
| 17050 | + } |
---|
16546 | 17051 | object.Select(color, deselect); |
---|
16547 | 17052 | } |
---|
16548 | 17053 | |
---|
.. | .. |
---|
17068 | 17573 | int AAbuffersize = 0; |
---|
17069 | 17574 | |
---|
17070 | 17575 | //double[] selectedpoint = new double[3]; |
---|
17071 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17576 | + static Superellipsoid selectedpoint; |
---|
17072 | 17577 | static Sphere previousselectedpoint = null; |
---|
17073 | | - static Sphere debugpointG = new Sphere(); |
---|
17074 | | - static Sphere debugpointP = new Sphere(); |
---|
17075 | | - static Sphere debugpointC = new Sphere(); |
---|
17076 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17578 | + static Sphere debugpointG; |
---|
| 17579 | + static Sphere debugpointP; |
---|
| 17580 | + static Sphere debugpointC; |
---|
| 17581 | + static Sphere debugpointR; |
---|
17077 | 17582 | |
---|
17078 | 17583 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17079 | 17584 | |
---|
17080 | | - static |
---|
17081 | | - { |
---|
17082 | | - for (int i=0; i<8; i++) |
---|
17083 | | - { |
---|
17084 | | - debugpoints[i] = new Sphere(); |
---|
17085 | | - } |
---|
17086 | | - } |
---|
17087 | | - |
---|
17088 | 17585 | static void InitPoints(float radius) |
---|
17089 | 17586 | { |
---|
17090 | 17587 | for (int i=0; i<8; i++) |
---|