.. | .. |
---|
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; |
---|
.. | .. |
---|
56 | 92 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 93 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 94 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 95 | |
---|
62 | 96 | boolean DISPLAYTEXT = false; |
---|
63 | 97 | //boolean REDUCETEXTURE = true; |
---|
64 | 98 | boolean CACHETEXTURE = true; |
---|
65 | 99 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
67 | 101 | boolean COMPRESSTEXTURE = false; |
---|
68 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 126 | |
---|
93 | 127 | static int tickcount = 0; // slow pose issue |
---|
94 | 128 | |
---|
| 129 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 130 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 131 | static boolean BOXMODE = false; |
---|
96 | 132 | static boolean IMAGEFLIP = false; |
---|
97 | 133 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 142 | static boolean OEIL = true; |
---|
107 | 143 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 144 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 145 | +static boolean SWITCH = true; // false; |
---|
110 | 146 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 147 | static boolean PAINTMODE = false; |
---|
112 | 148 | |
---|
.. | .. |
---|
149 | 185 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 186 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 187 | } |
---|
| 188 | + |
---|
| 189 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 190 | |
---|
153 | 191 | void SetAsGLRenderer(boolean b) |
---|
154 | 192 | { |
---|
.. | .. |
---|
223 | 261 | public boolean IsBoxMode() |
---|
224 | 262 | { |
---|
225 | 263 | return BOXMODE; |
---|
| 264 | + } |
---|
| 265 | + |
---|
| 266 | + public boolean IsZoomBoxMode() |
---|
| 267 | + { |
---|
| 268 | + return ZOOMBOXMODE; |
---|
226 | 269 | } |
---|
227 | 270 | |
---|
228 | 271 | public void ClearDepth() |
---|
.. | .. |
---|
320 | 363 | cStatic.objectstack[materialdepth++] = obj; |
---|
321 | 364 | //System.out.println("material " + material); |
---|
322 | 365 | //Applet3D.tracein(this, selected); |
---|
323 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 366 | + //display.vector2buffer = obj.projectedVertices; |
---|
324 | 367 | if (obj instanceof Camera) |
---|
325 | 368 | { |
---|
326 | 369 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
329 | 372 | display.options1[2] = material.shadowbias; |
---|
330 | 373 | display.options1[3] = material.aniso; |
---|
331 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
332 | 380 | display.options2[0] = material.opacity; |
---|
333 | 381 | display.options2[1] = material.diffuse; |
---|
334 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
335 | 386 | |
---|
336 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
337 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
338 | 392 | display.options4[1] = material.subsurface; |
---|
339 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
340 | 397 | |
---|
341 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
342 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
352 | 409 | /**/ |
---|
353 | 410 | } else |
---|
354 | 411 | { |
---|
355 | | - DrawMaterial(material, selected); |
---|
| 412 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
356 | 413 | } |
---|
357 | 414 | } else |
---|
358 | 415 | { |
---|
.. | .. |
---|
376 | 433 | cStatic.objectstack[materialdepth++] = obj; |
---|
377 | 434 | //System.out.println("material " + material); |
---|
378 | 435 | //Applet3D.tracein("selected ", selected); |
---|
379 | | - display.vector2buffer = obj.projectedVertices; |
---|
380 | | - display.DrawMaterial(material, selected); |
---|
| 436 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 437 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
381 | 438 | } |
---|
382 | 439 | } |
---|
383 | 440 | |
---|
.. | .. |
---|
394 | 451 | materialdepth -= 1; |
---|
395 | 452 | if (materialdepth > 0) |
---|
396 | 453 | { |
---|
397 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
398 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 454 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 455 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
399 | 456 | } |
---|
400 | 457 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
401 | 458 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
415 | 472 | materialdepth -= 1; |
---|
416 | 473 | if (materialdepth > 0) |
---|
417 | 474 | { |
---|
418 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
419 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 475 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 476 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
420 | 477 | } |
---|
421 | 478 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
422 | 479 | //else |
---|
.. | .. |
---|
457 | 514 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
458 | 515 | { |
---|
459 | 516 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
460 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 517 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 518 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 519 | + ; |
---|
461 | 520 | if (!hasnorm) |
---|
462 | 521 | { |
---|
463 | | - // System.out.println("FUCK!!"); |
---|
| 522 | + // System.out.println("Mesh normal"); |
---|
464 | 523 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
465 | 524 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
466 | 525 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1185 | 1244 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1186 | 1245 | } |
---|
1187 | 1246 | } |
---|
| 1247 | + |
---|
1188 | 1248 | if (flipV) |
---|
1189 | 1249 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1190 | 1250 | else |
---|
1191 | 1251 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1252 | + |
---|
1192 | 1253 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1193 | 1254 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1194 | 1255 | |
---|
.. | .. |
---|
1208 | 1269 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1209 | 1270 | } |
---|
1210 | 1271 | } |
---|
| 1272 | + |
---|
1211 | 1273 | if (flipV) |
---|
1212 | 1274 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1213 | 1275 | else |
---|
1214 | 1276 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1277 | + |
---|
1215 | 1278 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1216 | 1279 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1217 | 1280 | |
---|
.. | .. |
---|
1239 | 1302 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1240 | 1303 | else |
---|
1241 | 1304 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1305 | + |
---|
1242 | 1306 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1243 | 1307 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1308 | + |
---|
1244 | 1309 | count2 += 2; |
---|
1245 | 1310 | count3 += 3; |
---|
1246 | 1311 | } |
---|
.. | .. |
---|
1596 | 1661 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1597 | 1662 | } |
---|
1598 | 1663 | |
---|
1599 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1664 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1600 | 1665 | { |
---|
1601 | 1666 | CameraPane display = this; |
---|
1602 | 1667 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1612 | 1677 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
1613 | 1678 | if (!material.multiply) |
---|
1614 | 1679 | { |
---|
1615 | | - display.color = color; |
---|
| 1680 | + display.color = material.color; |
---|
1616 | 1681 | display.saturation = material.modulation; |
---|
1617 | 1682 | } |
---|
1618 | 1683 | else |
---|
1619 | 1684 | { |
---|
1620 | | - display.color *= color*2; |
---|
| 1685 | + display.color *= material.color*2; |
---|
1621 | 1686 | display.saturation *= material.modulation*2; |
---|
1622 | 1687 | } |
---|
1623 | 1688 | |
---|
1624 | 1689 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1625 | 1690 | |
---|
1626 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1691 | + float[] colorV = Grafreed.colorV; |
---|
1627 | 1692 | |
---|
1628 | 1693 | /**/ |
---|
1629 | 1694 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1631 | 1696 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1632 | 1697 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1633 | 1698 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1634 | | - colorV[3] = material.opacity; |
---|
| 1699 | + colorV[3] = 1; // material.opacity; |
---|
1635 | 1700 | |
---|
1636 | 1701 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1637 | 1702 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1739 | 1804 | display.modelParams7[2] = 0; |
---|
1740 | 1805 | display.modelParams7[3] = 0; |
---|
1741 | 1806 | |
---|
1742 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1807 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1743 | 1808 | |
---|
1744 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1809 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1745 | 1810 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1746 | 1811 | { |
---|
1747 | 1812 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1883 | 1948 | void PushMatrix(double[][] matrix) |
---|
1884 | 1949 | { |
---|
1885 | 1950 | // GrafreeD.tracein(matrix); |
---|
1886 | | - PushMatrix(matrix,1); |
---|
| 1951 | + PushMatrix(matrix, 1); |
---|
1887 | 1952 | } |
---|
1888 | 1953 | |
---|
1889 | 1954 | void PushMatrix() |
---|
.. | .. |
---|
2037 | 2102 | //System.err.println("Oeil on"); |
---|
2038 | 2103 | OEIL = true; |
---|
2039 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2040 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2041 | 2106 | //pingthread.StepToTarget(true); |
---|
2042 | 2107 | } |
---|
2043 | 2108 | |
---|
.. | .. |
---|
2135 | 2200 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
2136 | 2201 | |
---|
2137 | 2202 | if (!Globals.isLIVE()) // save sound |
---|
2138 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2203 | + Grafreed.savesound = true; // wav.save(); |
---|
2139 | 2204 | // else |
---|
2140 | 2205 | repaint(); // start loop // may 2013 |
---|
2141 | 2206 | } |
---|
.. | .. |
---|
2168 | 2233 | public void ToggleBoxMode() |
---|
2169 | 2234 | { |
---|
2170 | 2235 | BOXMODE ^= true; |
---|
| 2236 | + } |
---|
| 2237 | + |
---|
| 2238 | + public void ToggleZoomBoxMode() |
---|
| 2239 | + { |
---|
| 2240 | + ZOOMBOXMODE ^= true; |
---|
2171 | 2241 | } |
---|
2172 | 2242 | |
---|
2173 | 2243 | public void ToggleSmoothFocus() |
---|
.. | .. |
---|
2247 | 2317 | |
---|
2248 | 2318 | void ToggleDebug() |
---|
2249 | 2319 | { |
---|
2250 | | - DEBUG ^= true; |
---|
| 2320 | + Globals.DEBUG ^= true; |
---|
2251 | 2321 | } |
---|
2252 | 2322 | |
---|
2253 | 2323 | void ToggleLookAt() |
---|
.. | .. |
---|
2255 | 2325 | LOOKAT ^= true; |
---|
2256 | 2326 | } |
---|
2257 | 2327 | |
---|
2258 | | - void ToggleRandom() |
---|
| 2328 | + void ToggleSwitch() |
---|
2259 | 2329 | { |
---|
2260 | | - RANDOM ^= true; |
---|
| 2330 | + SWITCH ^= true; |
---|
2261 | 2331 | } |
---|
2262 | 2332 | |
---|
2263 | 2333 | void ToggleHandles() |
---|
.. | .. |
---|
2265 | 2335 | HANDLES ^= true; |
---|
2266 | 2336 | } |
---|
2267 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2268 | 2340 | void TogglePaint() |
---|
2269 | 2341 | { |
---|
2270 | 2342 | PAINTMODE ^= true; |
---|
2271 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2272 | 2349 | } |
---|
2273 | 2350 | |
---|
2274 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2364 | 2441 | { |
---|
2365 | 2442 | return currentGL; |
---|
2366 | 2443 | } |
---|
2367 | | - |
---|
| 2444 | + |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2368 | 2460 | /**/ |
---|
2369 | 2461 | class CacheTexture |
---|
2370 | 2462 | { |
---|
.. | .. |
---|
2373 | 2465 | |
---|
2374 | 2466 | int resolution; |
---|
2375 | 2467 | |
---|
2376 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2377 | 2469 | { |
---|
2378 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2379 | 2472 | resolution = res; |
---|
2380 | 2473 | } |
---|
2381 | 2474 | } |
---|
2382 | 2475 | /**/ |
---|
2383 | 2476 | |
---|
2384 | 2477 | // TEXTURE static Texture texture; |
---|
2385 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2386 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2387 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2388 | 2483 | int pigmentdepth = 0; |
---|
2389 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2390 | 2485 | int bumpdepth = 0; |
---|
2391 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2392 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2393 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2394 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2395 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2396 | 2491 | |
---|
2397 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2398 | 2493 | { |
---|
2399 | 2494 | TextureData texturedata = null; |
---|
2400 | 2495 | |
---|
.. | .. |
---|
2413 | 2508 | if (bump) |
---|
2414 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2415 | 2510 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2417 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2418 | 2513 | |
---|
2419 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2420 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2421 | 2516 | |
---|
2422 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2423 | 2539 | } |
---|
2424 | 2540 | |
---|
2425 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3492 | 3608 | |
---|
3493 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3494 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3495 | 3613 | // |
---|
3496 | 3614 | if (false) // compressbit > 0) |
---|
3497 | 3615 | { |
---|
.. | .. |
---|
4196 | 4314 | |
---|
4197 | 4315 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
4198 | 4316 | { |
---|
| 4317 | + new Exception().printStackTrace(); |
---|
4199 | 4318 | System.exit(0); |
---|
4200 | 4319 | com.sun.opengl.util.texture.Texture texture = null; |
---|
4201 | 4320 | |
---|
.. | .. |
---|
7889 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7890 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7891 | 8010 | |
---|
7892 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7893 | 8012 | { |
---|
7894 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7895 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7904 | 8023 | pigment = null; |
---|
7905 | 8024 | } |
---|
7906 | 8025 | |
---|
7907 | | - ReleaseTexture(bump, true); |
---|
7908 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7909 | 8028 | } |
---|
7910 | 8029 | |
---|
7911 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8030 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8031 | + { |
---|
| 8032 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8033 | + { |
---|
| 8034 | + return; |
---|
| 8035 | + } |
---|
| 8036 | + |
---|
| 8037 | + if (tex == null) |
---|
| 8038 | + { |
---|
| 8039 | + ReleaseTexture(null, false); |
---|
| 8040 | + return; |
---|
| 8041 | + } |
---|
| 8042 | + |
---|
| 8043 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8044 | + |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + { |
---|
| 8047 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8048 | + // System.out.println("; bump = " + bump); |
---|
| 8049 | + } |
---|
| 8050 | + |
---|
| 8051 | + if (pigment.equals("")) |
---|
| 8052 | + { |
---|
| 8053 | + pigment = null; |
---|
| 8054 | + } |
---|
| 8055 | + |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
| 8057 | + } |
---|
| 8058 | + |
---|
| 8059 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8060 | + { |
---|
| 8061 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8062 | + { |
---|
| 8063 | + return; |
---|
| 8064 | + } |
---|
| 8065 | + |
---|
| 8066 | + if (tex == null) |
---|
| 8067 | + { |
---|
| 8068 | + ReleaseTexture(null, true); |
---|
| 8069 | + return; |
---|
| 8070 | + } |
---|
| 8071 | + |
---|
| 8072 | + String bump = Object3D.GetBump(tex); |
---|
| 8073 | + |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + { |
---|
| 8076 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8077 | + // System.out.println("; bump = " + bump); |
---|
| 8078 | + } |
---|
| 8079 | + |
---|
| 8080 | + if (bump.equals("")) |
---|
| 8081 | + { |
---|
| 8082 | + bump = null; |
---|
| 8083 | + } |
---|
| 8084 | + |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
| 8086 | + } |
---|
| 8087 | + |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7912 | 8089 | { |
---|
7913 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7914 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7919 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7920 | 8097 | |
---|
7921 | 8098 | if (tex != null) |
---|
7922 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
7923 | 8100 | |
---|
7924 | 8101 | // //assert( texture != null ); |
---|
7925 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8011 | 8188 | } |
---|
8012 | 8189 | } |
---|
8013 | 8190 | |
---|
8014 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8191 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8192 | + { |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
| 8234 | + |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
| 8237 | + } |
---|
| 8238 | + |
---|
| 8239 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8015 | 8240 | { |
---|
8016 | 8241 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8017 | 8242 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8022 | 8247 | if (tex == null) |
---|
8023 | 8248 | { |
---|
8024 | 8249 | BindTexture(null,false,resolution); |
---|
8025 | | - BindTexture(null,true,resolution); |
---|
8026 | 8250 | return; |
---|
8027 | 8251 | } |
---|
8028 | 8252 | |
---|
8029 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
| 8254 | + |
---|
| 8255 | + usedtextures.add(tex); |
---|
| 8256 | + |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + { |
---|
| 8259 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8260 | + // System.out.println("; bump = " + bump); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + if (pigment.equals("")) |
---|
| 8264 | + { |
---|
| 8265 | + pigment = null; |
---|
| 8266 | + } |
---|
| 8267 | + |
---|
| 8268 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
| 8270 | + } |
---|
| 8271 | + |
---|
| 8272 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8273 | + { |
---|
| 8274 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8275 | + ambientOcclusion ) // || !textureon) |
---|
| 8276 | + { |
---|
| 8277 | + return; // false; |
---|
| 8278 | + } |
---|
| 8279 | + |
---|
| 8280 | + if (tex == null) |
---|
| 8281 | + { |
---|
| 8282 | + BindTexture(null,true,resolution); |
---|
| 8283 | + return; |
---|
| 8284 | + } |
---|
| 8285 | + |
---|
8030 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8031 | 8287 | |
---|
8032 | | - usedtextures.put(pigment, pigment); |
---|
8033 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8034 | 8289 | |
---|
8035 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8036 | 8291 | { |
---|
8037 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8038 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8042 | 8297 | { |
---|
8043 | 8298 | bump = null; |
---|
8044 | 8299 | } |
---|
8045 | | - if (pigment.equals("")) |
---|
8046 | | - { |
---|
8047 | | - pigment = null; |
---|
8048 | | - } |
---|
8049 | 8300 | |
---|
8050 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8051 | | - BindTexture(pigment, false, resolution); |
---|
8052 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8053 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8054 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8055 | | - |
---|
8056 | | - return; // true; |
---|
8057 | 8304 | } |
---|
8058 | 8305 | |
---|
8059 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8306 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8307 | + |
---|
| 8308 | + private boolean FileExists(String tex) |
---|
8060 | 8309 | { |
---|
8061 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8310 | + if (missingTextures.contains(tex)) |
---|
| 8311 | + { |
---|
| 8312 | + return false; |
---|
| 8313 | + } |
---|
| 8314 | + |
---|
| 8315 | + boolean fileExists = new File(tex).exists(); |
---|
| 8316 | + |
---|
| 8317 | + if (!fileExists) |
---|
| 8318 | + { |
---|
| 8319 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8320 | + missingTextures.add(tex); |
---|
| 8321 | + } |
---|
| 8322 | + |
---|
| 8323 | + return fileExists; |
---|
| 8324 | + } |
---|
| 8325 | + |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + { |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8062 | 8329 | |
---|
8063 | 8330 | if (tex != null) |
---|
8064 | 8331 | { |
---|
8065 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
8066 | 8334 | |
---|
8067 | | - String[] split = tex.split("Textures"); |
---|
8068 | | - if (split.length > 1) |
---|
8069 | | - texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
8070 | | - else |
---|
8071 | | - if (!texname.startsWith("/")) |
---|
8072 | | - texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
| 8339 | + |
---|
| 8340 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8341 | + |
---|
| 8342 | +// String[] split = tex.split("Textures"); |
---|
| 8343 | +// if (split.length > 1) |
---|
| 8344 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8345 | +// else |
---|
| 8346 | +// if (!texname.startsWith("/")) |
---|
| 8347 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8348 | + if (!FileExists(texname)) |
---|
| 8349 | + { |
---|
| 8350 | + texname = fallbackTextureName; |
---|
| 8351 | + } |
---|
8073 | 8352 | |
---|
8074 | 8353 | if (CACHETEXTURE) |
---|
8075 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8076 | | - |
---|
8077 | | - TextureData texturedata = null; |
---|
8078 | | - |
---|
8079 | | - if (texture == null || texture.resolution < resolution) |
---|
8080 | 8354 | { |
---|
8081 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8082 | 8388 | { |
---|
8083 | 8389 | assert(!bump); |
---|
8084 | 8390 | // if (bump) |
---|
.. | .. |
---|
8089 | 8395 | // } |
---|
8090 | 8396 | // else |
---|
8091 | 8397 | // { |
---|
8092 | | - texture = textures.get(tex); |
---|
8093 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8094 | 8400 | { |
---|
8095 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8096 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8097 | 8405 | // } |
---|
8098 | 8406 | } else |
---|
8099 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8100 | 8408 | { |
---|
8101 | 8409 | assert(bump); |
---|
8102 | | - texture = textures.get(tex); |
---|
8103 | | - if (texture == null) |
---|
8104 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
8105 | 8415 | } else |
---|
8106 | 8416 | { |
---|
8107 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8109 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8110 | 8420 | //} else |
---|
8111 | 8421 | //{ |
---|
8112 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8113 | 8423 | { |
---|
8114 | | - texture = textures.get(tex); |
---|
8115 | | - if (texture == null) |
---|
8116 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
8117 | 8429 | } else |
---|
8118 | 8430 | { |
---|
8119 | 8431 | if (textureon) |
---|
.. | .. |
---|
8138 | 8450 | } |
---|
8139 | 8451 | |
---|
8140 | 8452 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8141 | | - if (!new File(cachename).exists()) |
---|
| 8453 | + if (!FileExists(cachename)) |
---|
8142 | 8454 | cachename = texname; |
---|
8143 | 8455 | else |
---|
8144 | 8456 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8160 | 8472 | } |
---|
8161 | 8473 | |
---|
8162 | 8474 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8163 | | - if (!new File(cachename).exists()) |
---|
| 8475 | + if (!FileExists(cachename)) |
---|
8164 | 8476 | cachename = texname; |
---|
8165 | 8477 | else |
---|
8166 | 8478 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8169 | 8481 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8170 | 8482 | |
---|
8171 | 8483 | |
---|
8172 | | - if (texturedata != null) |
---|
8173 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8484 | + if (texturedata == null) |
---|
| 8485 | + throw new Exception(); |
---|
| 8486 | + |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8174 | 8488 | //texture = GetTexture(tex, bump); |
---|
8175 | 8489 | } |
---|
8176 | 8490 | } |
---|
8177 | 8491 | //} |
---|
8178 | 8492 | } |
---|
8179 | 8493 | |
---|
8180 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8181 | 8495 | { |
---|
8182 | 8496 | //return false; |
---|
8183 | 8497 | |
---|
8184 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8185 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8186 | 8500 | { |
---|
8187 | 8501 | // String ext = "_highres"; |
---|
8188 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8199 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8200 | 8514 | if (!cachefile.exists()) |
---|
8201 | 8515 | { |
---|
8202 | | - // cache to disk |
---|
8203 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8204 | | - //buffers[0]. |
---|
8205 | | - |
---|
8206 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8207 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8208 | | - |
---|
8209 | | - // squared size heuristic... |
---|
8210 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8211 | 8517 | { |
---|
8212 | | - for (int i=pixels.length; --i>=0;) |
---|
8213 | | - { |
---|
8214 | | - int i3 = i*3; |
---|
8215 | | - pixels[i] = 0xFF; |
---|
8216 | | - pixels[i] <<= 8; |
---|
8217 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8218 | | - pixels[i] <<= 8; |
---|
8219 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8220 | | - pixels[i] <<= 8; |
---|
8221 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8222 | | - } |
---|
8223 | | - |
---|
8224 | | - /* |
---|
8225 | | - int r=0,g=0,b=0,a=0; |
---|
8226 | | - for (int i=0; i<width; i++) |
---|
8227 | | - for (int j=0; j<height; j++) |
---|
8228 | | - { |
---|
8229 | | - int index = j*width+i; |
---|
8230 | | - int p = pixels[index]; |
---|
8231 | | - a = ((p>>24) & 0xFF); |
---|
8232 | | - r = ((p>>16) & 0xFF); |
---|
8233 | | - g = ((p>>8) & 0xFF); |
---|
8234 | | - b = (p & 0xFF); |
---|
8235 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8236 | | - } |
---|
8237 | | - /**/ |
---|
8238 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8239 | | - int height = width; |
---|
8240 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8241 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8242 | 8520 | ImageWriter writer = null; |
---|
8243 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8244 | 8522 | if (iter.hasNext()) { |
---|
8245 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8246 | 8524 | } |
---|
8247 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8248 | 8527 | try |
---|
8249 | 8528 | { |
---|
8250 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8261 | 8540 | } |
---|
8262 | 8541 | } |
---|
8263 | 8542 | } |
---|
8264 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8265 | 8546 | //System.out.println("Texture = " + tex); |
---|
8266 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8267 | 8548 | { |
---|
8268 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8269 | 8550 | thetex.texture.disable(); |
---|
8270 | 8551 | thetex.texture.dispose(); |
---|
8271 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8272 | 8553 | } |
---|
8273 | 8554 | |
---|
8274 | | - texture.texturedata = texturedata; |
---|
8275 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8276 | 8557 | |
---|
8277 | 8558 | // newtex = true; |
---|
8278 | 8559 | } |
---|
.. | .. |
---|
8288 | 8569 | } |
---|
8289 | 8570 | } |
---|
8290 | 8571 | |
---|
8291 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8292 | 8573 | } |
---|
8293 | 8574 | |
---|
8294 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8295 | 8610 | { |
---|
8296 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8297 | 8612 | |
---|
.. | .. |
---|
8309 | 8624 | return texture!=null?texture.texture:null; |
---|
8310 | 8625 | } |
---|
8311 | 8626 | |
---|
8312 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8313 | 8628 | { |
---|
8314 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8315 | 8630 | |
---|
8316 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8317 | 8632 | } |
---|
8318 | 8633 | |
---|
8319 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8320 | 8635 | { |
---|
8321 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8322 | 8637 | { |
---|
8323 | 8638 | return false; |
---|
8324 | 8639 | } |
---|
8325 | 8640 | |
---|
8326 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8327 | 8642 | |
---|
8328 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8329 | 8644 | |
---|
.. | .. |
---|
8355 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8356 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8357 | 8672 | |
---|
8358 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8359 | 8674 | } |
---|
8360 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8361 | 8742 | ShadowBuffer shadowPBuf; |
---|
8362 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8363 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
9193 | 9574 | jy8[3] = 0.5f; |
---|
9194 | 9575 | } |
---|
9195 | 9576 | |
---|
9196 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9197 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9198 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9199 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9200 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
9201 | 9606 | static int imagecount = 0; // movie generation |
---|
9202 | 9607 | |
---|
9203 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
9293 | 9698 | assert (parentcam != renderCamera); |
---|
9294 | 9699 | |
---|
9295 | 9700 | if (renderCamera != lightCamera) |
---|
9296 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9297 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9701 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9702 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9298 | 9703 | |
---|
9299 | 9704 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9300 | 9705 | |
---|
.. | .. |
---|
9309 | 9714 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9310 | 9715 | |
---|
9311 | 9716 | if (renderCamera != lightCamera) |
---|
9312 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9313 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9717 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9718 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9314 | 9719 | |
---|
9315 | 9720 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9316 | 9721 | |
---|
.. | .. |
---|
9382 | 9787 | //gl.glFlush(); |
---|
9383 | 9788 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9384 | 9789 | |
---|
9385 | | - if (ANIMATION && ABORTED) |
---|
| 9790 | + if (Globals.ANIMATION && ABORTED) |
---|
9386 | 9791 | { |
---|
9387 | 9792 | System.err.println(" ABORTED FRAME"); |
---|
9388 | 9793 | break; |
---|
.. | .. |
---|
9412 | 9817 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9413 | 9818 | |
---|
9414 | 9819 | // save image |
---|
9415 | | - if (ANIMATION && !ABORTED) |
---|
| 9820 | + if (Globals.ANIMATION && !ABORTED) |
---|
9416 | 9821 | { |
---|
9417 | 9822 | VPwidth = viewport[2]; |
---|
9418 | 9823 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9523 | 9928 | |
---|
9524 | 9929 | // imagecount++; |
---|
9525 | 9930 | |
---|
9526 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9931 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
9527 | 9932 | |
---|
9528 | 9933 | if (!BOXMODE) |
---|
9529 | 9934 | { |
---|
9530 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9935 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9531 | 9936 | } |
---|
9532 | 9937 | |
---|
9533 | 9938 | if (!BOXMODE) |
---|
.. | .. |
---|
9565 | 9970 | ABORTED = false; |
---|
9566 | 9971 | } |
---|
9567 | 9972 | else |
---|
9568 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9973 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9569 | 9974 | |
---|
9570 | 9975 | if (false) |
---|
9571 | 9976 | { |
---|
.. | .. |
---|
10228 | 10633 | |
---|
10229 | 10634 | public void display(GLAutoDrawable drawable) |
---|
10230 | 10635 | { |
---|
10231 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10636 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
10232 | 10637 | { |
---|
10233 | | - GrafreeD.wav.save(); |
---|
10234 | | - GrafreeD.savesound = false; |
---|
10235 | | - GrafreeD.hassound = false; |
---|
| 10638 | + Grafreed.wav.save(); |
---|
| 10639 | + Grafreed.savesound = false; |
---|
| 10640 | + Grafreed.hassound = false; |
---|
10236 | 10641 | } |
---|
10237 | 10642 | // if (DEBUG_SELECTION) |
---|
10238 | 10643 | // { |
---|
.. | .. |
---|
10308 | 10713 | ANTIALIAS = 0; |
---|
10309 | 10714 | //System.out.println("RESTART"); |
---|
10310 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
10311 | 10717 | } |
---|
10312 | 10718 | } |
---|
10313 | 10719 | } |
---|
.. | .. |
---|
10362 | 10768 | Object3D theobject = object; |
---|
10363 | 10769 | Object3D theparent = object.parent; |
---|
10364 | 10770 | object.parent = null; |
---|
10365 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10771 | + object = (Object3D)Grafreed.clone(object); |
---|
10366 | 10772 | object.Stripify(); |
---|
10367 | 10773 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10368 | 10774 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10375 | 10781 | ambientOcclusion = false; |
---|
10376 | 10782 | } |
---|
10377 | 10783 | |
---|
10378 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10784 | + if (//Globals.lighttouched && |
---|
| 10785 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10379 | 10786 | { |
---|
10380 | 10787 | //if (RENDERSHADOW) // ? |
---|
10381 | 10788 | if (!IsFrozen()) |
---|
10382 | 10789 | { |
---|
10383 | 10790 | // dec 2012 |
---|
10384 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10791 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10385 | 10792 | { |
---|
10386 | 10793 | Globals.framecount++; |
---|
10387 | 10794 | shadowbuffer.display(); |
---|
.. | .. |
---|
10508 | 10915 | |
---|
10509 | 10916 | // if (parentcam != renderCamera) // not a light |
---|
10510 | 10917 | if (cam != lightCamera) |
---|
10511 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10512 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10918 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10919 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10513 | 10920 | |
---|
10514 | 10921 | for (int j = 0; j < 4; j++) |
---|
10515 | 10922 | { |
---|
.. | .. |
---|
10523 | 10930 | |
---|
10524 | 10931 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10932 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10933 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10934 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10528 | 10935 | |
---|
10529 | 10936 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10530 | 10937 | |
---|
.. | .. |
---|
10783 | 11190 | // Bump noise |
---|
10784 | 11191 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10785 | 11192 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10786 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11193 | + |
---|
| 11194 | + try |
---|
| 11195 | + { |
---|
| 11196 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11197 | + } |
---|
| 11198 | + catch (Exception e) |
---|
| 11199 | + { |
---|
| 11200 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11201 | + } |
---|
| 11202 | + |
---|
10787 | 11203 | |
---|
10788 | 11204 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10789 | 11205 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10806 | 11222 | |
---|
10807 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10808 | 11224 | |
---|
10809 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10810 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10811 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10812 | 11228 | } else |
---|
10813 | 11229 | { |
---|
10814 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10819 | 11235 | //System.out.println("BLENDING ON"); |
---|
10820 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
10821 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10822 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10823 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10824 | 11240 | gl.glLoadIdentity(); |
---|
10825 | 11241 | |
---|
.. | .. |
---|
10908 | 11324 | System.err.println("parentcam != renderCamera"); |
---|
10909 | 11325 | |
---|
10910 | 11326 | // if (cam != lightCamera) |
---|
10911 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10912 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11327 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11328 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10913 | 11329 | } |
---|
10914 | 11330 | |
---|
10915 | 11331 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10930 | 11346 | if (true) // TODO |
---|
10931 | 11347 | { |
---|
10932 | 11348 | if (cam != lightCamera) |
---|
10933 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11349 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11350 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10935 | 11351 | } |
---|
10936 | 11352 | |
---|
10937 | 11353 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11068 | 11484 | } |
---|
11069 | 11485 | } |
---|
11070 | 11486 | |
---|
11071 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11072 | 11488 | { |
---|
11073 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11074 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11076 | 11492 | |
---|
11077 | 11493 | boolean texon = textureon; |
---|
11078 | 11494 | |
---|
11079 | | - if (RENDERPROGRAM > 0) |
---|
11080 | | - { |
---|
11081 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11082 | | - textureon = false; |
---|
11083 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11084 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11085 | 11499 | //System.out.println("ALLO"); |
---|
11086 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11087 | 11501 | DrawObject(gl); |
---|
11088 | | - if (RENDERPROGRAM > 0) |
---|
11089 | | - { |
---|
11090 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11091 | | - textureon = texon; |
---|
11092 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11093 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11094 | 11507 | |
---|
11095 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11096 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11097 | 11510 | } |
---|
11098 | 11511 | |
---|
11099 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11247 | 11660 | { |
---|
11248 | 11661 | renderpass++; |
---|
11249 | 11662 | // System.out.println("Draw object... "); |
---|
| 11663 | + STEP = 1; |
---|
11250 | 11664 | if (FAST) // in case there is no script |
---|
11251 | | - STEP = 16; |
---|
| 11665 | + STEP = 8; |
---|
| 11666 | + |
---|
| 11667 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11668 | + { |
---|
| 11669 | + STEP *= 4; |
---|
| 11670 | + } |
---|
11252 | 11671 | |
---|
11253 | 11672 | //object.FullInvariants(); |
---|
11254 | 11673 | |
---|
.. | .. |
---|
11262 | 11681 | e.printStackTrace(); |
---|
11263 | 11682 | } |
---|
11264 | 11683 | |
---|
11265 | | - if (GrafreeD.RENDERME > 0) |
---|
11266 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11684 | + if (Grafreed.RENDERME > 0) |
---|
| 11685 | + Grafreed.RENDERME--; // mechante magouille |
---|
11267 | 11686 | |
---|
11268 | 11687 | Globals.ONESTEP = false; |
---|
11269 | 11688 | } |
---|
11270 | 11689 | |
---|
11271 | 11690 | static boolean zoomonce = false; |
---|
11272 | 11691 | |
---|
| 11692 | + static void CreateSelectedPoint() |
---|
| 11693 | + { |
---|
| 11694 | + if (selectedpoint == null) |
---|
| 11695 | + { |
---|
| 11696 | + debugpointG = new Sphere(); |
---|
| 11697 | + debugpointP = new Sphere(); |
---|
| 11698 | + debugpointC = new Sphere(); |
---|
| 11699 | + debugpointR = new Sphere(); |
---|
| 11700 | + |
---|
| 11701 | + selectedpoint = new Superellipsoid(); |
---|
| 11702 | + |
---|
| 11703 | + for (int i=0; i<8; i++) |
---|
| 11704 | + { |
---|
| 11705 | + debugpoints[i] = new Sphere(); |
---|
| 11706 | + } |
---|
| 11707 | + } |
---|
| 11708 | + } |
---|
| 11709 | + |
---|
11273 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
11274 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
11275 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11276 | 11716 | // DrawMode() = SELECTION; |
---|
11277 | 11717 | //GL gl = getGL(); |
---|
11278 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11279 | 11719 | { |
---|
11280 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11281 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11282 | 11722 | pingthread.StepToTarget(true); // true); |
---|
11283 | 11723 | // zoomonce = false; |
---|
11284 | 11724 | } |
---|
.. | .. |
---|
11333 | 11773 | |
---|
11334 | 11774 | usedtextures.clear(); |
---|
11335 | 11775 | |
---|
11336 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11776 | + try |
---|
| 11777 | + { |
---|
| 11778 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11779 | + } |
---|
| 11780 | + catch (Exception e) |
---|
| 11781 | + { |
---|
| 11782 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11783 | + } |
---|
11337 | 11784 | } |
---|
11338 | 11785 | //System.out.println("--> " + stackdepth); |
---|
11339 | 11786 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11343 | 11790 | |
---|
11344 | 11791 | if (DrawMode() == DEFAULT) |
---|
11345 | 11792 | { |
---|
11346 | | - if (DEBUG) |
---|
| 11793 | + if (Globals.DEBUG) |
---|
11347 | 11794 | { |
---|
| 11795 | + CreateSelectedPoint(); |
---|
11348 | 11796 | float radius = 0.05f; |
---|
11349 | 11797 | if (selectedpoint.radius != radius) |
---|
11350 | 11798 | { |
---|
.. | .. |
---|
11398 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11399 | 11847 | |
---|
11400 | 11848 | if (CLEANCACHE) |
---|
11401 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11402 | 11850 | { |
---|
11403 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11404 | 11852 | |
---|
11405 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11406 | 11854 | |
---|
11407 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11408 | 11856 | continue; |
---|
11409 | 11857 | |
---|
11410 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11411 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11412 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11413 | | - textures.get(tex).texture.dispose(); |
---|
11414 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
11415 | 11875 | } |
---|
11416 | 11876 | } |
---|
11417 | 11877 | } |
---|
.. | .. |
---|
11424 | 11884 | if (checker != null && DrawMode() == DEFAULT) |
---|
11425 | 11885 | { |
---|
11426 | 11886 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11427 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11887 | + try |
---|
| 11888 | + { |
---|
| 11889 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11890 | + } |
---|
| 11891 | + catch (Exception e) |
---|
| 11892 | + { |
---|
| 11893 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11894 | + } |
---|
11428 | 11895 | // NEAREST |
---|
11429 | 11896 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11430 | 11897 | DrawChecker(gl); |
---|
.. | .. |
---|
11506 | 11973 | return; |
---|
11507 | 11974 | } |
---|
11508 | 11975 | |
---|
11509 | | - String string = obj.GetToolTip(); |
---|
| 11976 | + String string = obj.toString(); //.GetToolTip(); |
---|
11510 | 11977 | |
---|
11511 | 11978 | GL gl = GetGL(); |
---|
11512 | 11979 | |
---|
.. | .. |
---|
11823 | 12290 | //obj.TransformToWorld(light, light); |
---|
11824 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
11825 | 12292 | { |
---|
11826 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11827 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12293 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11828 | 12295 | } |
---|
11829 | 12296 | |
---|
11830 | 12297 | |
---|
.. | .. |
---|
11841 | 12308 | parentcam = cameras[0]; |
---|
11842 | 12309 | } |
---|
11843 | 12310 | |
---|
11844 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11845 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12311 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12312 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11846 | 12313 | |
---|
11847 | 12314 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11848 | 12315 | |
---|
.. | .. |
---|
12456 | 12923 | |
---|
12457 | 12924 | // display shadow only (bump == 0) |
---|
12458 | 12925 | "SUB temp.x, half.x, shadow.x;" + |
---|
12459 | | - "MOV temp.y, -params6.x;" + |
---|
12460 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12926 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12927 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12461 | 12928 | "SUB temp.y, one.x, temp.z;" + |
---|
12462 | 12929 | "MUL temp.x, temp.x, temp.y;" + |
---|
12463 | 12930 | "KIL temp.x;" + |
---|
.. | .. |
---|
12586 | 13053 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12587 | 13054 | |
---|
12588 | 13055 | "SUB temp.x, one.x, ndotl.x;" + |
---|
12589 | | - "ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
12590 | | - "ADD temp.y, one.y, options2.y;" + // sursurface |
---|
| 13056 | + // Tuning for default skin |
---|
| 13057 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 13058 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 13059 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12591 | 13060 | "MUL temp.x, temp.x, temp.y;" + |
---|
12592 | 13061 | |
---|
12593 | 13062 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12786 | 13255 | //once = true; |
---|
12787 | 13256 | } |
---|
12788 | 13257 | |
---|
12789 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13258 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12790 | 13259 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12791 | 13260 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12792 | 13261 | |
---|
.. | .. |
---|
12919 | 13388 | |
---|
12920 | 13389 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12921 | 13390 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13391 | + |
---|
| 13392 | + // Compare fragment depth in light space with shadowmap. |
---|
12922 | 13393 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12923 | 13394 | "SGE temp.y, temp.x, zero.x;" + |
---|
12924 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13395 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13396 | + |
---|
| 13397 | + // Reverse comparison |
---|
12925 | 13398 | "SUB temp.x, one.x, temp.x;" + |
---|
12926 | 13399 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12927 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13400 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12928 | 13401 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12929 | 13402 | |
---|
12930 | 13403 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12938 | 13411 | // No shadow for backface |
---|
12939 | 13412 | "DP3 temp.x, normal, lightd;" + |
---|
12940 | 13413 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13414 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13415 | + |
---|
| 13416 | + // No shadow when out of frustrum |
---|
| 13417 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12941 | 13418 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12942 | 13419 | ""; |
---|
12943 | 13420 | } |
---|
.. | .. |
---|
13084 | 13561 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13085 | 13562 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13086 | 13563 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13087 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13564 | + |
---|
| 13565 | + //Object3D.cVector2[] vector2buffer; |
---|
13088 | 13566 | |
---|
13089 | 13567 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13090 | 13568 | // OUT : diff, spec |
---|
.. | .. |
---|
13100 | 13578 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13101 | 13579 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13102 | 13580 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13103 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13104 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13105 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13581 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13582 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13583 | + |
---|
| 13584 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13106 | 13585 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13107 | 13586 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13108 | 13587 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13496 | 13975 | public void mousePressed(MouseEvent e) |
---|
13497 | 13976 | { |
---|
13498 | 13977 | //System.out.println("mousePressed: " + e); |
---|
13499 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13978 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13500 | 13979 | } |
---|
13501 | 13980 | |
---|
13502 | 13981 | static long prevtime = 0; |
---|
.. | .. |
---|
13523 | 14002 | |
---|
13524 | 14003 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
13525 | 14004 | |
---|
| 14005 | + if (BUTTONLESSWHEEL) |
---|
13526 | 14006 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
13527 | 14007 | { |
---|
13528 | 14008 | return; |
---|
.. | .. |
---|
13531 | 14011 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13532 | 14012 | |
---|
13533 | 14013 | // TIMER |
---|
13534 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 14014 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
13535 | 14015 | { |
---|
13536 | 14016 | keepboxmode = BOXMODE; |
---|
13537 | 14017 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13571 | 14051 | // mode |= META; |
---|
13572 | 14052 | //} |
---|
13573 | 14053 | |
---|
13574 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13575 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 14054 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 14055 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13576 | 14056 | anchorX = ax; |
---|
13577 | 14057 | anchorY = ay; |
---|
13578 | 14058 | prevX = px; |
---|
.. | .. |
---|
13606 | 14086 | else |
---|
13607 | 14087 | if (evt.getSource() == AAtimer) |
---|
13608 | 14088 | { |
---|
| 14089 | + Globals.TIMERRUNNING = false; |
---|
13609 | 14090 | if (mouseDown) |
---|
13610 | 14091 | { |
---|
13611 | 14092 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13631 | 14112 | // LIVE = waslive; |
---|
13632 | 14113 | // wasliveok = true; |
---|
13633 | 14114 | // waslive = false; |
---|
| 14115 | + |
---|
| 14116 | + // May 2019 Forget it: |
---|
| 14117 | + if (true) |
---|
| 14118 | + return; |
---|
13634 | 14119 | |
---|
13635 | 14120 | // source == timer |
---|
13636 | 14121 | if (mouseDown) |
---|
.. | .. |
---|
13661 | 14146 | |
---|
13662 | 14147 | // fev 2014??? |
---|
13663 | 14148 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13664 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14149 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13665 | 14150 | pingthread.StepToTarget(true); // true); |
---|
13666 | 14151 | } |
---|
13667 | 14152 | // if (!LIVE) |
---|
.. | .. |
---|
13670 | 14155 | |
---|
13671 | 14156 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13672 | 14157 | |
---|
13673 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14158 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13674 | 14159 | { |
---|
13675 | 14160 | if (!wasliveok) |
---|
13676 | 14161 | return; |
---|
13677 | 14162 | |
---|
13678 | 14163 | AAtimer.restart(); // |
---|
| 14164 | + Globals.TIMERRUNNING = true; |
---|
13679 | 14165 | |
---|
13680 | 14166 | // waslive = LIVE; |
---|
13681 | 14167 | // LIVE = false; |
---|
.. | .. |
---|
13687 | 14173 | // touched = true; // main DL |
---|
13688 | 14174 | if (isRenderer) |
---|
13689 | 14175 | { |
---|
13690 | | - SetMouseMode(modifiers); |
---|
| 14176 | + SetMouseMode(modifiers, modifiersex); |
---|
13691 | 14177 | } |
---|
13692 | 14178 | |
---|
13693 | 14179 | selectX = anchorX = x; |
---|
.. | .. |
---|
13700 | 14186 | clicked = true; |
---|
13701 | 14187 | hold = false; |
---|
13702 | 14188 | |
---|
13703 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14189 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13704 | 14190 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13705 | 14191 | { |
---|
13706 | 14192 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13731 | 14217 | info.camera = renderCamera; |
---|
13732 | 14218 | info.x = x; |
---|
13733 | 14219 | info.y = y; |
---|
13734 | | - info.modifiers = modifiers; |
---|
| 14220 | + info.modifiers = modifiersex; |
---|
13735 | 14221 | editObj = object.doEditClick(info, 0); |
---|
13736 | 14222 | if (!editObj) |
---|
13737 | 14223 | { |
---|
.. | .. |
---|
13748 | 14234 | |
---|
13749 | 14235 | public void mouseDragged(MouseEvent e) |
---|
13750 | 14236 | { |
---|
| 14237 | + Globals.MOUSEDRAGGED = true; |
---|
| 14238 | + |
---|
| 14239 | + //System.out.println("mouseDragged: " + e); |
---|
13751 | 14240 | if (isRenderer) |
---|
13752 | 14241 | movingcamera = true; |
---|
| 14242 | + |
---|
13753 | 14243 | //if (drawing) |
---|
13754 | 14244 | //return; |
---|
13755 | | - //System.out.println("mouseDragged: " + e); |
---|
13756 | 14245 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13757 | 14246 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13758 | 14247 | { |
---|
.. | .. |
---|
13760 | 14249 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13761 | 14250 | } |
---|
13762 | 14251 | else |
---|
13763 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14252 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13764 | 14253 | |
---|
13765 | 14254 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13766 | 14255 | } |
---|
.. | .. |
---|
13933 | 14422 | |
---|
13934 | 14423 | public void run() |
---|
13935 | 14424 | { |
---|
| 14425 | + new Exception().printStackTrace(); |
---|
13936 | 14426 | System.exit(0); |
---|
13937 | 14427 | for (;;) |
---|
13938 | 14428 | { |
---|
.. | .. |
---|
13996 | 14486 | { |
---|
13997 | 14487 | Globals.lighttouched = true; |
---|
13998 | 14488 | } |
---|
13999 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14489 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
14000 | 14490 | } |
---|
14001 | 14491 | //else |
---|
14002 | 14492 | } |
---|
.. | .. |
---|
14010 | 14500 | void GoDown(int mod) |
---|
14011 | 14501 | { |
---|
14012 | 14502 | MODIFIERS |= COMMAND; |
---|
14013 | | - /* |
---|
| 14503 | + /**/ |
---|
14014 | 14504 | if((mod&SHIFT) == SHIFT) |
---|
14015 | 14505 | manipCamera.RotatePosition(0, -speed); |
---|
14016 | 14506 | else |
---|
14017 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14018 | | - */ |
---|
| 14507 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14508 | + /**/ |
---|
14019 | 14509 | if ((mod & SHIFT) == SHIFT) |
---|
14020 | 14510 | { |
---|
14021 | 14511 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14031 | 14521 | void GoUp(int mod) |
---|
14032 | 14522 | { |
---|
14033 | 14523 | MODIFIERS |= COMMAND; |
---|
14034 | | - /* |
---|
| 14524 | + /**/ |
---|
14035 | 14525 | if((mod&SHIFT) == SHIFT) |
---|
14036 | 14526 | manipCamera.RotatePosition(0, speed); |
---|
14037 | 14527 | else |
---|
14038 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14039 | | - */ |
---|
| 14528 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14529 | + /**/ |
---|
14040 | 14530 | if ((mod & SHIFT) == SHIFT) |
---|
14041 | 14531 | { |
---|
14042 | 14532 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14052 | 14542 | void GoLeft(int mod) |
---|
14053 | 14543 | { |
---|
14054 | 14544 | MODIFIERS |= COMMAND; |
---|
14055 | | - /* |
---|
| 14545 | + /**/ |
---|
14056 | 14546 | if((mod&SHIFT) == SHIFT) |
---|
14057 | | - manipCamera.RotatePosition(speed, 0); |
---|
14058 | | - else |
---|
14059 | 14547 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14060 | | - */ |
---|
| 14548 | + else |
---|
| 14549 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14550 | + /**/ |
---|
14061 | 14551 | if ((mod & SHIFT) == SHIFT) |
---|
14062 | 14552 | { |
---|
14063 | 14553 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14073 | 14563 | void GoRight(int mod) |
---|
14074 | 14564 | { |
---|
14075 | 14565 | MODIFIERS |= COMMAND; |
---|
14076 | | - /* |
---|
| 14566 | + /**/ |
---|
14077 | 14567 | if((mod&SHIFT) == SHIFT) |
---|
14078 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14079 | | - else |
---|
14080 | 14568 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14081 | | - */ |
---|
| 14569 | + else |
---|
| 14570 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14571 | + /**/ |
---|
14082 | 14572 | if ((mod & SHIFT) == SHIFT) |
---|
14083 | 14573 | { |
---|
14084 | 14574 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14096 | 14586 | int X, Y; |
---|
14097 | 14587 | boolean SX, SY; |
---|
14098 | 14588 | |
---|
14099 | | - void drag(int x, int y, int modifiers) |
---|
| 14589 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
14100 | 14590 | { |
---|
14101 | 14591 | if (IsFrozen()) |
---|
14102 | 14592 | { |
---|
.. | .. |
---|
14105 | 14595 | |
---|
14106 | 14596 | drag = true; // NEW |
---|
14107 | 14597 | |
---|
14108 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14598 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
14109 | 14599 | |
---|
14110 | 14600 | X = x; |
---|
14111 | 14601 | Y = y; |
---|
14112 | 14602 | // floating state for animation |
---|
14113 | | - MODIFIERS = modifiers; |
---|
14114 | | - modifiers &= ~1024; |
---|
| 14603 | + MODIFIERS = modifiersex; |
---|
| 14604 | + modifiersex &= ~1024; |
---|
14115 | 14605 | if (false) // modifiers != 0) |
---|
14116 | 14606 | { |
---|
14117 | 14607 | //new Exception().printStackTrace(); |
---|
14118 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14608 | + System.out.println("mouseDragged: " + modifiersex); |
---|
14119 | 14609 | System.out.println("SHIFT = " + SHIFT); |
---|
14120 | 14610 | System.out.println("CONTROL = " + COMMAND); |
---|
14121 | 14611 | System.out.println("META = " + META); |
---|
.. | .. |
---|
14135 | 14625 | info.camera = renderCamera; |
---|
14136 | 14626 | info.x = x; |
---|
14137 | 14627 | info.y = y; |
---|
14138 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14628 | + object.GetWindow().copy |
---|
| 14629 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14139 | 14630 | } else |
---|
14140 | 14631 | { |
---|
14141 | 14632 | if (x < startX) |
---|
.. | .. |
---|
14287 | 14778 | public void mouseMoved(MouseEvent e) |
---|
14288 | 14779 | { |
---|
14289 | 14780 | //System.out.println("mouseMoved: " + e); |
---|
14290 | | - |
---|
14291 | 14781 | if (isRenderer) |
---|
14292 | 14782 | return; |
---|
14293 | 14783 | |
---|
.. | .. |
---|
14300 | 14790 | ci.camera = renderCamera; |
---|
14301 | 14791 | if (!isRenderer) |
---|
14302 | 14792 | { |
---|
14303 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14793 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14794 | + //Object3D copy = editWindow.copy; |
---|
| 14795 | + if (object.doEditClick(ci, 0)) |
---|
14304 | 14796 | { |
---|
14305 | 14797 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14306 | 14798 | } else |
---|
.. | .. |
---|
14312 | 14804 | |
---|
14313 | 14805 | public void mouseReleased(MouseEvent e) |
---|
14314 | 14806 | { |
---|
| 14807 | + Globals.MOUSEDRAGGED = false; |
---|
| 14808 | + |
---|
14315 | 14809 | movingcamera = false; |
---|
| 14810 | + X = 0; // getBounds().width/2; |
---|
| 14811 | + Y = 0; // getBounds().height/2; |
---|
14316 | 14812 | //System.out.println("mouseReleased: " + e); |
---|
14317 | 14813 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14318 | 14814 | } |
---|
.. | .. |
---|
14335 | 14831 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
14336 | 14832 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
14337 | 14833 | |
---|
14338 | | - if (control || command || IsFrozen()) |
---|
| 14834 | +// No delay if (control || command || IsFrozen()) |
---|
14339 | 14835 | timeout = true; |
---|
14340 | | - else |
---|
| 14836 | +// ?? May 2019 else |
---|
14341 | 14837 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
14342 | 14838 | mouseDown = false; |
---|
14343 | 14839 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14447 | 14943 | System.out.println("keyReleased: " + e); |
---|
14448 | 14944 | } |
---|
14449 | 14945 | |
---|
14450 | | - void SetMouseMode(int modifiers) |
---|
| 14946 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14451 | 14947 | { |
---|
14452 | 14948 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14453 | 14949 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14459 | 14955 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14460 | 14956 | // return; |
---|
14461 | 14957 | //System.out.println("SetMode = " + modifiers); |
---|
14462 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14958 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14463 | 14959 | { |
---|
14464 | 14960 | mouseMode |= ZOOM; |
---|
14465 | 14961 | } |
---|
14466 | 14962 | |
---|
14467 | 14963 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14468 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14964 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14469 | 14965 | { |
---|
14470 | 14966 | mouseMode |= VR; // BACKFORTH; |
---|
14471 | 14967 | } |
---|
14472 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14968 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14473 | 14969 | { |
---|
14474 | 14970 | mouseMode |= SELECT; |
---|
14475 | 14971 | } |
---|
14476 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14972 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14477 | 14973 | { |
---|
14478 | 14974 | mouseMode |= SELECT; |
---|
14479 | 14975 | } |
---|
14480 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14976 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14481 | 14977 | { |
---|
14482 | 14978 | mouseMode &= ~VR; |
---|
14483 | 14979 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14506 | 15002 | |
---|
14507 | 15003 | if (isRenderer) // |
---|
14508 | 15004 | { |
---|
14509 | | - SetMouseMode(modifiers); |
---|
| 15005 | + SetMouseMode(0, modifiers); |
---|
14510 | 15006 | } |
---|
14511 | 15007 | |
---|
14512 | 15008 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14568 | 15064 | // break; |
---|
14569 | 15065 | case 'T': |
---|
14570 | 15066 | CACHETEXTURE ^= true; |
---|
14571 | | - textures.clear(); |
---|
| 15067 | + texturepigment.clear(); |
---|
| 15068 | + texturebump.clear(); |
---|
14572 | 15069 | // repaint(); |
---|
14573 | 15070 | break; |
---|
14574 | 15071 | case 'Y': |
---|
.. | .. |
---|
14653 | 15150 | case 'E' : COMPACT ^= true; |
---|
14654 | 15151 | repaint(); |
---|
14655 | 15152 | break; |
---|
14656 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15153 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15154 | + //DEBUGHSB ^= true; |
---|
| 15155 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14657 | 15156 | repaint(); |
---|
14658 | 15157 | break; |
---|
14659 | 15158 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14678 | 15177 | RevertCamera(); |
---|
14679 | 15178 | repaint(); |
---|
14680 | 15179 | break; |
---|
14681 | | - case 'L': |
---|
14682 | 15180 | case 'l': |
---|
| 15181 | + //case 'L': |
---|
14683 | 15182 | if (lightMode) |
---|
14684 | 15183 | { |
---|
14685 | 15184 | lightMode = false; |
---|
.. | .. |
---|
14822 | 15321 | case '_': |
---|
14823 | 15322 | kompactbit = 5; |
---|
14824 | 15323 | break; |
---|
14825 | | - case '+': |
---|
14826 | | - kompactbit = 6; |
---|
14827 | | - break; |
---|
| 15324 | +// case '+': |
---|
| 15325 | +// kompactbit = 6; |
---|
| 15326 | +// break; |
---|
14828 | 15327 | case ' ': |
---|
14829 | 15328 | lightMode ^= true; |
---|
14830 | 15329 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14836 | 15335 | case ESC: |
---|
14837 | 15336 | RENDERPROGRAM += 1; |
---|
14838 | 15337 | RENDERPROGRAM %= 3; |
---|
| 15338 | + |
---|
14839 | 15339 | repaint(); |
---|
14840 | 15340 | break; |
---|
14841 | 15341 | case 'Z': |
---|
14842 | 15342 | //RESIZETEXTURE ^= true; |
---|
14843 | 15343 | //break; |
---|
14844 | 15344 | case 'z': |
---|
14845 | | - RENDERSHADOW ^= true; |
---|
| 15345 | + Globals.RENDERSHADOW ^= true; |
---|
14846 | 15346 | Globals.lighttouched = true; |
---|
14847 | 15347 | repaint(); |
---|
14848 | 15348 | break; |
---|
.. | .. |
---|
14875 | 15375 | case DELETE: |
---|
14876 | 15376 | ClearSelection(); |
---|
14877 | 15377 | break; |
---|
14878 | | - /* |
---|
14879 | 15378 | case '+': |
---|
| 15379 | + |
---|
| 15380 | + /* |
---|
14880 | 15381 | //fontsize += 1; |
---|
14881 | 15382 | bbzoom *= 2; |
---|
14882 | 15383 | repaint(); |
---|
.. | .. |
---|
14893 | 15394 | case '=': |
---|
14894 | 15395 | IncDepth(); |
---|
14895 | 15396 | //fontsize += 1; |
---|
14896 | | - object.editWindow.refreshContents(true); |
---|
| 15397 | + object.GetWindow().refreshContents(true); |
---|
14897 | 15398 | maskbit = 6; |
---|
14898 | 15399 | break; |
---|
14899 | 15400 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14900 | 15401 | DecDepth(); |
---|
14901 | 15402 | maskbit = 5; |
---|
14902 | 15403 | //if(fontsize > 1) fontsize -= 1; |
---|
14903 | | - if (object.editWindow == null) |
---|
14904 | | - new Exception().printStackTrace(); |
---|
14905 | | - else |
---|
14906 | | - object.editWindow.refreshContents(true); |
---|
| 15404 | +// if (object.editWindow == null) |
---|
| 15405 | +// new Exception().printStackTrace(); |
---|
| 15406 | +// else |
---|
| 15407 | + object.GetWindow().refreshContents(true); |
---|
14907 | 15408 | break; |
---|
14908 | 15409 | case '{': |
---|
14909 | 15410 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14966 | 15467 | //mode = ROTATE; |
---|
14967 | 15468 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14968 | 15469 | { |
---|
14969 | | - SetMouseMode(modifiers); |
---|
| 15470 | + SetMouseMode(0, modifiers); |
---|
14970 | 15471 | } |
---|
14971 | 15472 | } |
---|
14972 | 15473 | |
---|
.. | .. |
---|
15100 | 15601 | |
---|
15101 | 15602 | protected void processMouseMotionEvent(MouseEvent e) |
---|
15102 | 15603 | { |
---|
15103 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
15104 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15604 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15605 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15606 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
15105 | 15607 | { |
---|
15106 | 15608 | mouseMoved(e); |
---|
15107 | 15609 | } else |
---|
.. | .. |
---|
15126 | 15628 | } |
---|
15127 | 15629 | */ |
---|
15128 | 15630 | |
---|
15129 | | - object.editWindow.EditSelection(); |
---|
| 15631 | + object.GetWindow().EditSelection(false); |
---|
15130 | 15632 | } |
---|
15131 | 15633 | |
---|
15132 | 15634 | void SelectParent() |
---|
15133 | 15635 | { |
---|
| 15636 | + new Exception().printStackTrace(); |
---|
15134 | 15637 | System.exit(0); |
---|
15135 | 15638 | Composite group = (Composite) object; |
---|
15136 | 15639 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
15142 | 15645 | { |
---|
15143 | 15646 | //selectees.remove(i); |
---|
15144 | 15647 | System.out.println("select parent of " + elem); |
---|
15145 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15648 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15146 | 15649 | } else |
---|
15147 | 15650 | { |
---|
15148 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15651 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15149 | 15652 | } |
---|
15150 | 15653 | |
---|
15151 | 15654 | first = false; |
---|
.. | .. |
---|
15154 | 15657 | |
---|
15155 | 15658 | void SelectChildren() |
---|
15156 | 15659 | { |
---|
| 15660 | + new Exception().printStackTrace(); |
---|
15157 | 15661 | System.exit(0); |
---|
15158 | 15662 | /* |
---|
15159 | 15663 | Composite group = (Composite) object; |
---|
.. | .. |
---|
15186 | 15690 | for (int j = 0; j < group.children.size(); j++) |
---|
15187 | 15691 | { |
---|
15188 | 15692 | elem = (Object3D) group.children.elementAt(j); |
---|
15189 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15693 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15190 | 15694 | first = false; |
---|
15191 | 15695 | } |
---|
15192 | 15696 | } else |
---|
15193 | 15697 | { |
---|
15194 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15698 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15195 | 15699 | } |
---|
15196 | 15700 | |
---|
15197 | 15701 | first = false; |
---|
.. | .. |
---|
15202 | 15706 | { |
---|
15203 | 15707 | //Composite group = (Composite) object; |
---|
15204 | 15708 | Object3D group = object; |
---|
15205 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15709 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15206 | 15710 | } |
---|
15207 | 15711 | |
---|
15208 | 15712 | void ResetTransform(int mask) |
---|
15209 | 15713 | { |
---|
15210 | 15714 | //Composite group = (Composite) object; |
---|
15211 | 15715 | Object3D group = object; |
---|
15212 | | - group.editWindow.ResetTransform(mask); |
---|
| 15716 | + group.GetWindow().ResetTransform(mask); |
---|
15213 | 15717 | } |
---|
15214 | 15718 | |
---|
15215 | 15719 | void FlipTransform() |
---|
15216 | 15720 | { |
---|
15217 | 15721 | //Composite group = (Composite) object; |
---|
15218 | 15722 | Object3D group = object; |
---|
15219 | | - group.editWindow.FlipTransform(); |
---|
| 15723 | + group.GetWindow().FlipTransform(); |
---|
15220 | 15724 | // group.editWindow.ReduceMesh(true); |
---|
15221 | 15725 | } |
---|
15222 | 15726 | |
---|
.. | .. |
---|
15224 | 15728 | { |
---|
15225 | 15729 | //Composite group = (Composite) object; |
---|
15226 | 15730 | Object3D group = object; |
---|
15227 | | - group.editWindow.PrintMemory(); |
---|
| 15731 | + group.GetWindow().PrintMemory(); |
---|
15228 | 15732 | // group.editWindow.ReduceMesh(true); |
---|
15229 | 15733 | } |
---|
15230 | 15734 | |
---|
.. | .. |
---|
15232 | 15736 | { |
---|
15233 | 15737 | //Composite group = (Composite) object; |
---|
15234 | 15738 | Object3D group = object; |
---|
15235 | | - group.editWindow.ResetCentroid(); |
---|
| 15739 | + group.GetWindow().ResetCentroid(); |
---|
15236 | 15740 | } |
---|
15237 | 15741 | |
---|
15238 | 15742 | void IncDepth() |
---|
.. | .. |
---|
15318 | 15822 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15319 | 15823 | //Image img = CreateImage(width, height); |
---|
15320 | 15824 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15825 | + |
---|
15321 | 15826 | Graphics gr = g; // img.getGraphics(); |
---|
| 15827 | + |
---|
15322 | 15828 | if (!hasMarquee) |
---|
15323 | 15829 | { |
---|
15324 | 15830 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15406 | 15912 | info.bounds.y += (height - desired) / 2; |
---|
15407 | 15913 | } |
---|
15408 | 15914 | } |
---|
| 15915 | + |
---|
15409 | 15916 | info.g = gr; |
---|
15410 | 15917 | info.camera = renderCamera; |
---|
15411 | 15918 | /* |
---|
.. | .. |
---|
15415 | 15922 | */ |
---|
15416 | 15923 | if (!isRenderer) |
---|
15417 | 15924 | { |
---|
15418 | | - object.drawEditHandles(info, 0); |
---|
| 15925 | + Grafreed.Assert(object != null); |
---|
| 15926 | + Grafreed.Assert(object.selection != null); |
---|
| 15927 | + if (object.selection.Size() > 0) |
---|
| 15928 | + { |
---|
| 15929 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15930 | + |
---|
| 15931 | + info.DX = 0; |
---|
| 15932 | + info.DY = 0; |
---|
| 15933 | + info.W = 1; |
---|
| 15934 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15935 | + { |
---|
| 15936 | + info.DX = X; |
---|
| 15937 | + if (X != 0) |
---|
| 15938 | + info.DX -= info.bounds.width/2; |
---|
| 15939 | + |
---|
| 15940 | + info.DY = Y; |
---|
| 15941 | + if (Y != 0) |
---|
| 15942 | + info.DY -= info.bounds.height/2; |
---|
| 15943 | + } |
---|
| 15944 | + |
---|
| 15945 | + object.drawEditHandles(info, 0); |
---|
| 15946 | + |
---|
| 15947 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15948 | + { |
---|
| 15949 | + switch (hitSomething) |
---|
| 15950 | + { |
---|
| 15951 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15952 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15953 | + break; |
---|
| 15954 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15955 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15956 | + break; |
---|
| 15957 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15958 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15959 | + break; |
---|
| 15960 | + } |
---|
| 15961 | + |
---|
| 15962 | + } |
---|
| 15963 | + } |
---|
15419 | 15964 | } |
---|
15420 | 15965 | } |
---|
| 15966 | + |
---|
15421 | 15967 | if (isRenderer) |
---|
15422 | 15968 | { |
---|
15423 | 15969 | //gr.setColor(Color.black); |
---|
15424 | 15970 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15425 | 15971 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15426 | 15972 | } |
---|
| 15973 | + |
---|
15427 | 15974 | if (hasMarquee) |
---|
15428 | 15975 | { |
---|
15429 | 15976 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15536 | 16083 | public boolean mouseDown(Event evt, int x, int y) |
---|
15537 | 16084 | { |
---|
15538 | 16085 | System.out.println("mouseDown: " + evt); |
---|
| 16086 | + System.exit(0); |
---|
15539 | 16087 | /* |
---|
15540 | 16088 | locked = true; |
---|
15541 | 16089 | drag = false; |
---|
.. | .. |
---|
15579 | 16127 | { |
---|
15580 | 16128 | keyPressed(0, modifiers); |
---|
15581 | 16129 | } |
---|
15582 | | - clickStart(x, y, modifiers); |
---|
| 16130 | + // clickStart(x, y, modifiers); |
---|
15583 | 16131 | return true; |
---|
15584 | 16132 | } |
---|
15585 | 16133 | |
---|
.. | .. |
---|
15697 | 16245 | { |
---|
15698 | 16246 | keyReleased(0, 0); |
---|
15699 | 16247 | } |
---|
15700 | | - drag(x, y, modifiers); |
---|
| 16248 | + drag(x, y, 0, modifiers); |
---|
15701 | 16249 | return true; |
---|
15702 | 16250 | } |
---|
15703 | 16251 | |
---|
.. | .. |
---|
15829 | 16377 | Object3D object; |
---|
15830 | 16378 | static Object3D trackedobject; |
---|
15831 | 16379 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15832 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16380 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15833 | 16381 | /*static*/ Camera eyeCamera; |
---|
15834 | 16382 | /*static*/ Camera lightCamera; |
---|
15835 | 16383 | int cameracount; |
---|
.. | .. |
---|
16114 | 16662 | cStatic.objectstack[materialdepth++] = checker; |
---|
16115 | 16663 | //System.out.println("material " + material); |
---|
16116 | 16664 | //Applet3D.tracein(this, selected); |
---|
16117 | | - vector2buffer = checker.projectedVertices; |
---|
| 16665 | + //vector2buffer = checker.projectedVertices; |
---|
16118 | 16666 | |
---|
16119 | 16667 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16120 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16668 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16121 | 16669 | |
---|
16122 | 16670 | materialdepth -= 1; |
---|
16123 | 16671 | if (materialdepth > 0) |
---|
16124 | 16672 | { |
---|
16125 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16126 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16673 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16674 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16127 | 16675 | } |
---|
16128 | 16676 | //checker.GetMaterial().opacity = 1f; |
---|
16129 | 16677 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16209 | 16757 | } |
---|
16210 | 16758 | } |
---|
16211 | 16759 | |
---|
| 16760 | + private Object3D GetFolder() |
---|
| 16761 | + { |
---|
| 16762 | + Object3D folder = object.GetWindow().copy; |
---|
| 16763 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16764 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16765 | + return folder; |
---|
| 16766 | + } |
---|
| 16767 | + |
---|
16212 | 16768 | class SelectBuffer implements GLEventListener |
---|
16213 | 16769 | { |
---|
16214 | 16770 | |
---|
.. | .. |
---|
16267 | 16823 | { |
---|
16268 | 16824 | if (!selection) |
---|
16269 | 16825 | { |
---|
| 16826 | + new Exception().printStackTrace(); |
---|
16270 | 16827 | System.exit(0); |
---|
16271 | 16828 | return; |
---|
16272 | 16829 | } |
---|
.. | .. |
---|
16287 | 16844 | |
---|
16288 | 16845 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16289 | 16846 | |
---|
| 16847 | + if (PAINTMODE) |
---|
| 16848 | + { |
---|
| 16849 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16850 | + { |
---|
| 16851 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16852 | + |
---|
| 16853 | + // Make what you paint not selectable. |
---|
| 16854 | + paintobj.ResetSelectable(); |
---|
| 16855 | + } |
---|
| 16856 | + } |
---|
| 16857 | + |
---|
16290 | 16858 | //int tmp = selection_view; |
---|
16291 | 16859 | //selection_view = -1; |
---|
16292 | 16860 | int temp = DrawMode(); |
---|
.. | .. |
---|
16298 | 16866 | // temp = DEFAULT; // patch for selection debug |
---|
16299 | 16867 | Globals.drawMode = temp; // WARNING |
---|
16300 | 16868 | |
---|
| 16869 | + if (PAINTMODE) |
---|
| 16870 | + { |
---|
| 16871 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16872 | + { |
---|
| 16873 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16874 | + |
---|
| 16875 | + // Revert. |
---|
| 16876 | + paintobj.RestoreSelectable(); |
---|
| 16877 | + } |
---|
| 16878 | + } |
---|
| 16879 | + |
---|
16301 | 16880 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16302 | 16881 | |
---|
16303 | 16882 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16345 | 16924 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16346 | 16925 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16347 | 16926 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16927 | + |
---|
| 16928 | + CreateSelectedPoint(); |
---|
16348 | 16929 | |
---|
16349 | 16930 | // Will fit the mesh !!! |
---|
16350 | 16931 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16394 | 16975 | System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
16395 | 16976 | } |
---|
16396 | 16977 | |
---|
16397 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16978 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16398 | 16979 | } |
---|
16399 | 16980 | } |
---|
16400 | 16981 | |
---|
16401 | 16982 | if (!movingcamera && !PAINTMODE) |
---|
16402 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16983 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16403 | 16984 | |
---|
16404 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16985 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16405 | 16986 | { |
---|
16406 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16987 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16407 | 16988 | |
---|
16408 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16989 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16990 | + { |
---|
| 16991 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16409 | 16992 | |
---|
16410 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16411 | | - |
---|
16412 | | - group.add(paintobj); // link |
---|
16413 | | - |
---|
16414 | | - object.editWindow.SnapObject(group); |
---|
16415 | | - |
---|
16416 | | - Object3D folder = object.editWindow.copy; |
---|
16417 | | - |
---|
16418 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16419 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16420 | | - |
---|
16421 | | - folder.add(group); |
---|
16422 | | - |
---|
16423 | | - object.editWindow.ResetModel(); |
---|
16424 | | - object.editWindow.refreshContents(); |
---|
| 16993 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16994 | + |
---|
| 16995 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16996 | + |
---|
| 16997 | + inst.add(paintobj); // link |
---|
| 16998 | + |
---|
| 16999 | + object.GetWindow().SnapObject(inst); |
---|
| 17000 | + |
---|
| 17001 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17002 | + |
---|
| 17003 | + folder.add(inst); |
---|
| 17004 | + |
---|
| 17005 | + object.GetWindow().ResetModel(); |
---|
| 17006 | + object.GetWindow().refreshContents(); |
---|
| 17007 | + } |
---|
16425 | 17008 | } |
---|
16426 | 17009 | else |
---|
16427 | 17010 | paintcount = 0; |
---|
.. | .. |
---|
16460 | 17043 | //System.out.println("objects[color] = " + objects[color]); |
---|
16461 | 17044 | //objects[color].Select(); |
---|
16462 | 17045 | indexcount = 0; |
---|
| 17046 | + ObjEditor window = object.GetWindow(); |
---|
| 17047 | + if (window != null && deselect) |
---|
| 17048 | + { |
---|
| 17049 | + window.Select(null, deselect, true); |
---|
| 17050 | + } |
---|
16463 | 17051 | object.Select(color, deselect); |
---|
16464 | 17052 | } |
---|
16465 | 17053 | |
---|
.. | .. |
---|
16559 | 17147 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16560 | 17148 | } |
---|
16561 | 17149 | |
---|
16562 | | - if (!RENDERSHADOW) |
---|
| 17150 | + if (!Globals.RENDERSHADOW) |
---|
16563 | 17151 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16564 | 17152 | |
---|
16565 | 17153 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16569 | 17157 | //gl.glColorMask(false, false, false, false); |
---|
16570 | 17158 | |
---|
16571 | 17159 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16572 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17160 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16573 | 17161 | { |
---|
16574 | 17162 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16575 | 17163 | |
---|
.. | .. |
---|
16985 | 17573 | int AAbuffersize = 0; |
---|
16986 | 17574 | |
---|
16987 | 17575 | //double[] selectedpoint = new double[3]; |
---|
16988 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17576 | + static Superellipsoid selectedpoint; |
---|
16989 | 17577 | static Sphere previousselectedpoint = null; |
---|
16990 | | - static Sphere debugpointG = new Sphere(); |
---|
16991 | | - static Sphere debugpointP = new Sphere(); |
---|
16992 | | - static Sphere debugpointC = new Sphere(); |
---|
16993 | | - static Sphere debugpointR = new Sphere(); |
---|
| 17578 | + static Sphere debugpointG; |
---|
| 17579 | + static Sphere debugpointP; |
---|
| 17580 | + static Sphere debugpointC; |
---|
| 17581 | + static Sphere debugpointR; |
---|
16994 | 17582 | |
---|
16995 | 17583 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16996 | 17584 | |
---|
16997 | | - static |
---|
16998 | | - { |
---|
16999 | | - for (int i=0; i<8; i++) |
---|
17000 | | - { |
---|
17001 | | - debugpoints[i] = new Sphere(); |
---|
17002 | | - } |
---|
17003 | | - } |
---|
17004 | | - |
---|
17005 | 17585 | static void InitPoints(float radius) |
---|
17006 | 17586 | { |
---|
17007 | 17587 | for (int i=0; i<8; i++) |
---|