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,6 +2405,45 @@
23982405 return currentGL;
23992406 }
24002407
2408
+ private BufferedImage CreateBim(TextureData texturedata)
2409
+ {
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;)
2418
+ {
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;
2427
+ }
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++)
2432
+ {
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;
2440
+ }
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;
2445
+ }
2446
+
24012447 /**/
24022448 class CacheTexture
24032449 {
....@@ -2415,9 +2461,10 @@
24152461 /**/
24162462
24172463 // TEXTURE static Texture texture;
2418
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2419
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2420
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
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
+
24212468 int pigmentdepth = 0;
24222469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24232470 int bumpdepth = 0;
....@@ -2439,6 +2486,33 @@
24392486 true,
24402487 com.sun.opengl.util.texture.TextureIO.PNG);
24412488 } 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)
24422516 {
24432517 throw new javax.media.opengl.GLException(e);
24442518 }
....@@ -3525,6 +3599,8 @@
35253599
35263600 System.out.println("LOADING TEXTURE : " + name);
35273601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35283604 //
35293605 if (false) // compressbit > 0)
35303606 {
....@@ -7923,7 +7999,7 @@
79237999 String pigment = Object3D.GetPigment(tex);
79248000 String bump = Object3D.GetBump(tex);
79258001
7926
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79278003 {
79288004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79298005 // System.out.println("; bump = " + bump);
....@@ -7957,7 +8033,7 @@
79578033
79588034 String pigment = Object3D.GetPigment(tex);
79598035
7960
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79618037 {
79628038 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79638039 // System.out.println("; bump = " + bump);
....@@ -7986,7 +8062,7 @@
79868062
79878063 String bump = Object3D.GetBump(tex);
79888064
7989
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79908066 {
79918067 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79928068 // System.out.println("; bump = " + bump);
....@@ -8105,47 +8181,50 @@
81058181
81068182 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
81078183 {
8108
- if (// DrawMode() != 0 || /*tex == null ||*/
8109
- ambientOcclusion ) // || !textureon)
8110
- {
8111
- return; // false;
8112
- }
8113
-
8114
- if (tex == null)
8115
- {
8116
- BindTexture(null,false,resolution);
8117
- BindTexture(null,true,resolution);
8118
- return;
8119
- }
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;
81208225
8121
- String pigment = Object3D.GetPigment(tex);
8122
- String bump = Object3D.GetBump(tex);
8123
-
8124
- usedtextures.put(pigment, pigment);
8125
- usedtextures.put(bump, bump);
8126
-
8127
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8128
- {
8129
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8130
- // System.out.println("; bump = " + bump);
8131
- }
8132
-
8133
- if (bump.equals(""))
8134
- {
8135
- bump = null;
8136
- }
8137
- if (pigment.equals(""))
8138
- {
8139
- pigment = null;
8140
- }
8141
-
8142
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8143
- BindTexture(pigment, false, resolution);
8144
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8145
- BindTexture(bump, true, resolution);
8146
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8147
-
8148
- return; // true;
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
81498228 }
81508229
81518230 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8158,15 +8237,15 @@
81588237
81598238 if (tex == null)
81608239 {
8161
- BindTexture(null,false,resolution);
8240
+ BindTexture(null, null,false,resolution);
81628241 return;
81638242 }
81648243
81658244 String pigment = Object3D.GetPigment(tex);
81668245
8167
- usedtextures.put(pigment, pigment);
8246
+ usedtextures.add(pigment);
81688247
8169
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81708249 {
81718250 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81728251 // System.out.println("; bump = " + bump);
....@@ -8178,7 +8257,7 @@
81788257 }
81798258
81808259 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8181
- BindTexture(pigment, false, resolution);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
81828261 }
81838262
81848263 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8191,15 +8270,15 @@
81918270
81928271 if (tex == null)
81938272 {
8194
- BindTexture(null,true,resolution);
8273
+ BindTexture(null, null,true,resolution);
81958274 return;
81968275 }
81978276
81988277 String bump = Object3D.GetBump(tex);
81998278
8200
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
82018280
8202
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82038282 {
82048283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
82058284 // System.out.println("; bump = " + bump);
....@@ -8211,7 +8290,7 @@
82118290 }
82128291
82138292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8214
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
82158294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82168295 }
82178296
....@@ -8235,9 +8314,9 @@
82358314 return fileExists;
82368315 }
82378316
8238
- 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
82398318 {
8240
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8319
+ CacheTexture texturecache = null;
82418320
82428321 if (tex != null)
82438322 {
....@@ -8257,12 +8336,22 @@
82578336 }
82588337
82598338 if (CACHETEXTURE)
8260
- texture = textures.get(texname); // TEXTURE CACHE
8261
-
8262
- TextureData texturedata = null;
8263
-
8264
- if (texture == null || texture.resolution < resolution)
82658339 {
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
82668355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82678356 {
82688357 assert(!bump);
....@@ -8274,19 +8363,23 @@
82748363 // }
82758364 // else
82768365 // {
8277
- texture = textures.get(tex);
8278
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
82798368 {
8280
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82818370 }
8371
+ else
8372
+ new Exception().printStackTrace();
82828373 // }
82838374 } else
82848375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82858376 {
82868377 assert(bump);
8287
- texture = textures.get(tex);
8288
- if (texture == null)
8289
- 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();
82908383 } else
82918384 {
82928385 //if (tex.equals("IMMORTAL"))
....@@ -8296,9 +8389,11 @@
82968389 //{
82978390 if (tex.equals("WHITE_NOISE"))
82988391 {
8299
- texture = textures.get(tex);
8300
- if (texture == null)
8301
- 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();
83028397 } else
83038398 {
83048399 if (textureon)
....@@ -8357,19 +8452,20 @@
83578452 if (texturedata == null)
83588453 throw new Exception();
83598454
8360
- 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);
83618456 //texture = GetTexture(tex, bump);
83628457 }
83638458 }
83648459 //}
83658460 }
83668461
8367
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
83688463 {
83698464 //return false;
8465
+ assert(bim == null);
83708466
83718467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8372
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83738469 {
83748470 // String ext = "_highres";
83758471 // if (REDUCETEXTURE)
....@@ -8386,52 +8482,17 @@
83868482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83878483 if (!cachefile.exists())
83888484 {
8389
- // cache to disk
8390
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8391
- //buffers[0].
8392
-
8393
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8394
- int[] pixels = new int[bytebuf.capacity()/3];
8395
-
8396
- // squared size heuristic...
8397
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
83988486 {
8399
- for (int i=pixels.length; --i>=0;)
8400
- {
8401
- int i3 = i*3;
8402
- pixels[i] = 0xFF;
8403
- pixels[i] <<= 8;
8404
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8405
- pixels[i] <<= 8;
8406
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8407
- pixels[i] <<= 8;
8408
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8409
- }
8410
-
8411
- /*
8412
- int r=0,g=0,b=0,a=0;
8413
- for (int i=0; i<width; i++)
8414
- for (int j=0; j<height; j++)
8415
- {
8416
- int index = j*width+i;
8417
- int p = pixels[index];
8418
- a = ((p>>24) & 0xFF);
8419
- r = ((p>>16) & 0xFF);
8420
- g = ((p>>8) & 0xFF);
8421
- b = (p & 0xFF);
8422
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8423
- }
8424
- /**/
8425
- int width = (int)Math.sqrt(pixels.length); // squared
8426
- int height = width;
8427
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8428
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
84298489 ImageWriter writer = null;
84308490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84318491 if (iter.hasNext()) {
84328492 writer = (ImageWriter)iter.next();
84338493 }
8434
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
84358496 try
84368497 {
84378498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8458,8 +8519,8 @@
84588519 textures.remove(texname);
84598520 }
84608521
8461
- texture.texturedata = texturedata;
8462
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
84638524
84648525 // newtex = true;
84658526 }
....@@ -8475,12 +8536,17 @@
84758536 }
84768537 }
84778538
8478
- return texture;
8539
+ return texturecache;
84798540 }
84808541
8481
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8542
+ static void EmbedTextures(cTexture tex)
84828543 {
8483
- 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);
84848550
84858551 if (bump)
84868552 {
....@@ -8496,23 +8562,23 @@
84968562 return texture!=null?texture.texture:null;
84978563 }
84988564
8499
- 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
85008566 {
8501
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
85028568
85038569 return texture!=null?texture.texturedata:null;
85048570 }
85058571
8506
- 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
85078573 {
85088574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
85098575 {
85108576 return false;
85118577 }
85128578
8513
- boolean newtex = false;
8579
+ //boolean newtex = false;
85148580
8515
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
85168582
85178583 if (texture == null)
85188584 return false;
....@@ -8542,7 +8608,7 @@
85428608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85438609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85448610
8545
- return newtex;
8611
+ return true; // Warning: not used.
85468612 }
85478613
85488614 ShadowBuffer shadowPBuf;
....@@ -10999,7 +11065,7 @@
1099911065
1100011066 try
1100111067 {
11002
- BindTexture(NOISE_TEXTURE, false, 2);
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
1100311069 }
1100411070 catch (Exception e)
1100511071 {
....@@ -11028,9 +11094,9 @@
1102811094
1102911095 gl.glMatrixMode(GL.GL_MODELVIEW);
1103011096
11031
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11032
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11033
-//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);
1103411100 } else
1103511101 {
1103611102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11041,7 +11107,7 @@
1104111107 //System.out.println("BLENDING ON");
1104211108 gl.glEnable(GL.GL_BLEND);
1104311109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11044
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1104511111 gl.glMatrixMode(gl.GL_PROJECTION);
1104611112 gl.glLoadIdentity();
1104711113
....@@ -11527,7 +11593,7 @@
1152711593 if ((TRACK || SHADOWTRACK) || zoomonce)
1152811594 {
1152911595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11530
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1153111597 pingthread.StepToTarget(true); // true);
1153211598 // zoomonce = false;
1153311599 }
....@@ -11664,7 +11730,7 @@
1166411730 if (tex.equals("WHITE_NOISE"))
1166511731 continue;
1166611732
11667
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1166811734 {
1166911735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1167011736 textures.get(tex).texture.dispose();
....@@ -13375,9 +13441,10 @@
1337513441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1337613442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1337713443 //"MOV " + dest + ".w," + "normal.z;" +
13378
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13379
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13380
- //"MOV " + dest + ".z," + "params2.w;" +
13444
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13445
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13446
+
13447
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1338113448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1338213449 "RCP " + dest + ".w," + dest + ".w;" +
1338313450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13942,7 +14009,7 @@
1394214009
1394314010 // fev 2014???
1394414011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13945
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1394614013 pingthread.StepToTarget(true); // true);
1394714014 }
1394814015 // if (!LIVE)
....@@ -14296,12 +14363,12 @@
1429614363 void GoDown(int mod)
1429714364 {
1429814365 MODIFIERS |= COMMAND;
14299
- /*
14366
+ /**/
1430014367 if((mod&SHIFT) == SHIFT)
1430114368 manipCamera.RotatePosition(0, -speed);
1430214369 else
14303
- manipCamera.BackForth(0, -speed*delta, getWidth());
14304
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1430514372 if ((mod & SHIFT) == SHIFT)
1430614373 {
1430714374 mouseMode = mouseMode; // VR??
....@@ -14317,12 +14384,12 @@
1431714384 void GoUp(int mod)
1431814385 {
1431914386 MODIFIERS |= COMMAND;
14320
- /*
14387
+ /**/
1432114388 if((mod&SHIFT) == SHIFT)
1432214389 manipCamera.RotatePosition(0, speed);
1432314390 else
14324
- manipCamera.BackForth(0, speed*delta, getWidth());
14325
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1432614393 if ((mod & SHIFT) == SHIFT)
1432714394 {
1432814395 mouseMode = mouseMode;
....@@ -14338,12 +14405,12 @@
1433814405 void GoLeft(int mod)
1433914406 {
1434014407 MODIFIERS |= COMMAND;
14341
- /*
14408
+ /**/
1434214409 if((mod&SHIFT) == SHIFT)
14343
- manipCamera.RotatePosition(speed, 0);
14344
- else
1434514410 manipCamera.Translate(speed*delta, 0, getWidth());
14346
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1434714414 if ((mod & SHIFT) == SHIFT)
1434814415 {
1434914416 mouseMode = mouseMode;
....@@ -14359,12 +14426,12 @@
1435914426 void GoRight(int mod)
1436014427 {
1436114428 MODIFIERS |= COMMAND;
14362
- /*
14429
+ /**/
1436314430 if((mod&SHIFT) == SHIFT)
14364
- manipCamera.RotatePosition(-speed, 0);
14365
- else
1436614431 manipCamera.Translate(-speed*delta, 0, getWidth());
14367
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1436814435 if ((mod & SHIFT) == SHIFT)
1436914436 {
1437014437 mouseMode = mouseMode;
....@@ -14603,7 +14670,8 @@
1460314670 Globals.MOUSEDRAGGED = false;
1460414671
1460514672 movingcamera = false;
14606
- X = Y = 0;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1460714675 //System.out.println("mouseReleased: " + e);
1460814676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1460914677 }
....@@ -14944,7 +15012,9 @@
1494415012 case 'E' : COMPACT ^= true;
1494515013 repaint();
1494615014 break;
14947
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1494815018 repaint();
1494915019 break;
1495015020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14970,13 +15040,7 @@
1497015040 repaint();
1497115041 break;
1497215042 case 'l':
14973
- lightMode ^= true;
14974
- Globals.lighttouched = true;
14975
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14976
- targetLookAt.set(manipCamera.lookAt);
14977
- repaint();
14978
- break;
14979
- case 'L':
15043
+ //case 'L':
1498015044 if (lightMode)
1498115045 {
1498215046 lightMode = false;
....@@ -15119,11 +15183,14 @@
1511915183 case '_':
1512015184 kompactbit = 5;
1512115185 break;
15122
- case '+':
15123
- kompactbit = 6;
15124
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1512515189 case ' ':
15126
- ObjEditor.theFrame.ToggleFullScreen();
15190
+ lightMode ^= true;
15191
+ Globals.lighttouched = true;
15192
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15193
+ targetLookAt.set(manipCamera.lookAt);
1512715194 repaint();
1512815195 break;
1512915196 //case '`' :
....@@ -15170,8 +15237,9 @@
1517015237 case DELETE:
1517115238 ClearSelection();
1517215239 break;
15173
- /*
1517415240 case '+':
15241
+
15242
+ /*
1517515243 //fontsize += 1;
1517615244 bbzoom *= 2;
1517715245 repaint();
....@@ -15188,17 +15256,17 @@
1518815256 case '=':
1518915257 IncDepth();
1519015258 //fontsize += 1;
15191
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1519215260 maskbit = 6;
1519315261 break;
1519415262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1519515263 DecDepth();
1519615264 maskbit = 5;
1519715265 //if(fontsize > 1) fontsize -= 1;
15198
- if (object.editWindow == null)
15199
- new Exception().printStackTrace();
15200
- else
15201
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1520215270 break;
1520315271 case '{':
1520415272 manipCamera.shaper_fovy /= 1.1;
....@@ -15422,7 +15490,7 @@
1542215490 }
1542315491 */
1542415492
15425
- object.editWindow.EditSelection(false);
15493
+ object.GetWindow().EditSelection(false);
1542615494 }
1542715495
1542815496 void SelectParent()
....@@ -15439,10 +15507,10 @@
1543915507 {
1544015508 //selectees.remove(i);
1544115509 System.out.println("select parent of " + elem);
15442
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1544315511 } else
1544415512 {
15445
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1544615514 }
1544715515
1544815516 first = false;
....@@ -15484,12 +15552,12 @@
1548415552 for (int j = 0; j < group.children.size(); j++)
1548515553 {
1548615554 elem = (Object3D) group.children.elementAt(j);
15487
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1548815556 first = false;
1548915557 }
1549015558 } else
1549115559 {
15492
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1549315561 }
1549415562
1549515563 first = false;
....@@ -15500,21 +15568,21 @@
1550015568 {
1550115569 //Composite group = (Composite) object;
1550215570 Object3D group = object;
15503
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1550415572 }
1550515573
1550615574 void ResetTransform(int mask)
1550715575 {
1550815576 //Composite group = (Composite) object;
1550915577 Object3D group = object;
15510
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1551115579 }
1551215580
1551315581 void FlipTransform()
1551415582 {
1551515583 //Composite group = (Composite) object;
1551615584 Object3D group = object;
15517
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1551815586 // group.editWindow.ReduceMesh(true);
1551915587 }
1552015588
....@@ -15522,7 +15590,7 @@
1552215590 {
1552315591 //Composite group = (Composite) object;
1552415592 Object3D group = object;
15525
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1552615594 // group.editWindow.ReduceMesh(true);
1552715595 }
1552815596
....@@ -15530,7 +15598,7 @@
1553015598 {
1553115599 //Composite group = (Composite) object;
1553215600 Object3D group = object;
15533
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1553415602 }
1553515603
1553615604 void IncDepth()
....@@ -15706,6 +15774,7 @@
1570615774 info.bounds.y += (height - desired) / 2;
1570715775 }
1570815776 }
15777
+
1570915778 info.g = gr;
1571015779 info.camera = renderCamera;
1571115780 /*
....@@ -15715,23 +15784,44 @@
1571515784 */
1571615785 if (!isRenderer)
1571715786 {
15718
- object.drawEditHandles(info, 0);
15719
-
15720
- 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)
1572115790 {
15722
- 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)
1572315797 {
15724
- case Object3D.hitCenter: gr.setColor(Color.pink);
15725
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15726
- break;
15727
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15728
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15729
- break;
15730
- case Object3D.hitScale: gr.setColor(Color.cyan);
15731
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15732
- 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;
1573315805 }
15734
-
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
+ }
1573515825 }
1573615826 }
1573715827 }
....@@ -16529,6 +16619,14 @@
1652916619 }
1653016620 }
1653116621
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
+
1653216630 class SelectBuffer implements GLEventListener
1653316631 {
1653416632
....@@ -16608,6 +16706,17 @@
1660816706
1660916707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1661016708
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
+
1661116720 //int tmp = selection_view;
1661216721 //selection_view = -1;
1661316722 int temp = DrawMode();
....@@ -16619,6 +16728,17 @@
1661916728 // temp = DEFAULT; // patch for selection debug
1662016729 Globals.drawMode = temp; // WARNING
1662116730
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
+
1662216742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1662316743
1662416744 // trying different ways of getting the depth info over
....@@ -16722,29 +16842,31 @@
1672216842 }
1672316843
1672416844 if (!movingcamera && !PAINTMODE)
16725
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1672616846
16727
- 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)
1672816848 {
16729
- 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);
1673016850
16731
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1673216854
16733
- group.CreateMaterial(); // use a void leaf to select instances
16734
-
16735
- group.add(paintobj); // link
16736
-
16737
- object.editWindow.SnapObject(group);
16738
-
16739
- Object3D folder = object.editWindow.copy;
16740
-
16741
- if (object.editWindow.copy.selection.Size() > 0)
16742
- folder = object.editWindow.copy.selection.elementAt(0);
16743
-
16744
- folder.add(group);
16745
-
16746
- object.editWindow.ResetModel();
16747
- 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
+ }
1674816870 }
1674916871 else
1675016872 paintcount = 0;