.. | .. |
---|
37 | 37 | static boolean[] selectedstack = new boolean[65536]; |
---|
38 | 38 | static int materialdepth = 0; |
---|
39 | 39 | |
---|
40 | | - static boolean DEBUG = false; |
---|
41 | 40 | static boolean FRUSTUM = false; // still bogus true; // frustum culling |
---|
42 | 41 | |
---|
43 | 42 | // camera change fix |
---|
.. | .. |
---|
56 | 55 | static int CURRENTANTIALIAS = 0; // 1; |
---|
57 | 56 | /*static*/ boolean RENDERSHADOW = true; |
---|
58 | 57 | /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal |
---|
59 | | - static boolean ANIMATION = false; |
---|
60 | | - static String filename; |
---|
61 | 58 | |
---|
62 | 59 | boolean DISPLAYTEXT = false; |
---|
63 | 60 | //boolean REDUCETEXTURE = true; |
---|
64 | 61 | boolean CACHETEXTURE = true; |
---|
65 | 62 | boolean CLEANCACHE = false; // true; |
---|
66 | | - boolean MIPMAP = false; // true; |
---|
| 63 | + boolean MIPMAP = true; // false; // true; |
---|
67 | 64 | boolean COMPRESSTEXTURE = false; |
---|
68 | 65 | boolean KOMPACTTEXTURE = false; // true; |
---|
69 | 66 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
92 | 89 | |
---|
93 | 90 | static int tickcount = 0; // slow pose issue |
---|
94 | 91 | |
---|
| 92 | +static boolean BUTTONLESSWHEEL = false; |
---|
| 93 | +static boolean ZOOMBOXMODE = false; |
---|
95 | 94 | static boolean BOXMODE = false; |
---|
96 | 95 | static boolean IMAGEFLIP = false; |
---|
97 | 96 | static boolean SMOOTHFOCUS = false; |
---|
.. | .. |
---|
106 | 105 | static boolean OEIL = true; |
---|
107 | 106 | static boolean OEILONCE = false; // do oeilon then oeiloff |
---|
108 | 107 | static boolean LOOKAT = true; |
---|
109 | | -static boolean RANDOM = true; // false; |
---|
| 108 | +static boolean SWITCH = true; // false; |
---|
110 | 109 | static boolean HANDLES = false; // selection doesn't work!! |
---|
111 | 110 | static boolean PAINTMODE = false; |
---|
112 | 111 | |
---|
.. | .. |
---|
149 | 148 | defaultcaps.setAccumBlueBits(16); |
---|
150 | 149 | defaultcaps.setAccumAlphaBits(16); |
---|
151 | 150 | } |
---|
| 151 | + |
---|
| 152 | + private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
152 | 153 | |
---|
153 | 154 | void SetAsGLRenderer(boolean b) |
---|
154 | 155 | { |
---|
.. | .. |
---|
223 | 224 | public boolean IsBoxMode() |
---|
224 | 225 | { |
---|
225 | 226 | return BOXMODE; |
---|
| 227 | + } |
---|
| 228 | + |
---|
| 229 | + public boolean IsZoomBoxMode() |
---|
| 230 | + { |
---|
| 231 | + return ZOOMBOXMODE; |
---|
226 | 232 | } |
---|
227 | 233 | |
---|
228 | 234 | public void ClearDepth() |
---|
.. | .. |
---|
320 | 326 | cStatic.objectstack[materialdepth++] = obj; |
---|
321 | 327 | //System.out.println("material " + material); |
---|
322 | 328 | //Applet3D.tracein(this, selected); |
---|
323 | | - display.vector2buffer = obj.projectedVertices; |
---|
| 329 | + //display.vector2buffer = obj.projectedVertices; |
---|
324 | 330 | if (obj instanceof Camera) |
---|
325 | 331 | { |
---|
326 | 332 | display.options1[0] = material.shift; |
---|
.. | .. |
---|
329 | 335 | display.options1[2] = material.shadowbias; |
---|
330 | 336 | display.options1[3] = material.aniso; |
---|
331 | 337 | display.options1[4] = material.anisoV; |
---|
| 338 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 339 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 340 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 341 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 342 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
332 | 343 | display.options2[0] = material.opacity; |
---|
333 | 344 | display.options2[1] = material.diffuse; |
---|
334 | 345 | display.options2[2] = material.factor; |
---|
| 346 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 347 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 348 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
335 | 349 | |
---|
336 | 350 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 351 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 352 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 353 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
337 | 354 | display.options4[0] = material.cameralight/0.2f; |
---|
338 | 355 | display.options4[1] = material.subsurface; |
---|
339 | 356 | display.options4[2] = material.sheen; |
---|
| 357 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 358 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 359 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
340 | 360 | |
---|
341 | 361 | // if (display.CURRENTANTIALIAS > 0) |
---|
342 | 362 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
352 | 372 | /**/ |
---|
353 | 373 | } else |
---|
354 | 374 | { |
---|
355 | | - DrawMaterial(material, selected); |
---|
| 375 | + DrawMaterial(material, selected, obj.projectedVertices); |
---|
356 | 376 | } |
---|
357 | 377 | } else |
---|
358 | 378 | { |
---|
.. | .. |
---|
376 | 396 | cStatic.objectstack[materialdepth++] = obj; |
---|
377 | 397 | //System.out.println("material " + material); |
---|
378 | 398 | //Applet3D.tracein("selected ", selected); |
---|
379 | | - display.vector2buffer = obj.projectedVertices; |
---|
380 | | - display.DrawMaterial(material, selected); |
---|
| 399 | + //display.vector2buffer = obj.projectedVertices; |
---|
| 400 | + display.DrawMaterial(material, selected, obj.projectedVertices); |
---|
381 | 401 | } |
---|
382 | 402 | } |
---|
383 | 403 | |
---|
.. | .. |
---|
394 | 414 | materialdepth -= 1; |
---|
395 | 415 | if (materialdepth > 0) |
---|
396 | 416 | { |
---|
397 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
398 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 417 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 418 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
399 | 419 | } |
---|
400 | 420 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
401 | 421 | } else if (selected && CameraPane.flash && obj.GetMaterial() != null) |
---|
.. | .. |
---|
415 | 435 | materialdepth -= 1; |
---|
416 | 436 | if (materialdepth > 0) |
---|
417 | 437 | { |
---|
418 | | - display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
419 | | - display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 438 | + //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 439 | + display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
420 | 440 | } |
---|
421 | 441 | //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???"); |
---|
422 | 442 | //else |
---|
.. | .. |
---|
457 | 477 | if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0) |
---|
458 | 478 | { |
---|
459 | 479 | //gl.glBegin(gl.GL_TRIANGLES); |
---|
460 | | - boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0); |
---|
| 480 | + boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0) |
---|
| 481 | + // TEST LIVE NORMALS && !obj.dontselect |
---|
| 482 | + ; |
---|
461 | 483 | if (!hasnorm) |
---|
462 | 484 | { |
---|
463 | | - // System.out.println("FUCK!!"); |
---|
| 485 | + // System.out.println("Mesh normal"); |
---|
464 | 486 | LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0); |
---|
465 | 487 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
466 | 488 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
.. | .. |
---|
1185 | 1207 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1186 | 1208 | } |
---|
1187 | 1209 | } |
---|
| 1210 | + |
---|
1188 | 1211 | if (flipV) |
---|
1189 | 1212 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1190 | 1213 | else |
---|
1191 | 1214 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1215 | + |
---|
1192 | 1216 | //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1193 | 1217 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1194 | 1218 | |
---|
.. | .. |
---|
1208 | 1232 | gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1); |
---|
1209 | 1233 | } |
---|
1210 | 1234 | } |
---|
| 1235 | + |
---|
1211 | 1236 | if (flipV) |
---|
1212 | 1237 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1213 | 1238 | else |
---|
1214 | 1239 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1240 | + |
---|
1215 | 1241 | //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]); |
---|
1216 | 1242 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
1217 | 1243 | |
---|
.. | .. |
---|
1239 | 1265 | gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]); |
---|
1240 | 1266 | else |
---|
1241 | 1267 | gl.glTexCoord2f(uv[count2], uv[count2 + 1]); |
---|
| 1268 | + |
---|
1242 | 1269 | //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]); |
---|
1243 | 1270 | gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]); |
---|
| 1271 | + |
---|
1244 | 1272 | count2 += 2; |
---|
1245 | 1273 | count3 += 3; |
---|
1246 | 1274 | } |
---|
.. | .. |
---|
1596 | 1624 | // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0); |
---|
1597 | 1625 | } |
---|
1598 | 1626 | |
---|
1599 | | - void DrawMaterial(cMaterial material, boolean selected) |
---|
| 1627 | + void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others) |
---|
1600 | 1628 | { |
---|
1601 | 1629 | CameraPane display = this; |
---|
1602 | 1630 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
1612 | 1640 | //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0); |
---|
1613 | 1641 | if (!material.multiply) |
---|
1614 | 1642 | { |
---|
1615 | | - display.color = color; |
---|
| 1643 | + display.color = material.color; |
---|
1616 | 1644 | display.saturation = material.modulation; |
---|
1617 | 1645 | } |
---|
1618 | 1646 | else |
---|
1619 | 1647 | { |
---|
1620 | | - display.color *= color*2; |
---|
| 1648 | + display.color *= material.color*2; |
---|
1621 | 1649 | display.saturation *= material.modulation*2; |
---|
1622 | 1650 | } |
---|
1623 | 1651 | |
---|
1624 | 1652 | cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0); |
---|
1625 | 1653 | |
---|
1626 | | - float[] colorV = GrafreeD.colorV; |
---|
| 1654 | + float[] colorV = Grafreed.colorV; |
---|
1627 | 1655 | |
---|
1628 | 1656 | /**/ |
---|
1629 | 1657 | if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0) |
---|
.. | .. |
---|
1631 | 1659 | colorV[0] = display.modelParams0[0] * material.diffuse; |
---|
1632 | 1660 | colorV[1] = display.modelParams0[1] * material.diffuse; |
---|
1633 | 1661 | colorV[2] = display.modelParams0[2] * material.diffuse; |
---|
1634 | | - colorV[3] = material.opacity; |
---|
| 1662 | + colorV[3] = 1; // material.opacity; |
---|
1635 | 1663 | |
---|
1636 | 1664 | gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity); |
---|
1637 | 1665 | //System.out.println("Opacity = " + opacity); |
---|
.. | .. |
---|
1739 | 1767 | display.modelParams7[2] = 0; |
---|
1740 | 1768 | display.modelParams7[3] = 0; |
---|
1741 | 1769 | |
---|
1742 | | - display.modelParams6[0] = 100; // criss de bug de bump |
---|
| 1770 | + //display.modelParams6[0] = 100; // criss de bug de bump |
---|
1743 | 1771 | |
---|
1744 | | - Object3D.cVector2[] extparams = display.vector2buffer; |
---|
| 1772 | + Object3D.cVector2[] extparams = others; // display.vector2buffer; |
---|
1745 | 1773 | if (extparams != null && extparams.length > 0 && extparams[0] != null) |
---|
1746 | 1774 | { |
---|
1747 | 1775 | display.modelParams6[0] = extparams[0].x / 1000.0f; // bump |
---|
.. | .. |
---|
1883 | 1911 | void PushMatrix(double[][] matrix) |
---|
1884 | 1912 | { |
---|
1885 | 1913 | // GrafreeD.tracein(matrix); |
---|
1886 | | - PushMatrix(matrix,1); |
---|
| 1914 | + PushMatrix(matrix, 1); |
---|
1887 | 1915 | } |
---|
1888 | 1916 | |
---|
1889 | 1917 | void PushMatrix() |
---|
.. | .. |
---|
2037 | 2065 | //System.err.println("Oeil on"); |
---|
2038 | 2066 | OEIL = true; |
---|
2039 | 2067 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2040 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2068 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2041 | 2069 | //pingthread.StepToTarget(true); |
---|
2042 | 2070 | } |
---|
2043 | 2071 | |
---|
.. | .. |
---|
2135 | 2163 | System.err.println("LIVE = " + Globals.isLIVE()); |
---|
2136 | 2164 | |
---|
2137 | 2165 | if (!Globals.isLIVE()) // save sound |
---|
2138 | | - GrafreeD.savesound = true; // wav.save(); |
---|
| 2166 | + Grafreed.savesound = true; // wav.save(); |
---|
2139 | 2167 | // else |
---|
2140 | 2168 | repaint(); // start loop // may 2013 |
---|
2141 | 2169 | } |
---|
.. | .. |
---|
2168 | 2196 | public void ToggleBoxMode() |
---|
2169 | 2197 | { |
---|
2170 | 2198 | BOXMODE ^= true; |
---|
| 2199 | + } |
---|
| 2200 | + |
---|
| 2201 | + public void ToggleZoomBoxMode() |
---|
| 2202 | + { |
---|
| 2203 | + ZOOMBOXMODE ^= true; |
---|
2171 | 2204 | } |
---|
2172 | 2205 | |
---|
2173 | 2206 | public void ToggleSmoothFocus() |
---|
.. | .. |
---|
2247 | 2280 | |
---|
2248 | 2281 | void ToggleDebug() |
---|
2249 | 2282 | { |
---|
2250 | | - DEBUG ^= true; |
---|
| 2283 | + Globals.DEBUG ^= true; |
---|
2251 | 2284 | } |
---|
2252 | 2285 | |
---|
2253 | 2286 | void ToggleLookAt() |
---|
.. | .. |
---|
2255 | 2288 | LOOKAT ^= true; |
---|
2256 | 2289 | } |
---|
2257 | 2290 | |
---|
2258 | | - void ToggleRandom() |
---|
| 2291 | + void ToggleSwitch() |
---|
2259 | 2292 | { |
---|
2260 | | - RANDOM ^= true; |
---|
| 2293 | + SWITCH ^= true; |
---|
2261 | 2294 | } |
---|
2262 | 2295 | |
---|
2263 | 2296 | void ToggleHandles() |
---|
.. | .. |
---|
2265 | 2298 | HANDLES ^= true; |
---|
2266 | 2299 | } |
---|
2267 | 2300 | |
---|
| 2301 | + Object3D paintFolder; |
---|
| 2302 | + |
---|
2268 | 2303 | void TogglePaint() |
---|
2269 | 2304 | { |
---|
2270 | 2305 | PAINTMODE ^= true; |
---|
2271 | 2306 | paintcount = 0; |
---|
| 2307 | + |
---|
| 2308 | + if (PAINTMODE) |
---|
| 2309 | + { |
---|
| 2310 | + paintFolder = GetFolder(); |
---|
| 2311 | + } |
---|
2272 | 2312 | } |
---|
2273 | 2313 | |
---|
2274 | 2314 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2364 | 2404 | { |
---|
2365 | 2405 | return currentGL; |
---|
2366 | 2406 | } |
---|
2367 | | - |
---|
| 2407 | + |
---|
| 2408 | + private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2409 | + { |
---|
| 2410 | + // cache to disk |
---|
| 2411 | + Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
| 2412 | + //buffers[0]. |
---|
| 2413 | + ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
| 2414 | + int[] pixels = new int[bytebuf.capacity()/3]; |
---|
| 2415 | + int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared |
---|
| 2416 | + int height = width; |
---|
| 2417 | + for (int i=pixels.length; --i>=0;) |
---|
| 2418 | + { |
---|
| 2419 | + int i3 = i*3; |
---|
| 2420 | + pixels[i] = 0xFF; |
---|
| 2421 | + pixels[i] <<= 8; |
---|
| 2422 | + pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
| 2423 | + pixels[i] <<= 8; |
---|
| 2424 | + pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
| 2425 | + pixels[i] <<= 8; |
---|
| 2426 | + pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
| 2427 | + } |
---|
| 2428 | + /* |
---|
| 2429 | + int r=0,g=0,b=0,a=0; |
---|
| 2430 | + for (int i=0; i<width; i++) |
---|
| 2431 | + for (int j=0; j<height; j++) |
---|
| 2432 | + { |
---|
| 2433 | + int index = j*width+i; |
---|
| 2434 | + int p = pixels[index]; |
---|
| 2435 | + a = ((p>>24) & 0xFF); |
---|
| 2436 | + r = ((p>>16) & 0xFF); |
---|
| 2437 | + g = ((p>>8) & 0xFF); |
---|
| 2438 | + b = (p & 0xFF); |
---|
| 2439 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 2440 | + } |
---|
| 2441 | + /**/ |
---|
| 2442 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 2443 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 2444 | + return rendImage; |
---|
| 2445 | + } |
---|
| 2446 | + |
---|
2368 | 2447 | /**/ |
---|
2369 | 2448 | class CacheTexture |
---|
2370 | 2449 | { |
---|
.. | .. |
---|
2382 | 2461 | /**/ |
---|
2383 | 2462 | |
---|
2384 | 2463 | // 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>(); |
---|
| 2464 | + static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
| 2465 | + static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
| 2466 | + static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); |
---|
| 2467 | + |
---|
2388 | 2468 | int pigmentdepth = 0; |
---|
2389 | 2469 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2390 | 2470 | int bumpdepth = 0; |
---|
.. | .. |
---|
2406 | 2486 | true, |
---|
2407 | 2487 | com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2408 | 2488 | } catch (java.io.IOException e) |
---|
| 2489 | + { |
---|
| 2490 | + throw new javax.media.opengl.GLException(e); |
---|
| 2491 | + } |
---|
| 2492 | + |
---|
| 2493 | + if (bump) |
---|
| 2494 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2495 | + |
---|
| 2496 | + com.sun.opengl.util.texture.Texture texture = |
---|
| 2497 | + com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2498 | + |
---|
| 2499 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2500 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2501 | + |
---|
| 2502 | + return texture; |
---|
| 2503 | + } |
---|
| 2504 | + |
---|
| 2505 | + com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2506 | + { |
---|
| 2507 | + TextureData texturedata = null; |
---|
| 2508 | + |
---|
| 2509 | + try |
---|
| 2510 | + { |
---|
| 2511 | + texturedata = |
---|
| 2512 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2513 | + name, |
---|
| 2514 | + true); |
---|
| 2515 | + } catch (Exception e) |
---|
2409 | 2516 | { |
---|
2410 | 2517 | throw new javax.media.opengl.GLException(e); |
---|
2411 | 2518 | } |
---|
.. | .. |
---|
3492 | 3599 | |
---|
3493 | 3600 | System.out.println("LOADING TEXTURE : " + name); |
---|
3494 | 3601 | |
---|
| 3602 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3603 | + |
---|
3495 | 3604 | // |
---|
3496 | 3605 | if (false) // compressbit > 0) |
---|
3497 | 3606 | { |
---|
.. | .. |
---|
4196 | 4305 | |
---|
4197 | 4306 | com.sun.opengl.util.texture.Texture CompressTexture2(String name) |
---|
4198 | 4307 | { |
---|
| 4308 | + new Exception().printStackTrace(); |
---|
4199 | 4309 | System.exit(0); |
---|
4200 | 4310 | com.sun.opengl.util.texture.Texture texture = null; |
---|
4201 | 4311 | |
---|
.. | .. |
---|
7889 | 7999 | String pigment = Object3D.GetPigment(tex); |
---|
7890 | 8000 | String bump = Object3D.GetBump(tex); |
---|
7891 | 8001 | |
---|
7892 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8002 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7893 | 8003 | { |
---|
7894 | 8004 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7895 | 8005 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7906 | 8016 | |
---|
7907 | 8017 | ReleaseTexture(bump, true); |
---|
7908 | 8018 | ReleaseTexture(pigment, false); |
---|
| 8019 | + } |
---|
| 8020 | + |
---|
| 8021 | + public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
| 8022 | + { |
---|
| 8023 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8024 | + { |
---|
| 8025 | + return; |
---|
| 8026 | + } |
---|
| 8027 | + |
---|
| 8028 | + if (tex == null) |
---|
| 8029 | + { |
---|
| 8030 | + ReleaseTexture(null, false); |
---|
| 8031 | + return; |
---|
| 8032 | + } |
---|
| 8033 | + |
---|
| 8034 | + String pigment = Object3D.GetPigment(tex); |
---|
| 8035 | + |
---|
| 8036 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8037 | + { |
---|
| 8038 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8039 | + // System.out.println("; bump = " + bump); |
---|
| 8040 | + } |
---|
| 8041 | + |
---|
| 8042 | + if (pigment.equals("")) |
---|
| 8043 | + { |
---|
| 8044 | + pigment = null; |
---|
| 8045 | + } |
---|
| 8046 | + |
---|
| 8047 | + ReleaseTexture(pigment, false); |
---|
| 8048 | + } |
---|
| 8049 | + |
---|
| 8050 | + public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
| 8051 | + { |
---|
| 8052 | + if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
| 8053 | + { |
---|
| 8054 | + return; |
---|
| 8055 | + } |
---|
| 8056 | + |
---|
| 8057 | + if (tex == null) |
---|
| 8058 | + { |
---|
| 8059 | + ReleaseTexture(null, true); |
---|
| 8060 | + return; |
---|
| 8061 | + } |
---|
| 8062 | + |
---|
| 8063 | + String bump = Object3D.GetBump(tex); |
---|
| 8064 | + |
---|
| 8065 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8066 | + { |
---|
| 8067 | + // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
| 8068 | + // System.out.println("; bump = " + bump); |
---|
| 8069 | + } |
---|
| 8070 | + |
---|
| 8071 | + if (bump.equals("")) |
---|
| 8072 | + { |
---|
| 8073 | + bump = null; |
---|
| 8074 | + } |
---|
| 8075 | + |
---|
| 8076 | + ReleaseTexture(bump, true); |
---|
7909 | 8077 | } |
---|
7910 | 8078 | |
---|
7911 | 8079 | void ReleaseTexture(String tex, boolean bump) |
---|
.. | .. |
---|
8011 | 8179 | } |
---|
8012 | 8180 | } |
---|
8013 | 8181 | |
---|
8014 | | - /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE |
---|
| 8182 | + /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8183 | + { |
---|
| 8184 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8185 | +// ambientOcclusion ) // || !textureon) |
---|
| 8186 | +// { |
---|
| 8187 | +// return; // false; |
---|
| 8188 | +// } |
---|
| 8189 | +// |
---|
| 8190 | +// if (tex == null) |
---|
| 8191 | +// { |
---|
| 8192 | +// BindTexture(null,false,resolution); |
---|
| 8193 | +// BindTexture(null,true,resolution); |
---|
| 8194 | +// return; |
---|
| 8195 | +// } |
---|
| 8196 | +// |
---|
| 8197 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8198 | +// String bump = Object3D.GetBump(tex); |
---|
| 8199 | +// |
---|
| 8200 | +// usedtextures.add(pigment); |
---|
| 8201 | +// usedtextures.add(bump); |
---|
| 8202 | +// |
---|
| 8203 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8204 | +// { |
---|
| 8205 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8206 | +// // System.out.println("; bump = " + bump); |
---|
| 8207 | +// } |
---|
| 8208 | +// |
---|
| 8209 | +// if (bump.equals("")) |
---|
| 8210 | +// { |
---|
| 8211 | +// bump = null; |
---|
| 8212 | +// } |
---|
| 8213 | +// if (pigment.equals("")) |
---|
| 8214 | +// { |
---|
| 8215 | +// pigment = null; |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8219 | +// BindTexture(pigment, false, resolution); |
---|
| 8220 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8221 | +// BindTexture(bump, true, resolution); |
---|
| 8222 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8223 | +// |
---|
| 8224 | +// return; // true; |
---|
| 8225 | + |
---|
| 8226 | + BindPigmentTexture(tex, resolution); |
---|
| 8227 | + BindBumpTexture(tex, resolution); |
---|
| 8228 | + } |
---|
| 8229 | + |
---|
| 8230 | + /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8015 | 8231 | { |
---|
8016 | 8232 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8017 | 8233 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8021 | 8237 | |
---|
8022 | 8238 | if (tex == null) |
---|
8023 | 8239 | { |
---|
8024 | | - BindTexture(null,false,resolution); |
---|
8025 | | - BindTexture(null,true,resolution); |
---|
| 8240 | + BindTexture(null, null,false,resolution); |
---|
8026 | 8241 | return; |
---|
8027 | 8242 | } |
---|
8028 | 8243 | |
---|
8029 | 8244 | String pigment = Object3D.GetPigment(tex); |
---|
| 8245 | + |
---|
| 8246 | + usedtextures.add(pigment); |
---|
| 8247 | + |
---|
| 8248 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8249 | + { |
---|
| 8250 | + // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8251 | + // System.out.println("; bump = " + bump); |
---|
| 8252 | + } |
---|
| 8253 | + |
---|
| 8254 | + if (pigment.equals("")) |
---|
| 8255 | + { |
---|
| 8256 | + pigment = null; |
---|
| 8257 | + } |
---|
| 8258 | + |
---|
| 8259 | + GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8260 | + BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
| 8261 | + } |
---|
| 8262 | + |
---|
| 8263 | + /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
| 8264 | + { |
---|
| 8265 | + if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8266 | + ambientOcclusion ) // || !textureon) |
---|
| 8267 | + { |
---|
| 8268 | + return; // false; |
---|
| 8269 | + } |
---|
| 8270 | + |
---|
| 8271 | + if (tex == null) |
---|
| 8272 | + { |
---|
| 8273 | + BindTexture(null, null,true,resolution); |
---|
| 8274 | + return; |
---|
| 8275 | + } |
---|
| 8276 | + |
---|
8030 | 8277 | String bump = Object3D.GetBump(tex); |
---|
8031 | 8278 | |
---|
8032 | | - usedtextures.put(pigment, pigment); |
---|
8033 | | - usedtextures.put(bump, bump); |
---|
| 8279 | + usedtextures.add(bump); |
---|
8034 | 8280 | |
---|
8035 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8281 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8036 | 8282 | { |
---|
8037 | 8283 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8038 | 8284 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8042 | 8288 | { |
---|
8043 | 8289 | bump = null; |
---|
8044 | 8290 | } |
---|
8045 | | - if (pigment.equals("")) |
---|
8046 | | - { |
---|
8047 | | - pigment = null; |
---|
8048 | | - } |
---|
8049 | 8291 | |
---|
8050 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8051 | | - BindTexture(pigment, false, resolution); |
---|
8052 | 8292 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8053 | | - BindTexture(bump, true, resolution); |
---|
| 8293 | + BindTexture(tex.bumptexture, bump, true, resolution); |
---|
8054 | 8294 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8055 | | - |
---|
8056 | | - return; // true; |
---|
8057 | 8295 | } |
---|
8058 | 8296 | |
---|
8059 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) |
---|
| 8297 | + java.util.HashSet<String> missingTextures = new java.util.HashSet<String>(); |
---|
| 8298 | + |
---|
| 8299 | + private boolean FileExists(String tex) |
---|
8060 | 8300 | { |
---|
8061 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8301 | + if (missingTextures.contains(tex)) |
---|
| 8302 | + { |
---|
| 8303 | + return false; |
---|
| 8304 | + } |
---|
| 8305 | + |
---|
| 8306 | + boolean fileExists = new File(tex).exists(); |
---|
| 8307 | + |
---|
| 8308 | + if (!fileExists) |
---|
| 8309 | + { |
---|
| 8310 | + // If file exists, the "new File()" is not executed sgain |
---|
| 8311 | + missingTextures.add(tex); |
---|
| 8312 | + } |
---|
| 8313 | + |
---|
| 8314 | + return fileExists; |
---|
| 8315 | + } |
---|
| 8316 | + |
---|
| 8317 | + CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
| 8318 | + { |
---|
| 8319 | + CacheTexture texturecache = null; |
---|
8062 | 8320 | |
---|
8063 | 8321 | if (tex != null) |
---|
8064 | 8322 | { |
---|
8065 | 8323 | String texname = tex; |
---|
8066 | 8324 | |
---|
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; |
---|
| 8325 | + String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
| 8326 | + |
---|
| 8327 | +// String[] split = tex.split("Textures"); |
---|
| 8328 | +// if (split.length > 1) |
---|
| 8329 | +// texname = "/Users/nbriere/Textures" + split[split.length-1]; |
---|
| 8330 | +// else |
---|
| 8331 | +// if (!texname.startsWith("/")) |
---|
| 8332 | +// texname = "/Users/nbriere/Textures/" + texname; |
---|
| 8333 | + if (!FileExists(tex)) |
---|
| 8334 | + { |
---|
| 8335 | + texname = fallbackTextureName; |
---|
| 8336 | + } |
---|
8073 | 8337 | |
---|
8074 | 8338 | if (CACHETEXTURE) |
---|
8075 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8076 | | - |
---|
8077 | | - TextureData texturedata = null; |
---|
8078 | | - |
---|
8079 | | - if (texture == null || texture.resolution < resolution) |
---|
8080 | 8339 | { |
---|
| 8340 | + if (bim == null) |
---|
| 8341 | + texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8342 | + else |
---|
| 8343 | + texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8344 | + } |
---|
| 8345 | + |
---|
| 8346 | + if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8347 | + { |
---|
| 8348 | + TextureData texturedata = null; |
---|
| 8349 | + |
---|
| 8350 | + if (bim != null) |
---|
| 8351 | + { |
---|
| 8352 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8353 | + } |
---|
| 8354 | + else |
---|
8081 | 8355 | if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8082 | 8356 | { |
---|
8083 | 8357 | assert(!bump); |
---|
.. | .. |
---|
8089 | 8363 | // } |
---|
8090 | 8364 | // else |
---|
8091 | 8365 | // { |
---|
8092 | | - texture = textures.get(tex); |
---|
8093 | | - if (texture == null) |
---|
| 8366 | + texturecache = textures.get(tex); |
---|
| 8367 | + if (texturecache == null) |
---|
8094 | 8368 | { |
---|
8095 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8369 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8096 | 8370 | } |
---|
| 8371 | + else |
---|
| 8372 | + new Exception().printStackTrace(); |
---|
8097 | 8373 | // } |
---|
8098 | 8374 | } else |
---|
8099 | 8375 | if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8100 | 8376 | { |
---|
8101 | 8377 | assert(bump); |
---|
8102 | | - texture = textures.get(tex); |
---|
8103 | | - if (texture == null) |
---|
8104 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8378 | + texturecache = textures.get(tex); |
---|
| 8379 | + if (texturecache == null) |
---|
| 8380 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8381 | + else |
---|
| 8382 | + new Exception().printStackTrace(); |
---|
8105 | 8383 | } else |
---|
8106 | 8384 | { |
---|
8107 | 8385 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8111 | 8389 | //{ |
---|
8112 | 8390 | if (tex.equals("WHITE_NOISE")) |
---|
8113 | 8391 | { |
---|
8114 | | - texture = textures.get(tex); |
---|
8115 | | - if (texture == null) |
---|
8116 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8392 | + texturecache = textures.get(tex); |
---|
| 8393 | + if (texturecache == null) |
---|
| 8394 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8395 | + else |
---|
| 8396 | + new Exception().printStackTrace(); |
---|
8117 | 8397 | } else |
---|
8118 | 8398 | { |
---|
8119 | 8399 | if (textureon) |
---|
.. | .. |
---|
8138 | 8418 | } |
---|
8139 | 8419 | |
---|
8140 | 8420 | cachename = texname.substring(0, texname.length()-4)+ext+".jpg"; |
---|
8141 | | - if (!new File(cachename).exists()) |
---|
| 8421 | + if (!FileExists(cachename)) |
---|
8142 | 8422 | cachename = texname; |
---|
8143 | 8423 | else |
---|
8144 | 8424 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8160 | 8440 | } |
---|
8161 | 8441 | |
---|
8162 | 8442 | cachename = texname.substring(0, texname.length()-4)+ext+".png"; |
---|
8163 | | - if (!new File(cachename).exists()) |
---|
| 8443 | + if (!FileExists(cachename)) |
---|
8164 | 8444 | cachename = texname; |
---|
8165 | 8445 | else |
---|
8166 | 8446 | processbump = false; // don't process bump map again |
---|
.. | .. |
---|
8169 | 8449 | texturedata = GetFileTexture(cachename, processbump, resolution); |
---|
8170 | 8450 | |
---|
8171 | 8451 | |
---|
8172 | | - if (texturedata != null) |
---|
8173 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8452 | + if (texturedata == null) |
---|
| 8453 | + throw new Exception(); |
---|
| 8454 | + |
---|
| 8455 | + texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8174 | 8456 | //texture = GetTexture(tex, bump); |
---|
8175 | 8457 | } |
---|
8176 | 8458 | } |
---|
8177 | 8459 | //} |
---|
8178 | 8460 | } |
---|
8179 | 8461 | |
---|
8180 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8462 | + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8181 | 8463 | { |
---|
8182 | 8464 | //return false; |
---|
| 8465 | + assert(bim == null); |
---|
8183 | 8466 | |
---|
8184 | 8467 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8185 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8468 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8186 | 8469 | { |
---|
8187 | 8470 | // String ext = "_highres"; |
---|
8188 | 8471 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8199 | 8482 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8200 | 8483 | if (!cachefile.exists()) |
---|
8201 | 8484 | { |
---|
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)) |
---|
| 8485 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8211 | 8486 | { |
---|
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); |
---|
| 8487 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8488 | + |
---|
8242 | 8489 | ImageWriter writer = null; |
---|
8243 | 8490 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8244 | 8491 | if (iter.hasNext()) { |
---|
8245 | 8492 | writer = (ImageWriter)iter.next(); |
---|
8246 | 8493 | } |
---|
8247 | | - float compressionQuality = 0.9f; |
---|
| 8494 | + |
---|
| 8495 | + float compressionQuality = 0.85f; |
---|
8248 | 8496 | try |
---|
8249 | 8497 | { |
---|
8250 | 8498 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8271 | 8519 | textures.remove(texname); |
---|
8272 | 8520 | } |
---|
8273 | 8521 | |
---|
8274 | | - texture.texturedata = texturedata; |
---|
8275 | | - textures.put(texname, texture); |
---|
| 8522 | + //texture.texturedata = texturedata; |
---|
| 8523 | + textures.put(texname, texturecache); |
---|
8276 | 8524 | |
---|
8277 | 8525 | // newtex = true; |
---|
8278 | 8526 | } |
---|
.. | .. |
---|
8288 | 8536 | } |
---|
8289 | 8537 | } |
---|
8290 | 8538 | |
---|
8291 | | - return texture; |
---|
| 8539 | + return texturecache; |
---|
8292 | 8540 | } |
---|
8293 | 8541 | |
---|
8294 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) |
---|
| 8542 | + static void EmbedTextures(cTexture tex) |
---|
8295 | 8543 | { |
---|
8296 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8544 | + |
---|
| 8545 | + } |
---|
| 8546 | + |
---|
| 8547 | + com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8548 | + { |
---|
| 8549 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8297 | 8550 | |
---|
8298 | 8551 | if (bump) |
---|
8299 | 8552 | { |
---|
.. | .. |
---|
8309 | 8562 | return texture!=null?texture.texture:null; |
---|
8310 | 8563 | } |
---|
8311 | 8564 | |
---|
8312 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) |
---|
| 8565 | + public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8313 | 8566 | { |
---|
8314 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8567 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8315 | 8568 | |
---|
8316 | 8569 | return texture!=null?texture.texturedata:null; |
---|
8317 | 8570 | } |
---|
8318 | 8571 | |
---|
8319 | | - boolean BindTexture(String tex, boolean bump, int resolution) |
---|
| 8572 | + boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8320 | 8573 | { |
---|
8321 | 8574 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8322 | 8575 | { |
---|
8323 | 8576 | return false; |
---|
8324 | 8577 | } |
---|
8325 | 8578 | |
---|
8326 | | - boolean newtex = false; |
---|
| 8579 | + //boolean newtex = false; |
---|
8327 | 8580 | |
---|
8328 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
| 8581 | + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
8329 | 8582 | |
---|
8330 | 8583 | if (texture == null) |
---|
8331 | 8584 | return false; |
---|
.. | .. |
---|
8355 | 8608 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8356 | 8609 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8357 | 8610 | |
---|
8358 | | - return newtex; |
---|
| 8611 | + return true; // Warning: not used. |
---|
8359 | 8612 | } |
---|
8360 | 8613 | |
---|
8361 | 8614 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
9193 | 9446 | jy8[3] = 0.5f; |
---|
9194 | 9447 | } |
---|
9195 | 9448 | |
---|
9196 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9449 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9197 | 9450 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9198 | 9451 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9199 | 9452 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9200 | 9453 | |
---|
| 9454 | + void ResetOptions() |
---|
| 9455 | + { |
---|
| 9456 | + options1[0] = 100; |
---|
| 9457 | + options1[1] = 0.025f; |
---|
| 9458 | + options1[2] = 0.01f; |
---|
| 9459 | + options1[3] = 0; |
---|
| 9460 | + options1[4] = 0; |
---|
| 9461 | + |
---|
| 9462 | + options2[0] = 0; |
---|
| 9463 | + options2[1] = 0.75f; |
---|
| 9464 | + options2[2] = 0; |
---|
| 9465 | + options2[3] = 0; |
---|
| 9466 | + |
---|
| 9467 | + options3[0] = 1; |
---|
| 9468 | + options3[1] = 1; |
---|
| 9469 | + options3[2] = 1; |
---|
| 9470 | + options3[3] = 0; |
---|
| 9471 | + |
---|
| 9472 | + options4[0] = 1; |
---|
| 9473 | + options4[1] = 0; |
---|
| 9474 | + options4[2] = 1; |
---|
| 9475 | + options4[3] = 0; |
---|
| 9476 | + } |
---|
| 9477 | + |
---|
9201 | 9478 | static int imagecount = 0; // movie generation |
---|
9202 | 9479 | |
---|
9203 | 9480 | static int jitter = 0; |
---|
.. | .. |
---|
9293 | 9570 | assert (parentcam != renderCamera); |
---|
9294 | 9571 | |
---|
9295 | 9572 | if (renderCamera != lightCamera) |
---|
9296 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9297 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 9573 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9574 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
9298 | 9575 | |
---|
9299 | 9576 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9300 | 9577 | |
---|
.. | .. |
---|
9309 | 9586 | LA.matCopy(renderCamera.fromScreen, matrix); |
---|
9310 | 9587 | |
---|
9311 | 9588 | if (renderCamera != lightCamera) |
---|
9312 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9313 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 9589 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 9590 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
9314 | 9591 | |
---|
9315 | 9592 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9316 | 9593 | |
---|
.. | .. |
---|
9382 | 9659 | //gl.glFlush(); |
---|
9383 | 9660 | gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE); |
---|
9384 | 9661 | |
---|
9385 | | - if (ANIMATION && ABORTED) |
---|
| 9662 | + if (Globals.ANIMATION && ABORTED) |
---|
9386 | 9663 | { |
---|
9387 | 9664 | System.err.println(" ABORTED FRAME"); |
---|
9388 | 9665 | break; |
---|
.. | .. |
---|
9412 | 9689 | setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR)); |
---|
9413 | 9690 | |
---|
9414 | 9691 | // save image |
---|
9415 | | - if (ANIMATION && !ABORTED) |
---|
| 9692 | + if (Globals.ANIMATION && !ABORTED) |
---|
9416 | 9693 | { |
---|
9417 | 9694 | VPwidth = viewport[2]; |
---|
9418 | 9695 | VPheight = viewport[3]; |
---|
.. | .. |
---|
9523 | 9800 | |
---|
9524 | 9801 | // imagecount++; |
---|
9525 | 9802 | |
---|
9526 | | - String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
| 9803 | + String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext; |
---|
9527 | 9804 | |
---|
9528 | 9805 | if (!BOXMODE) |
---|
9529 | 9806 | { |
---|
9530 | | - System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")"); |
---|
| 9807 | + System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")"); |
---|
9531 | 9808 | } |
---|
9532 | 9809 | |
---|
9533 | 9810 | if (!BOXMODE) |
---|
.. | .. |
---|
9565 | 9842 | ABORTED = false; |
---|
9566 | 9843 | } |
---|
9567 | 9844 | else |
---|
9568 | | - GrafreeD.wav.cursor += 735 * ACSIZE; |
---|
| 9845 | + Grafreed.wav.cursor += 735 * ACSIZE; |
---|
9569 | 9846 | |
---|
9570 | 9847 | if (false) |
---|
9571 | 9848 | { |
---|
.. | .. |
---|
10228 | 10505 | |
---|
10229 | 10506 | public void display(GLAutoDrawable drawable) |
---|
10230 | 10507 | { |
---|
10231 | | - if (GrafreeD.savesound && GrafreeD.hassound) |
---|
| 10508 | + if (Grafreed.savesound && Grafreed.hassound) |
---|
10232 | 10509 | { |
---|
10233 | | - GrafreeD.wav.save(); |
---|
10234 | | - GrafreeD.savesound = false; |
---|
10235 | | - GrafreeD.hassound = false; |
---|
| 10510 | + Grafreed.wav.save(); |
---|
| 10511 | + Grafreed.savesound = false; |
---|
| 10512 | + Grafreed.hassound = false; |
---|
10236 | 10513 | } |
---|
10237 | 10514 | // if (DEBUG_SELECTION) |
---|
10238 | 10515 | // { |
---|
.. | .. |
---|
10308 | 10585 | ANTIALIAS = 0; |
---|
10309 | 10586 | //System.out.println("RESTART"); |
---|
10310 | 10587 | AAtimer.restart(); |
---|
| 10588 | + Globals.TIMERRUNNING = true; |
---|
10311 | 10589 | } |
---|
10312 | 10590 | } |
---|
10313 | 10591 | } |
---|
.. | .. |
---|
10362 | 10640 | Object3D theobject = object; |
---|
10363 | 10641 | Object3D theparent = object.parent; |
---|
10364 | 10642 | object.parent = null; |
---|
10365 | | - object = (Object3D)GrafreeD.clone(object); |
---|
| 10643 | + object = (Object3D)Grafreed.clone(object); |
---|
10366 | 10644 | object.Stripify(); |
---|
10367 | 10645 | if (theobject.selection == null || theobject.selection.Size() == 0) |
---|
10368 | 10646 | theobject.PreprocessOcclusion(this); |
---|
.. | .. |
---|
10375 | 10653 | ambientOcclusion = false; |
---|
10376 | 10654 | } |
---|
10377 | 10655 | |
---|
10378 | | - if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN) |
---|
| 10656 | + if (//Globals.lighttouched && |
---|
| 10657 | + DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN) |
---|
10379 | 10658 | { |
---|
10380 | 10659 | //if (RENDERSHADOW) // ? |
---|
10381 | 10660 | if (!IsFrozen()) |
---|
10382 | 10661 | { |
---|
10383 | 10662 | // dec 2012 |
---|
10384 | | - if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
| 10663 | + if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0)) |
---|
10385 | 10664 | { |
---|
10386 | 10665 | Globals.framecount++; |
---|
10387 | 10666 | shadowbuffer.display(); |
---|
.. | .. |
---|
10508 | 10787 | |
---|
10509 | 10788 | // if (parentcam != renderCamera) // not a light |
---|
10510 | 10789 | if (cam != lightCamera) |
---|
10511 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10512 | | - LA.matConcat(matrix, parentcam.toParent, matrix); |
---|
| 10790 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10791 | + LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
10513 | 10792 | |
---|
10514 | 10793 | for (int j = 0; j < 4; j++) |
---|
10515 | 10794 | { |
---|
.. | .. |
---|
10523 | 10802 | |
---|
10524 | 10803 | // if (parentcam != renderCamera) // not a light |
---|
10525 | 10804 | if (cam != lightCamera) |
---|
10526 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10527 | | - LA.matConcat(parentcam.fromParent, matrix, matrix); |
---|
| 10805 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 10806 | + LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
10528 | 10807 | |
---|
10529 | 10808 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10530 | 10809 | |
---|
.. | .. |
---|
10783 | 11062 | // Bump noise |
---|
10784 | 11063 | gl.glActiveTexture(GL.GL_TEXTURE6); |
---|
10785 | 11064 | //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise); |
---|
10786 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11065 | + |
---|
| 11066 | + try |
---|
| 11067 | + { |
---|
| 11068 | + BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
| 11069 | + } |
---|
| 11070 | + catch (Exception e) |
---|
| 11071 | + { |
---|
| 11072 | + System.err.println("FAILED: " + NOISE_TEXTURE); |
---|
| 11073 | + } |
---|
| 11074 | + |
---|
10787 | 11075 | |
---|
10788 | 11076 | gl.glActiveTexture(GL.GL_TEXTURE0); |
---|
10789 | 11077 | gl.glEnable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10806 | 11094 | |
---|
10807 | 11095 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10808 | 11096 | |
---|
10809 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10810 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10811 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11097 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11098 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11099 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10812 | 11100 | } else |
---|
10813 | 11101 | { |
---|
10814 | 11102 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
10819 | 11107 | //System.out.println("BLENDING ON"); |
---|
10820 | 11108 | gl.glEnable(GL.GL_BLEND); |
---|
10821 | 11109 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
10822 | | - |
---|
| 11110 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
10823 | 11111 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
10824 | 11112 | gl.glLoadIdentity(); |
---|
10825 | 11113 | |
---|
.. | .. |
---|
10908 | 11196 | System.err.println("parentcam != renderCamera"); |
---|
10909 | 11197 | |
---|
10910 | 11198 | // if (cam != lightCamera) |
---|
10911 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10912 | | - LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013 |
---|
| 11199 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11200 | + LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
10913 | 11201 | } |
---|
10914 | 11202 | |
---|
10915 | 11203 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
10930 | 11218 | if (true) // TODO |
---|
10931 | 11219 | { |
---|
10932 | 11220 | if (cam != lightCamera) |
---|
10933 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.xformDir(light0, parentcam.toParent, light0); // may 2013 |
---|
| 11221 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 11222 | + LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013 |
---|
10935 | 11223 | } |
---|
10936 | 11224 | |
---|
10937 | 11225 | LA.xformPos(light0, cam.toScreen, light0); |
---|
.. | .. |
---|
11247 | 11535 | { |
---|
11248 | 11536 | renderpass++; |
---|
11249 | 11537 | // System.out.println("Draw object... "); |
---|
| 11538 | + STEP = 1; |
---|
11250 | 11539 | if (FAST) // in case there is no script |
---|
11251 | | - STEP = 16; |
---|
| 11540 | + STEP = 8; |
---|
| 11541 | + |
---|
| 11542 | + if (CURRENTANTIALIAS == 0 || ACSIZE == 1) |
---|
| 11543 | + { |
---|
| 11544 | + STEP *= 4; |
---|
| 11545 | + } |
---|
11252 | 11546 | |
---|
11253 | 11547 | //object.FullInvariants(); |
---|
11254 | 11548 | |
---|
.. | .. |
---|
11262 | 11556 | e.printStackTrace(); |
---|
11263 | 11557 | } |
---|
11264 | 11558 | |
---|
11265 | | - if (GrafreeD.RENDERME > 0) |
---|
11266 | | - GrafreeD.RENDERME--; // mechante magouille |
---|
| 11559 | + if (Grafreed.RENDERME > 0) |
---|
| 11560 | + Grafreed.RENDERME--; // mechante magouille |
---|
11267 | 11561 | |
---|
11268 | 11562 | Globals.ONESTEP = false; |
---|
11269 | 11563 | } |
---|
11270 | 11564 | |
---|
11271 | 11565 | static boolean zoomonce = false; |
---|
11272 | 11566 | |
---|
| 11567 | + static void CreateSelectedPoint() |
---|
| 11568 | + { |
---|
| 11569 | + if (selectedpoint == null) |
---|
| 11570 | + { |
---|
| 11571 | + debugpointG = new Sphere(); |
---|
| 11572 | + debugpointP = new Sphere(); |
---|
| 11573 | + debugpointC = new Sphere(); |
---|
| 11574 | + debugpointR = new Sphere(); |
---|
| 11575 | + |
---|
| 11576 | + selectedpoint = new Superellipsoid(); |
---|
| 11577 | + |
---|
| 11578 | + for (int i=0; i<8; i++) |
---|
| 11579 | + { |
---|
| 11580 | + debugpoints[i] = new Sphere(); |
---|
| 11581 | + } |
---|
| 11582 | + } |
---|
| 11583 | + } |
---|
| 11584 | + |
---|
11273 | 11585 | void DrawObject(GL gl, boolean draw) |
---|
11274 | 11586 | { |
---|
| 11587 | + // To clear camera values |
---|
| 11588 | + ResetOptions(); |
---|
| 11589 | + |
---|
11275 | 11590 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11276 | 11591 | // DrawMode() = SELECTION; |
---|
11277 | 11592 | //GL gl = getGL(); |
---|
11278 | 11593 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11279 | 11594 | { |
---|
11280 | 11595 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11281 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11596 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11282 | 11597 | pingthread.StepToTarget(true); // true); |
---|
11283 | 11598 | // zoomonce = false; |
---|
11284 | 11599 | } |
---|
.. | .. |
---|
11333 | 11648 | |
---|
11334 | 11649 | usedtextures.clear(); |
---|
11335 | 11650 | |
---|
11336 | | - BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11651 | + try |
---|
| 11652 | + { |
---|
| 11653 | + BindTextures(DEFAULT_TEXTURES, 2); |
---|
| 11654 | + } |
---|
| 11655 | + catch (Exception e) |
---|
| 11656 | + { |
---|
| 11657 | + System.err.println("FAILED: " + DEFAULT_TEXTURES); |
---|
| 11658 | + } |
---|
11337 | 11659 | } |
---|
11338 | 11660 | //System.out.println("--> " + stackdepth); |
---|
11339 | 11661 | // GrafreeD.traceon(); |
---|
.. | .. |
---|
11343 | 11665 | |
---|
11344 | 11666 | if (DrawMode() == DEFAULT) |
---|
11345 | 11667 | { |
---|
11346 | | - if (DEBUG) |
---|
| 11668 | + if (Globals.DEBUG) |
---|
11347 | 11669 | { |
---|
| 11670 | + CreateSelectedPoint(); |
---|
11348 | 11671 | float radius = 0.05f; |
---|
11349 | 11672 | if (selectedpoint.radius != radius) |
---|
11350 | 11673 | { |
---|
.. | .. |
---|
11407 | 11730 | if (tex.equals("WHITE_NOISE")) |
---|
11408 | 11731 | continue; |
---|
11409 | 11732 | |
---|
11410 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11733 | + if (!usedtextures.contains(tex)) |
---|
11411 | 11734 | { |
---|
11412 | 11735 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11413 | 11736 | textures.get(tex).texture.dispose(); |
---|
.. | .. |
---|
11424 | 11747 | if (checker != null && DrawMode() == DEFAULT) |
---|
11425 | 11748 | { |
---|
11426 | 11749 | //BindTexture(IMMORTAL_TEXTURE); |
---|
11427 | | - BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11750 | + try |
---|
| 11751 | + { |
---|
| 11752 | + BindTextures(checker.GetTextures(), checker.texres); |
---|
| 11753 | + } |
---|
| 11754 | + catch (Exception e) |
---|
| 11755 | + { |
---|
| 11756 | + System.err.println("FAILED: " + checker.GetTextures()); |
---|
| 11757 | + } |
---|
11428 | 11758 | // NEAREST |
---|
11429 | 11759 | GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR); |
---|
11430 | 11760 | DrawChecker(gl); |
---|
.. | .. |
---|
11506 | 11836 | return; |
---|
11507 | 11837 | } |
---|
11508 | 11838 | |
---|
11509 | | - String string = obj.GetToolTip(); |
---|
| 11839 | + String string = obj.toString(); //.GetToolTip(); |
---|
11510 | 11840 | |
---|
11511 | 11841 | GL gl = GetGL(); |
---|
11512 | 11842 | |
---|
.. | .. |
---|
11823 | 12153 | //obj.TransformToWorld(light, light); |
---|
11824 | 12154 | for (int i = tp.size(); --i >= 0;) |
---|
11825 | 12155 | { |
---|
11826 | | - for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
11827 | | - LA.xformPos(light, tp.get(i).toParent, light); |
---|
| 12156 | + //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
| 12157 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
11828 | 12158 | } |
---|
11829 | 12159 | |
---|
11830 | 12160 | |
---|
.. | .. |
---|
11841 | 12171 | parentcam = cameras[0]; |
---|
11842 | 12172 | } |
---|
11843 | 12173 | |
---|
11844 | | - for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11845 | | - LA.xformPos(light, parentcam.toParent, light); // may 2013 |
---|
| 12174 | + //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
| 12175 | + LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013 |
---|
11846 | 12176 | |
---|
11847 | 12177 | LA.xformPos(light, renderCamera.toScreen, light); |
---|
11848 | 12178 | |
---|
.. | .. |
---|
12456 | 12786 | |
---|
12457 | 12787 | // display shadow only (bump == 0) |
---|
12458 | 12788 | "SUB temp.x, half.x, shadow.x;" + |
---|
12459 | | - "MOV temp.y, -params6.x;" + |
---|
12460 | | - "SLT temp.z, temp.y, zero.x;" + |
---|
| 12789 | + "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
| 12790 | + "SLT temp.z, temp.y, -one2048th.x;" + |
---|
12461 | 12791 | "SUB temp.y, one.x, temp.z;" + |
---|
12462 | 12792 | "MUL temp.x, temp.x, temp.y;" + |
---|
12463 | 12793 | "KIL temp.x;" + |
---|
.. | .. |
---|
12586 | 12916 | "MAX ndotl.x, ndotl.x, -ndotl.x;" + |
---|
12587 | 12917 | |
---|
12588 | 12918 | "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 |
---|
| 12919 | + // Tuning for default skin |
---|
| 12920 | + //"ADD temp.x, temp.x, options2.z;" + // lightsheen |
---|
| 12921 | + "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen |
---|
| 12922 | + "ADD temp.y, one.y, options2.y;" + // subsurface |
---|
12591 | 12923 | "MUL temp.x, temp.x, temp.y;" + |
---|
12592 | 12924 | |
---|
12593 | 12925 | "MUL saturation, saturation, temp.xxxx;" + |
---|
.. | .. |
---|
12786 | 13118 | //once = true; |
---|
12787 | 13119 | } |
---|
12788 | 13120 | |
---|
12789 | | - System.out.print("Program #" + mode + "; length = " + program.length()); |
---|
| 13121 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
12790 | 13122 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
12791 | 13123 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
12792 | 13124 | |
---|
.. | .. |
---|
12919 | 13251 | |
---|
12920 | 13252 | "ADD " + depth + ".z, " + depth + ".z, temp.x;" + |
---|
12921 | 13253 | //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing! |
---|
| 13254 | + |
---|
| 13255 | + // Compare fragment depth in light space with shadowmap. |
---|
12922 | 13256 | "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
12923 | 13257 | "SGE temp.y, temp.x, zero.x;" + |
---|
12924 | | - "SUB " + shadow + ".y, one.x, temp.y;" + |
---|
| 13258 | + "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded |
---|
| 13259 | + |
---|
| 13260 | + // Reverse comparison |
---|
12925 | 13261 | "SUB temp.x, one.x, temp.x;" + |
---|
12926 | 13262 | "MUL " + shadow + ".x, temp.x, temp.y;" + |
---|
12927 | | - "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded |
---|
| 13263 | + "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse |
---|
12928 | 13264 | "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth |
---|
12929 | 13265 | |
---|
12930 | 13266 | "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" + |
---|
.. | .. |
---|
12938 | 13274 | // No shadow for backface |
---|
12939 | 13275 | "DP3 temp.x, normal, lightd;" + |
---|
12940 | 13276 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
| 13277 | + "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
| 13278 | + |
---|
| 13279 | + // No shadow when out of frustrum |
---|
| 13280 | + "SGE temp.x, " + depth + ".z, one.z;" + |
---|
12941 | 13281 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
12942 | 13282 | ""; |
---|
12943 | 13283 | } |
---|
.. | .. |
---|
13084 | 13424 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13085 | 13425 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13086 | 13426 | /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
13087 | | - Object3D.cVector2[] vector2buffer; |
---|
| 13427 | + |
---|
| 13428 | + //Object3D.cVector2[] vector2buffer; |
---|
13088 | 13429 | |
---|
13089 | 13430 | // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea |
---|
13090 | 13431 | // OUT : diff, spec |
---|
.. | .. |
---|
13100 | 13441 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13101 | 13442 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13102 | 13443 | //"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;" + |
---|
| 13444 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13445 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13446 | + |
---|
| 13447 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13106 | 13448 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13107 | 13449 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13108 | 13450 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13496 | 13838 | public void mousePressed(MouseEvent e) |
---|
13497 | 13839 | { |
---|
13498 | 13840 | //System.out.println("mousePressed: " + e); |
---|
13499 | | - clickStart(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 13841 | + clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13500 | 13842 | } |
---|
13501 | 13843 | |
---|
13502 | 13844 | static long prevtime = 0; |
---|
.. | .. |
---|
13523 | 13865 | |
---|
13524 | 13866 | //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio); |
---|
13525 | 13867 | |
---|
| 13868 | + if (BUTTONLESSWHEEL) |
---|
13526 | 13869 | if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30) |
---|
13527 | 13870 | { |
---|
13528 | 13871 | return; |
---|
.. | .. |
---|
13531 | 13874 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
13532 | 13875 | |
---|
13533 | 13876 | // TIMER |
---|
13534 | | - if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
| 13877 | + if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR |
---|
13535 | 13878 | { |
---|
13536 | 13879 | keepboxmode = BOXMODE; |
---|
13537 | 13880 | keepsupport = SUPPORT; |
---|
.. | .. |
---|
13571 | 13914 | // mode |= META; |
---|
13572 | 13915 | //} |
---|
13573 | 13916 | |
---|
13574 | | - SetMouseMode(WHEEL | e.getModifiersEx()); |
---|
13575 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0); |
---|
| 13917 | + SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
| 13918 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
13576 | 13919 | anchorX = ax; |
---|
13577 | 13920 | anchorY = ay; |
---|
13578 | 13921 | prevX = px; |
---|
.. | .. |
---|
13606 | 13949 | else |
---|
13607 | 13950 | if (evt.getSource() == AAtimer) |
---|
13608 | 13951 | { |
---|
| 13952 | + Globals.TIMERRUNNING = false; |
---|
13609 | 13953 | if (mouseDown) |
---|
13610 | 13954 | { |
---|
13611 | 13955 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13631 | 13975 | // LIVE = waslive; |
---|
13632 | 13976 | // wasliveok = true; |
---|
13633 | 13977 | // waslive = false; |
---|
| 13978 | + |
---|
| 13979 | + // May 2019 Forget it: |
---|
| 13980 | + if (true) |
---|
| 13981 | + return; |
---|
13634 | 13982 | |
---|
13635 | 13983 | // source == timer |
---|
13636 | 13984 | if (mouseDown) |
---|
.. | .. |
---|
13661 | 14009 | |
---|
13662 | 14010 | // fev 2014??? |
---|
13663 | 14011 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13664 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14012 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13665 | 14013 | pingthread.StepToTarget(true); // true); |
---|
13666 | 14014 | } |
---|
13667 | 14015 | // if (!LIVE) |
---|
.. | .. |
---|
13670 | 14018 | |
---|
13671 | 14019 | javax.swing.Timer timer = new javax.swing.Timer(350, this); |
---|
13672 | 14020 | |
---|
13673 | | - void clickStart(int x, int y, int modifiers) |
---|
| 14021 | + void clickStart(int x, int y, int modifiers, int modifiersex) |
---|
13674 | 14022 | { |
---|
13675 | 14023 | if (!wasliveok) |
---|
13676 | 14024 | return; |
---|
13677 | 14025 | |
---|
13678 | 14026 | AAtimer.restart(); // |
---|
| 14027 | + Globals.TIMERRUNNING = true; |
---|
13679 | 14028 | |
---|
13680 | 14029 | // waslive = LIVE; |
---|
13681 | 14030 | // LIVE = false; |
---|
.. | .. |
---|
13687 | 14036 | // touched = true; // main DL |
---|
13688 | 14037 | if (isRenderer) |
---|
13689 | 14038 | { |
---|
13690 | | - SetMouseMode(modifiers); |
---|
| 14039 | + SetMouseMode(modifiers, modifiersex); |
---|
13691 | 14040 | } |
---|
13692 | 14041 | |
---|
13693 | 14042 | selectX = anchorX = x; |
---|
.. | .. |
---|
13700 | 14049 | clicked = true; |
---|
13701 | 14050 | hold = false; |
---|
13702 | 14051 | |
---|
13703 | | - if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection |
---|
| 14052 | + if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection |
---|
13704 | 14053 | // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection |
---|
13705 | 14054 | { |
---|
13706 | 14055 | // System.out.println("RESTART II " + modifiers); |
---|
.. | .. |
---|
13731 | 14080 | info.camera = renderCamera; |
---|
13732 | 14081 | info.x = x; |
---|
13733 | 14082 | info.y = y; |
---|
13734 | | - info.modifiers = modifiers; |
---|
| 14083 | + info.modifiers = modifiersex; |
---|
13735 | 14084 | editObj = object.doEditClick(info, 0); |
---|
13736 | 14085 | if (!editObj) |
---|
13737 | 14086 | { |
---|
.. | .. |
---|
13748 | 14097 | |
---|
13749 | 14098 | public void mouseDragged(MouseEvent e) |
---|
13750 | 14099 | { |
---|
| 14100 | + Globals.MOUSEDRAGGED = true; |
---|
| 14101 | + |
---|
| 14102 | + //System.out.println("mouseDragged: " + e); |
---|
13751 | 14103 | if (isRenderer) |
---|
13752 | 14104 | movingcamera = true; |
---|
| 14105 | + |
---|
13753 | 14106 | //if (drawing) |
---|
13754 | 14107 | //return; |
---|
13755 | | - //System.out.println("mouseDragged: " + e); |
---|
13756 | 14108 | if ((e.getModifiersEx() & CTRL) != 0 |
---|
13757 | 14109 | || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
13758 | 14110 | { |
---|
.. | .. |
---|
13760 | 14112 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
13761 | 14113 | } |
---|
13762 | 14114 | else |
---|
13763 | | - drag(e.getX(), e.getY(), e.getModifiersEx()); |
---|
| 14115 | + drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx()); |
---|
13764 | 14116 | |
---|
13765 | 14117 | //try { Thread.sleep(1); } catch (Exception ex) {} |
---|
13766 | 14118 | } |
---|
.. | .. |
---|
13933 | 14285 | |
---|
13934 | 14286 | public void run() |
---|
13935 | 14287 | { |
---|
| 14288 | + new Exception().printStackTrace(); |
---|
13936 | 14289 | System.exit(0); |
---|
13937 | 14290 | for (;;) |
---|
13938 | 14291 | { |
---|
.. | .. |
---|
13996 | 14349 | { |
---|
13997 | 14350 | Globals.lighttouched = true; |
---|
13998 | 14351 | } |
---|
13999 | | - drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS); |
---|
| 14352 | + drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS); |
---|
14000 | 14353 | } |
---|
14001 | 14354 | //else |
---|
14002 | 14355 | } |
---|
.. | .. |
---|
14010 | 14363 | void GoDown(int mod) |
---|
14011 | 14364 | { |
---|
14012 | 14365 | MODIFIERS |= COMMAND; |
---|
14013 | | - /* |
---|
| 14366 | + /**/ |
---|
14014 | 14367 | if((mod&SHIFT) == SHIFT) |
---|
14015 | 14368 | manipCamera.RotatePosition(0, -speed); |
---|
14016 | 14369 | else |
---|
14017 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14018 | | - */ |
---|
| 14370 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14371 | + /**/ |
---|
14019 | 14372 | if ((mod & SHIFT) == SHIFT) |
---|
14020 | 14373 | { |
---|
14021 | 14374 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14031 | 14384 | void GoUp(int mod) |
---|
14032 | 14385 | { |
---|
14033 | 14386 | MODIFIERS |= COMMAND; |
---|
14034 | | - /* |
---|
| 14387 | + /**/ |
---|
14035 | 14388 | if((mod&SHIFT) == SHIFT) |
---|
14036 | 14389 | manipCamera.RotatePosition(0, speed); |
---|
14037 | 14390 | else |
---|
14038 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14039 | | - */ |
---|
| 14391 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14392 | + /**/ |
---|
14040 | 14393 | if ((mod & SHIFT) == SHIFT) |
---|
14041 | 14394 | { |
---|
14042 | 14395 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14052 | 14405 | void GoLeft(int mod) |
---|
14053 | 14406 | { |
---|
14054 | 14407 | MODIFIERS |= COMMAND; |
---|
14055 | | - /* |
---|
| 14408 | + /**/ |
---|
14056 | 14409 | if((mod&SHIFT) == SHIFT) |
---|
14057 | | - manipCamera.RotatePosition(speed, 0); |
---|
14058 | | - else |
---|
14059 | 14410 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14060 | | - */ |
---|
| 14411 | + else |
---|
| 14412 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14413 | + /**/ |
---|
14061 | 14414 | if ((mod & SHIFT) == SHIFT) |
---|
14062 | 14415 | { |
---|
14063 | 14416 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14073 | 14426 | void GoRight(int mod) |
---|
14074 | 14427 | { |
---|
14075 | 14428 | MODIFIERS |= COMMAND; |
---|
14076 | | - /* |
---|
| 14429 | + /**/ |
---|
14077 | 14430 | if((mod&SHIFT) == SHIFT) |
---|
14078 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14079 | | - else |
---|
14080 | 14431 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14081 | | - */ |
---|
| 14432 | + else |
---|
| 14433 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14434 | + /**/ |
---|
14082 | 14435 | if ((mod & SHIFT) == SHIFT) |
---|
14083 | 14436 | { |
---|
14084 | 14437 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14096 | 14449 | int X, Y; |
---|
14097 | 14450 | boolean SX, SY; |
---|
14098 | 14451 | |
---|
14099 | | - void drag(int x, int y, int modifiers) |
---|
| 14452 | + void drag(int x, int y, int modifiers, int modifiersex) |
---|
14100 | 14453 | { |
---|
14101 | 14454 | if (IsFrozen()) |
---|
14102 | 14455 | { |
---|
.. | .. |
---|
14105 | 14458 | |
---|
14106 | 14459 | drag = true; // NEW |
---|
14107 | 14460 | |
---|
14108 | | - boolean continuous = (modifiers & COMMAND) == COMMAND; |
---|
| 14461 | + boolean continuous = (modifiersex & COMMAND) == COMMAND; |
---|
14109 | 14462 | |
---|
14110 | 14463 | X = x; |
---|
14111 | 14464 | Y = y; |
---|
14112 | 14465 | // floating state for animation |
---|
14113 | | - MODIFIERS = modifiers; |
---|
14114 | | - modifiers &= ~1024; |
---|
| 14466 | + MODIFIERS = modifiersex; |
---|
| 14467 | + modifiersex &= ~1024; |
---|
14115 | 14468 | if (false) // modifiers != 0) |
---|
14116 | 14469 | { |
---|
14117 | 14470 | //new Exception().printStackTrace(); |
---|
14118 | | - System.out.println("mouseDragged: " + modifiers); |
---|
| 14471 | + System.out.println("mouseDragged: " + modifiersex); |
---|
14119 | 14472 | System.out.println("SHIFT = " + SHIFT); |
---|
14120 | 14473 | System.out.println("CONTROL = " + COMMAND); |
---|
14121 | 14474 | System.out.println("META = " + META); |
---|
.. | .. |
---|
14135 | 14488 | info.camera = renderCamera; |
---|
14136 | 14489 | info.x = x; |
---|
14137 | 14490 | info.y = y; |
---|
14138 | | - object.editWindow.copy.doEditDrag(info); |
---|
| 14491 | + object.GetWindow().copy |
---|
| 14492 | + .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14139 | 14493 | } else |
---|
14140 | 14494 | { |
---|
14141 | 14495 | if (x < startX) |
---|
.. | .. |
---|
14287 | 14641 | public void mouseMoved(MouseEvent e) |
---|
14288 | 14642 | { |
---|
14289 | 14643 | //System.out.println("mouseMoved: " + e); |
---|
14290 | | - |
---|
14291 | 14644 | if (isRenderer) |
---|
14292 | 14645 | return; |
---|
14293 | 14646 | |
---|
.. | .. |
---|
14300 | 14653 | ci.camera = renderCamera; |
---|
14301 | 14654 | if (!isRenderer) |
---|
14302 | 14655 | { |
---|
14303 | | - if (object.editWindow.copy.doEditClick(ci, 0)) |
---|
| 14656 | + //ObjEditor editWindow = object.editWindow; |
---|
| 14657 | + //Object3D copy = editWindow.copy; |
---|
| 14658 | + if (object.doEditClick(ci, 0)) |
---|
14304 | 14659 | { |
---|
14305 | 14660 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14306 | 14661 | } else |
---|
.. | .. |
---|
14312 | 14667 | |
---|
14313 | 14668 | public void mouseReleased(MouseEvent e) |
---|
14314 | 14669 | { |
---|
| 14670 | + Globals.MOUSEDRAGGED = false; |
---|
| 14671 | + |
---|
14315 | 14672 | movingcamera = false; |
---|
| 14673 | + X = 0; // getBounds().width/2; |
---|
| 14674 | + Y = 0; // getBounds().height/2; |
---|
14316 | 14675 | //System.out.println("mouseReleased: " + e); |
---|
14317 | 14676 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14318 | 14677 | } |
---|
.. | .. |
---|
14335 | 14694 | boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection |
---|
14336 | 14695 | boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection |
---|
14337 | 14696 | |
---|
14338 | | - if (control || command || IsFrozen()) |
---|
| 14697 | +// No delay if (control || command || IsFrozen()) |
---|
14339 | 14698 | timeout = true; |
---|
14340 | | - else |
---|
| 14699 | +// ?? May 2019 else |
---|
14341 | 14700 | // timer.setDelay((modifiers & 128) != 0?0:350); |
---|
14342 | 14701 | mouseDown = false; |
---|
14343 | 14702 | if (!control && !command) // june 2013 |
---|
.. | .. |
---|
14447 | 14806 | System.out.println("keyReleased: " + e); |
---|
14448 | 14807 | } |
---|
14449 | 14808 | |
---|
14450 | | - void SetMouseMode(int modifiers) |
---|
| 14809 | + void SetMouseMode(int modifiers, int modifiersex) |
---|
14451 | 14810 | { |
---|
14452 | 14811 | //System.out.println("SetMouseMode = " + modifiers); |
---|
14453 | 14812 | //modifiers &= ~1024; |
---|
.. | .. |
---|
14459 | 14818 | //if (modifiers == 0) // || (modifiers == (1024 | CONTROL))) |
---|
14460 | 14819 | // return; |
---|
14461 | 14820 | //System.out.println("SetMode = " + modifiers); |
---|
14462 | | - if ((modifiers & WHEEL) == WHEEL) |
---|
| 14821 | + if ((modifiersex & WHEEL) == WHEEL) |
---|
14463 | 14822 | { |
---|
14464 | 14823 | mouseMode |= ZOOM; |
---|
14465 | 14824 | } |
---|
14466 | 14825 | |
---|
14467 | 14826 | boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK); |
---|
14468 | | - if (capsLocked || (modifiers & META) == META) |
---|
| 14827 | + if (capsLocked) // || (modifiers & META) == META) |
---|
14469 | 14828 | { |
---|
14470 | 14829 | mouseMode |= VR; // BACKFORTH; |
---|
14471 | 14830 | } |
---|
14472 | | - if ((modifiers & CTRLCLICK) == CTRLCLICK) |
---|
| 14831 | + if ((modifiersex & CTRLCLICK) == CTRLCLICK) |
---|
14473 | 14832 | { |
---|
14474 | 14833 | mouseMode |= SELECT; |
---|
14475 | 14834 | } |
---|
14476 | | - if ((modifiers & COMMAND) == COMMAND) |
---|
| 14835 | + if ((modifiersex & COMMAND) == COMMAND) |
---|
14477 | 14836 | { |
---|
14478 | 14837 | mouseMode |= SELECT; |
---|
14479 | 14838 | } |
---|
14480 | | - if ((modifiers & SHIFT) == SHIFT || forcetranslate) |
---|
| 14839 | + if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
14481 | 14840 | { |
---|
14482 | 14841 | mouseMode &= ~VR; |
---|
14483 | 14842 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
14506 | 14865 | |
---|
14507 | 14866 | if (isRenderer) // |
---|
14508 | 14867 | { |
---|
14509 | | - SetMouseMode(modifiers); |
---|
| 14868 | + SetMouseMode(0, modifiers); |
---|
14510 | 14869 | } |
---|
14511 | 14870 | |
---|
14512 | 14871 | Globals.theRenderer.keyPressed(key); |
---|
.. | .. |
---|
14653 | 15012 | case 'E' : COMPACT ^= true; |
---|
14654 | 15013 | repaint(); |
---|
14655 | 15014 | break; |
---|
14656 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15015 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15016 | + //DEBUGHSB ^= true; |
---|
| 15017 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14657 | 15018 | repaint(); |
---|
14658 | 15019 | break; |
---|
14659 | 15020 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14678 | 15039 | RevertCamera(); |
---|
14679 | 15040 | repaint(); |
---|
14680 | 15041 | break; |
---|
14681 | | - case 'L': |
---|
14682 | 15042 | case 'l': |
---|
| 15043 | + //case 'L': |
---|
14683 | 15044 | if (lightMode) |
---|
14684 | 15045 | { |
---|
14685 | 15046 | lightMode = false; |
---|
.. | .. |
---|
14822 | 15183 | case '_': |
---|
14823 | 15184 | kompactbit = 5; |
---|
14824 | 15185 | break; |
---|
14825 | | - case '+': |
---|
14826 | | - kompactbit = 6; |
---|
14827 | | - break; |
---|
| 15186 | +// case '+': |
---|
| 15187 | +// kompactbit = 6; |
---|
| 15188 | +// break; |
---|
14828 | 15189 | case ' ': |
---|
14829 | 15190 | lightMode ^= true; |
---|
14830 | 15191 | Globals.lighttouched = true; |
---|
.. | .. |
---|
14836 | 15197 | case ESC: |
---|
14837 | 15198 | RENDERPROGRAM += 1; |
---|
14838 | 15199 | RENDERPROGRAM %= 3; |
---|
| 15200 | + |
---|
14839 | 15201 | repaint(); |
---|
14840 | 15202 | break; |
---|
14841 | 15203 | case 'Z': |
---|
14842 | 15204 | //RESIZETEXTURE ^= true; |
---|
14843 | 15205 | //break; |
---|
14844 | 15206 | case 'z': |
---|
14845 | | - RENDERSHADOW ^= true; |
---|
| 15207 | + Globals.RENDERSHADOW ^= true; |
---|
14846 | 15208 | Globals.lighttouched = true; |
---|
14847 | 15209 | repaint(); |
---|
14848 | 15210 | break; |
---|
.. | .. |
---|
14875 | 15237 | case DELETE: |
---|
14876 | 15238 | ClearSelection(); |
---|
14877 | 15239 | break; |
---|
14878 | | - /* |
---|
14879 | 15240 | case '+': |
---|
| 15241 | + |
---|
| 15242 | + /* |
---|
14880 | 15243 | //fontsize += 1; |
---|
14881 | 15244 | bbzoom *= 2; |
---|
14882 | 15245 | repaint(); |
---|
.. | .. |
---|
14893 | 15256 | case '=': |
---|
14894 | 15257 | IncDepth(); |
---|
14895 | 15258 | //fontsize += 1; |
---|
14896 | | - object.editWindow.refreshContents(true); |
---|
| 15259 | + object.GetWindow().refreshContents(true); |
---|
14897 | 15260 | maskbit = 6; |
---|
14898 | 15261 | break; |
---|
14899 | 15262 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
14900 | 15263 | DecDepth(); |
---|
14901 | 15264 | maskbit = 5; |
---|
14902 | 15265 | //if(fontsize > 1) fontsize -= 1; |
---|
14903 | | - if (object.editWindow == null) |
---|
14904 | | - new Exception().printStackTrace(); |
---|
14905 | | - else |
---|
14906 | | - object.editWindow.refreshContents(true); |
---|
| 15266 | +// if (object.editWindow == null) |
---|
| 15267 | +// new Exception().printStackTrace(); |
---|
| 15268 | +// else |
---|
| 15269 | + object.GetWindow().refreshContents(true); |
---|
14907 | 15270 | break; |
---|
14908 | 15271 | case '{': |
---|
14909 | 15272 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
14966 | 15329 | //mode = ROTATE; |
---|
14967 | 15330 | if ((MODIFIERS & COMMAND) == 0) // VR?? |
---|
14968 | 15331 | { |
---|
14969 | | - SetMouseMode(modifiers); |
---|
| 15332 | + SetMouseMode(0, modifiers); |
---|
14970 | 15333 | } |
---|
14971 | 15334 | } |
---|
14972 | 15335 | |
---|
.. | .. |
---|
15100 | 15463 | |
---|
15101 | 15464 | protected void processMouseMotionEvent(MouseEvent e) |
---|
15102 | 15465 | { |
---|
15103 | | - //System.out.println("processMouseMotionEvent: " + mouseMode); |
---|
15104 | | - if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15466 | + //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton()); |
---|
| 15467 | + //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0) |
---|
| 15468 | + if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0) |
---|
15105 | 15469 | { |
---|
15106 | 15470 | mouseMoved(e); |
---|
15107 | 15471 | } else |
---|
.. | .. |
---|
15126 | 15490 | } |
---|
15127 | 15491 | */ |
---|
15128 | 15492 | |
---|
15129 | | - object.editWindow.EditSelection(); |
---|
| 15493 | + object.GetWindow().EditSelection(false); |
---|
15130 | 15494 | } |
---|
15131 | 15495 | |
---|
15132 | 15496 | void SelectParent() |
---|
15133 | 15497 | { |
---|
| 15498 | + new Exception().printStackTrace(); |
---|
15134 | 15499 | System.exit(0); |
---|
15135 | 15500 | Composite group = (Composite) object; |
---|
15136 | 15501 | java.util.Vector selectees = new java.util.Vector(group.selection); |
---|
.. | .. |
---|
15142 | 15507 | { |
---|
15143 | 15508 | //selectees.remove(i); |
---|
15144 | 15509 | System.out.println("select parent of " + elem); |
---|
15145 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15510 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15146 | 15511 | } else |
---|
15147 | 15512 | { |
---|
15148 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15513 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15149 | 15514 | } |
---|
15150 | 15515 | |
---|
15151 | 15516 | first = false; |
---|
.. | .. |
---|
15154 | 15519 | |
---|
15155 | 15520 | void SelectChildren() |
---|
15156 | 15521 | { |
---|
| 15522 | + new Exception().printStackTrace(); |
---|
15157 | 15523 | System.exit(0); |
---|
15158 | 15524 | /* |
---|
15159 | 15525 | Composite group = (Composite) object; |
---|
.. | .. |
---|
15186 | 15552 | for (int j = 0; j < group.children.size(); j++) |
---|
15187 | 15553 | { |
---|
15188 | 15554 | elem = (Object3D) group.children.elementAt(j); |
---|
15189 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15555 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15190 | 15556 | first = false; |
---|
15191 | 15557 | } |
---|
15192 | 15558 | } else |
---|
15193 | 15559 | { |
---|
15194 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15560 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15195 | 15561 | } |
---|
15196 | 15562 | |
---|
15197 | 15563 | first = false; |
---|
.. | .. |
---|
15202 | 15568 | { |
---|
15203 | 15569 | //Composite group = (Composite) object; |
---|
15204 | 15570 | Object3D group = object; |
---|
15205 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15571 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15206 | 15572 | } |
---|
15207 | 15573 | |
---|
15208 | 15574 | void ResetTransform(int mask) |
---|
15209 | 15575 | { |
---|
15210 | 15576 | //Composite group = (Composite) object; |
---|
15211 | 15577 | Object3D group = object; |
---|
15212 | | - group.editWindow.ResetTransform(mask); |
---|
| 15578 | + group.GetWindow().ResetTransform(mask); |
---|
15213 | 15579 | } |
---|
15214 | 15580 | |
---|
15215 | 15581 | void FlipTransform() |
---|
15216 | 15582 | { |
---|
15217 | 15583 | //Composite group = (Composite) object; |
---|
15218 | 15584 | Object3D group = object; |
---|
15219 | | - group.editWindow.FlipTransform(); |
---|
| 15585 | + group.GetWindow().FlipTransform(); |
---|
15220 | 15586 | // group.editWindow.ReduceMesh(true); |
---|
15221 | 15587 | } |
---|
15222 | 15588 | |
---|
.. | .. |
---|
15224 | 15590 | { |
---|
15225 | 15591 | //Composite group = (Composite) object; |
---|
15226 | 15592 | Object3D group = object; |
---|
15227 | | - group.editWindow.PrintMemory(); |
---|
| 15593 | + group.GetWindow().PrintMemory(); |
---|
15228 | 15594 | // group.editWindow.ReduceMesh(true); |
---|
15229 | 15595 | } |
---|
15230 | 15596 | |
---|
.. | .. |
---|
15232 | 15598 | { |
---|
15233 | 15599 | //Composite group = (Composite) object; |
---|
15234 | 15600 | Object3D group = object; |
---|
15235 | | - group.editWindow.ResetCentroid(); |
---|
| 15601 | + group.GetWindow().ResetCentroid(); |
---|
15236 | 15602 | } |
---|
15237 | 15603 | |
---|
15238 | 15604 | void IncDepth() |
---|
.. | .. |
---|
15318 | 15684 | info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15319 | 15685 | //Image img = CreateImage(width, height); |
---|
15320 | 15686 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
| 15687 | + |
---|
15321 | 15688 | Graphics gr = g; // img.getGraphics(); |
---|
| 15689 | + |
---|
15322 | 15690 | if (!hasMarquee) |
---|
15323 | 15691 | { |
---|
15324 | 15692 | if (Xmin < Xmax) // !locked) |
---|
.. | .. |
---|
15406 | 15774 | info.bounds.y += (height - desired) / 2; |
---|
15407 | 15775 | } |
---|
15408 | 15776 | } |
---|
| 15777 | + |
---|
15409 | 15778 | info.g = gr; |
---|
15410 | 15779 | info.camera = renderCamera; |
---|
15411 | 15780 | /* |
---|
.. | .. |
---|
15415 | 15784 | */ |
---|
15416 | 15785 | if (!isRenderer) |
---|
15417 | 15786 | { |
---|
15418 | | - object.drawEditHandles(info, 0); |
---|
| 15787 | + Grafreed.Assert(object != null); |
---|
| 15788 | + Grafreed.Assert(object.selection != null); |
---|
| 15789 | + if (object.selection.Size() > 0) |
---|
| 15790 | + { |
---|
| 15791 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15792 | + |
---|
| 15793 | + info.DX = 0; |
---|
| 15794 | + info.DY = 0; |
---|
| 15795 | + info.W = 1; |
---|
| 15796 | + if (hitSomething == Object3D.hitCenter) |
---|
| 15797 | + { |
---|
| 15798 | + info.DX = X; |
---|
| 15799 | + if (X != 0) |
---|
| 15800 | + info.DX -= info.bounds.width/2; |
---|
| 15801 | + |
---|
| 15802 | + info.DY = Y; |
---|
| 15803 | + if (Y != 0) |
---|
| 15804 | + info.DY -= info.bounds.height/2; |
---|
| 15805 | + } |
---|
| 15806 | + |
---|
| 15807 | + object.drawEditHandles(info, 0); |
---|
| 15808 | + |
---|
| 15809 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15810 | + { |
---|
| 15811 | + switch (hitSomething) |
---|
| 15812 | + { |
---|
| 15813 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15814 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15815 | + break; |
---|
| 15816 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15817 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15818 | + break; |
---|
| 15819 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15820 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15821 | + break; |
---|
| 15822 | + } |
---|
| 15823 | + |
---|
| 15824 | + } |
---|
| 15825 | + } |
---|
15419 | 15826 | } |
---|
15420 | 15827 | } |
---|
| 15828 | + |
---|
15421 | 15829 | if (isRenderer) |
---|
15422 | 15830 | { |
---|
15423 | 15831 | //gr.setColor(Color.black); |
---|
15424 | 15832 | //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1); |
---|
15425 | 15833 | //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3); |
---|
15426 | 15834 | } |
---|
| 15835 | + |
---|
15427 | 15836 | if (hasMarquee) |
---|
15428 | 15837 | { |
---|
15429 | 15838 | gr.setXORMode(Color.white); |
---|
.. | .. |
---|
15536 | 15945 | public boolean mouseDown(Event evt, int x, int y) |
---|
15537 | 15946 | { |
---|
15538 | 15947 | System.out.println("mouseDown: " + evt); |
---|
| 15948 | + System.exit(0); |
---|
15539 | 15949 | /* |
---|
15540 | 15950 | locked = true; |
---|
15541 | 15951 | drag = false; |
---|
.. | .. |
---|
15579 | 15989 | { |
---|
15580 | 15990 | keyPressed(0, modifiers); |
---|
15581 | 15991 | } |
---|
15582 | | - clickStart(x, y, modifiers); |
---|
| 15992 | + // clickStart(x, y, modifiers); |
---|
15583 | 15993 | return true; |
---|
15584 | 15994 | } |
---|
15585 | 15995 | |
---|
.. | .. |
---|
15697 | 16107 | { |
---|
15698 | 16108 | keyReleased(0, 0); |
---|
15699 | 16109 | } |
---|
15700 | | - drag(x, y, modifiers); |
---|
| 16110 | + drag(x, y, 0, modifiers); |
---|
15701 | 16111 | return true; |
---|
15702 | 16112 | } |
---|
15703 | 16113 | |
---|
.. | .. |
---|
15829 | 16239 | Object3D object; |
---|
15830 | 16240 | static Object3D trackedobject; |
---|
15831 | 16241 | Camera renderCamera; // Light or Eye (or Occlusion) |
---|
15832 | | - /*static*/ Camera manipCamera; // Light or Eye |
---|
| 16242 | + /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light |
---|
15833 | 16243 | /*static*/ Camera eyeCamera; |
---|
15834 | 16244 | /*static*/ Camera lightCamera; |
---|
15835 | 16245 | int cameracount; |
---|
.. | .. |
---|
16114 | 16524 | cStatic.objectstack[materialdepth++] = checker; |
---|
16115 | 16525 | //System.out.println("material " + material); |
---|
16116 | 16526 | //Applet3D.tracein(this, selected); |
---|
16117 | | - vector2buffer = checker.projectedVertices; |
---|
| 16527 | + //vector2buffer = checker.projectedVertices; |
---|
16118 | 16528 | |
---|
16119 | 16529 | //checker.GetMaterial().Draw(this, false); // true); |
---|
16120 | | - DrawMaterial(checker.GetMaterial(), false); // true); |
---|
| 16530 | + DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true); |
---|
16121 | 16531 | |
---|
16122 | 16532 | materialdepth -= 1; |
---|
16123 | 16533 | if (materialdepth > 0) |
---|
16124 | 16534 | { |
---|
16125 | | - vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
16126 | | - DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]); |
---|
| 16535 | + //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices; |
---|
| 16536 | + DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices); |
---|
16127 | 16537 | } |
---|
16128 | 16538 | //checker.GetMaterial().opacity = 1f; |
---|
16129 | 16539 | ////checker.GetMaterial().ambient = 1f; |
---|
.. | .. |
---|
16209 | 16619 | } |
---|
16210 | 16620 | } |
---|
16211 | 16621 | |
---|
| 16622 | + private Object3D GetFolder() |
---|
| 16623 | + { |
---|
| 16624 | + Object3D folder = object.GetWindow().copy; |
---|
| 16625 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16626 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16627 | + return folder; |
---|
| 16628 | + } |
---|
| 16629 | + |
---|
16212 | 16630 | class SelectBuffer implements GLEventListener |
---|
16213 | 16631 | { |
---|
16214 | 16632 | |
---|
.. | .. |
---|
16267 | 16685 | { |
---|
16268 | 16686 | if (!selection) |
---|
16269 | 16687 | { |
---|
| 16688 | + new Exception().printStackTrace(); |
---|
16270 | 16689 | System.exit(0); |
---|
16271 | 16690 | return; |
---|
16272 | 16691 | } |
---|
.. | .. |
---|
16287 | 16706 | |
---|
16288 | 16707 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16289 | 16708 | |
---|
| 16709 | + if (PAINTMODE) |
---|
| 16710 | + { |
---|
| 16711 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16712 | + { |
---|
| 16713 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16714 | + |
---|
| 16715 | + // Make what you paint not selectable. |
---|
| 16716 | + paintobj.ResetSelectable(); |
---|
| 16717 | + } |
---|
| 16718 | + } |
---|
| 16719 | + |
---|
16290 | 16720 | //int tmp = selection_view; |
---|
16291 | 16721 | //selection_view = -1; |
---|
16292 | 16722 | int temp = DrawMode(); |
---|
.. | .. |
---|
16298 | 16728 | // temp = DEFAULT; // patch for selection debug |
---|
16299 | 16729 | Globals.drawMode = temp; // WARNING |
---|
16300 | 16730 | |
---|
| 16731 | + if (PAINTMODE) |
---|
| 16732 | + { |
---|
| 16733 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16734 | + { |
---|
| 16735 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16736 | + |
---|
| 16737 | + // Revert. |
---|
| 16738 | + paintobj.RestoreSelectable(); |
---|
| 16739 | + } |
---|
| 16740 | + } |
---|
| 16741 | + |
---|
16301 | 16742 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16302 | 16743 | |
---|
16303 | 16744 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16345 | 16786 | // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]); |
---|
16346 | 16787 | // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]); |
---|
16347 | 16788 | // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]); |
---|
| 16789 | + |
---|
| 16790 | + CreateSelectedPoint(); |
---|
16348 | 16791 | |
---|
16349 | 16792 | // Will fit the mesh !!! |
---|
16350 | 16793 | selectedpoint.toParent[0][0] = 0.0001; |
---|
.. | .. |
---|
16394 | 16837 | 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 | 16838 | } |
---|
16396 | 16839 | |
---|
16397 | | - previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint); |
---|
| 16840 | + previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint); |
---|
16398 | 16841 | } |
---|
16399 | 16842 | } |
---|
16400 | 16843 | |
---|
16401 | 16844 | if (!movingcamera && !PAINTMODE) |
---|
16402 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16845 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16403 | 16846 | |
---|
16404 | | - if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16847 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16405 | 16848 | { |
---|
16406 | | - Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16849 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16407 | 16850 | |
---|
16408 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16851 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16852 | + { |
---|
| 16853 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16409 | 16854 | |
---|
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(); |
---|
| 16855 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16856 | + |
---|
| 16857 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16858 | + |
---|
| 16859 | + inst.add(paintobj); // link |
---|
| 16860 | + |
---|
| 16861 | + object.GetWindow().SnapObject(inst); |
---|
| 16862 | + |
---|
| 16863 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16864 | + |
---|
| 16865 | + folder.add(inst); |
---|
| 16866 | + |
---|
| 16867 | + object.GetWindow().ResetModel(); |
---|
| 16868 | + object.GetWindow().refreshContents(); |
---|
| 16869 | + } |
---|
16425 | 16870 | } |
---|
16426 | 16871 | else |
---|
16427 | 16872 | paintcount = 0; |
---|
.. | .. |
---|
16460 | 16905 | //System.out.println("objects[color] = " + objects[color]); |
---|
16461 | 16906 | //objects[color].Select(); |
---|
16462 | 16907 | indexcount = 0; |
---|
| 16908 | + ObjEditor window = object.GetWindow(); |
---|
| 16909 | + if (window != null && deselect) |
---|
| 16910 | + { |
---|
| 16911 | + window.Select(null, deselect, true); |
---|
| 16912 | + } |
---|
16463 | 16913 | object.Select(color, deselect); |
---|
16464 | 16914 | } |
---|
16465 | 16915 | |
---|
.. | .. |
---|
16559 | 17009 | gl.glDisable(gl.GL_CULL_FACE); |
---|
16560 | 17010 | } |
---|
16561 | 17011 | |
---|
16562 | | - if (!RENDERSHADOW) |
---|
| 17012 | + if (!Globals.RENDERSHADOW) |
---|
16563 | 17013 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16564 | 17014 | |
---|
16565 | 17015 | // SB gl.glPolygonOffset(2.5f, 10); |
---|
.. | .. |
---|
16569 | 17019 | //gl.glColorMask(false, false, false, false); |
---|
16570 | 17020 | |
---|
16571 | 17021 | //render_scene_from_light_view(gl, drawable, 0, 0); |
---|
16572 | | - if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed()) |
---|
| 17022 | + if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed()) |
---|
16573 | 17023 | { |
---|
16574 | 17024 | gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT); |
---|
16575 | 17025 | |
---|
.. | .. |
---|
16985 | 17435 | int AAbuffersize = 0; |
---|
16986 | 17436 | |
---|
16987 | 17437 | //double[] selectedpoint = new double[3]; |
---|
16988 | | - static Superellipsoid selectedpoint = new Superellipsoid(); |
---|
| 17438 | + static Superellipsoid selectedpoint; |
---|
16989 | 17439 | 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(); |
---|
| 17440 | + static Sphere debugpointG; |
---|
| 17441 | + static Sphere debugpointP; |
---|
| 17442 | + static Sphere debugpointC; |
---|
| 17443 | + static Sphere debugpointR; |
---|
16994 | 17444 | |
---|
16995 | 17445 | static Sphere debugpoints[] = new Sphere[8]; |
---|
16996 | 17446 | |
---|
16997 | | - static |
---|
16998 | | - { |
---|
16999 | | - for (int i=0; i<8; i++) |
---|
17000 | | - { |
---|
17001 | | - debugpoints[i] = new Sphere(); |
---|
17002 | | - } |
---|
17003 | | - } |
---|
17004 | | - |
---|
17005 | 17447 | static void InitPoints(float radius) |
---|
17006 | 17448 | { |
---|
17007 | 17449 | for (int i=0; i<8; i++) |
---|