.. | .. |
---|
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; |
---|
.. | .. |
---|
2298 | 2335 | HANDLES ^= true; |
---|
2299 | 2336 | } |
---|
2300 | 2337 | |
---|
| 2338 | + Object3D paintFolder; |
---|
| 2339 | + |
---|
2301 | 2340 | void TogglePaint() |
---|
2302 | 2341 | { |
---|
2303 | 2342 | PAINTMODE ^= true; |
---|
2304 | 2343 | paintcount = 0; |
---|
| 2344 | + |
---|
| 2345 | + if (PAINTMODE) |
---|
| 2346 | + { |
---|
| 2347 | + paintFolder = GetFolder(); |
---|
| 2348 | + } |
---|
2305 | 2349 | } |
---|
2306 | 2350 | |
---|
2307 | 2351 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2398 | 2442 | return currentGL; |
---|
2399 | 2443 | } |
---|
2400 | 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 | + |
---|
2401 | 2460 | /**/ |
---|
2402 | 2461 | class CacheTexture |
---|
2403 | 2462 | { |
---|
.. | .. |
---|
2406 | 2465 | |
---|
2407 | 2466 | int resolution; |
---|
2408 | 2467 | |
---|
2409 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2468 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2410 | 2469 | { |
---|
2411 | | - texture = tex; |
---|
| 2470 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2471 | + texturedata = texdata; |
---|
2412 | 2472 | resolution = res; |
---|
2413 | 2473 | } |
---|
2414 | 2474 | } |
---|
2415 | 2475 | /**/ |
---|
2416 | 2476 | |
---|
2417 | 2477 | // TEXTURE static Texture texture; |
---|
2418 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2419 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2420 | | - 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 | + |
---|
2421 | 2483 | int pigmentdepth = 0; |
---|
2422 | 2484 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2423 | 2485 | int bumpdepth = 0; |
---|
2424 | 2486 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2425 | 2487 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2426 | 2488 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2427 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2489 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2428 | 2490 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2429 | 2491 | |
---|
2430 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2492 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2431 | 2493 | { |
---|
2432 | 2494 | TextureData texturedata = null; |
---|
2433 | 2495 | |
---|
.. | .. |
---|
2446 | 2508 | if (bump) |
---|
2447 | 2509 | texturedata = ConvertBump(texturedata, false); |
---|
2448 | 2510 | |
---|
2449 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2450 | | - 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); |
---|
2451 | 2513 | |
---|
2452 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2453 | | - 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); |
---|
2454 | 2516 | |
---|
2455 | | - 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; |
---|
2456 | 2539 | } |
---|
2457 | 2540 | |
---|
2458 | 2541 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3525 | 3608 | |
---|
3526 | 3609 | System.out.println("LOADING TEXTURE : " + name); |
---|
3527 | 3610 | |
---|
| 3611 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3612 | + |
---|
3528 | 3613 | // |
---|
3529 | 3614 | if (false) // compressbit > 0) |
---|
3530 | 3615 | { |
---|
.. | .. |
---|
7923 | 8008 | String pigment = Object3D.GetPigment(tex); |
---|
7924 | 8009 | String bump = Object3D.GetBump(tex); |
---|
7925 | 8010 | |
---|
7926 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8011 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7927 | 8012 | { |
---|
7928 | 8013 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7929 | 8014 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7938 | 8023 | pigment = null; |
---|
7939 | 8024 | } |
---|
7940 | 8025 | |
---|
7941 | | - ReleaseTexture(bump, true); |
---|
7942 | | - ReleaseTexture(pigment, false); |
---|
| 8026 | + ReleaseTexture(tex, true); |
---|
| 8027 | + ReleaseTexture(tex, false); |
---|
7943 | 8028 | } |
---|
7944 | 8029 | |
---|
7945 | 8030 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7957 | 8042 | |
---|
7958 | 8043 | String pigment = Object3D.GetPigment(tex); |
---|
7959 | 8044 | |
---|
7960 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8045 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7961 | 8046 | { |
---|
7962 | 8047 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7963 | 8048 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7968 | 8053 | pigment = null; |
---|
7969 | 8054 | } |
---|
7970 | 8055 | |
---|
7971 | | - ReleaseTexture(pigment, false); |
---|
| 8056 | + ReleaseTexture(tex, false); |
---|
7972 | 8057 | } |
---|
7973 | 8058 | |
---|
7974 | 8059 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7986 | 8071 | |
---|
7987 | 8072 | String bump = Object3D.GetBump(tex); |
---|
7988 | 8073 | |
---|
7989 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8074 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7990 | 8075 | { |
---|
7991 | 8076 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7992 | 8077 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7997 | 8082 | bump = null; |
---|
7998 | 8083 | } |
---|
7999 | 8084 | |
---|
8000 | | - ReleaseTexture(bump, true); |
---|
| 8085 | + ReleaseTexture(tex, true); |
---|
8001 | 8086 | } |
---|
8002 | 8087 | |
---|
8003 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8088 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8004 | 8089 | { |
---|
8005 | 8090 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8006 | 8091 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8011 | 8096 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8012 | 8097 | |
---|
8013 | 8098 | if (tex != null) |
---|
8014 | | - texture = textures.get(tex); |
---|
| 8099 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8015 | 8100 | |
---|
8016 | 8101 | // //assert( texture != null ); |
---|
8017 | 8102 | // if (texture == null) |
---|
.. | .. |
---|
8105 | 8190 | |
---|
8106 | 8191 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8107 | 8192 | { |
---|
8108 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8109 | | - ambientOcclusion ) // || !textureon) |
---|
8110 | | - { |
---|
8111 | | - return; // false; |
---|
8112 | | - } |
---|
8113 | | - |
---|
8114 | | - if (tex == null) |
---|
8115 | | - { |
---|
8116 | | - BindTexture(null,false,resolution); |
---|
8117 | | - BindTexture(null,true,resolution); |
---|
8118 | | - return; |
---|
8119 | | - } |
---|
| 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; |
---|
8120 | 8234 | |
---|
8121 | | - String pigment = Object3D.GetPigment(tex); |
---|
8122 | | - String bump = Object3D.GetBump(tex); |
---|
8123 | | - |
---|
8124 | | - usedtextures.put(pigment, pigment); |
---|
8125 | | - usedtextures.put(bump, bump); |
---|
8126 | | - |
---|
8127 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8128 | | - { |
---|
8129 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8130 | | - // System.out.println("; bump = " + bump); |
---|
8131 | | - } |
---|
8132 | | - |
---|
8133 | | - if (bump.equals("")) |
---|
8134 | | - { |
---|
8135 | | - bump = null; |
---|
8136 | | - } |
---|
8137 | | - if (pigment.equals("")) |
---|
8138 | | - { |
---|
8139 | | - pigment = null; |
---|
8140 | | - } |
---|
8141 | | - |
---|
8142 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8143 | | - BindTexture(pigment, false, resolution); |
---|
8144 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8145 | | - BindTexture(bump, true, resolution); |
---|
8146 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8147 | | - |
---|
8148 | | - return; // true; |
---|
| 8235 | + BindPigmentTexture(tex, resolution); |
---|
| 8236 | + BindBumpTexture(tex, resolution); |
---|
8149 | 8237 | } |
---|
8150 | 8238 | |
---|
8151 | 8239 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8164 | 8252 | |
---|
8165 | 8253 | String pigment = Object3D.GetPigment(tex); |
---|
8166 | 8254 | |
---|
8167 | | - usedtextures.put(pigment, pigment); |
---|
| 8255 | + usedtextures.add(tex); |
---|
8168 | 8256 | |
---|
8169 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8257 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8170 | 8258 | { |
---|
8171 | 8259 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8172 | 8260 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8178 | 8266 | } |
---|
8179 | 8267 | |
---|
8180 | 8268 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8181 | | - BindTexture(pigment, false, resolution); |
---|
| 8269 | + BindTexture(tex, false, resolution); |
---|
8182 | 8270 | } |
---|
8183 | 8271 | |
---|
8184 | 8272 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8197 | 8285 | |
---|
8198 | 8286 | String bump = Object3D.GetBump(tex); |
---|
8199 | 8287 | |
---|
8200 | | - usedtextures.put(bump, bump); |
---|
| 8288 | + usedtextures.add(tex); |
---|
8201 | 8289 | |
---|
8202 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8290 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8203 | 8291 | { |
---|
8204 | 8292 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8205 | 8293 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8211 | 8299 | } |
---|
8212 | 8300 | |
---|
8213 | 8301 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8214 | | - BindTexture(bump, true, resolution); |
---|
| 8302 | + BindTexture(tex, true, resolution); |
---|
8215 | 8303 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8216 | 8304 | } |
---|
8217 | 8305 | |
---|
.. | .. |
---|
8235 | 8323 | return fileExists; |
---|
8236 | 8324 | } |
---|
8237 | 8325 | |
---|
8238 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8326 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8239 | 8327 | { |
---|
8240 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8328 | + CacheTexture texturecache = null; |
---|
8241 | 8329 | |
---|
8242 | 8330 | if (tex != null) |
---|
8243 | 8331 | { |
---|
8244 | | - 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 | + } |
---|
8245 | 8339 | |
---|
8246 | 8340 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8247 | 8341 | |
---|
.. | .. |
---|
8251 | 8345 | // else |
---|
8252 | 8346 | // if (!texname.startsWith("/")) |
---|
8253 | 8347 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8254 | | - if (!FileExists(tex)) |
---|
| 8348 | + if (!FileExists(texname)) |
---|
8255 | 8349 | { |
---|
8256 | 8350 | texname = fallbackTextureName; |
---|
8257 | 8351 | } |
---|
8258 | 8352 | |
---|
8259 | 8353 | if (CACHETEXTURE) |
---|
8260 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8261 | | - |
---|
8262 | | - TextureData texturedata = null; |
---|
8263 | | - |
---|
8264 | | - if (texture == null || texture.resolution < resolution) |
---|
8265 | 8354 | { |
---|
8266 | | - 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("")) |
---|
8267 | 8388 | { |
---|
8268 | 8389 | assert(!bump); |
---|
8269 | 8390 | // if (bump) |
---|
.. | .. |
---|
8274 | 8395 | // } |
---|
8275 | 8396 | // else |
---|
8276 | 8397 | // { |
---|
8277 | | - texture = textures.get(tex); |
---|
8278 | | - if (texture == null) |
---|
| 8398 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8399 | + if (texturecache == null) |
---|
8279 | 8400 | { |
---|
8280 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8401 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8281 | 8402 | } |
---|
| 8403 | + else |
---|
| 8404 | + new Exception().printStackTrace(); |
---|
8282 | 8405 | // } |
---|
8283 | 8406 | } else |
---|
8284 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8407 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8285 | 8408 | { |
---|
8286 | 8409 | assert(bump); |
---|
8287 | | - texture = textures.get(tex); |
---|
8288 | | - if (texture == null) |
---|
8289 | | - 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(); |
---|
8290 | 8415 | } else |
---|
8291 | 8416 | { |
---|
8292 | 8417 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8294 | 8419 | // texture = GetResourceTexture("default.png"); |
---|
8295 | 8420 | //} else |
---|
8296 | 8421 | //{ |
---|
8297 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8422 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8298 | 8423 | { |
---|
8299 | | - texture = textures.get(tex); |
---|
8300 | | - if (texture == null) |
---|
8301 | | - 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(); |
---|
8302 | 8429 | } else |
---|
8303 | 8430 | { |
---|
8304 | 8431 | if (textureon) |
---|
.. | .. |
---|
8357 | 8484 | if (texturedata == null) |
---|
8358 | 8485 | throw new Exception(); |
---|
8359 | 8486 | |
---|
8360 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8487 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8361 | 8488 | //texture = GetTexture(tex, bump); |
---|
8362 | 8489 | } |
---|
8363 | 8490 | } |
---|
8364 | 8491 | //} |
---|
8365 | 8492 | } |
---|
8366 | 8493 | |
---|
8367 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8494 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8368 | 8495 | { |
---|
8369 | 8496 | //return false; |
---|
8370 | 8497 | |
---|
8371 | 8498 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8372 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8499 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8373 | 8500 | { |
---|
8374 | 8501 | // String ext = "_highres"; |
---|
8375 | 8502 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8386 | 8513 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8387 | 8514 | if (!cachefile.exists()) |
---|
8388 | 8515 | { |
---|
8389 | | - // cache to disk |
---|
8390 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8391 | | - //buffers[0]. |
---|
8392 | | - |
---|
8393 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8394 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8395 | | - |
---|
8396 | | - // squared size heuristic... |
---|
8397 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8516 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8398 | 8517 | { |
---|
8399 | | - for (int i=pixels.length; --i>=0;) |
---|
8400 | | - { |
---|
8401 | | - int i3 = i*3; |
---|
8402 | | - pixels[i] = 0xFF; |
---|
8403 | | - pixels[i] <<= 8; |
---|
8404 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8405 | | - pixels[i] <<= 8; |
---|
8406 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8407 | | - pixels[i] <<= 8; |
---|
8408 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8409 | | - } |
---|
8410 | | - |
---|
8411 | | - /* |
---|
8412 | | - int r=0,g=0,b=0,a=0; |
---|
8413 | | - for (int i=0; i<width; i++) |
---|
8414 | | - for (int j=0; j<height; j++) |
---|
8415 | | - { |
---|
8416 | | - int index = j*width+i; |
---|
8417 | | - int p = pixels[index]; |
---|
8418 | | - a = ((p>>24) & 0xFF); |
---|
8419 | | - r = ((p>>16) & 0xFF); |
---|
8420 | | - g = ((p>>8) & 0xFF); |
---|
8421 | | - b = (p & 0xFF); |
---|
8422 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8423 | | - } |
---|
8424 | | - /**/ |
---|
8425 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8426 | | - int height = width; |
---|
8427 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8428 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8518 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8519 | + |
---|
8429 | 8520 | ImageWriter writer = null; |
---|
8430 | 8521 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8431 | 8522 | if (iter.hasNext()) { |
---|
8432 | 8523 | writer = (ImageWriter)iter.next(); |
---|
8433 | 8524 | } |
---|
8434 | | - float compressionQuality = 0.9f; |
---|
| 8525 | + |
---|
| 8526 | + float compressionQuality = 0.85f; |
---|
8435 | 8527 | try |
---|
8436 | 8528 | { |
---|
8437 | 8529 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8448 | 8540 | } |
---|
8449 | 8541 | } |
---|
8450 | 8542 | } |
---|
8451 | | - |
---|
| 8543 | + |
---|
| 8544 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8545 | + |
---|
8452 | 8546 | //System.out.println("Texture = " + tex); |
---|
8453 | | - if (textures.containsKey(texname)) |
---|
| 8547 | + if (textures.containsKey(tex)) |
---|
8454 | 8548 | { |
---|
8455 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8549 | + CacheTexture thetex = textures.get(tex); |
---|
8456 | 8550 | thetex.texture.disable(); |
---|
8457 | 8551 | thetex.texture.dispose(); |
---|
8458 | | - textures.remove(texname); |
---|
| 8552 | + textures.remove(tex); |
---|
8459 | 8553 | } |
---|
8460 | 8554 | |
---|
8461 | | - texture.texturedata = texturedata; |
---|
8462 | | - textures.put(texname, texture); |
---|
| 8555 | + //texture.texturedata = texturedata; |
---|
| 8556 | + textures.put(tex, texturecache); |
---|
8463 | 8557 | |
---|
8464 | 8558 | // newtex = true; |
---|
8465 | 8559 | } |
---|
.. | .. |
---|
8475 | 8569 | } |
---|
8476 | 8570 | } |
---|
8477 | 8571 | |
---|
8478 | | - return texture; |
---|
| 8572 | + return texturecache; |
---|
8479 | 8573 | } |
---|
8480 | 8574 | |
---|
8481 | | - 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 |
---|
8482 | 8610 | { |
---|
8483 | 8611 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8484 | 8612 | |
---|
.. | .. |
---|
8496 | 8624 | return texture!=null?texture.texture:null; |
---|
8497 | 8625 | } |
---|
8498 | 8626 | |
---|
8499 | | - 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 |
---|
8500 | 8628 | { |
---|
8501 | 8629 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8502 | 8630 | |
---|
8503 | 8631 | return texture!=null?texture.texturedata:null; |
---|
8504 | 8632 | } |
---|
8505 | 8633 | |
---|
8506 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8634 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8507 | 8635 | { |
---|
8508 | 8636 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8509 | 8637 | { |
---|
8510 | 8638 | return false; |
---|
8511 | 8639 | } |
---|
8512 | 8640 | |
---|
8513 | | - boolean newtex = false; |
---|
| 8641 | + //boolean newtex = false; |
---|
8514 | 8642 | |
---|
8515 | 8643 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8516 | 8644 | |
---|
.. | .. |
---|
8542 | 8670 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8543 | 8671 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8544 | 8672 | |
---|
8545 | | - return newtex; |
---|
| 8673 | + return true; // Warning: not used. |
---|
8546 | 8674 | } |
---|
8547 | 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 | + |
---|
8548 | 8742 | ShadowBuffer shadowPBuf; |
---|
8549 | 8743 | AntialiasBuffer antialiasPBuf; |
---|
8550 | 8744 | int MAXSTACK; |
---|
.. | .. |
---|
11290 | 11484 | } |
---|
11291 | 11485 | } |
---|
11292 | 11486 | |
---|
11293 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11487 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11294 | 11488 | { |
---|
11295 | 11489 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11296 | 11490 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11298 | 11492 | |
---|
11299 | 11493 | boolean texon = textureon; |
---|
11300 | 11494 | |
---|
11301 | | - if (RENDERPROGRAM > 0) |
---|
11302 | | - { |
---|
11303 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11304 | | - textureon = false; |
---|
11305 | | - } |
---|
| 11495 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11496 | + textureon = false; |
---|
| 11497 | + |
---|
11306 | 11498 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11307 | 11499 | //System.out.println("ALLO"); |
---|
11308 | 11500 | gl.glColorMask(false, false, false, false); |
---|
11309 | 11501 | DrawObject(gl); |
---|
11310 | | - if (RENDERPROGRAM > 0) |
---|
11311 | | - { |
---|
11312 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11313 | | - textureon = texon; |
---|
11314 | | - } |
---|
| 11502 | + |
---|
| 11503 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11504 | + textureon = texon; |
---|
| 11505 | + |
---|
11315 | 11506 | gl.glColorMask(true, true, true, true); |
---|
11316 | 11507 | |
---|
11317 | 11508 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11318 | | - //gl.glDepthMask(false); |
---|
| 11509 | + gl.glDepthMask(false); |
---|
11319 | 11510 | } |
---|
11320 | 11511 | |
---|
11321 | 11512 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11655 | 11846 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11656 | 11847 | |
---|
11657 | 11848 | if (CLEANCACHE) |
---|
11658 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11849 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11659 | 11850 | { |
---|
11660 | | - String tex = e.nextElement(); |
---|
| 11851 | + cTexture tex = e.nextElement(); |
---|
11661 | 11852 | |
---|
11662 | 11853 | // System.out.println("Texture --------- " + tex); |
---|
11663 | 11854 | |
---|
11664 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11855 | + if (tex.equals("WHITE_NOISE:")) |
---|
11665 | 11856 | continue; |
---|
11666 | 11857 | |
---|
11667 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11858 | + if (!usedtextures.contains(tex)) |
---|
11668 | 11859 | { |
---|
| 11860 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11669 | 11861 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11670 | | - textures.get(tex).texture.dispose(); |
---|
11671 | | - 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 | + } |
---|
11672 | 11875 | } |
---|
11673 | 11876 | } |
---|
11674 | 11877 | } |
---|
.. | .. |
---|
12197 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12198 | 12401 | |
---|
12199 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12200 | 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 | + |
---|
12201 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12202 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
12203 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12312 | 12560 | "TEMP shininess;" + |
---|
12313 | 12561 | "\n" + |
---|
12314 | 12562 | "MOV texSamp, one;" + |
---|
12315 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12316 | | - |
---|
| 12563 | + |
---|
12317 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
12318 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
12319 | 12566 | /* |
---|
.. | .. |
---|
12718 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12719 | 12966 | "") + |
---|
12720 | 12967 | |
---|
12721 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12722 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12723 | 12970 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12724 | 12971 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13150 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13151 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13152 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13153 | 13402 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13154 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13155 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13156 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13157 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13158 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13159 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13160 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13161 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13162 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13163 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13164 | 13411 | |
---|
13165 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13166 | | - //"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;"; |
---|
13167 | 13414 | } |
---|
13168 | 13415 | |
---|
13169 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13210 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13211 | 13458 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13212 | 13459 | |
---|
13213 | | - // No shadow when out of frustrum |
---|
| 13460 | + // No shadow when out of frustum |
---|
13214 | 13461 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13215 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13216 | 13463 | ""; |
---|
.. | .. |
---|
14008 | 14255 | drag = false; |
---|
14009 | 14256 | //System.out.println("Mouse DOWN"); |
---|
14010 | 14257 | editObj = false; |
---|
14011 | | - ClickInfo info = new ClickInfo(); |
---|
14012 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14013 | | - info.pane = this; |
---|
14014 | | - info.camera = renderCamera; |
---|
14015 | | - info.x = x; |
---|
14016 | | - info.y = y; |
---|
14017 | | - info.modifiers = modifiersex; |
---|
14018 | | - 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); |
---|
14019 | 14267 | if (!editObj) |
---|
14020 | 14268 | { |
---|
14021 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
14415 | 14663 | if (editObj) |
---|
14416 | 14664 | { |
---|
14417 | 14665 | drag = true; |
---|
14418 | | - ClickInfo info = new ClickInfo(); |
---|
14419 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14420 | 14668 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14421 | | - info.pane = this; |
---|
14422 | | - info.camera = renderCamera; |
---|
14423 | | - info.x = x; |
---|
14424 | | - info.y = y; |
---|
14425 | | - object.GetWindow().copy |
---|
14426 | | - .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); |
---|
14427 | 14676 | } else |
---|
14428 | 14677 | { |
---|
14429 | 14678 | if (x < startX) |
---|
.. | .. |
---|
14572 | 14821 | } |
---|
14573 | 14822 | } |
---|
14574 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
14575 | 14826 | public void mouseMoved(MouseEvent e) |
---|
14576 | 14827 | { |
---|
14577 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
14578 | 14829 | if (isRenderer) |
---|
14579 | 14830 | return; |
---|
14580 | 14831 | |
---|
14581 | | - ClickInfo ci = new ClickInfo(); |
---|
14582 | | - ci.x = e.getX(); |
---|
14583 | | - ci.y = e.getY(); |
---|
14584 | | - ci.modifiers = e.getModifiersEx(); |
---|
14585 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14586 | | - ci.pane = this; |
---|
14587 | | - 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; |
---|
14588 | 14839 | if (!isRenderer) |
---|
14589 | 14840 | { |
---|
14590 | 14841 | //ObjEditor editWindow = object.editWindow; |
---|
14591 | 14842 | //Object3D copy = editWindow.copy; |
---|
14592 | | - if (object.doEditClick(ci, 0)) |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
14593 | 14845 | { |
---|
14594 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14595 | 14847 | } else |
---|
.. | .. |
---|
14861 | 15113 | // break; |
---|
14862 | 15114 | case 'T': |
---|
14863 | 15115 | CACHETEXTURE ^= true; |
---|
14864 | | - textures.clear(); |
---|
| 15116 | + texturepigment.clear(); |
---|
| 15117 | + texturebump.clear(); |
---|
14865 | 15118 | // repaint(); |
---|
14866 | 15119 | break; |
---|
14867 | 15120 | case 'Y': |
---|
.. | .. |
---|
15614 | 15867 | |
---|
15615 | 15868 | int width = getBounds().width; |
---|
15616 | 15869 | int height = getBounds().height; |
---|
15617 | | - ClickInfo info = new ClickInfo(); |
---|
15618 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15619 | 15870 | //Image img = CreateImage(width, height); |
---|
15620 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15621 | 15872 | |
---|
.. | .. |
---|
15692 | 15943 | } |
---|
15693 | 15944 | if (object != null && !hasMarquee) |
---|
15694 | 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 | + |
---|
15695 | 15952 | if (isRenderer) |
---|
15696 | 15953 | { |
---|
15697 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
15698 | 15955 | double frameAspect = (double) width / (double) height; |
---|
15699 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
15700 | 15957 | { |
---|
15701 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15702 | | - info.bounds.width -= width - desired; |
---|
15703 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15704 | 15961 | } else |
---|
15705 | 15962 | { |
---|
15706 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15707 | | - info.bounds.height -= height - desired; |
---|
15708 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15709 | 15966 | } |
---|
15710 | 15967 | } |
---|
15711 | | - info.g = gr; |
---|
15712 | | - info.camera = renderCamera; |
---|
| 15968 | + |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
15713 | 15971 | /* |
---|
15714 | 15972 | // Memory intensive (brep.verticescopy) |
---|
15715 | 15973 | if (!(object instanceof Composite)) |
---|
15716 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
15717 | 15975 | */ |
---|
15718 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
15719 | 15977 | { |
---|
| 15978 | + Grafreed.Assert(object != null); |
---|
| 15979 | + Grafreed.Assert(object.selection != null); |
---|
15720 | 15980 | if (object.selection.Size() > 0) |
---|
15721 | 15981 | { |
---|
15722 | 15982 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15723 | 15983 | |
---|
15724 | | - info.DX = 0; |
---|
15725 | | - info.DY = 0; |
---|
15726 | | - info.W = 1; |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
15727 | 15987 | if (hitSomething == Object3D.hitCenter) |
---|
15728 | 15988 | { |
---|
15729 | 15989 | info.DX = X; |
---|
.. | .. |
---|
15735 | 15995 | info.DY -= info.bounds.height/2; |
---|
15736 | 15996 | } |
---|
15737 | 15997 | |
---|
15738 | | - object.drawEditHandles(info, 0); |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
15739 | 16000 | |
---|
15740 | 16001 | if (drag && (X != 0 || Y != 0)) |
---|
15741 | 16002 | { |
---|
.. | .. |
---|
15748 | 16009 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15749 | 16010 | break; |
---|
15750 | 16011 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15751 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
15752 | 16013 | break; |
---|
15753 | 16014 | } |
---|
15754 | 16015 | |
---|
.. | .. |
---|
16550 | 16811 | } |
---|
16551 | 16812 | } |
---|
16552 | 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 | + |
---|
16553 | 16822 | class SelectBuffer implements GLEventListener |
---|
16554 | 16823 | { |
---|
16555 | 16824 | |
---|
.. | .. |
---|
16629 | 16898 | |
---|
16630 | 16899 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16631 | 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 | + |
---|
16632 | 16912 | //int tmp = selection_view; |
---|
16633 | 16913 | //selection_view = -1; |
---|
16634 | 16914 | int temp = DrawMode(); |
---|
.. | .. |
---|
16640 | 16920 | // temp = DEFAULT; // patch for selection debug |
---|
16641 | 16921 | Globals.drawMode = temp; // WARNING |
---|
16642 | 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 | + |
---|
16643 | 16934 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16644 | 16935 | |
---|
16645 | 16936 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16745 | 17036 | if (!movingcamera && !PAINTMODE) |
---|
16746 | 17037 | object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16747 | 17038 | |
---|
16748 | | - 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) |
---|
16749 | 17040 | { |
---|
16750 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16751 | | - |
---|
16752 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
16753 | | - |
---|
16754 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16755 | | - |
---|
16756 | | - group.add(paintobj); // link |
---|
16757 | | - |
---|
16758 | | - object.GetWindow().SnapObject(group); |
---|
16759 | | - |
---|
16760 | | - Object3D folder = object.GetWindow().copy; |
---|
| 17041 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16761 | 17042 | |
---|
16762 | 17043 | if (object.GetWindow().copy.selection.Size() > 0) |
---|
16763 | | - folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 17044 | + { |
---|
| 17045 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16764 | 17046 | |
---|
16765 | | - folder.add(group); |
---|
16766 | | - |
---|
16767 | | - object.GetWindow().ResetModel(); |
---|
16768 | | - object.GetWindow().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 | + } |
---|
16769 | 17062 | } |
---|
16770 | 17063 | else |
---|
16771 | 17064 | paintcount = 0; |
---|