.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
44 | 48 | static boolean ABORTED = false; |
---|
45 | 49 | |
---|
46 | 50 | static int STEP = 1; |
---|
| 51 | + |
---|
| 52 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 53 | + { |
---|
| 54 | + int[] pixels = new int[bytes.length/3]; |
---|
| 55 | + for (int i=pixels.length; --i>=0;) |
---|
| 56 | + { |
---|
| 57 | + int i3 = i*3; |
---|
| 58 | + pixels[i] = 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 61 | + pixels[i] <<= 8; |
---|
| 62 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 63 | + pixels[i] <<= 8; |
---|
| 64 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 65 | + } |
---|
| 66 | + /* |
---|
| 67 | + int r=0,g=0,b=0,a=0; |
---|
| 68 | + for (int i=0; i<width; i++) |
---|
| 69 | + for (int j=0; j<height; j++) |
---|
| 70 | + { |
---|
| 71 | + int index = j*width+i; |
---|
| 72 | + int p = pixels[index]; |
---|
| 73 | + a = ((p>>24) & 0xFF); |
---|
| 74 | + r = ((p>>16) & 0xFF); |
---|
| 75 | + g = ((p>>8) & 0xFF); |
---|
| 76 | + b = (p & 0xFF); |
---|
| 77 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 78 | + } |
---|
| 79 | + /**/ |
---|
| 80 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 81 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 82 | + return rendImage; |
---|
| 83 | + } |
---|
47 | 84 | |
---|
48 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
60 | 97 | //boolean REDUCETEXTURE = true; |
---|
61 | 98 | boolean CACHETEXTURE = true; |
---|
62 | 99 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
64 | 101 | boolean COMPRESSTEXTURE = false; |
---|
65 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
150 | 187 | } |
---|
151 | 188 | |
---|
152 | 189 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
| 191 | + public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 192 | + { |
---|
| 193 | + try |
---|
| 194 | + { |
---|
| 195 | + cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 196 | + } catch (IOException e) |
---|
| 197 | + { |
---|
| 198 | + System.out.println("NAME = " + name); |
---|
| 199 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 200 | + } |
---|
| 201 | + } |
---|
153 | 202 | |
---|
154 | 203 | void SetAsGLRenderer(boolean b) |
---|
155 | 204 | { |
---|
.. | .. |
---|
169 | 218 | |
---|
170 | 219 | SetCamera(cam); |
---|
171 | 220 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 221 | + // Warning: not used. |
---|
| 222 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 223 | |
---|
174 | 224 | object = o; |
---|
175 | 225 | |
---|
.. | .. |
---|
335 | 385 | display.options1[2] = material.shadowbias; |
---|
336 | 386 | display.options1[3] = material.aniso; |
---|
337 | 387 | display.options1[4] = material.anisoV; |
---|
| 388 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 389 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 390 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 391 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 392 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
338 | 393 | display.options2[0] = material.opacity; |
---|
339 | 394 | display.options2[1] = material.diffuse; |
---|
340 | 395 | display.options2[2] = material.factor; |
---|
| 396 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 397 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 398 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
341 | 399 | |
---|
342 | 400 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 401 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 402 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 403 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
343 | 404 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 405 | display.options4[1] = material.subsurface; |
---|
345 | 406 | display.options4[2] = material.sheen; |
---|
| 407 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 408 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 409 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
346 | 410 | |
---|
347 | 411 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 412 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
1433 | 1497 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1434 | 1498 | } |
---|
1435 | 1499 | |
---|
| 1500 | + float[] colorV = new float[4]; |
---|
| 1501 | + |
---|
1436 | 1502 | void SetColor(Object3D obj, Vertex p0) |
---|
1437 | 1503 | { |
---|
1438 | 1504 | CameraPane display = this; |
---|
.. | .. |
---|
1500 | 1566 | { |
---|
1501 | 1567 | return; |
---|
1502 | 1568 | } |
---|
1503 | | - |
---|
1504 | | - float[] colorV = new float[3]; |
---|
1505 | 1569 | |
---|
1506 | 1570 | if (false) // marked) |
---|
1507 | 1571 | { |
---|
.. | .. |
---|
2051 | 2115 | //System.err.println("Oeil on"); |
---|
2052 | 2116 | OEIL = true; |
---|
2053 | 2117 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2118 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2119 | //pingthread.StepToTarget(true); |
---|
2056 | 2120 | } |
---|
2057 | 2121 | |
---|
.. | .. |
---|
2284 | 2348 | HANDLES ^= true; |
---|
2285 | 2349 | } |
---|
2286 | 2350 | |
---|
| 2351 | + Object3D paintFolder; |
---|
| 2352 | + |
---|
2287 | 2353 | void TogglePaint() |
---|
2288 | 2354 | { |
---|
2289 | 2355 | PAINTMODE ^= true; |
---|
2290 | 2356 | paintcount = 0; |
---|
| 2357 | + |
---|
| 2358 | + if (PAINTMODE) |
---|
| 2359 | + { |
---|
| 2360 | + paintFolder = GetFolder(); |
---|
| 2361 | + } |
---|
2291 | 2362 | } |
---|
2292 | 2363 | |
---|
2293 | 2364 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2384 | 2455 | return currentGL; |
---|
2385 | 2456 | } |
---|
2386 | 2457 | |
---|
| 2458 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2459 | + { |
---|
| 2460 | + Grafreed.Assert(texturedata != null); |
---|
| 2461 | + |
---|
| 2462 | + int width = texturedata.getWidth(); |
---|
| 2463 | + int height = texturedata.getHeight(); |
---|
| 2464 | + |
---|
| 2465 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2466 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2467 | + |
---|
| 2468 | + byte[] bytes = bytebuf.array(); |
---|
| 2469 | + |
---|
| 2470 | + return CreateBim(bytes, width, height); |
---|
| 2471 | + } |
---|
| 2472 | + |
---|
2387 | 2473 | /**/ |
---|
2388 | 2474 | class CacheTexture |
---|
2389 | 2475 | { |
---|
.. | .. |
---|
2392 | 2478 | |
---|
2393 | 2479 | int resolution; |
---|
2394 | 2480 | |
---|
2395 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2481 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2396 | 2482 | { |
---|
2397 | | - texture = tex; |
---|
| 2483 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2484 | + texturedata = texdata; |
---|
2398 | 2485 | resolution = res; |
---|
2399 | 2486 | } |
---|
2400 | 2487 | } |
---|
2401 | 2488 | /**/ |
---|
2402 | 2489 | |
---|
2403 | 2490 | // TEXTURE static Texture texture; |
---|
2404 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2405 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2406 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2491 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2492 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2493 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2494 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2495 | + |
---|
2407 | 2496 | int pigmentdepth = 0; |
---|
2408 | 2497 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2498 | int bumpdepth = 0; |
---|
2410 | 2499 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2411 | 2500 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2412 | 2501 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2413 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2502 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2414 | 2503 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2415 | 2504 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2505 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2417 | 2506 | { |
---|
2418 | 2507 | TextureData texturedata = null; |
---|
2419 | 2508 | |
---|
.. | .. |
---|
2432 | 2521 | if (bump) |
---|
2433 | 2522 | texturedata = ConvertBump(texturedata, false); |
---|
2434 | 2523 | |
---|
2435 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2436 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2524 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2525 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2437 | 2526 | |
---|
2438 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2439 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2527 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2528 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2440 | 2529 | |
---|
2441 | | - return texture; |
---|
| 2530 | + return texturedata; |
---|
| 2531 | + } |
---|
| 2532 | + |
---|
| 2533 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2534 | + { |
---|
| 2535 | + TextureData texturedata = null; |
---|
| 2536 | + |
---|
| 2537 | + try |
---|
| 2538 | + { |
---|
| 2539 | + texturedata = |
---|
| 2540 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2541 | + bim, |
---|
| 2542 | + true); |
---|
| 2543 | + } catch (Exception e) |
---|
| 2544 | + { |
---|
| 2545 | + throw new javax.media.opengl.GLException(e); |
---|
| 2546 | + } |
---|
| 2547 | + |
---|
| 2548 | + if (bump) |
---|
| 2549 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2550 | + |
---|
| 2551 | + return texturedata; |
---|
2442 | 2552 | } |
---|
2443 | 2553 | |
---|
2444 | 2554 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3511 | 3621 | |
---|
3512 | 3622 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3623 | |
---|
| 3624 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3625 | + |
---|
3514 | 3626 | // |
---|
3515 | 3627 | if (false) // compressbit > 0) |
---|
3516 | 3628 | { |
---|
.. | .. |
---|
7909 | 8021 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8022 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8023 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8024 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8025 | { |
---|
7914 | 8026 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8027 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7924 | 8036 | pigment = null; |
---|
7925 | 8037 | } |
---|
7926 | 8038 | |
---|
7927 | | - ReleaseTexture(bump, true); |
---|
7928 | | - ReleaseTexture(pigment, false); |
---|
| 8039 | + ReleaseTexture(tex, true); |
---|
| 8040 | + ReleaseTexture(tex, false); |
---|
7929 | 8041 | } |
---|
7930 | 8042 | |
---|
7931 | 8043 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7943 | 8055 | |
---|
7944 | 8056 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8057 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8058 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8059 | { |
---|
7948 | 8060 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8061 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7954 | 8066 | pigment = null; |
---|
7955 | 8067 | } |
---|
7956 | 8068 | |
---|
7957 | | - ReleaseTexture(pigment, false); |
---|
| 8069 | + ReleaseTexture(tex, false); |
---|
7958 | 8070 | } |
---|
7959 | 8071 | |
---|
7960 | 8072 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7972 | 8084 | |
---|
7973 | 8085 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8086 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8087 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8088 | { |
---|
7977 | 8089 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8090 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7983 | 8095 | bump = null; |
---|
7984 | 8096 | } |
---|
7985 | 8097 | |
---|
7986 | | - ReleaseTexture(bump, true); |
---|
| 8098 | + ReleaseTexture(tex, true); |
---|
7987 | 8099 | } |
---|
7988 | 8100 | |
---|
7989 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8101 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7990 | 8102 | { |
---|
7991 | 8103 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7992 | 8104 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7997 | 8109 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7998 | 8110 | |
---|
7999 | 8111 | if (tex != null) |
---|
8000 | | - texture = textures.get(tex); |
---|
| 8112 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8001 | 8113 | |
---|
8002 | 8114 | // //assert( texture != null ); |
---|
8003 | 8115 | // if (texture == null) |
---|
.. | .. |
---|
8091 | 8203 | |
---|
8092 | 8204 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8205 | { |
---|
8094 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8095 | | - ambientOcclusion ) // || !textureon) |
---|
8096 | | - { |
---|
8097 | | - return; // false; |
---|
8098 | | - } |
---|
8099 | | - |
---|
8100 | | - if (tex == null) |
---|
8101 | | - { |
---|
8102 | | - BindTexture(null,false,resolution); |
---|
8103 | | - BindTexture(null,true,resolution); |
---|
8104 | | - return; |
---|
8105 | | - } |
---|
| 8206 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8207 | +// ambientOcclusion ) // || !textureon) |
---|
| 8208 | +// { |
---|
| 8209 | +// return; // false; |
---|
| 8210 | +// } |
---|
| 8211 | +// |
---|
| 8212 | +// if (tex == null) |
---|
| 8213 | +// { |
---|
| 8214 | +// BindTexture(null,false,resolution); |
---|
| 8215 | +// BindTexture(null,true,resolution); |
---|
| 8216 | +// return; |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8220 | +// String bump = Object3D.GetBump(tex); |
---|
| 8221 | +// |
---|
| 8222 | +// usedtextures.add(pigment); |
---|
| 8223 | +// usedtextures.add(bump); |
---|
| 8224 | +// |
---|
| 8225 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8226 | +// { |
---|
| 8227 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8228 | +// // System.out.println("; bump = " + bump); |
---|
| 8229 | +// } |
---|
| 8230 | +// |
---|
| 8231 | +// if (bump.equals("")) |
---|
| 8232 | +// { |
---|
| 8233 | +// bump = null; |
---|
| 8234 | +// } |
---|
| 8235 | +// if (pigment.equals("")) |
---|
| 8236 | +// { |
---|
| 8237 | +// pigment = null; |
---|
| 8238 | +// } |
---|
| 8239 | +// |
---|
| 8240 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8241 | +// BindTexture(pigment, false, resolution); |
---|
| 8242 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8243 | +// BindTexture(bump, true, resolution); |
---|
| 8244 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8245 | +// |
---|
| 8246 | +// return; // true; |
---|
8106 | 8247 | |
---|
8107 | | - String pigment = Object3D.GetPigment(tex); |
---|
8108 | | - String bump = Object3D.GetBump(tex); |
---|
8109 | | - |
---|
8110 | | - usedtextures.put(pigment, pigment); |
---|
8111 | | - usedtextures.put(bump, bump); |
---|
8112 | | - |
---|
8113 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8114 | | - { |
---|
8115 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8116 | | - // System.out.println("; bump = " + bump); |
---|
8117 | | - } |
---|
8118 | | - |
---|
8119 | | - if (bump.equals("")) |
---|
8120 | | - { |
---|
8121 | | - bump = null; |
---|
8122 | | - } |
---|
8123 | | - if (pigment.equals("")) |
---|
8124 | | - { |
---|
8125 | | - pigment = null; |
---|
8126 | | - } |
---|
8127 | | - |
---|
8128 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8129 | | - BindTexture(pigment, false, resolution); |
---|
8130 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8131 | | - BindTexture(bump, true, resolution); |
---|
8132 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8133 | | - |
---|
8134 | | - return; // true; |
---|
| 8248 | + BindPigmentTexture(tex, resolution); |
---|
| 8249 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8250 | } |
---|
8136 | 8251 | |
---|
8137 | 8252 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8150 | 8265 | |
---|
8151 | 8266 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8267 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8268 | + usedtextures.add(tex); |
---|
8154 | 8269 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8270 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8271 | { |
---|
8157 | 8272 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8273 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8279 | } |
---|
8165 | 8280 | |
---|
8166 | 8281 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8282 | + BindTexture(tex, false, resolution); |
---|
8168 | 8283 | } |
---|
8169 | 8284 | |
---|
8170 | 8285 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8183 | 8298 | |
---|
8184 | 8299 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8300 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8301 | + usedtextures.add(tex); |
---|
8187 | 8302 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8303 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8304 | { |
---|
8190 | 8305 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8306 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8312 | } |
---|
8198 | 8313 | |
---|
8199 | 8314 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8315 | + BindTexture(tex, true, resolution); |
---|
8201 | 8316 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8317 | } |
---|
8203 | 8318 | |
---|
.. | .. |
---|
8221 | 8336 | return fileExists; |
---|
8222 | 8337 | } |
---|
8223 | 8338 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8339 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8340 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8341 | + CacheTexture texturecache = null; |
---|
8227 | 8342 | |
---|
8228 | 8343 | if (tex != null) |
---|
8229 | 8344 | { |
---|
8230 | | - String texname = tex; |
---|
| 8345 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8346 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8347 | + |
---|
| 8348 | + if (texname.equals("") && texdata == null) |
---|
| 8349 | + { |
---|
| 8350 | + return null; |
---|
| 8351 | + } |
---|
8231 | 8352 | |
---|
8232 | 8353 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8233 | 8354 | |
---|
.. | .. |
---|
8237 | 8358 | // else |
---|
8238 | 8359 | // if (!texname.startsWith("/")) |
---|
8239 | 8360 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8240 | | - if (!FileExists(tex)) |
---|
| 8361 | + if (!FileExists(texname)) |
---|
8241 | 8362 | { |
---|
8242 | 8363 | texname = fallbackTextureName; |
---|
8243 | 8364 | } |
---|
8244 | 8365 | |
---|
8245 | 8366 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8367 | { |
---|
8252 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8368 | + if (texdata == null) |
---|
| 8369 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8370 | + else |
---|
| 8371 | + texturecache = bimtextures.get(texdata); |
---|
| 8372 | + } |
---|
| 8373 | + |
---|
| 8374 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8375 | + { |
---|
| 8376 | + TextureData texturedata = null; |
---|
| 8377 | + |
---|
| 8378 | + if (texdata != null && textureon) |
---|
| 8379 | + { |
---|
| 8380 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8381 | + |
---|
| 8382 | + try |
---|
| 8383 | + { |
---|
| 8384 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8385 | + } |
---|
| 8386 | + catch (Exception e) |
---|
| 8387 | + { |
---|
| 8388 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8389 | + } |
---|
| 8390 | + |
---|
| 8391 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8392 | + bimtextures.put(texdata, texturecache); |
---|
| 8393 | + |
---|
| 8394 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8395 | + |
---|
| 8396 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8397 | + //bim2 = bim; |
---|
| 8398 | + } |
---|
| 8399 | + else |
---|
| 8400 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8253 | 8401 | { |
---|
8254 | 8402 | assert(!bump); |
---|
8255 | 8403 | // if (bump) |
---|
.. | .. |
---|
8260 | 8408 | // } |
---|
8261 | 8409 | // else |
---|
8262 | 8410 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
8265 | 8413 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8415 | } |
---|
| 8416 | + else |
---|
| 8417 | + new Exception().printStackTrace(); |
---|
8268 | 8418 | // } |
---|
8269 | 8419 | } else |
---|
8270 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8420 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8421 | { |
---|
8272 | 8422 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8423 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8424 | + if (texturecache == null) |
---|
| 8425 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8426 | + else |
---|
| 8427 | + new Exception().printStackTrace(); |
---|
8276 | 8428 | } else |
---|
8277 | 8429 | { |
---|
8278 | 8430 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8280 | 8432 | // texture = GetResourceTexture("default.png"); |
---|
8281 | 8433 | //} else |
---|
8282 | 8434 | //{ |
---|
8283 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8435 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8284 | 8436 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8437 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8438 | + if (texturecache == null) |
---|
| 8439 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8440 | + else |
---|
| 8441 | + new Exception().printStackTrace(); |
---|
8288 | 8442 | } else |
---|
8289 | 8443 | { |
---|
8290 | 8444 | if (textureon) |
---|
.. | .. |
---|
8343 | 8497 | if (texturedata == null) |
---|
8344 | 8498 | throw new Exception(); |
---|
8345 | 8499 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8500 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8347 | 8501 | //texture = GetTexture(tex, bump); |
---|
8348 | 8502 | } |
---|
8349 | 8503 | } |
---|
8350 | 8504 | //} |
---|
8351 | 8505 | } |
---|
8352 | 8506 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8507 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8508 | { |
---|
8355 | 8509 | //return false; |
---|
8356 | 8510 | |
---|
8357 | 8511 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8512 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8513 | { |
---|
8360 | 8514 | // String ext = "_highres"; |
---|
8361 | 8515 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8526 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8527 | if (!cachefile.exists()) |
---|
8374 | 8528 | { |
---|
8375 | | - // cache to disk |
---|
8376 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8377 | | - //buffers[0]. |
---|
8378 | | - |
---|
8379 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8380 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8381 | | - |
---|
8382 | | - // squared size heuristic... |
---|
8383 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8529 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8530 | { |
---|
8385 | | - for (int i=pixels.length; --i>=0;) |
---|
8386 | | - { |
---|
8387 | | - int i3 = i*3; |
---|
8388 | | - pixels[i] = 0xFF; |
---|
8389 | | - pixels[i] <<= 8; |
---|
8390 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8391 | | - pixels[i] <<= 8; |
---|
8392 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8393 | | - pixels[i] <<= 8; |
---|
8394 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8395 | | - } |
---|
8396 | | - |
---|
8397 | | - /* |
---|
8398 | | - int r=0,g=0,b=0,a=0; |
---|
8399 | | - for (int i=0; i<width; i++) |
---|
8400 | | - for (int j=0; j<height; j++) |
---|
8401 | | - { |
---|
8402 | | - int index = j*width+i; |
---|
8403 | | - int p = pixels[index]; |
---|
8404 | | - a = ((p>>24) & 0xFF); |
---|
8405 | | - r = ((p>>16) & 0xFF); |
---|
8406 | | - g = ((p>>8) & 0xFF); |
---|
8407 | | - b = (p & 0xFF); |
---|
8408 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8409 | | - } |
---|
8410 | | - /**/ |
---|
8411 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8412 | | - int height = width; |
---|
8413 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8414 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8531 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8532 | + |
---|
8415 | 8533 | ImageWriter writer = null; |
---|
8416 | 8534 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8535 | if (iter.hasNext()) { |
---|
8418 | 8536 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8537 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8538 | + |
---|
| 8539 | + float compressionQuality = 0.85f; |
---|
8421 | 8540 | try |
---|
8422 | 8541 | { |
---|
8423 | 8542 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8434 | 8553 | } |
---|
8435 | 8554 | } |
---|
8436 | 8555 | } |
---|
8437 | | - |
---|
| 8556 | + |
---|
| 8557 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8558 | + |
---|
8438 | 8559 | //System.out.println("Texture = " + tex); |
---|
8439 | | - if (textures.containsKey(texname)) |
---|
| 8560 | + if (textures.containsKey(tex)) |
---|
8440 | 8561 | { |
---|
8441 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8562 | + CacheTexture thetex = textures.get(tex); |
---|
8442 | 8563 | thetex.texture.disable(); |
---|
8443 | 8564 | thetex.texture.dispose(); |
---|
8444 | | - textures.remove(texname); |
---|
| 8565 | + textures.remove(tex); |
---|
8445 | 8566 | } |
---|
8446 | 8567 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8568 | + //texture.texturedata = texturedata; |
---|
| 8569 | + textures.put(tex, texturecache); |
---|
8449 | 8570 | |
---|
8450 | 8571 | // newtex = true; |
---|
8451 | 8572 | } |
---|
.. | .. |
---|
8461 | 8582 | } |
---|
8462 | 8583 | } |
---|
8463 | 8584 | |
---|
8464 | | - return texture; |
---|
| 8585 | + return texturecache; |
---|
8465 | 8586 | } |
---|
8466 | 8587 | |
---|
8467 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8588 | + static void EmbedTextures(cTexture tex) |
---|
| 8589 | + { |
---|
| 8590 | + if (tex.pigmentdata == null) |
---|
| 8591 | + { |
---|
| 8592 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8593 | + |
---|
| 8594 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8595 | + |
---|
| 8596 | + if (texturecache != null) |
---|
| 8597 | + { |
---|
| 8598 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8599 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8600 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8601 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8602 | + ; |
---|
| 8603 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8604 | + } |
---|
| 8605 | + } |
---|
| 8606 | + |
---|
| 8607 | + if (tex.bumpdata == null) |
---|
| 8608 | + { |
---|
| 8609 | + //String texname = Object3D.GetBump(tex); |
---|
| 8610 | + |
---|
| 8611 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8612 | + |
---|
| 8613 | + if (texturecache != null) |
---|
| 8614 | + { |
---|
| 8615 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8616 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8617 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8618 | + } |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
| 8621 | + |
---|
| 8622 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8468 | 8623 | { |
---|
8469 | 8624 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8470 | 8625 | |
---|
.. | .. |
---|
8482 | 8637 | return texture!=null?texture.texture:null; |
---|
8483 | 8638 | } |
---|
8484 | 8639 | |
---|
8485 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8640 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8486 | 8641 | { |
---|
8487 | 8642 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8488 | 8643 | |
---|
8489 | 8644 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8645 | } |
---|
8491 | 8646 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8647 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8648 | { |
---|
8494 | 8649 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8650 | { |
---|
8496 | 8651 | return false; |
---|
8497 | 8652 | } |
---|
8498 | 8653 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8654 | + //boolean newtex = false; |
---|
8500 | 8655 | |
---|
8501 | 8656 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8502 | 8657 | |
---|
.. | .. |
---|
8528 | 8683 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8684 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8685 | |
---|
8531 | | - return newtex; |
---|
| 8686 | + return true; // Warning: not used. |
---|
8532 | 8687 | } |
---|
8533 | 8688 | |
---|
| 8689 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8690 | + { |
---|
| 8691 | + try |
---|
| 8692 | + { |
---|
| 8693 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8694 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8695 | + ImageWriter writer = writers.next(); |
---|
| 8696 | + |
---|
| 8697 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8698 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8699 | + param.setCompressionQuality(quality); |
---|
| 8700 | + |
---|
| 8701 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8702 | + writer.setOutput(ios); |
---|
| 8703 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8704 | + |
---|
| 8705 | + byte[] data = baos.toByteArray(); |
---|
| 8706 | + writer.dispose(); |
---|
| 8707 | + return data; |
---|
| 8708 | + } |
---|
| 8709 | + catch (Exception e) |
---|
| 8710 | + { |
---|
| 8711 | + e.printStackTrace(); |
---|
| 8712 | + return null; |
---|
| 8713 | + } |
---|
| 8714 | + } |
---|
| 8715 | + |
---|
| 8716 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8717 | + { |
---|
| 8718 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8719 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8720 | + ImageReader reader = writers.next(); |
---|
| 8721 | + |
---|
| 8722 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8723 | + |
---|
| 8724 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8725 | + param.setDestination(bim); |
---|
| 8726 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8727 | + |
---|
| 8728 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8729 | + reader.setInput(ios); |
---|
| 8730 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8731 | + reader.dispose(); |
---|
| 8732 | + |
---|
| 8733 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8734 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8735 | +// byte[] bytes = data.getData(); |
---|
| 8736 | +// |
---|
| 8737 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8738 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8739 | +// { |
---|
| 8740 | +// int i3 = i*3; |
---|
| 8741 | +// pixels[i] = 0xFF; |
---|
| 8742 | +// pixels[i] <<= 8; |
---|
| 8743 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8744 | +// pixels[i] <<= 8; |
---|
| 8745 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8746 | +// pixels[i] <<= 8; |
---|
| 8747 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8748 | +// } |
---|
| 8749 | +// |
---|
| 8750 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8751 | + |
---|
| 8752 | + return bim; |
---|
| 8753 | + } |
---|
| 8754 | + |
---|
8534 | 8755 | ShadowBuffer shadowPBuf; |
---|
8535 | 8756 | AntialiasBuffer antialiasPBuf; |
---|
8536 | 8757 | int MAXSTACK; |
---|
.. | .. |
---|
8723 | 8944 | |
---|
8724 | 8945 | if (cubemap == null) |
---|
8725 | 8946 | { |
---|
8726 | | - LoadEnvy(5); |
---|
| 8947 | + //LoadEnvy(1); |
---|
8727 | 8948 | } |
---|
8728 | 8949 | |
---|
8729 | 8950 | //cubemap.enable(); |
---|
.. | .. |
---|
9010 | 9231 | cubemap = null; |
---|
9011 | 9232 | return; |
---|
9012 | 9233 | case 1: |
---|
9013 | | - name = "cubemaps/box_"; |
---|
9014 | | - ext = "png"; |
---|
| 9234 | + name = "cubemaps/rgb/"; |
---|
| 9235 | + ext = "jpg"; |
---|
9015 | 9236 | reverseUP = false; |
---|
9016 | 9237 | break; |
---|
9017 | 9238 | case 2: |
---|
9018 | | - name = "cubemaps/uffizi_"; |
---|
9019 | | - ext = "png"; |
---|
9020 | | - break; // reverseUP = true; break; |
---|
| 9239 | + name = "cubemaps/uffizi/"; |
---|
| 9240 | + ext = "jpg"; |
---|
| 9241 | + reverseUP = false; |
---|
| 9242 | + break; |
---|
9021 | 9243 | case 3: |
---|
9022 | | - name = "cubemaps/CloudyHills_"; |
---|
9023 | | - ext = "tga"; |
---|
| 9244 | + name = "cubemaps/CloudyHills/"; |
---|
| 9245 | + ext = "jpg"; |
---|
9024 | 9246 | reverseUP = false; |
---|
9025 | 9247 | break; |
---|
9026 | 9248 | case 4: |
---|
9027 | | - name = "cubemaps/cornell_"; |
---|
| 9249 | + name = "cubemaps/cornell/"; |
---|
9028 | 9250 | ext = "png"; |
---|
9029 | 9251 | reverseUP = false; |
---|
9030 | 9252 | break; |
---|
| 9253 | + case 5: |
---|
| 9254 | + name = "cubemaps/skycube/"; |
---|
| 9255 | + ext = "jpg"; |
---|
| 9256 | + reverseUP = false; |
---|
| 9257 | + break; |
---|
| 9258 | + case 6: |
---|
| 9259 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
| 9263 | + case 7: |
---|
| 9264 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 8: |
---|
| 9269 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 9: |
---|
| 9274 | + name = "cubemaps/UnionSquare/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
9031 | 9278 | default: |
---|
9032 | | - name = "cubemaps/rgb_"; |
---|
9033 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9279 | + name = "cubemaps/box/"; |
---|
| 9280 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9281 | + reverseUP = false; |
---|
9034 | 9282 | break; |
---|
9035 | 9283 | } |
---|
9036 | | - |
---|
9037 | | - try |
---|
9038 | | - { |
---|
9039 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9040 | | - } catch (IOException e) |
---|
9041 | | - { |
---|
9042 | | - throw new RuntimeException(e); |
---|
9043 | | - } |
---|
| 9284 | + |
---|
| 9285 | + LoadSkybox(name, ext, mipmap); |
---|
9044 | 9286 | } |
---|
9045 | 9287 | |
---|
9046 | 9288 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9072 | 9314 | static double[] model = new double[16]; |
---|
9073 | 9315 | double[] camera2light = new double[16]; |
---|
9074 | 9316 | double[] light2camera = new double[16]; |
---|
9075 | | - int newenvy = -1; |
---|
9076 | | - boolean envyoff = true; // false; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
| 9322 | + |
---|
9077 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9078 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
9079 | 9325 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9366 | 9612 | jy8[3] = 0.5f; |
---|
9367 | 9613 | } |
---|
9368 | 9614 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9615 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9616 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9617 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9618 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9619 | |
---|
| 9620 | + void ResetOptions() |
---|
| 9621 | + { |
---|
| 9622 | + options1[0] = 100; |
---|
| 9623 | + options1[1] = 0.025f; |
---|
| 9624 | + options1[2] = 0.01f; |
---|
| 9625 | + options1[3] = 0; |
---|
| 9626 | + options1[4] = 0; |
---|
| 9627 | + |
---|
| 9628 | + options2[0] = 0; |
---|
| 9629 | + options2[1] = 0.75f; |
---|
| 9630 | + options2[2] = 0; |
---|
| 9631 | + options2[3] = 0; |
---|
| 9632 | + |
---|
| 9633 | + options3[0] = 1; |
---|
| 9634 | + options3[1] = 1; |
---|
| 9635 | + options3[2] = 1; |
---|
| 9636 | + options3[3] = 0; |
---|
| 9637 | + |
---|
| 9638 | + options4[0] = 1; |
---|
| 9639 | + options4[1] = 0; |
---|
| 9640 | + options4[2] = 1; |
---|
| 9641 | + options4[3] = 0; |
---|
| 9642 | + } |
---|
| 9643 | + |
---|
9374 | 9644 | static int imagecount = 0; // movie generation |
---|
9375 | 9645 | |
---|
9376 | 9646 | static int jitter = 0; |
---|
.. | .. |
---|
9467 | 9737 | |
---|
9468 | 9738 | if (renderCamera != lightCamera) |
---|
9469 | 9739 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9470 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9740 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9471 | 9741 | |
---|
9472 | 9742 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9473 | 9743 | |
---|
.. | .. |
---|
9483 | 9753 | |
---|
9484 | 9754 | if (renderCamera != lightCamera) |
---|
9485 | 9755 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9486 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9756 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9487 | 9757 | |
---|
9488 | 9758 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9489 | 9759 | |
---|
.. | .. |
---|
9529 | 9799 | rati = 1 / rati; |
---|
9530 | 9800 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9531 | 9801 | } |
---|
9532 | | - assert (newenvy == -1); |
---|
| 9802 | + |
---|
| 9803 | + //assert (newenvy == -1); |
---|
| 9804 | + |
---|
9533 | 9805 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9534 | 9806 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9535 | | - DrawSkyBox(gl); |
---|
| 9807 | + DrawSkyBox(gl, (float)rati); |
---|
9536 | 9808 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9537 | 9809 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9538 | 9810 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10481 | 10753 | ANTIALIAS = 0; |
---|
10482 | 10754 | //System.out.println("RESTART"); |
---|
10483 | 10755 | AAtimer.restart(); |
---|
| 10756 | + Globals.TIMERRUNNING = true; |
---|
10484 | 10757 | } |
---|
10485 | 10758 | } |
---|
10486 | 10759 | } |
---|
.. | .. |
---|
10683 | 10956 | // if (parentcam != renderCamera) // not a light |
---|
10684 | 10957 | if (cam != lightCamera) |
---|
10685 | 10958 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10686 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10959 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10687 | 10960 | |
---|
10688 | 10961 | for (int j = 0; j < 4; j++) |
---|
10689 | 10962 | { |
---|
.. | .. |
---|
10698 | 10971 | // if (parentcam != renderCamera) // not a light |
---|
10699 | 10972 | if (cam != lightCamera) |
---|
10700 | 10973 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10701 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10974 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10702 | 10975 | |
---|
10703 | 10976 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10704 | 10977 | |
---|
.. | .. |
---|
10784 | 11057 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10785 | 11058 | } |
---|
10786 | 11059 | |
---|
10787 | | - if (newenvy > -1) |
---|
| 11060 | +// if (newenvy > -1) |
---|
| 11061 | +// { |
---|
| 11062 | +// LoadEnvy(newenvy); |
---|
| 11063 | +// } |
---|
| 11064 | +// |
---|
| 11065 | +// newenvy = -1; |
---|
| 11066 | + |
---|
| 11067 | + if (object.skyboxname != null) |
---|
10788 | 11068 | { |
---|
10789 | | - LoadEnvy(newenvy); |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
10790 | 11074 | } |
---|
10791 | | - |
---|
10792 | | - newenvy = -1; |
---|
10793 | | - |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
| 11079 | + } |
---|
| 11080 | + |
---|
10794 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
10795 | 11082 | //System.out.println("ratio = " + ratio); |
---|
10796 | 11083 | |
---|
.. | .. |
---|
10806 | 11093 | |
---|
10807 | 11094 | if (!IsFrozen() && !ambientOcclusion) |
---|
10808 | 11095 | { |
---|
10809 | | - DrawSkyBox(gl); |
---|
| 11096 | + DrawSkyBox(gl, (float)ratio); |
---|
10810 | 11097 | } |
---|
10811 | 11098 | |
---|
10812 | 11099 | //if (selection_view == -1) |
---|
.. | .. |
---|
10989 | 11276 | |
---|
10990 | 11277 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10991 | 11278 | |
---|
10992 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10993 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10994 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11279 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11280 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11281 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10995 | 11282 | } else |
---|
10996 | 11283 | { |
---|
10997 | 11284 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11002 | 11289 | //System.out.println("BLENDING ON"); |
---|
11003 | 11290 | gl.glEnable(GL.GL_BLEND); |
---|
11004 | 11291 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11005 | | - |
---|
| 11292 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11006 | 11293 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11007 | 11294 | gl.glLoadIdentity(); |
---|
11008 | 11295 | |
---|
.. | .. |
---|
11092 | 11379 | |
---|
11093 | 11380 | // if (cam != lightCamera) |
---|
11094 | 11381 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11095 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11382 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11096 | 11383 | } |
---|
11097 | 11384 | |
---|
11098 | 11385 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11251 | 11538 | } |
---|
11252 | 11539 | } |
---|
11253 | 11540 | |
---|
11254 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11541 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11255 | 11542 | { |
---|
11256 | 11543 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11257 | 11544 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11259 | 11546 | |
---|
11260 | 11547 | boolean texon = textureon; |
---|
11261 | 11548 | |
---|
11262 | | - if (RENDERPROGRAM > 0) |
---|
11263 | | - { |
---|
11264 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11265 | | - textureon = false; |
---|
11266 | | - } |
---|
| 11549 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11550 | + textureon = false; |
---|
| 11551 | + |
---|
11267 | 11552 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11268 | 11553 | //System.out.println("ALLO"); |
---|
11269 | 11554 | gl.glColorMask(false, false, false, false); |
---|
11270 | 11555 | DrawObject(gl); |
---|
11271 | | - if (RENDERPROGRAM > 0) |
---|
11272 | | - { |
---|
11273 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11274 | | - textureon = texon; |
---|
11275 | | - } |
---|
| 11556 | + |
---|
| 11557 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11558 | + textureon = texon; |
---|
| 11559 | + |
---|
11276 | 11560 | gl.glColorMask(true, true, true, true); |
---|
11277 | 11561 | |
---|
11278 | 11562 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11279 | | - //gl.glDepthMask(false); |
---|
| 11563 | + gl.glDepthMask(false); |
---|
11280 | 11564 | } |
---|
11281 | 11565 | |
---|
11282 | 11566 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11479 | 11763 | |
---|
11480 | 11764 | void DrawObject(GL gl, boolean draw) |
---|
11481 | 11765 | { |
---|
| 11766 | + // To clear camera values |
---|
| 11767 | + ResetOptions(); |
---|
| 11768 | + |
---|
11482 | 11769 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11483 | 11770 | // DrawMode() = SELECTION; |
---|
11484 | 11771 | //GL gl = getGL(); |
---|
11485 | 11772 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11486 | 11773 | { |
---|
11487 | 11774 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11488 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11775 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11489 | 11776 | pingthread.StepToTarget(true); // true); |
---|
11490 | 11777 | // zoomonce = false; |
---|
11491 | 11778 | } |
---|
.. | .. |
---|
11613 | 11900 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11614 | 11901 | |
---|
11615 | 11902 | if (CLEANCACHE) |
---|
11616 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11903 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11617 | 11904 | { |
---|
11618 | | - String tex = e.nextElement(); |
---|
| 11905 | + cTexture tex = e.nextElement(); |
---|
11619 | 11906 | |
---|
11620 | 11907 | // System.out.println("Texture --------- " + tex); |
---|
11621 | 11908 | |
---|
11622 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11909 | + if (tex.equals("WHITE_NOISE:")) |
---|
11623 | 11910 | continue; |
---|
11624 | 11911 | |
---|
11625 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11912 | + if (!usedtextures.contains(tex)) |
---|
11626 | 11913 | { |
---|
| 11914 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11627 | 11915 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11628 | | - textures.get(tex).texture.dispose(); |
---|
11629 | | - textures.remove(tex); |
---|
| 11916 | + if (gettex != null) |
---|
| 11917 | + { |
---|
| 11918 | + gettex.texture.dispose(); |
---|
| 11919 | + texturepigment.remove(tex); |
---|
| 11920 | + } |
---|
| 11921 | + |
---|
| 11922 | + gettex = texturebump.get(tex); |
---|
| 11923 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11924 | + if (gettex != null) |
---|
| 11925 | + { |
---|
| 11926 | + gettex.texture.dispose(); |
---|
| 11927 | + texturebump.remove(tex); |
---|
| 11928 | + } |
---|
11630 | 11929 | } |
---|
11631 | 11930 | } |
---|
11632 | 11931 | } |
---|
.. | .. |
---|
12046 | 12345 | for (int i = tp.size(); --i >= 0;) |
---|
12047 | 12346 | { |
---|
12048 | 12347 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12049 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12348 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12050 | 12349 | } |
---|
12051 | 12350 | |
---|
12052 | 12351 | |
---|
.. | .. |
---|
12154 | 12453 | |
---|
12155 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12156 | 12455 | |
---|
12157 | | - String program = |
---|
| 12456 | + String programmin = |
---|
| 12457 | + // Min shader |
---|
12158 | 12458 | "!!ARBfp1.0\n" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12460 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12461 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12462 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12463 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12464 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12465 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12466 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12467 | + "TEMP temp;" + |
---|
| 12468 | + "TEMP light;" + |
---|
| 12469 | + "TEMP ndotl;" + |
---|
| 12470 | + "TEMP normal;" + |
---|
| 12471 | + "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
| 12474 | + |
---|
| 12475 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12476 | + Normalize("normal") + |
---|
| 12477 | + "MOV light, state.light[0].position;" + |
---|
| 12478 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12479 | + |
---|
| 12480 | + // shadow |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12484 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12486 | + |
---|
| 12487 | + // No shadow when out of frustum |
---|
| 12488 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12489 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12490 | + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12492 | + |
---|
| 12493 | + // Backlit |
---|
| 12494 | + "MOV pos.w, zero123.y;" + |
---|
| 12495 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12496 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12497 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12498 | + Normalize("eye") + |
---|
| 12499 | + |
---|
| 12500 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12501 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12502 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12503 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12504 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12505 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12506 | + |
---|
| 12507 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12508 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12509 | + |
---|
| 12510 | + // Pigment |
---|
| 12511 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12512 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12513 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12514 | + |
---|
| 12515 | + "MUL temp, temp, zero123.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12518 | + |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12520 | + "MOV result.color, temp;" + |
---|
| 12521 | + "END"; |
---|
| 12522 | + |
---|
| 12523 | + String programmax = |
---|
| 12524 | + "!!ARBfp1.0\n" + |
---|
| 12525 | + |
---|
12159 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12160 | 12527 | "PARAM light2cam0 = program.env[10];" + |
---|
12161 | 12528 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12270 | 12637 | "TEMP shininess;" + |
---|
12271 | 12638 | "\n" + |
---|
12272 | 12639 | "MOV texSamp, one;" + |
---|
12273 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12274 | | - |
---|
| 12640 | + |
---|
12275 | 12641 | "MOV mapgrid.x, one2048th.x;" + |
---|
12276 | 12642 | "MOV temp, fragment.texcoord[1];" + |
---|
12277 | 12643 | /* |
---|
.. | .. |
---|
12292 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
12293 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12294 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12295 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12296 | 12662 | "") + |
---|
12297 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12298 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12299 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12300 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12301 | 12667 | "") + |
---|
12302 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12303 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12304 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12305 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12306 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12307 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12308 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12309 | 12675 | "") + |
---|
12310 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12311 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
12676 | 13042 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12677 | 13043 | "") + |
---|
12678 | 13044 | |
---|
12679 | | - // display shadow only (bump == 0) |
---|
| 13045 | + // display shadow only (fakedepth == 0) |
---|
12680 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
12681 | 13047 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12682 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12683 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
12684 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
12685 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
13010 | 13376 | //once = true; |
---|
13011 | 13377 | } |
---|
13012 | 13378 | |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
13013 | 13386 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13014 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13015 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13103 | 13476 | return out; |
---|
13104 | 13477 | } |
---|
13105 | 13478 | |
---|
13106 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13107 | 13481 | { |
---|
13108 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13109 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13110 | 13484 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13485 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13486 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13111 | 13487 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13112 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13113 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13114 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13115 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13488 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13489 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13116 | 13490 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13117 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13491 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13118 | 13492 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13119 | 13493 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13120 | 13494 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13121 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13495 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13122 | 13496 | |
---|
13123 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13124 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13497 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13498 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13125 | 13499 | } |
---|
13126 | 13500 | |
---|
13127 | 13501 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13168 | 13542 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13169 | 13543 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13170 | 13544 | |
---|
13171 | | - // No shadow when out of frustrum |
---|
| 13545 | + // No shadow when out of frustum |
---|
13172 | 13546 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13173 | 13547 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13174 | 13548 | ""; |
---|
.. | .. |
---|
13333 | 13707 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13334 | 13708 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13335 | 13709 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13336 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13337 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13338 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13710 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13711 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13712 | + |
---|
| 13713 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13339 | 13714 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13340 | 13715 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13341 | 13716 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13840 | 14215 | else |
---|
13841 | 14216 | if (evt.getSource() == AAtimer) |
---|
13842 | 14217 | { |
---|
| 14218 | + Globals.TIMERRUNNING = false; |
---|
13843 | 14219 | if (mouseDown) |
---|
13844 | 14220 | { |
---|
13845 | 14221 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13899 | 14275 | |
---|
13900 | 14276 | // fev 2014??? |
---|
13901 | 14277 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13902 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14278 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13903 | 14279 | pingthread.StepToTarget(true); // true); |
---|
13904 | 14280 | } |
---|
13905 | 14281 | // if (!LIVE) |
---|
.. | .. |
---|
13914 | 14290 | return; |
---|
13915 | 14291 | |
---|
13916 | 14292 | AAtimer.restart(); // |
---|
| 14293 | + Globals.TIMERRUNNING = true; |
---|
13917 | 14294 | |
---|
13918 | 14295 | // waslive = LIVE; |
---|
13919 | 14296 | // LIVE = false; |
---|
.. | .. |
---|
13963 | 14340 | drag = false; |
---|
13964 | 14341 | //System.out.println("Mouse DOWN"); |
---|
13965 | 14342 | editObj = false; |
---|
13966 | | - ClickInfo info = new ClickInfo(); |
---|
13967 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13968 | | - info.pane = this; |
---|
13969 | | - info.camera = renderCamera; |
---|
13970 | | - info.x = x; |
---|
13971 | | - info.y = y; |
---|
13972 | | - info.modifiers = modifiersex; |
---|
13973 | | - editObj = object.doEditClick(info, 0); |
---|
| 14343 | + //ClickInfo info = new ClickInfo(); |
---|
| 14344 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14345 | + object.clickInfo.pane = this; |
---|
| 14346 | + object.clickInfo.camera = renderCamera; |
---|
| 14347 | + object.clickInfo.x = x; |
---|
| 14348 | + object.clickInfo.y = y; |
---|
| 14349 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14350 | + editObj = object.doEditClick(//info, |
---|
| 14351 | + 0); |
---|
13974 | 14352 | if (!editObj) |
---|
13975 | 14353 | { |
---|
13976 | 14354 | hasMarquee = true; |
---|
.. | .. |
---|
14252 | 14630 | void GoDown(int mod) |
---|
14253 | 14631 | { |
---|
14254 | 14632 | MODIFIERS |= COMMAND; |
---|
14255 | | - /* |
---|
| 14633 | + /**/ |
---|
14256 | 14634 | if((mod&SHIFT) == SHIFT) |
---|
14257 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14635 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
14258 | 14636 | else |
---|
14259 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14260 | | - */ |
---|
| 14637 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14638 | + /**/ |
---|
14261 | 14639 | if ((mod & SHIFT) == SHIFT) |
---|
14262 | 14640 | { |
---|
14263 | 14641 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14273 | 14651 | void GoUp(int mod) |
---|
14274 | 14652 | { |
---|
14275 | 14653 | MODIFIERS |= COMMAND; |
---|
14276 | | - /* |
---|
| 14654 | + /**/ |
---|
14277 | 14655 | if((mod&SHIFT) == SHIFT) |
---|
14278 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14656 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
14279 | 14657 | else |
---|
14280 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14281 | | - */ |
---|
| 14658 | + manipCamera.RotatePosition(0, speed); |
---|
| 14659 | + /**/ |
---|
14282 | 14660 | if ((mod & SHIFT) == SHIFT) |
---|
14283 | 14661 | { |
---|
14284 | 14662 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14294 | 14672 | void GoLeft(int mod) |
---|
14295 | 14673 | { |
---|
14296 | 14674 | MODIFIERS |= COMMAND; |
---|
14297 | | - /* |
---|
| 14675 | + /**/ |
---|
14298 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14299 | | - manipCamera.RotatePosition(speed, 0); |
---|
14300 | | - else |
---|
14301 | 14677 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14302 | | - */ |
---|
| 14678 | + else |
---|
| 14679 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14680 | + /**/ |
---|
14303 | 14681 | if ((mod & SHIFT) == SHIFT) |
---|
14304 | 14682 | { |
---|
14305 | 14683 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14315 | 14693 | void GoRight(int mod) |
---|
14316 | 14694 | { |
---|
14317 | 14695 | MODIFIERS |= COMMAND; |
---|
14318 | | - /* |
---|
| 14696 | + /**/ |
---|
14319 | 14697 | if((mod&SHIFT) == SHIFT) |
---|
14320 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14321 | | - else |
---|
14322 | 14698 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14323 | | - */ |
---|
| 14699 | + else |
---|
| 14700 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14701 | + /**/ |
---|
14324 | 14702 | if ((mod & SHIFT) == SHIFT) |
---|
14325 | 14703 | { |
---|
14326 | 14704 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14370 | 14748 | if (editObj) |
---|
14371 | 14749 | { |
---|
14372 | 14750 | drag = true; |
---|
14373 | | - ClickInfo info = new ClickInfo(); |
---|
14374 | | - info.bounds.setBounds(0, 0, |
---|
| 14751 | + //ClickInfo info = new ClickInfo(); |
---|
| 14752 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14375 | 14753 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14376 | | - info.pane = this; |
---|
14377 | | - info.camera = renderCamera; |
---|
14378 | | - info.x = x; |
---|
14379 | | - info.y = y; |
---|
14380 | | - object.manipWindow.copy |
---|
14381 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14754 | + object.clickInfo.pane = this; |
---|
| 14755 | + object.clickInfo.camera = renderCamera; |
---|
| 14756 | + object.clickInfo.x = x; |
---|
| 14757 | + object.clickInfo.y = y; |
---|
| 14758 | + object //.GetWindow().copy |
---|
| 14759 | + .doEditDrag(//info, |
---|
| 14760 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14382 | 14761 | } else |
---|
14383 | 14762 | { |
---|
14384 | 14763 | if (x < startX) |
---|
.. | .. |
---|
14527 | 14906 | } |
---|
14528 | 14907 | } |
---|
14529 | 14908 | |
---|
| 14909 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14910 | + |
---|
14530 | 14911 | public void mouseMoved(MouseEvent e) |
---|
14531 | 14912 | { |
---|
14532 | 14913 | //System.out.println("mouseMoved: " + e); |
---|
14533 | 14914 | if (isRenderer) |
---|
14534 | 14915 | return; |
---|
14535 | 14916 | |
---|
14536 | | - ClickInfo ci = new ClickInfo(); |
---|
14537 | | - ci.x = e.getX(); |
---|
14538 | | - ci.y = e.getY(); |
---|
14539 | | - ci.modifiers = e.getModifiersEx(); |
---|
14540 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14541 | | - ci.pane = this; |
---|
14542 | | - ci.camera = renderCamera; |
---|
| 14917 | + // Mouse cursor feedback |
---|
| 14918 | + object.clickInfo.x = e.getX(); |
---|
| 14919 | + object.clickInfo.y = e.getY(); |
---|
| 14920 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14921 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14922 | + object.clickInfo.pane = this; |
---|
| 14923 | + object.clickInfo.camera = renderCamera; |
---|
14543 | 14924 | if (!isRenderer) |
---|
14544 | 14925 | { |
---|
14545 | 14926 | //ObjEditor editWindow = object.editWindow; |
---|
14546 | 14927 | //Object3D copy = editWindow.copy; |
---|
14547 | | - if (object.doEditClick(ci, 0)) |
---|
| 14928 | + if (object.doEditClick(//clickInfo, |
---|
| 14929 | + 0)) |
---|
14548 | 14930 | { |
---|
14549 | 14931 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14550 | 14932 | } else |
---|
.. | .. |
---|
14559 | 14941 | Globals.MOUSEDRAGGED = false; |
---|
14560 | 14942 | |
---|
14561 | 14943 | movingcamera = false; |
---|
14562 | | - X = Y = 0; |
---|
| 14944 | + X = 0; // getBounds().width/2; |
---|
| 14945 | + Y = 0; // getBounds().height/2; |
---|
14563 | 14946 | //System.out.println("mouseReleased: " + e); |
---|
14564 | 14947 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14565 | 14948 | } |
---|
.. | .. |
---|
14815 | 15198 | // break; |
---|
14816 | 15199 | case 'T': |
---|
14817 | 15200 | CACHETEXTURE ^= true; |
---|
14818 | | - textures.clear(); |
---|
| 15201 | + texturepigment.clear(); |
---|
| 15202 | + texturebump.clear(); |
---|
14819 | 15203 | // repaint(); |
---|
14820 | 15204 | break; |
---|
14821 | 15205 | case 'Y': |
---|
.. | .. |
---|
14900 | 15284 | case 'E' : COMPACT ^= true; |
---|
14901 | 15285 | repaint(); |
---|
14902 | 15286 | break; |
---|
14903 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15287 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15288 | + //DEBUGHSB ^= true; |
---|
| 15289 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14904 | 15290 | repaint(); |
---|
14905 | 15291 | break; |
---|
14906 | 15292 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14926 | 15312 | repaint(); |
---|
14927 | 15313 | break; |
---|
14928 | 15314 | case 'l': |
---|
14929 | | - lightMode ^= true; |
---|
14930 | | - Globals.lighttouched = true; |
---|
14931 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14932 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14933 | | - repaint(); |
---|
14934 | | - break; |
---|
14935 | | - case 'L': |
---|
| 15315 | + //case 'L': |
---|
14936 | 15316 | if (lightMode) |
---|
14937 | 15317 | { |
---|
14938 | 15318 | lightMode = false; |
---|
.. | .. |
---|
14996 | 15376 | OCCLUSION_CULLING ^= true; |
---|
14997 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
14998 | 15378 | break; |
---|
14999 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15000 | 15380 | case '1': |
---|
15001 | 15381 | case '2': |
---|
15002 | 15382 | case '3': |
---|
15003 | 15383 | case '4': |
---|
15004 | 15384 | case '5': |
---|
15005 | | - newenvy = Character.getNumericValue(key); |
---|
15006 | | - repaint(); |
---|
15007 | | - break; |
---|
15008 | 15385 | case '6': |
---|
15009 | 15386 | case '7': |
---|
15010 | 15387 | case '8': |
---|
15011 | 15388 | case '9': |
---|
15012 | | - BGcolor = (key - '6')/3.f; |
---|
| 15389 | + if (true) // envyoff) |
---|
| 15390 | + { |
---|
| 15391 | + BGcolor = (key - '1')/8.f; |
---|
| 15392 | + } |
---|
| 15393 | + else |
---|
| 15394 | + { |
---|
| 15395 | + //newenvy = Character.getNumericValue(key); |
---|
| 15396 | + } |
---|
15013 | 15397 | repaint(); |
---|
15014 | 15398 | break; |
---|
15015 | 15399 | case '!': |
---|
.. | .. |
---|
15075 | 15459 | case '_': |
---|
15076 | 15460 | kompactbit = 5; |
---|
15077 | 15461 | break; |
---|
15078 | | - case '+': |
---|
15079 | | - kompactbit = 6; |
---|
15080 | | - break; |
---|
| 15462 | +// case '+': |
---|
| 15463 | +// kompactbit = 6; |
---|
| 15464 | +// break; |
---|
15081 | 15465 | case ' ': |
---|
15082 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15466 | + lightMode ^= true; |
---|
| 15467 | + Globals.lighttouched = true; |
---|
| 15468 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15469 | + targetLookAt.set(manipCamera.lookAt); |
---|
15083 | 15470 | repaint(); |
---|
15084 | 15471 | break; |
---|
15085 | 15472 | //case '`' : |
---|
.. | .. |
---|
15126 | 15513 | case DELETE: |
---|
15127 | 15514 | ClearSelection(); |
---|
15128 | 15515 | break; |
---|
15129 | | - /* |
---|
15130 | 15516 | case '+': |
---|
| 15517 | + |
---|
| 15518 | + /* |
---|
15131 | 15519 | //fontsize += 1; |
---|
15132 | 15520 | bbzoom *= 2; |
---|
15133 | 15521 | repaint(); |
---|
.. | .. |
---|
15144 | 15532 | case '=': |
---|
15145 | 15533 | IncDepth(); |
---|
15146 | 15534 | //fontsize += 1; |
---|
15147 | | - object.editWindow.refreshContents(true); |
---|
| 15535 | + object.GetWindow().refreshContents(true); |
---|
15148 | 15536 | maskbit = 6; |
---|
15149 | 15537 | break; |
---|
15150 | 15538 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15151 | 15539 | DecDepth(); |
---|
15152 | 15540 | maskbit = 5; |
---|
15153 | 15541 | //if(fontsize > 1) fontsize -= 1; |
---|
15154 | | - if (object.editWindow == null) |
---|
15155 | | - new Exception().printStackTrace(); |
---|
15156 | | - else |
---|
15157 | | - object.editWindow.refreshContents(true); |
---|
| 15542 | +// if (object.editWindow == null) |
---|
| 15543 | +// new Exception().printStackTrace(); |
---|
| 15544 | +// else |
---|
| 15545 | + object.GetWindow().refreshContents(true); |
---|
15158 | 15546 | break; |
---|
15159 | 15547 | case '{': |
---|
15160 | 15548 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15378 | 15766 | } |
---|
15379 | 15767 | */ |
---|
15380 | 15768 | |
---|
15381 | | - object.editWindow.EditSelection(); |
---|
| 15769 | + object.GetWindow().EditSelection(false); |
---|
15382 | 15770 | } |
---|
15383 | 15771 | |
---|
15384 | 15772 | void SelectParent() |
---|
.. | .. |
---|
15395 | 15783 | { |
---|
15396 | 15784 | //selectees.remove(i); |
---|
15397 | 15785 | System.out.println("select parent of " + elem); |
---|
15398 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15786 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15399 | 15787 | } else |
---|
15400 | 15788 | { |
---|
15401 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15789 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15402 | 15790 | } |
---|
15403 | 15791 | |
---|
15404 | 15792 | first = false; |
---|
.. | .. |
---|
15440 | 15828 | for (int j = 0; j < group.children.size(); j++) |
---|
15441 | 15829 | { |
---|
15442 | 15830 | elem = (Object3D) group.children.elementAt(j); |
---|
15443 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15831 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15444 | 15832 | first = false; |
---|
15445 | 15833 | } |
---|
15446 | 15834 | } else |
---|
15447 | 15835 | { |
---|
15448 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15836 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15449 | 15837 | } |
---|
15450 | 15838 | |
---|
15451 | 15839 | first = false; |
---|
.. | .. |
---|
15456 | 15844 | { |
---|
15457 | 15845 | //Composite group = (Composite) object; |
---|
15458 | 15846 | Object3D group = object; |
---|
15459 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15847 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15460 | 15848 | } |
---|
15461 | 15849 | |
---|
15462 | 15850 | void ResetTransform(int mask) |
---|
15463 | 15851 | { |
---|
15464 | 15852 | //Composite group = (Composite) object; |
---|
15465 | 15853 | Object3D group = object; |
---|
15466 | | - group.editWindow.ResetTransform(mask); |
---|
| 15854 | + group.GetWindow().ResetTransform(mask); |
---|
15467 | 15855 | } |
---|
15468 | 15856 | |
---|
15469 | 15857 | void FlipTransform() |
---|
15470 | 15858 | { |
---|
15471 | 15859 | //Composite group = (Composite) object; |
---|
15472 | 15860 | Object3D group = object; |
---|
15473 | | - group.editWindow.FlipTransform(); |
---|
| 15861 | + group.GetWindow().FlipTransform(); |
---|
15474 | 15862 | // group.editWindow.ReduceMesh(true); |
---|
15475 | 15863 | } |
---|
15476 | 15864 | |
---|
.. | .. |
---|
15478 | 15866 | { |
---|
15479 | 15867 | //Composite group = (Composite) object; |
---|
15480 | 15868 | Object3D group = object; |
---|
15481 | | - group.editWindow.PrintMemory(); |
---|
| 15869 | + group.GetWindow().PrintMemory(); |
---|
15482 | 15870 | // group.editWindow.ReduceMesh(true); |
---|
15483 | 15871 | } |
---|
15484 | 15872 | |
---|
.. | .. |
---|
15486 | 15874 | { |
---|
15487 | 15875 | //Composite group = (Composite) object; |
---|
15488 | 15876 | Object3D group = object; |
---|
15489 | | - group.editWindow.ResetCentroid(); |
---|
| 15877 | + group.GetWindow().ResetCentroid(); |
---|
15490 | 15878 | } |
---|
15491 | 15879 | |
---|
15492 | 15880 | void IncDepth() |
---|
.. | .. |
---|
15568 | 15956 | |
---|
15569 | 15957 | int width = getBounds().width; |
---|
15570 | 15958 | int height = getBounds().height; |
---|
15571 | | - ClickInfo info = new ClickInfo(); |
---|
15572 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15573 | 15959 | //Image img = CreateImage(width, height); |
---|
15574 | 15960 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15575 | 15961 | |
---|
.. | .. |
---|
15646 | 16032 | } |
---|
15647 | 16033 | if (object != null && !hasMarquee) |
---|
15648 | 16034 | { |
---|
| 16035 | + if (object.clickInfo == null) |
---|
| 16036 | + object.clickInfo = new ClickInfo(); |
---|
| 16037 | + ClickInfo info = object.clickInfo; |
---|
| 16038 | + //ClickInfo info = new ClickInfo(); |
---|
| 16039 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16040 | + |
---|
15649 | 16041 | if (isRenderer) |
---|
15650 | 16042 | { |
---|
15651 | | - info.flags++; |
---|
| 16043 | + object.clickInfo.flags++; |
---|
15652 | 16044 | double frameAspect = (double) width / (double) height; |
---|
15653 | 16045 | if (frameAspect > renderCamera.aspect) |
---|
15654 | 16046 | { |
---|
15655 | 16047 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15656 | | - info.bounds.width -= width - desired; |
---|
15657 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16048 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16049 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15658 | 16050 | } else |
---|
15659 | 16051 | { |
---|
15660 | 16052 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15661 | | - info.bounds.height -= height - desired; |
---|
15662 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16053 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16054 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15663 | 16055 | } |
---|
15664 | 16056 | } |
---|
15665 | | - info.g = gr; |
---|
15666 | | - info.camera = renderCamera; |
---|
| 16057 | + |
---|
| 16058 | + object.clickInfo.g = gr; |
---|
| 16059 | + object.clickInfo.camera = renderCamera; |
---|
15667 | 16060 | /* |
---|
15668 | 16061 | // Memory intensive (brep.verticescopy) |
---|
15669 | 16062 | if (!(object instanceof Composite)) |
---|
15670 | 16063 | object.draw(info, 0, false); // SLOW : |
---|
15671 | 16064 | */ |
---|
15672 | | - if (!isRenderer) |
---|
| 16065 | + if (!isRenderer) // && drag) |
---|
15673 | 16066 | { |
---|
15674 | | - object.drawEditHandles(info, 0); |
---|
15675 | | - |
---|
15676 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16067 | + Grafreed.Assert(object != null); |
---|
| 16068 | + Grafreed.Assert(object.selection != null); |
---|
| 16069 | + if (object.selection.Size() > 0) |
---|
15677 | 16070 | { |
---|
15678 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16071 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16072 | + |
---|
| 16073 | + object.clickInfo.DX = 0; |
---|
| 16074 | + object.clickInfo.DY = 0; |
---|
| 16075 | + object.clickInfo.W = 1; |
---|
| 16076 | + if (hitSomething == Object3D.hitCenter) |
---|
15679 | 16077 | { |
---|
15680 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15681 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15682 | | - break; |
---|
15683 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15684 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15685 | | - break; |
---|
15686 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15687 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15688 | | - break; |
---|
| 16078 | + info.DX = X; |
---|
| 16079 | + if (X != 0) |
---|
| 16080 | + info.DX -= info.bounds.width/2; |
---|
| 16081 | + |
---|
| 16082 | + info.DY = Y; |
---|
| 16083 | + if (Y != 0) |
---|
| 16084 | + info.DY -= info.bounds.height/2; |
---|
15689 | 16085 | } |
---|
15690 | | - |
---|
| 16086 | + |
---|
| 16087 | + object.drawEditHandles(//info, |
---|
| 16088 | + 0); |
---|
| 16089 | + |
---|
| 16090 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16091 | + { |
---|
| 16092 | + switch (hitSomething) |
---|
| 16093 | + { |
---|
| 16094 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16095 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16096 | + break; |
---|
| 16097 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16098 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16099 | + break; |
---|
| 16100 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16102 | + break; |
---|
| 16103 | + } |
---|
| 16104 | + |
---|
| 16105 | + } |
---|
15691 | 16106 | } |
---|
15692 | 16107 | } |
---|
15693 | 16108 | } |
---|
.. | .. |
---|
16169 | 16584 | private /*static*/ boolean firstime; |
---|
16170 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
16171 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16172 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16173 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16174 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16181 | 16598 | { |
---|
16182 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16183 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
16184 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
16185 | 16604 | { |
---|
16186 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16187 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16188 | | - mipmapped, |
---|
16189 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16190 | | - if (data == null) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
16191 | 16610 | { |
---|
16192 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
16193 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
16194 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
16195 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
16196 | 16646 | } |
---|
16197 | 16647 | |
---|
16198 | 16648 | return cubemap; |
---|
16199 | 16649 | } |
---|
| 16650 | + |
---|
16200 | 16651 | int bigsphere = -1; |
---|
16201 | 16652 | |
---|
16202 | 16653 | float BGcolor = 0.5f; |
---|
16203 | 16654 | |
---|
16204 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16205 | 16658 | { |
---|
16206 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
16207 | 16661 | { |
---|
16208 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16209 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16218 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16219 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16220 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
16221 | 16676 | |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16685 | + |
---|
16222 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16223 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16224 | 16688 | |
---|
.. | .. |
---|
16250 | 16714 | { |
---|
16251 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16252 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16253 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16254 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16255 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16485 | 16950 | } |
---|
16486 | 16951 | } |
---|
16487 | 16952 | |
---|
| 16953 | + private Object3D GetFolder() |
---|
| 16954 | + { |
---|
| 16955 | + Object3D folder = object.GetWindow().copy; |
---|
| 16956 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16957 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16958 | + return folder; |
---|
| 16959 | + } |
---|
| 16960 | + |
---|
16488 | 16961 | class SelectBuffer implements GLEventListener |
---|
16489 | 16962 | { |
---|
16490 | 16963 | |
---|
.. | .. |
---|
16500 | 16973 | //new Exception().printStackTrace(); |
---|
16501 | 16974 | System.out.println("select buffer init"); |
---|
16502 | 16975 | // Use debug pipeline |
---|
16503 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16504 | 16977 | |
---|
16505 | 16978 | GL gl = drawable.getGL(); |
---|
16506 | 16979 | |
---|
.. | .. |
---|
16564 | 17037 | |
---|
16565 | 17038 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16566 | 17039 | |
---|
| 17040 | + if (PAINTMODE) |
---|
| 17041 | + { |
---|
| 17042 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17043 | + { |
---|
| 17044 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17045 | + |
---|
| 17046 | + // Make what you paint not selectable. |
---|
| 17047 | + paintobj.ResetSelectable(); |
---|
| 17048 | + } |
---|
| 17049 | + } |
---|
| 17050 | + |
---|
16567 | 17051 | //int tmp = selection_view; |
---|
16568 | 17052 | //selection_view = -1; |
---|
16569 | 17053 | int temp = DrawMode(); |
---|
.. | .. |
---|
16575 | 17059 | // temp = DEFAULT; // patch for selection debug |
---|
16576 | 17060 | Globals.drawMode = temp; // WARNING |
---|
16577 | 17061 | |
---|
| 17062 | + if (PAINTMODE) |
---|
| 17063 | + { |
---|
| 17064 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17065 | + { |
---|
| 17066 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17067 | + |
---|
| 17068 | + // Revert. |
---|
| 17069 | + paintobj.RestoreSelectable(); |
---|
| 17070 | + } |
---|
| 17071 | + } |
---|
| 17072 | + |
---|
16578 | 17073 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16579 | 17074 | |
---|
16580 | 17075 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16678 | 17173 | } |
---|
16679 | 17174 | |
---|
16680 | 17175 | if (!movingcamera && !PAINTMODE) |
---|
16681 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17176 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16682 | 17177 | |
---|
16683 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17178 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16684 | 17179 | { |
---|
16685 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17180 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16686 | 17181 | |
---|
16687 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17182 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17183 | + { |
---|
| 17184 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16688 | 17185 | |
---|
16689 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16690 | | - |
---|
16691 | | - group.add(paintobj); // link |
---|
16692 | | - |
---|
16693 | | - object.editWindow.SnapObject(group); |
---|
16694 | | - |
---|
16695 | | - Object3D folder = object.editWindow.copy; |
---|
16696 | | - |
---|
16697 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16698 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16699 | | - |
---|
16700 | | - folder.add(group); |
---|
16701 | | - |
---|
16702 | | - object.editWindow.ResetModel(); |
---|
16703 | | - object.editWindow.refreshContents(); |
---|
| 17186 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17187 | + |
---|
| 17188 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17189 | + |
---|
| 17190 | + inst.add(paintobj); // link |
---|
| 17191 | + |
---|
| 17192 | + object.GetWindow().SnapObject(inst); |
---|
| 17193 | + |
---|
| 17194 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17195 | + |
---|
| 17196 | + folder.add(inst); |
---|
| 17197 | + |
---|
| 17198 | + object.GetWindow().ResetModel(); |
---|
| 17199 | + object.GetWindow().refreshContents(); |
---|
| 17200 | + } |
---|
16704 | 17201 | } |
---|
16705 | 17202 | else |
---|
16706 | 17203 | paintcount = 0; |
---|
.. | .. |
---|
16739 | 17236 | //System.out.println("objects[color] = " + objects[color]); |
---|
16740 | 17237 | //objects[color].Select(); |
---|
16741 | 17238 | indexcount = 0; |
---|
| 17239 | + ObjEditor window = object.GetWindow(); |
---|
| 17240 | + if (window != null && deselect) |
---|
| 17241 | + { |
---|
| 17242 | + window.Select(null, deselect, true); |
---|
| 17243 | + } |
---|
16742 | 17244 | object.Select(color, deselect); |
---|
16743 | 17245 | } |
---|
16744 | 17246 | |
---|