.. | .. |
---|
45 | 45 | |
---|
46 | 46 | static int STEP = 1; |
---|
47 | 47 | |
---|
| 48 | + private static BufferedImage CreateBim(byte[] bytes, int width, int height) |
---|
| 49 | + { |
---|
| 50 | + int[] pixels = new int[bytes.length/3]; |
---|
| 51 | + for (int i=pixels.length; --i>=0;) |
---|
| 52 | + { |
---|
| 53 | + int i3 = i*3; |
---|
| 54 | + pixels[i] = 0xFF; |
---|
| 55 | + pixels[i] <<= 8; |
---|
| 56 | + pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 57 | + pixels[i] <<= 8; |
---|
| 58 | + pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 59 | + pixels[i] <<= 8; |
---|
| 60 | + pixels[i] |= bytes[i3] & 0xFF; |
---|
| 61 | + } |
---|
| 62 | + /* |
---|
| 63 | + int r=0,g=0,b=0,a=0; |
---|
| 64 | + for (int i=0; i<width; i++) |
---|
| 65 | + for (int j=0; j<height; j++) |
---|
| 66 | + { |
---|
| 67 | + int index = j*width+i; |
---|
| 68 | + int p = pixels[index]; |
---|
| 69 | + a = ((p>>24) & 0xFF); |
---|
| 70 | + r = ((p>>16) & 0xFF); |
---|
| 71 | + g = ((p>>8) & 0xFF); |
---|
| 72 | + b = (p & 0xFF); |
---|
| 73 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
| 74 | + } |
---|
| 75 | + /**/ |
---|
| 76 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 77 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 78 | + return rendImage; |
---|
| 79 | + } |
---|
| 80 | + |
---|
48 | 81 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 82 | /*static*/ boolean NEAREST = false; // true; |
---|
50 | 83 | /*static*/ boolean WIREFRAME = false; // true; |
---|
.. | .. |
---|
60 | 93 | //boolean REDUCETEXTURE = true; |
---|
61 | 94 | boolean CACHETEXTURE = true; |
---|
62 | 95 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 96 | + boolean MIPMAP = true; // false; // true; |
---|
64 | 97 | boolean COMPRESSTEXTURE = false; |
---|
65 | 98 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 99 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
2298 | 2331 | HANDLES ^= true; |
---|
2299 | 2332 | } |
---|
2300 | 2333 | |
---|
| 2334 | + Object3D paintFolder; |
---|
| 2335 | + |
---|
2301 | 2336 | void TogglePaint() |
---|
2302 | 2337 | { |
---|
2303 | 2338 | PAINTMODE ^= true; |
---|
2304 | 2339 | paintcount = 0; |
---|
| 2340 | + |
---|
| 2341 | + if (PAINTMODE) |
---|
| 2342 | + { |
---|
| 2343 | + paintFolder = GetFolder(); |
---|
| 2344 | + } |
---|
2305 | 2345 | } |
---|
2306 | 2346 | |
---|
2307 | 2347 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2398 | 2438 | return currentGL; |
---|
2399 | 2439 | } |
---|
2400 | 2440 | |
---|
| 2441 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2442 | + { |
---|
| 2443 | + Grafreed.Assert(texturedata != null); |
---|
| 2444 | + |
---|
| 2445 | + int width = texturedata.getWidth(); |
---|
| 2446 | + int height = texturedata.getHeight(); |
---|
| 2447 | + |
---|
| 2448 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2449 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2450 | + |
---|
| 2451 | + byte[] bytes = bytebuf.array(); |
---|
| 2452 | + |
---|
| 2453 | + return CreateBim(bytes, width, height); |
---|
| 2454 | + } |
---|
| 2455 | + |
---|
2401 | 2456 | /**/ |
---|
2402 | 2457 | class CacheTexture |
---|
2403 | 2458 | { |
---|
.. | .. |
---|
2406 | 2461 | |
---|
2407 | 2462 | int resolution; |
---|
2408 | 2463 | |
---|
2409 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2464 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2410 | 2465 | { |
---|
2411 | | - texture = tex; |
---|
| 2466 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2467 | + texturedata = texdata; |
---|
2412 | 2468 | resolution = res; |
---|
2413 | 2469 | } |
---|
2414 | 2470 | } |
---|
2415 | 2471 | /**/ |
---|
2416 | 2472 | |
---|
2417 | 2473 | // 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>(); |
---|
| 2474 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2475 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2476 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2477 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
| 2478 | + |
---|
2421 | 2479 | int pigmentdepth = 0; |
---|
2422 | 2480 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2423 | 2481 | int bumpdepth = 0; |
---|
2424 | 2482 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2425 | 2483 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2426 | 2484 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2427 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2485 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2428 | 2486 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2429 | 2487 | |
---|
2430 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2488 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2431 | 2489 | { |
---|
2432 | 2490 | TextureData texturedata = null; |
---|
2433 | 2491 | |
---|
.. | .. |
---|
2446 | 2504 | if (bump) |
---|
2447 | 2505 | texturedata = ConvertBump(texturedata, false); |
---|
2448 | 2506 | |
---|
2449 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2450 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2507 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2508 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2451 | 2509 | |
---|
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); |
---|
| 2510 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2511 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2454 | 2512 | |
---|
2455 | | - return texture; |
---|
| 2513 | + return texturedata; |
---|
| 2514 | + } |
---|
| 2515 | + |
---|
| 2516 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
| 2517 | + { |
---|
| 2518 | + TextureData texturedata = null; |
---|
| 2519 | + |
---|
| 2520 | + try |
---|
| 2521 | + { |
---|
| 2522 | + texturedata = |
---|
| 2523 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2524 | + bim, |
---|
| 2525 | + true); |
---|
| 2526 | + } catch (Exception e) |
---|
| 2527 | + { |
---|
| 2528 | + throw new javax.media.opengl.GLException(e); |
---|
| 2529 | + } |
---|
| 2530 | + |
---|
| 2531 | + if (bump) |
---|
| 2532 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2533 | + |
---|
| 2534 | + return texturedata; |
---|
2456 | 2535 | } |
---|
2457 | 2536 | |
---|
2458 | 2537 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
3525 | 3604 | |
---|
3526 | 3605 | System.out.println("LOADING TEXTURE : " + name); |
---|
3527 | 3606 | |
---|
| 3607 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3608 | + |
---|
3528 | 3609 | // |
---|
3529 | 3610 | if (false) // compressbit > 0) |
---|
3530 | 3611 | { |
---|
.. | .. |
---|
7923 | 8004 | String pigment = Object3D.GetPigment(tex); |
---|
7924 | 8005 | String bump = Object3D.GetBump(tex); |
---|
7925 | 8006 | |
---|
7926 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8007 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7927 | 8008 | { |
---|
7928 | 8009 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7929 | 8010 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7938 | 8019 | pigment = null; |
---|
7939 | 8020 | } |
---|
7940 | 8021 | |
---|
7941 | | - ReleaseTexture(bump, true); |
---|
7942 | | - ReleaseTexture(pigment, false); |
---|
| 8022 | + ReleaseTexture(tex, true); |
---|
| 8023 | + ReleaseTexture(tex, false); |
---|
7943 | 8024 | } |
---|
7944 | 8025 | |
---|
7945 | 8026 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7957 | 8038 | |
---|
7958 | 8039 | String pigment = Object3D.GetPigment(tex); |
---|
7959 | 8040 | |
---|
7960 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8041 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7961 | 8042 | { |
---|
7962 | 8043 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7963 | 8044 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7968 | 8049 | pigment = null; |
---|
7969 | 8050 | } |
---|
7970 | 8051 | |
---|
7971 | | - ReleaseTexture(pigment, false); |
---|
| 8052 | + ReleaseTexture(tex, false); |
---|
7972 | 8053 | } |
---|
7973 | 8054 | |
---|
7974 | 8055 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
7986 | 8067 | |
---|
7987 | 8068 | String bump = Object3D.GetBump(tex); |
---|
7988 | 8069 | |
---|
7989 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8070 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
7990 | 8071 | { |
---|
7991 | 8072 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
7992 | 8073 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
7997 | 8078 | bump = null; |
---|
7998 | 8079 | } |
---|
7999 | 8080 | |
---|
8000 | | - ReleaseTexture(bump, true); |
---|
| 8081 | + ReleaseTexture(tex, true); |
---|
8001 | 8082 | } |
---|
8002 | 8083 | |
---|
8003 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8084 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8004 | 8085 | { |
---|
8005 | 8086 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8006 | 8087 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8011 | 8092 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8012 | 8093 | |
---|
8013 | 8094 | if (tex != null) |
---|
8014 | | - texture = textures.get(tex); |
---|
| 8095 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8015 | 8096 | |
---|
8016 | 8097 | // //assert( texture != null ); |
---|
8017 | 8098 | // if (texture == null) |
---|
.. | .. |
---|
8105 | 8186 | |
---|
8106 | 8187 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8107 | 8188 | { |
---|
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 | | - } |
---|
| 8189 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8190 | +// ambientOcclusion ) // || !textureon) |
---|
| 8191 | +// { |
---|
| 8192 | +// return; // false; |
---|
| 8193 | +// } |
---|
| 8194 | +// |
---|
| 8195 | +// if (tex == null) |
---|
| 8196 | +// { |
---|
| 8197 | +// BindTexture(null,false,resolution); |
---|
| 8198 | +// BindTexture(null,true,resolution); |
---|
| 8199 | +// return; |
---|
| 8200 | +// } |
---|
| 8201 | +// |
---|
| 8202 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8203 | +// String bump = Object3D.GetBump(tex); |
---|
| 8204 | +// |
---|
| 8205 | +// usedtextures.add(pigment); |
---|
| 8206 | +// usedtextures.add(bump); |
---|
| 8207 | +// |
---|
| 8208 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8209 | +// { |
---|
| 8210 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8211 | +// // System.out.println("; bump = " + bump); |
---|
| 8212 | +// } |
---|
| 8213 | +// |
---|
| 8214 | +// if (bump.equals("")) |
---|
| 8215 | +// { |
---|
| 8216 | +// bump = null; |
---|
| 8217 | +// } |
---|
| 8218 | +// if (pigment.equals("")) |
---|
| 8219 | +// { |
---|
| 8220 | +// pigment = null; |
---|
| 8221 | +// } |
---|
| 8222 | +// |
---|
| 8223 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8224 | +// BindTexture(pigment, false, resolution); |
---|
| 8225 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8226 | +// BindTexture(bump, true, resolution); |
---|
| 8227 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8228 | +// |
---|
| 8229 | +// return; // true; |
---|
8120 | 8230 | |
---|
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; |
---|
| 8231 | + BindPigmentTexture(tex, resolution); |
---|
| 8232 | + BindBumpTexture(tex, resolution); |
---|
8149 | 8233 | } |
---|
8150 | 8234 | |
---|
8151 | 8235 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8164 | 8248 | |
---|
8165 | 8249 | String pigment = Object3D.GetPigment(tex); |
---|
8166 | 8250 | |
---|
8167 | | - usedtextures.put(pigment, pigment); |
---|
| 8251 | + usedtextures.add(tex); |
---|
8168 | 8252 | |
---|
8169 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8253 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8170 | 8254 | { |
---|
8171 | 8255 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8172 | 8256 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8178 | 8262 | } |
---|
8179 | 8263 | |
---|
8180 | 8264 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8181 | | - BindTexture(pigment, false, resolution); |
---|
| 8265 | + BindTexture(tex, false, resolution); |
---|
8182 | 8266 | } |
---|
8183 | 8267 | |
---|
8184 | 8268 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8197 | 8281 | |
---|
8198 | 8282 | String bump = Object3D.GetBump(tex); |
---|
8199 | 8283 | |
---|
8200 | | - usedtextures.put(bump, bump); |
---|
| 8284 | + usedtextures.add(tex); |
---|
8201 | 8285 | |
---|
8202 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8286 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8203 | 8287 | { |
---|
8204 | 8288 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8205 | 8289 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8211 | 8295 | } |
---|
8212 | 8296 | |
---|
8213 | 8297 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8214 | | - BindTexture(bump, true, resolution); |
---|
| 8298 | + BindTexture(tex, true, resolution); |
---|
8215 | 8299 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8216 | 8300 | } |
---|
8217 | 8301 | |
---|
.. | .. |
---|
8235 | 8319 | return fileExists; |
---|
8236 | 8320 | } |
---|
8237 | 8321 | |
---|
8238 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8322 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8239 | 8323 | { |
---|
8240 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8324 | + CacheTexture texturecache = null; |
---|
8241 | 8325 | |
---|
8242 | 8326 | if (tex != null) |
---|
8243 | 8327 | { |
---|
8244 | | - String texname = tex; |
---|
| 8328 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8329 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8330 | + |
---|
| 8331 | + if (texname.equals("") && texdata == null) |
---|
| 8332 | + { |
---|
| 8333 | + return null; |
---|
| 8334 | + } |
---|
8245 | 8335 | |
---|
8246 | 8336 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8247 | 8337 | |
---|
.. | .. |
---|
8251 | 8341 | // else |
---|
8252 | 8342 | // if (!texname.startsWith("/")) |
---|
8253 | 8343 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8254 | | - if (!FileExists(tex)) |
---|
| 8344 | + if (!FileExists(texname)) |
---|
8255 | 8345 | { |
---|
8256 | 8346 | texname = fallbackTextureName; |
---|
8257 | 8347 | } |
---|
8258 | 8348 | |
---|
8259 | 8349 | if (CACHETEXTURE) |
---|
8260 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8261 | | - |
---|
8262 | | - TextureData texturedata = null; |
---|
8263 | | - |
---|
8264 | | - if (texture == null || texture.resolution < resolution) |
---|
8265 | 8350 | { |
---|
8266 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8351 | + if (texdata == null) |
---|
| 8352 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
| 8353 | + else |
---|
| 8354 | + texturecache = bimtextures.get(texdata); |
---|
| 8355 | + } |
---|
| 8356 | + |
---|
| 8357 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
| 8358 | + { |
---|
| 8359 | + TextureData texturedata = null; |
---|
| 8360 | + |
---|
| 8361 | + if (texdata != null) |
---|
| 8362 | + { |
---|
| 8363 | + BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8364 | + |
---|
| 8365 | + CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8366 | + |
---|
| 8367 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8368 | + bimtextures.put(texdata, texturecache); |
---|
| 8369 | + } |
---|
| 8370 | + else |
---|
| 8371 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8267 | 8372 | { |
---|
8268 | 8373 | assert(!bump); |
---|
8269 | 8374 | // if (bump) |
---|
.. | .. |
---|
8274 | 8379 | // } |
---|
8275 | 8380 | // else |
---|
8276 | 8381 | // { |
---|
8277 | | - texture = textures.get(tex); |
---|
8278 | | - if (texture == null) |
---|
| 8382 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8383 | + if (texturecache == null) |
---|
8279 | 8384 | { |
---|
8280 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8385 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8281 | 8386 | } |
---|
| 8387 | + else |
---|
| 8388 | + new Exception().printStackTrace(); |
---|
8282 | 8389 | // } |
---|
8283 | 8390 | } else |
---|
8284 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8391 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8285 | 8392 | { |
---|
8286 | 8393 | assert(bump); |
---|
8287 | | - texture = textures.get(tex); |
---|
8288 | | - if (texture == null) |
---|
8289 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8394 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8395 | + if (texturecache == null) |
---|
| 8396 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8397 | + else |
---|
| 8398 | + new Exception().printStackTrace(); |
---|
8290 | 8399 | } else |
---|
8291 | 8400 | { |
---|
8292 | 8401 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8294 | 8403 | // texture = GetResourceTexture("default.png"); |
---|
8295 | 8404 | //} else |
---|
8296 | 8405 | //{ |
---|
8297 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8406 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8298 | 8407 | { |
---|
8299 | | - texture = textures.get(tex); |
---|
8300 | | - if (texture == null) |
---|
8301 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8408 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8409 | + if (texturecache == null) |
---|
| 8410 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8411 | + else |
---|
| 8412 | + new Exception().printStackTrace(); |
---|
8302 | 8413 | } else |
---|
8303 | 8414 | { |
---|
8304 | 8415 | if (textureon) |
---|
.. | .. |
---|
8357 | 8468 | if (texturedata == null) |
---|
8358 | 8469 | throw new Exception(); |
---|
8359 | 8470 | |
---|
8360 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8471 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8361 | 8472 | //texture = GetTexture(tex, bump); |
---|
8362 | 8473 | } |
---|
8363 | 8474 | } |
---|
8364 | 8475 | //} |
---|
8365 | 8476 | } |
---|
8366 | 8477 | |
---|
8367 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8478 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8368 | 8479 | { |
---|
8369 | 8480 | //return false; |
---|
8370 | 8481 | |
---|
8371 | 8482 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8372 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8483 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8373 | 8484 | { |
---|
8374 | 8485 | // String ext = "_highres"; |
---|
8375 | 8486 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8386 | 8497 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8387 | 8498 | if (!cachefile.exists()) |
---|
8388 | 8499 | { |
---|
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)) |
---|
| 8500 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8398 | 8501 | { |
---|
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); |
---|
| 8502 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8503 | + |
---|
8429 | 8504 | ImageWriter writer = null; |
---|
8430 | 8505 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8431 | 8506 | if (iter.hasNext()) { |
---|
8432 | 8507 | writer = (ImageWriter)iter.next(); |
---|
8433 | 8508 | } |
---|
8434 | | - float compressionQuality = 0.9f; |
---|
| 8509 | + |
---|
| 8510 | + float compressionQuality = 0.85f; |
---|
8435 | 8511 | try |
---|
8436 | 8512 | { |
---|
8437 | 8513 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8448 | 8524 | } |
---|
8449 | 8525 | } |
---|
8450 | 8526 | } |
---|
8451 | | - |
---|
| 8527 | + |
---|
| 8528 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8529 | + |
---|
8452 | 8530 | //System.out.println("Texture = " + tex); |
---|
8453 | | - if (textures.containsKey(texname)) |
---|
| 8531 | + if (textures.containsKey(tex)) |
---|
8454 | 8532 | { |
---|
8455 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8533 | + CacheTexture thetex = textures.get(tex); |
---|
8456 | 8534 | thetex.texture.disable(); |
---|
8457 | 8535 | thetex.texture.dispose(); |
---|
8458 | | - textures.remove(texname); |
---|
| 8536 | + textures.remove(tex); |
---|
8459 | 8537 | } |
---|
8460 | 8538 | |
---|
8461 | | - texture.texturedata = texturedata; |
---|
8462 | | - textures.put(texname, texture); |
---|
| 8539 | + //texture.texturedata = texturedata; |
---|
| 8540 | + textures.put(tex, texturecache); |
---|
8463 | 8541 | |
---|
8464 | 8542 | // newtex = true; |
---|
8465 | 8543 | } |
---|
.. | .. |
---|
8475 | 8553 | } |
---|
8476 | 8554 | } |
---|
8477 | 8555 | |
---|
8478 | | - return texture; |
---|
| 8556 | + return texturecache; |
---|
8479 | 8557 | } |
---|
8480 | 8558 | |
---|
8481 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8559 | + static void EmbedTextures(cTexture tex) |
---|
| 8560 | + { |
---|
| 8561 | + if (tex.pigmentdata == null) |
---|
| 8562 | + { |
---|
| 8563 | + String texname = Object3D.GetPigment(tex); |
---|
| 8564 | + |
---|
| 8565 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8566 | + |
---|
| 8567 | + if (texturecache != null) |
---|
| 8568 | + { |
---|
| 8569 | + tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8570 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8571 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8572 | + } |
---|
| 8573 | + } |
---|
| 8574 | + |
---|
| 8575 | + if (tex.bumpdata == null) |
---|
| 8576 | + { |
---|
| 8577 | + String texname = Object3D.GetBump(tex); |
---|
| 8578 | + |
---|
| 8579 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8580 | + |
---|
| 8581 | + if (texturecache != null) |
---|
| 8582 | + { |
---|
| 8583 | + tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array(); |
---|
| 8584 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8585 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8586 | + } |
---|
| 8587 | + } |
---|
| 8588 | + } |
---|
| 8589 | + |
---|
| 8590 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8482 | 8591 | { |
---|
8483 | 8592 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8484 | 8593 | |
---|
.. | .. |
---|
8496 | 8605 | return texture!=null?texture.texture:null; |
---|
8497 | 8606 | } |
---|
8498 | 8607 | |
---|
8499 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8608 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8500 | 8609 | { |
---|
8501 | 8610 | CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8502 | 8611 | |
---|
8503 | 8612 | return texture!=null?texture.texturedata:null; |
---|
8504 | 8613 | } |
---|
8505 | 8614 | |
---|
8506 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8615 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8507 | 8616 | { |
---|
8508 | 8617 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8509 | 8618 | { |
---|
8510 | 8619 | return false; |
---|
8511 | 8620 | } |
---|
8512 | 8621 | |
---|
8513 | | - boolean newtex = false; |
---|
| 8622 | + //boolean newtex = false; |
---|
8514 | 8623 | |
---|
8515 | 8624 | com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8516 | 8625 | |
---|
.. | .. |
---|
8542 | 8651 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8543 | 8652 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8544 | 8653 | |
---|
8545 | | - return newtex; |
---|
| 8654 | + return true; // Warning: not used. |
---|
8546 | 8655 | } |
---|
8547 | 8656 | |
---|
8548 | 8657 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
11028 | 11137 | |
---|
11029 | 11138 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11030 | 11139 | |
---|
11031 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11032 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
11033 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11140 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11141 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11142 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
11034 | 11143 | } else |
---|
11035 | 11144 | { |
---|
11036 | 11145 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11041 | 11150 | //System.out.println("BLENDING ON"); |
---|
11042 | 11151 | gl.glEnable(GL.GL_BLEND); |
---|
11043 | 11152 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11044 | | - |
---|
| 11153 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11045 | 11154 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11046 | 11155 | gl.glLoadIdentity(); |
---|
11047 | 11156 | |
---|
.. | .. |
---|
11655 | 11764 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11656 | 11765 | |
---|
11657 | 11766 | if (CLEANCACHE) |
---|
11658 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11767 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11659 | 11768 | { |
---|
11660 | | - String tex = e.nextElement(); |
---|
| 11769 | + cTexture tex = e.nextElement(); |
---|
11661 | 11770 | |
---|
11662 | 11771 | // System.out.println("Texture --------- " + tex); |
---|
11663 | 11772 | |
---|
11664 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11773 | + if (tex.equals("WHITE_NOISE:")) |
---|
11665 | 11774 | continue; |
---|
11666 | 11775 | |
---|
11667 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11776 | + if (!usedtextures.contains(tex)) |
---|
11668 | 11777 | { |
---|
| 11778 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11669 | 11779 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11670 | | - textures.get(tex).texture.dispose(); |
---|
11671 | | - textures.remove(tex); |
---|
| 11780 | + if (gettex != null) |
---|
| 11781 | + { |
---|
| 11782 | + gettex.texture.dispose(); |
---|
| 11783 | + texturepigment.remove(tex); |
---|
| 11784 | + } |
---|
| 11785 | + |
---|
| 11786 | + gettex = texturebump.get(tex); |
---|
| 11787 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11788 | + if (gettex != null) |
---|
| 11789 | + { |
---|
| 11790 | + gettex.texture.dispose(); |
---|
| 11791 | + texturebump.remove(tex); |
---|
| 11792 | + } |
---|
11672 | 11793 | } |
---|
11673 | 11794 | } |
---|
11674 | 11795 | } |
---|
.. | .. |
---|
14297 | 14418 | void GoDown(int mod) |
---|
14298 | 14419 | { |
---|
14299 | 14420 | MODIFIERS |= COMMAND; |
---|
14300 | | - /* |
---|
| 14421 | + /**/ |
---|
14301 | 14422 | if((mod&SHIFT) == SHIFT) |
---|
14302 | 14423 | manipCamera.RotatePosition(0, -speed); |
---|
14303 | 14424 | else |
---|
14304 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14305 | | - */ |
---|
| 14425 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14426 | + /**/ |
---|
14306 | 14427 | if ((mod & SHIFT) == SHIFT) |
---|
14307 | 14428 | { |
---|
14308 | 14429 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14318 | 14439 | void GoUp(int mod) |
---|
14319 | 14440 | { |
---|
14320 | 14441 | MODIFIERS |= COMMAND; |
---|
14321 | | - /* |
---|
| 14442 | + /**/ |
---|
14322 | 14443 | if((mod&SHIFT) == SHIFT) |
---|
14323 | 14444 | manipCamera.RotatePosition(0, speed); |
---|
14324 | 14445 | else |
---|
14325 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14326 | | - */ |
---|
| 14446 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14447 | + /**/ |
---|
14327 | 14448 | if ((mod & SHIFT) == SHIFT) |
---|
14328 | 14449 | { |
---|
14329 | 14450 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14339 | 14460 | void GoLeft(int mod) |
---|
14340 | 14461 | { |
---|
14341 | 14462 | MODIFIERS |= COMMAND; |
---|
14342 | | - /* |
---|
| 14463 | + /**/ |
---|
14343 | 14464 | if((mod&SHIFT) == SHIFT) |
---|
14344 | | - manipCamera.RotatePosition(speed, 0); |
---|
14345 | | - else |
---|
14346 | 14465 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14347 | | - */ |
---|
| 14466 | + else |
---|
| 14467 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14468 | + /**/ |
---|
14348 | 14469 | if ((mod & SHIFT) == SHIFT) |
---|
14349 | 14470 | { |
---|
14350 | 14471 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14360 | 14481 | void GoRight(int mod) |
---|
14361 | 14482 | { |
---|
14362 | 14483 | MODIFIERS |= COMMAND; |
---|
14363 | | - /* |
---|
| 14484 | + /**/ |
---|
14364 | 14485 | if((mod&SHIFT) == SHIFT) |
---|
14365 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14366 | | - else |
---|
14367 | 14486 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14368 | | - */ |
---|
| 14487 | + else |
---|
| 14488 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14489 | + /**/ |
---|
14369 | 14490 | if ((mod & SHIFT) == SHIFT) |
---|
14370 | 14491 | { |
---|
14371 | 14492 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14861 | 14982 | // break; |
---|
14862 | 14983 | case 'T': |
---|
14863 | 14984 | CACHETEXTURE ^= true; |
---|
14864 | | - textures.clear(); |
---|
| 14985 | + texturepigment.clear(); |
---|
| 14986 | + texturebump.clear(); |
---|
14865 | 14987 | // repaint(); |
---|
14866 | 14988 | break; |
---|
14867 | 14989 | case 'Y': |
---|
.. | .. |
---|
14946 | 15068 | case 'E' : COMPACT ^= true; |
---|
14947 | 15069 | repaint(); |
---|
14948 | 15070 | break; |
---|
14949 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15071 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15072 | + //DEBUGHSB ^= true; |
---|
| 15073 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
14950 | 15074 | repaint(); |
---|
14951 | 15075 | break; |
---|
14952 | 15076 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
14972 | 15096 | repaint(); |
---|
14973 | 15097 | break; |
---|
14974 | 15098 | case 'l': |
---|
14975 | | - lightMode ^= true; |
---|
14976 | | - Globals.lighttouched = true; |
---|
14977 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
14978 | | - targetLookAt.set(manipCamera.lookAt); |
---|
14979 | | - repaint(); |
---|
14980 | | - break; |
---|
14981 | | - case 'L': |
---|
| 15099 | + //case 'L': |
---|
14982 | 15100 | if (lightMode) |
---|
14983 | 15101 | { |
---|
14984 | 15102 | lightMode = false; |
---|
.. | .. |
---|
15125 | 15243 | // kompactbit = 6; |
---|
15126 | 15244 | // break; |
---|
15127 | 15245 | case ' ': |
---|
15128 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15246 | + lightMode ^= true; |
---|
| 15247 | + Globals.lighttouched = true; |
---|
| 15248 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15249 | + targetLookAt.set(manipCamera.lookAt); |
---|
15129 | 15250 | repaint(); |
---|
15130 | 15251 | break; |
---|
15131 | 15252 | //case '`' : |
---|
.. | .. |
---|
15709 | 15830 | info.bounds.y += (height - desired) / 2; |
---|
15710 | 15831 | } |
---|
15711 | 15832 | } |
---|
| 15833 | + |
---|
15712 | 15834 | info.g = gr; |
---|
15713 | 15835 | info.camera = renderCamera; |
---|
15714 | 15836 | /* |
---|
.. | .. |
---|
15718 | 15840 | */ |
---|
15719 | 15841 | if (!isRenderer) |
---|
15720 | 15842 | { |
---|
| 15843 | + Grafreed.Assert(object != null); |
---|
| 15844 | + Grafreed.Assert(object.selection != null); |
---|
15721 | 15845 | if (object.selection.Size() > 0) |
---|
15722 | 15846 | { |
---|
15723 | 15847 | int hitSomething = object.selection.get(0).hitSomething; |
---|
.. | .. |
---|
16551 | 16675 | } |
---|
16552 | 16676 | } |
---|
16553 | 16677 | |
---|
| 16678 | + private Object3D GetFolder() |
---|
| 16679 | + { |
---|
| 16680 | + Object3D folder = object.GetWindow().copy; |
---|
| 16681 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16682 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16683 | + return folder; |
---|
| 16684 | + } |
---|
| 16685 | + |
---|
16554 | 16686 | class SelectBuffer implements GLEventListener |
---|
16555 | 16687 | { |
---|
16556 | 16688 | |
---|
.. | .. |
---|
16630 | 16762 | |
---|
16631 | 16763 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16632 | 16764 | |
---|
| 16765 | + if (PAINTMODE) |
---|
| 16766 | + { |
---|
| 16767 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16768 | + { |
---|
| 16769 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16770 | + |
---|
| 16771 | + // Make what you paint not selectable. |
---|
| 16772 | + paintobj.ResetSelectable(); |
---|
| 16773 | + } |
---|
| 16774 | + } |
---|
| 16775 | + |
---|
16633 | 16776 | //int tmp = selection_view; |
---|
16634 | 16777 | //selection_view = -1; |
---|
16635 | 16778 | int temp = DrawMode(); |
---|
.. | .. |
---|
16641 | 16784 | // temp = DEFAULT; // patch for selection debug |
---|
16642 | 16785 | Globals.drawMode = temp; // WARNING |
---|
16643 | 16786 | |
---|
| 16787 | + if (PAINTMODE) |
---|
| 16788 | + { |
---|
| 16789 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16790 | + { |
---|
| 16791 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16792 | + |
---|
| 16793 | + // Revert. |
---|
| 16794 | + paintobj.RestoreSelectable(); |
---|
| 16795 | + } |
---|
| 16796 | + } |
---|
| 16797 | + |
---|
16644 | 16798 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16645 | 16799 | |
---|
16646 | 16800 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16746 | 16900 | if (!movingcamera && !PAINTMODE) |
---|
16747 | 16901 | object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16748 | 16902 | |
---|
16749 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16903 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16750 | 16904 | { |
---|
16751 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16752 | | - |
---|
16753 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
16754 | | - |
---|
16755 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16756 | | - |
---|
16757 | | - group.add(paintobj); // link |
---|
16758 | | - |
---|
16759 | | - object.GetWindow().SnapObject(group); |
---|
16760 | | - |
---|
16761 | | - Object3D folder = object.GetWindow().copy; |
---|
| 16905 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16762 | 16906 | |
---|
16763 | 16907 | if (object.GetWindow().copy.selection.Size() > 0) |
---|
16764 | | - folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16908 | + { |
---|
| 16909 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16765 | 16910 | |
---|
16766 | | - folder.add(group); |
---|
16767 | | - |
---|
16768 | | - object.GetWindow().ResetModel(); |
---|
16769 | | - object.GetWindow().refreshContents(); |
---|
| 16911 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16912 | + |
---|
| 16913 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16914 | + |
---|
| 16915 | + inst.add(paintobj); // link |
---|
| 16916 | + |
---|
| 16917 | + object.GetWindow().SnapObject(inst); |
---|
| 16918 | + |
---|
| 16919 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16920 | + |
---|
| 16921 | + folder.add(inst); |
---|
| 16922 | + |
---|
| 16923 | + object.GetWindow().ResetModel(); |
---|
| 16924 | + object.GetWindow().refreshContents(); |
---|
| 16925 | + } |
---|
16770 | 16926 | } |
---|
16771 | 16927 | else |
---|
16772 | 16928 | paintcount = 0; |
---|