.. | .. |
---|
60 | 60 | //boolean REDUCETEXTURE = true; |
---|
61 | 61 | boolean CACHETEXTURE = true; |
---|
62 | 62 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = false; // true; |
---|
| 63 | + boolean MIPMAP = true; // false; // true; |
---|
64 | 64 | boolean COMPRESSTEXTURE = false; |
---|
65 | 65 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 66 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
2065 | 2065 | //System.err.println("Oeil on"); |
---|
2066 | 2066 | OEIL = true; |
---|
2067 | 2067 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
2068 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 2068 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
2069 | 2069 | //pingthread.StepToTarget(true); |
---|
2070 | 2070 | } |
---|
2071 | 2071 | |
---|
.. | .. |
---|
2298 | 2298 | HANDLES ^= true; |
---|
2299 | 2299 | } |
---|
2300 | 2300 | |
---|
| 2301 | + Object3D paintFolder; |
---|
| 2302 | + |
---|
2301 | 2303 | void TogglePaint() |
---|
2302 | 2304 | { |
---|
2303 | 2305 | PAINTMODE ^= true; |
---|
2304 | 2306 | paintcount = 0; |
---|
| 2307 | + |
---|
| 2308 | + if (PAINTMODE) |
---|
| 2309 | + { |
---|
| 2310 | + paintFolder = GetFolder(); |
---|
| 2311 | + } |
---|
2305 | 2312 | } |
---|
2306 | 2313 | |
---|
2307 | 2314 | void SwapCamera(int a, int b) |
---|
.. | .. |
---|
2398 | 2405 | return currentGL; |
---|
2399 | 2406 | } |
---|
2400 | 2407 | |
---|
2401 | | - private void GetRemoteZip(String url, String name, boolean unzip, boolean save) |
---|
| 2408 | + private BufferedImage CreateBim(TextureData texturedata) |
---|
2402 | 2409 | { |
---|
2403 | | - java.net.URL u; |
---|
2404 | | - InputStream is = null; |
---|
2405 | | - DataInputStream dis; |
---|
2406 | | - java.util.zip.ZipInputStream zis; |
---|
2407 | | - //String s; |
---|
2408 | | - |
---|
2409 | | - System.out.println("GetRemoteZip " + name); |
---|
2410 | | - |
---|
2411 | | - int total = 0; // dis.available(); |
---|
2412 | | - |
---|
2413 | | - byte[] bytes = new byte[16384]; |
---|
2414 | | - |
---|
2415 | | - try |
---|
| 2410 | + // cache to disk |
---|
| 2411 | + Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
| 2412 | + //buffers[0]. |
---|
| 2413 | + ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
| 2414 | + int[] pixels = new int[bytebuf.capacity()/3]; |
---|
| 2415 | + int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared |
---|
| 2416 | + int height = width; |
---|
| 2417 | + for (int i=pixels.length; --i>=0;) |
---|
2416 | 2418 | { |
---|
2417 | | - u = new java.net.URL(url + name); |
---|
2418 | | - is = u.openStream(); |
---|
2419 | | - |
---|
2420 | | - System.out.println(url + name); |
---|
2421 | | - |
---|
2422 | | - if (unzip) |
---|
2423 | | - { |
---|
2424 | | - //dis = new DataInputStream(new BufferedInputStream(is)); |
---|
2425 | | - zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is)); |
---|
2426 | | - //while ((s = dis.readLine()) != null) |
---|
2427 | | - |
---|
2428 | | - if (save) |
---|
2429 | | - new java.io.File(name).mkdirs(); |
---|
2430 | | - |
---|
2431 | | - // FileOutputStream stream = new FileOutputStream("test.zip"); |
---|
2432 | | - // |
---|
2433 | | - // int count; |
---|
2434 | | - // |
---|
2435 | | - // while ((count = dis.read(bytes)) != -1) |
---|
2436 | | - // { |
---|
2437 | | - // //System.out.println(s); |
---|
2438 | | - // System.out.println(count); |
---|
2439 | | - // total += count; |
---|
2440 | | - // stream.write(bytes); |
---|
2441 | | - // } |
---|
2442 | | - // |
---|
2443 | | - // stream.close(); |
---|
2444 | | - |
---|
2445 | | - // now iterate through each item in the stream. The get next |
---|
2446 | | - // entry call will return a ZipEntry for each file in the |
---|
2447 | | - // stream |
---|
2448 | | - java.util.zip.ZipEntry entry; |
---|
2449 | | - while((entry = zis.getNextEntry())!=null) |
---|
2450 | | - { |
---|
2451 | | - if (entry.getName().endsWith(".gsm")) |
---|
2452 | | - { |
---|
2453 | | - continue; |
---|
2454 | | - } |
---|
2455 | | - |
---|
2456 | | - String s = String.format("Entry: %s len %d added %TD", |
---|
2457 | | - entry.getName(), entry.getSize(), |
---|
2458 | | - new java.util.Date(entry.getTime())); |
---|
2459 | | - System.out.println(s); |
---|
2460 | | - |
---|
2461 | | - if (save) |
---|
2462 | | - { |
---|
2463 | | - // Once we get the entry from the stream, the stream is |
---|
2464 | | - // positioned read to read the raw data, and we keep |
---|
2465 | | - // reading until read returns 0 or less. |
---|
2466 | | - String outpath = name + "/" + entry.getName(); |
---|
2467 | | - FileOutputStream output = null; |
---|
2468 | | - try |
---|
2469 | | - { |
---|
2470 | | - output = new FileOutputStream(outpath); |
---|
2471 | | - int len = 0; |
---|
2472 | | - while ((len = zis.read(bytes)) > 0) |
---|
2473 | | - { |
---|
2474 | | - output.write(bytes, 0, len); |
---|
2475 | | - } |
---|
2476 | | - } |
---|
2477 | | - finally |
---|
2478 | | - { |
---|
2479 | | - // we must always close the output file |
---|
2480 | | - if(output!=null) output.close(); |
---|
2481 | | - } |
---|
2482 | | - } |
---|
2483 | | - } |
---|
2484 | | - } |
---|
| 2419 | + int i3 = i*3; |
---|
| 2420 | + pixels[i] = 0xFF; |
---|
| 2421 | + pixels[i] <<= 8; |
---|
| 2422 | + pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
| 2423 | + pixels[i] <<= 8; |
---|
| 2424 | + pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
| 2425 | + pixels[i] <<= 8; |
---|
| 2426 | + pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
2485 | 2427 | } |
---|
2486 | | - catch (java.net.MalformedURLException mue) |
---|
| 2428 | + /* |
---|
| 2429 | + int r=0,g=0,b=0,a=0; |
---|
| 2430 | + for (int i=0; i<width; i++) |
---|
| 2431 | + for (int j=0; j<height; j++) |
---|
2487 | 2432 | { |
---|
2488 | | - System.err.println("Ouch - a MalformedURLException happened."); |
---|
2489 | | - mue.printStackTrace(); |
---|
2490 | | - //System.exit(2); |
---|
| 2433 | + int index = j*width+i; |
---|
| 2434 | + int p = pixels[index]; |
---|
| 2435 | + a = ((p>>24) & 0xFF); |
---|
| 2436 | + r = ((p>>16) & 0xFF); |
---|
| 2437 | + g = ((p>>8) & 0xFF); |
---|
| 2438 | + b = (p & 0xFF); |
---|
| 2439 | + pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
2491 | 2440 | } |
---|
2492 | | - catch (IOException ioe) |
---|
2493 | | - { |
---|
2494 | | - //System.err.println("Oops - an IOException happened."); |
---|
2495 | | - //ioe.printStackTrace(); |
---|
2496 | | - //System.exit(3); |
---|
2497 | | - } |
---|
2498 | | - finally |
---|
2499 | | - { |
---|
2500 | | - try |
---|
2501 | | - { |
---|
2502 | | - if (is != null) |
---|
2503 | | - is.close(); |
---|
2504 | | - } |
---|
2505 | | - catch (IOException ioe) |
---|
2506 | | - { |
---|
2507 | | - } |
---|
2508 | | - } |
---|
2509 | | - |
---|
2510 | | - // System.out.println("length = " + total); |
---|
2511 | | - |
---|
2512 | | -// try |
---|
2513 | | -// { |
---|
2514 | | -// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905"); |
---|
2515 | | -// } |
---|
2516 | | -// catch (Exception e) |
---|
2517 | | -// { |
---|
2518 | | -// e.printStackTrace(); |
---|
2519 | | -// } |
---|
2520 | | - |
---|
| 2441 | + /**/ |
---|
| 2442 | + BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
| 2443 | + rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 2444 | + return rendImage; |
---|
2521 | 2445 | } |
---|
2522 | 2446 | |
---|
2523 | 2447 | /**/ |
---|
.. | .. |
---|
2537 | 2461 | /**/ |
---|
2538 | 2462 | |
---|
2539 | 2463 | // TEXTURE static Texture texture; |
---|
2540 | | - static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures |
---|
2541 | | - = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>(); |
---|
2542 | | - static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>(); |
---|
| 2464 | + static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
| 2465 | + static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
| 2466 | + static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); |
---|
| 2467 | + |
---|
2543 | 2468 | int pigmentdepth = 0; |
---|
2544 | 2469 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2545 | 2470 | int bumpdepth = 0; |
---|
.. | .. |
---|
2561 | 2486 | true, |
---|
2562 | 2487 | com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2563 | 2488 | } catch (java.io.IOException e) |
---|
| 2489 | + { |
---|
| 2490 | + throw new javax.media.opengl.GLException(e); |
---|
| 2491 | + } |
---|
| 2492 | + |
---|
| 2493 | + if (bump) |
---|
| 2494 | + texturedata = ConvertBump(texturedata, false); |
---|
| 2495 | + |
---|
| 2496 | + com.sun.opengl.util.texture.Texture texture = |
---|
| 2497 | + com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2498 | + |
---|
| 2499 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2500 | + texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2501 | + |
---|
| 2502 | + return texture; |
---|
| 2503 | + } |
---|
| 2504 | + |
---|
| 2505 | + com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2506 | + { |
---|
| 2507 | + TextureData texturedata = null; |
---|
| 2508 | + |
---|
| 2509 | + try |
---|
| 2510 | + { |
---|
| 2511 | + texturedata = |
---|
| 2512 | + com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
| 2513 | + name, |
---|
| 2514 | + true); |
---|
| 2515 | + } catch (Exception e) |
---|
2564 | 2516 | { |
---|
2565 | 2517 | throw new javax.media.opengl.GLException(e); |
---|
2566 | 2518 | } |
---|
.. | .. |
---|
3647 | 3599 | |
---|
3648 | 3600 | System.out.println("LOADING TEXTURE : " + name); |
---|
3649 | 3601 | |
---|
| 3602 | + Object x = texturedata.getMipmapData(); // .getBuffer(); |
---|
| 3603 | + |
---|
3650 | 3604 | // |
---|
3651 | 3605 | if (false) // compressbit > 0) |
---|
3652 | 3606 | { |
---|
.. | .. |
---|
8045 | 7999 | String pigment = Object3D.GetPigment(tex); |
---|
8046 | 8000 | String bump = Object3D.GetBump(tex); |
---|
8047 | 8001 | |
---|
8048 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8002 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8049 | 8003 | { |
---|
8050 | 8004 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8051 | 8005 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8079 | 8033 | |
---|
8080 | 8034 | String pigment = Object3D.GetPigment(tex); |
---|
8081 | 8035 | |
---|
8082 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8036 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8083 | 8037 | { |
---|
8084 | 8038 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8085 | 8039 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8108 | 8062 | |
---|
8109 | 8063 | String bump = Object3D.GetBump(tex); |
---|
8110 | 8064 | |
---|
8111 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8065 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8112 | 8066 | { |
---|
8113 | 8067 | // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment); |
---|
8114 | 8068 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8227 | 8181 | |
---|
8228 | 8182 | /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
8229 | 8183 | { |
---|
8230 | | - if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8231 | | - ambientOcclusion ) // || !textureon) |
---|
8232 | | - { |
---|
8233 | | - return; // false; |
---|
8234 | | - } |
---|
8235 | | - |
---|
8236 | | - if (tex == null) |
---|
8237 | | - { |
---|
8238 | | - BindTexture(null,false,resolution); |
---|
8239 | | - BindTexture(null,true,resolution); |
---|
8240 | | - return; |
---|
8241 | | - } |
---|
| 8184 | +// if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
| 8185 | +// ambientOcclusion ) // || !textureon) |
---|
| 8186 | +// { |
---|
| 8187 | +// return; // false; |
---|
| 8188 | +// } |
---|
| 8189 | +// |
---|
| 8190 | +// if (tex == null) |
---|
| 8191 | +// { |
---|
| 8192 | +// BindTexture(null,false,resolution); |
---|
| 8193 | +// BindTexture(null,true,resolution); |
---|
| 8194 | +// return; |
---|
| 8195 | +// } |
---|
| 8196 | +// |
---|
| 8197 | +// String pigment = Object3D.GetPigment(tex); |
---|
| 8198 | +// String bump = Object3D.GetBump(tex); |
---|
| 8199 | +// |
---|
| 8200 | +// usedtextures.add(pigment); |
---|
| 8201 | +// usedtextures.add(bump); |
---|
| 8202 | +// |
---|
| 8203 | +// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8204 | +// { |
---|
| 8205 | +// // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
| 8206 | +// // System.out.println("; bump = " + bump); |
---|
| 8207 | +// } |
---|
| 8208 | +// |
---|
| 8209 | +// if (bump.equals("")) |
---|
| 8210 | +// { |
---|
| 8211 | +// bump = null; |
---|
| 8212 | +// } |
---|
| 8213 | +// if (pigment.equals("")) |
---|
| 8214 | +// { |
---|
| 8215 | +// pigment = null; |
---|
| 8216 | +// } |
---|
| 8217 | +// |
---|
| 8218 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8219 | +// BindTexture(pigment, false, resolution); |
---|
| 8220 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
| 8221 | +// BindTexture(bump, true, resolution); |
---|
| 8222 | +// GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
| 8223 | +// |
---|
| 8224 | +// return; // true; |
---|
8242 | 8225 | |
---|
8243 | | - String pigment = Object3D.GetPigment(tex); |
---|
8244 | | - String bump = Object3D.GetBump(tex); |
---|
8245 | | - |
---|
8246 | | - usedtextures.put(pigment, pigment); |
---|
8247 | | - usedtextures.put(bump, bump); |
---|
8248 | | - |
---|
8249 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8250 | | - { |
---|
8251 | | - // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8252 | | - // System.out.println("; bump = " + bump); |
---|
8253 | | - } |
---|
8254 | | - |
---|
8255 | | - if (bump.equals("")) |
---|
8256 | | - { |
---|
8257 | | - bump = null; |
---|
8258 | | - } |
---|
8259 | | - if (pigment.equals("")) |
---|
8260 | | - { |
---|
8261 | | - pigment = null; |
---|
8262 | | - } |
---|
8263 | | - |
---|
8264 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8265 | | - BindTexture(pigment, false, resolution); |
---|
8266 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8267 | | - BindTexture(bump, true, resolution); |
---|
8268 | | - GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8269 | | - |
---|
8270 | | - return; // true; |
---|
| 8226 | + BindPigmentTexture(tex, resolution); |
---|
| 8227 | + BindBumpTexture(tex, resolution); |
---|
8271 | 8228 | } |
---|
8272 | 8229 | |
---|
8273 | 8230 | /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8280 | 8237 | |
---|
8281 | 8238 | if (tex == null) |
---|
8282 | 8239 | { |
---|
8283 | | - BindTexture(null,false,resolution); |
---|
| 8240 | + BindTexture(null, null,false,resolution); |
---|
8284 | 8241 | return; |
---|
8285 | 8242 | } |
---|
8286 | 8243 | |
---|
8287 | 8244 | String pigment = Object3D.GetPigment(tex); |
---|
8288 | 8245 | |
---|
8289 | | - usedtextures.put(pigment, pigment); |
---|
| 8246 | + usedtextures.add(pigment); |
---|
8290 | 8247 | |
---|
8291 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8248 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8292 | 8249 | { |
---|
8293 | 8250 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8294 | 8251 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8300 | 8257 | } |
---|
8301 | 8258 | |
---|
8302 | 8259 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8303 | | - BindTexture(pigment, false, resolution); |
---|
| 8260 | + BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
8304 | 8261 | } |
---|
8305 | 8262 | |
---|
8306 | 8263 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8313 | 8270 | |
---|
8314 | 8271 | if (tex == null) |
---|
8315 | 8272 | { |
---|
8316 | | - BindTexture(null,true,resolution); |
---|
| 8273 | + BindTexture(null, null,true,resolution); |
---|
8317 | 8274 | return; |
---|
8318 | 8275 | } |
---|
8319 | 8276 | |
---|
8320 | 8277 | String bump = Object3D.GetBump(tex); |
---|
8321 | 8278 | |
---|
8322 | | - usedtextures.put(bump, bump); |
---|
| 8279 | + usedtextures.add(bump); |
---|
8323 | 8280 | |
---|
8324 | | - if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
| 8281 | + //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8325 | 8282 | { |
---|
8326 | 8283 | // System.out.print("BIND +++++++++++++++ pigment = " + pigment); |
---|
8327 | 8284 | // System.out.println("; bump = " + bump); |
---|
.. | .. |
---|
8333 | 8290 | } |
---|
8334 | 8291 | |
---|
8335 | 8292 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8336 | | - BindTexture(bump, true, resolution); |
---|
| 8293 | + BindTexture(tex.bumptexture, bump, true, resolution); |
---|
8337 | 8294 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8338 | 8295 | } |
---|
8339 | 8296 | |
---|
.. | .. |
---|
8357 | 8314 | return fileExists; |
---|
8358 | 8315 | } |
---|
8359 | 8316 | |
---|
8360 | | - CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8317 | + CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
8361 | 8318 | { |
---|
8362 | | - CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
| 8319 | + CacheTexture texturecache = null; |
---|
8363 | 8320 | |
---|
8364 | 8321 | if (tex != null) |
---|
8365 | 8322 | { |
---|
.. | .. |
---|
8379 | 8336 | } |
---|
8380 | 8337 | |
---|
8381 | 8338 | if (CACHETEXTURE) |
---|
8382 | | - texture = textures.get(texname); // TEXTURE CACHE |
---|
8383 | | - |
---|
8384 | | - TextureData texturedata = null; |
---|
8385 | | - |
---|
8386 | | - if (texture == null || texture.resolution < resolution) |
---|
8387 | 8339 | { |
---|
| 8340 | + if (bim == null) |
---|
| 8341 | + texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8342 | + else |
---|
| 8343 | + texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8344 | + } |
---|
| 8345 | + |
---|
| 8346 | + if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8347 | + { |
---|
| 8348 | + TextureData texturedata = null; |
---|
| 8349 | + |
---|
| 8350 | + if (bim != null) |
---|
| 8351 | + { |
---|
| 8352 | + texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8353 | + } |
---|
| 8354 | + else |
---|
8388 | 8355 | if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8389 | 8356 | { |
---|
8390 | 8357 | assert(!bump); |
---|
.. | .. |
---|
8396 | 8363 | // } |
---|
8397 | 8364 | // else |
---|
8398 | 8365 | // { |
---|
8399 | | - texture = textures.get(tex); |
---|
8400 | | - if (texture == null) |
---|
| 8366 | + texturecache = textures.get(tex); |
---|
| 8367 | + if (texturecache == null) |
---|
8401 | 8368 | { |
---|
8402 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8369 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8403 | 8370 | } |
---|
| 8371 | + else |
---|
| 8372 | + new Exception().printStackTrace(); |
---|
8404 | 8373 | // } |
---|
8405 | 8374 | } else |
---|
8406 | 8375 | if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8407 | 8376 | { |
---|
8408 | 8377 | assert(bump); |
---|
8409 | | - texture = textures.get(tex); |
---|
8410 | | - if (texture == null) |
---|
8411 | | - texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8378 | + texturecache = textures.get(tex); |
---|
| 8379 | + if (texturecache == null) |
---|
| 8380 | + texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8381 | + else |
---|
| 8382 | + new Exception().printStackTrace(); |
---|
8412 | 8383 | } else |
---|
8413 | 8384 | { |
---|
8414 | 8385 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8418 | 8389 | //{ |
---|
8419 | 8390 | if (tex.equals("WHITE_NOISE")) |
---|
8420 | 8391 | { |
---|
8421 | | - texture = textures.get(tex); |
---|
8422 | | - if (texture == null) |
---|
8423 | | - texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8392 | + texturecache = textures.get(tex); |
---|
| 8393 | + if (texturecache == null) |
---|
| 8394 | + texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8395 | + else |
---|
| 8396 | + new Exception().printStackTrace(); |
---|
8424 | 8397 | } else |
---|
8425 | 8398 | { |
---|
8426 | 8399 | if (textureon) |
---|
.. | .. |
---|
8479 | 8452 | if (texturedata == null) |
---|
8480 | 8453 | throw new Exception(); |
---|
8481 | 8454 | |
---|
8482 | | - texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8455 | + texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
8483 | 8456 | //texture = GetTexture(tex, bump); |
---|
8484 | 8457 | } |
---|
8485 | 8458 | } |
---|
8486 | 8459 | //} |
---|
8487 | 8460 | } |
---|
8488 | 8461 | |
---|
8489 | | - if (/*CACHETEXTURE &&*/ texture != null && textureon) |
---|
| 8462 | + if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8490 | 8463 | { |
---|
8491 | 8464 | //return false; |
---|
| 8465 | + assert(bim == null); |
---|
8492 | 8466 | |
---|
8493 | 8467 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8494 | | - if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG"))) |
---|
| 8468 | + if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
8495 | 8469 | { |
---|
8496 | 8470 | // String ext = "_highres"; |
---|
8497 | 8471 | // if (REDUCETEXTURE) |
---|
.. | .. |
---|
8508 | 8482 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8509 | 8483 | if (!cachefile.exists()) |
---|
8510 | 8484 | { |
---|
8511 | | - // cache to disk |
---|
8512 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8513 | | - //buffers[0]. |
---|
8514 | | - |
---|
8515 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8516 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8517 | | - |
---|
8518 | | - // squared size heuristic... |
---|
8519 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8485 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8520 | 8486 | { |
---|
8521 | | - for (int i=pixels.length; --i>=0;) |
---|
8522 | | - { |
---|
8523 | | - int i3 = i*3; |
---|
8524 | | - pixels[i] = 0xFF; |
---|
8525 | | - pixels[i] <<= 8; |
---|
8526 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8527 | | - pixels[i] <<= 8; |
---|
8528 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8529 | | - pixels[i] <<= 8; |
---|
8530 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8531 | | - } |
---|
8532 | | - |
---|
8533 | | - /* |
---|
8534 | | - int r=0,g=0,b=0,a=0; |
---|
8535 | | - for (int i=0; i<width; i++) |
---|
8536 | | - for (int j=0; j<height; j++) |
---|
8537 | | - { |
---|
8538 | | - int index = j*width+i; |
---|
8539 | | - int p = pixels[index]; |
---|
8540 | | - a = ((p>>24) & 0xFF); |
---|
8541 | | - r = ((p>>16) & 0xFF); |
---|
8542 | | - g = ((p>>8) & 0xFF); |
---|
8543 | | - b = (p & 0xFF); |
---|
8544 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8545 | | - } |
---|
8546 | | - /**/ |
---|
8547 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8548 | | - int height = width; |
---|
8549 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8550 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8487 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8488 | + |
---|
8551 | 8489 | ImageWriter writer = null; |
---|
8552 | 8490 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8553 | 8491 | if (iter.hasNext()) { |
---|
8554 | 8492 | writer = (ImageWriter)iter.next(); |
---|
8555 | 8493 | } |
---|
8556 | | - float compressionQuality = 0.9f; |
---|
| 8494 | + |
---|
| 8495 | + float compressionQuality = 0.85f; |
---|
8557 | 8496 | try |
---|
8558 | 8497 | { |
---|
8559 | 8498 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8580 | 8519 | textures.remove(texname); |
---|
8581 | 8520 | } |
---|
8582 | 8521 | |
---|
8583 | | - texture.texturedata = texturedata; |
---|
8584 | | - textures.put(texname, texture); |
---|
| 8522 | + //texture.texturedata = texturedata; |
---|
| 8523 | + textures.put(texname, texturecache); |
---|
8585 | 8524 | |
---|
8586 | 8525 | // newtex = true; |
---|
8587 | 8526 | } |
---|
.. | .. |
---|
8597 | 8536 | } |
---|
8598 | 8537 | } |
---|
8599 | 8538 | |
---|
8600 | | - return texture; |
---|
| 8539 | + return texturecache; |
---|
8601 | 8540 | } |
---|
8602 | 8541 | |
---|
8603 | | - com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8542 | + static void EmbedTextures(cTexture tex) |
---|
8604 | 8543 | { |
---|
8605 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8544 | + |
---|
| 8545 | + } |
---|
| 8546 | + |
---|
| 8547 | + com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8548 | + { |
---|
| 8549 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8606 | 8550 | |
---|
8607 | 8551 | if (bump) |
---|
8608 | 8552 | { |
---|
.. | .. |
---|
8618 | 8562 | return texture!=null?texture.texture:null; |
---|
8619 | 8563 | } |
---|
8620 | 8564 | |
---|
8621 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception |
---|
| 8565 | + public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8622 | 8566 | { |
---|
8623 | | - CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
| 8567 | + CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
8624 | 8568 | |
---|
8625 | 8569 | return texture!=null?texture.texturedata:null; |
---|
8626 | 8570 | } |
---|
8627 | 8571 | |
---|
8628 | | - boolean BindTexture(String tex, boolean bump, int resolution) throws Exception |
---|
| 8572 | + boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
8629 | 8573 | { |
---|
8630 | 8574 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8631 | 8575 | { |
---|
8632 | 8576 | return false; |
---|
8633 | 8577 | } |
---|
8634 | 8578 | |
---|
8635 | | - boolean newtex = false; |
---|
| 8579 | + //boolean newtex = false; |
---|
8636 | 8580 | |
---|
8637 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
| 8581 | + com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
8638 | 8582 | |
---|
8639 | 8583 | if (texture == null) |
---|
8640 | 8584 | return false; |
---|
.. | .. |
---|
8664 | 8608 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT); |
---|
8665 | 8609 | texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT); |
---|
8666 | 8610 | |
---|
8667 | | - return newtex; |
---|
| 8611 | + return true; // Warning: not used. |
---|
8668 | 8612 | } |
---|
8669 | 8613 | |
---|
8670 | 8614 | ShadowBuffer shadowPBuf; |
---|
.. | .. |
---|
11121 | 11065 | |
---|
11122 | 11066 | try |
---|
11123 | 11067 | { |
---|
11124 | | - BindTexture(NOISE_TEXTURE, false, 2); |
---|
| 11068 | + BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
11125 | 11069 | } |
---|
11126 | 11070 | catch (Exception e) |
---|
11127 | 11071 | { |
---|
.. | .. |
---|
11150 | 11094 | |
---|
11151 | 11095 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
11152 | 11096 | |
---|
11153 | | -//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
11154 | | -//gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
11155 | | -//gl.glEnable(gl.GL_MULTISAMPLE); |
---|
| 11097 | +gl.glEnable(gl.GL_POLYGON_SMOOTH); |
---|
| 11098 | +gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST); |
---|
| 11099 | +gl.glEnable(gl.GL_MULTISAMPLE); |
---|
11156 | 11100 | } else |
---|
11157 | 11101 | { |
---|
11158 | 11102 | //gl.glDisable(GL.GL_TEXTURE_2D); |
---|
.. | .. |
---|
11163 | 11107 | //System.out.println("BLENDING ON"); |
---|
11164 | 11108 | gl.glEnable(GL.GL_BLEND); |
---|
11165 | 11109 | gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA); |
---|
11166 | | - |
---|
| 11110 | +// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE); |
---|
11167 | 11111 | gl.glMatrixMode(gl.GL_PROJECTION); |
---|
11168 | 11112 | gl.glLoadIdentity(); |
---|
11169 | 11113 | |
---|
.. | .. |
---|
11649 | 11593 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11650 | 11594 | { |
---|
11651 | 11595 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11652 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 11596 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11653 | 11597 | pingthread.StepToTarget(true); // true); |
---|
11654 | 11598 | // zoomonce = false; |
---|
11655 | 11599 | } |
---|
.. | .. |
---|
11786 | 11730 | if (tex.equals("WHITE_NOISE")) |
---|
11787 | 11731 | continue; |
---|
11788 | 11732 | |
---|
11789 | | - if (!usedtextures.containsKey(tex)) |
---|
| 11733 | + if (!usedtextures.contains(tex)) |
---|
11790 | 11734 | { |
---|
11791 | 11735 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11792 | 11736 | textures.get(tex).texture.dispose(); |
---|
.. | .. |
---|
14065 | 14009 | |
---|
14066 | 14010 | // fev 2014??? |
---|
14067 | 14011 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
14068 | | - object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
| 14012 | + object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
14069 | 14013 | pingthread.StepToTarget(true); // true); |
---|
14070 | 14014 | } |
---|
14071 | 14015 | // if (!LIVE) |
---|
.. | .. |
---|
14419 | 14363 | void GoDown(int mod) |
---|
14420 | 14364 | { |
---|
14421 | 14365 | MODIFIERS |= COMMAND; |
---|
14422 | | - /* |
---|
| 14366 | + /**/ |
---|
14423 | 14367 | if((mod&SHIFT) == SHIFT) |
---|
14424 | 14368 | manipCamera.RotatePosition(0, -speed); |
---|
14425 | 14369 | else |
---|
14426 | | - manipCamera.BackForth(0, -speed*delta, getWidth()); |
---|
14427 | | - */ |
---|
| 14370 | + manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14371 | + /**/ |
---|
14428 | 14372 | if ((mod & SHIFT) == SHIFT) |
---|
14429 | 14373 | { |
---|
14430 | 14374 | mouseMode = mouseMode; // VR?? |
---|
.. | .. |
---|
14440 | 14384 | void GoUp(int mod) |
---|
14441 | 14385 | { |
---|
14442 | 14386 | MODIFIERS |= COMMAND; |
---|
14443 | | - /* |
---|
| 14387 | + /**/ |
---|
14444 | 14388 | if((mod&SHIFT) == SHIFT) |
---|
14445 | 14389 | manipCamera.RotatePosition(0, speed); |
---|
14446 | 14390 | else |
---|
14447 | | - manipCamera.BackForth(0, speed*delta, getWidth()); |
---|
14448 | | - */ |
---|
| 14391 | + manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14392 | + /**/ |
---|
14449 | 14393 | if ((mod & SHIFT) == SHIFT) |
---|
14450 | 14394 | { |
---|
14451 | 14395 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14461 | 14405 | void GoLeft(int mod) |
---|
14462 | 14406 | { |
---|
14463 | 14407 | MODIFIERS |= COMMAND; |
---|
14464 | | - /* |
---|
| 14408 | + /**/ |
---|
14465 | 14409 | if((mod&SHIFT) == SHIFT) |
---|
14466 | | - manipCamera.RotatePosition(speed, 0); |
---|
14467 | | - else |
---|
14468 | 14410 | manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14469 | | - */ |
---|
| 14411 | + else |
---|
| 14412 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14413 | + /**/ |
---|
14470 | 14414 | if ((mod & SHIFT) == SHIFT) |
---|
14471 | 14415 | { |
---|
14472 | 14416 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14482 | 14426 | void GoRight(int mod) |
---|
14483 | 14427 | { |
---|
14484 | 14428 | MODIFIERS |= COMMAND; |
---|
14485 | | - /* |
---|
| 14429 | + /**/ |
---|
14486 | 14430 | if((mod&SHIFT) == SHIFT) |
---|
14487 | | - manipCamera.RotatePosition(-speed, 0); |
---|
14488 | | - else |
---|
14489 | 14431 | manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14490 | | - */ |
---|
| 14432 | + else |
---|
| 14433 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14434 | + /**/ |
---|
14491 | 14435 | if ((mod & SHIFT) == SHIFT) |
---|
14492 | 14436 | { |
---|
14493 | 14437 | mouseMode = mouseMode; |
---|
.. | .. |
---|
14726 | 14670 | Globals.MOUSEDRAGGED = false; |
---|
14727 | 14671 | |
---|
14728 | 14672 | movingcamera = false; |
---|
14729 | | - X = Y = 0; |
---|
| 14673 | + X = 0; // getBounds().width/2; |
---|
| 14674 | + Y = 0; // getBounds().height/2; |
---|
14730 | 14675 | //System.out.println("mouseReleased: " + e); |
---|
14731 | 14676 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
14732 | 14677 | } |
---|
.. | .. |
---|
15067 | 15012 | case 'E' : COMPACT ^= true; |
---|
15068 | 15013 | repaint(); |
---|
15069 | 15014 | break; |
---|
15070 | | - case 'W' : DEBUGHSB ^= true; |
---|
| 15015 | + case 'W' : // Wide Window (fullscreen) |
---|
| 15016 | + //DEBUGHSB ^= true; |
---|
| 15017 | + ObjEditor.theFrame.ToggleFullScreen(); |
---|
15071 | 15018 | repaint(); |
---|
15072 | 15019 | break; |
---|
15073 | 15020 | case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break; |
---|
.. | .. |
---|
15093 | 15040 | repaint(); |
---|
15094 | 15041 | break; |
---|
15095 | 15042 | case 'l': |
---|
15096 | | - lightMode ^= true; |
---|
15097 | | - Globals.lighttouched = true; |
---|
15098 | | - manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
15099 | | - targetLookAt.set(manipCamera.lookAt); |
---|
15100 | | - repaint(); |
---|
15101 | | - break; |
---|
15102 | | - case 'L': |
---|
| 15043 | + //case 'L': |
---|
15103 | 15044 | if (lightMode) |
---|
15104 | 15045 | { |
---|
15105 | 15046 | lightMode = false; |
---|
.. | .. |
---|
15246 | 15187 | // kompactbit = 6; |
---|
15247 | 15188 | // break; |
---|
15248 | 15189 | case ' ': |
---|
15249 | | - ObjEditor.theFrame.ToggleFullScreen(); |
---|
| 15190 | + lightMode ^= true; |
---|
| 15191 | + Globals.lighttouched = true; |
---|
| 15192 | + manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
| 15193 | + targetLookAt.set(manipCamera.lookAt); |
---|
15250 | 15194 | repaint(); |
---|
15251 | 15195 | break; |
---|
15252 | 15196 | //case '`' : |
---|
.. | .. |
---|
15295 | 15239 | break; |
---|
15296 | 15240 | case '+': |
---|
15297 | 15241 | |
---|
15298 | | - //for (int i=0; i<0x7FFFFFFF; i++) |
---|
15299 | | - { |
---|
15300 | | - //String.format("%08X", i); // "7caca905" |
---|
15301 | | - GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true); |
---|
15302 | | - } |
---|
15303 | | - |
---|
15304 | 15242 | /* |
---|
15305 | 15243 | //fontsize += 1; |
---|
15306 | 15244 | bbzoom *= 2; |
---|
.. | .. |
---|
15318 | 15256 | case '=': |
---|
15319 | 15257 | IncDepth(); |
---|
15320 | 15258 | //fontsize += 1; |
---|
15321 | | - object.editWindow.refreshContents(true); |
---|
| 15259 | + object.GetWindow().refreshContents(true); |
---|
15322 | 15260 | maskbit = 6; |
---|
15323 | 15261 | break; |
---|
15324 | 15262 | case '-': //if (PixelThreshold>1) PixelThreshold /= 2; |
---|
15325 | 15263 | DecDepth(); |
---|
15326 | 15264 | maskbit = 5; |
---|
15327 | 15265 | //if(fontsize > 1) fontsize -= 1; |
---|
15328 | | - if (object.editWindow == null) |
---|
15329 | | - new Exception().printStackTrace(); |
---|
15330 | | - else |
---|
15331 | | - object.editWindow.refreshContents(true); |
---|
| 15266 | +// if (object.editWindow == null) |
---|
| 15267 | +// new Exception().printStackTrace(); |
---|
| 15268 | +// else |
---|
| 15269 | + object.GetWindow().refreshContents(true); |
---|
15332 | 15270 | break; |
---|
15333 | 15271 | case '{': |
---|
15334 | 15272 | manipCamera.shaper_fovy /= 1.1; |
---|
.. | .. |
---|
15552 | 15490 | } |
---|
15553 | 15491 | */ |
---|
15554 | 15492 | |
---|
15555 | | - object.editWindow.EditSelection(false); |
---|
| 15493 | + object.GetWindow().EditSelection(false); |
---|
15556 | 15494 | } |
---|
15557 | 15495 | |
---|
15558 | 15496 | void SelectParent() |
---|
.. | .. |
---|
15569 | 15507 | { |
---|
15570 | 15508 | //selectees.remove(i); |
---|
15571 | 15509 | System.out.println("select parent of " + elem); |
---|
15572 | | - group.editWindow.Select(elem.parent.GetTreePath(), first, true); |
---|
| 15510 | + group.GetWindow().Select(elem.parent.GetTreePath(), first, true); |
---|
15573 | 15511 | } else |
---|
15574 | 15512 | { |
---|
15575 | | - group.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15513 | + group.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15576 | 15514 | } |
---|
15577 | 15515 | |
---|
15578 | 15516 | first = false; |
---|
.. | .. |
---|
15614 | 15552 | for (int j = 0; j < group.children.size(); j++) |
---|
15615 | 15553 | { |
---|
15616 | 15554 | elem = (Object3D) group.children.elementAt(j); |
---|
15617 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15555 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15618 | 15556 | first = false; |
---|
15619 | 15557 | } |
---|
15620 | 15558 | } else |
---|
15621 | 15559 | { |
---|
15622 | | - object.editWindow.Select(elem.GetTreePath(), first, true); |
---|
| 15560 | + object.GetWindow().Select(elem.GetTreePath(), first, true); |
---|
15623 | 15561 | } |
---|
15624 | 15562 | |
---|
15625 | 15563 | first = false; |
---|
.. | .. |
---|
15630 | 15568 | { |
---|
15631 | 15569 | //Composite group = (Composite) object; |
---|
15632 | 15570 | Object3D group = object; |
---|
15633 | | - group.editWindow.loadClipboard(true); // ClearSelection(false); |
---|
| 15571 | + group.GetWindow().loadClipboard(true); // ClearSelection(false); |
---|
15634 | 15572 | } |
---|
15635 | 15573 | |
---|
15636 | 15574 | void ResetTransform(int mask) |
---|
15637 | 15575 | { |
---|
15638 | 15576 | //Composite group = (Composite) object; |
---|
15639 | 15577 | Object3D group = object; |
---|
15640 | | - group.editWindow.ResetTransform(mask); |
---|
| 15578 | + group.GetWindow().ResetTransform(mask); |
---|
15641 | 15579 | } |
---|
15642 | 15580 | |
---|
15643 | 15581 | void FlipTransform() |
---|
15644 | 15582 | { |
---|
15645 | 15583 | //Composite group = (Composite) object; |
---|
15646 | 15584 | Object3D group = object; |
---|
15647 | | - group.editWindow.FlipTransform(); |
---|
| 15585 | + group.GetWindow().FlipTransform(); |
---|
15648 | 15586 | // group.editWindow.ReduceMesh(true); |
---|
15649 | 15587 | } |
---|
15650 | 15588 | |
---|
.. | .. |
---|
15652 | 15590 | { |
---|
15653 | 15591 | //Composite group = (Composite) object; |
---|
15654 | 15592 | Object3D group = object; |
---|
15655 | | - group.editWindow.PrintMemory(); |
---|
| 15593 | + group.GetWindow().PrintMemory(); |
---|
15656 | 15594 | // group.editWindow.ReduceMesh(true); |
---|
15657 | 15595 | } |
---|
15658 | 15596 | |
---|
.. | .. |
---|
15660 | 15598 | { |
---|
15661 | 15599 | //Composite group = (Composite) object; |
---|
15662 | 15600 | Object3D group = object; |
---|
15663 | | - group.editWindow.ResetCentroid(); |
---|
| 15601 | + group.GetWindow().ResetCentroid(); |
---|
15664 | 15602 | } |
---|
15665 | 15603 | |
---|
15666 | 15604 | void IncDepth() |
---|
.. | .. |
---|
15836 | 15774 | info.bounds.y += (height - desired) / 2; |
---|
15837 | 15775 | } |
---|
15838 | 15776 | } |
---|
| 15777 | + |
---|
15839 | 15778 | info.g = gr; |
---|
15840 | 15779 | info.camera = renderCamera; |
---|
15841 | 15780 | /* |
---|
.. | .. |
---|
15845 | 15784 | */ |
---|
15846 | 15785 | if (!isRenderer) |
---|
15847 | 15786 | { |
---|
15848 | | - object.drawEditHandles(info, 0); |
---|
15849 | | - |
---|
15850 | | - if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0) |
---|
| 15787 | + Grafreed.Assert(object != null); |
---|
| 15788 | + Grafreed.Assert(object.selection != null); |
---|
| 15789 | + if (object.selection.Size() > 0) |
---|
15851 | 15790 | { |
---|
15852 | | - switch (object.selection.get(0).hitSomething) |
---|
| 15791 | + int hitSomething = object.selection.get(0).hitSomething; |
---|
| 15792 | + |
---|
| 15793 | + info.DX = 0; |
---|
| 15794 | + info.DY = 0; |
---|
| 15795 | + info.W = 1; |
---|
| 15796 | + if (hitSomething == Object3D.hitCenter) |
---|
15853 | 15797 | { |
---|
15854 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
15855 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15856 | | - break; |
---|
15857 | | - case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
15858 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15859 | | - break; |
---|
15860 | | - case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15861 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15862 | | - break; |
---|
| 15798 | + info.DX = X; |
---|
| 15799 | + if (X != 0) |
---|
| 15800 | + info.DX -= info.bounds.width/2; |
---|
| 15801 | + |
---|
| 15802 | + info.DY = Y; |
---|
| 15803 | + if (Y != 0) |
---|
| 15804 | + info.DY -= info.bounds.height/2; |
---|
15863 | 15805 | } |
---|
15864 | | - |
---|
| 15806 | + |
---|
| 15807 | + object.drawEditHandles(info, 0); |
---|
| 15808 | + |
---|
| 15809 | + if (drag && (X != 0 || Y != 0)) |
---|
| 15810 | + { |
---|
| 15811 | + switch (hitSomething) |
---|
| 15812 | + { |
---|
| 15813 | + case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 15814 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15815 | + break; |
---|
| 15816 | + case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
| 15817 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15818 | + break; |
---|
| 15819 | + case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
| 15820 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 15821 | + break; |
---|
| 15822 | + } |
---|
| 15823 | + |
---|
| 15824 | + } |
---|
15865 | 15825 | } |
---|
15866 | 15826 | } |
---|
15867 | 15827 | } |
---|
.. | .. |
---|
16659 | 16619 | } |
---|
16660 | 16620 | } |
---|
16661 | 16621 | |
---|
| 16622 | + private Object3D GetFolder() |
---|
| 16623 | + { |
---|
| 16624 | + Object3D folder = object.GetWindow().copy; |
---|
| 16625 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16626 | + folder = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16627 | + return folder; |
---|
| 16628 | + } |
---|
| 16629 | + |
---|
16662 | 16630 | class SelectBuffer implements GLEventListener |
---|
16663 | 16631 | { |
---|
16664 | 16632 | |
---|
.. | .. |
---|
16738 | 16706 | |
---|
16739 | 16707 | //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL); |
---|
16740 | 16708 | |
---|
| 16709 | + if (PAINTMODE) |
---|
| 16710 | + { |
---|
| 16711 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16712 | + { |
---|
| 16713 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16714 | + |
---|
| 16715 | + // Make what you paint not selectable. |
---|
| 16716 | + paintobj.ResetSelectable(); |
---|
| 16717 | + } |
---|
| 16718 | + } |
---|
| 16719 | + |
---|
16741 | 16720 | //int tmp = selection_view; |
---|
16742 | 16721 | //selection_view = -1; |
---|
16743 | 16722 | int temp = DrawMode(); |
---|
.. | .. |
---|
16749 | 16728 | // temp = DEFAULT; // patch for selection debug |
---|
16750 | 16729 | Globals.drawMode = temp; // WARNING |
---|
16751 | 16730 | |
---|
| 16731 | + if (PAINTMODE) |
---|
| 16732 | + { |
---|
| 16733 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16734 | + { |
---|
| 16735 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
| 16736 | + |
---|
| 16737 | + // Revert. |
---|
| 16738 | + paintobj.RestoreSelectable(); |
---|
| 16739 | + } |
---|
| 16740 | + } |
---|
| 16741 | + |
---|
16752 | 16742 | //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view); |
---|
16753 | 16743 | |
---|
16754 | 16744 | // trying different ways of getting the depth info over |
---|
.. | .. |
---|
16852 | 16842 | } |
---|
16853 | 16843 | |
---|
16854 | 16844 | if (!movingcamera && !PAINTMODE) |
---|
16855 | | - object.editWindow.ScreenFitPoint(); // fev 2014 |
---|
| 16845 | + object.GetWindow().ScreenFitPoint(); // fev 2014 |
---|
16856 | 16846 | |
---|
16857 | | - if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
| 16847 | + if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0) |
---|
16858 | 16848 | { |
---|
16859 | | - Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
| 16849 | + //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0); |
---|
16860 | 16850 | |
---|
16861 | | - Object3D group = new Object3D("inst" + paintcount++); |
---|
| 16851 | + if (object.GetWindow().copy.selection.Size() > 0) |
---|
| 16852 | + { |
---|
| 16853 | + Object3D paintobj = object.GetWindow().copy.selection.elementAt(0); |
---|
16862 | 16854 | |
---|
16863 | | - group.CreateMaterial(); // use a void leaf to select instances |
---|
16864 | | - |
---|
16865 | | - group.add(paintobj); // link |
---|
16866 | | - |
---|
16867 | | - object.editWindow.SnapObject(group); |
---|
16868 | | - |
---|
16869 | | - Object3D folder = object.editWindow.copy; |
---|
16870 | | - |
---|
16871 | | - if (object.editWindow.copy.selection.Size() > 0) |
---|
16872 | | - folder = object.editWindow.copy.selection.elementAt(0); |
---|
16873 | | - |
---|
16874 | | - folder.add(group); |
---|
16875 | | - |
---|
16876 | | - object.editWindow.ResetModel(); |
---|
16877 | | - object.editWindow.refreshContents(); |
---|
| 16855 | + Object3D inst = new Object3D("inst" + paintcount++); |
---|
| 16856 | + |
---|
| 16857 | + inst.CreateMaterial(); // use a void leaf to select instances |
---|
| 16858 | + |
---|
| 16859 | + inst.add(paintobj); // link |
---|
| 16860 | + |
---|
| 16861 | + object.GetWindow().SnapObject(inst); |
---|
| 16862 | + |
---|
| 16863 | + Object3D folder = paintFolder; // GetFolder(); |
---|
| 16864 | + |
---|
| 16865 | + folder.add(inst); |
---|
| 16866 | + |
---|
| 16867 | + object.GetWindow().ResetModel(); |
---|
| 16868 | + object.GetWindow().refreshContents(); |
---|
| 16869 | + } |
---|
16878 | 16870 | } |
---|
16879 | 16871 | else |
---|
16880 | 16872 | paintcount = 0; |
---|