.. | .. |
---|
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 |
---|
.. | .. |
---|
61 | 60 | //boolean REDUCETEXTURE = true; |
---|
62 | 61 | boolean CACHETEXTURE = true; |
---|
63 | 62 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 63 | + boolean MIPMAP = true; // false; // true; |
---|
65 | 64 | boolean COMPRESSTEXTURE = false; |
---|
66 | 65 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 66 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
327 | 326 | cStatic.objectstack[materialdepth++] = obj; |
---|
328 | 327 | //System.out.println("material " + material); |
---|
329 | 328 | //Applet3D.tracein(this, selected); |
---|
330 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 329 | + //display.vector2buffer = obj.projectedVertices; |
---|
331 | 330 | if (obj instanceof Camera) |
---|
332 | 331 | { |
---|
333 | 332 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
336 | 335 | display.options1[2] = material.shadowbias; |
---|
337 | 336 | display.options1[3] = material.aniso; |
---|
338 | 337 | display.options1[4] = material.anisoV; |
---|
| 338 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 339 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 340 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 341 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 342 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
339 | 343 | display.options2[0] = material.opacity; |
---|
340 | 344 | display.options2[1] = material.diffuse; |
---|
341 | 345 | display.options2[2] = material.factor; |
---|
| 346 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 347 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 348 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
342 | 349 | |
---|
343 | 350 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 351 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 352 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 353 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
344 | 354 | display.options4[0] = material.cameralight/0.2f; |
---|
345 | 355 | display.options4[1] = material.subsurface; |
---|
346 | 356 | display.options4[2] = material.sheen; |
---|
| 357 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 358 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 359 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
347 | 360 | |
---|
348 | 361 | // if (display.CURRENTANTIALIAS > 0) |
---|
349 | 362 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
359 | 372 | /**/ |
---|
360 | 373 | } else |
---|
361 | 374 | { |
---|
362 | | - DrawMaterial(material, selected); |
---|
| 375 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
363 | 376 | } |
---|
364 | 377 | } else |
---|
365 | 378 | { |
---|
.. | .. |
---|
383 | 396 | cStatic.objectstack[materialdepth++] = obj; |
---|
384 | 397 | //System.out.println("material " + material); |
---|
385 | 398 | //Applet3D.tracein("selected ", selected); |
---|
386 | | - display.vector2buffer = obj.projectedVertices; |
---|
387 | | - display.DrawMaterial(material, selected); |
---|
| 399 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 400 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
388 | 401 | } |
---|
389 | 402 | } |
---|
390 | 403 | |
---|
.. | .. |
---|
401 | 414 | materialdepth -= 1; |
---|
402 | 415 | if (materialdepth > 0) |
---|
403 | 416 | { |
---|
404 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
405 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 417 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 418 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
406 | 419 | } |
---|
407 | 420 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
408 | 421 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
422 | 435 | materialdepth -= 1; |
---|
423 | 436 | if (materialdepth > 0) |
---|
424 | 437 | { |
---|
425 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
426 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 438 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 439 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
427 | 440 | } |
---|
428 | 441 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
429 | 442 | //else |
---|
.. | .. |
---|
464 | 477 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
465 | 478 | { |
---|
466 | 479 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
467 | | - boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 480 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 481 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 482 | + ; |
---|
468 | 483 | if (!hasnorm) |
---|
469 | 484 | { |
---|
470 | | - // System.out.println("FUCK!!"); |
---|
| 485 | + // System.out.println("Mesh normal"); |
---|
471 | 486 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
472 | 487 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
473 | 488 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1192 | 1207 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1193 | 1208 | } |
---|
1194 | 1209 | } |
---|
| 1210 | + |
---|
1195 | 1211 | if (flipV) |
---|
1196 | 1212 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1197 | 1213 | else |
---|
1198 | 1214 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1215 | + |
---|
1199 | 1216 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1200 | 1217 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1201 | 1218 | |
---|
.. | .. |
---|
1215 | 1232 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1216 | 1233 | } |
---|
1217 | 1234 | } |
---|
| 1235 | + |
---|
1218 | 1236 | if (flipV) |
---|
1219 | 1237 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1220 | 1238 | else |
---|
1221 | 1239 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1240 | + |
---|
1222 | 1241 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1223 | 1242 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1224 | 1243 | |
---|
.. | .. |
---|
1246 | 1265 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1247 | 1266 | else |
---|
1248 | 1267 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1268 | + |
---|
1249 | 1269 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1250 | 1270 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1271 | + |
---|
1251 | 1272 | count2 += 2; |
---|
1252 | 1273 | count3 += 3; |
---|
1253 | 1274 | } |
---|
.. | .. |
---|
1603 | 1624 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1604 | 1625 | } |
---|
1605 | 1626 | |
---|
1606 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1627 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1607 | 1628 | { |
---|
1608 | 1629 | CameraPane display = this; |
---|
1609 | 1630 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1638 | 1659 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1639 | 1660 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1640 | 1661 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1641 | | - colorV[3] = material.opacity; |
---|
| 1662 | + colorV[3] = 1; // material.opacity; |
---|
1642 | 1663 | |
---|
1643 | 1664 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1644 | 1665 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1746 | 1767 | display.modelParams7[2] = 0; |
---|
1747 | 1768 | display.modelParams7[3] = 0; |
---|
1748 | 1769 | |
---|
1749 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1770 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1750 | 1771 | |
---|
1751 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1772 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1752 | 1773 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1753 | 1774 | { |
---|
1754 | 1775 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1890 | 1911 | void PushMatrix(double[][] matrix) |
---|
1891 | 1912 | { |
---|
1892 | 1913 | // GrafreeD.tracein(matrix); |
---|
1893 | | - PushMatrix(matrix,1); |
---|
| 1914 | + PushMatrix(matrix, 1); |
---|
1894 | 1915 | } |
---|
1895 | 1916 | |
---|
1896 | 1917 | void PushMatrix() |
---|
.. | .. |
---|
2044 | 2065 | //System.err.println("Oeil on"); |
---|
2045 | 2066 | OEIL = true; |
---|
2046 | 2067 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2047 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2068 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2048 | 2069 | //pingthread.StepToTarget(true); |
---|
2049 | 2070 | } |
---|
2050 | 2071 | |
---|
.. | .. |
---|
2259 | 2280 | |
---|
2260 | 2281 | void ToggleDebug() |
---|
2261 | 2282 | { |
---|
2262 | | - DEBUG ^= true; |
---|
| 2283 | + Globals.DEBUG ^= true; |
---|
2263 | 2284 | } |
---|
2264 | 2285 | |
---|
2265 | 2286 | void ToggleLookAt() |
---|
.. | .. |
---|
2277 | 2298 | HANDLES ^= true; |
---|
2278 | 2299 | } |
---|
2279 | 2300 | |
---|
| 2301 | + Object3D paintFolder; |
---|
| 2302 | + |
---|
2280 | 2303 | void TogglePaint() |
---|
2281 | 2304 | { |
---|
2282 | 2305 | PAINTMODE ^= true; |
---|
2283 | 2306 | paintcount = 0; |
---|
| 2307 | + |
---|
| 2308 | + if (PAINTMODE) |
---|
| 2309 | + { |
---|
| 2310 | + paintFolder = GetFolder(); |
---|
| 2311 | + } |
---|
2284 | 2312 | } |
---|
2285 | 2313 | |
---|
2286 | 2314 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2377 | 2405 | return currentGL; |
---|
2378 | 2406 | } |
---|
2379 | 2407 | |
---|
| 2408 | + private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2409 | + { |
---|
| 2410 | + // cache to disk |
---|
| 2411 | + Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
| 2412 | + //buffers[0]. |
---|
| 2413 | + ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
| 2414 | + int[] pixels = new int[bytebuf.capacity()/3]; |
---|
| 2415 | + int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared |
---|
| 2416 | + int height = width; |
---|
| 2417 | + for (int i=pixels.length; --i>=0;) |
---|
| 2418 | + { |
---|
| 2419 | + int i3 = i*3; |
---|
| 2420 | + pixels[i] = 0xFF; |
---|
| 2421 | + pixels[i] <<= 8; |
---|
| 2422 | + pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
| 2423 | + pixels[i] <<= 8; |
---|
| 2424 | + pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
| 2425 | + pixels[i] <<= 8; |
---|
| 2426 | + pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
| 2427 | + } |
---|
| 2428 | + /* |
---|
| 2429 | + int r=0,g=0,b=0,a=0; |
---|
| 2430 | + for (int i=0; i<width; i++) |
---|
| 2431 | + for (int j=0; j<height; j++) |
---|
| 2432 | + { |
---|
| 2433 | + int index = j*width+i; |
---|
| 2434 | + int p = pixels[index]; |
---|
| 2435 | + a = ((p>>24) & 0xFF); |
---|
| 2436 | + r = ((p>>16) & 0xFF); |
---|
| 2437 | + g = ((p>>8) & 0xFF); |
---|
| 2438 | + b = (p & 0xFF); |
---|
| 2439 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 2440 | + } |
---|
| 2441 | + /**/ |
---|
| 2442 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 2443 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 2444 | + return rendImage; |
---|
| 2445 | + } |
---|
| 2446 | + |
---|
2380 | 2447 | /**/ |
---|
2381 | 2448 | class CacheTexture |
---|
2382 | 2449 | { |
---|
.. | .. |
---|
2394 | 2461 | /**/ |
---|
2395 | 2462 | |
---|
2396 | 2463 | // 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>(); |
---|
| 2464 | + static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
| 2465 | + static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
| 2466 | + static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); |
---|
| 2467 | + |
---|
2400 | 2468 | int pigmentdepth = 0; |
---|
2401 | 2469 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2470 | int bumpdepth = 0; |
---|
.. | .. |
---|
2418 | 2486 | true, |
---|
2419 | 2487 | com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2420 | 2488 | } catch (java.io.IOException e) |
---|
| 2489 | + { |
---|
| 2490 | + throw new javax.media.opengl.GLException(e); |
---|
| 2491 | + } |
---|
| 2492 | + |
---|
| 2493 | + if (bump) |
---|
| 2494 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2495 | + |
---|
| 2496 | + com.sun.opengl.util.texture.Texture texture = |
---|
| 2497 | + com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2498 | + |
---|
| 2499 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2500 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2501 | + |
---|
| 2502 | + return texture; |
---|
| 2503 | + } |
---|
| 2504 | + |
---|
| 2505 | + com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2506 | + { |
---|
| 2507 | + TextureData texturedata = null; |
---|
| 2508 | + |
---|
| 2509 | + try |
---|
| 2510 | + { |
---|
| 2511 | + texturedata = |
---|
| 2512 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2513 | + name, |
---|
| 2514 | + true); |
---|
| 2515 | + } catch (Exception e) |
---|
2421 | 2516 | { |
---|
2422 | 2517 | throw new javax.media.opengl.GLException(e); |
---|
2423 | 2518 | } |
---|
.. | .. |
---|
3504 | 3599 | |
---|
3505 | 3600 | System.out.println("LOADING TEXTURE : " + name); |
---|
3506 | 3601 | |
---|
| 3602 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3603 | + |
---|
3507 | 3604 | // |
---|
3508 | 3605 | if (false) // compressbit > 0) |
---|
3509 | 3606 | { |
---|
.. | .. |
---|
7902 | 7999 | String pigment = Object3D.GetPigment(tex); |
---|
7903 | 8000 | String bump = Object3D.GetBump(tex); |
---|
7904 | 8001 | |
---|
7905 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8002 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7906 | 8003 | { |
---|
7907 | 8004 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7908 | 8005 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7919 | 8016 | |
---|
7920 | 8017 | ReleaseTexture(bump, true); |
---|
7921 | 8018 | ReleaseTexture(pigment, false); |
---|
| 8019 | + } |
---|
| 8020 | + |
---|
| 8021 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8022 | + { |
---|
| 8023 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8024 | + { |
---|
| 8025 | + return; |
---|
| 8026 | + } |
---|
| 8027 | + |
---|
| 8028 | + if (tex == null) |
---|
| 8029 | + { |
---|
| 8030 | + ReleaseTexture(null, false); |
---|
| 8031 | + return; |
---|
| 8032 | + } |
---|
| 8033 | + |
---|
| 8034 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8035 | + |
---|
| 8036 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8037 | + { |
---|
| 8038 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8039 | + // System.out.println("; bump = " + bump); |
---|
| 8040 | + } |
---|
| 8041 | + |
---|
| 8042 | + if (pigment.equals("")) |
---|
| 8043 | + { |
---|
| 8044 | + pigment = null; |
---|
| 8045 | + } |
---|
| 8046 | + |
---|
| 8047 | + ReleaseTexture(pigment, false); |
---|
| 8048 | + } |
---|
| 8049 | + |
---|
| 8050 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8051 | + { |
---|
| 8052 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8053 | + { |
---|
| 8054 | + return; |
---|
| 8055 | + } |
---|
| 8056 | + |
---|
| 8057 | + if (tex == null) |
---|
| 8058 | + { |
---|
| 8059 | + ReleaseTexture(null, true); |
---|
| 8060 | + return; |
---|
| 8061 | + } |
---|
| 8062 | + |
---|
| 8063 | + String bump = Object3D.GetBump(tex); |
---|
| 8064 | + |
---|
| 8065 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8066 | + { |
---|
| 8067 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8068 | + // System.out.println("; bump = " + bump); |
---|
| 8069 | + } |
---|
| 8070 | + |
---|
| 8071 | + if (bump.equals("")) |
---|
| 8072 | + { |
---|
| 8073 | + bump = null; |
---|
| 8074 | + } |
---|
| 8075 | + |
---|
| 8076 | + ReleaseTexture(bump, true); |
---|
7922 | 8077 | } |
---|
7923 | 8078 | |
---|
7924 | 8079 | void ReleaseTexture(String tex, boolean bump) |
---|
.. | .. |
---|
8026 | 8181 | |
---|
8027 | 8182 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8028 | 8183 | { |
---|
| 8184 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8185 | +// ambientOcclusion ) // || !textureon) |
---|
| 8186 | +// { |
---|
| 8187 | +// return; // false; |
---|
| 8188 | +// } |
---|
| 8189 | +// |
---|
| 8190 | +// if (tex == null) |
---|
| 8191 | +// { |
---|
| 8192 | +// BindTexture(null,false,resolution); |
---|
| 8193 | +// BindTexture(null,true,resolution); |
---|
| 8194 | +// return; |
---|
| 8195 | +// } |
---|
| 8196 | +// |
---|
| 8197 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8198 | +// String bump = Object3D.GetBump(tex); |
---|
| 8199 | +// |
---|
| 8200 | +// usedtextures.add(pigment); |
---|
| 8201 | +// usedtextures.add(bump); |
---|
| 8202 | +// |
---|
| 8203 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8204 | +// { |
---|
| 8205 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8206 | +// // System.out.println("; bump = " + bump); |
---|
| 8207 | +// } |
---|
| 8208 | +// |
---|
| 8209 | +// if (bump.equals("")) |
---|
| 8210 | +// { |
---|
| 8211 | +// bump = null; |
---|
| 8212 | +// } |
---|
| 8213 | +// if (pigment.equals("")) |
---|
| 8214 | +// { |
---|
| 8215 | +// pigment = null; |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8219 | +// BindTexture(pigment, false, resolution); |
---|
| 8220 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8221 | +// BindTexture(bump, true, resolution); |
---|
| 8222 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8223 | +// |
---|
| 8224 | +// return; // true; |
---|
| 8225 | + |
---|
| 8226 | + BindPigmentTexture(tex, resolution); |
---|
| 8227 | + BindBumpTexture(tex, resolution); |
---|
| 8228 | + } |
---|
| 8229 | + |
---|
| 8230 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8231 | + { |
---|
8029 | 8232 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8030 | 8233 | ambientOcclusion ) // || !textureon) |
---|
8031 | 8234 | { |
---|
.. | .. |
---|
8034 | 8237 | |
---|
8035 | 8238 | if (tex == null) |
---|
8036 | 8239 | { |
---|
8037 | | - BindTexture(null,false,resolution); |
---|
8038 | | - BindTexture(null,true,resolution); |
---|
| 8240 | + BindTexture(null, null,false,resolution); |
---|
8039 | 8241 | return; |
---|
8040 | 8242 | } |
---|
8041 | 8243 | |
---|
8042 | 8244 | String pigment = Object3D.GetPigment(tex); |
---|
| 8245 | + |
---|
| 8246 | + usedtextures.add(pigment); |
---|
| 8247 | + |
---|
| 8248 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8249 | + { |
---|
| 8250 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8251 | + // System.out.println("; bump = " + bump); |
---|
| 8252 | + } |
---|
| 8253 | + |
---|
| 8254 | + if (pigment.equals("")) |
---|
| 8255 | + { |
---|
| 8256 | + pigment = null; |
---|
| 8257 | + } |
---|
| 8258 | + |
---|
| 8259 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8260 | + BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8264 | + { |
---|
| 8265 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8266 | + ambientOcclusion ) // || !textureon) |
---|
| 8267 | + { |
---|
| 8268 | + return; // false; |
---|
| 8269 | + } |
---|
| 8270 | + |
---|
| 8271 | + if (tex == null) |
---|
| 8272 | + { |
---|
| 8273 | + BindTexture(null, null,true,resolution); |
---|
| 8274 | + return; |
---|
| 8275 | + } |
---|
| 8276 | + |
---|
8043 | 8277 | String bump = Object3D.GetBump(tex); |
---|
8044 | 8278 | |
---|
8045 | | - usedtextures.put(pigment, pigment); |
---|
8046 | | - usedtextures.put(bump, bump); |
---|
| 8279 | + usedtextures.add(bump); |
---|
8047 | 8280 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8281 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8282 | { |
---|
8050 | 8283 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8284 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8055 | 8288 | { |
---|
8056 | 8289 | bump = null; |
---|
8057 | 8290 | } |
---|
8058 | | - if (pigment.equals("")) |
---|
8059 | | - { |
---|
8060 | | - pigment = null; |
---|
8061 | | - } |
---|
8062 | 8291 | |
---|
8063 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8064 | | - BindTexture(pigment, false, resolution); |
---|
8065 | 8292 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8066 | | - BindTexture(bump, true, resolution); |
---|
| 8293 | + BindTexture(tex.bumptexture, bump, true, resolution); |
---|
8067 | 8294 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8068 | | - |
---|
8069 | | - return; // true; |
---|
8070 | 8295 | } |
---|
8071 | 8296 | |
---|
8072 | 8297 | java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
.. | .. |
---|
8089 | 8314 | return fileExists; |
---|
8090 | 8315 | } |
---|
8091 | 8316 | |
---|
8092 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8317 | + CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
8093 | 8318 | { |
---|
8094 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8319 | + CacheTexture texturecache = null; |
---|
8095 | 8320 | |
---|
8096 | 8321 | if (tex != null) |
---|
8097 | 8322 | { |
---|
.. | .. |
---|
8111 | 8336 | } |
---|
8112 | 8337 | |
---|
8113 | 8338 | if (CACHETEXTURE) |
---|
8114 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8115 | | - |
---|
8116 | | - TextureData texturedata = null; |
---|
8117 | | - |
---|
8118 | | - if (texture == null || texture.resolution < resolution) |
---|
8119 | 8339 | { |
---|
| 8340 | + if (bim == null) |
---|
| 8341 | + texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8342 | + else |
---|
| 8343 | + texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8344 | + } |
---|
| 8345 | + |
---|
| 8346 | + if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8347 | + { |
---|
| 8348 | + TextureData texturedata = null; |
---|
| 8349 | + |
---|
| 8350 | + if (bim != null) |
---|
| 8351 | + { |
---|
| 8352 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8353 | + } |
---|
| 8354 | + else |
---|
8120 | 8355 | if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8121 | 8356 | { |
---|
8122 | 8357 | assert(!bump); |
---|
.. | .. |
---|
8128 | 8363 | // } |
---|
8129 | 8364 | // else |
---|
8130 | 8365 | // { |
---|
8131 | | - texture = textures.get(tex); |
---|
8132 | | - if (texture == null) |
---|
| 8366 | + texturecache = textures.get(tex); |
---|
| 8367 | + if (texturecache == null) |
---|
8133 | 8368 | { |
---|
8134 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8369 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8135 | 8370 | } |
---|
| 8371 | + else |
---|
| 8372 | + new Exception().printStackTrace(); |
---|
8136 | 8373 | // } |
---|
8137 | 8374 | } else |
---|
8138 | 8375 | if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8139 | 8376 | { |
---|
8140 | 8377 | assert(bump); |
---|
8141 | | - texture = textures.get(tex); |
---|
8142 | | - if (texture == null) |
---|
8143 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8378 | + texturecache = textures.get(tex); |
---|
| 8379 | + if (texturecache == null) |
---|
| 8380 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8381 | + else |
---|
| 8382 | + new Exception().printStackTrace(); |
---|
8144 | 8383 | } else |
---|
8145 | 8384 | { |
---|
8146 | 8385 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8150 | 8389 | //{ |
---|
8151 | 8390 | if (tex.equals("WHITE_NOISE")) |
---|
8152 | 8391 | { |
---|
8153 | | - texture = textures.get(tex); |
---|
8154 | | - if (texture == null) |
---|
8155 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8392 | + texturecache = textures.get(tex); |
---|
| 8393 | + if (texturecache == null) |
---|
| 8394 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8395 | + else |
---|
| 8396 | + new Exception().printStackTrace(); |
---|
8156 | 8397 | } else |
---|
8157 | 8398 | { |
---|
8158 | 8399 | if (textureon) |
---|
.. | .. |
---|
8211 | 8452 | if (texturedata == null) |
---|
8212 | 8453 | throw new Exception(); |
---|
8213 | 8454 | |
---|
8214 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8455 | + texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8215 | 8456 | //texture = GetTexture(tex, bump); |
---|
8216 | 8457 | } |
---|
8217 | 8458 | } |
---|
8218 | 8459 | //} |
---|
8219 | 8460 | } |
---|
8220 | 8461 | |
---|
8221 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8462 | + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8222 | 8463 | { |
---|
8223 | 8464 | //return false; |
---|
| 8465 | + assert(bim == null); |
---|
8224 | 8466 | |
---|
8225 | 8467 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8226 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8468 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8227 | 8469 | { |
---|
8228 | 8470 | // String ext = "_highres"; |
---|
8229 | 8471 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8240 | 8482 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8241 | 8483 | if (!cachefile.exists()) |
---|
8242 | 8484 | { |
---|
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)) |
---|
| 8485 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8252 | 8486 | { |
---|
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); |
---|
| 8487 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8488 | + |
---|
8283 | 8489 | ImageWriter writer = null; |
---|
8284 | 8490 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8285 | 8491 | if (iter.hasNext()) { |
---|
8286 | 8492 | writer = (ImageWriter)iter.next(); |
---|
8287 | 8493 | } |
---|
8288 | | - float compressionQuality = 0.9f; |
---|
| 8494 | + |
---|
| 8495 | + float compressionQuality = 0.85f; |
---|
8289 | 8496 | try |
---|
8290 | 8497 | { |
---|
8291 | 8498 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8312 | 8519 | textures.remove(texname); |
---|
8313 | 8520 | } |
---|
8314 | 8521 | |
---|
8315 | | - texture.texturedata = texturedata; |
---|
8316 | | - textures.put(texname, texture); |
---|
| 8522 | + //texture.texturedata = texturedata; |
---|
| 8523 | + textures.put(texname, texturecache); |
---|
8317 | 8524 | |
---|
8318 | 8525 | // newtex = true; |
---|
8319 | 8526 | } |
---|
.. | .. |
---|
8329 | 8536 | } |
---|
8330 | 8537 | } |
---|
8331 | 8538 | |
---|
8332 | | - return texture; |
---|
| 8539 | + return texturecache; |
---|
8333 | 8540 | } |
---|
8334 | 8541 | |
---|
8335 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8542 | + static void EmbedTextures(cTexture tex) |
---|
8336 | 8543 | { |
---|
8337 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8544 | + |
---|
| 8545 | + } |
---|
| 8546 | + |
---|
| 8547 | + com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8548 | + { |
---|
| 8549 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8338 | 8550 | |
---|
8339 | 8551 | if (bump) |
---|
8340 | 8552 | { |
---|
.. | .. |
---|
8350 | 8562 | return texture!=null?texture.texture:null; |
---|
8351 | 8563 | } |
---|
8352 | 8564 | |
---|
8353 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8565 | + public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8354 | 8566 | { |
---|
8355 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8567 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8356 | 8568 | |
---|
8357 | 8569 | return texture!=null?texture.texturedata:null; |
---|
8358 | 8570 | } |
---|
8359 | 8571 | |
---|
8360 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8572 | + boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8361 | 8573 | { |
---|
8362 | 8574 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8363 | 8575 | { |
---|
8364 | 8576 | return false; |
---|
8365 | 8577 | } |
---|
8366 | 8578 | |
---|
8367 | | - boolean newtex = false; |
---|
| 8579 | + //boolean newtex = false; |
---|
8368 | 8580 | |
---|
8369 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
| 8581 | + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
8370 | 8582 | |
---|
8371 | 8583 | if (texture == null) |
---|
8372 | 8584 | return false; |
---|
.. | .. |
---|
8396 | 8608 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8397 | 8609 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8398 | 8610 | |
---|
8399 | | - return newtex; |
---|
| 8611 | + return true; // Warning: not used. |
---|
8400 | 8612 | } |
---|
8401 | 8613 | |
---|
8402 | 8614 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
9234 | 9446 | jy8[3] = 0.5f; |
---|
9235 | 9447 | } |
---|
9236 | 9448 | |
---|
9237 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9449 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9238 | 9450 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9239 | 9451 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9240 | 9452 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9241 | 9453 | |
---|
| 9454 | + void ResetOptions() |
---|
| 9455 | + { |
---|
| 9456 | + options1[0] = 100; |
---|
| 9457 | + options1[1] = 0.025f; |
---|
| 9458 | + options1[2] = 0.01f; |
---|
| 9459 | + options1[3] = 0; |
---|
| 9460 | + options1[4] = 0; |
---|
| 9461 | + |
---|
| 9462 | + options2[0] = 0; |
---|
| 9463 | + options2[1] = 0.75f; |
---|
| 9464 | + options2[2] = 0; |
---|
| 9465 | + options2[3] = 0; |
---|
| 9466 | + |
---|
| 9467 | + options3[0] = 1; |
---|
| 9468 | + options3[1] = 1; |
---|
| 9469 | + options3[2] = 1; |
---|
| 9470 | + options3[3] = 0; |
---|
| 9471 | + |
---|
| 9472 | + options4[0] = 1; |
---|
| 9473 | + options4[1] = 0; |
---|
| 9474 | + options4[2] = 1; |
---|
| 9475 | + options4[3] = 0; |
---|
| 9476 | + } |
---|
| 9477 | + |
---|
9242 | 9478 | static int imagecount = 0; // movie generation |
---|
9243 | 9479 | |
---|
9244 | 9480 | static int jitter = 0; |
---|
.. | .. |
---|
9335 | 9571 | |
---|
9336 | 9572 | if (renderCamera != lightCamera) |
---|
9337 | 9573 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9338 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 9574 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9339 | 9575 | |
---|
9340 | 9576 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9341 | 9577 | |
---|
.. | .. |
---|
9351 | 9587 | |
---|
9352 | 9588 | if (renderCamera != lightCamera) |
---|
9353 | 9589 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9354 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 9590 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9355 | 9591 | |
---|
9356 | 9592 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9357 | 9593 | |
---|
.. | .. |
---|
10349 | 10585 | ANTIALIAS = 0; |
---|
10350 | 10586 | //System.out.println("RESTART"); |
---|
10351 | 10587 | AAtimer.restart(); |
---|
| 10588 | + Globals.TIMERRUNNING = true; |
---|
10352 | 10589 | } |
---|
10353 | 10590 | } |
---|
10354 | 10591 | } |
---|
.. | .. |
---|
10416 | 10653 | ambientOcclusion = false; |
---|
10417 | 10654 | } |
---|
10418 | 10655 | |
---|
10419 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10656 | + if (//Globals.lighttouched && |
---|
| 10657 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10420 | 10658 | { |
---|
10421 | 10659 | //if (RENDERSHADOW) // ? |
---|
10422 | 10660 | if (!IsFrozen()) |
---|
.. | .. |
---|
10550 | 10788 | // if (parentcam != renderCamera) // not a light |
---|
10551 | 10789 | if (cam != lightCamera) |
---|
10552 | 10790 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10553 | | - LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
| 10791 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10554 | 10792 | |
---|
10555 | 10793 | for (int j = 0; j < 4; j++) |
---|
10556 | 10794 | { |
---|
.. | .. |
---|
10565 | 10803 | // if (parentcam != renderCamera) // not a light |
---|
10566 | 10804 | if (cam != lightCamera) |
---|
10567 | 10805 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10568 | | - LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
| 10806 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10569 | 10807 | |
---|
10570 | 10808 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10571 | 10809 | |
---|
.. | .. |
---|
10827 | 11065 | |
---|
10828 | 11066 | try |
---|
10829 | 11067 | { |
---|
10830 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11068 | + BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
10831 | 11069 | } |
---|
10832 | 11070 | catch (Exception e) |
---|
10833 | 11071 | { |
---|
.. | .. |
---|
10856 | 11094 | |
---|
10857 | 11095 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10858 | 11096 | |
---|
10859 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10860 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10861 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11097 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11098 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11099 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10862 | 11100 | } else |
---|
10863 | 11101 | { |
---|
10864 | 11102 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10869 | 11107 | //System.out.println("BLENDING ON"); |
---|
10870 | 11108 | gl.glEnable(GL.GL_BLEND); |
---|
10871 | 11109 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10872 | | - |
---|
| 11110 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10873 | 11111 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10874 | 11112 | gl.glLoadIdentity(); |
---|
10875 | 11113 | |
---|
.. | .. |
---|
10959 | 11197 | |
---|
10960 | 11198 | // if (cam != lightCamera) |
---|
10961 | 11199 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10962 | | - LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
| 11200 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10963 | 11201 | } |
---|
10964 | 11202 | |
---|
10965 | 11203 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10981 | 11219 | { |
---|
10982 | 11220 | if (cam != lightCamera) |
---|
10983 | 11221 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10984 | | - LA.xformDir(light0, parentcam.GlobalTransformInv(), light0); // may 2013 |
---|
| 11222 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10985 | 11223 | } |
---|
10986 | 11224 | |
---|
10987 | 11225 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11326 | 11564 | |
---|
11327 | 11565 | static boolean zoomonce = false; |
---|
11328 | 11566 | |
---|
| 11567 | + static void CreateSelectedPoint() |
---|
| 11568 | + { |
---|
| 11569 | + if (selectedpoint == null) |
---|
| 11570 | + { |
---|
| 11571 | + debugpointG = new Sphere(); |
---|
| 11572 | + debugpointP = new Sphere(); |
---|
| 11573 | + debugpointC = new Sphere(); |
---|
| 11574 | + debugpointR = new Sphere(); |
---|
| 11575 | + |
---|
| 11576 | + selectedpoint = new Superellipsoid(); |
---|
| 11577 | + |
---|
| 11578 | + for (int i=0; i<8; i++) |
---|
| 11579 | + { |
---|
| 11580 | + debugpoints[i] = new Sphere(); |
---|
| 11581 | + } |
---|
| 11582 | + } |
---|
| 11583 | + } |
---|
| 11584 | + |
---|
11329 | 11585 | void DrawObject(GL gl, boolean draw) |
---|
11330 | 11586 | { |
---|
| 11587 | + // To clear camera values |
---|
| 11588 | + ResetOptions(); |
---|
| 11589 | + |
---|
11331 | 11590 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11332 | 11591 | // DrawMode() = SELECTION; |
---|
11333 | 11592 | //GL gl = getGL(); |
---|
11334 | 11593 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11335 | 11594 | { |
---|
11336 | 11595 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11337 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11596 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11338 | 11597 | pingthread.StepToTarget(true); // true); |
---|
11339 | 11598 | // zoomonce = false; |
---|
11340 | 11599 | } |
---|
.. | .. |
---|
11406 | 11665 | |
---|
11407 | 11666 | if (DrawMode() == DEFAULT) |
---|
11408 | 11667 | { |
---|
11409 | | - if (DEBUG) |
---|
| 11668 | + if (Globals.DEBUG) |
---|
11410 | 11669 | { |
---|
| 11670 | + CreateSelectedPoint(); |
---|
11411 | 11671 | float radius = 0.05f; |
---|
11412 | 11672 | if (selectedpoint.radius != radius) |
---|
11413 | 11673 | { |
---|
.. | .. |
---|
11470 | 11730 | if (tex.equals("WHITE_NOISE")) |
---|
11471 | 11731 | continue; |
---|
11472 | 11732 | |
---|
11473 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11733 | + if (!usedtextures.contains(tex)) |
---|
11474 | 11734 | { |
---|
11475 | 11735 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11476 | 11736 | textures.get(tex).texture.dispose(); |
---|
.. | .. |
---|
11912 | 12172 | } |
---|
11913 | 12173 | |
---|
11914 | 12174 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11915 | | - LA.xformPos(light, parentcam.GlobalTransformInv(), light); // may 2013 |
---|
| 12175 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11916 | 12176 | |
---|
11917 | 12177 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11918 | 12178 | |
---|
.. | .. |
---|
13164 | 13424 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13165 | 13425 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13166 | 13426 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13167 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13427 | + |
---|
| 13428 | + //Object3D.cVector2[] vector2buffer; |
---|
13168 | 13429 | |
---|
13169 | 13430 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13170 | 13431 | // OUT : diff, spec |
---|
.. | .. |
---|
13180 | 13441 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13181 | 13442 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13182 | 13443 | //"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;" + |
---|
| 13444 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13445 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13446 | + |
---|
| 13447 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13186 | 13448 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13187 | 13449 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13188 | 13450 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13687 | 13949 | else |
---|
13688 | 13950 | if (evt.getSource() == AAtimer) |
---|
13689 | 13951 | { |
---|
| 13952 | + Globals.TIMERRUNNING = false; |
---|
13690 | 13953 | if (mouseDown) |
---|
13691 | 13954 | { |
---|
13692 | 13955 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13746 | 14009 | |
---|
13747 | 14010 | // fev 2014??? |
---|
13748 | 14011 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13749 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14012 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13750 | 14013 | pingthread.StepToTarget(true); // true); |
---|
13751 | 14014 | } |
---|
13752 | 14015 | // if (!LIVE) |
---|
.. | .. |
---|
13761 | 14024 | return; |
---|
13762 | 14025 | |
---|
13763 | 14026 | AAtimer.restart(); // |
---|
| 14027 | + Globals.TIMERRUNNING = true; |
---|
13764 | 14028 | |
---|
13765 | 14029 | // waslive = LIVE; |
---|
13766 | 14030 | // LIVE = false; |
---|
.. | .. |
---|
13833 | 14097 | |
---|
13834 | 14098 | public void mouseDragged(MouseEvent e) |
---|
13835 | 14099 | { |
---|
| 14100 | + Globals.MOUSEDRAGGED = true; |
---|
| 14101 | + |
---|
13836 | 14102 | //System.out.println("mouseDragged: " + e); |
---|
13837 | 14103 | if (isRenderer) |
---|
13838 | 14104 | movingcamera = true; |
---|
.. | .. |
---|
14097 | 14363 | void GoDown(int mod) |
---|
14098 | 14364 | { |
---|
14099 | 14365 | MODIFIERS |= COMMAND; |
---|
14100 | | - /* |
---|
| 14366 | + /**/ |
---|
14101 | 14367 | if((mod&SHIFT) == SHIFT) |
---|
14102 | 14368 | manipCamera.RotatePosition(0, -speed); |
---|
14103 | 14369 | else |
---|
14104 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14105 | | - */ |
---|
| 14370 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14371 | + /**/ |
---|
14106 | 14372 | if ((mod & SHIFT) == SHIFT) |
---|
14107 | 14373 | { |
---|
14108 | 14374 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14118 | 14384 | void GoUp(int mod) |
---|
14119 | 14385 | { |
---|
14120 | 14386 | MODIFIERS |= COMMAND; |
---|
14121 | | - /* |
---|
| 14387 | + /**/ |
---|
14122 | 14388 | if((mod&SHIFT) == SHIFT) |
---|
14123 | 14389 | manipCamera.RotatePosition(0, speed); |
---|
14124 | 14390 | else |
---|
14125 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14126 | | - */ |
---|
| 14391 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14392 | + /**/ |
---|
14127 | 14393 | if ((mod & SHIFT) == SHIFT) |
---|
14128 | 14394 | { |
---|
14129 | 14395 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14139 | 14405 | void GoLeft(int mod) |
---|
14140 | 14406 | { |
---|
14141 | 14407 | MODIFIERS |= COMMAND; |
---|
14142 | | - /* |
---|
| 14408 | + /**/ |
---|
14143 | 14409 | if((mod&SHIFT) == SHIFT) |
---|
14144 | | - manipCamera.RotatePosition(speed, 0); |
---|
14145 | | - else |
---|
14146 | 14410 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14147 | | - */ |
---|
| 14411 | + else |
---|
| 14412 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14413 | + /**/ |
---|
14148 | 14414 | if ((mod & SHIFT) == SHIFT) |
---|
14149 | 14415 | { |
---|
14150 | 14416 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14160 | 14426 | void GoRight(int mod) |
---|
14161 | 14427 | { |
---|
14162 | 14428 | MODIFIERS |= COMMAND; |
---|
14163 | | - /* |
---|
| 14429 | + /**/ |
---|
14164 | 14430 | if((mod&SHIFT) == SHIFT) |
---|
14165 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14166 | | - else |
---|
14167 | 14431 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14168 | | - */ |
---|
| 14432 | + else |
---|
| 14433 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14434 | + /**/ |
---|
14169 | 14435 | if ((mod & SHIFT) == SHIFT) |
---|
14170 | 14436 | { |
---|
14171 | 14437 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14222 | 14488 | info.camera = renderCamera; |
---|
14223 | 14489 | info.x = x; |
---|
14224 | 14490 | info.y = y; |
---|
14225 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14491 | + object.GetWindow().copy |
---|
| 14492 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14226 | 14493 | } else |
---|
14227 | 14494 | { |
---|
14228 | 14495 | if (x < startX) |
---|
.. | .. |
---|
14386 | 14653 | ci.camera = renderCamera; |
---|
14387 | 14654 | if (!isRenderer) |
---|
14388 | 14655 | { |
---|
14389 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14656 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14657 | + //Object3D copy = editWindow.copy; |
---|
| 14658 | + if (object.doEditClick(ci, 0)) |
---|
14390 | 14659 | { |
---|
14391 | 14660 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14392 | 14661 | } else |
---|
.. | .. |
---|
14398 | 14667 | |
---|
14399 | 14668 | public void mouseReleased(MouseEvent e) |
---|
14400 | 14669 | { |
---|
| 14670 | + Globals.MOUSEDRAGGED = false; |
---|
| 14671 | + |
---|
14401 | 14672 | movingcamera = false; |
---|
14402 | | - X = Y = 0; |
---|
| 14673 | + X = 0; // getBounds().width/2; |
---|
| 14674 | + Y = 0; // getBounds().height/2; |
---|
14403 | 14675 | //System.out.println("mouseReleased: " + e); |
---|
14404 | 14676 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14405 | 14677 | } |
---|
.. | .. |
---|
14740 | 15012 | case 'E' : COMPACT ^= true; |
---|
14741 | 15013 | repaint(); |
---|
14742 | 15014 | break; |
---|
14743 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15015 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15016 | + //DEBUGHSB ^= true; |
---|
| 15017 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14744 | 15018 | repaint(); |
---|
14745 | 15019 | break; |
---|
14746 | 15020 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14765 | 15039 | RevertCamera(); |
---|
14766 | 15040 | repaint(); |
---|
14767 | 15041 | break; |
---|
14768 | | - case 'L': |
---|
14769 | 15042 | case 'l': |
---|
| 15043 | + //case 'L': |
---|
14770 | 15044 | if (lightMode) |
---|
14771 | 15045 | { |
---|
14772 | 15046 | lightMode = false; |
---|
.. | .. |
---|
14909 | 15183 | case '_': |
---|
14910 | 15184 | kompactbit = 5; |
---|
14911 | 15185 | break; |
---|
14912 | | - case '+': |
---|
14913 | | - kompactbit = 6; |
---|
14914 | | - break; |
---|
| 15186 | +// case '+': |
---|
| 15187 | +// kompactbit = 6; |
---|
| 15188 | +// break; |
---|
14915 | 15189 | case ' ': |
---|
14916 | 15190 | lightMode ^= true; |
---|
14917 | 15191 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14923 | 15197 | case ESC: |
---|
14924 | 15198 | RENDERPROGRAM += 1; |
---|
14925 | 15199 | RENDERPROGRAM %= 3; |
---|
| 15200 | + |
---|
14926 | 15201 | repaint(); |
---|
14927 | 15202 | break; |
---|
14928 | 15203 | case 'Z': |
---|
.. | .. |
---|
14962 | 15237 | case DELETE: |
---|
14963 | 15238 | ClearSelection(); |
---|
14964 | 15239 | break; |
---|
14965 | | - /* |
---|
14966 | 15240 | case '+': |
---|
| 15241 | + |
---|
| 15242 | + /* |
---|
14967 | 15243 | //fontsize += 1; |
---|
14968 | 15244 | bbzoom *= 2; |
---|
14969 | 15245 | repaint(); |
---|
.. | .. |
---|
14980 | 15256 | case '=': |
---|
14981 | 15257 | IncDepth(); |
---|
14982 | 15258 | //fontsize += 1; |
---|
14983 | | - object.editWindow.refreshContents(true); |
---|
| 15259 | + object.GetWindow().refreshContents(true); |
---|
14984 | 15260 | maskbit = 6; |
---|
14985 | 15261 | break; |
---|
14986 | 15262 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14987 | 15263 | DecDepth(); |
---|
14988 | 15264 | maskbit = 5; |
---|
14989 | 15265 | //if(fontsize > 1) fontsize -= 1; |
---|
14990 | | - if (object.editWindow == null) |
---|
14991 | | - new Exception().printStackTrace(); |
---|
14992 | | - else |
---|
14993 | | - object.editWindow.refreshContents(true); |
---|
| 15266 | +// if (object.editWindow == null) |
---|
| 15267 | +// new Exception().printStackTrace(); |
---|
| 15268 | +// else |
---|
| 15269 | + object.GetWindow().refreshContents(true); |
---|
14994 | 15270 | break; |
---|
14995 | 15271 | case '{': |
---|
14996 | 15272 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15214 | 15490 | } |
---|
15215 | 15491 | */ |
---|
15216 | 15492 | |
---|
15217 | | - object.editWindow.EditSelection(); |
---|
| 15493 | + object.GetWindow().EditSelection(false); |
---|
15218 | 15494 | } |
---|
15219 | 15495 | |
---|
15220 | 15496 | void SelectParent() |
---|
.. | .. |
---|
15231 | 15507 | { |
---|
15232 | 15508 | //selectees.remove(i); |
---|
15233 | 15509 | System.out.println("select parent of " + elem); |
---|
15234 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15510 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15235 | 15511 | } else |
---|
15236 | 15512 | { |
---|
15237 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15513 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15238 | 15514 | } |
---|
15239 | 15515 | |
---|
15240 | 15516 | first = false; |
---|
.. | .. |
---|
15276 | 15552 | for (int j = 0; j < group.children.size(); j++) |
---|
15277 | 15553 | { |
---|
15278 | 15554 | elem = (Object3D) group.children.elementAt(j); |
---|
15279 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15555 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15280 | 15556 | first = false; |
---|
15281 | 15557 | } |
---|
15282 | 15558 | } else |
---|
15283 | 15559 | { |
---|
15284 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15560 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15285 | 15561 | } |
---|
15286 | 15562 | |
---|
15287 | 15563 | first = false; |
---|
.. | .. |
---|
15292 | 15568 | { |
---|
15293 | 15569 | //Composite group = (Composite) object; |
---|
15294 | 15570 | Object3D group = object; |
---|
15295 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15571 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15296 | 15572 | } |
---|
15297 | 15573 | |
---|
15298 | 15574 | void ResetTransform(int mask) |
---|
15299 | 15575 | { |
---|
15300 | 15576 | //Composite group = (Composite) object; |
---|
15301 | 15577 | Object3D group = object; |
---|
15302 | | - group.editWindow.ResetTransform(mask); |
---|
| 15578 | + group.GetWindow().ResetTransform(mask); |
---|
15303 | 15579 | } |
---|
15304 | 15580 | |
---|
15305 | 15581 | void FlipTransform() |
---|
15306 | 15582 | { |
---|
15307 | 15583 | //Composite group = (Composite) object; |
---|
15308 | 15584 | Object3D group = object; |
---|
15309 | | - group.editWindow.FlipTransform(); |
---|
| 15585 | + group.GetWindow().FlipTransform(); |
---|
15310 | 15586 | // group.editWindow.ReduceMesh(true); |
---|
15311 | 15587 | } |
---|
15312 | 15588 | |
---|
.. | .. |
---|
15314 | 15590 | { |
---|
15315 | 15591 | //Composite group = (Composite) object; |
---|
15316 | 15592 | Object3D group = object; |
---|
15317 | | - group.editWindow.PrintMemory(); |
---|
| 15593 | + group.GetWindow().PrintMemory(); |
---|
15318 | 15594 | // group.editWindow.ReduceMesh(true); |
---|
15319 | 15595 | } |
---|
15320 | 15596 | |
---|
.. | .. |
---|
15322 | 15598 | { |
---|
15323 | 15599 | //Composite group = (Composite) object; |
---|
15324 | 15600 | Object3D group = object; |
---|
15325 | | - group.editWindow.ResetCentroid(); |
---|
| 15601 | + group.GetWindow().ResetCentroid(); |
---|
15326 | 15602 | } |
---|
15327 | 15603 | |
---|
15328 | 15604 | void IncDepth() |
---|
.. | .. |
---|
15498 | 15774 | info.bounds.y += (height - desired) / 2; |
---|
15499 | 15775 | } |
---|
15500 | 15776 | } |
---|
| 15777 | + |
---|
15501 | 15778 | info.g = gr; |
---|
15502 | 15779 | info.camera = renderCamera; |
---|
15503 | 15780 | /* |
---|
.. | .. |
---|
15507 | 15784 | */ |
---|
15508 | 15785 | if (!isRenderer) |
---|
15509 | 15786 | { |
---|
15510 | | - object.drawEditHandles(info, 0); |
---|
15511 | | - |
---|
15512 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15787 | + Grafreed.Assert(object != null); |
---|
| 15788 | + Grafreed.Assert(object.selection != null); |
---|
| 15789 | + if (object.selection.Size() > 0) |
---|
15513 | 15790 | { |
---|
15514 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15791 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15792 | + |
---|
| 15793 | + info.DX = 0; |
---|
| 15794 | + info.DY = 0; |
---|
| 15795 | + info.W = 1; |
---|
| 15796 | + if (hitSomething == Object3D.hitCenter) |
---|
15515 | 15797 | { |
---|
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; |
---|
| 15798 | + info.DX = X; |
---|
| 15799 | + if (X != 0) |
---|
| 15800 | + info.DX -= info.bounds.width/2; |
---|
| 15801 | + |
---|
| 15802 | + info.DY = Y; |
---|
| 15803 | + if (Y != 0) |
---|
| 15804 | + info.DY -= info.bounds.height/2; |
---|
15519 | 15805 | } |
---|
15520 | | - |
---|
15521 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15806 | + |
---|
| 15807 | + object.drawEditHandles(info, 0); |
---|
| 15808 | + |
---|
| 15809 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15810 | + { |
---|
| 15811 | + switch (hitSomething) |
---|
| 15812 | + { |
---|
| 15813 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15814 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15815 | + break; |
---|
| 15816 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15817 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15818 | + break; |
---|
| 15819 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15820 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15821 | + break; |
---|
| 15822 | + } |
---|
| 15823 | + |
---|
| 15824 | + } |
---|
15522 | 15825 | } |
---|
15523 | 15826 | } |
---|
15524 | 15827 | } |
---|
.. | .. |
---|
16221 | 16524 | cStatic.objectstack[materialdepth++] = checker; |
---|
16222 | 16525 | //System.out.println("material " + material); |
---|
16223 | 16526 | //Applet3D.tracein(this, selected); |
---|
16224 | | - vector2buffer = checker.projectedVertices; |
---|
| 16527 | + //vector2buffer = checker.projectedVertices; |
---|
16225 | 16528 | |
---|
16226 | 16529 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16227 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16530 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16228 | 16531 | |
---|
16229 | 16532 | materialdepth -= 1; |
---|
16230 | 16533 | if (materialdepth > 0) |
---|
16231 | 16534 | { |
---|
16232 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16233 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16535 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16536 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16234 | 16537 | } |
---|
16235 | 16538 | //checker.GetMaterial().opacity = 1f; |
---|
16236 | 16539 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16316 | 16619 | } |
---|
16317 | 16620 | } |
---|
16318 | 16621 | |
---|
| 16622 | + private Object3D GetFolder() |
---|
| 16623 | + { |
---|
| 16624 | + Object3D folder = object.GetWindow().copy; |
---|
| 16625 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16626 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16627 | + return folder; |
---|
| 16628 | + } |
---|
| 16629 | + |
---|
16319 | 16630 | class SelectBuffer implements GLEventListener |
---|
16320 | 16631 | { |
---|
16321 | 16632 | |
---|
.. | .. |
---|
16395 | 16706 | |
---|
16396 | 16707 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16397 | 16708 | |
---|
| 16709 | + if (PAINTMODE) |
---|
| 16710 | + { |
---|
| 16711 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16712 | + { |
---|
| 16713 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16714 | + |
---|
| 16715 | + // Make what you paint not selectable. |
---|
| 16716 | + paintobj.ResetSelectable(); |
---|
| 16717 | + } |
---|
| 16718 | + } |
---|
| 16719 | + |
---|
16398 | 16720 | //int tmp = selection_view; |
---|
16399 | 16721 | //selection_view = -1; |
---|
16400 | 16722 | int temp = DrawMode(); |
---|
.. | .. |
---|
16406 | 16728 | // temp = DEFAULT; // patch for selection debug |
---|
16407 | 16729 | Globals.drawMode = temp; // WARNING |
---|
16408 | 16730 | |
---|
| 16731 | + if (PAINTMODE) |
---|
| 16732 | + { |
---|
| 16733 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16734 | + { |
---|
| 16735 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16736 | + |
---|
| 16737 | + // Revert. |
---|
| 16738 | + paintobj.RestoreSelectable(); |
---|
| 16739 | + } |
---|
| 16740 | + } |
---|
| 16741 | + |
---|
16409 | 16742 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16410 | 16743 | |
---|
16411 | 16744 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16453 | 16786 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16454 | 16787 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16455 | 16788 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16789 | + |
---|
| 16790 | + CreateSelectedPoint(); |
---|
16456 | 16791 | |
---|
16457 | 16792 | // Will fit the mesh !!! |
---|
16458 | 16793 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16507 | 16842 | } |
---|
16508 | 16843 | |
---|
16509 | 16844 | if (!movingcamera && !PAINTMODE) |
---|
16510 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16845 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16511 | 16846 | |
---|
16512 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16847 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16513 | 16848 | { |
---|
16514 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16849 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16515 | 16850 | |
---|
16516 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16851 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16852 | + { |
---|
| 16853 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16517 | 16854 | |
---|
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(); |
---|
| 16855 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16856 | + |
---|
| 16857 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16858 | + |
---|
| 16859 | + inst.add(paintobj); // link |
---|
| 16860 | + |
---|
| 16861 | + object.GetWindow().SnapObject(inst); |
---|
| 16862 | + |
---|
| 16863 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16864 | + |
---|
| 16865 | + folder.add(inst); |
---|
| 16866 | + |
---|
| 16867 | + object.GetWindow().ResetModel(); |
---|
| 16868 | + object.GetWindow().refreshContents(); |
---|
| 16869 | + } |
---|
16533 | 16870 | } |
---|
16534 | 16871 | else |
---|
16535 | 16872 | paintcount = 0; |
---|
.. | .. |
---|
16568 | 16905 | //System.out.println("objects[color] = " + objects[color]); |
---|
16569 | 16906 | //objects[color].Select(); |
---|
16570 | 16907 | indexcount = 0; |
---|
| 16908 | + ObjEditor window = object.GetWindow(); |
---|
| 16909 | + if (window != null && deselect) |
---|
| 16910 | + { |
---|
| 16911 | + window.Select(null, deselect, true); |
---|
| 16912 | + } |
---|
16571 | 16913 | object.Select(color, deselect); |
---|
16572 | 16914 | } |
---|
16573 | 16915 | |
---|
.. | .. |
---|
17093 | 17435 | int AAbuffersize = 0; |
---|
17094 | 17436 | |
---|
17095 | 17437 | //double[] selectedpoint = new double[3]; |
---|
17096 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17438 | + static Superellipsoid selectedpoint; |
---|
17097 | 17439 | 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(); |
---|
| 17440 | + static Sphere debugpointG; |
---|
| 17441 | + static Sphere debugpointP; |
---|
| 17442 | + static Sphere debugpointC; |
---|
| 17443 | + static Sphere debugpointR; |
---|
17102 | 17444 | |
---|
17103 | 17445 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17104 | 17446 | |
---|
17105 | | - static |
---|
17106 | | - { |
---|
17107 | | - for (int i=0; i<8; i++) |
---|
17108 | | - { |
---|
17109 | | - debugpoints[i] = new Sphere(); |
---|
17110 | | - } |
---|
17111 | | - } |
---|
17112 | | - |
---|
17113 | 17447 | static void InitPoints(float radius) |
---|
17114 | 17448 | { |
---|
17115 | 17449 | for (int i=0; i<8; i++) |
---|