.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
37 | 41 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 42 | static int materialdepth = 0; |
---|
39 | 43 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 44 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 45 | |
---|
43 | 46 | // camera change fix |
---|
.. | .. |
---|
45 | 48 | static boolean ABORTED = false; |
---|
46 | 49 | |
---|
47 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
48 | 84 | |
---|
49 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
50 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
61 | 97 | //boolean REDUCETEXTURE = true; |
---|
62 | 98 | boolean CACHETEXTURE = true; |
---|
63 | 99 | boolean CLEANCACHE = false; // true; |
---|
64 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
65 | 101 | boolean COMPRESSTEXTURE = false; |
---|
66 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
67 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
152 | 188 | |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
| 191 | + public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 192 | + { |
---|
| 193 | + try |
---|
| 194 | + { |
---|
| 195 | + cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 196 | + } catch (IOException e) |
---|
| 197 | + { |
---|
| 198 | + System.out.println("NAME = " + name); |
---|
| 199 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 200 | + } |
---|
| 201 | + } |
---|
| 202 | + |
---|
153 | 203 | void SetAsGLRenderer(boolean b) |
---|
154 | 204 | { |
---|
155 | 205 | isRenderer = b; |
---|
.. | .. |
---|
168 | 218 | |
---|
169 | 219 | SetCamera(cam); |
---|
170 | 220 | |
---|
171 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 221 | + // Warning: not used. |
---|
| 222 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
172 | 223 | |
---|
173 | 224 | object = o; |
---|
174 | 225 | |
---|
.. | .. |
---|
325 | 376 | cStatic.objectstack[materialdepth++] = obj; |
---|
326 | 377 | //System.out.println("material " + material); |
---|
327 | 378 | //Applet3D.tracein(this, selected); |
---|
328 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 379 | + //display.vector2buffer = obj.projectedVertices; |
---|
329 | 380 | if (obj instanceof Camera) |
---|
330 | 381 | { |
---|
331 | 382 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
334 | 385 | display.options1[2] = material.shadowbias; |
---|
335 | 386 | display.options1[3] = material.aniso; |
---|
336 | 387 | display.options1[4] = material.anisoV; |
---|
| 388 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 389 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 390 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 391 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 392 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
337 | 393 | display.options2[0] = material.opacity; |
---|
338 | 394 | display.options2[1] = material.diffuse; |
---|
339 | 395 | display.options2[2] = material.factor; |
---|
| 396 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 397 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 398 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
340 | 399 | |
---|
341 | 400 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 401 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 402 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 403 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
342 | 404 | display.options4[0] = material.cameralight/0.2f; |
---|
343 | 405 | display.options4[1] = material.subsurface; |
---|
344 | 406 | display.options4[2] = material.sheen; |
---|
| 407 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 408 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 409 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
345 | 410 | |
---|
346 | 411 | // if (display.CURRENTANTIALIAS > 0) |
---|
347 | 412 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
357 | 422 | /**/ |
---|
358 | 423 | } else |
---|
359 | 424 | { |
---|
360 | | - DrawMaterial(material, selected); |
---|
| 425 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
361 | 426 | } |
---|
362 | 427 | } else |
---|
363 | 428 | { |
---|
.. | .. |
---|
381 | 446 | cStatic.objectstack[materialdepth++] = obj; |
---|
382 | 447 | //System.out.println("material " + material); |
---|
383 | 448 | //Applet3D.tracein("selected ", selected); |
---|
384 | | - display.vector2buffer = obj.projectedVertices; |
---|
385 | | - display.DrawMaterial(material, selected); |
---|
| 449 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 450 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
386 | 451 | } |
---|
387 | 452 | } |
---|
388 | 453 | |
---|
.. | .. |
---|
399 | 464 | materialdepth -= 1; |
---|
400 | 465 | if (materialdepth > 0) |
---|
401 | 466 | { |
---|
402 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
403 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 467 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 468 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
404 | 469 | } |
---|
405 | 470 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
406 | 471 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
420 | 485 | materialdepth -= 1; |
---|
421 | 486 | if (materialdepth > 0) |
---|
422 | 487 | { |
---|
423 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
424 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 488 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 489 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
425 | 490 | } |
---|
426 | 491 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
427 | 492 | //else |
---|
.. | .. |
---|
462 | 527 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
463 | 528 | { |
---|
464 | 529 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
465 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 530 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 531 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 532 | + ; |
---|
466 | 533 | if (!hasnorm) |
---|
467 | 534 | { |
---|
468 | | - // System.out.println("FUCK!!"); |
---|
| 535 | + // System.out.println("Mesh normal"); |
---|
469 | 536 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
470 | 537 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
471 | 538 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1190 | 1257 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1191 | 1258 | } |
---|
1192 | 1259 | } |
---|
| 1260 | + |
---|
1193 | 1261 | if (flipV) |
---|
1194 | 1262 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1195 | 1263 | else |
---|
1196 | 1264 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1265 | + |
---|
1197 | 1266 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1198 | 1267 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1199 | 1268 | |
---|
.. | .. |
---|
1213 | 1282 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1214 | 1283 | } |
---|
1215 | 1284 | } |
---|
| 1285 | + |
---|
1216 | 1286 | if (flipV) |
---|
1217 | 1287 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1218 | 1288 | else |
---|
1219 | 1289 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1290 | + |
---|
1220 | 1291 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1221 | 1292 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1222 | 1293 | |
---|
.. | .. |
---|
1244 | 1315 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1245 | 1316 | else |
---|
1246 | 1317 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1318 | + |
---|
1247 | 1319 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1248 | 1320 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1321 | + |
---|
1249 | 1322 | count2 += 2; |
---|
1250 | 1323 | count3 += 3; |
---|
1251 | 1324 | } |
---|
.. | .. |
---|
1424 | 1497 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1425 | 1498 | } |
---|
1426 | 1499 | |
---|
| 1500 | + float[] colorV = new float[4]; |
---|
| 1501 | + |
---|
1427 | 1502 | void SetColor(Object3D obj, Vertex p0) |
---|
1428 | 1503 | { |
---|
1429 | 1504 | CameraPane display = this; |
---|
.. | .. |
---|
1491 | 1566 | { |
---|
1492 | 1567 | return; |
---|
1493 | 1568 | } |
---|
1494 | | - |
---|
1495 | | - float[] colorV = new float[3]; |
---|
1496 | 1569 | |
---|
1497 | 1570 | if (false) // marked) |
---|
1498 | 1571 | { |
---|
.. | .. |
---|
1601 | 1674 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1602 | 1675 | } |
---|
1603 | 1676 | |
---|
1604 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1677 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1605 | 1678 | { |
---|
1606 | 1679 | CameraPane display = this; |
---|
1607 | 1680 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1636 | 1709 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1637 | 1710 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1638 | 1711 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1639 | | - colorV[3] = material.opacity; |
---|
| 1712 | + colorV[3] = 1; // material.opacity; |
---|
1640 | 1713 | |
---|
1641 | 1714 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1642 | 1715 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1744 | 1817 | display.modelParams7[2] = 0; |
---|
1745 | 1818 | display.modelParams7[3] = 0; |
---|
1746 | 1819 | |
---|
1747 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1820 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1748 | 1821 | |
---|
1749 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1822 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1750 | 1823 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1751 | 1824 | { |
---|
1752 | 1825 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1888 | 1961 | void PushMatrix(double[][] matrix) |
---|
1889 | 1962 | { |
---|
1890 | 1963 | // GrafreeD.tracein(matrix); |
---|
1891 | | - PushMatrix(matrix,1); |
---|
| 1964 | + PushMatrix(matrix, 1); |
---|
1892 | 1965 | } |
---|
1893 | 1966 | |
---|
1894 | 1967 | void PushMatrix() |
---|
.. | .. |
---|
2042 | 2115 | //System.err.println("Oeil on"); |
---|
2043 | 2116 | OEIL = true; |
---|
2044 | 2117 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2045 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2118 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2046 | 2119 | //pingthread.StepToTarget(true); |
---|
2047 | 2120 | } |
---|
2048 | 2121 | |
---|
.. | .. |
---|
2257 | 2330 | |
---|
2258 | 2331 | void ToggleDebug() |
---|
2259 | 2332 | { |
---|
2260 | | - DEBUG ^= true; |
---|
| 2333 | + Globals.DEBUG ^= true; |
---|
2261 | 2334 | } |
---|
2262 | 2335 | |
---|
2263 | 2336 | void ToggleLookAt() |
---|
.. | .. |
---|
2265 | 2338 | LOOKAT ^= true; |
---|
2266 | 2339 | } |
---|
2267 | 2340 | |
---|
2268 | | - void ToggleRandom() |
---|
| 2341 | + void ToggleSwitch() |
---|
2269 | 2342 | { |
---|
2270 | 2343 | SWITCH ^= true; |
---|
2271 | 2344 | } |
---|
.. | .. |
---|
2275 | 2348 | HANDLES ^= true; |
---|
2276 | 2349 | } |
---|
2277 | 2350 | |
---|
| 2351 | + Object3D paintFolder; |
---|
| 2352 | + |
---|
2278 | 2353 | void TogglePaint() |
---|
2279 | 2354 | { |
---|
2280 | 2355 | PAINTMODE ^= true; |
---|
2281 | 2356 | paintcount = 0; |
---|
| 2357 | + |
---|
| 2358 | + if (PAINTMODE) |
---|
| 2359 | + { |
---|
| 2360 | + paintFolder = GetFolder(); |
---|
| 2361 | + } |
---|
2282 | 2362 | } |
---|
2283 | 2363 | |
---|
2284 | 2364 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2374 | 2454 | { |
---|
2375 | 2455 | return currentGL; |
---|
2376 | 2456 | } |
---|
2377 | | - |
---|
| 2457 | + |
---|
| 2458 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2459 | + { |
---|
| 2460 | + Grafreed.Assert(texturedata != null); |
---|
| 2461 | + |
---|
| 2462 | + int width = texturedata.getWidth(); |
---|
| 2463 | + int height = texturedata.getHeight(); |
---|
| 2464 | + |
---|
| 2465 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2466 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2467 | + |
---|
| 2468 | + byte[] bytes = bytebuf.array(); |
---|
| 2469 | + |
---|
| 2470 | + return CreateBim(bytes, width, height); |
---|
| 2471 | + } |
---|
| 2472 | + |
---|
2378 | 2473 | /**/ |
---|
2379 | 2474 | class CacheTexture |
---|
2380 | 2475 | { |
---|
.. | .. |
---|
2383 | 2478 | |
---|
2384 | 2479 | int resolution; |
---|
2385 | 2480 | |
---|
2386 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2481 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2387 | 2482 | { |
---|
2388 | | - texture = tex; |
---|
| 2483 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2484 | + texturedata = texdata; |
---|
2389 | 2485 | resolution = res; |
---|
2390 | 2486 | } |
---|
2391 | 2487 | } |
---|
2392 | 2488 | /**/ |
---|
2393 | 2489 | |
---|
2394 | 2490 | // TEXTURE static Texture texture; |
---|
2395 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2396 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2397 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2491 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2492 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2493 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2494 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2495 | + |
---|
2398 | 2496 | int pigmentdepth = 0; |
---|
2399 | 2497 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2400 | 2498 | int bumpdepth = 0; |
---|
2401 | 2499 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2402 | 2500 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2403 | 2501 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2404 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2502 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2405 | 2503 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2406 | 2504 | |
---|
2407 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2505 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2408 | 2506 | { |
---|
2409 | 2507 | TextureData texturedata = null; |
---|
2410 | 2508 | |
---|
.. | .. |
---|
2423 | 2521 | if (bump) |
---|
2424 | 2522 | texturedata = ConvertBump(texturedata, false); |
---|
2425 | 2523 | |
---|
2426 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2427 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2524 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2525 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2428 | 2526 | |
---|
2429 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2430 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2527 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2528 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2431 | 2529 | |
---|
2432 | | - return texture; |
---|
| 2530 | + return texturedata; |
---|
| 2531 | + } |
---|
| 2532 | + |
---|
| 2533 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2534 | + { |
---|
| 2535 | + TextureData texturedata = null; |
---|
| 2536 | + |
---|
| 2537 | + try |
---|
| 2538 | + { |
---|
| 2539 | + texturedata = |
---|
| 2540 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2541 | + bim, |
---|
| 2542 | + true); |
---|
| 2543 | + } catch (Exception e) |
---|
| 2544 | + { |
---|
| 2545 | + throw new javax.media.opengl.GLException(e); |
---|
| 2546 | + } |
---|
| 2547 | + |
---|
| 2548 | + if (bump) |
---|
| 2549 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2550 | + |
---|
| 2551 | + return texturedata; |
---|
2433 | 2552 | } |
---|
2434 | 2553 | |
---|
2435 | 2554 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3502 | 3621 | |
---|
3503 | 3622 | System.out.println("LOADING TEXTURE : " + name); |
---|
3504 | 3623 | |
---|
| 3624 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3625 | + |
---|
3505 | 3626 | // |
---|
3506 | 3627 | if (false) // compressbit > 0) |
---|
3507 | 3628 | { |
---|
.. | .. |
---|
7900 | 8021 | String pigment = Object3D.GetPigment(tex); |
---|
7901 | 8022 | String bump = Object3D.GetBump(tex); |
---|
7902 | 8023 | |
---|
7903 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8024 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7904 | 8025 | { |
---|
7905 | 8026 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7906 | 8027 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7915 | 8036 | pigment = null; |
---|
7916 | 8037 | } |
---|
7917 | 8038 | |
---|
7918 | | - ReleaseTexture(bump, true); |
---|
7919 | | - ReleaseTexture(pigment, false); |
---|
| 8039 | + ReleaseTexture(tex, true); |
---|
| 8040 | + ReleaseTexture(tex, false); |
---|
7920 | 8041 | } |
---|
7921 | 8042 | |
---|
7922 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8043 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8044 | + { |
---|
| 8045 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8046 | + { |
---|
| 8047 | + return; |
---|
| 8048 | + } |
---|
| 8049 | + |
---|
| 8050 | + if (tex == null) |
---|
| 8051 | + { |
---|
| 8052 | + ReleaseTexture(null, false); |
---|
| 8053 | + return; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8057 | + |
---|
| 8058 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8059 | + { |
---|
| 8060 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8061 | + // System.out.println("; bump = " + bump); |
---|
| 8062 | + } |
---|
| 8063 | + |
---|
| 8064 | + if (pigment.equals("")) |
---|
| 8065 | + { |
---|
| 8066 | + pigment = null; |
---|
| 8067 | + } |
---|
| 8068 | + |
---|
| 8069 | + ReleaseTexture(tex, false); |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8073 | + { |
---|
| 8074 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8075 | + { |
---|
| 8076 | + return; |
---|
| 8077 | + } |
---|
| 8078 | + |
---|
| 8079 | + if (tex == null) |
---|
| 8080 | + { |
---|
| 8081 | + ReleaseTexture(null, true); |
---|
| 8082 | + return; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + String bump = Object3D.GetBump(tex); |
---|
| 8086 | + |
---|
| 8087 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8088 | + { |
---|
| 8089 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8090 | + // System.out.println("; bump = " + bump); |
---|
| 8091 | + } |
---|
| 8092 | + |
---|
| 8093 | + if (bump.equals("")) |
---|
| 8094 | + { |
---|
| 8095 | + bump = null; |
---|
| 8096 | + } |
---|
| 8097 | + |
---|
| 8098 | + ReleaseTexture(tex, true); |
---|
| 8099 | + } |
---|
| 8100 | + |
---|
| 8101 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7923 | 8102 | { |
---|
7924 | 8103 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7925 | 8104 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7930 | 8109 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7931 | 8110 | |
---|
7932 | 8111 | if (tex != null) |
---|
7933 | | - texture = textures.get(tex); |
---|
| 8112 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7934 | 8113 | |
---|
7935 | 8114 | // //assert( texture != null ); |
---|
7936 | 8115 | // if (texture == null) |
---|
.. | .. |
---|
8022 | 8201 | } |
---|
8023 | 8202 | } |
---|
8024 | 8203 | |
---|
8025 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8204 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8205 | + { |
---|
| 8206 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8207 | +// ambientOcclusion ) // || !textureon) |
---|
| 8208 | +// { |
---|
| 8209 | +// return; // false; |
---|
| 8210 | +// } |
---|
| 8211 | +// |
---|
| 8212 | +// if (tex == null) |
---|
| 8213 | +// { |
---|
| 8214 | +// BindTexture(null,false,resolution); |
---|
| 8215 | +// BindTexture(null,true,resolution); |
---|
| 8216 | +// return; |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8220 | +// String bump = Object3D.GetBump(tex); |
---|
| 8221 | +// |
---|
| 8222 | +// usedtextures.add(pigment); |
---|
| 8223 | +// usedtextures.add(bump); |
---|
| 8224 | +// |
---|
| 8225 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8226 | +// { |
---|
| 8227 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8228 | +// // System.out.println("; bump = " + bump); |
---|
| 8229 | +// } |
---|
| 8230 | +// |
---|
| 8231 | +// if (bump.equals("")) |
---|
| 8232 | +// { |
---|
| 8233 | +// bump = null; |
---|
| 8234 | +// } |
---|
| 8235 | +// if (pigment.equals("")) |
---|
| 8236 | +// { |
---|
| 8237 | +// pigment = null; |
---|
| 8238 | +// } |
---|
| 8239 | +// |
---|
| 8240 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8241 | +// BindTexture(pigment, false, resolution); |
---|
| 8242 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8243 | +// BindTexture(bump, true, resolution); |
---|
| 8244 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8245 | +// |
---|
| 8246 | +// return; // true; |
---|
| 8247 | + |
---|
| 8248 | + BindPigmentTexture(tex, resolution); |
---|
| 8249 | + BindBumpTexture(tex, resolution); |
---|
| 8250 | + } |
---|
| 8251 | + |
---|
| 8252 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 8253 | { |
---|
8027 | 8254 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8255 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8033 | 8260 | if (tex == null) |
---|
8034 | 8261 | { |
---|
8035 | 8262 | BindTexture(null,false,resolution); |
---|
8036 | | - BindTexture(null,true,resolution); |
---|
8037 | 8263 | return; |
---|
8038 | 8264 | } |
---|
8039 | 8265 | |
---|
8040 | 8266 | String pigment = Object3D.GetPigment(tex); |
---|
| 8267 | + |
---|
| 8268 | + usedtextures.add(tex); |
---|
| 8269 | + |
---|
| 8270 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8271 | + { |
---|
| 8272 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8273 | + // System.out.println("; bump = " + bump); |
---|
| 8274 | + } |
---|
| 8275 | + |
---|
| 8276 | + if (pigment.equals("")) |
---|
| 8277 | + { |
---|
| 8278 | + pigment = null; |
---|
| 8279 | + } |
---|
| 8280 | + |
---|
| 8281 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8282 | + BindTexture(tex, false, resolution); |
---|
| 8283 | + } |
---|
| 8284 | + |
---|
| 8285 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8286 | + { |
---|
| 8287 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8288 | + ambientOcclusion ) // || !textureon) |
---|
| 8289 | + { |
---|
| 8290 | + return; // false; |
---|
| 8291 | + } |
---|
| 8292 | + |
---|
| 8293 | + if (tex == null) |
---|
| 8294 | + { |
---|
| 8295 | + BindTexture(null,true,resolution); |
---|
| 8296 | + return; |
---|
| 8297 | + } |
---|
| 8298 | + |
---|
8041 | 8299 | String bump = Object3D.GetBump(tex); |
---|
8042 | 8300 | |
---|
8043 | | - usedtextures.put(pigment, pigment); |
---|
8044 | | - usedtextures.put(bump, bump); |
---|
| 8301 | + usedtextures.add(tex); |
---|
8045 | 8302 | |
---|
8046 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8303 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8047 | 8304 | { |
---|
8048 | 8305 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8049 | 8306 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8053 | 8310 | { |
---|
8054 | 8311 | bump = null; |
---|
8055 | 8312 | } |
---|
8056 | | - if (pigment.equals("")) |
---|
8057 | | - { |
---|
8058 | | - pigment = null; |
---|
8059 | | - } |
---|
8060 | 8313 | |
---|
8061 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8062 | | - BindTexture(pigment, false, resolution); |
---|
8063 | 8314 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8064 | | - BindTexture(bump, true, resolution); |
---|
| 8315 | + BindTexture(tex, true, resolution); |
---|
8065 | 8316 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8066 | | - |
---|
8067 | | - return; // true; |
---|
8068 | 8317 | } |
---|
8069 | 8318 | |
---|
8070 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8319 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8320 | + |
---|
| 8321 | + private boolean FileExists(String tex) |
---|
8071 | 8322 | { |
---|
8072 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8323 | + if (missingTextures.contains(tex)) |
---|
| 8324 | + { |
---|
| 8325 | + return false; |
---|
| 8326 | + } |
---|
| 8327 | + |
---|
| 8328 | + boolean fileExists = new File(tex).exists(); |
---|
| 8329 | + |
---|
| 8330 | + if (!fileExists) |
---|
| 8331 | + { |
---|
| 8332 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8333 | + missingTextures.add(tex); |
---|
| 8334 | + } |
---|
| 8335 | + |
---|
| 8336 | + return fileExists; |
---|
| 8337 | + } |
---|
| 8338 | + |
---|
| 8339 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8340 | + { |
---|
| 8341 | + CacheTexture texturecache = null; |
---|
8073 | 8342 | |
---|
8074 | 8343 | if (tex != null) |
---|
8075 | 8344 | { |
---|
8076 | | - String texname = tex; |
---|
| 8345 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8346 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8077 | 8347 | |
---|
| 8348 | + if (texname.equals("") && texdata == null) |
---|
| 8349 | + { |
---|
| 8350 | + return null; |
---|
| 8351 | + } |
---|
| 8352 | + |
---|
| 8353 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8354 | + |
---|
8078 | 8355 | // String[] split = tex.split("Textures"); |
---|
8079 | 8356 | // if (split.length > 1) |
---|
8080 | 8357 | // texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8081 | 8358 | // else |
---|
8082 | 8359 | // if (!texname.startsWith("/")) |
---|
8083 | 8360 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8084 | | - if (!new File(tex).exists()) |
---|
| 8361 | + if (!FileExists(texname)) |
---|
8085 | 8362 | { |
---|
8086 | | - texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname; |
---|
| 8363 | + texname = fallbackTextureName; |
---|
8087 | 8364 | } |
---|
8088 | 8365 | |
---|
8089 | 8366 | if (CACHETEXTURE) |
---|
8090 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8091 | | - |
---|
8092 | | - TextureData texturedata = null; |
---|
8093 | | - |
---|
8094 | | - if (texture == null || texture.resolution < resolution) |
---|
8095 | 8367 | { |
---|
8096 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8368 | + if (texdata == null) |
---|
| 8369 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8370 | + else |
---|
| 8371 | + texturecache = bimtextures.get(texdata); |
---|
| 8372 | + } |
---|
| 8373 | + |
---|
| 8374 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8375 | + { |
---|
| 8376 | + TextureData texturedata = null; |
---|
| 8377 | + |
---|
| 8378 | + if (texdata != null && textureon) |
---|
| 8379 | + { |
---|
| 8380 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8381 | + |
---|
| 8382 | + try |
---|
| 8383 | + { |
---|
| 8384 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8385 | + } |
---|
| 8386 | + catch (Exception e) |
---|
| 8387 | + { |
---|
| 8388 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8389 | + } |
---|
| 8390 | + |
---|
| 8391 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8392 | + bimtextures.put(texdata, texturecache); |
---|
| 8393 | + |
---|
| 8394 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8395 | + |
---|
| 8396 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8397 | + //bim2 = bim; |
---|
| 8398 | + } |
---|
| 8399 | + else |
---|
| 8400 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8097 | 8401 | { |
---|
8098 | 8402 | assert(!bump); |
---|
8099 | 8403 | // if (bump) |
---|
.. | .. |
---|
8104 | 8408 | // } |
---|
8105 | 8409 | // else |
---|
8106 | 8410 | // { |
---|
8107 | | - texture = textures.get(tex); |
---|
8108 | | - if (texture == null) |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
8109 | 8413 | { |
---|
8110 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8111 | 8415 | } |
---|
| 8416 | + else |
---|
| 8417 | + new Exception().printStackTrace(); |
---|
8112 | 8418 | // } |
---|
8113 | 8419 | } else |
---|
8114 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8420 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8115 | 8421 | { |
---|
8116 | 8422 | assert(bump); |
---|
8117 | | - texture = textures.get(tex); |
---|
8118 | | - if (texture == null) |
---|
8119 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8423 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8424 | + if (texturecache == null) |
---|
| 8425 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8426 | + else |
---|
| 8427 | + new Exception().printStackTrace(); |
---|
8120 | 8428 | } else |
---|
8121 | 8429 | { |
---|
8122 | 8430 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8124 | 8432 | // texture = GetResourceTexture("default.png"); |
---|
8125 | 8433 | //} else |
---|
8126 | 8434 | //{ |
---|
8127 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8435 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8128 | 8436 | { |
---|
8129 | | - texture = textures.get(tex); |
---|
8130 | | - if (texture == null) |
---|
8131 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8437 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8438 | + if (texturecache == null) |
---|
| 8439 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8440 | + else |
---|
| 8441 | + new Exception().printStackTrace(); |
---|
8132 | 8442 | } else |
---|
8133 | 8443 | { |
---|
8134 | 8444 | if (textureon) |
---|
.. | .. |
---|
8153 | 8463 | } |
---|
8154 | 8464 | |
---|
8155 | 8465 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8466 | + if (!FileExists(cachename)) |
---|
8157 | 8467 | cachename = texname; |
---|
8158 | 8468 | else |
---|
8159 | 8469 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8485 | } |
---|
8176 | 8486 | |
---|
8177 | 8487 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8488 | + if (!FileExists(cachename)) |
---|
8179 | 8489 | cachename = texname; |
---|
8180 | 8490 | else |
---|
8181 | 8491 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8184 | 8494 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8185 | 8495 | |
---|
8186 | 8496 | |
---|
8187 | | - if (texturedata != null) |
---|
8188 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8497 | + if (texturedata == null) |
---|
| 8498 | + throw new Exception(); |
---|
| 8499 | + |
---|
| 8500 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8189 | 8501 | //texture = GetTexture(tex, bump); |
---|
8190 | 8502 | } |
---|
8191 | 8503 | } |
---|
8192 | 8504 | //} |
---|
8193 | 8505 | } |
---|
8194 | 8506 | |
---|
8195 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8507 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8196 | 8508 | { |
---|
8197 | 8509 | //return false; |
---|
8198 | 8510 | |
---|
8199 | 8511 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8200 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8512 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8201 | 8513 | { |
---|
8202 | 8514 | // String ext = "_highres"; |
---|
8203 | 8515 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8214 | 8526 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8215 | 8527 | if (!cachefile.exists()) |
---|
8216 | 8528 | { |
---|
8217 | | - // cache to disk |
---|
8218 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8219 | | - //buffers[0]. |
---|
8220 | | - |
---|
8221 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8222 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8223 | | - |
---|
8224 | | - // squared size heuristic... |
---|
8225 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8529 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8226 | 8530 | { |
---|
8227 | | - for (int i=pixels.length; --i>=0;) |
---|
8228 | | - { |
---|
8229 | | - int i3 = i*3; |
---|
8230 | | - pixels[i] = 0xFF; |
---|
8231 | | - pixels[i] <<= 8; |
---|
8232 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8233 | | - pixels[i] <<= 8; |
---|
8234 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8235 | | - pixels[i] <<= 8; |
---|
8236 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8237 | | - } |
---|
8238 | | - |
---|
8239 | | - /* |
---|
8240 | | - int r=0,g=0,b=0,a=0; |
---|
8241 | | - for (int i=0; i<width; i++) |
---|
8242 | | - for (int j=0; j<height; j++) |
---|
8243 | | - { |
---|
8244 | | - int index = j*width+i; |
---|
8245 | | - int p = pixels[index]; |
---|
8246 | | - a = ((p>>24) & 0xFF); |
---|
8247 | | - r = ((p>>16) & 0xFF); |
---|
8248 | | - g = ((p>>8) & 0xFF); |
---|
8249 | | - b = (p & 0xFF); |
---|
8250 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8251 | | - } |
---|
8252 | | - /**/ |
---|
8253 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8254 | | - int height = width; |
---|
8255 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8256 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8531 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8532 | + |
---|
8257 | 8533 | ImageWriter writer = null; |
---|
8258 | 8534 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8259 | 8535 | if (iter.hasNext()) { |
---|
8260 | 8536 | writer = (ImageWriter)iter.next(); |
---|
8261 | 8537 | } |
---|
8262 | | - float compressionQuality = 0.9f; |
---|
| 8538 | + |
---|
| 8539 | + float compressionQuality = 0.85f; |
---|
8263 | 8540 | try |
---|
8264 | 8541 | { |
---|
8265 | 8542 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8276 | 8553 | } |
---|
8277 | 8554 | } |
---|
8278 | 8555 | } |
---|
8279 | | - |
---|
| 8556 | + |
---|
| 8557 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8558 | + |
---|
8280 | 8559 | //System.out.println("Texture = " + tex); |
---|
8281 | | - if (textures.containsKey(texname)) |
---|
| 8560 | + if (textures.containsKey(tex)) |
---|
8282 | 8561 | { |
---|
8283 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8562 | + CacheTexture thetex = textures.get(tex); |
---|
8284 | 8563 | thetex.texture.disable(); |
---|
8285 | 8564 | thetex.texture.dispose(); |
---|
8286 | | - textures.remove(texname); |
---|
| 8565 | + textures.remove(tex); |
---|
8287 | 8566 | } |
---|
8288 | 8567 | |
---|
8289 | | - texture.texturedata = texturedata; |
---|
8290 | | - textures.put(texname, texture); |
---|
| 8568 | + //texture.texturedata = texturedata; |
---|
| 8569 | + textures.put(tex, texturecache); |
---|
8291 | 8570 | |
---|
8292 | 8571 | // newtex = true; |
---|
8293 | 8572 | } |
---|
.. | .. |
---|
8303 | 8582 | } |
---|
8304 | 8583 | } |
---|
8305 | 8584 | |
---|
8306 | | - return texture; |
---|
| 8585 | + return texturecache; |
---|
8307 | 8586 | } |
---|
8308 | 8587 | |
---|
8309 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8588 | + static void EmbedTextures(cTexture tex) |
---|
| 8589 | + { |
---|
| 8590 | + if (tex.pigmentdata == null) |
---|
| 8591 | + { |
---|
| 8592 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8593 | + |
---|
| 8594 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8595 | + |
---|
| 8596 | + if (texturecache != null) |
---|
| 8597 | + { |
---|
| 8598 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8599 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8600 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8601 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8602 | + ; |
---|
| 8603 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8604 | + } |
---|
| 8605 | + } |
---|
| 8606 | + |
---|
| 8607 | + if (tex.bumpdata == null) |
---|
| 8608 | + { |
---|
| 8609 | + //String texname = Object3D.GetBump(tex); |
---|
| 8610 | + |
---|
| 8611 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8612 | + |
---|
| 8613 | + if (texturecache != null) |
---|
| 8614 | + { |
---|
| 8615 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8616 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8617 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8618 | + } |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8310 | 8623 | { |
---|
8311 | 8624 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8312 | 8625 | |
---|
.. | .. |
---|
8324 | 8637 | return texture!=null?texture.texture:null; |
---|
8325 | 8638 | } |
---|
8326 | 8639 | |
---|
8327 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8640 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8328 | 8641 | { |
---|
8329 | 8642 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8330 | 8643 | |
---|
8331 | 8644 | return texture!=null?texture.texturedata:null; |
---|
8332 | 8645 | } |
---|
8333 | 8646 | |
---|
8334 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8647 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8335 | 8648 | { |
---|
8336 | 8649 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8337 | 8650 | { |
---|
8338 | 8651 | return false; |
---|
8339 | 8652 | } |
---|
8340 | 8653 | |
---|
8341 | | - boolean newtex = false; |
---|
| 8654 | + //boolean newtex = false; |
---|
8342 | 8655 | |
---|
8343 | 8656 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8344 | 8657 | |
---|
.. | .. |
---|
8370 | 8683 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8371 | 8684 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8372 | 8685 | |
---|
8373 | | - return newtex; |
---|
| 8686 | + return true; // Warning: not used. |
---|
8374 | 8687 | } |
---|
8375 | 8688 | |
---|
| 8689 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8690 | + { |
---|
| 8691 | + try |
---|
| 8692 | + { |
---|
| 8693 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8694 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8695 | + ImageWriter writer = writers.next(); |
---|
| 8696 | + |
---|
| 8697 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8698 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8699 | + param.setCompressionQuality(quality); |
---|
| 8700 | + |
---|
| 8701 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8702 | + writer.setOutput(ios); |
---|
| 8703 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8704 | + |
---|
| 8705 | + byte[] data = baos.toByteArray(); |
---|
| 8706 | + writer.dispose(); |
---|
| 8707 | + return data; |
---|
| 8708 | + } |
---|
| 8709 | + catch (Exception e) |
---|
| 8710 | + { |
---|
| 8711 | + e.printStackTrace(); |
---|
| 8712 | + return null; |
---|
| 8713 | + } |
---|
| 8714 | + } |
---|
| 8715 | + |
---|
| 8716 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8717 | + { |
---|
| 8718 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8719 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8720 | + ImageReader reader = writers.next(); |
---|
| 8721 | + |
---|
| 8722 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8723 | + |
---|
| 8724 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8725 | + param.setDestination(bim); |
---|
| 8726 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8727 | + |
---|
| 8728 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8729 | + reader.setInput(ios); |
---|
| 8730 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8731 | + reader.dispose(); |
---|
| 8732 | + |
---|
| 8733 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8734 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8735 | +// byte[] bytes = data.getData(); |
---|
| 8736 | +// |
---|
| 8737 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8738 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8739 | +// { |
---|
| 8740 | +// int i3 = i*3; |
---|
| 8741 | +// pixels[i] = 0xFF; |
---|
| 8742 | +// pixels[i] <<= 8; |
---|
| 8743 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8744 | +// pixels[i] <<= 8; |
---|
| 8745 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8746 | +// pixels[i] <<= 8; |
---|
| 8747 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8748 | +// } |
---|
| 8749 | +// |
---|
| 8750 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8751 | + |
---|
| 8752 | + return bim; |
---|
| 8753 | + } |
---|
| 8754 | + |
---|
8376 | 8755 | ShadowBuffer shadowPBuf; |
---|
8377 | 8756 | AntialiasBuffer antialiasPBuf; |
---|
8378 | 8757 | int MAXSTACK; |
---|
.. | .. |
---|
8565 | 8944 | |
---|
8566 | 8945 | if (cubemap == null) |
---|
8567 | 8946 | { |
---|
8568 | | - LoadEnvy(5); |
---|
| 8947 | + //LoadEnvy(1); |
---|
8569 | 8948 | } |
---|
8570 | 8949 | |
---|
8571 | 8950 | //cubemap.enable(); |
---|
.. | .. |
---|
8852 | 9231 | cubemap = null; |
---|
8853 | 9232 | return; |
---|
8854 | 9233 | case 1: |
---|
8855 | | - name = "cubemaps/box_"; |
---|
8856 | | - ext = "png"; |
---|
| 9234 | + name = "cubemaps/rgb/"; |
---|
| 9235 | + ext = "jpg"; |
---|
8857 | 9236 | reverseUP = false; |
---|
8858 | 9237 | break; |
---|
8859 | 9238 | case 2: |
---|
8860 | | - name = "cubemaps/uffizi_"; |
---|
8861 | | - ext = "png"; |
---|
8862 | | - break; // reverseUP = true; break; |
---|
| 9239 | + name = "cubemaps/uffizi/"; |
---|
| 9240 | + ext = "jpg"; |
---|
| 9241 | + reverseUP = false; |
---|
| 9242 | + break; |
---|
8863 | 9243 | case 3: |
---|
8864 | | - name = "cubemaps/CloudyHills_"; |
---|
8865 | | - ext = "tga"; |
---|
| 9244 | + name = "cubemaps/CloudyHills/"; |
---|
| 9245 | + ext = "jpg"; |
---|
8866 | 9246 | reverseUP = false; |
---|
8867 | 9247 | break; |
---|
8868 | 9248 | case 4: |
---|
8869 | | - name = "cubemaps/cornell_"; |
---|
| 9249 | + name = "cubemaps/cornell/"; |
---|
8870 | 9250 | ext = "png"; |
---|
8871 | 9251 | reverseUP = false; |
---|
8872 | 9252 | break; |
---|
| 9253 | + case 5: |
---|
| 9254 | + name = "cubemaps/skycube/"; |
---|
| 9255 | + ext = "jpg"; |
---|
| 9256 | + reverseUP = false; |
---|
| 9257 | + break; |
---|
| 9258 | + case 6: |
---|
| 9259 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
| 9263 | + case 7: |
---|
| 9264 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 8: |
---|
| 9269 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 9: |
---|
| 9274 | + name = "cubemaps/UnionSquare/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
8873 | 9278 | default: |
---|
8874 | | - name = "cubemaps/rgb_"; |
---|
8875 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9279 | + name = "cubemaps/box/"; |
---|
| 9280 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9281 | + reverseUP = false; |
---|
8876 | 9282 | break; |
---|
8877 | 9283 | } |
---|
8878 | | - |
---|
8879 | | - try |
---|
8880 | | - { |
---|
8881 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8882 | | - } catch (IOException e) |
---|
8883 | | - { |
---|
8884 | | - throw new RuntimeException(e); |
---|
8885 | | - } |
---|
| 9284 | + |
---|
| 9285 | + LoadSkybox(name, ext, mipmap); |
---|
8886 | 9286 | } |
---|
8887 | 9287 | |
---|
8888 | 9288 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8914 | 9314 | static double[] model = new double[16]; |
---|
8915 | 9315 | double[] camera2light = new double[16]; |
---|
8916 | 9316 | double[] light2camera = new double[16]; |
---|
8917 | | - int newenvy = -1; |
---|
8918 | | - boolean envyoff = true; // false; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
| 9322 | + |
---|
8919 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8920 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
8921 | 9325 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9208 | 9612 | jy8[3] = 0.5f; |
---|
9209 | 9613 | } |
---|
9210 | 9614 | |
---|
9211 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9615 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9212 | 9616 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9213 | 9617 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9214 | 9618 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9215 | 9619 | |
---|
| 9620 | + void ResetOptions() |
---|
| 9621 | + { |
---|
| 9622 | + options1[0] = 100; |
---|
| 9623 | + options1[1] = 0.025f; |
---|
| 9624 | + options1[2] = 0.01f; |
---|
| 9625 | + options1[3] = 0; |
---|
| 9626 | + options1[4] = 0; |
---|
| 9627 | + |
---|
| 9628 | + options2[0] = 0; |
---|
| 9629 | + options2[1] = 0.75f; |
---|
| 9630 | + options2[2] = 0; |
---|
| 9631 | + options2[3] = 0; |
---|
| 9632 | + |
---|
| 9633 | + options3[0] = 1; |
---|
| 9634 | + options3[1] = 1; |
---|
| 9635 | + options3[2] = 1; |
---|
| 9636 | + options3[3] = 0; |
---|
| 9637 | + |
---|
| 9638 | + options4[0] = 1; |
---|
| 9639 | + options4[1] = 0; |
---|
| 9640 | + options4[2] = 1; |
---|
| 9641 | + options4[3] = 0; |
---|
| 9642 | + } |
---|
| 9643 | + |
---|
9216 | 9644 | static int imagecount = 0; // movie generation |
---|
9217 | 9645 | |
---|
9218 | 9646 | static int jitter = 0; |
---|
.. | .. |
---|
9308 | 9736 | assert (parentcam != renderCamera); |
---|
9309 | 9737 | |
---|
9310 | 9738 | if (renderCamera != lightCamera) |
---|
9311 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9312 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9739 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9740 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9313 | 9741 | |
---|
9314 | 9742 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9315 | 9743 | |
---|
.. | .. |
---|
9324 | 9752 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9325 | 9753 | |
---|
9326 | 9754 | if (renderCamera != lightCamera) |
---|
9327 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9328 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9755 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9756 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9329 | 9757 | |
---|
9330 | 9758 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9331 | 9759 | |
---|
.. | .. |
---|
9371 | 9799 | rati = 1 / rati; |
---|
9372 | 9800 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9373 | 9801 | } |
---|
9374 | | - assert (newenvy == -1); |
---|
| 9802 | + |
---|
| 9803 | + //assert (newenvy == -1); |
---|
| 9804 | + |
---|
9375 | 9805 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9376 | 9806 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9377 | | - DrawSkyBox(gl); |
---|
| 9807 | + DrawSkyBox(gl, (float)rati); |
---|
9378 | 9808 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9379 | 9809 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9380 | 9810 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10323 | 10753 | ANTIALIAS = 0; |
---|
10324 | 10754 | //System.out.println("RESTART"); |
---|
10325 | 10755 | AAtimer.restart(); |
---|
| 10756 | + Globals.TIMERRUNNING = true; |
---|
10326 | 10757 | } |
---|
10327 | 10758 | } |
---|
10328 | 10759 | } |
---|
.. | .. |
---|
10390 | 10821 | ambientOcclusion = false; |
---|
10391 | 10822 | } |
---|
10392 | 10823 | |
---|
10393 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10824 | + if (//Globals.lighttouched && |
---|
| 10825 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10394 | 10826 | { |
---|
10395 | 10827 | //if (RENDERSHADOW) // ? |
---|
10396 | 10828 | if (!IsFrozen()) |
---|
10397 | 10829 | { |
---|
10398 | 10830 | // dec 2012 |
---|
10399 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10831 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10400 | 10832 | { |
---|
10401 | 10833 | Globals.framecount++; |
---|
10402 | 10834 | shadowbuffer.display(); |
---|
.. | .. |
---|
10523 | 10955 | |
---|
10524 | 10956 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10957 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10958 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10959 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10528 | 10960 | |
---|
10529 | 10961 | for (int j = 0; j < 4; j++) |
---|
10530 | 10962 | { |
---|
.. | .. |
---|
10538 | 10970 | |
---|
10539 | 10971 | // if (parentcam != renderCamera) // not a light |
---|
10540 | 10972 | if (cam != lightCamera) |
---|
10541 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10542 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10973 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10974 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10543 | 10975 | |
---|
10544 | 10976 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10545 | 10977 | |
---|
.. | .. |
---|
10625 | 11057 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10626 | 11058 | } |
---|
10627 | 11059 | |
---|
10628 | | - if (newenvy > -1) |
---|
| 11060 | +// if (newenvy > -1) |
---|
| 11061 | +// { |
---|
| 11062 | +// LoadEnvy(newenvy); |
---|
| 11063 | +// } |
---|
| 11064 | +// |
---|
| 11065 | +// newenvy = -1; |
---|
| 11066 | + |
---|
| 11067 | + if (object.skyboxname != null) |
---|
10629 | 11068 | { |
---|
10630 | | - LoadEnvy(newenvy); |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
10631 | 11074 | } |
---|
10632 | | - |
---|
10633 | | - newenvy = -1; |
---|
10634 | | - |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
| 11079 | + } |
---|
| 11080 | + |
---|
10635 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
10636 | 11082 | //System.out.println("ratio = " + ratio); |
---|
10637 | 11083 | |
---|
.. | .. |
---|
10647 | 11093 | |
---|
10648 | 11094 | if (!IsFrozen() && !ambientOcclusion) |
---|
10649 | 11095 | { |
---|
10650 | | - DrawSkyBox(gl); |
---|
| 11096 | + DrawSkyBox(gl, (float)ratio); |
---|
10651 | 11097 | } |
---|
10652 | 11098 | |
---|
10653 | 11099 | //if (selection_view == -1) |
---|
.. | .. |
---|
10798 | 11244 | // Bump noise |
---|
10799 | 11245 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10800 | 11246 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10801 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11247 | + |
---|
| 11248 | + try |
---|
| 11249 | + { |
---|
| 11250 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11251 | + } |
---|
| 11252 | + catch (Exception e) |
---|
| 11253 | + { |
---|
| 11254 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11255 | + } |
---|
| 11256 | + |
---|
10802 | 11257 | |
---|
10803 | 11258 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10804 | 11259 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10821 | 11276 | |
---|
10822 | 11277 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10823 | 11278 | |
---|
10824 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10825 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10826 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11279 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11280 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11281 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10827 | 11282 | } else |
---|
10828 | 11283 | { |
---|
10829 | 11284 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10834 | 11289 | //System.out.println("BLENDING ON"); |
---|
10835 | 11290 | gl.glEnable(GL.GL_BLEND); |
---|
10836 | 11291 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10837 | | - |
---|
| 11292 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10838 | 11293 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10839 | 11294 | gl.glLoadIdentity(); |
---|
10840 | 11295 | |
---|
.. | .. |
---|
10923 | 11378 | System.err.println("parentcam != renderCamera"); |
---|
10924 | 11379 | |
---|
10925 | 11380 | // if (cam != lightCamera) |
---|
10926 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10927 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11381 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11382 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10928 | 11383 | } |
---|
10929 | 11384 | |
---|
10930 | 11385 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10945 | 11400 | if (true) // TODO |
---|
10946 | 11401 | { |
---|
10947 | 11402 | if (cam != lightCamera) |
---|
10948 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10949 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11403 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11404 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10950 | 11405 | } |
---|
10951 | 11406 | |
---|
10952 | 11407 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11083 | 11538 | } |
---|
11084 | 11539 | } |
---|
11085 | 11540 | |
---|
11086 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11541 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11087 | 11542 | { |
---|
11088 | 11543 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11089 | 11544 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11091 | 11546 | |
---|
11092 | 11547 | boolean texon = textureon; |
---|
11093 | 11548 | |
---|
11094 | | - if (RENDERPROGRAM > 0) |
---|
11095 | | - { |
---|
11096 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11097 | | - textureon = false; |
---|
11098 | | - } |
---|
| 11549 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11550 | + textureon = false; |
---|
| 11551 | + |
---|
11099 | 11552 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11100 | 11553 | //System.out.println("ALLO"); |
---|
11101 | 11554 | gl.glColorMask(false, false, false, false); |
---|
11102 | 11555 | DrawObject(gl); |
---|
11103 | | - if (RENDERPROGRAM > 0) |
---|
11104 | | - { |
---|
11105 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11106 | | - textureon = texon; |
---|
11107 | | - } |
---|
| 11556 | + |
---|
| 11557 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11558 | + textureon = texon; |
---|
| 11559 | + |
---|
11108 | 11560 | gl.glColorMask(true, true, true, true); |
---|
11109 | 11561 | |
---|
11110 | 11562 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11111 | | - //gl.glDepthMask(false); |
---|
| 11563 | + gl.glDepthMask(false); |
---|
11112 | 11564 | } |
---|
11113 | 11565 | |
---|
11114 | 11566 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11291 | 11743 | |
---|
11292 | 11744 | static boolean zoomonce = false; |
---|
11293 | 11745 | |
---|
| 11746 | + static void CreateSelectedPoint() |
---|
| 11747 | + { |
---|
| 11748 | + if (selectedpoint == null) |
---|
| 11749 | + { |
---|
| 11750 | + debugpointG = new Sphere(); |
---|
| 11751 | + debugpointP = new Sphere(); |
---|
| 11752 | + debugpointC = new Sphere(); |
---|
| 11753 | + debugpointR = new Sphere(); |
---|
| 11754 | + |
---|
| 11755 | + selectedpoint = new Superellipsoid(); |
---|
| 11756 | + |
---|
| 11757 | + for (int i=0; i<8; i++) |
---|
| 11758 | + { |
---|
| 11759 | + debugpoints[i] = new Sphere(); |
---|
| 11760 | + } |
---|
| 11761 | + } |
---|
| 11762 | + } |
---|
| 11763 | + |
---|
11294 | 11764 | void DrawObject(GL gl, boolean draw) |
---|
11295 | 11765 | { |
---|
| 11766 | + // To clear camera values |
---|
| 11767 | + ResetOptions(); |
---|
| 11768 | + |
---|
11296 | 11769 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11297 | 11770 | // DrawMode() = SELECTION; |
---|
11298 | 11771 | //GL gl = getGL(); |
---|
11299 | 11772 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11300 | 11773 | { |
---|
11301 | 11774 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11302 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11775 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11303 | 11776 | pingthread.StepToTarget(true); // true); |
---|
11304 | 11777 | // zoomonce = false; |
---|
11305 | 11778 | } |
---|
.. | .. |
---|
11354 | 11827 | |
---|
11355 | 11828 | usedtextures.clear(); |
---|
11356 | 11829 | |
---|
11357 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11830 | + try |
---|
| 11831 | + { |
---|
| 11832 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11833 | + } |
---|
| 11834 | + catch (Exception e) |
---|
| 11835 | + { |
---|
| 11836 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11837 | + } |
---|
11358 | 11838 | } |
---|
11359 | 11839 | //System.out.println("--> " + stackdepth); |
---|
11360 | 11840 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11364 | 11844 | |
---|
11365 | 11845 | if (DrawMode() == DEFAULT) |
---|
11366 | 11846 | { |
---|
11367 | | - if (DEBUG) |
---|
| 11847 | + if (Globals.DEBUG) |
---|
11368 | 11848 | { |
---|
| 11849 | + CreateSelectedPoint(); |
---|
11369 | 11850 | float radius = 0.05f; |
---|
11370 | 11851 | if (selectedpoint.radius != radius) |
---|
11371 | 11852 | { |
---|
.. | .. |
---|
11419 | 11900 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11420 | 11901 | |
---|
11421 | 11902 | if (CLEANCACHE) |
---|
11422 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11903 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11423 | 11904 | { |
---|
11424 | | - String tex = e.nextElement(); |
---|
| 11905 | + cTexture tex = e.nextElement(); |
---|
11425 | 11906 | |
---|
11426 | 11907 | // System.out.println("Texture --------- " + tex); |
---|
11427 | 11908 | |
---|
11428 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11909 | + if (tex.equals("WHITE_NOISE:")) |
---|
11429 | 11910 | continue; |
---|
11430 | 11911 | |
---|
11431 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11912 | + if (!usedtextures.contains(tex)) |
---|
11432 | 11913 | { |
---|
| 11914 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11433 | 11915 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11434 | | - textures.get(tex).texture.dispose(); |
---|
11435 | | - textures.remove(tex); |
---|
| 11916 | + if (gettex != null) |
---|
| 11917 | + { |
---|
| 11918 | + gettex.texture.dispose(); |
---|
| 11919 | + texturepigment.remove(tex); |
---|
| 11920 | + } |
---|
| 11921 | + |
---|
| 11922 | + gettex = texturebump.get(tex); |
---|
| 11923 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11924 | + if (gettex != null) |
---|
| 11925 | + { |
---|
| 11926 | + gettex.texture.dispose(); |
---|
| 11927 | + texturebump.remove(tex); |
---|
| 11928 | + } |
---|
11436 | 11929 | } |
---|
11437 | 11930 | } |
---|
11438 | 11931 | } |
---|
.. | .. |
---|
11445 | 11938 | if (checker != null && DrawMode() == DEFAULT) |
---|
11446 | 11939 | { |
---|
11447 | 11940 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11448 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11941 | + try |
---|
| 11942 | + { |
---|
| 11943 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11944 | + } |
---|
| 11945 | + catch (Exception e) |
---|
| 11946 | + { |
---|
| 11947 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11948 | + } |
---|
11449 | 11949 | // NEAREST |
---|
11450 | 11950 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11451 | 11951 | DrawChecker(gl); |
---|
.. | .. |
---|
11527 | 12027 | return; |
---|
11528 | 12028 | } |
---|
11529 | 12029 | |
---|
11530 | | - String string = obj.GetToolTip(); |
---|
| 12030 | + String string = obj.toString(); //.GetToolTip(); |
---|
11531 | 12031 | |
---|
11532 | 12032 | GL gl = GetGL(); |
---|
11533 | 12033 | |
---|
.. | .. |
---|
11844 | 12344 | //obj.TransformToWorld(light, light); |
---|
11845 | 12345 | for (int i = tp.size(); --i >= 0;) |
---|
11846 | 12346 | { |
---|
11847 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11848 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12347 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12348 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11849 | 12349 | } |
---|
11850 | 12350 | |
---|
11851 | 12351 | |
---|
.. | .. |
---|
11862 | 12362 | parentcam = cameras[0]; |
---|
11863 | 12363 | } |
---|
11864 | 12364 | |
---|
11865 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11866 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12365 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12366 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11867 | 12367 | |
---|
11868 | 12368 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11869 | 12369 | |
---|
.. | .. |
---|
11953 | 12453 | |
---|
11954 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11955 | 12455 | |
---|
11956 | | - String program = |
---|
| 12456 | + String programmin = |
---|
| 12457 | + // Min shader |
---|
11957 | 12458 | "!!ARBfp1.0\n" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12460 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12461 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12462 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12463 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12464 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12465 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12466 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12467 | + "TEMP temp;" + |
---|
| 12468 | + "TEMP light;" + |
---|
| 12469 | + "TEMP ndotl;" + |
---|
| 12470 | + "TEMP normal;" + |
---|
| 12471 | + "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
| 12474 | + |
---|
| 12475 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12476 | + Normalize("normal") + |
---|
| 12477 | + "MOV light, state.light[0].position;" + |
---|
| 12478 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12479 | + |
---|
| 12480 | + // shadow |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12484 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12486 | + |
---|
| 12487 | + // No shadow when out of frustum |
---|
| 12488 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12489 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12490 | + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12492 | + |
---|
| 12493 | + // Backlit |
---|
| 12494 | + "MOV pos.w, zero123.y;" + |
---|
| 12495 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12496 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12497 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12498 | + Normalize("eye") + |
---|
| 12499 | + |
---|
| 12500 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12501 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12502 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12503 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12504 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12505 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12506 | + |
---|
| 12507 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12508 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12509 | + |
---|
| 12510 | + // Pigment |
---|
| 12511 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12512 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12513 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12514 | + |
---|
| 12515 | + "MUL temp, temp, zero123.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12518 | + |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12520 | + "MOV result.color, temp;" + |
---|
| 12521 | + "END"; |
---|
| 12522 | + |
---|
| 12523 | + String programmax = |
---|
| 12524 | + "!!ARBfp1.0\n" + |
---|
| 12525 | + |
---|
11958 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11959 | 12527 | "PARAM light2cam0 = program.env[10];" + |
---|
11960 | 12528 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12069 | 12637 | "TEMP shininess;" + |
---|
12070 | 12638 | "\n" + |
---|
12071 | 12639 | "MOV texSamp, one;" + |
---|
12072 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12073 | | - |
---|
| 12640 | + |
---|
12074 | 12641 | "MOV mapgrid.x, one2048th.x;" + |
---|
12075 | 12642 | "MOV temp, fragment.texcoord[1];" + |
---|
12076 | 12643 | /* |
---|
.. | .. |
---|
12091 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
12092 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12093 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12094 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12095 | 12662 | "") + |
---|
12096 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12097 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12098 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12099 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12100 | 12667 | "") + |
---|
12101 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12102 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12103 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12104 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12105 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12106 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12107 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12108 | 12675 | "") + |
---|
12109 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12110 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
12475 | 13042 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12476 | 13043 | "") + |
---|
12477 | 13044 | |
---|
12478 | | - // display shadow only (bump == 0) |
---|
| 13045 | + // display shadow only (fakedepth == 0) |
---|
12479 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
12480 | | - "MOV temp.y, -params6.x;" + |
---|
12481 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 13047 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12482 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
12483 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
12484 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
12809 | 13376 | //once = true; |
---|
12810 | 13377 | } |
---|
12811 | 13378 | |
---|
12812 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
| 13386 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12813 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12814 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12815 | 13389 | |
---|
.. | .. |
---|
12902 | 13476 | return out; |
---|
12903 | 13477 | } |
---|
12904 | 13478 | |
---|
12905 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12906 | 13481 | { |
---|
12907 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12908 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12909 | 13484 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13485 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13486 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12910 | 13487 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12911 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12912 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12913 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12914 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13488 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13489 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12915 | 13490 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12916 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13491 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12917 | 13492 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12918 | 13493 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12919 | 13494 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12920 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13495 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12921 | 13496 | |
---|
12922 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12923 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13497 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13498 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12924 | 13499 | } |
---|
12925 | 13500 | |
---|
12926 | 13501 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12942 | 13517 | |
---|
12943 | 13518 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12944 | 13519 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13520 | + |
---|
| 13521 | + // Compare fragment depth in light space with shadowmap. |
---|
12945 | 13522 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12946 | 13523 | "SGE temp.y, temp.x, zero.x;" + |
---|
12947 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13524 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13525 | + |
---|
| 13526 | + // Reverse comparison |
---|
12948 | 13527 | "SUB temp.x, one.x, temp.x;" + |
---|
12949 | 13528 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12950 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13529 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12951 | 13530 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12952 | 13531 | |
---|
12953 | 13532 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12961 | 13540 | // No shadow for backface |
---|
12962 | 13541 | "DP3 temp.x, normal, lightd;" + |
---|
12963 | 13542 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13543 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13544 | + |
---|
| 13545 | + // No shadow when out of frustum |
---|
| 13546 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12964 | 13547 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12965 | 13548 | ""; |
---|
12966 | 13549 | } |
---|
.. | .. |
---|
13107 | 13690 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13108 | 13691 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13109 | 13692 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13110 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13693 | + |
---|
| 13694 | + //Object3D.cVector2[] vector2buffer; |
---|
13111 | 13695 | |
---|
13112 | 13696 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13113 | 13697 | // OUT : diff, spec |
---|
.. | .. |
---|
13123 | 13707 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13124 | 13708 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13125 | 13709 | //"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;" + |
---|
| 13710 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13711 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13712 | + |
---|
| 13713 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13129 | 13714 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13130 | 13715 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13131 | 13716 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13630 | 14215 | else |
---|
13631 | 14216 | if (evt.getSource() == AAtimer) |
---|
13632 | 14217 | { |
---|
| 14218 | + Globals.TIMERRUNNING = false; |
---|
13633 | 14219 | if (mouseDown) |
---|
13634 | 14220 | { |
---|
13635 | 14221 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13689 | 14275 | |
---|
13690 | 14276 | // fev 2014??? |
---|
13691 | 14277 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13692 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14278 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13693 | 14279 | pingthread.StepToTarget(true); // true); |
---|
13694 | 14280 | } |
---|
13695 | 14281 | // if (!LIVE) |
---|
.. | .. |
---|
13704 | 14290 | return; |
---|
13705 | 14291 | |
---|
13706 | 14292 | AAtimer.restart(); // |
---|
| 14293 | + Globals.TIMERRUNNING = true; |
---|
13707 | 14294 | |
---|
13708 | 14295 | // waslive = LIVE; |
---|
13709 | 14296 | // LIVE = false; |
---|
.. | .. |
---|
13753 | 14340 | drag = false; |
---|
13754 | 14341 | //System.out.println("Mouse DOWN"); |
---|
13755 | 14342 | editObj = false; |
---|
13756 | | - ClickInfo info = new ClickInfo(); |
---|
13757 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13758 | | - info.pane = this; |
---|
13759 | | - info.camera = renderCamera; |
---|
13760 | | - info.x = x; |
---|
13761 | | - info.y = y; |
---|
13762 | | - info.modifiers = modifiersex; |
---|
13763 | | - editObj = object.doEditClick(info, 0); |
---|
| 14343 | + //ClickInfo info = new ClickInfo(); |
---|
| 14344 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14345 | + object.clickInfo.pane = this; |
---|
| 14346 | + object.clickInfo.camera = renderCamera; |
---|
| 14347 | + object.clickInfo.x = x; |
---|
| 14348 | + object.clickInfo.y = y; |
---|
| 14349 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14350 | + editObj = object.doEditClick(//info, |
---|
| 14351 | + 0); |
---|
13764 | 14352 | if (!editObj) |
---|
13765 | 14353 | { |
---|
13766 | 14354 | hasMarquee = true; |
---|
.. | .. |
---|
13776 | 14364 | |
---|
13777 | 14365 | public void mouseDragged(MouseEvent e) |
---|
13778 | 14366 | { |
---|
| 14367 | + Globals.MOUSEDRAGGED = true; |
---|
| 14368 | + |
---|
13779 | 14369 | //System.out.println("mouseDragged: " + e); |
---|
13780 | 14370 | if (isRenderer) |
---|
13781 | 14371 | movingcamera = true; |
---|
| 14372 | + |
---|
13782 | 14373 | //if (drawing) |
---|
13783 | 14374 | //return; |
---|
13784 | 14375 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14039 | 14630 | void GoDown(int mod) |
---|
14040 | 14631 | { |
---|
14041 | 14632 | MODIFIERS |= COMMAND; |
---|
14042 | | - /* |
---|
| 14633 | + /**/ |
---|
14043 | 14634 | if((mod&SHIFT) == SHIFT) |
---|
14044 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14635 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
14045 | 14636 | else |
---|
14046 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14047 | | - */ |
---|
| 14637 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14638 | + /**/ |
---|
14048 | 14639 | if ((mod & SHIFT) == SHIFT) |
---|
14049 | 14640 | { |
---|
14050 | 14641 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14060 | 14651 | void GoUp(int mod) |
---|
14061 | 14652 | { |
---|
14062 | 14653 | MODIFIERS |= COMMAND; |
---|
14063 | | - /* |
---|
| 14654 | + /**/ |
---|
14064 | 14655 | if((mod&SHIFT) == SHIFT) |
---|
14065 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14656 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
14066 | 14657 | else |
---|
14067 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14068 | | - */ |
---|
| 14658 | + manipCamera.RotatePosition(0, speed); |
---|
| 14659 | + /**/ |
---|
14069 | 14660 | if ((mod & SHIFT) == SHIFT) |
---|
14070 | 14661 | { |
---|
14071 | 14662 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14081 | 14672 | void GoLeft(int mod) |
---|
14082 | 14673 | { |
---|
14083 | 14674 | MODIFIERS |= COMMAND; |
---|
14084 | | - /* |
---|
| 14675 | + /**/ |
---|
14085 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14086 | | - manipCamera.RotatePosition(speed, 0); |
---|
14087 | | - else |
---|
14088 | 14677 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14089 | | - */ |
---|
| 14678 | + else |
---|
| 14679 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14680 | + /**/ |
---|
14090 | 14681 | if ((mod & SHIFT) == SHIFT) |
---|
14091 | 14682 | { |
---|
14092 | 14683 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14102 | 14693 | void GoRight(int mod) |
---|
14103 | 14694 | { |
---|
14104 | 14695 | MODIFIERS |= COMMAND; |
---|
14105 | | - /* |
---|
| 14696 | + /**/ |
---|
14106 | 14697 | if((mod&SHIFT) == SHIFT) |
---|
14107 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14108 | | - else |
---|
14109 | 14698 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14110 | | - */ |
---|
| 14699 | + else |
---|
| 14700 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14701 | + /**/ |
---|
14111 | 14702 | if ((mod & SHIFT) == SHIFT) |
---|
14112 | 14703 | { |
---|
14113 | 14704 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14157 | 14748 | if (editObj) |
---|
14158 | 14749 | { |
---|
14159 | 14750 | drag = true; |
---|
14160 | | - ClickInfo info = new ClickInfo(); |
---|
14161 | | - info.bounds.setBounds(0, 0, |
---|
| 14751 | + //ClickInfo info = new ClickInfo(); |
---|
| 14752 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14162 | 14753 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14163 | | - info.pane = this; |
---|
14164 | | - info.camera = renderCamera; |
---|
14165 | | - info.x = x; |
---|
14166 | | - info.y = y; |
---|
14167 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14754 | + object.clickInfo.pane = this; |
---|
| 14755 | + object.clickInfo.camera = renderCamera; |
---|
| 14756 | + object.clickInfo.x = x; |
---|
| 14757 | + object.clickInfo.y = y; |
---|
| 14758 | + object //.GetWindow().copy |
---|
| 14759 | + .doEditDrag(//info, |
---|
| 14760 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14168 | 14761 | } else |
---|
14169 | 14762 | { |
---|
14170 | 14763 | if (x < startX) |
---|
.. | .. |
---|
14313 | 14906 | } |
---|
14314 | 14907 | } |
---|
14315 | 14908 | |
---|
| 14909 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14910 | + |
---|
14316 | 14911 | public void mouseMoved(MouseEvent e) |
---|
14317 | 14912 | { |
---|
14318 | 14913 | //System.out.println("mouseMoved: " + e); |
---|
14319 | 14914 | if (isRenderer) |
---|
14320 | 14915 | return; |
---|
14321 | 14916 | |
---|
14322 | | - ClickInfo ci = new ClickInfo(); |
---|
14323 | | - ci.x = e.getX(); |
---|
14324 | | - ci.y = e.getY(); |
---|
14325 | | - ci.modifiers = e.getModifiersEx(); |
---|
14326 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14327 | | - ci.pane = this; |
---|
14328 | | - ci.camera = renderCamera; |
---|
| 14917 | + // Mouse cursor feedback |
---|
| 14918 | + object.clickInfo.x = e.getX(); |
---|
| 14919 | + object.clickInfo.y = e.getY(); |
---|
| 14920 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14921 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14922 | + object.clickInfo.pane = this; |
---|
| 14923 | + object.clickInfo.camera = renderCamera; |
---|
14329 | 14924 | if (!isRenderer) |
---|
14330 | 14925 | { |
---|
14331 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14926 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14927 | + //Object3D copy = editWindow.copy; |
---|
| 14928 | + if (object.doEditClick(//clickInfo, |
---|
| 14929 | + 0)) |
---|
14332 | 14930 | { |
---|
14333 | 14931 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14334 | 14932 | } else |
---|
.. | .. |
---|
14340 | 14938 | |
---|
14341 | 14939 | public void mouseReleased(MouseEvent e) |
---|
14342 | 14940 | { |
---|
| 14941 | + Globals.MOUSEDRAGGED = false; |
---|
| 14942 | + |
---|
14343 | 14943 | movingcamera = false; |
---|
| 14944 | + X = 0; // getBounds().width/2; |
---|
| 14945 | + Y = 0; // getBounds().height/2; |
---|
14344 | 14946 | //System.out.println("mouseReleased: " + e); |
---|
14345 | 14947 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14346 | 14948 | } |
---|
.. | .. |
---|
14596 | 15198 | // break; |
---|
14597 | 15199 | case 'T': |
---|
14598 | 15200 | CACHETEXTURE ^= true; |
---|
14599 | | - textures.clear(); |
---|
| 15201 | + texturepigment.clear(); |
---|
| 15202 | + texturebump.clear(); |
---|
14600 | 15203 | // repaint(); |
---|
14601 | 15204 | break; |
---|
14602 | 15205 | case 'Y': |
---|
.. | .. |
---|
14681 | 15284 | case 'E' : COMPACT ^= true; |
---|
14682 | 15285 | repaint(); |
---|
14683 | 15286 | break; |
---|
14684 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15287 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15288 | + //DEBUGHSB ^= true; |
---|
| 15289 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14685 | 15290 | repaint(); |
---|
14686 | 15291 | break; |
---|
14687 | 15292 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14706 | 15311 | RevertCamera(); |
---|
14707 | 15312 | repaint(); |
---|
14708 | 15313 | break; |
---|
14709 | | - case 'L': |
---|
14710 | 15314 | case 'l': |
---|
| 15315 | + //case 'L': |
---|
14711 | 15316 | if (lightMode) |
---|
14712 | 15317 | { |
---|
14713 | 15318 | lightMode = false; |
---|
.. | .. |
---|
14771 | 15376 | OCCLUSION_CULLING ^= true; |
---|
14772 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14773 | 15378 | break; |
---|
14774 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14775 | 15380 | case '1': |
---|
14776 | 15381 | case '2': |
---|
14777 | 15382 | case '3': |
---|
14778 | 15383 | case '4': |
---|
14779 | 15384 | case '5': |
---|
14780 | | - newenvy = Character.getNumericValue(key); |
---|
14781 | | - repaint(); |
---|
14782 | | - break; |
---|
14783 | 15385 | case '6': |
---|
14784 | 15386 | case '7': |
---|
14785 | 15387 | case '8': |
---|
14786 | 15388 | case '9': |
---|
14787 | | - BGcolor = (key - '6')/3.f; |
---|
| 15389 | + if (true) // envyoff) |
---|
| 15390 | + { |
---|
| 15391 | + BGcolor = (key - '1')/8.f; |
---|
| 15392 | + } |
---|
| 15393 | + else |
---|
| 15394 | + { |
---|
| 15395 | + //newenvy = Character.getNumericValue(key); |
---|
| 15396 | + } |
---|
14788 | 15397 | repaint(); |
---|
14789 | 15398 | break; |
---|
14790 | 15399 | case '!': |
---|
.. | .. |
---|
14850 | 15459 | case '_': |
---|
14851 | 15460 | kompactbit = 5; |
---|
14852 | 15461 | break; |
---|
14853 | | - case '+': |
---|
14854 | | - kompactbit = 6; |
---|
14855 | | - break; |
---|
| 15462 | +// case '+': |
---|
| 15463 | +// kompactbit = 6; |
---|
| 15464 | +// break; |
---|
14856 | 15465 | case ' ': |
---|
14857 | 15466 | lightMode ^= true; |
---|
14858 | 15467 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14864 | 15473 | case ESC: |
---|
14865 | 15474 | RENDERPROGRAM += 1; |
---|
14866 | 15475 | RENDERPROGRAM %= 3; |
---|
| 15476 | + |
---|
14867 | 15477 | repaint(); |
---|
14868 | 15478 | break; |
---|
14869 | 15479 | case 'Z': |
---|
.. | .. |
---|
14903 | 15513 | case DELETE: |
---|
14904 | 15514 | ClearSelection(); |
---|
14905 | 15515 | break; |
---|
14906 | | - /* |
---|
14907 | 15516 | case '+': |
---|
| 15517 | + |
---|
| 15518 | + /* |
---|
14908 | 15519 | //fontsize += 1; |
---|
14909 | 15520 | bbzoom *= 2; |
---|
14910 | 15521 | repaint(); |
---|
.. | .. |
---|
14921 | 15532 | case '=': |
---|
14922 | 15533 | IncDepth(); |
---|
14923 | 15534 | //fontsize += 1; |
---|
14924 | | - object.editWindow.refreshContents(true); |
---|
| 15535 | + object.GetWindow().refreshContents(true); |
---|
14925 | 15536 | maskbit = 6; |
---|
14926 | 15537 | break; |
---|
14927 | 15538 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14928 | 15539 | DecDepth(); |
---|
14929 | 15540 | maskbit = 5; |
---|
14930 | 15541 | //if(fontsize > 1) fontsize -= 1; |
---|
14931 | | - if (object.editWindow == null) |
---|
14932 | | - new Exception().printStackTrace(); |
---|
14933 | | - else |
---|
14934 | | - object.editWindow.refreshContents(true); |
---|
| 15542 | +// if (object.editWindow == null) |
---|
| 15543 | +// new Exception().printStackTrace(); |
---|
| 15544 | +// else |
---|
| 15545 | + object.GetWindow().refreshContents(true); |
---|
14935 | 15546 | break; |
---|
14936 | 15547 | case '{': |
---|
14937 | 15548 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15155 | 15766 | } |
---|
15156 | 15767 | */ |
---|
15157 | 15768 | |
---|
15158 | | - object.editWindow.EditSelection(); |
---|
| 15769 | + object.GetWindow().EditSelection(false); |
---|
15159 | 15770 | } |
---|
15160 | 15771 | |
---|
15161 | 15772 | void SelectParent() |
---|
.. | .. |
---|
15172 | 15783 | { |
---|
15173 | 15784 | //selectees.remove(i); |
---|
15174 | 15785 | System.out.println("select parent of " + elem); |
---|
15175 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15786 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15176 | 15787 | } else |
---|
15177 | 15788 | { |
---|
15178 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15789 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15179 | 15790 | } |
---|
15180 | 15791 | |
---|
15181 | 15792 | first = false; |
---|
.. | .. |
---|
15217 | 15828 | for (int j = 0; j < group.children.size(); j++) |
---|
15218 | 15829 | { |
---|
15219 | 15830 | elem = (Object3D) group.children.elementAt(j); |
---|
15220 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15831 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15221 | 15832 | first = false; |
---|
15222 | 15833 | } |
---|
15223 | 15834 | } else |
---|
15224 | 15835 | { |
---|
15225 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15836 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15226 | 15837 | } |
---|
15227 | 15838 | |
---|
15228 | 15839 | first = false; |
---|
.. | .. |
---|
15233 | 15844 | { |
---|
15234 | 15845 | //Composite group = (Composite) object; |
---|
15235 | 15846 | Object3D group = object; |
---|
15236 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15847 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15237 | 15848 | } |
---|
15238 | 15849 | |
---|
15239 | 15850 | void ResetTransform(int mask) |
---|
15240 | 15851 | { |
---|
15241 | 15852 | //Composite group = (Composite) object; |
---|
15242 | 15853 | Object3D group = object; |
---|
15243 | | - group.editWindow.ResetTransform(mask); |
---|
| 15854 | + group.GetWindow().ResetTransform(mask); |
---|
15244 | 15855 | } |
---|
15245 | 15856 | |
---|
15246 | 15857 | void FlipTransform() |
---|
15247 | 15858 | { |
---|
15248 | 15859 | //Composite group = (Composite) object; |
---|
15249 | 15860 | Object3D group = object; |
---|
15250 | | - group.editWindow.FlipTransform(); |
---|
| 15861 | + group.GetWindow().FlipTransform(); |
---|
15251 | 15862 | // group.editWindow.ReduceMesh(true); |
---|
15252 | 15863 | } |
---|
15253 | 15864 | |
---|
.. | .. |
---|
15255 | 15866 | { |
---|
15256 | 15867 | //Composite group = (Composite) object; |
---|
15257 | 15868 | Object3D group = object; |
---|
15258 | | - group.editWindow.PrintMemory(); |
---|
| 15869 | + group.GetWindow().PrintMemory(); |
---|
15259 | 15870 | // group.editWindow.ReduceMesh(true); |
---|
15260 | 15871 | } |
---|
15261 | 15872 | |
---|
.. | .. |
---|
15263 | 15874 | { |
---|
15264 | 15875 | //Composite group = (Composite) object; |
---|
15265 | 15876 | Object3D group = object; |
---|
15266 | | - group.editWindow.ResetCentroid(); |
---|
| 15877 | + group.GetWindow().ResetCentroid(); |
---|
15267 | 15878 | } |
---|
15268 | 15879 | |
---|
15269 | 15880 | void IncDepth() |
---|
.. | .. |
---|
15345 | 15956 | |
---|
15346 | 15957 | int width = getBounds().width; |
---|
15347 | 15958 | int height = getBounds().height; |
---|
15348 | | - ClickInfo info = new ClickInfo(); |
---|
15349 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15350 | 15959 | //Image img = CreateImage(width, height); |
---|
15351 | 15960 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15961 | + |
---|
15352 | 15962 | Graphics gr = g; // img.getGraphics(); |
---|
| 15963 | + |
---|
15353 | 15964 | if (!hasMarquee) |
---|
15354 | 15965 | { |
---|
15355 | 15966 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15421 | 16032 | } |
---|
15422 | 16033 | if (object != null && !hasMarquee) |
---|
15423 | 16034 | { |
---|
| 16035 | + if (object.clickInfo == null) |
---|
| 16036 | + object.clickInfo = new ClickInfo(); |
---|
| 16037 | + ClickInfo info = object.clickInfo; |
---|
| 16038 | + //ClickInfo info = new ClickInfo(); |
---|
| 16039 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16040 | + |
---|
15424 | 16041 | if (isRenderer) |
---|
15425 | 16042 | { |
---|
15426 | | - info.flags++; |
---|
| 16043 | + object.clickInfo.flags++; |
---|
15427 | 16044 | double frameAspect = (double) width / (double) height; |
---|
15428 | 16045 | if (frameAspect > renderCamera.aspect) |
---|
15429 | 16046 | { |
---|
15430 | 16047 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15431 | | - info.bounds.width -= width - desired; |
---|
15432 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16048 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16049 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15433 | 16050 | } else |
---|
15434 | 16051 | { |
---|
15435 | 16052 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15436 | | - info.bounds.height -= height - desired; |
---|
15437 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16053 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16054 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15438 | 16055 | } |
---|
15439 | 16056 | } |
---|
15440 | | - info.g = gr; |
---|
15441 | | - info.camera = renderCamera; |
---|
| 16057 | + |
---|
| 16058 | + object.clickInfo.g = gr; |
---|
| 16059 | + object.clickInfo.camera = renderCamera; |
---|
15442 | 16060 | /* |
---|
15443 | 16061 | // Memory intensive (brep.verticescopy) |
---|
15444 | 16062 | if (!(object instanceof Composite)) |
---|
15445 | 16063 | object.draw(info, 0, false); // SLOW : |
---|
15446 | 16064 | */ |
---|
15447 | | - if (!isRenderer) |
---|
| 16065 | + if (!isRenderer) // && drag) |
---|
15448 | 16066 | { |
---|
15449 | | - object.drawEditHandles(info, 0); |
---|
| 16067 | + Grafreed.Assert(object != null); |
---|
| 16068 | + Grafreed.Assert(object.selection != null); |
---|
| 16069 | + if (object.selection.Size() > 0) |
---|
| 16070 | + { |
---|
| 16071 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16072 | + |
---|
| 16073 | + object.clickInfo.DX = 0; |
---|
| 16074 | + object.clickInfo.DY = 0; |
---|
| 16075 | + object.clickInfo.W = 1; |
---|
| 16076 | + if (hitSomething == Object3D.hitCenter) |
---|
| 16077 | + { |
---|
| 16078 | + info.DX = X; |
---|
| 16079 | + if (X != 0) |
---|
| 16080 | + info.DX -= info.bounds.width/2; |
---|
| 16081 | + |
---|
| 16082 | + info.DY = Y; |
---|
| 16083 | + if (Y != 0) |
---|
| 16084 | + info.DY -= info.bounds.height/2; |
---|
| 16085 | + } |
---|
| 16086 | + |
---|
| 16087 | + object.drawEditHandles(//info, |
---|
| 16088 | + 0); |
---|
| 16089 | + |
---|
| 16090 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16091 | + { |
---|
| 16092 | + switch (hitSomething) |
---|
| 16093 | + { |
---|
| 16094 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16095 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16096 | + break; |
---|
| 16097 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16098 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16099 | + break; |
---|
| 16100 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16102 | + break; |
---|
| 16103 | + } |
---|
| 16104 | + |
---|
| 16105 | + } |
---|
| 16106 | + } |
---|
15450 | 16107 | } |
---|
15451 | 16108 | } |
---|
| 16109 | + |
---|
15452 | 16110 | if (isRenderer) |
---|
15453 | 16111 | { |
---|
15454 | 16112 | //gr.setColor(Color.black); |
---|
15455 | 16113 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15456 | 16114 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15457 | 16115 | } |
---|
| 16116 | + |
---|
15458 | 16117 | if (hasMarquee) |
---|
15459 | 16118 | { |
---|
15460 | 16119 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15861 | 16520 | Object3D object; |
---|
15862 | 16521 | static Object3D trackedobject; |
---|
15863 | 16522 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15864 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16523 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15865 | 16524 | /*static*/ Camera eyeCamera; |
---|
15866 | 16525 | /*static*/ Camera lightCamera; |
---|
15867 | 16526 | int cameracount; |
---|
.. | .. |
---|
15925 | 16584 | private /*static*/ boolean firstime; |
---|
15926 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
15927 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15928 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15929 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15930 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15937 | 16598 | { |
---|
15938 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15939 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
15940 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
15941 | 16604 | { |
---|
15942 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15943 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15944 | | - mipmapped, |
---|
15945 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15946 | | - if (data == null) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
15947 | 16610 | { |
---|
15948 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
15949 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
15950 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
15951 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
15952 | 16646 | } |
---|
15953 | 16647 | |
---|
15954 | 16648 | return cubemap; |
---|
15955 | 16649 | } |
---|
| 16650 | + |
---|
15956 | 16651 | int bigsphere = -1; |
---|
15957 | 16652 | |
---|
15958 | 16653 | float BGcolor = 0.5f; |
---|
15959 | 16654 | |
---|
15960 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
15961 | 16658 | { |
---|
15962 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
15963 | 16661 | { |
---|
15964 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
15965 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
15974 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
15975 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
15976 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
15977 | 16676 | |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16685 | + |
---|
15978 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
15979 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
15980 | 16688 | |
---|
.. | .. |
---|
16006 | 16714 | { |
---|
16007 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16008 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16009 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16010 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16011 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16146 | 16855 | cStatic.objectstack[materialdepth++] = checker; |
---|
16147 | 16856 | //System.out.println("material " + material); |
---|
16148 | 16857 | //Applet3D.tracein(this, selected); |
---|
16149 | | - vector2buffer = checker.projectedVertices; |
---|
| 16858 | + //vector2buffer = checker.projectedVertices; |
---|
16150 | 16859 | |
---|
16151 | 16860 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16152 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16861 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16153 | 16862 | |
---|
16154 | 16863 | materialdepth -= 1; |
---|
16155 | 16864 | if (materialdepth > 0) |
---|
16156 | 16865 | { |
---|
16157 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16158 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16866 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16867 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16159 | 16868 | } |
---|
16160 | 16869 | //checker.GetMaterial().opacity = 1f; |
---|
16161 | 16870 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16241 | 16950 | } |
---|
16242 | 16951 | } |
---|
16243 | 16952 | |
---|
| 16953 | + private Object3D GetFolder() |
---|
| 16954 | + { |
---|
| 16955 | + Object3D folder = object.GetWindow().copy; |
---|
| 16956 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16957 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16958 | + return folder; |
---|
| 16959 | + } |
---|
| 16960 | + |
---|
16244 | 16961 | class SelectBuffer implements GLEventListener |
---|
16245 | 16962 | { |
---|
16246 | 16963 | |
---|
.. | .. |
---|
16256 | 16973 | //new Exception().printStackTrace(); |
---|
16257 | 16974 | System.out.println("select buffer init"); |
---|
16258 | 16975 | // Use debug pipeline |
---|
16259 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16260 | 16977 | |
---|
16261 | 16978 | GL gl = drawable.getGL(); |
---|
16262 | 16979 | |
---|
.. | .. |
---|
16320 | 17037 | |
---|
16321 | 17038 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16322 | 17039 | |
---|
| 17040 | + if (PAINTMODE) |
---|
| 17041 | + { |
---|
| 17042 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17043 | + { |
---|
| 17044 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17045 | + |
---|
| 17046 | + // Make what you paint not selectable. |
---|
| 17047 | + paintobj.ResetSelectable(); |
---|
| 17048 | + } |
---|
| 17049 | + } |
---|
| 17050 | + |
---|
16323 | 17051 | //int tmp = selection_view; |
---|
16324 | 17052 | //selection_view = -1; |
---|
16325 | 17053 | int temp = DrawMode(); |
---|
.. | .. |
---|
16331 | 17059 | // temp = DEFAULT; // patch for selection debug |
---|
16332 | 17060 | Globals.drawMode = temp; // WARNING |
---|
16333 | 17061 | |
---|
| 17062 | + if (PAINTMODE) |
---|
| 17063 | + { |
---|
| 17064 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17065 | + { |
---|
| 17066 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17067 | + |
---|
| 17068 | + // Revert. |
---|
| 17069 | + paintobj.RestoreSelectable(); |
---|
| 17070 | + } |
---|
| 17071 | + } |
---|
| 17072 | + |
---|
16334 | 17073 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16335 | 17074 | |
---|
16336 | 17075 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16378 | 17117 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16379 | 17118 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16380 | 17119 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17120 | + |
---|
| 17121 | + CreateSelectedPoint(); |
---|
16381 | 17122 | |
---|
16382 | 17123 | // Will fit the mesh !!! |
---|
16383 | 17124 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16432 | 17173 | } |
---|
16433 | 17174 | |
---|
16434 | 17175 | if (!movingcamera && !PAINTMODE) |
---|
16435 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17176 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16436 | 17177 | |
---|
16437 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17178 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16438 | 17179 | { |
---|
16439 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17180 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16440 | 17181 | |
---|
16441 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17182 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17183 | + { |
---|
| 17184 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16442 | 17185 | |
---|
16443 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16444 | | - |
---|
16445 | | - group.add(paintobj); // link |
---|
16446 | | - |
---|
16447 | | - object.editWindow.SnapObject(group); |
---|
16448 | | - |
---|
16449 | | - Object3D folder = object.editWindow.copy; |
---|
16450 | | - |
---|
16451 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16452 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16453 | | - |
---|
16454 | | - folder.add(group); |
---|
16455 | | - |
---|
16456 | | - object.editWindow.ResetModel(); |
---|
16457 | | - object.editWindow.refreshContents(); |
---|
| 17186 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17187 | + |
---|
| 17188 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17189 | + |
---|
| 17190 | + inst.add(paintobj); // link |
---|
| 17191 | + |
---|
| 17192 | + object.GetWindow().SnapObject(inst); |
---|
| 17193 | + |
---|
| 17194 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17195 | + |
---|
| 17196 | + folder.add(inst); |
---|
| 17197 | + |
---|
| 17198 | + object.GetWindow().ResetModel(); |
---|
| 17199 | + object.GetWindow().refreshContents(); |
---|
| 17200 | + } |
---|
16458 | 17201 | } |
---|
16459 | 17202 | else |
---|
16460 | 17203 | paintcount = 0; |
---|
.. | .. |
---|
16493 | 17236 | //System.out.println("objects[color] = " + objects[color]); |
---|
16494 | 17237 | //objects[color].Select(); |
---|
16495 | 17238 | indexcount = 0; |
---|
| 17239 | + ObjEditor window = object.GetWindow(); |
---|
| 17240 | + if (window != null && deselect) |
---|
| 17241 | + { |
---|
| 17242 | + window.Select(null, deselect, true); |
---|
| 17243 | + } |
---|
16496 | 17244 | object.Select(color, deselect); |
---|
16497 | 17245 | } |
---|
16498 | 17246 | |
---|
.. | .. |
---|
16602 | 17350 | //gl.glColorMask(false, false, false, false); |
---|
16603 | 17351 | |
---|
16604 | 17352 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16605 | | - if (Globals.RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17353 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16606 | 17354 | { |
---|
16607 | 17355 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16608 | 17356 | |
---|
.. | .. |
---|
17018 | 17766 | int AAbuffersize = 0; |
---|
17019 | 17767 | |
---|
17020 | 17768 | //double[] selectedpoint = new double[3]; |
---|
17021 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17769 | + static Superellipsoid selectedpoint; |
---|
17022 | 17770 | static Sphere previousselectedpoint = null; |
---|
17023 | | - static Sphere debugpointG = new Sphere(); |
---|
17024 | | - static Sphere debugpointP = new Sphere(); |
---|
17025 | | - static Sphere debugpointC = new Sphere(); |
---|
17026 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17771 | + static Sphere debugpointG; |
---|
| 17772 | + static Sphere debugpointP; |
---|
| 17773 | + static Sphere debugpointC; |
---|
| 17774 | + static Sphere debugpointR; |
---|
17027 | 17775 | |
---|
17028 | 17776 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17029 | 17777 | |
---|
17030 | | - static |
---|
17031 | | - { |
---|
17032 | | - for (int i=0; i<8; i++) |
---|
17033 | | - { |
---|
17034 | | - debugpoints[i] = new Sphere(); |
---|
17035 | | - } |
---|
17036 | | - } |
---|
17037 | | - |
---|
17038 | 17778 | static void InitPoints(float radius) |
---|
17039 | 17779 | { |
---|
17040 | 17780 | for (int i=0; i<8; i++) |
---|