Normand Briere
2019-07-21 d32f24f147068e6cbecb31c7f98047f68bc8b58a
CameraPane.java
....@@ -60,7 +60,7 @@
6060 //boolean REDUCETEXTURE = true;
6161 boolean CACHETEXTURE = true;
6262 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6464 boolean COMPRESSTEXTURE = false;
6565 boolean KOMPACTTEXTURE = false; // true;
6666 boolean RESIZETEXTURE = false;
....@@ -2065,7 +2065,7 @@
20652065 //System.err.println("Oeil on");
20662066 OEIL = true;
20672067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20692069 //pingthread.StepToTarget(true);
20702070 }
20712071
....@@ -2298,10 +2298,17 @@
22982298 HANDLES ^= true;
22992299 }
23002300
2301
+ Object3D paintFolder;
2302
+
23012303 void TogglePaint()
23022304 {
23032305 PAINTMODE ^= true;
23042306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
23052312 }
23062313
23072314 void SwapCamera(int a, int b)
....@@ -2398,126 +2405,43 @@
23982405 return currentGL;
23992406 }
24002407
2401
- private void GetRemoteZip(String url, String name, boolean unzip, boolean save)
2408
+ private BufferedImage CreateBim(TextureData texturedata)
24022409 {
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;)
24162418 {
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;
24852427 }
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++)
24872432 {
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;
24912440 }
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;
25212445 }
25222446
25232447 /**/
....@@ -2537,9 +2461,10 @@
25372461 /**/
25382462
25392463 // 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
+
25432468 int pigmentdepth = 0;
25442469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
25452470 int bumpdepth = 0;
....@@ -2561,6 +2486,33 @@
25612486 true,
25622487 com.sun.opengl.util.texture.TextureIO.PNG);
25632488 } 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)
25642516 {
25652517 throw new javax.media.opengl.GLException(e);
25662518 }
....@@ -3647,6 +3599,8 @@
36473599
36483600 System.out.println("LOADING TEXTURE : " + name);
36493601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
36503604 //
36513605 if (false) // compressbit > 0)
36523606 {
....@@ -8045,7 +7999,7 @@
80457999 String pigment = Object3D.GetPigment(tex);
80468000 String bump = Object3D.GetBump(tex);
80478001
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498003 {
80508004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80518005 // System.out.println("; bump = " + bump);
....@@ -8079,7 +8033,7 @@
80798033
80808034 String pigment = Object3D.GetPigment(tex);
80818035
8082
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80838037 {
80848038 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80858039 // System.out.println("; bump = " + bump);
....@@ -8108,7 +8062,7 @@
81088062
81098063 String bump = Object3D.GetBump(tex);
81108064
8111
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81128066 {
81138067 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
81148068 // System.out.println("; bump = " + bump);
....@@ -8227,47 +8181,50 @@
82278181
82288182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
82298183 {
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;
82428225
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);
82718228 }
82728229
82738230 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8280,15 +8237,15 @@
82808237
82818238 if (tex == null)
82828239 {
8283
- BindTexture(null,false,resolution);
8240
+ BindTexture(null, null,false,resolution);
82848241 return;
82858242 }
82868243
82878244 String pigment = Object3D.GetPigment(tex);
82888245
8289
- usedtextures.put(pigment, pigment);
8246
+ usedtextures.add(pigment);
82908247
8291
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82928249 {
82938250 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
82948251 // System.out.println("; bump = " + bump);
....@@ -8300,7 +8257,7 @@
83008257 }
83018258
83028259 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8303
- BindTexture(pigment, false, resolution);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
83048261 }
83058262
83068263 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8313,15 +8270,15 @@
83138270
83148271 if (tex == null)
83158272 {
8316
- BindTexture(null,true,resolution);
8273
+ BindTexture(null, null,true,resolution);
83178274 return;
83188275 }
83198276
83208277 String bump = Object3D.GetBump(tex);
83218278
8322
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
83238280
8324
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
83258282 {
83268283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
83278284 // System.out.println("; bump = " + bump);
....@@ -8333,7 +8290,7 @@
83338290 }
83348291
83358292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8336
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
83378294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
83388295 }
83398296
....@@ -8357,9 +8314,9 @@
83578314 return fileExists;
83588315 }
83598316
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
83618318 {
8362
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
83638320
83648321 if (tex != null)
83658322 {
....@@ -8379,12 +8336,22 @@
83798336 }
83808337
83818338 if (CACHETEXTURE)
8382
- texture = textures.get(texname); // TEXTURE CACHE
8383
-
8384
- TextureData texturedata = null;
8385
-
8386
- if (texture == null || texture.resolution < resolution)
83878339 {
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
83888355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
83898356 {
83908357 assert(!bump);
....@@ -8396,19 +8363,23 @@
83968363 // }
83978364 // else
83988365 // {
8399
- texture = textures.get(tex);
8400
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
84018368 {
8402
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
84038370 }
8371
+ else
8372
+ new Exception().printStackTrace();
84048373 // }
84058374 } else
84068375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
84078376 {
84088377 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();
84128383 } else
84138384 {
84148385 //if (tex.equals("IMMORTAL"))
....@@ -8418,9 +8389,11 @@
84188389 //{
84198390 if (tex.equals("WHITE_NOISE"))
84208391 {
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();
84248397 } else
84258398 {
84268399 if (textureon)
....@@ -8479,19 +8452,20 @@
84798452 if (texturedata == null)
84808453 throw new Exception();
84818454
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);
84838456 //texture = GetTexture(tex, bump);
84848457 }
84858458 }
84868459 //}
84878460 }
84888461
8489
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
84908463 {
84918464 //return false;
8465
+ assert(bim == null);
84928466
84938467 // 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"))
84958469 {
84968470 // String ext = "_highres";
84978471 // if (REDUCETEXTURE)
....@@ -8508,52 +8482,17 @@
85088482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
85098483 if (!cachefile.exists())
85108484 {
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())
85208486 {
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
+
85518489 ImageWriter writer = null;
85528490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
85538491 if (iter.hasNext()) {
85548492 writer = (ImageWriter)iter.next();
85558493 }
8556
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
85578496 try
85588497 {
85598498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8580,8 +8519,8 @@
85808519 textures.remove(texname);
85818520 }
85828521
8583
- texture.texturedata = texturedata;
8584
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
85858524
85868525 // newtex = true;
85878526 }
....@@ -8597,12 +8536,17 @@
85978536 }
85988537 }
85998538
8600
- return texture;
8539
+ return texturecache;
86018540 }
86028541
8603
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
86048543 {
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);
86068550
86078551 if (bump)
86088552 {
....@@ -8618,23 +8562,23 @@
86188562 return texture!=null?texture.texture:null;
86198563 }
86208564
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
86228566 {
8623
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
86248568
86258569 return texture!=null?texture.texturedata:null;
86268570 }
86278571
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
86298573 {
86308574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
86318575 {
86328576 return false;
86338577 }
86348578
8635
- boolean newtex = false;
8579
+ //boolean newtex = false;
86368580
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);
86388582
86398583 if (texture == null)
86408584 return false;
....@@ -8664,7 +8608,7 @@
86648608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
86658609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
86668610
8667
- return newtex;
8611
+ return true; // Warning: not used.
86688612 }
86698613
86708614 ShadowBuffer shadowPBuf;
....@@ -11121,7 +11065,7 @@
1112111065
1112211066 try
1112311067 {
11124
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1112511069 }
1112611070 catch (Exception e)
1112711071 {
....@@ -11150,9 +11094,9 @@
1115011094
1115111095 gl.glMatrixMode(GL.GL_MODELVIEW);
1115211096
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);
1115611100 } else
1115711101 {
1115811102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11163,7 +11107,7 @@
1116311107 //System.out.println("BLENDING ON");
1116411108 gl.glEnable(GL.GL_BLEND);
1116511109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11166
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1116711111 gl.glMatrixMode(gl.GL_PROJECTION);
1116811112 gl.glLoadIdentity();
1116911113
....@@ -11649,7 +11593,7 @@
1164911593 if ((TRACK || SHADOWTRACK) || zoomonce)
1165011594 {
1165111595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11652
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1165311597 pingthread.StepToTarget(true); // true);
1165411598 // zoomonce = false;
1165511599 }
....@@ -11786,7 +11730,7 @@
1178611730 if (tex.equals("WHITE_NOISE"))
1178711731 continue;
1178811732
11789
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1179011734 {
1179111735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1179211736 textures.get(tex).texture.dispose();
....@@ -14065,7 +14009,7 @@
1406514009
1406614010 // fev 2014???
1406714011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1406914013 pingthread.StepToTarget(true); // true);
1407014014 }
1407114015 // if (!LIVE)
....@@ -14419,12 +14363,12 @@
1441914363 void GoDown(int mod)
1442014364 {
1442114365 MODIFIERS |= COMMAND;
14422
- /*
14366
+ /**/
1442314367 if((mod&SHIFT) == SHIFT)
1442414368 manipCamera.RotatePosition(0, -speed);
1442514369 else
14426
- manipCamera.BackForth(0, -speed*delta, getWidth());
14427
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1442814372 if ((mod & SHIFT) == SHIFT)
1442914373 {
1443014374 mouseMode = mouseMode; // VR??
....@@ -14440,12 +14384,12 @@
1444014384 void GoUp(int mod)
1444114385 {
1444214386 MODIFIERS |= COMMAND;
14443
- /*
14387
+ /**/
1444414388 if((mod&SHIFT) == SHIFT)
1444514389 manipCamera.RotatePosition(0, speed);
1444614390 else
14447
- manipCamera.BackForth(0, speed*delta, getWidth());
14448
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1444914393 if ((mod & SHIFT) == SHIFT)
1445014394 {
1445114395 mouseMode = mouseMode;
....@@ -14461,12 +14405,12 @@
1446114405 void GoLeft(int mod)
1446214406 {
1446314407 MODIFIERS |= COMMAND;
14464
- /*
14408
+ /**/
1446514409 if((mod&SHIFT) == SHIFT)
14466
- manipCamera.RotatePosition(speed, 0);
14467
- else
1446814410 manipCamera.Translate(speed*delta, 0, getWidth());
14469
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1447014414 if ((mod & SHIFT) == SHIFT)
1447114415 {
1447214416 mouseMode = mouseMode;
....@@ -14482,12 +14426,12 @@
1448214426 void GoRight(int mod)
1448314427 {
1448414428 MODIFIERS |= COMMAND;
14485
- /*
14429
+ /**/
1448614430 if((mod&SHIFT) == SHIFT)
14487
- manipCamera.RotatePosition(-speed, 0);
14488
- else
1448914431 manipCamera.Translate(-speed*delta, 0, getWidth());
14490
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1449114435 if ((mod & SHIFT) == SHIFT)
1449214436 {
1449314437 mouseMode = mouseMode;
....@@ -14726,7 +14670,8 @@
1472614670 Globals.MOUSEDRAGGED = false;
1472714671
1472814672 movingcamera = false;
14729
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1473014675 //System.out.println("mouseReleased: " + e);
1473114676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1473214677 }
....@@ -15067,7 +15012,9 @@
1506715012 case 'E' : COMPACT ^= true;
1506815013 repaint();
1506915014 break;
15070
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1507115018 repaint();
1507215019 break;
1507315020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -15093,13 +15040,7 @@
1509315040 repaint();
1509415041 break;
1509515042 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':
1510315044 if (lightMode)
1510415045 {
1510515046 lightMode = false;
....@@ -15246,7 +15187,10 @@
1524615187 // kompactbit = 6;
1524715188 // break;
1524815189 case ' ':
15249
- ObjEditor.theFrame.ToggleFullScreen();
15190
+ lightMode ^= true;
15191
+ Globals.lighttouched = true;
15192
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15193
+ targetLookAt.set(manipCamera.lookAt);
1525015194 repaint();
1525115195 break;
1525215196 //case '`' :
....@@ -15295,12 +15239,6 @@
1529515239 break;
1529615240 case '+':
1529715241
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
-
1530415242 /*
1530515243 //fontsize += 1;
1530615244 bbzoom *= 2;
....@@ -15318,17 +15256,17 @@
1531815256 case '=':
1531915257 IncDepth();
1532015258 //fontsize += 1;
15321
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1532215260 maskbit = 6;
1532315261 break;
1532415262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1532515263 DecDepth();
1532615264 maskbit = 5;
1532715265 //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);
1533215270 break;
1533315271 case '{':
1533415272 manipCamera.shaper_fovy /= 1.1;
....@@ -15552,7 +15490,7 @@
1555215490 }
1555315491 */
1555415492
15555
- object.editWindow.EditSelection(false);
15493
+ object.GetWindow().EditSelection(false);
1555615494 }
1555715495
1555815496 void SelectParent()
....@@ -15569,10 +15507,10 @@
1556915507 {
1557015508 //selectees.remove(i);
1557115509 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);
1557315511 } else
1557415512 {
15575
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1557615514 }
1557715515
1557815516 first = false;
....@@ -15614,12 +15552,12 @@
1561415552 for (int j = 0; j < group.children.size(); j++)
1561515553 {
1561615554 elem = (Object3D) group.children.elementAt(j);
15617
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1561815556 first = false;
1561915557 }
1562015558 } else
1562115559 {
15622
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1562315561 }
1562415562
1562515563 first = false;
....@@ -15630,21 +15568,21 @@
1563015568 {
1563115569 //Composite group = (Composite) object;
1563215570 Object3D group = object;
15633
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1563415572 }
1563515573
1563615574 void ResetTransform(int mask)
1563715575 {
1563815576 //Composite group = (Composite) object;
1563915577 Object3D group = object;
15640
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1564115579 }
1564215580
1564315581 void FlipTransform()
1564415582 {
1564515583 //Composite group = (Composite) object;
1564615584 Object3D group = object;
15647
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1564815586 // group.editWindow.ReduceMesh(true);
1564915587 }
1565015588
....@@ -15652,7 +15590,7 @@
1565215590 {
1565315591 //Composite group = (Composite) object;
1565415592 Object3D group = object;
15655
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1565615594 // group.editWindow.ReduceMesh(true);
1565715595 }
1565815596
....@@ -15660,7 +15598,7 @@
1566015598 {
1566115599 //Composite group = (Composite) object;
1566215600 Object3D group = object;
15663
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1566415602 }
1566515603
1566615604 void IncDepth()
....@@ -15836,6 +15774,7 @@
1583615774 info.bounds.y += (height - desired) / 2;
1583715775 }
1583815776 }
15777
+
1583915778 info.g = gr;
1584015779 info.camera = renderCamera;
1584115780 /*
....@@ -15845,23 +15784,44 @@
1584515784 */
1584615785 if (!isRenderer)
1584715786 {
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)
1585115790 {
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)
1585315797 {
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;
1586315805 }
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
+ }
1586515825 }
1586615826 }
1586715827 }
....@@ -16659,6 +16619,14 @@
1665916619 }
1666016620 }
1666116621
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
+
1666216630 class SelectBuffer implements GLEventListener
1666316631 {
1666416632
....@@ -16738,6 +16706,17 @@
1673816706
1673916707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1674016708
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
+
1674116720 //int tmp = selection_view;
1674216721 //selection_view = -1;
1674316722 int temp = DrawMode();
....@@ -16749,6 +16728,17 @@
1674916728 // temp = DEFAULT; // patch for selection debug
1675016729 Globals.drawMode = temp; // WARNING
1675116730
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
+
1675216742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1675316743
1675416744 // trying different ways of getting the depth info over
....@@ -16852,29 +16842,31 @@
1685216842 }
1685316843
1685416844 if (!movingcamera && !PAINTMODE)
16855
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1685616846
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)
1685816848 {
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);
1686016850
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);
1686216854
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
+ }
1687816870 }
1687916871 else
1688016872 paintcount = 0;