.. | .. |
---|
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 |
---|
.. | .. |
---|
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); |
---|
.. | .. |
---|
7936 | 8033 | |
---|
7937 | 8034 | String pigment = Object3D.GetPigment(tex); |
---|
7938 | 8035 | |
---|
7939 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8036 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7940 | 8037 | { |
---|
7941 | 8038 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7942 | 8039 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7965 | 8062 | |
---|
7966 | 8063 | String bump = Object3D.GetBump(tex); |
---|
7967 | 8064 | |
---|
7968 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8065 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7969 | 8066 | { |
---|
7970 | 8067 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7971 | 8068 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8084 | 8181 | |
---|
8085 | 8182 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8086 | 8183 | { |
---|
8087 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8088 | | - ambientOcclusion ) // || !textureon) |
---|
8089 | | - { |
---|
8090 | | - return; // false; |
---|
8091 | | - } |
---|
8092 | | - |
---|
8093 | | - if (tex == null) |
---|
8094 | | - { |
---|
8095 | | - BindTexture(null,false,resolution); |
---|
8096 | | - BindTexture(null,true,resolution); |
---|
8097 | | - return; |
---|
8098 | | - } |
---|
| 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; |
---|
8099 | 8225 | |
---|
8100 | | - String pigment = Object3D.GetPigment(tex); |
---|
8101 | | - String bump = Object3D.GetBump(tex); |
---|
8102 | | - |
---|
8103 | | - usedtextures.put(pigment, pigment); |
---|
8104 | | - usedtextures.put(bump, bump); |
---|
8105 | | - |
---|
8106 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8107 | | - { |
---|
8108 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8109 | | - // System.out.println("; bump = " + bump); |
---|
8110 | | - } |
---|
8111 | | - |
---|
8112 | | - if (bump.equals("")) |
---|
8113 | | - { |
---|
8114 | | - bump = null; |
---|
8115 | | - } |
---|
8116 | | - if (pigment.equals("")) |
---|
8117 | | - { |
---|
8118 | | - pigment = null; |
---|
8119 | | - } |
---|
8120 | | - |
---|
8121 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8122 | | - BindTexture(pigment, false, resolution); |
---|
8123 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8124 | | - BindTexture(bump, true, resolution); |
---|
8125 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8126 | | - |
---|
8127 | | - return; // true; |
---|
| 8226 | + BindPigmentTexture(tex, resolution); |
---|
| 8227 | + BindBumpTexture(tex, resolution); |
---|
8128 | 8228 | } |
---|
8129 | 8229 | |
---|
8130 | 8230 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8137 | 8237 | |
---|
8138 | 8238 | if (tex == null) |
---|
8139 | 8239 | { |
---|
8140 | | - BindTexture(null,false,resolution); |
---|
| 8240 | + BindTexture(null, null,false,resolution); |
---|
8141 | 8241 | return; |
---|
8142 | 8242 | } |
---|
8143 | 8243 | |
---|
8144 | 8244 | String pigment = Object3D.GetPigment(tex); |
---|
8145 | 8245 | |
---|
8146 | | - usedtextures.put(pigment, pigment); |
---|
| 8246 | + usedtextures.add(pigment); |
---|
8147 | 8247 | |
---|
8148 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8248 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8149 | 8249 | { |
---|
8150 | 8250 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8151 | 8251 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8157 | 8257 | } |
---|
8158 | 8258 | |
---|
8159 | 8259 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8160 | | - BindTexture(pigment, false, resolution); |
---|
| 8260 | + BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
8161 | 8261 | } |
---|
8162 | 8262 | |
---|
8163 | 8263 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8170 | 8270 | |
---|
8171 | 8271 | if (tex == null) |
---|
8172 | 8272 | { |
---|
8173 | | - BindTexture(null,true,resolution); |
---|
| 8273 | + BindTexture(null, null,true,resolution); |
---|
8174 | 8274 | return; |
---|
8175 | 8275 | } |
---|
8176 | 8276 | |
---|
8177 | 8277 | String bump = Object3D.GetBump(tex); |
---|
8178 | 8278 | |
---|
8179 | | - usedtextures.put(bump, bump); |
---|
| 8279 | + usedtextures.add(bump); |
---|
8180 | 8280 | |
---|
8181 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8281 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8182 | 8282 | { |
---|
8183 | 8283 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8184 | 8284 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8190 | 8290 | } |
---|
8191 | 8291 | |
---|
8192 | 8292 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8193 | | - BindTexture(bump, true, resolution); |
---|
| 8293 | + BindTexture(tex.bumptexture, bump, true, resolution); |
---|
8194 | 8294 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8195 | 8295 | } |
---|
8196 | 8296 | |
---|
.. | .. |
---|
8214 | 8314 | return fileExists; |
---|
8215 | 8315 | } |
---|
8216 | 8316 | |
---|
8217 | | - 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 |
---|
8218 | 8318 | { |
---|
8219 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8319 | + CacheTexture texturecache = null; |
---|
8220 | 8320 | |
---|
8221 | 8321 | if (tex != null) |
---|
8222 | 8322 | { |
---|
.. | .. |
---|
8236 | 8336 | } |
---|
8237 | 8337 | |
---|
8238 | 8338 | if (CACHETEXTURE) |
---|
8239 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8240 | | - |
---|
8241 | | - TextureData texturedata = null; |
---|
8242 | | - |
---|
8243 | | - if (texture == null || texture.resolution < resolution) |
---|
8244 | 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 |
---|
8245 | 8355 | if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8246 | 8356 | { |
---|
8247 | 8357 | assert(!bump); |
---|
.. | .. |
---|
8253 | 8363 | // } |
---|
8254 | 8364 | // else |
---|
8255 | 8365 | // { |
---|
8256 | | - texture = textures.get(tex); |
---|
8257 | | - if (texture == null) |
---|
| 8366 | + texturecache = textures.get(tex); |
---|
| 8367 | + if (texturecache == null) |
---|
8258 | 8368 | { |
---|
8259 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8369 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8260 | 8370 | } |
---|
| 8371 | + else |
---|
| 8372 | + new Exception().printStackTrace(); |
---|
8261 | 8373 | // } |
---|
8262 | 8374 | } else |
---|
8263 | 8375 | if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8264 | 8376 | { |
---|
8265 | 8377 | assert(bump); |
---|
8266 | | - texture = textures.get(tex); |
---|
8267 | | - if (texture == null) |
---|
8268 | | - 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(); |
---|
8269 | 8383 | } else |
---|
8270 | 8384 | { |
---|
8271 | 8385 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8275 | 8389 | //{ |
---|
8276 | 8390 | if (tex.equals("WHITE_NOISE")) |
---|
8277 | 8391 | { |
---|
8278 | | - texture = textures.get(tex); |
---|
8279 | | - if (texture == null) |
---|
8280 | | - 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(); |
---|
8281 | 8397 | } else |
---|
8282 | 8398 | { |
---|
8283 | 8399 | if (textureon) |
---|
.. | .. |
---|
8336 | 8452 | if (texturedata == null) |
---|
8337 | 8453 | throw new Exception(); |
---|
8338 | 8454 | |
---|
8339 | | - 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); |
---|
8340 | 8456 | //texture = GetTexture(tex, bump); |
---|
8341 | 8457 | } |
---|
8342 | 8458 | } |
---|
8343 | 8459 | //} |
---|
8344 | 8460 | } |
---|
8345 | 8461 | |
---|
8346 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8462 | + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8347 | 8463 | { |
---|
8348 | 8464 | //return false; |
---|
| 8465 | + assert(bim == null); |
---|
8349 | 8466 | |
---|
8350 | 8467 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8351 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8468 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8352 | 8469 | { |
---|
8353 | 8470 | // String ext = "_highres"; |
---|
8354 | 8471 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8365 | 8482 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8366 | 8483 | if (!cachefile.exists()) |
---|
8367 | 8484 | { |
---|
8368 | | - // cache to disk |
---|
8369 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8370 | | - //buffers[0]. |
---|
8371 | | - |
---|
8372 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8373 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8374 | | - |
---|
8375 | | - // squared size heuristic... |
---|
8376 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8485 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8377 | 8486 | { |
---|
8378 | | - for (int i=pixels.length; --i>=0;) |
---|
8379 | | - { |
---|
8380 | | - int i3 = i*3; |
---|
8381 | | - pixels[i] = 0xFF; |
---|
8382 | | - pixels[i] <<= 8; |
---|
8383 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8384 | | - pixels[i] <<= 8; |
---|
8385 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8386 | | - pixels[i] <<= 8; |
---|
8387 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8388 | | - } |
---|
8389 | | - |
---|
8390 | | - /* |
---|
8391 | | - int r=0,g=0,b=0,a=0; |
---|
8392 | | - for (int i=0; i<width; i++) |
---|
8393 | | - for (int j=0; j<height; j++) |
---|
8394 | | - { |
---|
8395 | | - int index = j*width+i; |
---|
8396 | | - int p = pixels[index]; |
---|
8397 | | - a = ((p>>24) & 0xFF); |
---|
8398 | | - r = ((p>>16) & 0xFF); |
---|
8399 | | - g = ((p>>8) & 0xFF); |
---|
8400 | | - b = (p & 0xFF); |
---|
8401 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8402 | | - } |
---|
8403 | | - /**/ |
---|
8404 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8405 | | - int height = width; |
---|
8406 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8407 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8487 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8488 | + |
---|
8408 | 8489 | ImageWriter writer = null; |
---|
8409 | 8490 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8410 | 8491 | if (iter.hasNext()) { |
---|
8411 | 8492 | writer = (ImageWriter)iter.next(); |
---|
8412 | 8493 | } |
---|
8413 | | - float compressionQuality = 0.9f; |
---|
| 8494 | + |
---|
| 8495 | + float compressionQuality = 0.85f; |
---|
8414 | 8496 | try |
---|
8415 | 8497 | { |
---|
8416 | 8498 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8437 | 8519 | textures.remove(texname); |
---|
8438 | 8520 | } |
---|
8439 | 8521 | |
---|
8440 | | - texture.texturedata = texturedata; |
---|
8441 | | - textures.put(texname, texture); |
---|
| 8522 | + //texture.texturedata = texturedata; |
---|
| 8523 | + textures.put(texname, texturecache); |
---|
8442 | 8524 | |
---|
8443 | 8525 | // newtex = true; |
---|
8444 | 8526 | } |
---|
.. | .. |
---|
8454 | 8536 | } |
---|
8455 | 8537 | } |
---|
8456 | 8538 | |
---|
8457 | | - return texture; |
---|
| 8539 | + return texturecache; |
---|
8458 | 8540 | } |
---|
8459 | 8541 | |
---|
8460 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8542 | + static void EmbedTextures(cTexture tex) |
---|
8461 | 8543 | { |
---|
8462 | | - 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); |
---|
8463 | 8550 | |
---|
8464 | 8551 | if (bump) |
---|
8465 | 8552 | { |
---|
.. | .. |
---|
8475 | 8562 | return texture!=null?texture.texture:null; |
---|
8476 | 8563 | } |
---|
8477 | 8564 | |
---|
8478 | | - 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 |
---|
8479 | 8566 | { |
---|
8480 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8567 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8481 | 8568 | |
---|
8482 | 8569 | return texture!=null?texture.texturedata:null; |
---|
8483 | 8570 | } |
---|
8484 | 8571 | |
---|
8485 | | - 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 |
---|
8486 | 8573 | { |
---|
8487 | 8574 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8488 | 8575 | { |
---|
8489 | 8576 | return false; |
---|
8490 | 8577 | } |
---|
8491 | 8578 | |
---|
8492 | | - boolean newtex = false; |
---|
| 8579 | + //boolean newtex = false; |
---|
8493 | 8580 | |
---|
8494 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
| 8581 | + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
8495 | 8582 | |
---|
8496 | 8583 | if (texture == null) |
---|
8497 | 8584 | return false; |
---|
.. | .. |
---|
8521 | 8608 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8522 | 8609 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8523 | 8610 | |
---|
8524 | | - return newtex; |
---|
| 8611 | + return true; // Warning: not used. |
---|
8525 | 8612 | } |
---|
8526 | 8613 | |
---|
8527 | 8614 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
9359 | 9446 | jy8[3] = 0.5f; |
---|
9360 | 9447 | } |
---|
9361 | 9448 | |
---|
9362 | | - 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 |
---|
9363 | 9450 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9364 | 9451 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9365 | 9452 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9366 | 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 | + |
---|
9367 | 9478 | static int imagecount = 0; // movie generation |
---|
9368 | 9479 | |
---|
9369 | 9480 | static int jitter = 0; |
---|
.. | .. |
---|
10474 | 10585 | ANTIALIAS = 0; |
---|
10475 | 10586 | //System.out.println("RESTART"); |
---|
10476 | 10587 | AAtimer.restart(); |
---|
| 10588 | + Globals.TIMERRUNNING = true; |
---|
10477 | 10589 | } |
---|
10478 | 10590 | } |
---|
10479 | 10591 | } |
---|
.. | .. |
---|
10541 | 10653 | ambientOcclusion = false; |
---|
10542 | 10654 | } |
---|
10543 | 10655 | |
---|
10544 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10656 | + if (//Globals.lighttouched && |
---|
| 10657 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10545 | 10658 | { |
---|
10546 | 10659 | //if (RENDERSHADOW) // ? |
---|
10547 | 10660 | if (!IsFrozen()) |
---|
.. | .. |
---|
10952 | 11065 | |
---|
10953 | 11066 | try |
---|
10954 | 11067 | { |
---|
10955 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11068 | + BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
10956 | 11069 | } |
---|
10957 | 11070 | catch (Exception e) |
---|
10958 | 11071 | { |
---|
.. | .. |
---|
10981 | 11094 | |
---|
10982 | 11095 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10983 | 11096 | |
---|
10984 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10985 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10986 | | -//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); |
---|
10987 | 11100 | } else |
---|
10988 | 11101 | { |
---|
10989 | 11102 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10994 | 11107 | //System.out.println("BLENDING ON"); |
---|
10995 | 11108 | gl.glEnable(GL.GL_BLEND); |
---|
10996 | 11109 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10997 | | - |
---|
| 11110 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10998 | 11111 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10999 | 11112 | gl.glLoadIdentity(); |
---|
11000 | 11113 | |
---|
.. | .. |
---|
11451 | 11564 | |
---|
11452 | 11565 | static boolean zoomonce = false; |
---|
11453 | 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 | + |
---|
11454 | 11585 | void DrawObject(GL gl, boolean draw) |
---|
11455 | 11586 | { |
---|
| 11587 | + // To clear camera values |
---|
| 11588 | + ResetOptions(); |
---|
| 11589 | + |
---|
11456 | 11590 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11457 | 11591 | // DrawMode() = SELECTION; |
---|
11458 | 11592 | //GL gl = getGL(); |
---|
11459 | 11593 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11460 | 11594 | { |
---|
11461 | 11595 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11462 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11596 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11463 | 11597 | pingthread.StepToTarget(true); // true); |
---|
11464 | 11598 | // zoomonce = false; |
---|
11465 | 11599 | } |
---|
.. | .. |
---|
11531 | 11665 | |
---|
11532 | 11666 | if (DrawMode() == DEFAULT) |
---|
11533 | 11667 | { |
---|
11534 | | - if (DEBUG) |
---|
| 11668 | + if (Globals.DEBUG) |
---|
11535 | 11669 | { |
---|
| 11670 | + CreateSelectedPoint(); |
---|
11536 | 11671 | float radius = 0.05f; |
---|
11537 | 11672 | if (selectedpoint.radius != radius) |
---|
11538 | 11673 | { |
---|
.. | .. |
---|
11595 | 11730 | if (tex.equals("WHITE_NOISE")) |
---|
11596 | 11731 | continue; |
---|
11597 | 11732 | |
---|
11598 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11733 | + if (!usedtextures.contains(tex)) |
---|
11599 | 11734 | { |
---|
11600 | 11735 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11601 | 11736 | textures.get(tex).texture.dispose(); |
---|
.. | .. |
---|
12019 | 12154 | for (int i = tp.size(); --i >= 0;) |
---|
12020 | 12155 | { |
---|
12021 | 12156 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12022 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12157 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12023 | 12158 | } |
---|
12024 | 12159 | |
---|
12025 | 12160 | |
---|
.. | .. |
---|
13289 | 13424 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13290 | 13425 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13291 | 13426 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13292 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13427 | + |
---|
| 13428 | + //Object3D.cVector2[] vector2buffer; |
---|
13293 | 13429 | |
---|
13294 | 13430 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13295 | 13431 | // OUT : diff, spec |
---|
.. | .. |
---|
13305 | 13441 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13306 | 13442 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13307 | 13443 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13308 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13309 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13310 | | - //"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 |
---|
13311 | 13448 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13312 | 13449 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13313 | 13450 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13812 | 13949 | else |
---|
13813 | 13950 | if (evt.getSource() == AAtimer) |
---|
13814 | 13951 | { |
---|
| 13952 | + Globals.TIMERRUNNING = false; |
---|
13815 | 13953 | if (mouseDown) |
---|
13816 | 13954 | { |
---|
13817 | 13955 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13871 | 14009 | |
---|
13872 | 14010 | // fev 2014??? |
---|
13873 | 14011 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13874 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14012 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13875 | 14013 | pingthread.StepToTarget(true); // true); |
---|
13876 | 14014 | } |
---|
13877 | 14015 | // if (!LIVE) |
---|
.. | .. |
---|
13886 | 14024 | return; |
---|
13887 | 14025 | |
---|
13888 | 14026 | AAtimer.restart(); // |
---|
| 14027 | + Globals.TIMERRUNNING = true; |
---|
13889 | 14028 | |
---|
13890 | 14029 | // waslive = LIVE; |
---|
13891 | 14030 | // LIVE = false; |
---|
.. | .. |
---|
14224 | 14363 | void GoDown(int mod) |
---|
14225 | 14364 | { |
---|
14226 | 14365 | MODIFIERS |= COMMAND; |
---|
14227 | | - /* |
---|
| 14366 | + /**/ |
---|
14228 | 14367 | if((mod&SHIFT) == SHIFT) |
---|
14229 | 14368 | manipCamera.RotatePosition(0, -speed); |
---|
14230 | 14369 | else |
---|
14231 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14232 | | - */ |
---|
| 14370 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14371 | + /**/ |
---|
14233 | 14372 | if ((mod & SHIFT) == SHIFT) |
---|
14234 | 14373 | { |
---|
14235 | 14374 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14245 | 14384 | void GoUp(int mod) |
---|
14246 | 14385 | { |
---|
14247 | 14386 | MODIFIERS |= COMMAND; |
---|
14248 | | - /* |
---|
| 14387 | + /**/ |
---|
14249 | 14388 | if((mod&SHIFT) == SHIFT) |
---|
14250 | 14389 | manipCamera.RotatePosition(0, speed); |
---|
14251 | 14390 | else |
---|
14252 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14253 | | - */ |
---|
| 14391 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14392 | + /**/ |
---|
14254 | 14393 | if ((mod & SHIFT) == SHIFT) |
---|
14255 | 14394 | { |
---|
14256 | 14395 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14266 | 14405 | void GoLeft(int mod) |
---|
14267 | 14406 | { |
---|
14268 | 14407 | MODIFIERS |= COMMAND; |
---|
14269 | | - /* |
---|
| 14408 | + /**/ |
---|
14270 | 14409 | if((mod&SHIFT) == SHIFT) |
---|
14271 | | - manipCamera.RotatePosition(speed, 0); |
---|
14272 | | - else |
---|
14273 | 14410 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14274 | | - */ |
---|
| 14411 | + else |
---|
| 14412 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14413 | + /**/ |
---|
14275 | 14414 | if ((mod & SHIFT) == SHIFT) |
---|
14276 | 14415 | { |
---|
14277 | 14416 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14287 | 14426 | void GoRight(int mod) |
---|
14288 | 14427 | { |
---|
14289 | 14428 | MODIFIERS |= COMMAND; |
---|
14290 | | - /* |
---|
| 14429 | + /**/ |
---|
14291 | 14430 | if((mod&SHIFT) == SHIFT) |
---|
14292 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14293 | | - else |
---|
14294 | 14431 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14295 | | - */ |
---|
| 14432 | + else |
---|
| 14433 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14434 | + /**/ |
---|
14296 | 14435 | if ((mod & SHIFT) == SHIFT) |
---|
14297 | 14436 | { |
---|
14298 | 14437 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14349 | 14488 | info.camera = renderCamera; |
---|
14350 | 14489 | info.x = x; |
---|
14351 | 14490 | info.y = y; |
---|
14352 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14491 | + object.GetWindow().copy |
---|
| 14492 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14353 | 14493 | } else |
---|
14354 | 14494 | { |
---|
14355 | 14495 | if (x < startX) |
---|
.. | .. |
---|
14513 | 14653 | ci.camera = renderCamera; |
---|
14514 | 14654 | if (!isRenderer) |
---|
14515 | 14655 | { |
---|
14516 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14656 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14657 | + //Object3D copy = editWindow.copy; |
---|
| 14658 | + if (object.doEditClick(ci, 0)) |
---|
14517 | 14659 | { |
---|
14518 | 14660 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14519 | 14661 | } else |
---|
.. | .. |
---|
14528 | 14670 | Globals.MOUSEDRAGGED = false; |
---|
14529 | 14671 | |
---|
14530 | 14672 | movingcamera = false; |
---|
14531 | | - X = Y = 0; |
---|
| 14673 | + X = 0; // getBounds().width/2; |
---|
| 14674 | + Y = 0; // getBounds().height/2; |
---|
14532 | 14675 | //System.out.println("mouseReleased: " + e); |
---|
14533 | 14676 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14534 | 14677 | } |
---|
.. | .. |
---|
14869 | 15012 | case 'E' : COMPACT ^= true; |
---|
14870 | 15013 | repaint(); |
---|
14871 | 15014 | break; |
---|
14872 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15015 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15016 | + //DEBUGHSB ^= true; |
---|
| 15017 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14873 | 15018 | repaint(); |
---|
14874 | 15019 | break; |
---|
14875 | 15020 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14894 | 15039 | RevertCamera(); |
---|
14895 | 15040 | repaint(); |
---|
14896 | 15041 | break; |
---|
14897 | | - case 'L': |
---|
14898 | 15042 | case 'l': |
---|
| 15043 | + //case 'L': |
---|
14899 | 15044 | if (lightMode) |
---|
14900 | 15045 | { |
---|
14901 | 15046 | lightMode = false; |
---|
.. | .. |
---|
15038 | 15183 | case '_': |
---|
15039 | 15184 | kompactbit = 5; |
---|
15040 | 15185 | break; |
---|
15041 | | - case '+': |
---|
15042 | | - kompactbit = 6; |
---|
15043 | | - break; |
---|
| 15186 | +// case '+': |
---|
| 15187 | +// kompactbit = 6; |
---|
| 15188 | +// break; |
---|
15044 | 15189 | case ' ': |
---|
15045 | 15190 | lightMode ^= true; |
---|
15046 | 15191 | Globals.lighttouched = true; |
---|
.. | .. |
---|
15052 | 15197 | case ESC: |
---|
15053 | 15198 | RENDERPROGRAM += 1; |
---|
15054 | 15199 | RENDERPROGRAM %= 3; |
---|
| 15200 | + |
---|
15055 | 15201 | repaint(); |
---|
15056 | 15202 | break; |
---|
15057 | 15203 | case 'Z': |
---|
.. | .. |
---|
15091 | 15237 | case DELETE: |
---|
15092 | 15238 | ClearSelection(); |
---|
15093 | 15239 | break; |
---|
15094 | | - /* |
---|
15095 | 15240 | case '+': |
---|
| 15241 | + |
---|
| 15242 | + /* |
---|
15096 | 15243 | //fontsize += 1; |
---|
15097 | 15244 | bbzoom *= 2; |
---|
15098 | 15245 | repaint(); |
---|
.. | .. |
---|
15109 | 15256 | case '=': |
---|
15110 | 15257 | IncDepth(); |
---|
15111 | 15258 | //fontsize += 1; |
---|
15112 | | - object.editWindow.refreshContents(true); |
---|
| 15259 | + object.GetWindow().refreshContents(true); |
---|
15113 | 15260 | maskbit = 6; |
---|
15114 | 15261 | break; |
---|
15115 | 15262 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15116 | 15263 | DecDepth(); |
---|
15117 | 15264 | maskbit = 5; |
---|
15118 | 15265 | //if(fontsize > 1) fontsize -= 1; |
---|
15119 | | - if (object.editWindow == null) |
---|
15120 | | - new Exception().printStackTrace(); |
---|
15121 | | - else |
---|
15122 | | - object.editWindow.refreshContents(true); |
---|
| 15266 | +// if (object.editWindow == null) |
---|
| 15267 | +// new Exception().printStackTrace(); |
---|
| 15268 | +// else |
---|
| 15269 | + object.GetWindow().refreshContents(true); |
---|
15123 | 15270 | break; |
---|
15124 | 15271 | case '{': |
---|
15125 | 15272 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15343 | 15490 | } |
---|
15344 | 15491 | */ |
---|
15345 | 15492 | |
---|
15346 | | - object.editWindow.EditSelection(); |
---|
| 15493 | + object.GetWindow().EditSelection(false); |
---|
15347 | 15494 | } |
---|
15348 | 15495 | |
---|
15349 | 15496 | void SelectParent() |
---|
.. | .. |
---|
15360 | 15507 | { |
---|
15361 | 15508 | //selectees.remove(i); |
---|
15362 | 15509 | System.out.println("select parent of " + elem); |
---|
15363 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15510 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15364 | 15511 | } else |
---|
15365 | 15512 | { |
---|
15366 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15513 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15367 | 15514 | } |
---|
15368 | 15515 | |
---|
15369 | 15516 | first = false; |
---|
.. | .. |
---|
15405 | 15552 | for (int j = 0; j < group.children.size(); j++) |
---|
15406 | 15553 | { |
---|
15407 | 15554 | elem = (Object3D) group.children.elementAt(j); |
---|
15408 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15555 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15409 | 15556 | first = false; |
---|
15410 | 15557 | } |
---|
15411 | 15558 | } else |
---|
15412 | 15559 | { |
---|
15413 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15560 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15414 | 15561 | } |
---|
15415 | 15562 | |
---|
15416 | 15563 | first = false; |
---|
.. | .. |
---|
15421 | 15568 | { |
---|
15422 | 15569 | //Composite group = (Composite) object; |
---|
15423 | 15570 | Object3D group = object; |
---|
15424 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15571 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15425 | 15572 | } |
---|
15426 | 15573 | |
---|
15427 | 15574 | void ResetTransform(int mask) |
---|
15428 | 15575 | { |
---|
15429 | 15576 | //Composite group = (Composite) object; |
---|
15430 | 15577 | Object3D group = object; |
---|
15431 | | - group.editWindow.ResetTransform(mask); |
---|
| 15578 | + group.GetWindow().ResetTransform(mask); |
---|
15432 | 15579 | } |
---|
15433 | 15580 | |
---|
15434 | 15581 | void FlipTransform() |
---|
15435 | 15582 | { |
---|
15436 | 15583 | //Composite group = (Composite) object; |
---|
15437 | 15584 | Object3D group = object; |
---|
15438 | | - group.editWindow.FlipTransform(); |
---|
| 15585 | + group.GetWindow().FlipTransform(); |
---|
15439 | 15586 | // group.editWindow.ReduceMesh(true); |
---|
15440 | 15587 | } |
---|
15441 | 15588 | |
---|
.. | .. |
---|
15443 | 15590 | { |
---|
15444 | 15591 | //Composite group = (Composite) object; |
---|
15445 | 15592 | Object3D group = object; |
---|
15446 | | - group.editWindow.PrintMemory(); |
---|
| 15593 | + group.GetWindow().PrintMemory(); |
---|
15447 | 15594 | // group.editWindow.ReduceMesh(true); |
---|
15448 | 15595 | } |
---|
15449 | 15596 | |
---|
.. | .. |
---|
15451 | 15598 | { |
---|
15452 | 15599 | //Composite group = (Composite) object; |
---|
15453 | 15600 | Object3D group = object; |
---|
15454 | | - group.editWindow.ResetCentroid(); |
---|
| 15601 | + group.GetWindow().ResetCentroid(); |
---|
15455 | 15602 | } |
---|
15456 | 15603 | |
---|
15457 | 15604 | void IncDepth() |
---|
.. | .. |
---|
15627 | 15774 | info.bounds.y += (height - desired) / 2; |
---|
15628 | 15775 | } |
---|
15629 | 15776 | } |
---|
| 15777 | + |
---|
15630 | 15778 | info.g = gr; |
---|
15631 | 15779 | info.camera = renderCamera; |
---|
15632 | 15780 | /* |
---|
.. | .. |
---|
15636 | 15784 | */ |
---|
15637 | 15785 | if (!isRenderer) |
---|
15638 | 15786 | { |
---|
15639 | | - object.drawEditHandles(info, 0); |
---|
15640 | | - |
---|
15641 | | - 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) |
---|
15642 | 15790 | { |
---|
15643 | | - 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) |
---|
15644 | 15797 | { |
---|
15645 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15646 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15647 | | - break; |
---|
15648 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15649 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15650 | | - break; |
---|
15651 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15652 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15653 | | - 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; |
---|
15654 | 15805 | } |
---|
15655 | | - |
---|
| 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 | + } |
---|
15656 | 15825 | } |
---|
15657 | 15826 | } |
---|
15658 | 15827 | } |
---|
.. | .. |
---|
16355 | 16524 | cStatic.objectstack[materialdepth++] = checker; |
---|
16356 | 16525 | //System.out.println("material " + material); |
---|
16357 | 16526 | //Applet3D.tracein(this, selected); |
---|
16358 | | - vector2buffer = checker.projectedVertices; |
---|
| 16527 | + //vector2buffer = checker.projectedVertices; |
---|
16359 | 16528 | |
---|
16360 | 16529 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16361 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16530 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16362 | 16531 | |
---|
16363 | 16532 | materialdepth -= 1; |
---|
16364 | 16533 | if (materialdepth > 0) |
---|
16365 | 16534 | { |
---|
16366 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16367 | | - 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); |
---|
16368 | 16537 | } |
---|
16369 | 16538 | //checker.GetMaterial().opacity = 1f; |
---|
16370 | 16539 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16450 | 16619 | } |
---|
16451 | 16620 | } |
---|
16452 | 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 | + |
---|
16453 | 16630 | class SelectBuffer implements GLEventListener |
---|
16454 | 16631 | { |
---|
16455 | 16632 | |
---|
.. | .. |
---|
16529 | 16706 | |
---|
16530 | 16707 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16531 | 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 | + |
---|
16532 | 16720 | //int tmp = selection_view; |
---|
16533 | 16721 | //selection_view = -1; |
---|
16534 | 16722 | int temp = DrawMode(); |
---|
.. | .. |
---|
16540 | 16728 | // temp = DEFAULT; // patch for selection debug |
---|
16541 | 16729 | Globals.drawMode = temp; // WARNING |
---|
16542 | 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 | + |
---|
16543 | 16742 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16544 | 16743 | |
---|
16545 | 16744 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16587 | 16786 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16588 | 16787 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16589 | 16788 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16789 | + |
---|
| 16790 | + CreateSelectedPoint(); |
---|
16590 | 16791 | |
---|
16591 | 16792 | // Will fit the mesh !!! |
---|
16592 | 16793 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16641 | 16842 | } |
---|
16642 | 16843 | |
---|
16643 | 16844 | if (!movingcamera && !PAINTMODE) |
---|
16644 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16845 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16645 | 16846 | |
---|
16646 | | - 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) |
---|
16647 | 16848 | { |
---|
16648 | | - 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); |
---|
16649 | 16850 | |
---|
16650 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16851 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16852 | + { |
---|
| 16853 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16651 | 16854 | |
---|
16652 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16653 | | - |
---|
16654 | | - group.add(paintobj); // link |
---|
16655 | | - |
---|
16656 | | - object.editWindow.SnapObject(group); |
---|
16657 | | - |
---|
16658 | | - Object3D folder = object.editWindow.copy; |
---|
16659 | | - |
---|
16660 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16661 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16662 | | - |
---|
16663 | | - folder.add(group); |
---|
16664 | | - |
---|
16665 | | - object.editWindow.ResetModel(); |
---|
16666 | | - 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 | + } |
---|
16667 | 16870 | } |
---|
16668 | 16871 | else |
---|
16669 | 16872 | paintcount = 0; |
---|
.. | .. |
---|
16702 | 16905 | //System.out.println("objects[color] = " + objects[color]); |
---|
16703 | 16906 | //objects[color].Select(); |
---|
16704 | 16907 | indexcount = 0; |
---|
| 16908 | + ObjEditor window = object.GetWindow(); |
---|
| 16909 | + if (window != null && deselect) |
---|
| 16910 | + { |
---|
| 16911 | + window.Select(null, deselect, true); |
---|
| 16912 | + } |
---|
16705 | 16913 | object.Select(color, deselect); |
---|
16706 | 16914 | } |
---|
16707 | 16915 | |
---|
.. | .. |
---|
17227 | 17435 | int AAbuffersize = 0; |
---|
17228 | 17436 | |
---|
17229 | 17437 | //double[] selectedpoint = new double[3]; |
---|
17230 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17438 | + static Superellipsoid selectedpoint; |
---|
17231 | 17439 | static Sphere previousselectedpoint = null; |
---|
17232 | | - static Sphere debugpointG = new Sphere(); |
---|
17233 | | - static Sphere debugpointP = new Sphere(); |
---|
17234 | | - static Sphere debugpointC = new Sphere(); |
---|
17235 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17440 | + static Sphere debugpointG; |
---|
| 17441 | + static Sphere debugpointP; |
---|
| 17442 | + static Sphere debugpointC; |
---|
| 17443 | + static Sphere debugpointR; |
---|
17236 | 17444 | |
---|
17237 | 17445 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17238 | 17446 | |
---|
17239 | | - static |
---|
17240 | | - { |
---|
17241 | | - for (int i=0; i<8; i++) |
---|
17242 | | - { |
---|
17243 | | - debugpoints[i] = new Sphere(); |
---|
17244 | | - } |
---|
17245 | | - } |
---|
17246 | | - |
---|
17247 | 17447 | static void InitPoints(float radius) |
---|
17248 | 17448 | { |
---|
17249 | 17449 | for (int i=0; i<8; i++) |
---|