.. | .. |
---|
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; |
---|
.. | .. |
---|
335 | 372 | display.options1[2] = material.shadowbias; |
---|
336 | 373 | display.options1[3] = material.aniso; |
---|
337 | 374 | display.options1[4] = material.anisoV; |
---|
| 375 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 376 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 377 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 378 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 379 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
338 | 380 | display.options2[0] = material.opacity; |
---|
339 | 381 | display.options2[1] = material.diffuse; |
---|
340 | 382 | display.options2[2] = material.factor; |
---|
| 383 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 384 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 385 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
341 | 386 | |
---|
342 | 387 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 388 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 389 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 390 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
343 | 391 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 392 | display.options4[1] = material.subsurface; |
---|
345 | 393 | display.options4[2] = material.sheen; |
---|
| 394 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 395 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 396 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
346 | 397 | |
---|
347 | 398 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 399 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
2051 | 2102 | //System.err.println("Oeil on"); |
---|
2052 | 2103 | OEIL = true; |
---|
2053 | 2104 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2105 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2106 | //pingthread.StepToTarget(true); |
---|
2056 | 2107 | } |
---|
2057 | 2108 | |
---|
.. | .. |
---|
2284 | 2335 | HANDLES ^= true; |
---|
2285 | 2336 | } |
---|
2286 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2287 | 2340 | void TogglePaint() |
---|
2288 | 2341 | { |
---|
2289 | 2342 | PAINTMODE ^= true; |
---|
2290 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2291 | 2349 | } |
---|
2292 | 2350 | |
---|
2293 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2384 | 2442 | return currentGL; |
---|
2385 | 2443 | } |
---|
2386 | 2444 | |
---|
| 2445 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2446 | + { |
---|
| 2447 | + Grafreed.Assert(texturedata != null); |
---|
| 2448 | + |
---|
| 2449 | + int width = texturedata.getWidth(); |
---|
| 2450 | + int height = texturedata.getHeight(); |
---|
| 2451 | + |
---|
| 2452 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2453 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2454 | + |
---|
| 2455 | + byte[] bytes = bytebuf.array(); |
---|
| 2456 | + |
---|
| 2457 | + return CreateBim(bytes, width, height); |
---|
| 2458 | + } |
---|
| 2459 | + |
---|
2387 | 2460 | /**/ |
---|
2388 | 2461 | class CacheTexture |
---|
2389 | 2462 | { |
---|
.. | .. |
---|
2392 | 2465 | |
---|
2393 | 2466 | int resolution; |
---|
2394 | 2467 | |
---|
2395 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2396 | 2469 | { |
---|
2397 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2398 | 2472 | resolution = res; |
---|
2399 | 2473 | } |
---|
2400 | 2474 | } |
---|
2401 | 2475 | /**/ |
---|
2402 | 2476 | |
---|
2403 | 2477 | // 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>(); |
---|
| 2478 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2481 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2482 | + |
---|
2407 | 2483 | int pigmentdepth = 0; |
---|
2408 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2485 | int bumpdepth = 0; |
---|
2410 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2411 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2412 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2413 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2414 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2415 | 2491 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2417 | 2493 | { |
---|
2418 | 2494 | TextureData texturedata = null; |
---|
2419 | 2495 | |
---|
.. | .. |
---|
2432 | 2508 | if (bump) |
---|
2433 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2434 | 2510 | |
---|
2435 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2436 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2511 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2512 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2437 | 2513 | |
---|
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); |
---|
| 2514 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2440 | 2516 | |
---|
2441 | | - return texture; |
---|
| 2517 | + return texturedata; |
---|
| 2518 | + } |
---|
| 2519 | + |
---|
| 2520 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2521 | + { |
---|
| 2522 | + TextureData texturedata = null; |
---|
| 2523 | + |
---|
| 2524 | + try |
---|
| 2525 | + { |
---|
| 2526 | + texturedata = |
---|
| 2527 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2528 | + bim, |
---|
| 2529 | + true); |
---|
| 2530 | + } catch (Exception e) |
---|
| 2531 | + { |
---|
| 2532 | + throw new javax.media.opengl.GLException(e); |
---|
| 2533 | + } |
---|
| 2534 | + |
---|
| 2535 | + if (bump) |
---|
| 2536 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2537 | + |
---|
| 2538 | + return texturedata; |
---|
2442 | 2539 | } |
---|
2443 | 2540 | |
---|
2444 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3511 | 3608 | |
---|
3512 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3514 | 3613 | // |
---|
3515 | 3614 | if (false) // compressbit > 0) |
---|
3516 | 3615 | { |
---|
.. | .. |
---|
7909 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8010 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8012 | { |
---|
7914 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7924 | 8023 | pigment = null; |
---|
7925 | 8024 | } |
---|
7926 | 8025 | |
---|
7927 | | - ReleaseTexture(bump, true); |
---|
7928 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7929 | 8028 | } |
---|
7930 | 8029 | |
---|
7931 | 8030 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7943 | 8042 | |
---|
7944 | 8043 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8044 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8046 | { |
---|
7948 | 8047 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8048 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7954 | 8053 | pigment = null; |
---|
7955 | 8054 | } |
---|
7956 | 8055 | |
---|
7957 | | - ReleaseTexture(pigment, false); |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
7958 | 8057 | } |
---|
7959 | 8058 | |
---|
7960 | 8059 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7972 | 8071 | |
---|
7973 | 8072 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8073 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8075 | { |
---|
7977 | 8076 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8077 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7983 | 8082 | bump = null; |
---|
7984 | 8083 | } |
---|
7985 | 8084 | |
---|
7986 | | - ReleaseTexture(bump, true); |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
7987 | 8086 | } |
---|
7988 | 8087 | |
---|
7989 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7990 | 8089 | { |
---|
7991 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7992 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7997 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7998 | 8097 | |
---|
7999 | 8098 | if (tex != null) |
---|
8000 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8001 | 8100 | |
---|
8002 | 8101 | // //assert( texture != null ); |
---|
8003 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8091 | 8190 | |
---|
8092 | 8191 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8192 | { |
---|
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 | | - } |
---|
| 8193 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8194 | +// ambientOcclusion ) // || !textureon) |
---|
| 8195 | +// { |
---|
| 8196 | +// return; // false; |
---|
| 8197 | +// } |
---|
| 8198 | +// |
---|
| 8199 | +// if (tex == null) |
---|
| 8200 | +// { |
---|
| 8201 | +// BindTexture(null,false,resolution); |
---|
| 8202 | +// BindTexture(null,true,resolution); |
---|
| 8203 | +// return; |
---|
| 8204 | +// } |
---|
| 8205 | +// |
---|
| 8206 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8207 | +// String bump = Object3D.GetBump(tex); |
---|
| 8208 | +// |
---|
| 8209 | +// usedtextures.add(pigment); |
---|
| 8210 | +// usedtextures.add(bump); |
---|
| 8211 | +// |
---|
| 8212 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8213 | +// { |
---|
| 8214 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8215 | +// // System.out.println("; bump = " + bump); |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// if (bump.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// bump = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// if (pigment.equals("")) |
---|
| 8223 | +// { |
---|
| 8224 | +// pigment = null; |
---|
| 8225 | +// } |
---|
| 8226 | +// |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// BindTexture(pigment, false, resolution); |
---|
| 8229 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8230 | +// BindTexture(bump, true, resolution); |
---|
| 8231 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8232 | +// |
---|
| 8233 | +// return; // true; |
---|
8106 | 8234 | |
---|
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; |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8237 | } |
---|
8136 | 8238 | |
---|
8137 | 8239 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8150 | 8252 | |
---|
8151 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8254 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8255 | + usedtextures.add(tex); |
---|
8154 | 8256 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8258 | { |
---|
8157 | 8259 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8260 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8266 | } |
---|
8165 | 8267 | |
---|
8166 | 8268 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
8168 | 8270 | } |
---|
8169 | 8271 | |
---|
8170 | 8272 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8183 | 8285 | |
---|
8184 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8287 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8187 | 8289 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8291 | { |
---|
8190 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8299 | } |
---|
8198 | 8300 | |
---|
8199 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8201 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8304 | } |
---|
8203 | 8305 | |
---|
.. | .. |
---|
8221 | 8323 | return fileExists; |
---|
8222 | 8324 | } |
---|
8223 | 8325 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8327 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8227 | 8329 | |
---|
8228 | 8330 | if (tex != null) |
---|
8229 | 8331 | { |
---|
8230 | | - String texname = tex; |
---|
| 8332 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8333 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8334 | + |
---|
| 8335 | + if (texname.equals("") && texdata == null) |
---|
| 8336 | + { |
---|
| 8337 | + return null; |
---|
| 8338 | + } |
---|
8231 | 8339 | |
---|
8232 | 8340 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8233 | 8341 | |
---|
.. | .. |
---|
8237 | 8345 | // else |
---|
8238 | 8346 | // if (!texname.startsWith("/")) |
---|
8239 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8240 | | - if (!FileExists(tex)) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8241 | 8349 | { |
---|
8242 | 8350 | texname = fallbackTextureName; |
---|
8243 | 8351 | } |
---|
8244 | 8352 | |
---|
8245 | 8353 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8354 | { |
---|
8252 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8355 | + if (texdata == null) |
---|
| 8356 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8357 | + else |
---|
| 8358 | + texturecache = bimtextures.get(texdata); |
---|
| 8359 | + } |
---|
| 8360 | + |
---|
| 8361 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8362 | + { |
---|
| 8363 | + TextureData texturedata = null; |
---|
| 8364 | + |
---|
| 8365 | + if (texdata != null && textureon) |
---|
| 8366 | + { |
---|
| 8367 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8368 | + |
---|
| 8369 | + try |
---|
| 8370 | + { |
---|
| 8371 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8372 | + } |
---|
| 8373 | + catch (Exception e) |
---|
| 8374 | + { |
---|
| 8375 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8376 | + } |
---|
| 8377 | + |
---|
| 8378 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8379 | + bimtextures.put(texdata, texturecache); |
---|
| 8380 | + |
---|
| 8381 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8382 | + |
---|
| 8383 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8384 | + //bim2 = bim; |
---|
| 8385 | + } |
---|
| 8386 | + else |
---|
| 8387 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8253 | 8388 | { |
---|
8254 | 8389 | assert(!bump); |
---|
8255 | 8390 | // if (bump) |
---|
.. | .. |
---|
8260 | 8395 | // } |
---|
8261 | 8396 | // else |
---|
8262 | 8397 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8265 | 8400 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8268 | 8405 | // } |
---|
8269 | 8406 | } else |
---|
8270 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8408 | { |
---|
8272 | 8409 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8410 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8411 | + if (texturecache == null) |
---|
| 8412 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8413 | + else |
---|
| 8414 | + new Exception().printStackTrace(); |
---|
8276 | 8415 | } else |
---|
8277 | 8416 | { |
---|
8278 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8280 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8281 | 8420 | //} else |
---|
8282 | 8421 | //{ |
---|
8283 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8284 | 8423 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8424 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8425 | + if (texturecache == null) |
---|
| 8426 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8427 | + else |
---|
| 8428 | + new Exception().printStackTrace(); |
---|
8288 | 8429 | } else |
---|
8289 | 8430 | { |
---|
8290 | 8431 | if (textureon) |
---|
.. | .. |
---|
8343 | 8484 | if (texturedata == null) |
---|
8344 | 8485 | throw new Exception(); |
---|
8345 | 8486 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8347 | 8488 | //texture = GetTexture(tex, bump); |
---|
8348 | 8489 | } |
---|
8349 | 8490 | } |
---|
8350 | 8491 | //} |
---|
8351 | 8492 | } |
---|
8352 | 8493 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8495 | { |
---|
8355 | 8496 | //return false; |
---|
8356 | 8497 | |
---|
8357 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8500 | { |
---|
8360 | 8501 | // String ext = "_highres"; |
---|
8361 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8514 | if (!cachefile.exists()) |
---|
8374 | 8515 | { |
---|
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)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8517 | { |
---|
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); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8415 | 8520 | ImageWriter writer = null; |
---|
8416 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8522 | if (iter.hasNext()) { |
---|
8418 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8524 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8421 | 8527 | try |
---|
8422 | 8528 | { |
---|
8423 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8434 | 8540 | } |
---|
8435 | 8541 | } |
---|
8436 | 8542 | } |
---|
8437 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8438 | 8546 | //System.out.println("Texture = " + tex); |
---|
8439 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8440 | 8548 | { |
---|
8441 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8442 | 8550 | thetex.texture.disable(); |
---|
8443 | 8551 | thetex.texture.dispose(); |
---|
8444 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8445 | 8553 | } |
---|
8446 | 8554 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8449 | 8557 | |
---|
8450 | 8558 | // newtex = true; |
---|
8451 | 8559 | } |
---|
.. | .. |
---|
8461 | 8569 | } |
---|
8462 | 8570 | } |
---|
8463 | 8571 | |
---|
8464 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8465 | 8573 | } |
---|
8466 | 8574 | |
---|
8467 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8575 | + static void EmbedTextures(cTexture tex) |
---|
| 8576 | + { |
---|
| 8577 | + if (tex.pigmentdata == null) |
---|
| 8578 | + { |
---|
| 8579 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8580 | + |
---|
| 8581 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8582 | + |
---|
| 8583 | + if (texturecache != null) |
---|
| 8584 | + { |
---|
| 8585 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8586 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8587 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8588 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8589 | + ; |
---|
| 8590 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8591 | + } |
---|
| 8592 | + } |
---|
| 8593 | + |
---|
| 8594 | + if (tex.bumpdata == null) |
---|
| 8595 | + { |
---|
| 8596 | + //String texname = Object3D.GetBump(tex); |
---|
| 8597 | + |
---|
| 8598 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8599 | + |
---|
| 8600 | + if (texturecache != null) |
---|
| 8601 | + { |
---|
| 8602 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8603 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8604 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8605 | + } |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + |
---|
| 8609 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8468 | 8610 | { |
---|
8469 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8470 | 8612 | |
---|
.. | .. |
---|
8482 | 8624 | return texture!=null?texture.texture:null; |
---|
8483 | 8625 | } |
---|
8484 | 8626 | |
---|
8485 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8627 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8486 | 8628 | { |
---|
8487 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8488 | 8630 | |
---|
8489 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8632 | } |
---|
8491 | 8633 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8635 | { |
---|
8494 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8637 | { |
---|
8496 | 8638 | return false; |
---|
8497 | 8639 | } |
---|
8498 | 8640 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8500 | 8642 | |
---|
8501 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8502 | 8644 | |
---|
.. | .. |
---|
8528 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8672 | |
---|
8531 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8532 | 8674 | } |
---|
8533 | 8675 | |
---|
| 8676 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8677 | + { |
---|
| 8678 | + try |
---|
| 8679 | + { |
---|
| 8680 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8681 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8682 | + ImageWriter writer = writers.next(); |
---|
| 8683 | + |
---|
| 8684 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8685 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8686 | + param.setCompressionQuality(quality); |
---|
| 8687 | + |
---|
| 8688 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8689 | + writer.setOutput(ios); |
---|
| 8690 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8691 | + |
---|
| 8692 | + byte[] data = baos.toByteArray(); |
---|
| 8693 | + writer.dispose(); |
---|
| 8694 | + return data; |
---|
| 8695 | + } |
---|
| 8696 | + catch (Exception e) |
---|
| 8697 | + { |
---|
| 8698 | + e.printStackTrace(); |
---|
| 8699 | + return null; |
---|
| 8700 | + } |
---|
| 8701 | + } |
---|
| 8702 | + |
---|
| 8703 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8704 | + { |
---|
| 8705 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8706 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8707 | + ImageReader reader = writers.next(); |
---|
| 8708 | + |
---|
| 8709 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8710 | + |
---|
| 8711 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8712 | + param.setDestination(bim); |
---|
| 8713 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8714 | + |
---|
| 8715 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8716 | + reader.setInput(ios); |
---|
| 8717 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8718 | + reader.dispose(); |
---|
| 8719 | + |
---|
| 8720 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8721 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8722 | +// byte[] bytes = data.getData(); |
---|
| 8723 | +// |
---|
| 8724 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8725 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8726 | +// { |
---|
| 8727 | +// int i3 = i*3; |
---|
| 8728 | +// pixels[i] = 0xFF; |
---|
| 8729 | +// pixels[i] <<= 8; |
---|
| 8730 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8731 | +// pixels[i] <<= 8; |
---|
| 8732 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8733 | +// pixels[i] <<= 8; |
---|
| 8734 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8735 | +// } |
---|
| 8736 | +// |
---|
| 8737 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8738 | + |
---|
| 8739 | + return bim; |
---|
| 8740 | + } |
---|
| 8741 | + |
---|
8534 | 8742 | ShadowBuffer shadowPBuf; |
---|
8535 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8536 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
9366 | 9574 | jy8[3] = 0.5f; |
---|
9367 | 9575 | } |
---|
9368 | 9576 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9577 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9578 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9579 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9580 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9581 | |
---|
| 9582 | + void ResetOptions() |
---|
| 9583 | + { |
---|
| 9584 | + options1[0] = 100; |
---|
| 9585 | + options1[1] = 0.025f; |
---|
| 9586 | + options1[2] = 0.01f; |
---|
| 9587 | + options1[3] = 0; |
---|
| 9588 | + options1[4] = 0; |
---|
| 9589 | + |
---|
| 9590 | + options2[0] = 0; |
---|
| 9591 | + options2[1] = 0.75f; |
---|
| 9592 | + options2[2] = 0; |
---|
| 9593 | + options2[3] = 0; |
---|
| 9594 | + |
---|
| 9595 | + options3[0] = 1; |
---|
| 9596 | + options3[1] = 1; |
---|
| 9597 | + options3[2] = 1; |
---|
| 9598 | + options3[3] = 0; |
---|
| 9599 | + |
---|
| 9600 | + options4[0] = 1; |
---|
| 9601 | + options4[1] = 0; |
---|
| 9602 | + options4[2] = 1; |
---|
| 9603 | + options4[3] = 0; |
---|
| 9604 | + } |
---|
| 9605 | + |
---|
9374 | 9606 | static int imagecount = 0; // movie generation |
---|
9375 | 9607 | |
---|
9376 | 9608 | static int jitter = 0; |
---|
.. | .. |
---|
10481 | 10713 | ANTIALIAS = 0; |
---|
10482 | 10714 | //System.out.println("RESTART"); |
---|
10483 | 10715 | AAtimer.restart(); |
---|
| 10716 | + Globals.TIMERRUNNING = true; |
---|
10484 | 10717 | } |
---|
10485 | 10718 | } |
---|
10486 | 10719 | } |
---|
.. | .. |
---|
10989 | 11222 | |
---|
10990 | 11223 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10991 | 11224 | |
---|
10992 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10993 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10994 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11225 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11226 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11227 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10995 | 11228 | } else |
---|
10996 | 11229 | { |
---|
10997 | 11230 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11002 | 11235 | //System.out.println("BLENDING ON"); |
---|
11003 | 11236 | gl.glEnable(GL.GL_BLEND); |
---|
11004 | 11237 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11005 | | - |
---|
| 11238 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11006 | 11239 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11007 | 11240 | gl.glLoadIdentity(); |
---|
11008 | 11241 | |
---|
.. | .. |
---|
11251 | 11484 | } |
---|
11252 | 11485 | } |
---|
11253 | 11486 | |
---|
11254 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11255 | 11488 | { |
---|
11256 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11257 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11259 | 11492 | |
---|
11260 | 11493 | boolean texon = textureon; |
---|
11261 | 11494 | |
---|
11262 | | - if (RENDERPROGRAM > 0) |
---|
11263 | | - { |
---|
11264 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11265 | | - textureon = false; |
---|
11266 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11267 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11268 | 11499 | //System.out.println("ALLO"); |
---|
11269 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11270 | 11501 | DrawObject(gl); |
---|
11271 | | - if (RENDERPROGRAM > 0) |
---|
11272 | | - { |
---|
11273 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11274 | | - textureon = texon; |
---|
11275 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11276 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11277 | 11507 | |
---|
11278 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11279 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11280 | 11510 | } |
---|
11281 | 11511 | |
---|
11282 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11479 | 11709 | |
---|
11480 | 11710 | void DrawObject(GL gl, boolean draw) |
---|
11481 | 11711 | { |
---|
| 11712 | + // To clear camera values |
---|
| 11713 | + ResetOptions(); |
---|
| 11714 | + |
---|
11482 | 11715 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11483 | 11716 | // DrawMode() = SELECTION; |
---|
11484 | 11717 | //GL gl = getGL(); |
---|
11485 | 11718 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11486 | 11719 | { |
---|
11487 | 11720 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11488 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11721 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11489 | 11722 | pingthread.StepToTarget(true); // true); |
---|
11490 | 11723 | // zoomonce = false; |
---|
11491 | 11724 | } |
---|
.. | .. |
---|
11613 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11614 | 11847 | |
---|
11615 | 11848 | if (CLEANCACHE) |
---|
11616 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11617 | 11850 | { |
---|
11618 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11619 | 11852 | |
---|
11620 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11621 | 11854 | |
---|
11622 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11623 | 11856 | continue; |
---|
11624 | 11857 | |
---|
11625 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11626 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11627 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11628 | | - textures.get(tex).texture.dispose(); |
---|
11629 | | - textures.remove(tex); |
---|
| 11862 | + if (gettex != null) |
---|
| 11863 | + { |
---|
| 11864 | + gettex.texture.dispose(); |
---|
| 11865 | + texturepigment.remove(tex); |
---|
| 11866 | + } |
---|
| 11867 | + |
---|
| 11868 | + gettex = texturebump.get(tex); |
---|
| 11869 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11870 | + if (gettex != null) |
---|
| 11871 | + { |
---|
| 11872 | + gettex.texture.dispose(); |
---|
| 11873 | + texturebump.remove(tex); |
---|
| 11874 | + } |
---|
11630 | 11875 | } |
---|
11631 | 11876 | } |
---|
11632 | 11877 | } |
---|
.. | .. |
---|
12046 | 12291 | for (int i = tp.size(); --i >= 0;) |
---|
12047 | 12292 | { |
---|
12048 | 12293 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12049 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12294 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12050 | 12295 | } |
---|
12051 | 12296 | |
---|
12052 | 12297 | |
---|
.. | .. |
---|
12155 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12156 | 12401 | |
---|
12157 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12158 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
12159 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12160 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
12161 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12270 | 12560 | "TEMP shininess;" + |
---|
12271 | 12561 | "\n" + |
---|
12272 | 12562 | "MOV texSamp, one;" + |
---|
12273 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12274 | | - |
---|
| 12563 | + |
---|
12275 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
12276 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
12277 | 12566 | /* |
---|
.. | .. |
---|
12676 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12677 | 12966 | "") + |
---|
12678 | 12967 | |
---|
12679 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12680 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12681 | 12970 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12682 | 12971 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13108 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13109 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13110 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13111 | 13402 | "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;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13116 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13117 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13118 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13119 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13120 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13121 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13122 | 13411 | |
---|
13123 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13124 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13125 | 13414 | } |
---|
13126 | 13415 | |
---|
13127 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13168 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13169 | 13458 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13170 | 13459 | |
---|
13171 | | - // No shadow when out of frustrum |
---|
| 13460 | + // No shadow when out of frustum |
---|
13172 | 13461 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13173 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13174 | 13463 | ""; |
---|
.. | .. |
---|
13333 | 13622 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13334 | 13623 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13335 | 13624 | //"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;" + |
---|
| 13625 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13626 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13627 | + |
---|
| 13628 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13339 | 13629 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13340 | 13630 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13341 | 13631 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13840 | 14130 | else |
---|
13841 | 14131 | if (evt.getSource() == AAtimer) |
---|
13842 | 14132 | { |
---|
| 14133 | + Globals.TIMERRUNNING = false; |
---|
13843 | 14134 | if (mouseDown) |
---|
13844 | 14135 | { |
---|
13845 | 14136 | //new Exception().printStackTrace(); |
---|
.. | .. |
---|
13899 | 14190 | |
---|
13900 | 14191 | // fev 2014??? |
---|
13901 | 14192 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13902 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14193 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13903 | 14194 | pingthread.StepToTarget(true); // true); |
---|
13904 | 14195 | } |
---|
13905 | 14196 | // if (!LIVE) |
---|
.. | .. |
---|
13914 | 14205 | return; |
---|
13915 | 14206 | |
---|
13916 | 14207 | AAtimer.restart(); // |
---|
| 14208 | + Globals.TIMERRUNNING = true; |
---|
13917 | 14209 | |
---|
13918 | 14210 | // waslive = LIVE; |
---|
13919 | 14211 | // LIVE = false; |
---|
.. | .. |
---|
13963 | 14255 | drag = false; |
---|
13964 | 14256 | //System.out.println("Mouse DOWN"); |
---|
13965 | 14257 | 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); |
---|
| 14258 | + //ClickInfo info = new ClickInfo(); |
---|
| 14259 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14260 | + object.clickInfo.pane = this; |
---|
| 14261 | + object.clickInfo.camera = renderCamera; |
---|
| 14262 | + object.clickInfo.x = x; |
---|
| 14263 | + object.clickInfo.y = y; |
---|
| 14264 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14265 | + editObj = object.doEditClick(//info, |
---|
| 14266 | + 0); |
---|
13974 | 14267 | if (!editObj) |
---|
13975 | 14268 | { |
---|
13976 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
14252 | 14545 | void GoDown(int mod) |
---|
14253 | 14546 | { |
---|
14254 | 14547 | MODIFIERS |= COMMAND; |
---|
14255 | | - /* |
---|
| 14548 | + /**/ |
---|
14256 | 14549 | if((mod&SHIFT) == SHIFT) |
---|
14257 | 14550 | manipCamera.RotatePosition(0, -speed); |
---|
14258 | 14551 | else |
---|
14259 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14260 | | - */ |
---|
| 14552 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14553 | + /**/ |
---|
14261 | 14554 | if ((mod & SHIFT) == SHIFT) |
---|
14262 | 14555 | { |
---|
14263 | 14556 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14273 | 14566 | void GoUp(int mod) |
---|
14274 | 14567 | { |
---|
14275 | 14568 | MODIFIERS |= COMMAND; |
---|
14276 | | - /* |
---|
| 14569 | + /**/ |
---|
14277 | 14570 | if((mod&SHIFT) == SHIFT) |
---|
14278 | 14571 | manipCamera.RotatePosition(0, speed); |
---|
14279 | 14572 | else |
---|
14280 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14281 | | - */ |
---|
| 14573 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14574 | + /**/ |
---|
14282 | 14575 | if ((mod & SHIFT) == SHIFT) |
---|
14283 | 14576 | { |
---|
14284 | 14577 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14294 | 14587 | void GoLeft(int mod) |
---|
14295 | 14588 | { |
---|
14296 | 14589 | MODIFIERS |= COMMAND; |
---|
14297 | | - /* |
---|
| 14590 | + /**/ |
---|
14298 | 14591 | if((mod&SHIFT) == SHIFT) |
---|
14299 | | - manipCamera.RotatePosition(speed, 0); |
---|
14300 | | - else |
---|
14301 | 14592 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14302 | | - */ |
---|
| 14593 | + else |
---|
| 14594 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14595 | + /**/ |
---|
14303 | 14596 | if ((mod & SHIFT) == SHIFT) |
---|
14304 | 14597 | { |
---|
14305 | 14598 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14315 | 14608 | void GoRight(int mod) |
---|
14316 | 14609 | { |
---|
14317 | 14610 | MODIFIERS |= COMMAND; |
---|
14318 | | - /* |
---|
| 14611 | + /**/ |
---|
14319 | 14612 | if((mod&SHIFT) == SHIFT) |
---|
14320 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14321 | | - else |
---|
14322 | 14613 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14323 | | - */ |
---|
| 14614 | + else |
---|
| 14615 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14616 | + /**/ |
---|
14324 | 14617 | if ((mod & SHIFT) == SHIFT) |
---|
14325 | 14618 | { |
---|
14326 | 14619 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14370 | 14663 | if (editObj) |
---|
14371 | 14664 | { |
---|
14372 | 14665 | drag = true; |
---|
14373 | | - ClickInfo info = new ClickInfo(); |
---|
14374 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14375 | 14668 | (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); |
---|
| 14669 | + object.clickInfo.pane = this; |
---|
| 14670 | + object.clickInfo.camera = renderCamera; |
---|
| 14671 | + object.clickInfo.x = x; |
---|
| 14672 | + object.clickInfo.y = y; |
---|
| 14673 | + object //.GetWindow().copy |
---|
| 14674 | + .doEditDrag(//info, |
---|
| 14675 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14382 | 14676 | } else |
---|
14383 | 14677 | { |
---|
14384 | 14678 | if (x < startX) |
---|
.. | .. |
---|
14527 | 14821 | } |
---|
14528 | 14822 | } |
---|
14529 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
14530 | 14826 | public void mouseMoved(MouseEvent e) |
---|
14531 | 14827 | { |
---|
14532 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
14533 | 14829 | if (isRenderer) |
---|
14534 | 14830 | return; |
---|
14535 | 14831 | |
---|
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; |
---|
| 14832 | + // Mouse cursor feedback |
---|
| 14833 | + object.clickInfo.x = e.getX(); |
---|
| 14834 | + object.clickInfo.y = e.getY(); |
---|
| 14835 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14836 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14837 | + object.clickInfo.pane = this; |
---|
| 14838 | + object.clickInfo.camera = renderCamera; |
---|
14543 | 14839 | if (!isRenderer) |
---|
14544 | 14840 | { |
---|
14545 | 14841 | //ObjEditor editWindow = object.editWindow; |
---|
14546 | 14842 | //Object3D copy = editWindow.copy; |
---|
14547 | | - if (object.doEditClick(ci, 0)) |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
14548 | 14845 | { |
---|
14549 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14550 | 14847 | } else |
---|
.. | .. |
---|
14559 | 14856 | Globals.MOUSEDRAGGED = false; |
---|
14560 | 14857 | |
---|
14561 | 14858 | movingcamera = false; |
---|
14562 | | - X = Y = 0; |
---|
| 14859 | + X = 0; // getBounds().width/2; |
---|
| 14860 | + Y = 0; // getBounds().height/2; |
---|
14563 | 14861 | //System.out.println("mouseReleased: " + e); |
---|
14564 | 14862 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14565 | 14863 | } |
---|
.. | .. |
---|
14815 | 15113 | // break; |
---|
14816 | 15114 | case 'T': |
---|
14817 | 15115 | CACHETEXTURE ^= true; |
---|
14818 | | - textures.clear(); |
---|
| 15116 | + texturepigment.clear(); |
---|
| 15117 | + texturebump.clear(); |
---|
14819 | 15118 | // repaint(); |
---|
14820 | 15119 | break; |
---|
14821 | 15120 | case 'Y': |
---|
.. | .. |
---|
14900 | 15199 | case 'E' : COMPACT ^= true; |
---|
14901 | 15200 | repaint(); |
---|
14902 | 15201 | break; |
---|
14903 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15202 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15203 | + //DEBUGHSB ^= true; |
---|
| 15204 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14904 | 15205 | repaint(); |
---|
14905 | 15206 | break; |
---|
14906 | 15207 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14926 | 15227 | repaint(); |
---|
14927 | 15228 | break; |
---|
14928 | 15229 | 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': |
---|
| 15230 | + //case 'L': |
---|
14936 | 15231 | if (lightMode) |
---|
14937 | 15232 | { |
---|
14938 | 15233 | lightMode = false; |
---|
.. | .. |
---|
15075 | 15370 | case '_': |
---|
15076 | 15371 | kompactbit = 5; |
---|
15077 | 15372 | break; |
---|
15078 | | - case '+': |
---|
15079 | | - kompactbit = 6; |
---|
15080 | | - break; |
---|
| 15373 | +// case '+': |
---|
| 15374 | +// kompactbit = 6; |
---|
| 15375 | +// break; |
---|
15081 | 15376 | case ' ': |
---|
15082 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15377 | + lightMode ^= true; |
---|
| 15378 | + Globals.lighttouched = true; |
---|
| 15379 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15380 | + targetLookAt.set(manipCamera.lookAt); |
---|
15083 | 15381 | repaint(); |
---|
15084 | 15382 | break; |
---|
15085 | 15383 | //case '`' : |
---|
.. | .. |
---|
15126 | 15424 | case DELETE: |
---|
15127 | 15425 | ClearSelection(); |
---|
15128 | 15426 | break; |
---|
15129 | | - /* |
---|
15130 | 15427 | case '+': |
---|
| 15428 | + |
---|
| 15429 | + /* |
---|
15131 | 15430 | //fontsize += 1; |
---|
15132 | 15431 | bbzoom *= 2; |
---|
15133 | 15432 | repaint(); |
---|
.. | .. |
---|
15144 | 15443 | case '=': |
---|
15145 | 15444 | IncDepth(); |
---|
15146 | 15445 | //fontsize += 1; |
---|
15147 | | - object.editWindow.refreshContents(true); |
---|
| 15446 | + object.GetWindow().refreshContents(true); |
---|
15148 | 15447 | maskbit = 6; |
---|
15149 | 15448 | break; |
---|
15150 | 15449 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15151 | 15450 | DecDepth(); |
---|
15152 | 15451 | maskbit = 5; |
---|
15153 | 15452 | //if(fontsize > 1) fontsize -= 1; |
---|
15154 | | - if (object.editWindow == null) |
---|
15155 | | - new Exception().printStackTrace(); |
---|
15156 | | - else |
---|
15157 | | - object.editWindow.refreshContents(true); |
---|
| 15453 | +// if (object.editWindow == null) |
---|
| 15454 | +// new Exception().printStackTrace(); |
---|
| 15455 | +// else |
---|
| 15456 | + object.GetWindow().refreshContents(true); |
---|
15158 | 15457 | break; |
---|
15159 | 15458 | case '{': |
---|
15160 | 15459 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15378 | 15677 | } |
---|
15379 | 15678 | */ |
---|
15380 | 15679 | |
---|
15381 | | - object.editWindow.EditSelection(); |
---|
| 15680 | + object.GetWindow().EditSelection(false); |
---|
15382 | 15681 | } |
---|
15383 | 15682 | |
---|
15384 | 15683 | void SelectParent() |
---|
.. | .. |
---|
15395 | 15694 | { |
---|
15396 | 15695 | //selectees.remove(i); |
---|
15397 | 15696 | System.out.println("select parent of " + elem); |
---|
15398 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15697 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15399 | 15698 | } else |
---|
15400 | 15699 | { |
---|
15401 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15700 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15402 | 15701 | } |
---|
15403 | 15702 | |
---|
15404 | 15703 | first = false; |
---|
.. | .. |
---|
15440 | 15739 | for (int j = 0; j < group.children.size(); j++) |
---|
15441 | 15740 | { |
---|
15442 | 15741 | elem = (Object3D) group.children.elementAt(j); |
---|
15443 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15742 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15444 | 15743 | first = false; |
---|
15445 | 15744 | } |
---|
15446 | 15745 | } else |
---|
15447 | 15746 | { |
---|
15448 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15747 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15449 | 15748 | } |
---|
15450 | 15749 | |
---|
15451 | 15750 | first = false; |
---|
.. | .. |
---|
15456 | 15755 | { |
---|
15457 | 15756 | //Composite group = (Composite) object; |
---|
15458 | 15757 | Object3D group = object; |
---|
15459 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15758 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15460 | 15759 | } |
---|
15461 | 15760 | |
---|
15462 | 15761 | void ResetTransform(int mask) |
---|
15463 | 15762 | { |
---|
15464 | 15763 | //Composite group = (Composite) object; |
---|
15465 | 15764 | Object3D group = object; |
---|
15466 | | - group.editWindow.ResetTransform(mask); |
---|
| 15765 | + group.GetWindow().ResetTransform(mask); |
---|
15467 | 15766 | } |
---|
15468 | 15767 | |
---|
15469 | 15768 | void FlipTransform() |
---|
15470 | 15769 | { |
---|
15471 | 15770 | //Composite group = (Composite) object; |
---|
15472 | 15771 | Object3D group = object; |
---|
15473 | | - group.editWindow.FlipTransform(); |
---|
| 15772 | + group.GetWindow().FlipTransform(); |
---|
15474 | 15773 | // group.editWindow.ReduceMesh(true); |
---|
15475 | 15774 | } |
---|
15476 | 15775 | |
---|
.. | .. |
---|
15478 | 15777 | { |
---|
15479 | 15778 | //Composite group = (Composite) object; |
---|
15480 | 15779 | Object3D group = object; |
---|
15481 | | - group.editWindow.PrintMemory(); |
---|
| 15780 | + group.GetWindow().PrintMemory(); |
---|
15482 | 15781 | // group.editWindow.ReduceMesh(true); |
---|
15483 | 15782 | } |
---|
15484 | 15783 | |
---|
.. | .. |
---|
15486 | 15785 | { |
---|
15487 | 15786 | //Composite group = (Composite) object; |
---|
15488 | 15787 | Object3D group = object; |
---|
15489 | | - group.editWindow.ResetCentroid(); |
---|
| 15788 | + group.GetWindow().ResetCentroid(); |
---|
15490 | 15789 | } |
---|
15491 | 15790 | |
---|
15492 | 15791 | void IncDepth() |
---|
.. | .. |
---|
15568 | 15867 | |
---|
15569 | 15868 | int width = getBounds().width; |
---|
15570 | 15869 | int height = getBounds().height; |
---|
15571 | | - ClickInfo info = new ClickInfo(); |
---|
15572 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15573 | 15870 | //Image img = CreateImage(width, height); |
---|
15574 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15575 | 15872 | |
---|
.. | .. |
---|
15646 | 15943 | } |
---|
15647 | 15944 | if (object != null && !hasMarquee) |
---|
15648 | 15945 | { |
---|
| 15946 | + if (object.clickInfo == null) |
---|
| 15947 | + object.clickInfo = new ClickInfo(); |
---|
| 15948 | + ClickInfo info = object.clickInfo; |
---|
| 15949 | + //ClickInfo info = new ClickInfo(); |
---|
| 15950 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15951 | + |
---|
15649 | 15952 | if (isRenderer) |
---|
15650 | 15953 | { |
---|
15651 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
15652 | 15955 | double frameAspect = (double) width / (double) height; |
---|
15653 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
15654 | 15957 | { |
---|
15655 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15656 | | - info.bounds.width -= width - desired; |
---|
15657 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15658 | 15961 | } else |
---|
15659 | 15962 | { |
---|
15660 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15661 | | - info.bounds.height -= height - desired; |
---|
15662 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15663 | 15966 | } |
---|
15664 | 15967 | } |
---|
15665 | | - info.g = gr; |
---|
15666 | | - info.camera = renderCamera; |
---|
| 15968 | + |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
15667 | 15971 | /* |
---|
15668 | 15972 | // Memory intensive (brep.verticescopy) |
---|
15669 | 15973 | if (!(object instanceof Composite)) |
---|
15670 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
15671 | 15975 | */ |
---|
15672 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
15673 | 15977 | { |
---|
15674 | | - object.drawEditHandles(info, 0); |
---|
15675 | | - |
---|
15676 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15978 | + Grafreed.Assert(object != null); |
---|
| 15979 | + Grafreed.Assert(object.selection != null); |
---|
| 15980 | + if (object.selection.Size() > 0) |
---|
15677 | 15981 | { |
---|
15678 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15982 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15983 | + |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
| 15987 | + if (hitSomething == Object3D.hitCenter) |
---|
15679 | 15988 | { |
---|
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; |
---|
| 15989 | + info.DX = X; |
---|
| 15990 | + if (X != 0) |
---|
| 15991 | + info.DX -= info.bounds.width/2; |
---|
| 15992 | + |
---|
| 15993 | + info.DY = Y; |
---|
| 15994 | + if (Y != 0) |
---|
| 15995 | + info.DY -= info.bounds.height/2; |
---|
15689 | 15996 | } |
---|
15690 | | - |
---|
| 15997 | + |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
| 16000 | + |
---|
| 16001 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16002 | + { |
---|
| 16003 | + switch (hitSomething) |
---|
| 16004 | + { |
---|
| 16005 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16006 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16007 | + break; |
---|
| 16008 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16009 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16010 | + break; |
---|
| 16011 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
| 16013 | + break; |
---|
| 16014 | + } |
---|
| 16015 | + |
---|
| 16016 | + } |
---|
15691 | 16017 | } |
---|
15692 | 16018 | } |
---|
15693 | 16019 | } |
---|
.. | .. |
---|
16485 | 16811 | } |
---|
16486 | 16812 | } |
---|
16487 | 16813 | |
---|
| 16814 | + private Object3D GetFolder() |
---|
| 16815 | + { |
---|
| 16816 | + Object3D folder = object.GetWindow().copy; |
---|
| 16817 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16818 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16819 | + return folder; |
---|
| 16820 | + } |
---|
| 16821 | + |
---|
16488 | 16822 | class SelectBuffer implements GLEventListener |
---|
16489 | 16823 | { |
---|
16490 | 16824 | |
---|
.. | .. |
---|
16564 | 16898 | |
---|
16565 | 16899 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16566 | 16900 | |
---|
| 16901 | + if (PAINTMODE) |
---|
| 16902 | + { |
---|
| 16903 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16904 | + { |
---|
| 16905 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16906 | + |
---|
| 16907 | + // Make what you paint not selectable. |
---|
| 16908 | + paintobj.ResetSelectable(); |
---|
| 16909 | + } |
---|
| 16910 | + } |
---|
| 16911 | + |
---|
16567 | 16912 | //int tmp = selection_view; |
---|
16568 | 16913 | //selection_view = -1; |
---|
16569 | 16914 | int temp = DrawMode(); |
---|
.. | .. |
---|
16575 | 16920 | // temp = DEFAULT; // patch for selection debug |
---|
16576 | 16921 | Globals.drawMode = temp; // WARNING |
---|
16577 | 16922 | |
---|
| 16923 | + if (PAINTMODE) |
---|
| 16924 | + { |
---|
| 16925 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16926 | + { |
---|
| 16927 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16928 | + |
---|
| 16929 | + // Revert. |
---|
| 16930 | + paintobj.RestoreSelectable(); |
---|
| 16931 | + } |
---|
| 16932 | + } |
---|
| 16933 | + |
---|
16578 | 16934 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16579 | 16935 | |
---|
16580 | 16936 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16678 | 17034 | } |
---|
16679 | 17035 | |
---|
16680 | 17036 | if (!movingcamera && !PAINTMODE) |
---|
16681 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17037 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16682 | 17038 | |
---|
16683 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17039 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16684 | 17040 | { |
---|
16685 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17041 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16686 | 17042 | |
---|
16687 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17043 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17044 | + { |
---|
| 17045 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16688 | 17046 | |
---|
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(); |
---|
| 17047 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17048 | + |
---|
| 17049 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17050 | + |
---|
| 17051 | + inst.add(paintobj); // link |
---|
| 17052 | + |
---|
| 17053 | + object.GetWindow().SnapObject(inst); |
---|
| 17054 | + |
---|
| 17055 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17056 | + |
---|
| 17057 | + folder.add(inst); |
---|
| 17058 | + |
---|
| 17059 | + object.GetWindow().ResetModel(); |
---|
| 17060 | + object.GetWindow().refreshContents(); |
---|
| 17061 | + } |
---|
16704 | 17062 | } |
---|
16705 | 17063 | else |
---|
16706 | 17064 | paintcount = 0; |
---|
.. | .. |
---|
16739 | 17097 | //System.out.println("objects[color] = " + objects[color]); |
---|
16740 | 17098 | //objects[color].Select(); |
---|
16741 | 17099 | indexcount = 0; |
---|
| 17100 | + ObjEditor window = object.GetWindow(); |
---|
| 17101 | + if (window != null && deselect) |
---|
| 17102 | + { |
---|
| 17103 | + window.Select(null, deselect, true); |
---|
| 17104 | + } |
---|
16742 | 17105 | object.Select(color, deselect); |
---|
16743 | 17106 | } |
---|
16744 | 17107 | |
---|