.. | .. |
---|
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() |
---|
.. | .. |
---|
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) |
---|
.. | .. |
---|
8024 | 8203 | |
---|
8025 | 8204 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8026 | 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 |
---|
| 8253 | + { |
---|
8027 | 8254 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8028 | 8255 | ambientOcclusion ) // || !textureon) |
---|
8029 | 8256 | { |
---|
.. | .. |
---|
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) throws Exception |
---|
| 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) && !texname.startsWith("@")) |
---|
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(); |
---|
| 8442 | + } else |
---|
| 8443 | + { |
---|
| 8444 | + if (texname.startsWith("@")) |
---|
| 8445 | + { |
---|
| 8446 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8447 | + if (texturecache == null) |
---|
| 8448 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8449 | + else |
---|
| 8450 | + new Exception().printStackTrace(); |
---|
8132 | 8451 | } else |
---|
8133 | 8452 | { |
---|
8134 | 8453 | if (textureon) |
---|
.. | .. |
---|
8153 | 8472 | } |
---|
8154 | 8473 | |
---|
8155 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8156 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
8157 | 8476 | cachename = texname; |
---|
8158 | 8477 | else |
---|
8159 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8175 | 8494 | } |
---|
8176 | 8495 | |
---|
8177 | 8496 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8178 | | - if (!new File(cachename).exists()) |
---|
| 8497 | + if (!FileExists(cachename)) |
---|
8179 | 8498 | cachename = texname; |
---|
8180 | 8499 | else |
---|
8181 | 8500 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8187 | 8506 | if (texturedata == null) |
---|
8188 | 8507 | throw new Exception(); |
---|
8189 | 8508 | |
---|
8190 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8509 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8191 | 8510 | //texture = GetTexture(tex, bump); |
---|
8192 | 8511 | } |
---|
| 8512 | + } |
---|
8193 | 8513 | } |
---|
8194 | 8514 | //} |
---|
8195 | 8515 | } |
---|
8196 | 8516 | |
---|
8197 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8517 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8198 | 8518 | { |
---|
8199 | 8519 | //return false; |
---|
8200 | 8520 | |
---|
8201 | 8521 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8202 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8522 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8203 | 8523 | { |
---|
8204 | 8524 | // String ext = "_highres"; |
---|
8205 | 8525 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8216 | 8536 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8217 | 8537 | if (!cachefile.exists()) |
---|
8218 | 8538 | { |
---|
8219 | | - // cache to disk |
---|
8220 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8221 | | - //buffers[0]. |
---|
8222 | | - |
---|
8223 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8224 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8225 | | - |
---|
8226 | | - // squared size heuristic... |
---|
8227 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8539 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8228 | 8540 | { |
---|
8229 | | - for (int i=pixels.length; --i>=0;) |
---|
8230 | | - { |
---|
8231 | | - int i3 = i*3; |
---|
8232 | | - pixels[i] = 0xFF; |
---|
8233 | | - pixels[i] <<= 8; |
---|
8234 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8235 | | - pixels[i] <<= 8; |
---|
8236 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8237 | | - pixels[i] <<= 8; |
---|
8238 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8239 | | - } |
---|
8240 | | - |
---|
8241 | | - /* |
---|
8242 | | - int r=0,g=0,b=0,a=0; |
---|
8243 | | - for (int i=0; i<width; i++) |
---|
8244 | | - for (int j=0; j<height; j++) |
---|
8245 | | - { |
---|
8246 | | - int index = j*width+i; |
---|
8247 | | - int p = pixels[index]; |
---|
8248 | | - a = ((p>>24) & 0xFF); |
---|
8249 | | - r = ((p>>16) & 0xFF); |
---|
8250 | | - g = ((p>>8) & 0xFF); |
---|
8251 | | - b = (p & 0xFF); |
---|
8252 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8253 | | - } |
---|
8254 | | - /**/ |
---|
8255 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8256 | | - int height = width; |
---|
8257 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8258 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8541 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8542 | + |
---|
8259 | 8543 | ImageWriter writer = null; |
---|
8260 | 8544 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8261 | 8545 | if (iter.hasNext()) { |
---|
8262 | 8546 | writer = (ImageWriter)iter.next(); |
---|
8263 | 8547 | } |
---|
8264 | | - float compressionQuality = 0.9f; |
---|
| 8548 | + |
---|
| 8549 | + float compressionQuality = 0.85f; |
---|
8265 | 8550 | try |
---|
8266 | 8551 | { |
---|
8267 | 8552 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8278 | 8563 | } |
---|
8279 | 8564 | } |
---|
8280 | 8565 | } |
---|
8281 | | - |
---|
| 8566 | + |
---|
| 8567 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8568 | + |
---|
8282 | 8569 | //System.out.println("Texture = " + tex); |
---|
8283 | | - if (textures.containsKey(texname)) |
---|
| 8570 | + if (textures.containsKey(tex)) |
---|
8284 | 8571 | { |
---|
8285 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8572 | + CacheTexture thetex = textures.get(tex); |
---|
8286 | 8573 | thetex.texture.disable(); |
---|
8287 | 8574 | thetex.texture.dispose(); |
---|
8288 | | - textures.remove(texname); |
---|
| 8575 | + textures.remove(tex); |
---|
8289 | 8576 | } |
---|
8290 | 8577 | |
---|
8291 | | - texture.texturedata = texturedata; |
---|
8292 | | - textures.put(texname, texture); |
---|
| 8578 | + //texture.texturedata = texturedata; |
---|
| 8579 | + textures.put(tex, texturecache); |
---|
8293 | 8580 | |
---|
8294 | 8581 | // newtex = true; |
---|
8295 | 8582 | } |
---|
.. | .. |
---|
8305 | 8592 | } |
---|
8306 | 8593 | } |
---|
8307 | 8594 | |
---|
8308 | | - return texture; |
---|
| 8595 | + return texturecache; |
---|
8309 | 8596 | } |
---|
8310 | 8597 | |
---|
8311 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8598 | + static void EmbedTextures(cTexture tex) |
---|
| 8599 | + { |
---|
| 8600 | + if (tex.pigmentdata == null) |
---|
| 8601 | + { |
---|
| 8602 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8603 | + |
---|
| 8604 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8605 | + |
---|
| 8606 | + if (texturecache != null) |
---|
| 8607 | + { |
---|
| 8608 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8609 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8610 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8611 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8612 | + ; |
---|
| 8613 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8614 | + } |
---|
| 8615 | + } |
---|
| 8616 | + |
---|
| 8617 | + if (tex.bumpdata == null) |
---|
| 8618 | + { |
---|
| 8619 | + //String texname = Object3D.GetBump(tex); |
---|
| 8620 | + |
---|
| 8621 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8622 | + |
---|
| 8623 | + if (texturecache != null) |
---|
| 8624 | + { |
---|
| 8625 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8626 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8627 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8628 | + } |
---|
| 8629 | + } |
---|
| 8630 | + } |
---|
| 8631 | + |
---|
| 8632 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8312 | 8633 | { |
---|
8313 | 8634 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8314 | 8635 | |
---|
.. | .. |
---|
8326 | 8647 | return texture!=null?texture.texture:null; |
---|
8327 | 8648 | } |
---|
8328 | 8649 | |
---|
8329 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8650 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8330 | 8651 | { |
---|
8331 | 8652 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8332 | 8653 | |
---|
8333 | 8654 | return texture!=null?texture.texturedata:null; |
---|
8334 | 8655 | } |
---|
8335 | 8656 | |
---|
8336 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8657 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8337 | 8658 | { |
---|
8338 | 8659 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8339 | 8660 | { |
---|
8340 | 8661 | return false; |
---|
8341 | 8662 | } |
---|
8342 | 8663 | |
---|
8343 | | - boolean newtex = false; |
---|
| 8664 | + //boolean newtex = false; |
---|
8344 | 8665 | |
---|
8345 | 8666 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8346 | 8667 | |
---|
.. | .. |
---|
8372 | 8693 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8373 | 8694 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8374 | 8695 | |
---|
8375 | | - return newtex; |
---|
| 8696 | + return true; // Warning: not used. |
---|
8376 | 8697 | } |
---|
8377 | 8698 | |
---|
| 8699 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8700 | + { |
---|
| 8701 | + try |
---|
| 8702 | + { |
---|
| 8703 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8704 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8705 | + ImageWriter writer = writers.next(); |
---|
| 8706 | + |
---|
| 8707 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8708 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8709 | + param.setCompressionQuality(quality); |
---|
| 8710 | + |
---|
| 8711 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8712 | + writer.setOutput(ios); |
---|
| 8713 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8714 | + |
---|
| 8715 | + byte[] data = baos.toByteArray(); |
---|
| 8716 | + writer.dispose(); |
---|
| 8717 | + return data; |
---|
| 8718 | + } |
---|
| 8719 | + catch (Exception e) |
---|
| 8720 | + { |
---|
| 8721 | + e.printStackTrace(); |
---|
| 8722 | + return null; |
---|
| 8723 | + } |
---|
| 8724 | + } |
---|
| 8725 | + |
---|
| 8726 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8727 | + { |
---|
| 8728 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8729 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8730 | + ImageReader reader = writers.next(); |
---|
| 8731 | + |
---|
| 8732 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8733 | + |
---|
| 8734 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8735 | + param.setDestination(bim); |
---|
| 8736 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8737 | + |
---|
| 8738 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8739 | + reader.setInput(ios); |
---|
| 8740 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8741 | + reader.dispose(); |
---|
| 8742 | + |
---|
| 8743 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8744 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8745 | +// byte[] bytes = data.getData(); |
---|
| 8746 | +// |
---|
| 8747 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8748 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8749 | +// { |
---|
| 8750 | +// int i3 = i*3; |
---|
| 8751 | +// pixels[i] = 0xFF; |
---|
| 8752 | +// pixels[i] <<= 8; |
---|
| 8753 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8754 | +// pixels[i] <<= 8; |
---|
| 8755 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8756 | +// pixels[i] <<= 8; |
---|
| 8757 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8758 | +// } |
---|
| 8759 | +// |
---|
| 8760 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8761 | + |
---|
| 8762 | + return bim; |
---|
| 8763 | + } |
---|
| 8764 | + |
---|
8378 | 8765 | ShadowBuffer shadowPBuf; |
---|
8379 | 8766 | AntialiasBuffer antialiasPBuf; |
---|
8380 | 8767 | int MAXSTACK; |
---|
.. | .. |
---|
8567 | 8954 | |
---|
8568 | 8955 | if (cubemap == null) |
---|
8569 | 8956 | { |
---|
8570 | | - LoadEnvy(5); |
---|
| 8957 | + //LoadEnvy(1); |
---|
8571 | 8958 | } |
---|
8572 | 8959 | |
---|
8573 | 8960 | //cubemap.enable(); |
---|
.. | .. |
---|
8854 | 9241 | cubemap = null; |
---|
8855 | 9242 | return; |
---|
8856 | 9243 | case 1: |
---|
8857 | | - name = "cubemaps/box_"; |
---|
8858 | | - ext = "png"; |
---|
| 9244 | + name = "cubemaps/rgb/"; |
---|
| 9245 | + ext = "jpg"; |
---|
8859 | 9246 | reverseUP = false; |
---|
8860 | 9247 | break; |
---|
8861 | 9248 | case 2: |
---|
8862 | | - name = "cubemaps/uffizi_"; |
---|
8863 | | - ext = "png"; |
---|
8864 | | - break; // reverseUP = true; break; |
---|
| 9249 | + name = "cubemaps/uffizi/"; |
---|
| 9250 | + ext = "jpg"; |
---|
| 9251 | + reverseUP = false; |
---|
| 9252 | + break; |
---|
8865 | 9253 | case 3: |
---|
8866 | | - name = "cubemaps/CloudyHills_"; |
---|
8867 | | - ext = "tga"; |
---|
| 9254 | + name = "cubemaps/CloudyHills/"; |
---|
| 9255 | + ext = "jpg"; |
---|
8868 | 9256 | reverseUP = false; |
---|
8869 | 9257 | break; |
---|
8870 | 9258 | case 4: |
---|
8871 | | - name = "cubemaps/cornell_"; |
---|
| 9259 | + name = "cubemaps/cornell/"; |
---|
8872 | 9260 | ext = "png"; |
---|
8873 | 9261 | reverseUP = false; |
---|
8874 | 9262 | break; |
---|
| 9263 | + case 5: |
---|
| 9264 | + name = "cubemaps/skycube/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 6: |
---|
| 9269 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 7: |
---|
| 9274 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 8: |
---|
| 9279 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 9: |
---|
| 9284 | + name = "cubemaps/UnionSquare/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
8875 | 9288 | default: |
---|
8876 | | - name = "cubemaps/rgb_"; |
---|
8877 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9289 | + name = "cubemaps/box/"; |
---|
| 9290 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9291 | + reverseUP = false; |
---|
8878 | 9292 | break; |
---|
8879 | 9293 | } |
---|
8880 | | - |
---|
8881 | | - try |
---|
8882 | | - { |
---|
8883 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
8884 | | - } catch (IOException e) |
---|
8885 | | - { |
---|
8886 | | - throw new RuntimeException(e); |
---|
8887 | | - } |
---|
| 9294 | + |
---|
| 9295 | + LoadSkybox(name, ext, mipmap); |
---|
8888 | 9296 | } |
---|
8889 | 9297 | |
---|
8890 | 9298 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
8916 | 9324 | static double[] model = new double[16]; |
---|
8917 | 9325 | double[] camera2light = new double[16]; |
---|
8918 | 9326 | double[] light2camera = new double[16]; |
---|
8919 | | - int newenvy = -1; |
---|
8920 | | - boolean envyoff = true; // false; |
---|
| 9327 | + |
---|
| 9328 | + //int newenvy = -1; |
---|
| 9329 | + //boolean envyoff = false; |
---|
| 9330 | + |
---|
| 9331 | + String loadedskyboxname; |
---|
| 9332 | + |
---|
8921 | 9333 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
8922 | 9334 | //float[] light0 = { 0,0,0 }; |
---|
8923 | 9335 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9210 | 9622 | jy8[3] = 0.5f; |
---|
9211 | 9623 | } |
---|
9212 | 9624 | |
---|
9213 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9625 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9214 | 9626 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9215 | 9627 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9216 | 9628 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9217 | 9629 | |
---|
| 9630 | + void ResetOptions() |
---|
| 9631 | + { |
---|
| 9632 | + options1[0] = 100; |
---|
| 9633 | + options1[1] = 0.025f; |
---|
| 9634 | + options1[2] = 0.01f; |
---|
| 9635 | + options1[3] = 0; |
---|
| 9636 | + options1[4] = 0; |
---|
| 9637 | + |
---|
| 9638 | + options2[0] = 0; |
---|
| 9639 | + options2[1] = 0.75f; |
---|
| 9640 | + options2[2] = 0; |
---|
| 9641 | + options2[3] = 0; |
---|
| 9642 | + |
---|
| 9643 | + options3[0] = 1; |
---|
| 9644 | + options3[1] = 1; |
---|
| 9645 | + options3[2] = 1; |
---|
| 9646 | + options3[3] = 0; |
---|
| 9647 | + |
---|
| 9648 | + options4[0] = 1; |
---|
| 9649 | + options4[1] = 0; |
---|
| 9650 | + options4[2] = 1; |
---|
| 9651 | + options4[3] = 0; |
---|
| 9652 | + } |
---|
| 9653 | + |
---|
9218 | 9654 | static int imagecount = 0; // movie generation |
---|
9219 | 9655 | |
---|
9220 | 9656 | static int jitter = 0; |
---|
.. | .. |
---|
9310 | 9746 | assert (parentcam != renderCamera); |
---|
9311 | 9747 | |
---|
9312 | 9748 | if (renderCamera != lightCamera) |
---|
9313 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9314 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9749 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9750 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9315 | 9751 | |
---|
9316 | 9752 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9317 | 9753 | |
---|
.. | .. |
---|
9326 | 9762 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9327 | 9763 | |
---|
9328 | 9764 | if (renderCamera != lightCamera) |
---|
9329 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9330 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9765 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9766 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9331 | 9767 | |
---|
9332 | 9768 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9333 | 9769 | |
---|
.. | .. |
---|
9373 | 9809 | rati = 1 / rati; |
---|
9374 | 9810 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9375 | 9811 | } |
---|
9376 | | - assert (newenvy == -1); |
---|
| 9812 | + |
---|
| 9813 | + //assert (newenvy == -1); |
---|
| 9814 | + |
---|
9377 | 9815 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9378 | 9816 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9379 | | - DrawSkyBox(gl); |
---|
| 9817 | + DrawSkyBox(gl, (float)rati); |
---|
9380 | 9818 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9381 | 9819 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9382 | 9820 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10325 | 10763 | ANTIALIAS = 0; |
---|
10326 | 10764 | //System.out.println("RESTART"); |
---|
10327 | 10765 | AAtimer.restart(); |
---|
| 10766 | + Globals.TIMERRUNNING = true; |
---|
10328 | 10767 | } |
---|
10329 | 10768 | } |
---|
10330 | 10769 | } |
---|
.. | .. |
---|
10392 | 10831 | ambientOcclusion = false; |
---|
10393 | 10832 | } |
---|
10394 | 10833 | |
---|
10395 | | - if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
| 10834 | + if (//Globals.lighttouched && |
---|
| 10835 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10396 | 10836 | { |
---|
10397 | 10837 | //if (RENDERSHADOW) // ? |
---|
10398 | 10838 | if (!IsFrozen()) |
---|
.. | .. |
---|
10411 | 10851 | |
---|
10412 | 10852 | if (wait) |
---|
10413 | 10853 | { |
---|
10414 | | - Sleep(500); |
---|
| 10854 | + Sleep(200); // blocks everything |
---|
10415 | 10855 | |
---|
10416 | 10856 | wait = false; |
---|
10417 | 10857 | } |
---|
.. | .. |
---|
10525 | 10965 | |
---|
10526 | 10966 | // if (parentcam != renderCamera) // not a light |
---|
10527 | 10967 | if (cam != lightCamera) |
---|
10528 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10529 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10968 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10969 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10530 | 10970 | |
---|
10531 | 10971 | for (int j = 0; j < 4; j++) |
---|
10532 | 10972 | { |
---|
.. | .. |
---|
10540 | 10980 | |
---|
10541 | 10981 | // if (parentcam != renderCamera) // not a light |
---|
10542 | 10982 | if (cam != lightCamera) |
---|
10543 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10544 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10983 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10984 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10545 | 10985 | |
---|
10546 | 10986 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10547 | 10987 | |
---|
.. | .. |
---|
10627 | 11067 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10628 | 11068 | } |
---|
10629 | 11069 | |
---|
10630 | | - if (newenvy > -1) |
---|
| 11070 | +// if (newenvy > -1) |
---|
| 11071 | +// { |
---|
| 11072 | +// LoadEnvy(newenvy); |
---|
| 11073 | +// } |
---|
| 11074 | +// |
---|
| 11075 | +// newenvy = -1; |
---|
| 11076 | + |
---|
| 11077 | + if (object.skyboxname != null) |
---|
10631 | 11078 | { |
---|
10632 | | - LoadEnvy(newenvy); |
---|
| 11079 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11080 | + { |
---|
| 11081 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11082 | + loadedskyboxname = object.skyboxname; |
---|
| 11083 | + } |
---|
10633 | 11084 | } |
---|
10634 | | - |
---|
10635 | | - newenvy = -1; |
---|
10636 | | - |
---|
| 11085 | + else |
---|
| 11086 | + { |
---|
| 11087 | + cubemap = null; |
---|
| 11088 | + loadedskyboxname = null; |
---|
| 11089 | + } |
---|
| 11090 | + |
---|
10637 | 11091 | ratio = ((double) getWidth()) / getHeight(); |
---|
10638 | 11092 | //System.out.println("ratio = " + ratio); |
---|
10639 | 11093 | |
---|
.. | .. |
---|
10649 | 11103 | |
---|
10650 | 11104 | if (!IsFrozen() && !ambientOcclusion) |
---|
10651 | 11105 | { |
---|
10652 | | - DrawSkyBox(gl); |
---|
| 11106 | + DrawSkyBox(gl, (float)ratio); |
---|
10653 | 11107 | } |
---|
10654 | 11108 | |
---|
10655 | 11109 | //if (selection_view == -1) |
---|
.. | .. |
---|
10832 | 11286 | |
---|
10833 | 11287 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10834 | 11288 | |
---|
10835 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10836 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10837 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11289 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11290 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11291 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10838 | 11292 | } else |
---|
10839 | 11293 | { |
---|
10840 | 11294 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10845 | 11299 | //System.out.println("BLENDING ON"); |
---|
10846 | 11300 | gl.glEnable(GL.GL_BLEND); |
---|
10847 | 11301 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10848 | | - |
---|
| 11302 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10849 | 11303 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10850 | 11304 | gl.glLoadIdentity(); |
---|
10851 | 11305 | |
---|
.. | .. |
---|
10934 | 11388 | System.err.println("parentcam != renderCamera"); |
---|
10935 | 11389 | |
---|
10936 | 11390 | // if (cam != lightCamera) |
---|
10937 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10938 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11391 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11392 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
10939 | 11393 | } |
---|
10940 | 11394 | |
---|
10941 | 11395 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10956 | 11410 | if (true) // TODO |
---|
10957 | 11411 | { |
---|
10958 | 11412 | if (cam != lightCamera) |
---|
10959 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10960 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11413 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11414 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10961 | 11415 | } |
---|
10962 | 11416 | |
---|
10963 | 11417 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11094 | 11548 | } |
---|
11095 | 11549 | } |
---|
11096 | 11550 | |
---|
11097 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11551 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11098 | 11552 | { |
---|
11099 | 11553 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11100 | 11554 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11102 | 11556 | |
---|
11103 | 11557 | boolean texon = textureon; |
---|
11104 | 11558 | |
---|
11105 | | - if (RENDERPROGRAM > 0) |
---|
11106 | | - { |
---|
11107 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11108 | | - textureon = false; |
---|
11109 | | - } |
---|
| 11559 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11560 | + textureon = false; |
---|
| 11561 | + |
---|
11110 | 11562 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11111 | 11563 | //System.out.println("ALLO"); |
---|
11112 | 11564 | gl.glColorMask(false, false, false, false); |
---|
11113 | 11565 | DrawObject(gl); |
---|
11114 | | - if (RENDERPROGRAM > 0) |
---|
11115 | | - { |
---|
11116 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11117 | | - textureon = texon; |
---|
11118 | | - } |
---|
| 11566 | + |
---|
| 11567 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11568 | + textureon = texon; |
---|
| 11569 | + |
---|
11119 | 11570 | gl.glColorMask(true, true, true, true); |
---|
11120 | 11571 | |
---|
11121 | 11572 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11122 | | - //gl.glDepthMask(false); |
---|
| 11573 | + gl.glDepthMask(false); |
---|
11123 | 11574 | } |
---|
11124 | 11575 | |
---|
11125 | 11576 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11302 | 11753 | |
---|
11303 | 11754 | static boolean zoomonce = false; |
---|
11304 | 11755 | |
---|
| 11756 | + static void CreateSelectedPoint() |
---|
| 11757 | + { |
---|
| 11758 | + if (selectedpoint == null) |
---|
| 11759 | + { |
---|
| 11760 | + debugpointG = new Sphere(); |
---|
| 11761 | + debugpointP = new Sphere(); |
---|
| 11762 | + debugpointC = new Sphere(); |
---|
| 11763 | + debugpointR = new Sphere(); |
---|
| 11764 | + |
---|
| 11765 | + selectedpoint = new Superellipsoid(); |
---|
| 11766 | + |
---|
| 11767 | + for (int i=0; i<8; i++) |
---|
| 11768 | + { |
---|
| 11769 | + debugpoints[i] = new Sphere(); |
---|
| 11770 | + } |
---|
| 11771 | + } |
---|
| 11772 | + } |
---|
| 11773 | + |
---|
11305 | 11774 | void DrawObject(GL gl, boolean draw) |
---|
11306 | 11775 | { |
---|
| 11776 | + // To clear camera values |
---|
| 11777 | + ResetOptions(); |
---|
| 11778 | + |
---|
11307 | 11779 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11308 | 11780 | // DrawMode() = SELECTION; |
---|
11309 | 11781 | //GL gl = getGL(); |
---|
11310 | 11782 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11311 | 11783 | { |
---|
11312 | 11784 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11313 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11785 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11314 | 11786 | pingthread.StepToTarget(true); // true); |
---|
11315 | 11787 | // zoomonce = false; |
---|
11316 | 11788 | } |
---|
.. | .. |
---|
11382 | 11854 | |
---|
11383 | 11855 | if (DrawMode() == DEFAULT) |
---|
11384 | 11856 | { |
---|
11385 | | - if (DEBUG) |
---|
| 11857 | + if (Globals.DEBUG) |
---|
11386 | 11858 | { |
---|
| 11859 | + CreateSelectedPoint(); |
---|
11387 | 11860 | float radius = 0.05f; |
---|
11388 | 11861 | if (selectedpoint.radius != radius) |
---|
11389 | 11862 | { |
---|
.. | .. |
---|
11437 | 11910 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11438 | 11911 | |
---|
11439 | 11912 | if (CLEANCACHE) |
---|
11440 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11913 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11441 | 11914 | { |
---|
11442 | | - String tex = e.nextElement(); |
---|
| 11915 | + cTexture tex = e.nextElement(); |
---|
11443 | 11916 | |
---|
11444 | 11917 | // System.out.println("Texture --------- " + tex); |
---|
11445 | 11918 | |
---|
11446 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11919 | + if (tex.equals("WHITE_NOISE:")) |
---|
11447 | 11920 | continue; |
---|
11448 | 11921 | |
---|
11449 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11922 | + if (!usedtextures.contains(tex)) |
---|
11450 | 11923 | { |
---|
| 11924 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11451 | 11925 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11452 | | - textures.get(tex).texture.dispose(); |
---|
11453 | | - textures.remove(tex); |
---|
| 11926 | + if (gettex != null) |
---|
| 11927 | + { |
---|
| 11928 | + gettex.texture.dispose(); |
---|
| 11929 | + texturepigment.remove(tex); |
---|
| 11930 | + } |
---|
| 11931 | + |
---|
| 11932 | + gettex = texturebump.get(tex); |
---|
| 11933 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11934 | + if (gettex != null) |
---|
| 11935 | + { |
---|
| 11936 | + gettex.texture.dispose(); |
---|
| 11937 | + texturebump.remove(tex); |
---|
| 11938 | + } |
---|
11454 | 11939 | } |
---|
11455 | 11940 | } |
---|
11456 | 11941 | } |
---|
.. | .. |
---|
11869 | 12354 | //obj.TransformToWorld(light, light); |
---|
11870 | 12355 | for (int i = tp.size(); --i >= 0;) |
---|
11871 | 12356 | { |
---|
11872 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11873 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12357 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12358 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11874 | 12359 | } |
---|
11875 | 12360 | |
---|
11876 | 12361 | |
---|
.. | .. |
---|
11887 | 12372 | parentcam = cameras[0]; |
---|
11888 | 12373 | } |
---|
11889 | 12374 | |
---|
11890 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11891 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12375 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12376 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11892 | 12377 | |
---|
11893 | 12378 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11894 | 12379 | |
---|
.. | .. |
---|
11978 | 12463 | |
---|
11979 | 12464 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
11980 | 12465 | |
---|
11981 | | - String program = |
---|
| 12466 | + String programmin = |
---|
| 12467 | + // Min shader |
---|
11982 | 12468 | "!!ARBfp1.0\n" + |
---|
| 12469 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12470 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12471 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12472 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12473 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12474 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12475 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12476 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12477 | + "TEMP temp;" + |
---|
| 12478 | + "TEMP light;" + |
---|
| 12479 | + "TEMP ndotl;" + |
---|
| 12480 | + "TEMP normal;" + |
---|
| 12481 | + "TEMP depth;" + |
---|
| 12482 | + "TEMP eye;" + |
---|
| 12483 | + "TEMP pos;" + |
---|
| 12484 | + |
---|
| 12485 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12486 | + Normalize("normal") + |
---|
| 12487 | + "MOV light, state.light[0].position;" + |
---|
| 12488 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12489 | + |
---|
| 12490 | + // shadow |
---|
| 12491 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12492 | + "MOV temp, pos;" + |
---|
| 12493 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12494 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12495 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12496 | + |
---|
| 12497 | + // No shadow when out of frustum |
---|
| 12498 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12499 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12500 | + |
---|
| 12501 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12502 | + |
---|
| 12503 | + // Backlit |
---|
| 12504 | + "MOV pos.w, zero123.y;" + |
---|
| 12505 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12506 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12507 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12508 | + Normalize("eye") + |
---|
| 12509 | + |
---|
| 12510 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12511 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12512 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12513 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12514 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12515 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12518 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12519 | + |
---|
| 12520 | + // Pigment |
---|
| 12521 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12522 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12523 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12524 | + |
---|
| 12525 | + "MUL temp, temp, zero123.z;" + |
---|
| 12526 | + |
---|
| 12527 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12528 | + |
---|
| 12529 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12530 | + "MOV result.color, temp;" + |
---|
| 12531 | + "END"; |
---|
| 12532 | + |
---|
| 12533 | + String programmax = |
---|
| 12534 | + "!!ARBfp1.0\n" + |
---|
| 12535 | + |
---|
11983 | 12536 | //"OPTION ARB_fragment_program_shadow;" + |
---|
11984 | 12537 | "PARAM light2cam0 = program.env[10];" + |
---|
11985 | 12538 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12094 | 12647 | "TEMP shininess;" + |
---|
12095 | 12648 | "\n" + |
---|
12096 | 12649 | "MOV texSamp, one;" + |
---|
12097 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12098 | | - |
---|
| 12650 | + |
---|
12099 | 12651 | "MOV mapgrid.x, one2048th.x;" + |
---|
12100 | 12652 | "MOV temp, fragment.texcoord[1];" + |
---|
12101 | 12653 | /* |
---|
.. | .. |
---|
12116 | 12668 | "MUL temp, floor, mapgrid.x;" + |
---|
12117 | 12669 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12118 | 12670 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12119 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12671 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12120 | 12672 | "") + |
---|
12121 | 12673 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12122 | 12674 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12123 | 12675 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12124 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12676 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12125 | 12677 | "") + |
---|
12126 | 12678 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12127 | 12679 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12128 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12680 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12129 | 12681 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12130 | 12682 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12131 | 12683 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12132 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12684 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12133 | 12685 | "") + |
---|
12134 | 12686 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12135 | 12687 | //"MOV params, material;" + |
---|
.. | .. |
---|
12500 | 13052 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12501 | 13053 | "") + |
---|
12502 | 13054 | |
---|
12503 | | - // display shadow only (bump == 0) |
---|
| 13055 | + // display shadow only (fakedepth == 0) |
---|
12504 | 13056 | "SUB temp.x, half.x, shadow.x;" + |
---|
12505 | 13057 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12506 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13058 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12507 | 13059 | "SUB temp.y, one.x, temp.z;" + |
---|
12508 | 13060 | "MUL temp.x, temp.x, temp.y;" + |
---|
12509 | 13061 | "KIL temp.x;" + |
---|
.. | .. |
---|
12834 | 13386 | //once = true; |
---|
12835 | 13387 | } |
---|
12836 | 13388 | |
---|
| 13389 | + String program = programmax; |
---|
| 13390 | + |
---|
| 13391 | + if (Globals.MINSHADER) |
---|
| 13392 | + { |
---|
| 13393 | + program = programmin; |
---|
| 13394 | + } |
---|
| 13395 | + |
---|
12837 | 13396 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12838 | 13397 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12839 | 13398 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
12927 | 13486 | return out; |
---|
12928 | 13487 | } |
---|
12929 | 13488 | |
---|
12930 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13489 | + // Also does frustum culling |
---|
| 13490 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
12931 | 13491 | { |
---|
12932 | 13492 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
12933 | 13493 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
12934 | 13494 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13495 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13496 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
12935 | 13497 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12936 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
12937 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
12938 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
12939 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13498 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13499 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
12940 | 13500 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
12941 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13501 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
12942 | 13502 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
12943 | 13503 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
12944 | 13504 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
12945 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13505 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12946 | 13506 | |
---|
12947 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
12948 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13507 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13508 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
12949 | 13509 | } |
---|
12950 | 13510 | |
---|
12951 | 13511 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
12992 | 13552 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
12993 | 13553 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12994 | 13554 | |
---|
12995 | | - // No shadow when out of frustrum |
---|
| 13555 | + // No shadow when out of frustum |
---|
12996 | 13556 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12997 | 13557 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12998 | 13558 | ""; |
---|
.. | .. |
---|
13140 | 13700 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13141 | 13701 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13142 | 13702 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13143 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13703 | + |
---|
| 13704 | + //Object3D.cVector2[] vector2buffer; |
---|
13144 | 13705 | |
---|
13145 | 13706 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13146 | 13707 | // OUT : diff, spec |
---|
.. | .. |
---|
13156 | 13717 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13157 | 13718 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13158 | 13719 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13159 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13160 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13161 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13720 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13721 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13722 | + |
---|
| 13723 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13162 | 13724 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13163 | 13725 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13164 | 13726 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13663 | 14225 | else |
---|
13664 | 14226 | if (evt.getSource() == AAtimer) |
---|
13665 | 14227 | { |
---|
| 14228 | + Globals.TIMERRUNNING = false; |
---|
13666 | 14229 | if (mouseDown) |
---|
13667 | 14230 | { |
---|
13668 | 14231 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13722 | 14285 | |
---|
13723 | 14286 | // fev 2014??? |
---|
13724 | 14287 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13725 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14288 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13726 | 14289 | pingthread.StepToTarget(true); // true); |
---|
13727 | 14290 | } |
---|
13728 | 14291 | // if (!LIVE) |
---|
.. | .. |
---|
13737 | 14300 | return; |
---|
13738 | 14301 | |
---|
13739 | 14302 | AAtimer.restart(); // |
---|
| 14303 | + Globals.TIMERRUNNING = true; |
---|
13740 | 14304 | |
---|
13741 | 14305 | // waslive = LIVE; |
---|
13742 | 14306 | // LIVE = false; |
---|
.. | .. |
---|
13786 | 14350 | drag = false; |
---|
13787 | 14351 | //System.out.println("Mouse DOWN"); |
---|
13788 | 14352 | editObj = false; |
---|
13789 | | - ClickInfo info = new ClickInfo(); |
---|
13790 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13791 | | - info.pane = this; |
---|
13792 | | - info.camera = renderCamera; |
---|
13793 | | - info.x = x; |
---|
13794 | | - info.y = y; |
---|
13795 | | - info.modifiers = modifiersex; |
---|
13796 | | - editObj = object.doEditClick(info, 0); |
---|
| 14353 | + //ClickInfo info = new ClickInfo(); |
---|
| 14354 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14355 | + object.clickInfo.pane = this; |
---|
| 14356 | + object.clickInfo.camera = renderCamera; |
---|
| 14357 | + object.clickInfo.x = x; |
---|
| 14358 | + object.clickInfo.y = y; |
---|
| 14359 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14360 | + editObj = object.doEditClick(//info, |
---|
| 14361 | + 0); |
---|
13797 | 14362 | if (!editObj) |
---|
13798 | 14363 | { |
---|
13799 | 14364 | hasMarquee = true; |
---|
.. | .. |
---|
13809 | 14374 | |
---|
13810 | 14375 | public void mouseDragged(MouseEvent e) |
---|
13811 | 14376 | { |
---|
| 14377 | + Globals.MOUSEDRAGGED = true; |
---|
| 14378 | + |
---|
13812 | 14379 | //System.out.println("mouseDragged: " + e); |
---|
13813 | 14380 | if (isRenderer) |
---|
13814 | 14381 | movingcamera = true; |
---|
| 14382 | + |
---|
13815 | 14383 | //if (drawing) |
---|
13816 | 14384 | //return; |
---|
13817 | 14385 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
.. | .. |
---|
14072 | 14640 | void GoDown(int mod) |
---|
14073 | 14641 | { |
---|
14074 | 14642 | MODIFIERS |= COMMAND; |
---|
14075 | | - /* |
---|
| 14643 | + /**/ |
---|
14076 | 14644 | if((mod&SHIFT) == SHIFT) |
---|
14077 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14645 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
14078 | 14646 | else |
---|
14079 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14080 | | - */ |
---|
| 14647 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14648 | + /**/ |
---|
14081 | 14649 | if ((mod & SHIFT) == SHIFT) |
---|
14082 | 14650 | { |
---|
14083 | 14651 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14093 | 14661 | void GoUp(int mod) |
---|
14094 | 14662 | { |
---|
14095 | 14663 | MODIFIERS |= COMMAND; |
---|
14096 | | - /* |
---|
| 14664 | + /**/ |
---|
14097 | 14665 | if((mod&SHIFT) == SHIFT) |
---|
14098 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14666 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
14099 | 14667 | else |
---|
14100 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14101 | | - */ |
---|
| 14668 | + manipCamera.RotatePosition(0, speed); |
---|
| 14669 | + /**/ |
---|
14102 | 14670 | if ((mod & SHIFT) == SHIFT) |
---|
14103 | 14671 | { |
---|
14104 | 14672 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14114 | 14682 | void GoLeft(int mod) |
---|
14115 | 14683 | { |
---|
14116 | 14684 | MODIFIERS |= COMMAND; |
---|
14117 | | - /* |
---|
| 14685 | + /**/ |
---|
14118 | 14686 | if((mod&SHIFT) == SHIFT) |
---|
14119 | | - manipCamera.RotatePosition(speed, 0); |
---|
14120 | | - else |
---|
14121 | 14687 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14122 | | - */ |
---|
| 14688 | + else |
---|
| 14689 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14690 | + /**/ |
---|
14123 | 14691 | if ((mod & SHIFT) == SHIFT) |
---|
14124 | 14692 | { |
---|
14125 | 14693 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14135 | 14703 | void GoRight(int mod) |
---|
14136 | 14704 | { |
---|
14137 | 14705 | MODIFIERS |= COMMAND; |
---|
14138 | | - /* |
---|
| 14706 | + /**/ |
---|
14139 | 14707 | if((mod&SHIFT) == SHIFT) |
---|
14140 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14141 | | - else |
---|
14142 | 14708 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14143 | | - */ |
---|
| 14709 | + else |
---|
| 14710 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14711 | + /**/ |
---|
14144 | 14712 | if ((mod & SHIFT) == SHIFT) |
---|
14145 | 14713 | { |
---|
14146 | 14714 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14190 | 14758 | if (editObj) |
---|
14191 | 14759 | { |
---|
14192 | 14760 | drag = true; |
---|
14193 | | - ClickInfo info = new ClickInfo(); |
---|
14194 | | - info.bounds.setBounds(0, 0, |
---|
| 14761 | + //ClickInfo info = new ClickInfo(); |
---|
| 14762 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14195 | 14763 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14196 | | - info.pane = this; |
---|
14197 | | - info.camera = renderCamera; |
---|
14198 | | - info.x = x; |
---|
14199 | | - info.y = y; |
---|
14200 | | - object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14764 | + object.clickInfo.pane = this; |
---|
| 14765 | + object.clickInfo.camera = renderCamera; |
---|
| 14766 | + object.clickInfo.x = x; |
---|
| 14767 | + object.clickInfo.y = y; |
---|
| 14768 | + object //.GetWindow().copy |
---|
| 14769 | + .doEditDrag(//info, |
---|
| 14770 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14201 | 14771 | } else |
---|
14202 | 14772 | { |
---|
14203 | 14773 | if (x < startX) |
---|
.. | .. |
---|
14346 | 14916 | } |
---|
14347 | 14917 | } |
---|
14348 | 14918 | |
---|
| 14919 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14920 | + |
---|
14349 | 14921 | public void mouseMoved(MouseEvent e) |
---|
14350 | 14922 | { |
---|
14351 | 14923 | //System.out.println("mouseMoved: " + e); |
---|
14352 | 14924 | if (isRenderer) |
---|
14353 | 14925 | return; |
---|
14354 | 14926 | |
---|
14355 | | - ClickInfo ci = new ClickInfo(); |
---|
14356 | | - ci.x = e.getX(); |
---|
14357 | | - ci.y = e.getY(); |
---|
14358 | | - ci.modifiers = e.getModifiersEx(); |
---|
14359 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14360 | | - ci.pane = this; |
---|
14361 | | - ci.camera = renderCamera; |
---|
| 14927 | + // Mouse cursor feedback |
---|
| 14928 | + object.clickInfo.x = e.getX(); |
---|
| 14929 | + object.clickInfo.y = e.getY(); |
---|
| 14930 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14931 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14932 | + object.clickInfo.pane = this; |
---|
| 14933 | + object.clickInfo.camera = renderCamera; |
---|
14362 | 14934 | if (!isRenderer) |
---|
14363 | 14935 | { |
---|
14364 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14936 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14937 | + //Object3D copy = editWindow.copy; |
---|
| 14938 | + if (object.doEditClick(//clickInfo, |
---|
| 14939 | + 0)) |
---|
14365 | 14940 | { |
---|
14366 | 14941 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14367 | 14942 | } else |
---|
.. | .. |
---|
14373 | 14948 | |
---|
14374 | 14949 | public void mouseReleased(MouseEvent e) |
---|
14375 | 14950 | { |
---|
| 14951 | + Globals.MOUSEDRAGGED = false; |
---|
| 14952 | + |
---|
14376 | 14953 | movingcamera = false; |
---|
14377 | | - X = Y = 0; |
---|
| 14954 | + X = 0; // getBounds().width/2; |
---|
| 14955 | + Y = 0; // getBounds().height/2; |
---|
14378 | 14956 | //System.out.println("mouseReleased: " + e); |
---|
14379 | 14957 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14380 | 14958 | } |
---|
.. | .. |
---|
14630 | 15208 | // break; |
---|
14631 | 15209 | case 'T': |
---|
14632 | 15210 | CACHETEXTURE ^= true; |
---|
14633 | | - textures.clear(); |
---|
| 15211 | + texturepigment.clear(); |
---|
| 15212 | + texturebump.clear(); |
---|
14634 | 15213 | // repaint(); |
---|
14635 | 15214 | break; |
---|
14636 | 15215 | case 'Y': |
---|
.. | .. |
---|
14715 | 15294 | case 'E' : COMPACT ^= true; |
---|
14716 | 15295 | repaint(); |
---|
14717 | 15296 | break; |
---|
14718 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15297 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15298 | + //DEBUGHSB ^= true; |
---|
| 15299 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14719 | 15300 | repaint(); |
---|
14720 | 15301 | break; |
---|
14721 | 15302 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14740 | 15321 | RevertCamera(); |
---|
14741 | 15322 | repaint(); |
---|
14742 | 15323 | break; |
---|
14743 | | - case 'L': |
---|
14744 | 15324 | case 'l': |
---|
| 15325 | + //case 'L': |
---|
14745 | 15326 | if (lightMode) |
---|
14746 | 15327 | { |
---|
14747 | 15328 | lightMode = false; |
---|
.. | .. |
---|
14805 | 15386 | OCCLUSION_CULLING ^= true; |
---|
14806 | 15387 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14807 | 15388 | break; |
---|
14808 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15389 | + //case '0': envyoff ^= true; repaint(); break; |
---|
14809 | 15390 | case '1': |
---|
14810 | 15391 | case '2': |
---|
14811 | 15392 | case '3': |
---|
14812 | 15393 | case '4': |
---|
14813 | 15394 | case '5': |
---|
14814 | | - newenvy = Character.getNumericValue(key); |
---|
14815 | | - repaint(); |
---|
14816 | | - break; |
---|
14817 | 15395 | case '6': |
---|
14818 | 15396 | case '7': |
---|
14819 | 15397 | case '8': |
---|
14820 | 15398 | case '9': |
---|
14821 | | - BGcolor = (key - '6')/3.f; |
---|
| 15399 | + if (true) // envyoff) |
---|
| 15400 | + { |
---|
| 15401 | + BGcolor = (key - '1')/8.f; |
---|
| 15402 | + } |
---|
| 15403 | + else |
---|
| 15404 | + { |
---|
| 15405 | + //newenvy = Character.getNumericValue(key); |
---|
| 15406 | + } |
---|
14822 | 15407 | repaint(); |
---|
14823 | 15408 | break; |
---|
14824 | 15409 | case '!': |
---|
.. | .. |
---|
14884 | 15469 | case '_': |
---|
14885 | 15470 | kompactbit = 5; |
---|
14886 | 15471 | break; |
---|
14887 | | - case '+': |
---|
14888 | | - kompactbit = 6; |
---|
14889 | | - break; |
---|
| 15472 | +// case '+': |
---|
| 15473 | +// kompactbit = 6; |
---|
| 15474 | +// break; |
---|
14890 | 15475 | case ' ': |
---|
14891 | 15476 | lightMode ^= true; |
---|
14892 | 15477 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14898 | 15483 | case ESC: |
---|
14899 | 15484 | RENDERPROGRAM += 1; |
---|
14900 | 15485 | RENDERPROGRAM %= 3; |
---|
| 15486 | + |
---|
14901 | 15487 | repaint(); |
---|
14902 | 15488 | break; |
---|
14903 | 15489 | case 'Z': |
---|
.. | .. |
---|
14937 | 15523 | case DELETE: |
---|
14938 | 15524 | ClearSelection(); |
---|
14939 | 15525 | break; |
---|
14940 | | - /* |
---|
14941 | 15526 | case '+': |
---|
| 15527 | + |
---|
| 15528 | + /* |
---|
14942 | 15529 | //fontsize += 1; |
---|
14943 | 15530 | bbzoom *= 2; |
---|
14944 | 15531 | repaint(); |
---|
.. | .. |
---|
14955 | 15542 | case '=': |
---|
14956 | 15543 | IncDepth(); |
---|
14957 | 15544 | //fontsize += 1; |
---|
14958 | | - object.editWindow.refreshContents(true); |
---|
| 15545 | + object.GetWindow().refreshContents(true); |
---|
14959 | 15546 | maskbit = 6; |
---|
14960 | 15547 | break; |
---|
14961 | 15548 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14962 | 15549 | DecDepth(); |
---|
14963 | 15550 | maskbit = 5; |
---|
14964 | 15551 | //if(fontsize > 1) fontsize -= 1; |
---|
14965 | | - if (object.editWindow == null) |
---|
14966 | | - new Exception().printStackTrace(); |
---|
14967 | | - else |
---|
14968 | | - object.editWindow.refreshContents(true); |
---|
| 15552 | +// if (object.editWindow == null) |
---|
| 15553 | +// new Exception().printStackTrace(); |
---|
| 15554 | +// else |
---|
| 15555 | + object.GetWindow().refreshContents(true); |
---|
14969 | 15556 | break; |
---|
14970 | 15557 | case '{': |
---|
14971 | 15558 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15189 | 15776 | } |
---|
15190 | 15777 | */ |
---|
15191 | 15778 | |
---|
15192 | | - object.editWindow.EditSelection(); |
---|
| 15779 | + object.GetWindow().EditSelection(false); |
---|
15193 | 15780 | } |
---|
15194 | 15781 | |
---|
15195 | 15782 | void SelectParent() |
---|
.. | .. |
---|
15206 | 15793 | { |
---|
15207 | 15794 | //selectees.remove(i); |
---|
15208 | 15795 | System.out.println("select parent of " + elem); |
---|
15209 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15796 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15210 | 15797 | } else |
---|
15211 | 15798 | { |
---|
15212 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15799 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15213 | 15800 | } |
---|
15214 | 15801 | |
---|
15215 | 15802 | first = false; |
---|
.. | .. |
---|
15251 | 15838 | for (int j = 0; j < group.children.size(); j++) |
---|
15252 | 15839 | { |
---|
15253 | 15840 | elem = (Object3D) group.children.elementAt(j); |
---|
15254 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15841 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15255 | 15842 | first = false; |
---|
15256 | 15843 | } |
---|
15257 | 15844 | } else |
---|
15258 | 15845 | { |
---|
15259 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15846 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15260 | 15847 | } |
---|
15261 | 15848 | |
---|
15262 | 15849 | first = false; |
---|
.. | .. |
---|
15267 | 15854 | { |
---|
15268 | 15855 | //Composite group = (Composite) object; |
---|
15269 | 15856 | Object3D group = object; |
---|
15270 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15857 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15271 | 15858 | } |
---|
15272 | 15859 | |
---|
15273 | 15860 | void ResetTransform(int mask) |
---|
15274 | 15861 | { |
---|
15275 | 15862 | //Composite group = (Composite) object; |
---|
15276 | 15863 | Object3D group = object; |
---|
15277 | | - group.editWindow.ResetTransform(mask); |
---|
| 15864 | + group.GetWindow().ResetTransform(mask); |
---|
15278 | 15865 | } |
---|
15279 | 15866 | |
---|
15280 | 15867 | void FlipTransform() |
---|
15281 | 15868 | { |
---|
15282 | 15869 | //Composite group = (Composite) object; |
---|
15283 | 15870 | Object3D group = object; |
---|
15284 | | - group.editWindow.FlipTransform(); |
---|
| 15871 | + group.GetWindow().FlipTransform(); |
---|
15285 | 15872 | // group.editWindow.ReduceMesh(true); |
---|
15286 | 15873 | } |
---|
15287 | 15874 | |
---|
.. | .. |
---|
15289 | 15876 | { |
---|
15290 | 15877 | //Composite group = (Composite) object; |
---|
15291 | 15878 | Object3D group = object; |
---|
15292 | | - group.editWindow.PrintMemory(); |
---|
| 15879 | + group.GetWindow().PrintMemory(); |
---|
15293 | 15880 | // group.editWindow.ReduceMesh(true); |
---|
15294 | 15881 | } |
---|
15295 | 15882 | |
---|
.. | .. |
---|
15297 | 15884 | { |
---|
15298 | 15885 | //Composite group = (Composite) object; |
---|
15299 | 15886 | Object3D group = object; |
---|
15300 | | - group.editWindow.ResetCentroid(); |
---|
| 15887 | + group.GetWindow().ResetCentroid(); |
---|
15301 | 15888 | } |
---|
15302 | 15889 | |
---|
15303 | 15890 | void IncDepth() |
---|
.. | .. |
---|
15379 | 15966 | |
---|
15380 | 15967 | int width = getBounds().width; |
---|
15381 | 15968 | int height = getBounds().height; |
---|
15382 | | - ClickInfo info = new ClickInfo(); |
---|
15383 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15384 | 15969 | //Image img = CreateImage(width, height); |
---|
15385 | 15970 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15386 | 15971 | |
---|
.. | .. |
---|
15457 | 16042 | } |
---|
15458 | 16043 | if (object != null && !hasMarquee) |
---|
15459 | 16044 | { |
---|
| 16045 | + if (object.clickInfo == null) |
---|
| 16046 | + object.clickInfo = new ClickInfo(); |
---|
| 16047 | + ClickInfo info = object.clickInfo; |
---|
| 16048 | + //ClickInfo info = new ClickInfo(); |
---|
| 16049 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16050 | + |
---|
15460 | 16051 | if (isRenderer) |
---|
15461 | 16052 | { |
---|
15462 | | - info.flags++; |
---|
| 16053 | + object.clickInfo.flags++; |
---|
15463 | 16054 | double frameAspect = (double) width / (double) height; |
---|
15464 | 16055 | if (frameAspect > renderCamera.aspect) |
---|
15465 | 16056 | { |
---|
15466 | 16057 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15467 | | - info.bounds.width -= width - desired; |
---|
15468 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16058 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16059 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15469 | 16060 | } else |
---|
15470 | 16061 | { |
---|
15471 | 16062 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15472 | | - info.bounds.height -= height - desired; |
---|
15473 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16063 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16064 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15474 | 16065 | } |
---|
15475 | 16066 | } |
---|
15476 | | - info.g = gr; |
---|
15477 | | - info.camera = renderCamera; |
---|
| 16067 | + |
---|
| 16068 | + object.clickInfo.g = gr; |
---|
| 16069 | + object.clickInfo.camera = renderCamera; |
---|
15478 | 16070 | /* |
---|
15479 | 16071 | // Memory intensive (brep.verticescopy) |
---|
15480 | 16072 | if (!(object instanceof Composite)) |
---|
15481 | 16073 | object.draw(info, 0, false); // SLOW : |
---|
15482 | 16074 | */ |
---|
15483 | | - if (!isRenderer) |
---|
| 16075 | + if (!isRenderer) // && drag) |
---|
15484 | 16076 | { |
---|
15485 | | - object.drawEditHandles(info, 0); |
---|
15486 | | - |
---|
15487 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16077 | + Grafreed.Assert(object != null); |
---|
| 16078 | + Grafreed.Assert(object.selection != null); |
---|
| 16079 | + if (object.selection.Size() > 0) |
---|
15488 | 16080 | { |
---|
15489 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16081 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16082 | + |
---|
| 16083 | + object.clickInfo.DX = 0; |
---|
| 16084 | + object.clickInfo.DY = 0; |
---|
| 16085 | + object.clickInfo.W = 1; |
---|
| 16086 | + if (hitSomething == Object3D.hitCenter) |
---|
15490 | 16087 | { |
---|
15491 | | - case Object3D.hitCenter: gr.setColor(Color.pink); break; |
---|
15492 | | - case Object3D.hitRotate: gr.setColor(Color.green); break; |
---|
15493 | | - case Object3D.hitScale: gr.setColor(Color.cyan); break; |
---|
| 16088 | + info.DX = X; |
---|
| 16089 | + if (X != 0) |
---|
| 16090 | + info.DX -= info.bounds.width/2; |
---|
| 16091 | + |
---|
| 16092 | + info.DY = Y; |
---|
| 16093 | + if (Y != 0) |
---|
| 16094 | + info.DY -= info.bounds.height/2; |
---|
15494 | 16095 | } |
---|
15495 | | - |
---|
15496 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16096 | + |
---|
| 16097 | + object.drawEditHandles(//info, |
---|
| 16098 | + 0); |
---|
| 16099 | + |
---|
| 16100 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16101 | + { |
---|
| 16102 | + switch (hitSomething) |
---|
| 16103 | + { |
---|
| 16104 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16105 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16106 | + break; |
---|
| 16107 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16108 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16109 | + break; |
---|
| 16110 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16111 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16112 | + break; |
---|
| 16113 | + } |
---|
| 16114 | + |
---|
| 16115 | + } |
---|
15497 | 16116 | } |
---|
15498 | 16117 | } |
---|
15499 | 16118 | } |
---|
.. | .. |
---|
15911 | 16530 | Object3D object; |
---|
15912 | 16531 | static Object3D trackedobject; |
---|
15913 | 16532 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15914 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16533 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15915 | 16534 | /*static*/ Camera eyeCamera; |
---|
15916 | 16535 | /*static*/ Camera lightCamera; |
---|
15917 | 16536 | int cameracount; |
---|
.. | .. |
---|
15975 | 16594 | private /*static*/ boolean firstime; |
---|
15976 | 16595 | private /*static*/ cVector newView = new cVector(); |
---|
15977 | 16596 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16597 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16598 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
15978 | 16599 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
15979 | 16600 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
15980 | 16601 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
15987 | 16608 | { |
---|
15988 | 16609 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
15989 | 16610 | |
---|
| 16611 | + int usedsuf = 0; |
---|
| 16612 | + |
---|
15990 | 16613 | for (int i = 0; i < suffixes.length; i++) |
---|
15991 | 16614 | { |
---|
15992 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
15993 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
15994 | | - mipmapped, |
---|
15995 | | - FileUtil.getFileSuffix(resourceName)); |
---|
15996 | | - if (data == null) |
---|
| 16615 | + String[] suffixe = suffixes; |
---|
| 16616 | + String[] fallback = suffixes2; |
---|
| 16617 | + String[] fallfallback = suffixes3; |
---|
| 16618 | + |
---|
| 16619 | + for (int c=usedsuf; --c>=0;) |
---|
15997 | 16620 | { |
---|
15998 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16621 | +// String[] temp = suffixe; |
---|
| 16622 | +// suffixe = fallback; |
---|
| 16623 | +// fallback = fallfallback; |
---|
| 16624 | +// fallfallback = temp; |
---|
15999 | 16625 | } |
---|
| 16626 | + |
---|
| 16627 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16628 | + TextureData data; |
---|
| 16629 | + |
---|
| 16630 | + try |
---|
| 16631 | + { |
---|
| 16632 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16633 | + mipmapped, |
---|
| 16634 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16635 | + } |
---|
| 16636 | + catch (Exception e) |
---|
| 16637 | + { |
---|
| 16638 | + try |
---|
| 16639 | + { |
---|
| 16640 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16641 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16642 | + mipmapped, |
---|
| 16643 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16644 | + } |
---|
| 16645 | + catch (Exception e2) |
---|
| 16646 | + { |
---|
| 16647 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16648 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16649 | + mipmapped, |
---|
| 16650 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16651 | + } |
---|
| 16652 | + } |
---|
| 16653 | + |
---|
16000 | 16654 | //System.out.println("Target = " + targets[i]); |
---|
16001 | 16655 | cubemap.updateImage(data, targets[i]); |
---|
16002 | 16656 | } |
---|
16003 | 16657 | |
---|
16004 | 16658 | return cubemap; |
---|
16005 | 16659 | } |
---|
| 16660 | + |
---|
16006 | 16661 | int bigsphere = -1; |
---|
16007 | 16662 | |
---|
16008 | 16663 | float BGcolor = 0.5f; |
---|
16009 | 16664 | |
---|
16010 | | - private void DrawSkyBox(GL gl) |
---|
| 16665 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16666 | + |
---|
| 16667 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16011 | 16668 | { |
---|
16012 | | - if (envyoff || cubemap == null) |
---|
| 16669 | + if (//envyoff || |
---|
| 16670 | + WIREFRAME || |
---|
| 16671 | + cubemap == null) |
---|
16013 | 16672 | { |
---|
16014 | 16673 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16015 | 16674 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16024 | 16683 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16025 | 16684 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16026 | 16685 | gl.glLoadIdentity(); |
---|
| 16686 | + gl.glScalef(1,ratio,1); |
---|
16027 | 16687 | |
---|
| 16688 | +// colorV[0] = 2; |
---|
| 16689 | +// colorV[1] = 2; |
---|
| 16690 | +// colorV[2] = 2; |
---|
| 16691 | +// colorV[3] = 1; |
---|
| 16692 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16693 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16694 | +// |
---|
| 16695 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16696 | + |
---|
16028 | 16697 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16029 | 16698 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16030 | 16699 | |
---|
.. | .. |
---|
16056 | 16725 | { |
---|
16057 | 16726 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16058 | 16727 | } |
---|
| 16728 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16059 | 16729 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16060 | 16730 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16061 | 16731 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16196 | 16866 | cStatic.objectstack[materialdepth++] = checker; |
---|
16197 | 16867 | //System.out.println("material " + material); |
---|
16198 | 16868 | //Applet3D.tracein(this, selected); |
---|
16199 | | - vector2buffer = checker.projectedVertices; |
---|
| 16869 | + //vector2buffer = checker.projectedVertices; |
---|
16200 | 16870 | |
---|
16201 | 16871 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16202 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16872 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16203 | 16873 | |
---|
16204 | 16874 | materialdepth -= 1; |
---|
16205 | 16875 | if (materialdepth > 0) |
---|
16206 | 16876 | { |
---|
16207 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16208 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16877 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16878 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16209 | 16879 | } |
---|
16210 | 16880 | //checker.GetMaterial().opacity = 1f; |
---|
16211 | 16881 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16291 | 16961 | } |
---|
16292 | 16962 | } |
---|
16293 | 16963 | |
---|
| 16964 | + private Object3D GetFolder() |
---|
| 16965 | + { |
---|
| 16966 | + Object3D folder = object.GetWindow().copy; |
---|
| 16967 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16968 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16969 | + return folder; |
---|
| 16970 | + } |
---|
| 16971 | + |
---|
16294 | 16972 | class SelectBuffer implements GLEventListener |
---|
16295 | 16973 | { |
---|
16296 | 16974 | |
---|
.. | .. |
---|
16306 | 16984 | //new Exception().printStackTrace(); |
---|
16307 | 16985 | System.out.println("select buffer init"); |
---|
16308 | 16986 | // Use debug pipeline |
---|
16309 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16987 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16310 | 16988 | |
---|
16311 | 16989 | GL gl = drawable.getGL(); |
---|
16312 | 16990 | |
---|
.. | .. |
---|
16370 | 17048 | |
---|
16371 | 17049 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16372 | 17050 | |
---|
| 17051 | + if (PAINTMODE) |
---|
| 17052 | + { |
---|
| 17053 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17054 | + { |
---|
| 17055 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17056 | + |
---|
| 17057 | + // Make what you paint not selectable. |
---|
| 17058 | + paintobj.ResetSelectable(); |
---|
| 17059 | + } |
---|
| 17060 | + } |
---|
| 17061 | + |
---|
16373 | 17062 | //int tmp = selection_view; |
---|
16374 | 17063 | //selection_view = -1; |
---|
16375 | 17064 | int temp = DrawMode(); |
---|
.. | .. |
---|
16381 | 17070 | // temp = DEFAULT; // patch for selection debug |
---|
16382 | 17071 | Globals.drawMode = temp; // WARNING |
---|
16383 | 17072 | |
---|
| 17073 | + if (PAINTMODE) |
---|
| 17074 | + { |
---|
| 17075 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17076 | + { |
---|
| 17077 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17078 | + |
---|
| 17079 | + // Revert. |
---|
| 17080 | + paintobj.RestoreSelectable(); |
---|
| 17081 | + } |
---|
| 17082 | + } |
---|
| 17083 | + |
---|
16384 | 17084 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16385 | 17085 | |
---|
16386 | 17086 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16428 | 17128 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16429 | 17129 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16430 | 17130 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 17131 | + |
---|
| 17132 | + CreateSelectedPoint(); |
---|
16431 | 17133 | |
---|
16432 | 17134 | // Will fit the mesh !!! |
---|
16433 | 17135 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16482 | 17184 | } |
---|
16483 | 17185 | |
---|
16484 | 17186 | if (!movingcamera && !PAINTMODE) |
---|
16485 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17187 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16486 | 17188 | |
---|
16487 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17189 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16488 | 17190 | { |
---|
16489 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17191 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16490 | 17192 | |
---|
16491 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17193 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17194 | + { |
---|
| 17195 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16492 | 17196 | |
---|
16493 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16494 | | - |
---|
16495 | | - group.add(paintobj); // link |
---|
16496 | | - |
---|
16497 | | - object.editWindow.SnapObject(group); |
---|
16498 | | - |
---|
16499 | | - Object3D folder = object.editWindow.copy; |
---|
16500 | | - |
---|
16501 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16502 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16503 | | - |
---|
16504 | | - folder.add(group); |
---|
16505 | | - |
---|
16506 | | - object.editWindow.ResetModel(); |
---|
16507 | | - object.editWindow.refreshContents(); |
---|
| 17197 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17198 | + |
---|
| 17199 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17200 | + |
---|
| 17201 | + inst.add(paintobj); // link |
---|
| 17202 | + |
---|
| 17203 | + object.GetWindow().SnapObject(inst); |
---|
| 17204 | + |
---|
| 17205 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17206 | + |
---|
| 17207 | + folder.add(inst); |
---|
| 17208 | + |
---|
| 17209 | + object.GetWindow().ResetModel(); |
---|
| 17210 | + object.GetWindow().refreshContents(); |
---|
| 17211 | + } |
---|
16508 | 17212 | } |
---|
16509 | 17213 | else |
---|
16510 | 17214 | paintcount = 0; |
---|
.. | .. |
---|
16543 | 17247 | //System.out.println("objects[color] = " + objects[color]); |
---|
16544 | 17248 | //objects[color].Select(); |
---|
16545 | 17249 | indexcount = 0; |
---|
| 17250 | + ObjEditor window = object.GetWindow(); |
---|
| 17251 | + if (window != null && deselect) |
---|
| 17252 | + { |
---|
| 17253 | + window.Select(null, deselect, true); |
---|
| 17254 | + } |
---|
16546 | 17255 | object.Select(color, deselect); |
---|
16547 | 17256 | } |
---|
16548 | 17257 | |
---|
.. | .. |
---|
17068 | 17777 | int AAbuffersize = 0; |
---|
17069 | 17778 | |
---|
17070 | 17779 | //double[] selectedpoint = new double[3]; |
---|
17071 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17780 | + static Superellipsoid selectedpoint; |
---|
17072 | 17781 | static Sphere previousselectedpoint = null; |
---|
17073 | | - static Sphere debugpointG = new Sphere(); |
---|
17074 | | - static Sphere debugpointP = new Sphere(); |
---|
17075 | | - static Sphere debugpointC = new Sphere(); |
---|
17076 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17782 | + static Sphere debugpointG; |
---|
| 17783 | + static Sphere debugpointP; |
---|
| 17784 | + static Sphere debugpointC; |
---|
| 17785 | + static Sphere debugpointR; |
---|
17077 | 17786 | |
---|
17078 | 17787 | static Sphere debugpoints[] = new Sphere[8]; |
---|
17079 | 17788 | |
---|
17080 | | - static |
---|
17081 | | - { |
---|
17082 | | - for (int i=0; i<8; i++) |
---|
17083 | | - { |
---|
17084 | | - debugpoints[i] = new Sphere(); |
---|
17085 | | - } |
---|
17086 | | - } |
---|
17087 | | - |
---|
17088 | 17789 | static void InitPoints(float radius) |
---|
17089 | 17790 | { |
---|
17090 | 17791 | for (int i=0; i<8; i++) |
---|