Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
CameraPane.java
....@@ -45,6 +45,39 @@
4545
4646 static int STEP = 1;
4747
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
+
4881 /*static*/ private boolean CULLFACE = false; // true;
4982 /*static*/ boolean NEAREST = false; // true;
5083 /*static*/ boolean WIREFRAME = false; // true;
....@@ -60,7 +93,7 @@
6093 //boolean REDUCETEXTURE = true;
6194 boolean CACHETEXTURE = true;
6295 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
6497 boolean COMPRESSTEXTURE = false;
6598 boolean KOMPACTTEXTURE = false; // true;
6699 boolean RESIZETEXTURE = false;
....@@ -2065,7 +2098,7 @@
20652098 //System.err.println("Oeil on");
20662099 OEIL = true;
20672100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20692102 //pingthread.StepToTarget(true);
20702103 }
20712104
....@@ -2298,10 +2331,17 @@
22982331 HANDLES ^= true;
22992332 }
23002333
2334
+ Object3D paintFolder;
2335
+
23012336 void TogglePaint()
23022337 {
23032338 PAINTMODE ^= true;
23042339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
23052345 }
23062346
23072347 void SwapCamera(int a, int b)
....@@ -2398,126 +2438,19 @@
23982438 return currentGL;
23992439 }
24002440
2401
- private void GetRemoteZip(String url, String name, boolean unzip, boolean save)
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
24022442 {
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
2416
- {
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
- }
2485
- }
2486
- catch (java.net.MalformedURLException mue)
2487
- {
2488
- System.err.println("Ouch - a MalformedURLException happened.");
2489
- mue.printStackTrace();
2490
- //System.exit(2);
2491
- }
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
-
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);
25212454 }
25222455
25232456 /**/
....@@ -2528,28 +2461,31 @@
25282461
25292462 int resolution;
25302463
2531
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
25322465 {
2533
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
25342468 resolution = res;
25352469 }
25362470 }
25372471 /**/
25382472
25392473 // 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>();
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
+
25432479 int pigmentdepth = 0;
25442480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
25452481 int bumpdepth = 0;
25462482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
25472483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
25482484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2549
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
25502486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
25512487
2552
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
25532489 {
25542490 TextureData texturedata = null;
25552491
....@@ -2568,13 +2504,34 @@
25682504 if (bump)
25692505 texturedata = ConvertBump(texturedata, false);
25702506
2571
- com.sun.opengl.util.texture.Texture texture =
2572
- 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);
25732509
2574
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2575
- 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);
25762512
2577
- 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;
25782535 }
25792536
25802537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3647,6 +3604,8 @@
36473604
36483605 System.out.println("LOADING TEXTURE : " + name);
36493606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
36503609 //
36513610 if (false) // compressbit > 0)
36523611 {
....@@ -8045,7 +8004,7 @@
80458004 String pigment = Object3D.GetPigment(tex);
80468005 String bump = Object3D.GetBump(tex);
80478006
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498008 {
80508009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80518010 // System.out.println("; bump = " + bump);
....@@ -8060,8 +8019,8 @@
80608019 pigment = null;
80618020 }
80628021
8063
- ReleaseTexture(bump, true);
8064
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
80658024 }
80668025
80678026 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -8079,7 +8038,7 @@
80798038
80808039 String pigment = Object3D.GetPigment(tex);
80818040
8082
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80838042 {
80848043 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80858044 // System.out.println("; bump = " + bump);
....@@ -8090,7 +8049,7 @@
80908049 pigment = null;
80918050 }
80928051
8093
- ReleaseTexture(pigment, false);
8052
+ ReleaseTexture(tex, false);
80948053 }
80958054
80968055 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8108,7 +8067,7 @@
81088067
81098068 String bump = Object3D.GetBump(tex);
81108069
8111
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81128071 {
81138072 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
81148073 // System.out.println("; bump = " + bump);
....@@ -8119,10 +8078,10 @@
81198078 bump = null;
81208079 }
81218080
8122
- ReleaseTexture(bump, true);
8081
+ ReleaseTexture(tex, true);
81238082 }
81248083
8125
- void ReleaseTexture(String tex, boolean bump)
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
81268085 {
81278086 if (// DrawMode() != 0 || /*tex == null ||*/
81288087 ambientOcclusion ) // || !textureon)
....@@ -8133,7 +8092,7 @@
81338092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
81348093
81358094 if (tex != null)
8136
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
81378096
81388097 // //assert( texture != null );
81398098 // if (texture == null)
....@@ -8227,47 +8186,50 @@
82278186
82288187 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
82298188 {
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
- }
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;
82428230
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;
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
82718233 }
82728234
82738235 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8286,9 +8248,9 @@
82868248
82878249 String pigment = Object3D.GetPigment(tex);
82888250
8289
- usedtextures.put(pigment, pigment);
8251
+ usedtextures.add(tex);
82908252
8291
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82928254 {
82938255 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
82948256 // System.out.println("; bump = " + bump);
....@@ -8300,7 +8262,7 @@
83008262 }
83018263
83028264 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8303
- BindTexture(pigment, false, resolution);
8265
+ BindTexture(tex, false, resolution);
83048266 }
83058267
83068268 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8319,9 +8281,9 @@
83198281
83208282 String bump = Object3D.GetBump(tex);
83218283
8322
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
83238285
8324
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
83258287 {
83268288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
83278289 // System.out.println("; bump = " + bump);
....@@ -8333,7 +8295,7 @@
83338295 }
83348296
83358297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8336
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
83378299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
83388300 }
83398301
....@@ -8357,13 +8319,19 @@
83578319 return fileExists;
83588320 }
83598321
8360
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
83618323 {
8362
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8324
+ CacheTexture texturecache = null;
83638325
83648326 if (tex != null)
83658327 {
8366
- 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
+ }
83678335
83688336 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
83698337
....@@ -8373,19 +8341,34 @@
83738341 // else
83748342 // if (!texname.startsWith("/"))
83758343 // texname = "/Users/nbriere/Textures/" + texname;
8376
- if (!FileExists(tex))
8344
+ if (!FileExists(texname))
83778345 {
83788346 texname = fallbackTextureName;
83798347 }
83808348
83818349 if (CACHETEXTURE)
8382
- texture = textures.get(texname); // TEXTURE CACHE
8383
-
8384
- TextureData texturedata = null;
8385
-
8386
- if (texture == null || texture.resolution < resolution)
83878350 {
8388
- 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(""))
83898372 {
83908373 assert(!bump);
83918374 // if (bump)
....@@ -8396,19 +8379,23 @@
83968379 // }
83978380 // else
83988381 // {
8399
- texture = textures.get(tex);
8400
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
84018384 {
8402
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
84038386 }
8387
+ else
8388
+ new Exception().printStackTrace();
84048389 // }
84058390 } else
8406
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
84078392 {
84088393 assert(bump);
8409
- texture = textures.get(tex);
8410
- if (texture == null)
8411
- 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();
84128399 } else
84138400 {
84148401 //if (tex.equals("IMMORTAL"))
....@@ -8416,11 +8403,13 @@
84168403 // texture = GetResourceTexture("default.png");
84178404 //} else
84188405 //{
8419
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
84208407 {
8421
- texture = textures.get(tex);
8422
- if (texture == null)
8423
- 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();
84248413 } else
84258414 {
84268415 if (textureon)
....@@ -8479,19 +8468,19 @@
84798468 if (texturedata == null)
84808469 throw new Exception();
84818470
8482
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8471
+ texturecache = new CacheTexture(texturedata,resolution);
84838472 //texture = GetTexture(tex, bump);
84848473 }
84858474 }
84868475 //}
84878476 }
84888477
8489
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
84908479 {
84918480 //return false;
84928481
84938482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8494
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
84958484 {
84968485 // String ext = "_highres";
84978486 // if (REDUCETEXTURE)
....@@ -8508,52 +8497,17 @@
85088497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
85098498 if (!cachefile.exists())
85108499 {
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))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
85208501 {
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);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
85518504 ImageWriter writer = null;
85528505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
85538506 if (iter.hasNext()) {
85548507 writer = (ImageWriter)iter.next();
85558508 }
8556
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
85578511 try
85588512 {
85598513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8570,18 +8524,20 @@
85708524 }
85718525 }
85728526 }
8573
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
85748530 //System.out.println("Texture = " + tex);
8575
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
85768532 {
8577
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
85788534 thetex.texture.disable();
85798535 thetex.texture.dispose();
8580
- textures.remove(texname);
8536
+ textures.remove(tex);
85818537 }
85828538
8583
- texture.texturedata = texturedata;
8584
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
85858541
85868542 // newtex = true;
85878543 }
....@@ -8597,10 +8553,41 @@
85978553 }
85988554 }
85998555
8600
- return texture;
8556
+ return texturecache;
86018557 }
86028558
8603
- 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
86048591 {
86058592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86068593
....@@ -8618,21 +8605,21 @@
86188605 return texture!=null?texture.texture:null;
86198606 }
86208607
8621
- 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
86228609 {
86238610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86248611
86258612 return texture!=null?texture.texturedata:null;
86268613 }
86278614
8628
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
86298616 {
86308617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
86318618 {
86328619 return false;
86338620 }
86348621
8635
- boolean newtex = false;
8622
+ //boolean newtex = false;
86368623
86378624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
86388625
....@@ -8664,7 +8651,7 @@
86648651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
86658652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
86668653
8667
- return newtex;
8654
+ return true; // Warning: not used.
86688655 }
86698656
86708657 ShadowBuffer shadowPBuf;
....@@ -11150,9 +11137,9 @@
1115011137
1115111138 gl.glMatrixMode(GL.GL_MODELVIEW);
1115211139
11153
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11154
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11155
-//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);
1115611143 } else
1115711144 {
1115811145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11163,7 +11150,7 @@
1116311150 //System.out.println("BLENDING ON");
1116411151 gl.glEnable(GL.GL_BLEND);
1116511152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11166
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1116711154 gl.glMatrixMode(gl.GL_PROJECTION);
1116811155 gl.glLoadIdentity();
1116911156
....@@ -11649,7 +11636,7 @@
1164911636 if ((TRACK || SHADOWTRACK) || zoomonce)
1165011637 {
1165111638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11652
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1165311640 pingthread.StepToTarget(true); // true);
1165411641 // zoomonce = false;
1165511642 }
....@@ -11777,20 +11764,32 @@
1177711764 ReleaseTextures(DEFAULT_TEXTURES);
1177811765
1177911766 if (CLEANCACHE)
11780
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1178111768 {
11782
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1178311770
1178411771 // System.out.println("Texture --------- " + tex);
1178511772
11786
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1178711774 continue;
1178811775
11789
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1179011777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1179111779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11792
- textures.get(tex).texture.dispose();
11793
- 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
+ }
1179411793 }
1179511794 }
1179611795 }
....@@ -14065,7 +14064,7 @@
1406514064
1406614065 // fev 2014???
1406714066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1406914068 pingthread.StepToTarget(true); // true);
1407014069 }
1407114070 // if (!LIVE)
....@@ -14419,12 +14418,12 @@
1441914418 void GoDown(int mod)
1442014419 {
1442114420 MODIFIERS |= COMMAND;
14422
- /*
14421
+ /**/
1442314422 if((mod&SHIFT) == SHIFT)
1442414423 manipCamera.RotatePosition(0, -speed);
1442514424 else
14426
- manipCamera.BackForth(0, -speed*delta, getWidth());
14427
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1442814427 if ((mod & SHIFT) == SHIFT)
1442914428 {
1443014429 mouseMode = mouseMode; // VR??
....@@ -14440,12 +14439,12 @@
1444014439 void GoUp(int mod)
1444114440 {
1444214441 MODIFIERS |= COMMAND;
14443
- /*
14442
+ /**/
1444414443 if((mod&SHIFT) == SHIFT)
1444514444 manipCamera.RotatePosition(0, speed);
1444614445 else
14447
- manipCamera.BackForth(0, speed*delta, getWidth());
14448
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1444914448 if ((mod & SHIFT) == SHIFT)
1445014449 {
1445114450 mouseMode = mouseMode;
....@@ -14461,12 +14460,12 @@
1446114460 void GoLeft(int mod)
1446214461 {
1446314462 MODIFIERS |= COMMAND;
14464
- /*
14463
+ /**/
1446514464 if((mod&SHIFT) == SHIFT)
14466
- manipCamera.RotatePosition(speed, 0);
14467
- else
1446814465 manipCamera.Translate(speed*delta, 0, getWidth());
14469
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1447014469 if ((mod & SHIFT) == SHIFT)
1447114470 {
1447214471 mouseMode = mouseMode;
....@@ -14482,12 +14481,12 @@
1448214481 void GoRight(int mod)
1448314482 {
1448414483 MODIFIERS |= COMMAND;
14485
- /*
14484
+ /**/
1448614485 if((mod&SHIFT) == SHIFT)
14487
- manipCamera.RotatePosition(-speed, 0);
14488
- else
1448914486 manipCamera.Translate(-speed*delta, 0, getWidth());
14490
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1449114490 if ((mod & SHIFT) == SHIFT)
1449214491 {
1449314492 mouseMode = mouseMode;
....@@ -14726,7 +14725,8 @@
1472614725 Globals.MOUSEDRAGGED = false;
1472714726
1472814727 movingcamera = false;
14729
- X = Y = 0;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1473014730 //System.out.println("mouseReleased: " + e);
1473114731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1473214732 }
....@@ -14982,7 +14982,8 @@
1498214982 // break;
1498314983 case 'T':
1498414984 CACHETEXTURE ^= true;
14985
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1498614987 // repaint();
1498714988 break;
1498814989 case 'Y':
....@@ -15067,7 +15068,9 @@
1506715068 case 'E' : COMPACT ^= true;
1506815069 repaint();
1506915070 break;
15070
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1507115074 repaint();
1507215075 break;
1507315076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -15093,13 +15096,7 @@
1509315096 repaint();
1509415097 break;
1509515098 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':
15099
+ //case 'L':
1510315100 if (lightMode)
1510415101 {
1510515102 lightMode = false;
....@@ -15246,7 +15243,10 @@
1524615243 // kompactbit = 6;
1524715244 // break;
1524815245 case ' ':
15249
- ObjEditor.theFrame.ToggleFullScreen();
15246
+ lightMode ^= true;
15247
+ Globals.lighttouched = true;
15248
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15249
+ targetLookAt.set(manipCamera.lookAt);
1525015250 repaint();
1525115251 break;
1525215252 //case '`' :
....@@ -15295,12 +15295,6 @@
1529515295 break;
1529615296 case '+':
1529715297
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
-
1530415298 /*
1530515299 //fontsize += 1;
1530615300 bbzoom *= 2;
....@@ -15318,17 +15312,17 @@
1531815312 case '=':
1531915313 IncDepth();
1532015314 //fontsize += 1;
15321
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1532215316 maskbit = 6;
1532315317 break;
1532415318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1532515319 DecDepth();
1532615320 maskbit = 5;
1532715321 //if(fontsize > 1) fontsize -= 1;
15328
- if (object.editWindow == null)
15329
- new Exception().printStackTrace();
15330
- else
15331
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1533215326 break;
1533315327 case '{':
1533415328 manipCamera.shaper_fovy /= 1.1;
....@@ -15552,7 +15546,7 @@
1555215546 }
1555315547 */
1555415548
15555
- object.editWindow.EditSelection(false);
15549
+ object.GetWindow().EditSelection(false);
1555615550 }
1555715551
1555815552 void SelectParent()
....@@ -15569,10 +15563,10 @@
1556915563 {
1557015564 //selectees.remove(i);
1557115565 System.out.println("select parent of " + elem);
15572
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1557315567 } else
1557415568 {
15575
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1557615570 }
1557715571
1557815572 first = false;
....@@ -15614,12 +15608,12 @@
1561415608 for (int j = 0; j < group.children.size(); j++)
1561515609 {
1561615610 elem = (Object3D) group.children.elementAt(j);
15617
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1561815612 first = false;
1561915613 }
1562015614 } else
1562115615 {
15622
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1562315617 }
1562415618
1562515619 first = false;
....@@ -15630,21 +15624,21 @@
1563015624 {
1563115625 //Composite group = (Composite) object;
1563215626 Object3D group = object;
15633
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1563415628 }
1563515629
1563615630 void ResetTransform(int mask)
1563715631 {
1563815632 //Composite group = (Composite) object;
1563915633 Object3D group = object;
15640
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1564115635 }
1564215636
1564315637 void FlipTransform()
1564415638 {
1564515639 //Composite group = (Composite) object;
1564615640 Object3D group = object;
15647
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1564815642 // group.editWindow.ReduceMesh(true);
1564915643 }
1565015644
....@@ -15652,7 +15646,7 @@
1565215646 {
1565315647 //Composite group = (Composite) object;
1565415648 Object3D group = object;
15655
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1565615650 // group.editWindow.ReduceMesh(true);
1565715651 }
1565815652
....@@ -15660,7 +15654,7 @@
1566015654 {
1566115655 //Composite group = (Composite) object;
1566215656 Object3D group = object;
15663
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1566415658 }
1566515659
1566615660 void IncDepth()
....@@ -15836,6 +15830,7 @@
1583615830 info.bounds.y += (height - desired) / 2;
1583715831 }
1583815832 }
15833
+
1583915834 info.g = gr;
1584015835 info.camera = renderCamera;
1584115836 /*
....@@ -15845,23 +15840,44 @@
1584515840 */
1584615841 if (!isRenderer)
1584715842 {
15848
- object.drawEditHandles(info, 0);
15849
-
15850
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
1585115846 {
15852
- switch (object.selection.get(0).hitSomething)
15847
+ int hitSomething = object.selection.get(0).hitSomething;
15848
+
15849
+ info.DX = 0;
15850
+ info.DY = 0;
15851
+ info.W = 1;
15852
+ if (hitSomething == Object3D.hitCenter)
1585315853 {
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;
15854
+ info.DX = X;
15855
+ if (X != 0)
15856
+ info.DX -= info.bounds.width/2;
15857
+
15858
+ info.DY = Y;
15859
+ if (Y != 0)
15860
+ info.DY -= info.bounds.height/2;
1586315861 }
15864
-
15862
+
15863
+ object.drawEditHandles(info, 0);
15864
+
15865
+ if (drag && (X != 0 || Y != 0))
15866
+ {
15867
+ switch (hitSomething)
15868
+ {
15869
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15870
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15871
+ break;
15872
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15873
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15874
+ break;
15875
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15876
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15877
+ break;
15878
+ }
15879
+
15880
+ }
1586515881 }
1586615882 }
1586715883 }
....@@ -16659,6 +16675,14 @@
1665916675 }
1666016676 }
1666116677
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
+
1666216686 class SelectBuffer implements GLEventListener
1666316687 {
1666416688
....@@ -16738,6 +16762,17 @@
1673816762
1673916763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1674016764
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
+
1674116776 //int tmp = selection_view;
1674216777 //selection_view = -1;
1674316778 int temp = DrawMode();
....@@ -16749,6 +16784,17 @@
1674916784 // temp = DEFAULT; // patch for selection debug
1675016785 Globals.drawMode = temp; // WARNING
1675116786
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
+
1675216798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1675316799
1675416800 // trying different ways of getting the depth info over
....@@ -16852,29 +16898,31 @@
1685216898 }
1685316899
1685416900 if (!movingcamera && !PAINTMODE)
16855
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1685616902
16857
- 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)
1685816904 {
16859
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16905
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1686016906
16861
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1686216910
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();
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
+ }
1687816926 }
1687916927 else
1688016928 paintcount = 0;