.. | .. |
---|
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; |
---|
.. | .. |
---|
169 | 206 | |
---|
170 | 207 | SetCamera(cam); |
---|
171 | 208 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 209 | + // Warning: not used. |
---|
| 210 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 211 | |
---|
174 | 212 | object = o; |
---|
175 | 213 | |
---|
.. | .. |
---|
335 | 373 | display.options1[2] = material.shadowbias; |
---|
336 | 374 | display.options1[3] = material.aniso; |
---|
337 | 375 | display.options1[4] = material.anisoV; |
---|
| 376 | +// System.out.println("display.options1[0] " + display.options1[0]); |
---|
| 377 | +// System.out.println("display.options1[1] " + display.options1[1]); |
---|
| 378 | +// System.out.println("display.options1[2] " + display.options1[2]); |
---|
| 379 | +// System.out.println("display.options1[3] " + display.options1[3]); |
---|
| 380 | +// System.out.println("display.options1[4] " + display.options1[4]); |
---|
338 | 381 | display.options2[0] = material.opacity; |
---|
339 | 382 | display.options2[1] = material.diffuse; |
---|
340 | 383 | display.options2[2] = material.factor; |
---|
| 384 | +// System.out.println("display.options2[0] " + display.options2[0]); |
---|
| 385 | +// System.out.println("display.options2[1] " + display.options2[1]); |
---|
| 386 | +// System.out.println("display.options2[2] " + display.options2[2]); |
---|
341 | 387 | |
---|
342 | 388 | cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3); |
---|
| 389 | +// System.out.println("display.options3[0] " + display.options3[0]); |
---|
| 390 | +// System.out.println("display.options3[1] " + display.options3[1]); |
---|
| 391 | +// System.out.println("display.options3[2] " + display.options3[2]); |
---|
343 | 392 | display.options4[0] = material.cameralight/0.2f; |
---|
344 | 393 | display.options4[1] = material.subsurface; |
---|
345 | 394 | display.options4[2] = material.sheen; |
---|
| 395 | +// System.out.println("display.options4[0] " + display.options4[0]); |
---|
| 396 | +// System.out.println("display.options4[1] " + display.options4[1]); |
---|
| 397 | +// System.out.println("display.options4[2] " + display.options4[2]); |
---|
346 | 398 | |
---|
347 | 399 | // if (display.CURRENTANTIALIAS > 0) |
---|
348 | 400 | // display.options3[3] /= 4; |
---|
.. | .. |
---|
2051 | 2103 | //System.err.println("Oeil on"); |
---|
2052 | 2104 | OEIL = true; |
---|
2053 | 2105 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2054 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2106 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2055 | 2107 | //pingthread.StepToTarget(true); |
---|
2056 | 2108 | } |
---|
2057 | 2109 | |
---|
.. | .. |
---|
2284 | 2336 | HANDLES ^= true; |
---|
2285 | 2337 | } |
---|
2286 | 2338 | |
---|
| 2339 | + Object3D paintFolder; |
---|
| 2340 | + |
---|
2287 | 2341 | void TogglePaint() |
---|
2288 | 2342 | { |
---|
2289 | 2343 | PAINTMODE ^= true; |
---|
2290 | 2344 | paintcount = 0; |
---|
| 2345 | + |
---|
| 2346 | + if (PAINTMODE) |
---|
| 2347 | + { |
---|
| 2348 | + paintFolder = GetFolder(); |
---|
| 2349 | + } |
---|
2291 | 2350 | } |
---|
2292 | 2351 | |
---|
2293 | 2352 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2384 | 2443 | return currentGL; |
---|
2385 | 2444 | } |
---|
2386 | 2445 | |
---|
| 2446 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2447 | + { |
---|
| 2448 | + Grafreed.Assert(texturedata != null); |
---|
| 2449 | + |
---|
| 2450 | + int width = texturedata.getWidth(); |
---|
| 2451 | + int height = texturedata.getHeight(); |
---|
| 2452 | + |
---|
| 2453 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2454 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2455 | + |
---|
| 2456 | + byte[] bytes = bytebuf.array(); |
---|
| 2457 | + |
---|
| 2458 | + return CreateBim(bytes, width, height); |
---|
| 2459 | + } |
---|
| 2460 | + |
---|
2387 | 2461 | /**/ |
---|
2388 | 2462 | class CacheTexture |
---|
2389 | 2463 | { |
---|
.. | .. |
---|
2392 | 2466 | |
---|
2393 | 2467 | int resolution; |
---|
2394 | 2468 | |
---|
2395 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2469 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2396 | 2470 | { |
---|
2397 | | - texture = tex; |
---|
| 2471 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2472 | + texturedata = texdata; |
---|
2398 | 2473 | resolution = res; |
---|
2399 | 2474 | } |
---|
2400 | 2475 | } |
---|
2401 | 2476 | /**/ |
---|
2402 | 2477 | |
---|
2403 | 2478 | // 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>(); |
---|
| 2479 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2480 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2481 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2482 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2483 | + |
---|
2407 | 2484 | int pigmentdepth = 0; |
---|
2408 | 2485 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2409 | 2486 | int bumpdepth = 0; |
---|
2410 | 2487 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2411 | 2488 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2412 | 2489 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2413 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2490 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2414 | 2491 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2415 | 2492 | |
---|
2416 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2493 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2417 | 2494 | { |
---|
2418 | 2495 | TextureData texturedata = null; |
---|
2419 | 2496 | |
---|
.. | .. |
---|
2432 | 2509 | if (bump) |
---|
2433 | 2510 | texturedata = ConvertBump(texturedata, false); |
---|
2434 | 2511 | |
---|
2435 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2436 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2512 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2513 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2437 | 2514 | |
---|
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); |
---|
| 2515 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2516 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2440 | 2517 | |
---|
2441 | | - return texture; |
---|
| 2518 | + return texturedata; |
---|
| 2519 | + } |
---|
| 2520 | + |
---|
| 2521 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2522 | + { |
---|
| 2523 | + TextureData texturedata = null; |
---|
| 2524 | + |
---|
| 2525 | + try |
---|
| 2526 | + { |
---|
| 2527 | + texturedata = |
---|
| 2528 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2529 | + bim, |
---|
| 2530 | + true); |
---|
| 2531 | + } catch (Exception e) |
---|
| 2532 | + { |
---|
| 2533 | + throw new javax.media.opengl.GLException(e); |
---|
| 2534 | + } |
---|
| 2535 | + |
---|
| 2536 | + if (bump) |
---|
| 2537 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2538 | + |
---|
| 2539 | + return texturedata; |
---|
2442 | 2540 | } |
---|
2443 | 2541 | |
---|
2444 | 2542 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3511 | 3609 | |
---|
3512 | 3610 | System.out.println("LOADING TEXTURE : " + name); |
---|
3513 | 3611 | |
---|
| 3612 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3613 | + |
---|
3514 | 3614 | // |
---|
3515 | 3615 | if (false) // compressbit > 0) |
---|
3516 | 3616 | { |
---|
.. | .. |
---|
7909 | 8009 | String pigment = Object3D.GetPigment(tex); |
---|
7910 | 8010 | String bump = Object3D.GetBump(tex); |
---|
7911 | 8011 | |
---|
7912 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8012 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7913 | 8013 | { |
---|
7914 | 8014 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7915 | 8015 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7924 | 8024 | pigment = null; |
---|
7925 | 8025 | } |
---|
7926 | 8026 | |
---|
7927 | | - ReleaseTexture(bump, true); |
---|
7928 | | - ReleaseTexture(pigment, false); |
---|
| 8027 | + ReleaseTexture(tex, true); |
---|
| 8028 | + ReleaseTexture(tex, false); |
---|
7929 | 8029 | } |
---|
7930 | 8030 | |
---|
7931 | 8031 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7943 | 8043 | |
---|
7944 | 8044 | String pigment = Object3D.GetPigment(tex); |
---|
7945 | 8045 | |
---|
7946 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8046 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7947 | 8047 | { |
---|
7948 | 8048 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7949 | 8049 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7954 | 8054 | pigment = null; |
---|
7955 | 8055 | } |
---|
7956 | 8056 | |
---|
7957 | | - ReleaseTexture(pigment, false); |
---|
| 8057 | + ReleaseTexture(tex, false); |
---|
7958 | 8058 | } |
---|
7959 | 8059 | |
---|
7960 | 8060 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7972 | 8072 | |
---|
7973 | 8073 | String bump = Object3D.GetBump(tex); |
---|
7974 | 8074 | |
---|
7975 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8075 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7976 | 8076 | { |
---|
7977 | 8077 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7978 | 8078 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7983 | 8083 | bump = null; |
---|
7984 | 8084 | } |
---|
7985 | 8085 | |
---|
7986 | | - ReleaseTexture(bump, true); |
---|
| 8086 | + ReleaseTexture(tex, true); |
---|
7987 | 8087 | } |
---|
7988 | 8088 | |
---|
7989 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8089 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
7990 | 8090 | { |
---|
7991 | 8091 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
7992 | 8092 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
7997 | 8097 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
7998 | 8098 | |
---|
7999 | 8099 | if (tex != null) |
---|
8000 | | - texture = textures.get(tex); |
---|
| 8100 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8001 | 8101 | |
---|
8002 | 8102 | // //assert( texture != null ); |
---|
8003 | 8103 | // if (texture == null) |
---|
.. | .. |
---|
8091 | 8191 | |
---|
8092 | 8192 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8093 | 8193 | { |
---|
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 | | - } |
---|
| 8194 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8195 | +// ambientOcclusion ) // || !textureon) |
---|
| 8196 | +// { |
---|
| 8197 | +// return; // false; |
---|
| 8198 | +// } |
---|
| 8199 | +// |
---|
| 8200 | +// if (tex == null) |
---|
| 8201 | +// { |
---|
| 8202 | +// BindTexture(null,false,resolution); |
---|
| 8203 | +// BindTexture(null,true,resolution); |
---|
| 8204 | +// return; |
---|
| 8205 | +// } |
---|
| 8206 | +// |
---|
| 8207 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8208 | +// String bump = Object3D.GetBump(tex); |
---|
| 8209 | +// |
---|
| 8210 | +// usedtextures.add(pigment); |
---|
| 8211 | +// usedtextures.add(bump); |
---|
| 8212 | +// |
---|
| 8213 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8214 | +// { |
---|
| 8215 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8216 | +// // System.out.println("; bump = " + bump); |
---|
| 8217 | +// } |
---|
| 8218 | +// |
---|
| 8219 | +// if (bump.equals("")) |
---|
| 8220 | +// { |
---|
| 8221 | +// bump = null; |
---|
| 8222 | +// } |
---|
| 8223 | +// if (pigment.equals("")) |
---|
| 8224 | +// { |
---|
| 8225 | +// pigment = null; |
---|
| 8226 | +// } |
---|
| 8227 | +// |
---|
| 8228 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8229 | +// BindTexture(pigment, false, resolution); |
---|
| 8230 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8231 | +// BindTexture(bump, true, resolution); |
---|
| 8232 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8233 | +// |
---|
| 8234 | +// return; // true; |
---|
8106 | 8235 | |
---|
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; |
---|
| 8236 | + BindPigmentTexture(tex, resolution); |
---|
| 8237 | + BindBumpTexture(tex, resolution); |
---|
8135 | 8238 | } |
---|
8136 | 8239 | |
---|
8137 | 8240 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8150 | 8253 | |
---|
8151 | 8254 | String pigment = Object3D.GetPigment(tex); |
---|
8152 | 8255 | |
---|
8153 | | - usedtextures.put(pigment, pigment); |
---|
| 8256 | + usedtextures.add(tex); |
---|
8154 | 8257 | |
---|
8155 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8258 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8156 | 8259 | { |
---|
8157 | 8260 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8158 | 8261 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8164 | 8267 | } |
---|
8165 | 8268 | |
---|
8166 | 8269 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8167 | | - BindTexture(pigment, false, resolution); |
---|
| 8270 | + BindTexture(tex, false, resolution); |
---|
8168 | 8271 | } |
---|
8169 | 8272 | |
---|
8170 | 8273 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8183 | 8286 | |
---|
8184 | 8287 | String bump = Object3D.GetBump(tex); |
---|
8185 | 8288 | |
---|
8186 | | - usedtextures.put(bump, bump); |
---|
| 8289 | + usedtextures.add(tex); |
---|
8187 | 8290 | |
---|
8188 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8291 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8189 | 8292 | { |
---|
8190 | 8293 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8191 | 8294 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8197 | 8300 | } |
---|
8198 | 8301 | |
---|
8199 | 8302 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8200 | | - BindTexture(bump, true, resolution); |
---|
| 8303 | + BindTexture(tex, true, resolution); |
---|
8201 | 8304 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8202 | 8305 | } |
---|
8203 | 8306 | |
---|
.. | .. |
---|
8221 | 8324 | return fileExists; |
---|
8222 | 8325 | } |
---|
8223 | 8326 | |
---|
8224 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8327 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8225 | 8328 | { |
---|
8226 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8329 | + CacheTexture texturecache = null; |
---|
8227 | 8330 | |
---|
8228 | 8331 | if (tex != null) |
---|
8229 | 8332 | { |
---|
8230 | | - String texname = tex; |
---|
| 8333 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8334 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8335 | + |
---|
| 8336 | + if (texname.equals("") && texdata == null) |
---|
| 8337 | + { |
---|
| 8338 | + return null; |
---|
| 8339 | + } |
---|
8231 | 8340 | |
---|
8232 | 8341 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8233 | 8342 | |
---|
.. | .. |
---|
8237 | 8346 | // else |
---|
8238 | 8347 | // if (!texname.startsWith("/")) |
---|
8239 | 8348 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8240 | | - if (!FileExists(tex)) |
---|
| 8349 | + if (!FileExists(texname)) |
---|
8241 | 8350 | { |
---|
8242 | 8351 | texname = fallbackTextureName; |
---|
8243 | 8352 | } |
---|
8244 | 8353 | |
---|
8245 | 8354 | if (CACHETEXTURE) |
---|
8246 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8247 | | - |
---|
8248 | | - TextureData texturedata = null; |
---|
8249 | | - |
---|
8250 | | - if (texture == null || texture.resolution < resolution) |
---|
8251 | 8355 | { |
---|
8252 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8356 | + if (texdata == null) |
---|
| 8357 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8358 | + else |
---|
| 8359 | + texturecache = bimtextures.get(texdata); |
---|
| 8360 | + } |
---|
| 8361 | + |
---|
| 8362 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8363 | + { |
---|
| 8364 | + TextureData texturedata = null; |
---|
| 8365 | + |
---|
| 8366 | + if (texdata != null && textureon) |
---|
| 8367 | + { |
---|
| 8368 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8369 | + |
---|
| 8370 | + try |
---|
| 8371 | + { |
---|
| 8372 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8373 | + } |
---|
| 8374 | + catch (Exception e) |
---|
| 8375 | + { |
---|
| 8376 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8377 | + } |
---|
| 8378 | + |
---|
| 8379 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8380 | + bimtextures.put(texdata, texturecache); |
---|
| 8381 | + |
---|
| 8382 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8383 | + |
---|
| 8384 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8385 | + //bim2 = bim; |
---|
| 8386 | + } |
---|
| 8387 | + else |
---|
| 8388 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8253 | 8389 | { |
---|
8254 | 8390 | assert(!bump); |
---|
8255 | 8391 | // if (bump) |
---|
.. | .. |
---|
8260 | 8396 | // } |
---|
8261 | 8397 | // else |
---|
8262 | 8398 | // { |
---|
8263 | | - texture = textures.get(tex); |
---|
8264 | | - if (texture == null) |
---|
| 8399 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8400 | + if (texturecache == null) |
---|
8265 | 8401 | { |
---|
8266 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8402 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8267 | 8403 | } |
---|
| 8404 | + else |
---|
| 8405 | + new Exception().printStackTrace(); |
---|
8268 | 8406 | // } |
---|
8269 | 8407 | } else |
---|
8270 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8408 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8271 | 8409 | { |
---|
8272 | 8410 | assert(bump); |
---|
8273 | | - texture = textures.get(tex); |
---|
8274 | | - if (texture == null) |
---|
8275 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8411 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8412 | + if (texturecache == null) |
---|
| 8413 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8414 | + else |
---|
| 8415 | + new Exception().printStackTrace(); |
---|
8276 | 8416 | } else |
---|
8277 | 8417 | { |
---|
8278 | 8418 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8280 | 8420 | // texture = GetResourceTexture("default.png"); |
---|
8281 | 8421 | //} else |
---|
8282 | 8422 | //{ |
---|
8283 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8423 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8284 | 8424 | { |
---|
8285 | | - texture = textures.get(tex); |
---|
8286 | | - if (texture == null) |
---|
8287 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8425 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8426 | + if (texturecache == null) |
---|
| 8427 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8428 | + else |
---|
| 8429 | + new Exception().printStackTrace(); |
---|
8288 | 8430 | } else |
---|
8289 | 8431 | { |
---|
8290 | 8432 | if (textureon) |
---|
.. | .. |
---|
8343 | 8485 | if (texturedata == null) |
---|
8344 | 8486 | throw new Exception(); |
---|
8345 | 8487 | |
---|
8346 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8488 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8347 | 8489 | //texture = GetTexture(tex, bump); |
---|
8348 | 8490 | } |
---|
8349 | 8491 | } |
---|
8350 | 8492 | //} |
---|
8351 | 8493 | } |
---|
8352 | 8494 | |
---|
8353 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8495 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8354 | 8496 | { |
---|
8355 | 8497 | //return false; |
---|
8356 | 8498 | |
---|
8357 | 8499 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8358 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8500 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8359 | 8501 | { |
---|
8360 | 8502 | // String ext = "_highres"; |
---|
8361 | 8503 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8372 | 8514 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8373 | 8515 | if (!cachefile.exists()) |
---|
8374 | 8516 | { |
---|
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)) |
---|
| 8517 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8384 | 8518 | { |
---|
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); |
---|
| 8519 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8520 | + |
---|
8415 | 8521 | ImageWriter writer = null; |
---|
8416 | 8522 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8417 | 8523 | if (iter.hasNext()) { |
---|
8418 | 8524 | writer = (ImageWriter)iter.next(); |
---|
8419 | 8525 | } |
---|
8420 | | - float compressionQuality = 0.9f; |
---|
| 8526 | + |
---|
| 8527 | + float compressionQuality = 0.85f; |
---|
8421 | 8528 | try |
---|
8422 | 8529 | { |
---|
8423 | 8530 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8434 | 8541 | } |
---|
8435 | 8542 | } |
---|
8436 | 8543 | } |
---|
8437 | | - |
---|
| 8544 | + |
---|
| 8545 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8546 | + |
---|
8438 | 8547 | //System.out.println("Texture = " + tex); |
---|
8439 | | - if (textures.containsKey(texname)) |
---|
| 8548 | + if (textures.containsKey(tex)) |
---|
8440 | 8549 | { |
---|
8441 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8550 | + CacheTexture thetex = textures.get(tex); |
---|
8442 | 8551 | thetex.texture.disable(); |
---|
8443 | 8552 | thetex.texture.dispose(); |
---|
8444 | | - textures.remove(texname); |
---|
| 8553 | + textures.remove(tex); |
---|
8445 | 8554 | } |
---|
8446 | 8555 | |
---|
8447 | | - texture.texturedata = texturedata; |
---|
8448 | | - textures.put(texname, texture); |
---|
| 8556 | + //texture.texturedata = texturedata; |
---|
| 8557 | + textures.put(tex, texturecache); |
---|
8449 | 8558 | |
---|
8450 | 8559 | // newtex = true; |
---|
8451 | 8560 | } |
---|
.. | .. |
---|
8461 | 8570 | } |
---|
8462 | 8571 | } |
---|
8463 | 8572 | |
---|
8464 | | - return texture; |
---|
| 8573 | + return texturecache; |
---|
8465 | 8574 | } |
---|
8466 | 8575 | |
---|
8467 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8576 | + static void EmbedTextures(cTexture tex) |
---|
| 8577 | + { |
---|
| 8578 | + if (tex.pigmentdata == null) |
---|
| 8579 | + { |
---|
| 8580 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8581 | + |
---|
| 8582 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8583 | + |
---|
| 8584 | + if (texturecache != null) |
---|
| 8585 | + { |
---|
| 8586 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8587 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8588 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8589 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8590 | + ; |
---|
| 8591 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8592 | + } |
---|
| 8593 | + } |
---|
| 8594 | + |
---|
| 8595 | + if (tex.bumpdata == null) |
---|
| 8596 | + { |
---|
| 8597 | + //String texname = Object3D.GetBump(tex); |
---|
| 8598 | + |
---|
| 8599 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8600 | + |
---|
| 8601 | + if (texturecache != null) |
---|
| 8602 | + { |
---|
| 8603 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8604 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8605 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8606 | + } |
---|
| 8607 | + } |
---|
| 8608 | + } |
---|
| 8609 | + |
---|
| 8610 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8468 | 8611 | { |
---|
8469 | 8612 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8470 | 8613 | |
---|
.. | .. |
---|
8482 | 8625 | return texture!=null?texture.texture:null; |
---|
8483 | 8626 | } |
---|
8484 | 8627 | |
---|
8485 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8628 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8486 | 8629 | { |
---|
8487 | 8630 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8488 | 8631 | |
---|
8489 | 8632 | return texture!=null?texture.texturedata:null; |
---|
8490 | 8633 | } |
---|
8491 | 8634 | |
---|
8492 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8635 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8493 | 8636 | { |
---|
8494 | 8637 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8495 | 8638 | { |
---|
8496 | 8639 | return false; |
---|
8497 | 8640 | } |
---|
8498 | 8641 | |
---|
8499 | | - boolean newtex = false; |
---|
| 8642 | + //boolean newtex = false; |
---|
8500 | 8643 | |
---|
8501 | 8644 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8502 | 8645 | |
---|
.. | .. |
---|
8528 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8529 | 8672 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8530 | 8673 | |
---|
8531 | | - return newtex; |
---|
| 8674 | + return true; // Warning: not used. |
---|
8532 | 8675 | } |
---|
8533 | 8676 | |
---|
| 8677 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8678 | + { |
---|
| 8679 | + try |
---|
| 8680 | + { |
---|
| 8681 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8682 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8683 | + ImageWriter writer = writers.next(); |
---|
| 8684 | + |
---|
| 8685 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8686 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8687 | + param.setCompressionQuality(quality); |
---|
| 8688 | + |
---|
| 8689 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8690 | + writer.setOutput(ios); |
---|
| 8691 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8692 | + |
---|
| 8693 | + byte[] data = baos.toByteArray(); |
---|
| 8694 | + writer.dispose(); |
---|
| 8695 | + return data; |
---|
| 8696 | + } |
---|
| 8697 | + catch (Exception e) |
---|
| 8698 | + { |
---|
| 8699 | + e.printStackTrace(); |
---|
| 8700 | + return null; |
---|
| 8701 | + } |
---|
| 8702 | + } |
---|
| 8703 | + |
---|
| 8704 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8705 | + { |
---|
| 8706 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8707 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8708 | + ImageReader reader = writers.next(); |
---|
| 8709 | + |
---|
| 8710 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8711 | + |
---|
| 8712 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8713 | + param.setDestination(bim); |
---|
| 8714 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8715 | + |
---|
| 8716 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8717 | + reader.setInput(ios); |
---|
| 8718 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8719 | + reader.dispose(); |
---|
| 8720 | + |
---|
| 8721 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8722 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8723 | +// byte[] bytes = data.getData(); |
---|
| 8724 | +// |
---|
| 8725 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8726 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8727 | +// { |
---|
| 8728 | +// int i3 = i*3; |
---|
| 8729 | +// pixels[i] = 0xFF; |
---|
| 8730 | +// pixels[i] <<= 8; |
---|
| 8731 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8732 | +// pixels[i] <<= 8; |
---|
| 8733 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8734 | +// pixels[i] <<= 8; |
---|
| 8735 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8736 | +// } |
---|
| 8737 | +// |
---|
| 8738 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8739 | + |
---|
| 8740 | + return bim; |
---|
| 8741 | + } |
---|
| 8742 | + |
---|
8534 | 8743 | ShadowBuffer shadowPBuf; |
---|
8535 | 8744 | AntialiasBuffer antialiasPBuf; |
---|
8536 | 8745 | int MAXSTACK; |
---|
.. | .. |
---|
9366 | 9575 | jy8[3] = 0.5f; |
---|
9367 | 9576 | } |
---|
9368 | 9577 | |
---|
9369 | | - float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
| 9578 | + float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV |
---|
9370 | 9579 | float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation |
---|
9371 | 9580 | float[] options3 = new float[]{1, 1, 1, 0}; // fog color |
---|
9372 | 9581 | float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen |
---|
9373 | 9582 | |
---|
| 9583 | + void ResetOptions() |
---|
| 9584 | + { |
---|
| 9585 | + options1[0] = 100; |
---|
| 9586 | + options1[1] = 0.025f; |
---|
| 9587 | + options1[2] = 0.01f; |
---|
| 9588 | + options1[3] = 0; |
---|
| 9589 | + options1[4] = 0; |
---|
| 9590 | + |
---|
| 9591 | + options2[0] = 0; |
---|
| 9592 | + options2[1] = 0.75f; |
---|
| 9593 | + options2[2] = 0; |
---|
| 9594 | + options2[3] = 0; |
---|
| 9595 | + |
---|
| 9596 | + options3[0] = 1; |
---|
| 9597 | + options3[1] = 1; |
---|
| 9598 | + options3[2] = 1; |
---|
| 9599 | + options3[3] = 0; |
---|
| 9600 | + |
---|
| 9601 | + options4[0] = 1; |
---|
| 9602 | + options4[1] = 0; |
---|
| 9603 | + options4[2] = 1; |
---|
| 9604 | + options4[3] = 0; |
---|
| 9605 | + } |
---|
| 9606 | + |
---|
9374 | 9607 | static int imagecount = 0; // movie generation |
---|
9375 | 9608 | |
---|
9376 | 9609 | static int jitter = 0; |
---|
.. | .. |
---|
9467 | 9700 | |
---|
9468 | 9701 | if (renderCamera != lightCamera) |
---|
9469 | 9702 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9470 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9703 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9471 | 9704 | |
---|
9472 | 9705 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9473 | 9706 | |
---|
.. | .. |
---|
9483 | 9716 | |
---|
9484 | 9717 | if (renderCamera != lightCamera) |
---|
9485 | 9718 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9486 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9719 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9487 | 9720 | |
---|
9488 | 9721 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9489 | 9722 | |
---|
.. | .. |
---|
10684 | 10917 | // if (parentcam != renderCamera) // not a light |
---|
10685 | 10918 | if (cam != lightCamera) |
---|
10686 | 10919 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10687 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10920 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10688 | 10921 | |
---|
10689 | 10922 | for (int j = 0; j < 4; j++) |
---|
10690 | 10923 | { |
---|
.. | .. |
---|
10699 | 10932 | // if (parentcam != renderCamera) // not a light |
---|
10700 | 10933 | if (cam != lightCamera) |
---|
10701 | 10934 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10702 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10935 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10703 | 10936 | |
---|
10704 | 10937 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10705 | 10938 | |
---|
.. | .. |
---|
10990 | 11223 | |
---|
10991 | 11224 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
10992 | 11225 | |
---|
10993 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
10994 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
10995 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11226 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11227 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11228 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
10996 | 11229 | } else |
---|
10997 | 11230 | { |
---|
10998 | 11231 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11003 | 11236 | //System.out.println("BLENDING ON"); |
---|
11004 | 11237 | gl.glEnable(GL.GL_BLEND); |
---|
11005 | 11238 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11006 | | - |
---|
| 11239 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11007 | 11240 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11008 | 11241 | gl.glLoadIdentity(); |
---|
11009 | 11242 | |
---|
.. | .. |
---|
11252 | 11485 | } |
---|
11253 | 11486 | } |
---|
11254 | 11487 | |
---|
11255 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11488 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11256 | 11489 | { |
---|
11257 | 11490 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11258 | 11491 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11260 | 11493 | |
---|
11261 | 11494 | boolean texon = textureon; |
---|
11262 | 11495 | |
---|
11263 | | - if (RENDERPROGRAM > 0) |
---|
11264 | | - { |
---|
11265 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11266 | | - textureon = false; |
---|
11267 | | - } |
---|
| 11496 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11497 | + textureon = false; |
---|
| 11498 | + |
---|
11268 | 11499 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11269 | 11500 | //System.out.println("ALLO"); |
---|
11270 | 11501 | gl.glColorMask(false, false, false, false); |
---|
11271 | 11502 | DrawObject(gl); |
---|
11272 | | - if (RENDERPROGRAM > 0) |
---|
11273 | | - { |
---|
11274 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11275 | | - textureon = texon; |
---|
11276 | | - } |
---|
| 11503 | + |
---|
| 11504 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11505 | + textureon = texon; |
---|
| 11506 | + |
---|
11277 | 11507 | gl.glColorMask(true, true, true, true); |
---|
11278 | 11508 | |
---|
11279 | 11509 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11280 | | - //gl.glDepthMask(false); |
---|
| 11510 | + gl.glDepthMask(false); |
---|
11281 | 11511 | } |
---|
11282 | 11512 | |
---|
11283 | 11513 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11480 | 11710 | |
---|
11481 | 11711 | void DrawObject(GL gl, boolean draw) |
---|
11482 | 11712 | { |
---|
| 11713 | + // To clear camera values |
---|
| 11714 | + ResetOptions(); |
---|
| 11715 | + |
---|
11483 | 11716 | //System.out.println("DRAW OBJECT " + mouseDown); |
---|
11484 | 11717 | // DrawMode() = SELECTION; |
---|
11485 | 11718 | //GL gl = getGL(); |
---|
11486 | 11719 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11487 | 11720 | { |
---|
11488 | 11721 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11489 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11722 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11490 | 11723 | pingthread.StepToTarget(true); // true); |
---|
11491 | 11724 | // zoomonce = false; |
---|
11492 | 11725 | } |
---|
.. | .. |
---|
11614 | 11847 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11615 | 11848 | |
---|
11616 | 11849 | if (CLEANCACHE) |
---|
11617 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11850 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11618 | 11851 | { |
---|
11619 | | - String tex = e.nextElement(); |
---|
| 11852 | + cTexture tex = e.nextElement(); |
---|
11620 | 11853 | |
---|
11621 | 11854 | // System.out.println("Texture --------- " + tex); |
---|
11622 | 11855 | |
---|
11623 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11856 | + if (tex.equals("WHITE_NOISE:")) |
---|
11624 | 11857 | continue; |
---|
11625 | 11858 | |
---|
11626 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11859 | + if (!usedtextures.contains(tex)) |
---|
11627 | 11860 | { |
---|
| 11861 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11628 | 11862 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11629 | | - textures.get(tex).texture.dispose(); |
---|
11630 | | - textures.remove(tex); |
---|
| 11863 | + if (gettex != null) |
---|
| 11864 | + { |
---|
| 11865 | + gettex.texture.dispose(); |
---|
| 11866 | + texturepigment.remove(tex); |
---|
| 11867 | + } |
---|
| 11868 | + |
---|
| 11869 | + gettex = texturebump.get(tex); |
---|
| 11870 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11871 | + if (gettex != null) |
---|
| 11872 | + { |
---|
| 11873 | + gettex.texture.dispose(); |
---|
| 11874 | + texturebump.remove(tex); |
---|
| 11875 | + } |
---|
11631 | 11876 | } |
---|
11632 | 11877 | } |
---|
11633 | 11878 | } |
---|
.. | .. |
---|
12047 | 12292 | for (int i = tp.size(); --i >= 0;) |
---|
12048 | 12293 | { |
---|
12049 | 12294 | //for (int count = tp.get(i).GetTransformCount(); --count>=0;) |
---|
12050 | | - LA.xformPos(light, tp.get(i).GlobalTransform(), light); |
---|
| 12295 | + LA.xformPos(light, tp.get(i).GlobalTransformInv(), light); |
---|
12051 | 12296 | } |
---|
12052 | 12297 | |
---|
12053 | 12298 | |
---|
.. | .. |
---|
12156 | 12401 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12157 | 12402 | |
---|
12158 | 12403 | String program = |
---|
| 12404 | + // Min shader |
---|
12159 | 12405 | "!!ARBfp1.0\n" + |
---|
| 12406 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12407 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12408 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12409 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12410 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12411 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12412 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12413 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12414 | + "TEMP temp;" + |
---|
| 12415 | + "TEMP light;" + |
---|
| 12416 | + "TEMP ndotl;" + |
---|
| 12417 | + "TEMP normal;" + |
---|
| 12418 | + "TEMP depth;" + |
---|
| 12419 | + "TEMP eye;" + |
---|
| 12420 | + "TEMP pos;" + |
---|
| 12421 | + |
---|
| 12422 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12423 | + Normalize("normal") + |
---|
| 12424 | + "MOV light, state.light[0].position;" + |
---|
| 12425 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12426 | + |
---|
| 12427 | + // shadow |
---|
| 12428 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12429 | + "MOV temp, pos;" + |
---|
| 12430 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12431 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12432 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12433 | + |
---|
| 12434 | + // No shadow when out of frustum |
---|
| 12435 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12436 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12437 | + |
---|
| 12438 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12439 | + |
---|
| 12440 | + // Backlit |
---|
| 12441 | + "MOV pos.w, zero123.y;" + |
---|
| 12442 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12443 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12444 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12445 | + Normalize("eye") + |
---|
| 12446 | + |
---|
| 12447 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12448 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12449 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12450 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12451 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12452 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12453 | + |
---|
| 12454 | + "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12455 | + |
---|
| 12456 | + // Pigment |
---|
| 12457 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12458 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12459 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12460 | + |
---|
| 12461 | + "MUL temp, temp, zero123.z;" + |
---|
| 12462 | + |
---|
| 12463 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12464 | + |
---|
| 12465 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12466 | + "MOV result.color, temp;" + |
---|
| 12467 | + "END"; |
---|
| 12468 | + |
---|
| 12469 | + String program2 = |
---|
| 12470 | + "!!ARBfp1.0\n" + |
---|
| 12471 | + |
---|
12160 | 12472 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12161 | 12473 | "PARAM light2cam0 = program.env[10];" + |
---|
12162 | 12474 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12271 | 12583 | "TEMP shininess;" + |
---|
12272 | 12584 | "\n" + |
---|
12273 | 12585 | "MOV texSamp, one;" + |
---|
12274 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12275 | | - |
---|
| 12586 | + |
---|
12276 | 12587 | "MOV mapgrid.x, one2048th.x;" + |
---|
12277 | 12588 | "MOV temp, fragment.texcoord[1];" + |
---|
12278 | 12589 | /* |
---|
.. | .. |
---|
12293 | 12604 | "MUL temp, floor, mapgrid.x;" + |
---|
12294 | 12605 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12295 | 12606 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12296 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12607 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12297 | 12608 | "") + |
---|
12298 | 12609 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12299 | 12610 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12300 | 12611 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12301 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12612 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12302 | 12613 | "") + |
---|
12303 | 12614 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12304 | 12615 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12305 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12616 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12306 | 12617 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12307 | 12618 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12308 | 12619 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12309 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12620 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12310 | 12621 | "") + |
---|
12311 | 12622 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12312 | 12623 | //"MOV params, material;" + |
---|
.. | .. |
---|
12677 | 12988 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12678 | 12989 | "") + |
---|
12679 | 12990 | |
---|
12680 | | - // display shadow only (bump == 0) |
---|
| 12991 | + // display shadow only (fakedepth == 0) |
---|
12681 | 12992 | "SUB temp.x, half.x, shadow.x;" + |
---|
12682 | 12993 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12683 | 12994 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13104 | 13415 | return out; |
---|
13105 | 13416 | } |
---|
13106 | 13417 | |
---|
13107 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13418 | + // Also does frustum culling |
---|
| 13419 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13108 | 13420 | { |
---|
13109 | 13421 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13110 | 13422 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13111 | 13423 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13424 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13425 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13112 | 13426 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13113 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13114 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13115 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13116 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13427 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13428 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13117 | 13429 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13118 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13430 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13119 | 13431 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13120 | 13432 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13121 | 13433 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13122 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13434 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13123 | 13435 | |
---|
13124 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13125 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13436 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13437 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13126 | 13438 | } |
---|
13127 | 13439 | |
---|
13128 | 13440 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13169 | 13481 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13170 | 13482 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13171 | 13483 | |
---|
13172 | | - // No shadow when out of frustrum |
---|
| 13484 | + // No shadow when out of frustum |
---|
13173 | 13485 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13174 | 13486 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13175 | 13487 | ""; |
---|
.. | .. |
---|
13334 | 13646 | "DP3 " + dest + ".z," + "normals," + "eye;" + |
---|
13335 | 13647 | "MAX " + dest + ".w," + dest + ".z," + "eps.x;" + |
---|
13336 | 13648 | //"MOV " + dest + ".w," + "normal.z;" + |
---|
13337 | | - "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + |
---|
13338 | | - "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
13339 | | - //"MOV " + dest + ".z," + "params2.w;" + |
---|
| 13649 | +// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET |
---|
| 13650 | +// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" + |
---|
| 13651 | + |
---|
| 13652 | + "MOV " + dest + ".z," + "params2.w;" + // EXACT |
---|
13340 | 13653 | "POW " + dest + ".w," + dest + ".w," + dest + ".z;" + |
---|
13341 | 13654 | "RCP " + dest + ".w," + dest + ".w;" + |
---|
13342 | 13655 | //"RSQ " + dest + ".w," + dest + ".w;" + |
---|
.. | .. |
---|
13901 | 14214 | |
---|
13902 | 14215 | // fev 2014??? |
---|
13903 | 14216 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
13904 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14217 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
13905 | 14218 | pingthread.StepToTarget(true); // true); |
---|
13906 | 14219 | } |
---|
13907 | 14220 | // if (!LIVE) |
---|
.. | .. |
---|
13966 | 14279 | drag = false; |
---|
13967 | 14280 | //System.out.println("Mouse DOWN"); |
---|
13968 | 14281 | editObj = false; |
---|
13969 | | - ClickInfo info = new ClickInfo(); |
---|
13970 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
13971 | | - info.pane = this; |
---|
13972 | | - info.camera = renderCamera; |
---|
13973 | | - info.x = x; |
---|
13974 | | - info.y = y; |
---|
13975 | | - info.modifiers = modifiersex; |
---|
13976 | | - editObj = object.doEditClick(info, 0); |
---|
| 14282 | + //ClickInfo info = new ClickInfo(); |
---|
| 14283 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14284 | + object.clickInfo.pane = this; |
---|
| 14285 | + object.clickInfo.camera = renderCamera; |
---|
| 14286 | + object.clickInfo.x = x; |
---|
| 14287 | + object.clickInfo.y = y; |
---|
| 14288 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14289 | + editObj = object.doEditClick(//info, |
---|
| 14290 | + 0); |
---|
13977 | 14291 | if (!editObj) |
---|
13978 | 14292 | { |
---|
13979 | 14293 | hasMarquee = true; |
---|
.. | .. |
---|
14255 | 14569 | void GoDown(int mod) |
---|
14256 | 14570 | { |
---|
14257 | 14571 | MODIFIERS |= COMMAND; |
---|
14258 | | - /* |
---|
| 14572 | + /**/ |
---|
14259 | 14573 | if((mod&SHIFT) == SHIFT) |
---|
14260 | 14574 | manipCamera.RotatePosition(0, -speed); |
---|
14261 | 14575 | else |
---|
14262 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14263 | | - */ |
---|
| 14576 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14577 | + /**/ |
---|
14264 | 14578 | if ((mod & SHIFT) == SHIFT) |
---|
14265 | 14579 | { |
---|
14266 | 14580 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14276 | 14590 | void GoUp(int mod) |
---|
14277 | 14591 | { |
---|
14278 | 14592 | MODIFIERS |= COMMAND; |
---|
14279 | | - /* |
---|
| 14593 | + /**/ |
---|
14280 | 14594 | if((mod&SHIFT) == SHIFT) |
---|
14281 | 14595 | manipCamera.RotatePosition(0, speed); |
---|
14282 | 14596 | else |
---|
14283 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14284 | | - */ |
---|
| 14597 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14598 | + /**/ |
---|
14285 | 14599 | if ((mod & SHIFT) == SHIFT) |
---|
14286 | 14600 | { |
---|
14287 | 14601 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14297 | 14611 | void GoLeft(int mod) |
---|
14298 | 14612 | { |
---|
14299 | 14613 | MODIFIERS |= COMMAND; |
---|
14300 | | - /* |
---|
| 14614 | + /**/ |
---|
14301 | 14615 | if((mod&SHIFT) == SHIFT) |
---|
14302 | | - manipCamera.RotatePosition(speed, 0); |
---|
14303 | | - else |
---|
14304 | 14616 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14305 | | - */ |
---|
| 14617 | + else |
---|
| 14618 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14619 | + /**/ |
---|
14306 | 14620 | if ((mod & SHIFT) == SHIFT) |
---|
14307 | 14621 | { |
---|
14308 | 14622 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14318 | 14632 | void GoRight(int mod) |
---|
14319 | 14633 | { |
---|
14320 | 14634 | MODIFIERS |= COMMAND; |
---|
14321 | | - /* |
---|
| 14635 | + /**/ |
---|
14322 | 14636 | if((mod&SHIFT) == SHIFT) |
---|
14323 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14324 | | - else |
---|
14325 | 14637 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14326 | | - */ |
---|
| 14638 | + else |
---|
| 14639 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14640 | + /**/ |
---|
14327 | 14641 | if ((mod & SHIFT) == SHIFT) |
---|
14328 | 14642 | { |
---|
14329 | 14643 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14373 | 14687 | if (editObj) |
---|
14374 | 14688 | { |
---|
14375 | 14689 | drag = true; |
---|
14376 | | - ClickInfo info = new ClickInfo(); |
---|
14377 | | - info.bounds.setBounds(0, 0, |
---|
| 14690 | + //ClickInfo info = new ClickInfo(); |
---|
| 14691 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14378 | 14692 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14379 | | - info.pane = this; |
---|
14380 | | - info.camera = renderCamera; |
---|
14381 | | - info.x = x; |
---|
14382 | | - info.y = y; |
---|
14383 | | - object.GetWindow().copy |
---|
14384 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14693 | + object.clickInfo.pane = this; |
---|
| 14694 | + object.clickInfo.camera = renderCamera; |
---|
| 14695 | + object.clickInfo.x = x; |
---|
| 14696 | + object.clickInfo.y = y; |
---|
| 14697 | + object //.GetWindow().copy |
---|
| 14698 | + .doEditDrag(//info, |
---|
| 14699 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14385 | 14700 | } else |
---|
14386 | 14701 | { |
---|
14387 | 14702 | if (x < startX) |
---|
.. | .. |
---|
14530 | 14845 | } |
---|
14531 | 14846 | } |
---|
14532 | 14847 | |
---|
| 14848 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14849 | + |
---|
14533 | 14850 | public void mouseMoved(MouseEvent e) |
---|
14534 | 14851 | { |
---|
14535 | 14852 | //System.out.println("mouseMoved: " + e); |
---|
14536 | 14853 | if (isRenderer) |
---|
14537 | 14854 | return; |
---|
14538 | 14855 | |
---|
14539 | | - ClickInfo ci = new ClickInfo(); |
---|
14540 | | - ci.x = e.getX(); |
---|
14541 | | - ci.y = e.getY(); |
---|
14542 | | - ci.modifiers = e.getModifiersEx(); |
---|
14543 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14544 | | - ci.pane = this; |
---|
14545 | | - ci.camera = renderCamera; |
---|
| 14856 | + // Mouse cursor feedback |
---|
| 14857 | + object.clickInfo.x = e.getX(); |
---|
| 14858 | + object.clickInfo.y = e.getY(); |
---|
| 14859 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14860 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14861 | + object.clickInfo.pane = this; |
---|
| 14862 | + object.clickInfo.camera = renderCamera; |
---|
14546 | 14863 | if (!isRenderer) |
---|
14547 | 14864 | { |
---|
14548 | 14865 | //ObjEditor editWindow = object.editWindow; |
---|
14549 | 14866 | //Object3D copy = editWindow.copy; |
---|
14550 | | - if (object.doEditClick(ci, 0)) |
---|
| 14867 | + if (object.doEditClick(//clickInfo, |
---|
| 14868 | + 0)) |
---|
14551 | 14869 | { |
---|
14552 | 14870 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14553 | 14871 | } else |
---|
.. | .. |
---|
14562 | 14880 | Globals.MOUSEDRAGGED = false; |
---|
14563 | 14881 | |
---|
14564 | 14882 | movingcamera = false; |
---|
14565 | | - X = Y = 0; |
---|
| 14883 | + X = 0; // getBounds().width/2; |
---|
| 14884 | + Y = 0; // getBounds().height/2; |
---|
14566 | 14885 | //System.out.println("mouseReleased: " + e); |
---|
14567 | 14886 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14568 | 14887 | } |
---|
.. | .. |
---|
14818 | 15137 | // break; |
---|
14819 | 15138 | case 'T': |
---|
14820 | 15139 | CACHETEXTURE ^= true; |
---|
14821 | | - textures.clear(); |
---|
| 15140 | + texturepigment.clear(); |
---|
| 15141 | + texturebump.clear(); |
---|
14822 | 15142 | // repaint(); |
---|
14823 | 15143 | break; |
---|
14824 | 15144 | case 'Y': |
---|
.. | .. |
---|
14903 | 15223 | case 'E' : COMPACT ^= true; |
---|
14904 | 15224 | repaint(); |
---|
14905 | 15225 | break; |
---|
14906 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15226 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15227 | + //DEBUGHSB ^= true; |
---|
| 15228 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14907 | 15229 | repaint(); |
---|
14908 | 15230 | break; |
---|
14909 | 15231 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14929 | 15251 | repaint(); |
---|
14930 | 15252 | break; |
---|
14931 | 15253 | case 'l': |
---|
14932 | | - lightMode ^= true; |
---|
14933 | | - Globals.lighttouched = true; |
---|
14934 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14935 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14936 | | - repaint(); |
---|
14937 | | - break; |
---|
14938 | | - case 'L': |
---|
| 15254 | + //case 'L': |
---|
14939 | 15255 | if (lightMode) |
---|
14940 | 15256 | { |
---|
14941 | 15257 | lightMode = false; |
---|
.. | .. |
---|
15078 | 15394 | case '_': |
---|
15079 | 15395 | kompactbit = 5; |
---|
15080 | 15396 | break; |
---|
15081 | | - case '+': |
---|
15082 | | - kompactbit = 6; |
---|
15083 | | - break; |
---|
| 15397 | +// case '+': |
---|
| 15398 | +// kompactbit = 6; |
---|
| 15399 | +// break; |
---|
15084 | 15400 | case ' ': |
---|
15085 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15401 | + lightMode ^= true; |
---|
| 15402 | + Globals.lighttouched = true; |
---|
| 15403 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15404 | + targetLookAt.set(manipCamera.lookAt); |
---|
15086 | 15405 | repaint(); |
---|
15087 | 15406 | break; |
---|
15088 | 15407 | //case '`' : |
---|
.. | .. |
---|
15129 | 15448 | case DELETE: |
---|
15130 | 15449 | ClearSelection(); |
---|
15131 | 15450 | break; |
---|
15132 | | - /* |
---|
15133 | 15451 | case '+': |
---|
| 15452 | + |
---|
| 15453 | + /* |
---|
15134 | 15454 | //fontsize += 1; |
---|
15135 | 15455 | bbzoom *= 2; |
---|
15136 | 15456 | repaint(); |
---|
.. | .. |
---|
15147 | 15467 | case '=': |
---|
15148 | 15468 | IncDepth(); |
---|
15149 | 15469 | //fontsize += 1; |
---|
15150 | | - object.editWindow.refreshContents(true); |
---|
| 15470 | + object.GetWindow().refreshContents(true); |
---|
15151 | 15471 | maskbit = 6; |
---|
15152 | 15472 | break; |
---|
15153 | 15473 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15154 | 15474 | DecDepth(); |
---|
15155 | 15475 | maskbit = 5; |
---|
15156 | 15476 | //if(fontsize > 1) fontsize -= 1; |
---|
15157 | | - if (object.editWindow == null) |
---|
15158 | | - new Exception().printStackTrace(); |
---|
15159 | | - else |
---|
15160 | | - object.editWindow.refreshContents(true); |
---|
| 15477 | +// if (object.editWindow == null) |
---|
| 15478 | +// new Exception().printStackTrace(); |
---|
| 15479 | +// else |
---|
| 15480 | + object.GetWindow().refreshContents(true); |
---|
15161 | 15481 | break; |
---|
15162 | 15482 | case '{': |
---|
15163 | 15483 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15381 | 15701 | } |
---|
15382 | 15702 | */ |
---|
15383 | 15703 | |
---|
15384 | | - object.editWindow.EditSelection(false); |
---|
| 15704 | + object.GetWindow().EditSelection(false); |
---|
15385 | 15705 | } |
---|
15386 | 15706 | |
---|
15387 | 15707 | void SelectParent() |
---|
.. | .. |
---|
15398 | 15718 | { |
---|
15399 | 15719 | //selectees.remove(i); |
---|
15400 | 15720 | System.out.println("select parent of " + elem); |
---|
15401 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15721 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15402 | 15722 | } else |
---|
15403 | 15723 | { |
---|
15404 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15724 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15405 | 15725 | } |
---|
15406 | 15726 | |
---|
15407 | 15727 | first = false; |
---|
.. | .. |
---|
15443 | 15763 | for (int j = 0; j < group.children.size(); j++) |
---|
15444 | 15764 | { |
---|
15445 | 15765 | elem = (Object3D) group.children.elementAt(j); |
---|
15446 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15766 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15447 | 15767 | first = false; |
---|
15448 | 15768 | } |
---|
15449 | 15769 | } else |
---|
15450 | 15770 | { |
---|
15451 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15771 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15452 | 15772 | } |
---|
15453 | 15773 | |
---|
15454 | 15774 | first = false; |
---|
.. | .. |
---|
15459 | 15779 | { |
---|
15460 | 15780 | //Composite group = (Composite) object; |
---|
15461 | 15781 | Object3D group = object; |
---|
15462 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15782 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15463 | 15783 | } |
---|
15464 | 15784 | |
---|
15465 | 15785 | void ResetTransform(int mask) |
---|
15466 | 15786 | { |
---|
15467 | 15787 | //Composite group = (Composite) object; |
---|
15468 | 15788 | Object3D group = object; |
---|
15469 | | - group.editWindow.ResetTransform(mask); |
---|
| 15789 | + group.GetWindow().ResetTransform(mask); |
---|
15470 | 15790 | } |
---|
15471 | 15791 | |
---|
15472 | 15792 | void FlipTransform() |
---|
15473 | 15793 | { |
---|
15474 | 15794 | //Composite group = (Composite) object; |
---|
15475 | 15795 | Object3D group = object; |
---|
15476 | | - group.editWindow.FlipTransform(); |
---|
| 15796 | + group.GetWindow().FlipTransform(); |
---|
15477 | 15797 | // group.editWindow.ReduceMesh(true); |
---|
15478 | 15798 | } |
---|
15479 | 15799 | |
---|
.. | .. |
---|
15481 | 15801 | { |
---|
15482 | 15802 | //Composite group = (Composite) object; |
---|
15483 | 15803 | Object3D group = object; |
---|
15484 | | - group.editWindow.PrintMemory(); |
---|
| 15804 | + group.GetWindow().PrintMemory(); |
---|
15485 | 15805 | // group.editWindow.ReduceMesh(true); |
---|
15486 | 15806 | } |
---|
15487 | 15807 | |
---|
.. | .. |
---|
15489 | 15809 | { |
---|
15490 | 15810 | //Composite group = (Composite) object; |
---|
15491 | 15811 | Object3D group = object; |
---|
15492 | | - group.editWindow.ResetCentroid(); |
---|
| 15812 | + group.GetWindow().ResetCentroid(); |
---|
15493 | 15813 | } |
---|
15494 | 15814 | |
---|
15495 | 15815 | void IncDepth() |
---|
.. | .. |
---|
15571 | 15891 | |
---|
15572 | 15892 | int width = getBounds().width; |
---|
15573 | 15893 | int height = getBounds().height; |
---|
15574 | | - ClickInfo info = new ClickInfo(); |
---|
15575 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15576 | 15894 | //Image img = CreateImage(width, height); |
---|
15577 | 15895 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15578 | 15896 | |
---|
.. | .. |
---|
15649 | 15967 | } |
---|
15650 | 15968 | if (object != null && !hasMarquee) |
---|
15651 | 15969 | { |
---|
| 15970 | + if (object.clickInfo == null) |
---|
| 15971 | + object.clickInfo = new ClickInfo(); |
---|
| 15972 | + ClickInfo info = object.clickInfo; |
---|
| 15973 | + //ClickInfo info = new ClickInfo(); |
---|
| 15974 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15975 | + |
---|
15652 | 15976 | if (isRenderer) |
---|
15653 | 15977 | { |
---|
15654 | | - info.flags++; |
---|
| 15978 | + object.clickInfo.flags++; |
---|
15655 | 15979 | double frameAspect = (double) width / (double) height; |
---|
15656 | 15980 | if (frameAspect > renderCamera.aspect) |
---|
15657 | 15981 | { |
---|
15658 | 15982 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15659 | | - info.bounds.width -= width - desired; |
---|
15660 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15983 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15984 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15661 | 15985 | } else |
---|
15662 | 15986 | { |
---|
15663 | 15987 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15664 | | - info.bounds.height -= height - desired; |
---|
15665 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15988 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15989 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15666 | 15990 | } |
---|
15667 | 15991 | } |
---|
15668 | | - info.g = gr; |
---|
15669 | | - info.camera = renderCamera; |
---|
| 15992 | + |
---|
| 15993 | + object.clickInfo.g = gr; |
---|
| 15994 | + object.clickInfo.camera = renderCamera; |
---|
15670 | 15995 | /* |
---|
15671 | 15996 | // Memory intensive (brep.verticescopy) |
---|
15672 | 15997 | if (!(object instanceof Composite)) |
---|
15673 | 15998 | object.draw(info, 0, false); // SLOW : |
---|
15674 | 15999 | */ |
---|
15675 | | - if (!isRenderer) |
---|
| 16000 | + if (!isRenderer) // && drag) |
---|
15676 | 16001 | { |
---|
15677 | | - object.drawEditHandles(info, 0); |
---|
15678 | | - |
---|
15679 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 16002 | + Grafreed.Assert(object != null); |
---|
| 16003 | + Grafreed.Assert(object.selection != null); |
---|
| 16004 | + if (object.selection.Size() > 0) |
---|
15680 | 16005 | { |
---|
15681 | | - switch (object.selection.get(0).hitSomething) |
---|
| 16006 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 16007 | + |
---|
| 16008 | + object.clickInfo.DX = 0; |
---|
| 16009 | + object.clickInfo.DY = 0; |
---|
| 16010 | + object.clickInfo.W = 1; |
---|
| 16011 | + if (hitSomething == Object3D.hitCenter) |
---|
15682 | 16012 | { |
---|
15683 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15684 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15685 | | - break; |
---|
15686 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15687 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15688 | | - break; |
---|
15689 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15690 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15691 | | - break; |
---|
| 16013 | + info.DX = X; |
---|
| 16014 | + if (X != 0) |
---|
| 16015 | + info.DX -= info.bounds.width/2; |
---|
| 16016 | + |
---|
| 16017 | + info.DY = Y; |
---|
| 16018 | + if (Y != 0) |
---|
| 16019 | + info.DY -= info.bounds.height/2; |
---|
15692 | 16020 | } |
---|
15693 | | - |
---|
| 16021 | + |
---|
| 16022 | + object.drawEditHandles(//info, |
---|
| 16023 | + 0); |
---|
| 16024 | + |
---|
| 16025 | + if (drag && (X != 0 || Y != 0)) |
---|
| 16026 | + { |
---|
| 16027 | + switch (hitSomething) |
---|
| 16028 | + { |
---|
| 16029 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16030 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16031 | + break; |
---|
| 16032 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 16033 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16034 | + break; |
---|
| 16035 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 16036 | + gr.drawLine(X, Y, 0, 0); |
---|
| 16037 | + break; |
---|
| 16038 | + } |
---|
| 16039 | + |
---|
| 16040 | + } |
---|
15694 | 16041 | } |
---|
15695 | 16042 | } |
---|
15696 | 16043 | } |
---|
.. | .. |
---|
16488 | 16835 | } |
---|
16489 | 16836 | } |
---|
16490 | 16837 | |
---|
| 16838 | + private Object3D GetFolder() |
---|
| 16839 | + { |
---|
| 16840 | + Object3D folder = object.GetWindow().copy; |
---|
| 16841 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16842 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16843 | + return folder; |
---|
| 16844 | + } |
---|
| 16845 | + |
---|
16491 | 16846 | class SelectBuffer implements GLEventListener |
---|
16492 | 16847 | { |
---|
16493 | 16848 | |
---|
.. | .. |
---|
16567 | 16922 | |
---|
16568 | 16923 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16569 | 16924 | |
---|
| 16925 | + if (PAINTMODE) |
---|
| 16926 | + { |
---|
| 16927 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16928 | + { |
---|
| 16929 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16930 | + |
---|
| 16931 | + // Make what you paint not selectable. |
---|
| 16932 | + paintobj.ResetSelectable(); |
---|
| 16933 | + } |
---|
| 16934 | + } |
---|
| 16935 | + |
---|
16570 | 16936 | //int tmp = selection_view; |
---|
16571 | 16937 | //selection_view = -1; |
---|
16572 | 16938 | int temp = DrawMode(); |
---|
.. | .. |
---|
16578 | 16944 | // temp = DEFAULT; // patch for selection debug |
---|
16579 | 16945 | Globals.drawMode = temp; // WARNING |
---|
16580 | 16946 | |
---|
| 16947 | + if (PAINTMODE) |
---|
| 16948 | + { |
---|
| 16949 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16950 | + { |
---|
| 16951 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16952 | + |
---|
| 16953 | + // Revert. |
---|
| 16954 | + paintobj.RestoreSelectable(); |
---|
| 16955 | + } |
---|
| 16956 | + } |
---|
| 16957 | + |
---|
16581 | 16958 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16582 | 16959 | |
---|
16583 | 16960 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16681 | 17058 | } |
---|
16682 | 17059 | |
---|
16683 | 17060 | if (!movingcamera && !PAINTMODE) |
---|
16684 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 17061 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16685 | 17062 | |
---|
16686 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 17063 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16687 | 17064 | { |
---|
16688 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 17065 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16689 | 17066 | |
---|
16690 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 17067 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 17068 | + { |
---|
| 17069 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16691 | 17070 | |
---|
16692 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16693 | | - |
---|
16694 | | - group.add(paintobj); // link |
---|
16695 | | - |
---|
16696 | | - object.editWindow.SnapObject(group); |
---|
16697 | | - |
---|
16698 | | - Object3D folder = object.editWindow.copy; |
---|
16699 | | - |
---|
16700 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16701 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16702 | | - |
---|
16703 | | - folder.add(group); |
---|
16704 | | - |
---|
16705 | | - object.editWindow.ResetModel(); |
---|
16706 | | - object.editWindow.refreshContents(); |
---|
| 17071 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 17072 | + |
---|
| 17073 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 17074 | + |
---|
| 17075 | + inst.add(paintobj); // link |
---|
| 17076 | + |
---|
| 17077 | + object.GetWindow().SnapObject(inst); |
---|
| 17078 | + |
---|
| 17079 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 17080 | + |
---|
| 17081 | + folder.add(inst); |
---|
| 17082 | + |
---|
| 17083 | + object.GetWindow().ResetModel(); |
---|
| 17084 | + object.GetWindow().refreshContents(); |
---|
| 17085 | + } |
---|
16707 | 17086 | } |
---|
16708 | 17087 | else |
---|
16709 | 17088 | paintcount = 0; |
---|
.. | .. |
---|
16742 | 17121 | //System.out.println("objects[color] = " + objects[color]); |
---|
16743 | 17122 | //objects[color].Select(); |
---|
16744 | 17123 | indexcount = 0; |
---|
| 17124 | + ObjEditor window = object.GetWindow(); |
---|
| 17125 | + if (window != null && deselect) |
---|
| 17126 | + { |
---|
| 17127 | + window.Select(null, deselect, true); |
---|
| 17128 | + } |
---|
16745 | 17129 | object.Select(color, deselect); |
---|
16746 | 17130 | } |
---|
16747 | 17131 | |
---|