.. | .. |
---|
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 |
---|
.. | .. |
---|
149 | 148 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 149 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 150 | } |
---|
| 151 | + |
---|
| 152 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 153 | |
---|
153 | 154 | void SetAsGLRenderer(boolean b) |
---|
154 | 155 | { |
---|
.. | .. |
---|
325 | 326 | cStatic.objectstack[materialdepth++] = obj; |
---|
326 | 327 | //System.out.println("material " + material); |
---|
327 | 328 | //Applet3D.tracein(this, selected); |
---|
328 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 329 | + //display.vector2buffer = obj.projectedVertices; |
---|
329 | 330 | if (obj instanceof Camera) |
---|
330 | 331 | { |
---|
331 | 332 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
334 | 335 | display.options1[2] = material.shadowbias; |
---|
335 | 336 | display.options1[3] = material.aniso; |
---|
336 | 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]); |
---|
337 | 343 | display.options2[0] = material.opacity; |
---|
338 | 344 | display.options2[1] = material.diffuse; |
---|
339 | 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]); |
---|
340 | 349 | |
---|
341 | 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]); |
---|
342 | 354 | display.options4[0] = material.cameralight/0.2f; |
---|
343 | 355 | display.options4[1] = material.subsurface; |
---|
344 | 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]); |
---|
345 | 360 | |
---|
346 | 361 | // if (display.CURRENTANTIALIAS > 0) |
---|
347 | 362 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
357 | 372 | /**/ |
---|
358 | 373 | } else |
---|
359 | 374 | { |
---|
360 | | - DrawMaterial(material, selected); |
---|
| 375 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
361 | 376 | } |
---|
362 | 377 | } else |
---|
363 | 378 | { |
---|
.. | .. |
---|
381 | 396 | cStatic.objectstack[materialdepth++] = obj; |
---|
382 | 397 | //System.out.println("material " + material); |
---|
383 | 398 | //Applet3D.tracein("selected ", selected); |
---|
384 | | - display.vector2buffer = obj.projectedVertices; |
---|
385 | | - display.DrawMaterial(material, selected); |
---|
| 399 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 400 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
386 | 401 | } |
---|
387 | 402 | } |
---|
388 | 403 | |
---|
.. | .. |
---|
399 | 414 | materialdepth -= 1; |
---|
400 | 415 | if (materialdepth > 0) |
---|
401 | 416 | { |
---|
402 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
403 | | - 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); |
---|
404 | 419 | } |
---|
405 | 420 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
406 | 421 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
420 | 435 | materialdepth -= 1; |
---|
421 | 436 | if (materialdepth > 0) |
---|
422 | 437 | { |
---|
423 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
424 | | - 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); |
---|
425 | 440 | } |
---|
426 | 441 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
427 | 442 | //else |
---|
.. | .. |
---|
462 | 477 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 478 | { |
---|
464 | 479 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - 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 | + ; |
---|
466 | 483 | if (!hasnorm) |
---|
467 | 484 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 485 | + // System.out.println("Mesh normal"); |
---|
469 | 486 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 487 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 488 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1207 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1208 | } |
---|
1192 | 1209 | } |
---|
| 1210 | + |
---|
1193 | 1211 | if (flipV) |
---|
1194 | 1212 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1213 | else |
---|
1196 | 1214 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1215 | + |
---|
1197 | 1216 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1217 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1218 | |
---|
.. | .. |
---|
1213 | 1232 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1233 | } |
---|
1215 | 1234 | } |
---|
| 1235 | + |
---|
1216 | 1236 | if (flipV) |
---|
1217 | 1237 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1238 | else |
---|
1219 | 1239 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1240 | + |
---|
1220 | 1241 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1242 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1243 | |
---|
.. | .. |
---|
1244 | 1265 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1266 | else |
---|
1246 | 1267 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1268 | + |
---|
1247 | 1269 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1270 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1271 | + |
---|
1249 | 1272 | count2 += 2; |
---|
1250 | 1273 | count3 += 3; |
---|
1251 | 1274 | } |
---|
.. | .. |
---|
1601 | 1624 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1602 | 1625 | } |
---|
1603 | 1626 | |
---|
1604 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1627 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1605 | 1628 | { |
---|
1606 | 1629 | CameraPane display = this; |
---|
1607 | 1630 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1628 | 1651 | |
---|
1629 | 1652 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1630 | 1653 | |
---|
1631 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1654 | + float[] colorV = Grafreed.colorV; |
---|
1632 | 1655 | |
---|
1633 | 1656 | /**/ |
---|
1634 | 1657 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1636 | 1659 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1637 | 1660 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1638 | 1661 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1639 | | - colorV[3] = material.opacity; |
---|
| 1662 | + colorV[3] = 1; // material.opacity; |
---|
1640 | 1663 | |
---|
1641 | 1664 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1642 | 1665 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1744 | 1767 | display.modelParams7[2] = 0; |
---|
1745 | 1768 | display.modelParams7[3] = 0; |
---|
1746 | 1769 | |
---|
1747 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1770 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1748 | 1771 | |
---|
1749 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1772 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1750 | 1773 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1751 | 1774 | { |
---|
1752 | 1775 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1888 | 1911 | void PushMatrix(double[][] matrix) |
---|
1889 | 1912 | { |
---|
1890 | 1913 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1914 | + PushMatrix(matrix, 1); |
---|
1892 | 1915 | } |
---|
1893 | 1916 | |
---|
1894 | 1917 | void PushMatrix() |
---|
.. | .. |
---|
2140 | 2163 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
2141 | 2164 | |
---|
2142 | 2165 | if (!Globals.isLIVE()) // save sound |
---|
2143 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2166 | + Grafreed.savesound = true; // wav.save(); |
---|
2144 | 2167 | // else |
---|
2145 | 2168 | repaint(); // start loop // may 2013 |
---|
2146 | 2169 | } |
---|
.. | .. |
---|
2257 | 2280 | |
---|
2258 | 2281 | void ToggleDebug() |
---|
2259 | 2282 | { |
---|
2260 | | - DEBUG ^= true; |
---|
| 2283 | + Globals.DEBUG ^= true; |
---|
2261 | 2284 | } |
---|
2262 | 2285 | |
---|
2263 | 2286 | void ToggleLookAt() |
---|
.. | .. |
---|
2265 | 2288 | LOOKAT ^= true; |
---|
2266 | 2289 | } |
---|
2267 | 2290 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2291 | + void ToggleSwitch() |
---|
2269 | 2292 | { |
---|
2270 | 2293 | SWITCH ^= true; |
---|
2271 | 2294 | } |
---|
.. | .. |
---|
2374 | 2397 | { |
---|
2375 | 2398 | return currentGL; |
---|
2376 | 2399 | } |
---|
2377 | | - |
---|
| 2400 | + |
---|
| 2401 | + private void GetRemoteZip(String url, String name, boolean unzip, boolean save) |
---|
| 2402 | + { |
---|
| 2403 | + java.net.URL u; |
---|
| 2404 | + InputStream is = null; |
---|
| 2405 | + DataInputStream dis; |
---|
| 2406 | + java.util.zip.ZipInputStream zis; |
---|
| 2407 | + //String s; |
---|
| 2408 | + |
---|
| 2409 | + System.out.println("GetRemoteZip " + name); |
---|
| 2410 | + |
---|
| 2411 | + int total = 0; // dis.available(); |
---|
| 2412 | + |
---|
| 2413 | + byte[] bytes = new byte[16384]; |
---|
| 2414 | + |
---|
| 2415 | + try |
---|
| 2416 | + { |
---|
| 2417 | + u = new java.net.URL(url + name); |
---|
| 2418 | + is = u.openStream(); |
---|
| 2419 | + |
---|
| 2420 | + System.out.println(url + name); |
---|
| 2421 | + |
---|
| 2422 | + if (unzip) |
---|
| 2423 | + { |
---|
| 2424 | + //dis = new DataInputStream(new BufferedInputStream(is)); |
---|
| 2425 | + zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is)); |
---|
| 2426 | + //while ((s = dis.readLine()) != null) |
---|
| 2427 | + |
---|
| 2428 | + if (save) |
---|
| 2429 | + new java.io.File(name).mkdirs(); |
---|
| 2430 | + |
---|
| 2431 | + // FileOutputStream stream = new FileOutputStream("test.zip"); |
---|
| 2432 | + // |
---|
| 2433 | + // int count; |
---|
| 2434 | + // |
---|
| 2435 | + // while ((count = dis.read(bytes)) != -1) |
---|
| 2436 | + // { |
---|
| 2437 | + // //System.out.println(s); |
---|
| 2438 | + // System.out.println(count); |
---|
| 2439 | + // total += count; |
---|
| 2440 | + // stream.write(bytes); |
---|
| 2441 | + // } |
---|
| 2442 | + // |
---|
| 2443 | + // stream.close(); |
---|
| 2444 | + |
---|
| 2445 | + // now iterate through each item in the stream. The get next |
---|
| 2446 | + // entry call will return a ZipEntry for each file in the |
---|
| 2447 | + // stream |
---|
| 2448 | + java.util.zip.ZipEntry entry; |
---|
| 2449 | + while((entry = zis.getNextEntry())!=null) |
---|
| 2450 | + { |
---|
| 2451 | + if (entry.getName().endsWith(".gsm")) |
---|
| 2452 | + { |
---|
| 2453 | + continue; |
---|
| 2454 | + } |
---|
| 2455 | + |
---|
| 2456 | + String s = String.format("Entry: %s len %d added %TD", |
---|
| 2457 | + entry.getName(), entry.getSize(), |
---|
| 2458 | + new java.util.Date(entry.getTime())); |
---|
| 2459 | + System.out.println(s); |
---|
| 2460 | + |
---|
| 2461 | + if (save) |
---|
| 2462 | + { |
---|
| 2463 | + // Once we get the entry from the stream, the stream is |
---|
| 2464 | + // positioned read to read the raw data, and we keep |
---|
| 2465 | + // reading until read returns 0 or less. |
---|
| 2466 | + String outpath = name + "/" + entry.getName(); |
---|
| 2467 | + FileOutputStream output = null; |
---|
| 2468 | + try |
---|
| 2469 | + { |
---|
| 2470 | + output = new FileOutputStream(outpath); |
---|
| 2471 | + int len = 0; |
---|
| 2472 | + while ((len = zis.read(bytes)) > 0) |
---|
| 2473 | + { |
---|
| 2474 | + output.write(bytes, 0, len); |
---|
| 2475 | + } |
---|
| 2476 | + } |
---|
| 2477 | + finally |
---|
| 2478 | + { |
---|
| 2479 | + // we must always close the output file |
---|
| 2480 | + if(output!=null) output.close(); |
---|
| 2481 | + } |
---|
| 2482 | + } |
---|
| 2483 | + } |
---|
| 2484 | + } |
---|
| 2485 | + } |
---|
| 2486 | + catch (java.net.MalformedURLException mue) |
---|
| 2487 | + { |
---|
| 2488 | + System.err.println("Ouch - a MalformedURLException happened."); |
---|
| 2489 | + mue.printStackTrace(); |
---|
| 2490 | + //System.exit(2); |
---|
| 2491 | + } |
---|
| 2492 | + catch (IOException ioe) |
---|
| 2493 | + { |
---|
| 2494 | + //System.err.println("Oops - an IOException happened."); |
---|
| 2495 | + //ioe.printStackTrace(); |
---|
| 2496 | + //System.exit(3); |
---|
| 2497 | + } |
---|
| 2498 | + finally |
---|
| 2499 | + { |
---|
| 2500 | + try |
---|
| 2501 | + { |
---|
| 2502 | + if (is != null) |
---|
| 2503 | + is.close(); |
---|
| 2504 | + } |
---|
| 2505 | + catch (IOException ioe) |
---|
| 2506 | + { |
---|
| 2507 | + } |
---|
| 2508 | + } |
---|
| 2509 | + |
---|
| 2510 | + // System.out.println("length = " + total); |
---|
| 2511 | + |
---|
| 2512 | +// try |
---|
| 2513 | +// { |
---|
| 2514 | +// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); |
---|
| 2515 | +// } |
---|
| 2516 | +// catch (Exception e) |
---|
| 2517 | +// { |
---|
| 2518 | +// e.printStackTrace(); |
---|
| 2519 | +// } |
---|
| 2520 | + |
---|
| 2521 | + } |
---|
| 2522 | + |
---|
2378 | 2523 | /**/ |
---|
2379 | 2524 | class CacheTexture |
---|
2380 | 2525 | { |
---|
.. | .. |
---|
7919 | 8064 | ReleaseTexture(pigment, false); |
---|
7920 | 8065 | } |
---|
7921 | 8066 | |
---|
| 8067 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8068 | + { |
---|
| 8069 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8070 | + { |
---|
| 8071 | + return; |
---|
| 8072 | + } |
---|
| 8073 | + |
---|
| 8074 | + if (tex == null) |
---|
| 8075 | + { |
---|
| 8076 | + ReleaseTexture(null, false); |
---|
| 8077 | + return; |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8081 | + |
---|
| 8082 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8083 | + { |
---|
| 8084 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8085 | + // System.out.println("; bump = " + bump); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + if (pigment.equals("")) |
---|
| 8089 | + { |
---|
| 8090 | + pigment = null; |
---|
| 8091 | + } |
---|
| 8092 | + |
---|
| 8093 | + ReleaseTexture(pigment, false); |
---|
| 8094 | + } |
---|
| 8095 | + |
---|
| 8096 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8097 | + { |
---|
| 8098 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8099 | + { |
---|
| 8100 | + return; |
---|
| 8101 | + } |
---|
| 8102 | + |
---|
| 8103 | + if (tex == null) |
---|
| 8104 | + { |
---|
| 8105 | + ReleaseTexture(null, true); |
---|
| 8106 | + return; |
---|
| 8107 | + } |
---|
| 8108 | + |
---|
| 8109 | + String bump = Object3D.GetBump(tex); |
---|
| 8110 | + |
---|
| 8111 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8112 | + { |
---|
| 8113 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8114 | + // System.out.println("; bump = " + bump); |
---|
| 8115 | + } |
---|
| 8116 | + |
---|
| 8117 | + if (bump.equals("")) |
---|
| 8118 | + { |
---|
| 8119 | + bump = null; |
---|
| 8120 | + } |
---|
| 8121 | + |
---|
| 8122 | + ReleaseTexture(bump, true); |
---|
| 8123 | + } |
---|
| 8124 | + |
---|
7922 | 8125 | void ReleaseTexture(String tex, boolean bump) |
---|
7923 | 8126 | { |
---|
7924 | 8127 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
.. | .. |
---|
8022 | 8225 | } |
---|
8023 | 8226 | } |
---|
8024 | 8227 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8228 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8229 | { |
---|
8027 | 8230 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8231 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8067 | 8270 | return; // true; |
---|
8068 | 8271 | } |
---|
8069 | 8272 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8273 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8274 | + { |
---|
| 8275 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8276 | + ambientOcclusion ) // || !textureon) |
---|
| 8277 | + { |
---|
| 8278 | + return; // false; |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + if (tex == null) |
---|
| 8282 | + { |
---|
| 8283 | + BindTexture(null,false,resolution); |
---|
| 8284 | + return; |
---|
| 8285 | + } |
---|
| 8286 | + |
---|
| 8287 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8288 | + |
---|
| 8289 | + usedtextures.put(pigment, pigment); |
---|
| 8290 | + |
---|
| 8291 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8292 | + { |
---|
| 8293 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8294 | + // System.out.println("; bump = " + bump); |
---|
| 8295 | + } |
---|
| 8296 | + |
---|
| 8297 | + if (pigment.equals("")) |
---|
| 8298 | + { |
---|
| 8299 | + pigment = null; |
---|
| 8300 | + } |
---|
| 8301 | + |
---|
| 8302 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8303 | + BindTexture(pigment, false, resolution); |
---|
| 8304 | + } |
---|
| 8305 | + |
---|
| 8306 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8307 | + { |
---|
| 8308 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8309 | + ambientOcclusion ) // || !textureon) |
---|
| 8310 | + { |
---|
| 8311 | + return; // false; |
---|
| 8312 | + } |
---|
| 8313 | + |
---|
| 8314 | + if (tex == null) |
---|
| 8315 | + { |
---|
| 8316 | + BindTexture(null,true,resolution); |
---|
| 8317 | + return; |
---|
| 8318 | + } |
---|
| 8319 | + |
---|
| 8320 | + String bump = Object3D.GetBump(tex); |
---|
| 8321 | + |
---|
| 8322 | + usedtextures.put(bump, bump); |
---|
| 8323 | + |
---|
| 8324 | + if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8325 | + { |
---|
| 8326 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8327 | + // System.out.println("; bump = " + bump); |
---|
| 8328 | + } |
---|
| 8329 | + |
---|
| 8330 | + if (bump.equals("")) |
---|
| 8331 | + { |
---|
| 8332 | + bump = null; |
---|
| 8333 | + } |
---|
| 8334 | + |
---|
| 8335 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8336 | + BindTexture(bump, true, resolution); |
---|
| 8337 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8341 | + |
---|
| 8342 | + private boolean FileExists(String tex) |
---|
| 8343 | + { |
---|
| 8344 | + if (missingTextures.contains(tex)) |
---|
| 8345 | + { |
---|
| 8346 | + return false; |
---|
| 8347 | + } |
---|
| 8348 | + |
---|
| 8349 | + boolean fileExists = new File(tex).exists(); |
---|
| 8350 | + |
---|
| 8351 | + if (!fileExists) |
---|
| 8352 | + { |
---|
| 8353 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8354 | + missingTextures.add(tex); |
---|
| 8355 | + } |
---|
| 8356 | + |
---|
| 8357 | + return fileExists; |
---|
| 8358 | + } |
---|
| 8359 | + |
---|
| 8360 | + CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8071 | 8361 | { |
---|
8072 | 8362 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8073 | 8363 | |
---|
.. | .. |
---|
8075 | 8365 | { |
---|
8076 | 8366 | String texname = tex; |
---|
8077 | 8367 | |
---|
| 8368 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8369 | + |
---|
8078 | 8370 | // String[] split = tex.split("Textures"); |
---|
8079 | 8371 | // if (split.length > 1) |
---|
8080 | 8372 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8373 | // else |
---|
8082 | 8374 | // if (!texname.startsWith("/")) |
---|
8083 | 8375 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8376 | + if (!FileExists(tex)) |
---|
8085 | 8377 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8378 | + texname = fallbackTextureName; |
---|
8087 | 8379 | } |
---|
8088 | 8380 | |
---|
8089 | 8381 | if (CACHETEXTURE) |
---|
.. | .. |
---|
8153 | 8445 | } |
---|
8154 | 8446 | |
---|
8155 | 8447 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8448 | + if (!FileExists(cachename)) |
---|
8157 | 8449 | cachename = texname; |
---|
8158 | 8450 | else |
---|
8159 | 8451 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8467 | } |
---|
8176 | 8468 | |
---|
8177 | 8469 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8470 | + if (!FileExists(cachename)) |
---|
8179 | 8471 | cachename = texname; |
---|
8180 | 8472 | else |
---|
8181 | 8473 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8184 | 8476 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8477 | |
---|
8186 | 8478 | |
---|
8187 | | - if (texturedata != null) |
---|
| 8479 | + if (texturedata == null) |
---|
| 8480 | + throw new Exception(); |
---|
| 8481 | + |
---|
8188 | 8482 | texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8189 | 8483 | //texture = GetTexture(tex, bump); |
---|
8190 | 8484 | } |
---|
.. | .. |
---|
8306 | 8600 | return texture; |
---|
8307 | 8601 | } |
---|
8308 | 8602 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8603 | + com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8604 | { |
---|
8311 | 8605 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8606 | |
---|
.. | .. |
---|
8324 | 8618 | return texture!=null?texture.texture:null; |
---|
8325 | 8619 | } |
---|
8326 | 8620 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8621 | + public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8622 | { |
---|
8329 | 8623 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8624 | |
---|
8331 | 8625 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8626 | } |
---|
8333 | 8627 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8628 | + boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8629 | { |
---|
8336 | 8630 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8631 | { |
---|
.. | .. |
---|
9208 | 9502 | jy8[3] = 0.5f; |
---|
9209 | 9503 | } |
---|
9210 | 9504 | |
---|
9211 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9505 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9212 | 9506 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9213 | 9507 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9214 | 9508 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9215 | 9509 | |
---|
| 9510 | + void ResetOptions() |
---|
| 9511 | + { |
---|
| 9512 | + options1[0] = 100; |
---|
| 9513 | + options1[1] = 0.025f; |
---|
| 9514 | + options1[2] = 0.01f; |
---|
| 9515 | + options1[3] = 0; |
---|
| 9516 | + options1[4] = 0; |
---|
| 9517 | + |
---|
| 9518 | + options2[0] = 0; |
---|
| 9519 | + options2[1] = 0.75f; |
---|
| 9520 | + options2[2] = 0; |
---|
| 9521 | + options2[3] = 0; |
---|
| 9522 | + |
---|
| 9523 | + options3[0] = 1; |
---|
| 9524 | + options3[1] = 1; |
---|
| 9525 | + options3[2] = 1; |
---|
| 9526 | + options3[3] = 0; |
---|
| 9527 | + |
---|
| 9528 | + options4[0] = 1; |
---|
| 9529 | + options4[1] = 0; |
---|
| 9530 | + options4[2] = 1; |
---|
| 9531 | + options4[3] = 0; |
---|
| 9532 | + } |
---|
| 9533 | + |
---|
9216 | 9534 | static int imagecount = 0; // movie generation |
---|
9217 | 9535 | |
---|
9218 | 9536 | static int jitter = 0; |
---|
.. | .. |
---|
9308 | 9626 | assert (parentcam != renderCamera); |
---|
9309 | 9627 | |
---|
9310 | 9628 | if (renderCamera != lightCamera) |
---|
9311 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9312 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9629 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9630 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9313 | 9631 | |
---|
9314 | 9632 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9315 | 9633 | |
---|
.. | .. |
---|
9324 | 9642 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9325 | 9643 | |
---|
9326 | 9644 | if (renderCamera != lightCamera) |
---|
9327 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9328 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9645 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9646 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9329 | 9647 | |
---|
9330 | 9648 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9331 | 9649 | |
---|
.. | .. |
---|
9542 | 9860 | |
---|
9543 | 9861 | if (!BOXMODE) |
---|
9544 | 9862 | { |
---|
9545 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9863 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9546 | 9864 | } |
---|
9547 | 9865 | |
---|
9548 | 9866 | if (!BOXMODE) |
---|
.. | .. |
---|
9580 | 9898 | ABORTED = false; |
---|
9581 | 9899 | } |
---|
9582 | 9900 | else |
---|
9583 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9901 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9584 | 9902 | |
---|
9585 | 9903 | if (false) |
---|
9586 | 9904 | { |
---|
.. | .. |
---|
10243 | 10561 | |
---|
10244 | 10562 | public void display(GLAutoDrawable drawable) |
---|
10245 | 10563 | { |
---|
10246 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10564 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
10247 | 10565 | { |
---|
10248 | | - GrafreeD.wav.save(); |
---|
10249 | | - GrafreeD.savesound = false; |
---|
10250 | | - GrafreeD.hassound = false; |
---|
| 10566 | + Grafreed.wav.save(); |
---|
| 10567 | + Grafreed.savesound = false; |
---|
| 10568 | + Grafreed.hassound = false; |
---|
10251 | 10569 | } |
---|
10252 | 10570 | // if (DEBUG_SELECTION) |
---|
10253 | 10571 | // { |
---|
.. | .. |
---|
10323 | 10641 | ANTIALIAS = 0; |
---|
10324 | 10642 | //System.out.println("RESTART"); |
---|
10325 | 10643 | AAtimer.restart(); |
---|
| 10644 | + Globals.TIMERRUNNING = true; |
---|
10326 | 10645 | } |
---|
10327 | 10646 | } |
---|
10328 | 10647 | } |
---|
.. | .. |
---|
10377 | 10696 | Object3D theobject = object; |
---|
10378 | 10697 | Object3D theparent = object.parent; |
---|
10379 | 10698 | object.parent = null; |
---|
10380 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10699 | + object = (Object3D)Grafreed.clone(object); |
---|
10381 | 10700 | object.Stripify(); |
---|
10382 | 10701 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10383 | 10702 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10390 | 10709 | ambientOcclusion = false; |
---|
10391 | 10710 | } |
---|
10392 | 10711 | |
---|
10393 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10712 | + if (//Globals.lighttouched && |
---|
| 10713 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10394 | 10714 | { |
---|
10395 | 10715 | //if (RENDERSHADOW) // ? |
---|
10396 | 10716 | if (!IsFrozen()) |
---|
10397 | 10717 | { |
---|
10398 | 10718 | // dec 2012 |
---|
10399 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10719 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10400 | 10720 | { |
---|
10401 | 10721 | Globals.framecount++; |
---|
10402 | 10722 | shadowbuffer.display(); |
---|
.. | .. |
---|
10523 | 10843 | |
---|
10524 | 10844 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10845 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10846 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10847 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10528 | 10848 | |
---|
10529 | 10849 | for (int j = 0; j < 4; j++) |
---|
10530 | 10850 | { |
---|
.. | .. |
---|
10538 | 10858 | |
---|
10539 | 10859 | // if (parentcam != renderCamera) // not a light |
---|
10540 | 10860 | if (cam != lightCamera) |
---|
10541 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10542 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10861 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10862 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10543 | 10863 | |
---|
10544 | 10864 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10545 | 10865 | |
---|
.. | .. |
---|
10798 | 11118 | // Bump noise |
---|
10799 | 11119 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 11120 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11121 | + |
---|
| 11122 | + try |
---|
| 11123 | + { |
---|
| 11124 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11125 | + } |
---|
| 11126 | + catch (Exception e) |
---|
| 11127 | + { |
---|
| 11128 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11129 | + } |
---|
| 11130 | + |
---|
10802 | 11131 | |
---|
10803 | 11132 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 11133 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10923 | 11252 | System.err.println("parentcam != renderCamera"); |
---|
10924 | 11253 | |
---|
10925 | 11254 | // if (cam != lightCamera) |
---|
10926 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10927 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11255 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11256 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10928 | 11257 | } |
---|
10929 | 11258 | |
---|
10930 | 11259 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10945 | 11274 | if (true) // TODO |
---|
10946 | 11275 | { |
---|
10947 | 11276 | if (cam != lightCamera) |
---|
10948 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10949 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11277 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11278 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10950 | 11279 | } |
---|
10951 | 11280 | |
---|
10952 | 11281 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11283 | 11612 | e.printStackTrace(); |
---|
11284 | 11613 | } |
---|
11285 | 11614 | |
---|
11286 | | - if (GrafreeD.RENDERME > 0) |
---|
11287 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11615 | + if (Grafreed.RENDERME > 0) |
---|
| 11616 | + Grafreed.RENDERME--; // mechante magouille |
---|
11288 | 11617 | |
---|
11289 | 11618 | Globals.ONESTEP = false; |
---|
11290 | 11619 | } |
---|
11291 | 11620 | |
---|
11292 | 11621 | static boolean zoomonce = false; |
---|
11293 | 11622 | |
---|
| 11623 | + static void CreateSelectedPoint() |
---|
| 11624 | + { |
---|
| 11625 | + if (selectedpoint == null) |
---|
| 11626 | + { |
---|
| 11627 | + debugpointG = new Sphere(); |
---|
| 11628 | + debugpointP = new Sphere(); |
---|
| 11629 | + debugpointC = new Sphere(); |
---|
| 11630 | + debugpointR = new Sphere(); |
---|
| 11631 | + |
---|
| 11632 | + selectedpoint = new Superellipsoid(); |
---|
| 11633 | + |
---|
| 11634 | + for (int i=0; i<8; i++) |
---|
| 11635 | + { |
---|
| 11636 | + debugpoints[i] = new Sphere(); |
---|
| 11637 | + } |
---|
| 11638 | + } |
---|
| 11639 | + } |
---|
| 11640 | + |
---|
11294 | 11641 | void DrawObject(GL gl, boolean draw) |
---|
11295 | 11642 | { |
---|
| 11643 | + // To clear camera values |
---|
| 11644 | + ResetOptions(); |
---|
| 11645 | + |
---|
11296 | 11646 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11297 | 11647 | // DrawMode() = SELECTION; |
---|
11298 | 11648 | //GL gl = getGL(); |
---|
.. | .. |
---|
11354 | 11704 | |
---|
11355 | 11705 | usedtextures.clear(); |
---|
11356 | 11706 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11707 | + try |
---|
| 11708 | + { |
---|
| 11709 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11710 | + } |
---|
| 11711 | + catch (Exception e) |
---|
| 11712 | + { |
---|
| 11713 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11714 | + } |
---|
11358 | 11715 | } |
---|
11359 | 11716 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11717 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11364 | 11721 | |
---|
11365 | 11722 | if (DrawMode() == DEFAULT) |
---|
11366 | 11723 | { |
---|
11367 | | - if (DEBUG) |
---|
| 11724 | + if (Globals.DEBUG) |
---|
11368 | 11725 | { |
---|
| 11726 | + CreateSelectedPoint(); |
---|
11369 | 11727 | float radius = 0.05f; |
---|
11370 | 11728 | if (selectedpoint.radius != radius) |
---|
11371 | 11729 | { |
---|
.. | .. |
---|
11445 | 11803 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11804 | { |
---|
11447 | 11805 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11806 | + try |
---|
| 11807 | + { |
---|
| 11808 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11809 | + } |
---|
| 11810 | + catch (Exception e) |
---|
| 11811 | + { |
---|
| 11812 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11813 | + } |
---|
11449 | 11814 | // NEAREST |
---|
11450 | 11815 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11816 | DrawChecker(gl); |
---|
.. | .. |
---|
11527 | 11892 | return; |
---|
11528 | 11893 | } |
---|
11529 | 11894 | |
---|
11530 | | - String string = obj.GetToolTip(); |
---|
| 11895 | + String string = obj.toString(); //.GetToolTip(); |
---|
11531 | 11896 | |
---|
11532 | 11897 | GL gl = GetGL(); |
---|
11533 | 11898 | |
---|
.. | .. |
---|
11844 | 12209 | //obj.TransformToWorld(light, light); |
---|
11845 | 12210 | for (int i = tp.size(); --i >= 0;) |
---|
11846 | 12211 | { |
---|
11847 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11848 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12212 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12213 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11849 | 12214 | } |
---|
11850 | 12215 | |
---|
11851 | 12216 | |
---|
.. | .. |
---|
11862 | 12227 | parentcam = cameras[0]; |
---|
11863 | 12228 | } |
---|
11864 | 12229 | |
---|
11865 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11866 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12230 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12231 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11867 | 12232 | |
---|
11868 | 12233 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11869 | 12234 | |
---|
.. | .. |
---|
12477 | 12842 | |
---|
12478 | 12843 | // display shadow only (bump == 0) |
---|
12479 | 12844 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12845 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12846 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12482 | 12847 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 12848 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 12849 | "KIL temp.x;" + |
---|
.. | .. |
---|
12758 | 13123 | "MUL final.y, fragment.texcoord[0].x, c256;" + |
---|
12759 | 13124 | "FLR final.x, final.y;" + |
---|
12760 | 13125 | "SUB final.y, final.y, final.x;" + |
---|
12761 | | - //"MUL final.x, final.x, c256i;" + |
---|
| 13126 | + "MUL final.x, final.x, c256i;" + |
---|
12762 | 13127 | "MOV final.z, zero.x;" + |
---|
12763 | 13128 | "MOV final.a, one.w;":"" |
---|
12764 | 13129 | ) + |
---|
.. | .. |
---|
12766 | 13131 | "MUL final.y, fragment.texcoord[0].y, c256;" + |
---|
12767 | 13132 | "FLR final.x, final.y;" + |
---|
12768 | 13133 | "SUB final.y, final.y, final.x;" + |
---|
12769 | | - //"MUL final.x, final.x, c256i;" + |
---|
| 13134 | + "MUL final.x, final.x, c256i;" + |
---|
12770 | 13135 | "MOV final.z, zero.x;" + |
---|
12771 | 13136 | "MOV final.a, one.w;":"" |
---|
12772 | 13137 | ) + |
---|
.. | .. |
---|
12809 | 13174 | //once = true; |
---|
12810 | 13175 | } |
---|
12811 | 13176 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13177 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 13178 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 13179 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 13180 | |
---|
.. | .. |
---|
12942 | 13307 | |
---|
12943 | 13308 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 13309 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13310 | + |
---|
| 13311 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 13312 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 13313 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13314 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13315 | + |
---|
| 13316 | + // Reverse comparison |
---|
12948 | 13317 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 13318 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13319 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 13320 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 13321 | |
---|
12953 | 13322 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 13330 | // No shadow for backface |
---|
12962 | 13331 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 13332 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13333 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13334 | + |
---|
| 13335 | + // No shadow when out of frustrum |
---|
| 13336 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 13337 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 13338 | ""; |
---|
12966 | 13339 | } |
---|
.. | .. |
---|
13107 | 13480 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13108 | 13481 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13109 | 13482 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13110 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13483 | + |
---|
| 13484 | + //Object3D.cVector2[] vector2buffer; |
---|
13111 | 13485 | |
---|
13112 | 13486 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13113 | 13487 | // OUT : diff, spec |
---|
.. | .. |
---|
13123 | 13497 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13124 | 13498 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13125 | 13499 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13126 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13127 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13128 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13500 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13501 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13502 | + |
---|
| 13503 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13129 | 13504 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13130 | 13505 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13131 | 13506 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13519 | 13894 | public void mousePressed(MouseEvent e) |
---|
13520 | 13895 | { |
---|
13521 | 13896 | //System.out.println("mousePressed: " + e); |
---|
13522 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13897 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13523 | 13898 | } |
---|
13524 | 13899 | |
---|
13525 | 13900 | static long prevtime = 0; |
---|
.. | .. |
---|
13595 | 13970 | // mode |= META; |
---|
13596 | 13971 | //} |
---|
13597 | 13972 | |
---|
13598 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13599 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13973 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13974 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13600 | 13975 | anchorX = ax; |
---|
13601 | 13976 | anchorY = ay; |
---|
13602 | 13977 | prevX = px; |
---|
.. | .. |
---|
13630 | 14005 | else |
---|
13631 | 14006 | if (evt.getSource() == AAtimer) |
---|
13632 | 14007 | { |
---|
| 14008 | + Globals.TIMERRUNNING = false; |
---|
13633 | 14009 | if (mouseDown) |
---|
13634 | 14010 | { |
---|
13635 | 14011 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13655 | 14031 | // LIVE = waslive; |
---|
13656 | 14032 | // wasliveok = true; |
---|
13657 | 14033 | // waslive = false; |
---|
| 14034 | + |
---|
| 14035 | + // May 2019 Forget it: |
---|
| 14036 | + if (true) |
---|
| 14037 | + return; |
---|
13658 | 14038 | |
---|
13659 | 14039 | // source == timer |
---|
13660 | 14040 | if (mouseDown) |
---|
.. | .. |
---|
13694 | 14074 | |
---|
13695 | 14075 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13696 | 14076 | |
---|
13697 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14077 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13698 | 14078 | { |
---|
13699 | 14079 | if (!wasliveok) |
---|
13700 | 14080 | return; |
---|
13701 | 14081 | |
---|
13702 | 14082 | AAtimer.restart(); // |
---|
| 14083 | + Globals.TIMERRUNNING = true; |
---|
13703 | 14084 | |
---|
13704 | 14085 | // waslive = LIVE; |
---|
13705 | 14086 | // LIVE = false; |
---|
.. | .. |
---|
13711 | 14092 | // touched = true; // main DL |
---|
13712 | 14093 | if (isRenderer) |
---|
13713 | 14094 | { |
---|
13714 | | - SetMouseMode(modifiers); |
---|
| 14095 | + SetMouseMode(modifiers, modifiersex); |
---|
13715 | 14096 | } |
---|
13716 | 14097 | |
---|
13717 | 14098 | selectX = anchorX = x; |
---|
.. | .. |
---|
13724 | 14105 | clicked = true; |
---|
13725 | 14106 | hold = false; |
---|
13726 | 14107 | |
---|
13727 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14108 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13728 | 14109 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13729 | 14110 | { |
---|
13730 | 14111 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13755 | 14136 | info.camera = renderCamera; |
---|
13756 | 14137 | info.x = x; |
---|
13757 | 14138 | info.y = y; |
---|
13758 | | - info.modifiers = modifiers; |
---|
| 14139 | + info.modifiers = modifiersex; |
---|
13759 | 14140 | editObj = object.doEditClick(info, 0); |
---|
13760 | 14141 | if (!editObj) |
---|
13761 | 14142 | { |
---|
.. | .. |
---|
13772 | 14153 | |
---|
13773 | 14154 | public void mouseDragged(MouseEvent e) |
---|
13774 | 14155 | { |
---|
| 14156 | + Globals.MOUSEDRAGGED = true; |
---|
| 14157 | + |
---|
13775 | 14158 | //System.out.println("mouseDragged: " + e); |
---|
13776 | 14159 | if (isRenderer) |
---|
13777 | 14160 | movingcamera = true; |
---|
| 14161 | + |
---|
13778 | 14162 | //if (drawing) |
---|
13779 | 14163 | //return; |
---|
13780 | 14164 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
13784 | 14168 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13785 | 14169 | } |
---|
13786 | 14170 | else |
---|
13787 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14171 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13788 | 14172 | |
---|
13789 | 14173 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13790 | 14174 | } |
---|
.. | .. |
---|
14021 | 14405 | { |
---|
14022 | 14406 | Globals.lighttouched = true; |
---|
14023 | 14407 | } |
---|
14024 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14408 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
14025 | 14409 | } |
---|
14026 | 14410 | //else |
---|
14027 | 14411 | } |
---|
.. | .. |
---|
14121 | 14505 | int X, Y; |
---|
14122 | 14506 | boolean SX, SY; |
---|
14123 | 14507 | |
---|
14124 | | - void drag(int x, int y, int modifiers) |
---|
| 14508 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
14125 | 14509 | { |
---|
14126 | 14510 | if (IsFrozen()) |
---|
14127 | 14511 | { |
---|
.. | .. |
---|
14130 | 14514 | |
---|
14131 | 14515 | drag = true; // NEW |
---|
14132 | 14516 | |
---|
14133 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14517 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
14134 | 14518 | |
---|
14135 | 14519 | X = x; |
---|
14136 | 14520 | Y = y; |
---|
14137 | 14521 | // floating state for animation |
---|
14138 | | - MODIFIERS = modifiers; |
---|
14139 | | - modifiers &= ~1024; |
---|
| 14522 | + MODIFIERS = modifiersex; |
---|
| 14523 | + modifiersex &= ~1024; |
---|
14140 | 14524 | if (false) // modifiers != 0) |
---|
14141 | 14525 | { |
---|
14142 | 14526 | //new Exception().printStackTrace(); |
---|
14143 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14527 | + System.out.println("mouseDragged: " + modifiersex); |
---|
14144 | 14528 | System.out.println("SHIFT = " + SHIFT); |
---|
14145 | 14529 | System.out.println("CONTROL = " + COMMAND); |
---|
14146 | 14530 | System.out.println("META = " + META); |
---|
.. | .. |
---|
14160 | 14544 | info.camera = renderCamera; |
---|
14161 | 14545 | info.x = x; |
---|
14162 | 14546 | info.y = y; |
---|
14163 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14547 | + object.GetWindow().copy |
---|
| 14548 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14164 | 14549 | } else |
---|
14165 | 14550 | { |
---|
14166 | 14551 | if (x < startX) |
---|
.. | .. |
---|
14324 | 14709 | ci.camera = renderCamera; |
---|
14325 | 14710 | if (!isRenderer) |
---|
14326 | 14711 | { |
---|
14327 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14712 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14713 | + //Object3D copy = editWindow.copy; |
---|
| 14714 | + if (object.doEditClick(ci, 0)) |
---|
14328 | 14715 | { |
---|
14329 | 14716 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14330 | 14717 | } else |
---|
.. | .. |
---|
14336 | 14723 | |
---|
14337 | 14724 | public void mouseReleased(MouseEvent e) |
---|
14338 | 14725 | { |
---|
| 14726 | + Globals.MOUSEDRAGGED = false; |
---|
| 14727 | + |
---|
14339 | 14728 | movingcamera = false; |
---|
| 14729 | + X = Y = 0; |
---|
14340 | 14730 | //System.out.println("mouseReleased: " + e); |
---|
14341 | 14731 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14342 | 14732 | } |
---|
.. | .. |
---|
14359 | 14749 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
14360 | 14750 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
14361 | 14751 | |
---|
14362 | | - if (control || command || IsFrozen()) |
---|
| 14752 | +// No delay if (control || command || IsFrozen()) |
---|
14363 | 14753 | timeout = true; |
---|
14364 | | - else |
---|
| 14754 | +// ?? May 2019 else |
---|
14365 | 14755 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
14366 | 14756 | mouseDown = false; |
---|
14367 | 14757 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14471 | 14861 | System.out.println("keyReleased: " + e); |
---|
14472 | 14862 | } |
---|
14473 | 14863 | |
---|
14474 | | - void SetMouseMode(int modifiers) |
---|
| 14864 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14475 | 14865 | { |
---|
14476 | 14866 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14477 | 14867 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14483 | 14873 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14484 | 14874 | // return; |
---|
14485 | 14875 | //System.out.println("SetMode = " + modifiers); |
---|
14486 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14876 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14487 | 14877 | { |
---|
14488 | 14878 | mouseMode |= ZOOM; |
---|
14489 | 14879 | } |
---|
14490 | 14880 | |
---|
14491 | 14881 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14492 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14882 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14493 | 14883 | { |
---|
14494 | 14884 | mouseMode |= VR; // BACKFORTH; |
---|
14495 | 14885 | } |
---|
14496 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14886 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14497 | 14887 | { |
---|
14498 | 14888 | mouseMode |= SELECT; |
---|
14499 | 14889 | } |
---|
14500 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14890 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14501 | 14891 | { |
---|
14502 | 14892 | mouseMode |= SELECT; |
---|
14503 | 14893 | } |
---|
14504 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14894 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14505 | 14895 | { |
---|
14506 | 14896 | mouseMode &= ~VR; |
---|
14507 | 14897 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14530 | 14920 | |
---|
14531 | 14921 | if (isRenderer) // |
---|
14532 | 14922 | { |
---|
14533 | | - SetMouseMode(modifiers); |
---|
| 14923 | + SetMouseMode(0, modifiers); |
---|
14534 | 14924 | } |
---|
14535 | 14925 | |
---|
14536 | 14926 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14702 | 15092 | RevertCamera(); |
---|
14703 | 15093 | repaint(); |
---|
14704 | 15094 | break; |
---|
14705 | | - case 'L': |
---|
14706 | 15095 | case 'l': |
---|
| 15096 | + lightMode ^= true; |
---|
| 15097 | + Globals.lighttouched = true; |
---|
| 15098 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15099 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 15100 | + repaint(); |
---|
| 15101 | + break; |
---|
| 15102 | + case 'L': |
---|
14707 | 15103 | if (lightMode) |
---|
14708 | 15104 | { |
---|
14709 | 15105 | lightMode = false; |
---|
.. | .. |
---|
14846 | 15242 | case '_': |
---|
14847 | 15243 | kompactbit = 5; |
---|
14848 | 15244 | break; |
---|
14849 | | - case '+': |
---|
14850 | | - kompactbit = 6; |
---|
14851 | | - break; |
---|
| 15245 | +// case '+': |
---|
| 15246 | +// kompactbit = 6; |
---|
| 15247 | +// break; |
---|
14852 | 15248 | case ' ': |
---|
14853 | | - lightMode ^= true; |
---|
14854 | | - Globals.lighttouched = true; |
---|
14855 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14856 | | - targetLookAt.set(manipCamera.lookAt); |
---|
| 15249 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14857 | 15250 | repaint(); |
---|
14858 | 15251 | break; |
---|
14859 | 15252 | //case '`' : |
---|
14860 | 15253 | case ESC: |
---|
14861 | 15254 | RENDERPROGRAM += 1; |
---|
14862 | 15255 | RENDERPROGRAM %= 3; |
---|
| 15256 | + |
---|
14863 | 15257 | repaint(); |
---|
14864 | 15258 | break; |
---|
14865 | 15259 | case 'Z': |
---|
14866 | 15260 | //RESIZETEXTURE ^= true; |
---|
14867 | 15261 | //break; |
---|
14868 | 15262 | case 'z': |
---|
14869 | | - RENDERSHADOW ^= true; |
---|
| 15263 | + Globals.RENDERSHADOW ^= true; |
---|
14870 | 15264 | Globals.lighttouched = true; |
---|
14871 | 15265 | repaint(); |
---|
14872 | 15266 | break; |
---|
.. | .. |
---|
14899 | 15293 | case DELETE: |
---|
14900 | 15294 | ClearSelection(); |
---|
14901 | 15295 | break; |
---|
14902 | | - /* |
---|
14903 | 15296 | case '+': |
---|
| 15297 | + |
---|
| 15298 | + //for (int i=0; i<0x7FFFFFFF; i++) |
---|
| 15299 | + { |
---|
| 15300 | + //String.format("%08X", i); // "7caca905" |
---|
| 15301 | + GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true); |
---|
| 15302 | + } |
---|
| 15303 | + |
---|
| 15304 | + /* |
---|
14904 | 15305 | //fontsize += 1; |
---|
14905 | 15306 | bbzoom *= 2; |
---|
14906 | 15307 | repaint(); |
---|
.. | .. |
---|
14990 | 15391 | //mode = ROTATE; |
---|
14991 | 15392 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14992 | 15393 | { |
---|
14993 | | - SetMouseMode(modifiers); |
---|
| 15394 | + SetMouseMode(0, modifiers); |
---|
14994 | 15395 | } |
---|
14995 | 15396 | } |
---|
14996 | 15397 | |
---|
.. | .. |
---|
15126 | 15527 | { |
---|
15127 | 15528 | //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
15128 | 15529 | //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
15129 | | - if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
| 15530 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
15130 | 15531 | { |
---|
15131 | 15532 | mouseMoved(e); |
---|
15132 | 15533 | } else |
---|
.. | .. |
---|
15151 | 15552 | } |
---|
15152 | 15553 | */ |
---|
15153 | 15554 | |
---|
15154 | | - object.editWindow.EditSelection(); |
---|
| 15555 | + object.editWindow.EditSelection(false); |
---|
15155 | 15556 | } |
---|
15156 | 15557 | |
---|
15157 | 15558 | void SelectParent() |
---|
.. | .. |
---|
15345 | 15746 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15346 | 15747 | //Image img = CreateImage(width, height); |
---|
15347 | 15748 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15749 | + |
---|
15348 | 15750 | Graphics gr = g; // img.getGraphics(); |
---|
| 15751 | + |
---|
15349 | 15752 | if (!hasMarquee) |
---|
15350 | 15753 | { |
---|
15351 | 15754 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15443 | 15846 | if (!isRenderer) |
---|
15444 | 15847 | { |
---|
15445 | 15848 | object.drawEditHandles(info, 0); |
---|
| 15849 | + |
---|
| 15850 | + if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15851 | + { |
---|
| 15852 | + switch (object.selection.get(0).hitSomething) |
---|
| 15853 | + { |
---|
| 15854 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15855 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15856 | + break; |
---|
| 15857 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15858 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15859 | + break; |
---|
| 15860 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15861 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15862 | + break; |
---|
| 15863 | + } |
---|
| 15864 | + |
---|
| 15865 | + } |
---|
15446 | 15866 | } |
---|
15447 | 15867 | } |
---|
| 15868 | + |
---|
15448 | 15869 | if (isRenderer) |
---|
15449 | 15870 | { |
---|
15450 | 15871 | //gr.setColor(Color.black); |
---|
15451 | 15872 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15452 | 15873 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15453 | 15874 | } |
---|
| 15875 | + |
---|
15454 | 15876 | if (hasMarquee) |
---|
15455 | 15877 | { |
---|
15456 | 15878 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15563 | 15985 | public boolean mouseDown(Event evt, int x, int y) |
---|
15564 | 15986 | { |
---|
15565 | 15987 | System.out.println("mouseDown: " + evt); |
---|
| 15988 | + System.exit(0); |
---|
15566 | 15989 | /* |
---|
15567 | 15990 | locked = true; |
---|
15568 | 15991 | drag = false; |
---|
.. | .. |
---|
15606 | 16029 | { |
---|
15607 | 16030 | keyPressed(0, modifiers); |
---|
15608 | 16031 | } |
---|
15609 | | - clickStart(x, y, modifiers); |
---|
| 16032 | + // clickStart(x, y, modifiers); |
---|
15610 | 16033 | return true; |
---|
15611 | 16034 | } |
---|
15612 | 16035 | |
---|
.. | .. |
---|
15724 | 16147 | { |
---|
15725 | 16148 | keyReleased(0, 0); |
---|
15726 | 16149 | } |
---|
15727 | | - drag(x, y, modifiers); |
---|
| 16150 | + drag(x, y, 0, modifiers); |
---|
15728 | 16151 | return true; |
---|
15729 | 16152 | } |
---|
15730 | 16153 | |
---|
.. | .. |
---|
15856 | 16279 | Object3D object; |
---|
15857 | 16280 | static Object3D trackedobject; |
---|
15858 | 16281 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15859 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16282 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15860 | 16283 | /*static*/ Camera eyeCamera; |
---|
15861 | 16284 | /*static*/ Camera lightCamera; |
---|
15862 | 16285 | int cameracount; |
---|
.. | .. |
---|
16141 | 16564 | cStatic.objectstack[materialdepth++] = checker; |
---|
16142 | 16565 | //System.out.println("material " + material); |
---|
16143 | 16566 | //Applet3D.tracein(this, selected); |
---|
16144 | | - vector2buffer = checker.projectedVertices; |
---|
| 16567 | + //vector2buffer = checker.projectedVertices; |
---|
16145 | 16568 | |
---|
16146 | 16569 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16147 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16570 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16148 | 16571 | |
---|
16149 | 16572 | materialdepth -= 1; |
---|
16150 | 16573 | if (materialdepth > 0) |
---|
16151 | 16574 | { |
---|
16152 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16153 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16575 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16576 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16154 | 16577 | } |
---|
16155 | 16578 | //checker.GetMaterial().opacity = 1f; |
---|
16156 | 16579 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16374 | 16797 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16375 | 16798 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
16376 | 16799 | |
---|
| 16800 | + CreateSelectedPoint(); |
---|
| 16801 | + |
---|
16377 | 16802 | // Will fit the mesh !!! |
---|
16378 | 16803 | selectedpoint.toParent[0][0] = 0.0001; |
---|
16379 | 16804 | selectedpoint.toParent[1][1] = 0.0001; |
---|
.. | .. |
---|
16422 | 16847 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
16423 | 16848 | } |
---|
16424 | 16849 | |
---|
16425 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16850 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16426 | 16851 | } |
---|
16427 | 16852 | } |
---|
16428 | 16853 | |
---|
16429 | 16854 | if (!movingcamera && !PAINTMODE) |
---|
16430 | 16855 | object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
16431 | 16856 | |
---|
16432 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16857 | + if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16433 | 16858 | { |
---|
16434 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16859 | + Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16435 | 16860 | |
---|
16436 | 16861 | Object3D group = new Object3D("inst" + paintcount++); |
---|
16437 | 16862 | |
---|
.. | .. |
---|
16488 | 16913 | //System.out.println("objects[color] = " + objects[color]); |
---|
16489 | 16914 | //objects[color].Select(); |
---|
16490 | 16915 | indexcount = 0; |
---|
| 16916 | + ObjEditor window = object.GetWindow(); |
---|
| 16917 | + if (window != null && deselect) |
---|
| 16918 | + { |
---|
| 16919 | + window.Select(null, deselect, true); |
---|
| 16920 | + } |
---|
16491 | 16921 | object.Select(color, deselect); |
---|
16492 | 16922 | } |
---|
16493 | 16923 | |
---|
.. | .. |
---|
16587 | 17017 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16588 | 17018 | } |
---|
16589 | 17019 | |
---|
16590 | | - if (!RENDERSHADOW) |
---|
| 17020 | + if (!Globals.RENDERSHADOW) |
---|
16591 | 17021 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16592 | 17022 | |
---|
16593 | 17023 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16597 | 17027 | //gl.glColorMask(false, false, false, false); |
---|
16598 | 17028 | |
---|
16599 | 17029 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16600 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17030 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16601 | 17031 | { |
---|
16602 | 17032 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16603 | 17033 | |
---|
.. | .. |
---|
17013 | 17443 | int AAbuffersize = 0; |
---|
17014 | 17444 | |
---|
17015 | 17445 | //double[] selectedpoint = new double[3]; |
---|
17016 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17446 | + static Superellipsoid selectedpoint; |
---|
17017 | 17447 | static Sphere previousselectedpoint = null; |
---|
17018 | | - static Sphere debugpointG = new Sphere(); |
---|
17019 | | - static Sphere debugpointP = new Sphere(); |
---|
17020 | | - static Sphere debugpointC = new Sphere(); |
---|
17021 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17448 | + static Sphere debugpointG; |
---|
| 17449 | + static Sphere debugpointP; |
---|
| 17450 | + static Sphere debugpointC; |
---|
| 17451 | + static Sphere debugpointR; |
---|
17022 | 17452 | |
---|
17023 | 17453 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17024 | 17454 | |
---|
17025 | | - static |
---|
17026 | | - { |
---|
17027 | | - for (int i=0; i<8; i++) |
---|
17028 | | - { |
---|
17029 | | - debugpoints[i] = new Sphere(); |
---|
17030 | | - } |
---|
17031 | | - } |
---|
17032 | | - |
---|
17033 | 17455 | static void InitPoints(float radius) |
---|
17034 | 17456 | { |
---|
17035 | 17457 | for (int i=0; i<8; i++) |
---|