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;
....@@ -335,14 +368,28 @@
335368 display.options1[2] = material.shadowbias;
336369 display.options1[3] = material.aniso;
337370 display.options1[4] = material.anisoV;
371
+// System.out.println("display.options1[0] " + display.options1[0]);
372
+// System.out.println("display.options1[1] " + display.options1[1]);
373
+// System.out.println("display.options1[2] " + display.options1[2]);
374
+// System.out.println("display.options1[3] " + display.options1[3]);
375
+// System.out.println("display.options1[4] " + display.options1[4]);
338376 display.options2[0] = material.opacity;
339377 display.options2[1] = material.diffuse;
340378 display.options2[2] = material.factor;
379
+// System.out.println("display.options2[0] " + display.options2[0]);
380
+// System.out.println("display.options2[1] " + display.options2[1]);
381
+// System.out.println("display.options2[2] " + display.options2[2]);
341382
342383 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
384
+// System.out.println("display.options3[0] " + display.options3[0]);
385
+// System.out.println("display.options3[1] " + display.options3[1]);
386
+// System.out.println("display.options3[2] " + display.options3[2]);
343387 display.options4[0] = material.cameralight/0.2f;
344388 display.options4[1] = material.subsurface;
345389 display.options4[2] = material.sheen;
390
+// System.out.println("display.options4[0] " + display.options4[0]);
391
+// System.out.println("display.options4[1] " + display.options4[1]);
392
+// System.out.println("display.options4[2] " + display.options4[2]);
346393
347394 // if (display.CURRENTANTIALIAS > 0)
348395 // display.options3[3] /= 4;
....@@ -2051,7 +2098,7 @@
20512098 //System.err.println("Oeil on");
20522099 OEIL = true;
20532100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2054
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20552102 //pingthread.StepToTarget(true);
20562103 }
20572104
....@@ -2284,10 +2331,17 @@
22842331 HANDLES ^= true;
22852332 }
22862333
2334
+ Object3D paintFolder;
2335
+
22872336 void TogglePaint()
22882337 {
22892338 PAINTMODE ^= true;
22902339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
22912345 }
22922346
22932347 void SwapCamera(int a, int b)
....@@ -2384,6 +2438,21 @@
23842438 return currentGL;
23852439 }
23862440
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
2454
+ }
2455
+
23872456 /**/
23882457 class CacheTexture
23892458 {
....@@ -2392,28 +2461,31 @@
23922461
23932462 int resolution;
23942463
2395
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23962465 {
2397
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
23982468 resolution = res;
23992469 }
24002470 }
24012471 /**/
24022472
24032473 // TEXTURE static Texture texture;
2404
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2405
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2406
- 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
+
24072479 int pigmentdepth = 0;
24082480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24092481 int bumpdepth = 0;
24102482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24112483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24122484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2413
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24142486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24152487
2416
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24172489 {
24182490 TextureData texturedata = null;
24192491
....@@ -2432,13 +2504,34 @@
24322504 if (bump)
24332505 texturedata = ConvertBump(texturedata, false);
24342506
2435
- com.sun.opengl.util.texture.Texture texture =
2436
- 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);
24372509
2438
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2439
- 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);
24402512
2441
- 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;
24422535 }
24432536
24442537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3511,6 +3604,8 @@
35113604
35123605 System.out.println("LOADING TEXTURE : " + name);
35133606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
35143609 //
35153610 if (false) // compressbit > 0)
35163611 {
....@@ -7909,7 +8004,7 @@
79098004 String pigment = Object3D.GetPigment(tex);
79108005 String bump = Object3D.GetBump(tex);
79118006
7912
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79138008 {
79148009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79158010 // System.out.println("; bump = " + bump);
....@@ -7924,8 +8019,8 @@
79248019 pigment = null;
79258020 }
79268021
7927
- ReleaseTexture(bump, true);
7928
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79298024 }
79308025
79318026 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -7943,7 +8038,7 @@
79438038
79448039 String pigment = Object3D.GetPigment(tex);
79458040
7946
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79478042 {
79488043 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79498044 // System.out.println("; bump = " + bump);
....@@ -7954,7 +8049,7 @@
79548049 pigment = null;
79558050 }
79568051
7957
- ReleaseTexture(pigment, false);
8052
+ ReleaseTexture(tex, false);
79588053 }
79598054
79608055 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -7972,7 +8067,7 @@
79728067
79738068 String bump = Object3D.GetBump(tex);
79748069
7975
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79768071 {
79778072 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79788073 // System.out.println("; bump = " + bump);
....@@ -7983,10 +8078,10 @@
79838078 bump = null;
79848079 }
79858080
7986
- ReleaseTexture(bump, true);
8081
+ ReleaseTexture(tex, true);
79878082 }
79888083
7989
- void ReleaseTexture(String tex, boolean bump)
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
79908085 {
79918086 if (// DrawMode() != 0 || /*tex == null ||*/
79928087 ambientOcclusion ) // || !textureon)
....@@ -7997,7 +8092,7 @@
79978092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79988093
79998094 if (tex != null)
8000
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80018096
80028097 // //assert( texture != null );
80038098 // if (texture == null)
....@@ -8091,47 +8186,50 @@
80918186
80928187 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80938188 {
8094
- if (// DrawMode() != 0 || /*tex == null ||*/
8095
- ambientOcclusion ) // || !textureon)
8096
- {
8097
- return; // false;
8098
- }
8099
-
8100
- if (tex == null)
8101
- {
8102
- BindTexture(null,false,resolution);
8103
- BindTexture(null,true,resolution);
8104
- return;
8105
- }
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;
81068230
8107
- String pigment = Object3D.GetPigment(tex);
8108
- String bump = Object3D.GetBump(tex);
8109
-
8110
- usedtextures.put(pigment, pigment);
8111
- usedtextures.put(bump, bump);
8112
-
8113
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8114
- {
8115
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8116
- // System.out.println("; bump = " + bump);
8117
- }
8118
-
8119
- if (bump.equals(""))
8120
- {
8121
- bump = null;
8122
- }
8123
- if (pigment.equals(""))
8124
- {
8125
- pigment = null;
8126
- }
8127
-
8128
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8129
- BindTexture(pigment, false, resolution);
8130
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8131
- BindTexture(bump, true, resolution);
8132
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8133
-
8134
- return; // true;
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
81358233 }
81368234
81378235 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8150,9 +8248,9 @@
81508248
81518249 String pigment = Object3D.GetPigment(tex);
81528250
8153
- usedtextures.put(pigment, pigment);
8251
+ usedtextures.add(tex);
81548252
8155
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81568254 {
81578255 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81588256 // System.out.println("; bump = " + bump);
....@@ -8164,7 +8262,7 @@
81648262 }
81658263
81668264 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8167
- BindTexture(pigment, false, resolution);
8265
+ BindTexture(tex, false, resolution);
81688266 }
81698267
81708268 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8183,9 +8281,9 @@
81838281
81848282 String bump = Object3D.GetBump(tex);
81858283
8186
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
81878285
8188
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81898287 {
81908288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81918289 // System.out.println("; bump = " + bump);
....@@ -8197,7 +8295,7 @@
81978295 }
81988296
81998297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8200
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
82018299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82028300 }
82038301
....@@ -8221,13 +8319,19 @@
82218319 return fileExists;
82228320 }
82238321
8224
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82258323 {
8226
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8324
+ CacheTexture texturecache = null;
82278325
82288326 if (tex != null)
82298327 {
8230
- 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
+ }
82318335
82328336 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82338337
....@@ -8237,19 +8341,34 @@
82378341 // else
82388342 // if (!texname.startsWith("/"))
82398343 // texname = "/Users/nbriere/Textures/" + texname;
8240
- if (!FileExists(tex))
8344
+ if (!FileExists(texname))
82418345 {
82428346 texname = fallbackTextureName;
82438347 }
82448348
82458349 if (CACHETEXTURE)
8246
- texture = textures.get(texname); // TEXTURE CACHE
8247
-
8248
- TextureData texturedata = null;
8249
-
8250
- if (texture == null || texture.resolution < resolution)
82518350 {
8252
- 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(""))
82538372 {
82548373 assert(!bump);
82558374 // if (bump)
....@@ -8260,19 +8379,23 @@
82608379 // }
82618380 // else
82628381 // {
8263
- texture = textures.get(tex);
8264
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
82658384 {
8266
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82678386 }
8387
+ else
8388
+ new Exception().printStackTrace();
82688389 // }
82698390 } else
8270
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82718392 {
82728393 assert(bump);
8273
- texture = textures.get(tex);
8274
- if (texture == null)
8275
- 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();
82768399 } else
82778400 {
82788401 //if (tex.equals("IMMORTAL"))
....@@ -8280,11 +8403,13 @@
82808403 // texture = GetResourceTexture("default.png");
82818404 //} else
82828405 //{
8283
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
82848407 {
8285
- texture = textures.get(tex);
8286
- if (texture == null)
8287
- 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();
82888413 } else
82898414 {
82908415 if (textureon)
....@@ -8343,19 +8468,19 @@
83438468 if (texturedata == null)
83448469 throw new Exception();
83458470
8346
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8471
+ texturecache = new CacheTexture(texturedata,resolution);
83478472 //texture = GetTexture(tex, bump);
83488473 }
83498474 }
83508475 //}
83518476 }
83528477
8353
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
83548479 {
83558480 //return false;
83568481
83578482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8358
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83598484 {
83608485 // String ext = "_highres";
83618486 // if (REDUCETEXTURE)
....@@ -8372,52 +8497,17 @@
83728497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83738498 if (!cachefile.exists())
83748499 {
8375
- // cache to disk
8376
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8377
- //buffers[0].
8378
-
8379
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8380
- int[] pixels = new int[bytebuf.capacity()/3];
8381
-
8382
- // squared size heuristic...
8383
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
83848501 {
8385
- for (int i=pixels.length; --i>=0;)
8386
- {
8387
- int i3 = i*3;
8388
- pixels[i] = 0xFF;
8389
- pixels[i] <<= 8;
8390
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8391
- pixels[i] <<= 8;
8392
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8393
- pixels[i] <<= 8;
8394
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8395
- }
8396
-
8397
- /*
8398
- int r=0,g=0,b=0,a=0;
8399
- for (int i=0; i<width; i++)
8400
- for (int j=0; j<height; j++)
8401
- {
8402
- int index = j*width+i;
8403
- int p = pixels[index];
8404
- a = ((p>>24) & 0xFF);
8405
- r = ((p>>16) & 0xFF);
8406
- g = ((p>>8) & 0xFF);
8407
- b = (p & 0xFF);
8408
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8409
- }
8410
- /**/
8411
- int width = (int)Math.sqrt(pixels.length); // squared
8412
- int height = width;
8413
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8414
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
84158504 ImageWriter writer = null;
84168505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84178506 if (iter.hasNext()) {
84188507 writer = (ImageWriter)iter.next();
84198508 }
8420
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
84218511 try
84228512 {
84238513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8434,18 +8524,20 @@
84348524 }
84358525 }
84368526 }
8437
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
84388530 //System.out.println("Texture = " + tex);
8439
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
84408532 {
8441
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
84428534 thetex.texture.disable();
84438535 thetex.texture.dispose();
8444
- textures.remove(texname);
8536
+ textures.remove(tex);
84458537 }
84468538
8447
- texture.texturedata = texturedata;
8448
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
84498541
84508542 // newtex = true;
84518543 }
....@@ -8461,10 +8553,41 @@
84618553 }
84628554 }
84638555
8464
- return texture;
8556
+ return texturecache;
84658557 }
84668558
8467
- 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
84688591 {
84698592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84708593
....@@ -8482,21 +8605,21 @@
84828605 return texture!=null?texture.texture:null;
84838606 }
84848607
8485
- 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
84868609 {
84878610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84888611
84898612 return texture!=null?texture.texturedata:null;
84908613 }
84918614
8492
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
84938616 {
84948617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84958618 {
84968619 return false;
84978620 }
84988621
8499
- boolean newtex = false;
8622
+ //boolean newtex = false;
85008623
85018624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85028625
....@@ -8528,7 +8651,7 @@
85288651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85298652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85308653
8531
- return newtex;
8654
+ return true; // Warning: not used.
85328655 }
85338656
85348657 ShadowBuffer shadowPBuf;
....@@ -9374,13 +9497,13 @@
93749497 void ResetOptions()
93759498 {
93769499 options1[0] = 100;
9377
- options1[1] = 0.00001f;
9378
- options1[2] = 20;
9500
+ options1[1] = 0.025f;
9501
+ options1[2] = 0.01f;
93799502 options1[3] = 0;
93809503 options1[4] = 0;
93819504
93829505 options2[0] = 0;
9383
- options2[1] = 1;
9506
+ options2[1] = 0.75f;
93849507 options2[2] = 0;
93859508 options2[3] = 0;
93869509
....@@ -11014,9 +11137,9 @@
1101411137
1101511138 gl.glMatrixMode(GL.GL_MODELVIEW);
1101611139
11017
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11018
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11019
-//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);
1102011143 } else
1102111144 {
1102211145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11027,7 +11150,7 @@
1102711150 //System.out.println("BLENDING ON");
1102811151 gl.glEnable(GL.GL_BLEND);
1102911152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11030
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1103111154 gl.glMatrixMode(gl.GL_PROJECTION);
1103211155 gl.glLoadIdentity();
1103311156
....@@ -11513,7 +11636,7 @@
1151311636 if ((TRACK || SHADOWTRACK) || zoomonce)
1151411637 {
1151511638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11516
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1151711640 pingthread.StepToTarget(true); // true);
1151811641 // zoomonce = false;
1151911642 }
....@@ -11641,20 +11764,32 @@
1164111764 ReleaseTextures(DEFAULT_TEXTURES);
1164211765
1164311766 if (CLEANCACHE)
11644
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1164511768 {
11646
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1164711770
1164811771 // System.out.println("Texture --------- " + tex);
1164911772
11650
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1165111774 continue;
1165211775
11653
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1165411777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1165511779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11656
- textures.get(tex).texture.dispose();
11657
- 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
+ }
1165811793 }
1165911794 }
1166011795 }
....@@ -13361,9 +13496,10 @@
1336113496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1336213497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1336313498 //"MOV " + dest + ".w," + "normal.z;" +
13364
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13365
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13366
- //"MOV " + dest + ".z," + "params2.w;" +
13499
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13500
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13501
+
13502
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1336713503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1336813504 "RCP " + dest + ".w," + dest + ".w;" +
1336913505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13928,7 +14064,7 @@
1392814064
1392914065 // fev 2014???
1393014066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13931
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1393214068 pingthread.StepToTarget(true); // true);
1393314069 }
1393414070 // if (!LIVE)
....@@ -14282,12 +14418,12 @@
1428214418 void GoDown(int mod)
1428314419 {
1428414420 MODIFIERS |= COMMAND;
14285
- /*
14421
+ /**/
1428614422 if((mod&SHIFT) == SHIFT)
1428714423 manipCamera.RotatePosition(0, -speed);
1428814424 else
14289
- manipCamera.BackForth(0, -speed*delta, getWidth());
14290
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1429114427 if ((mod & SHIFT) == SHIFT)
1429214428 {
1429314429 mouseMode = mouseMode; // VR??
....@@ -14303,12 +14439,12 @@
1430314439 void GoUp(int mod)
1430414440 {
1430514441 MODIFIERS |= COMMAND;
14306
- /*
14442
+ /**/
1430714443 if((mod&SHIFT) == SHIFT)
1430814444 manipCamera.RotatePosition(0, speed);
1430914445 else
14310
- manipCamera.BackForth(0, speed*delta, getWidth());
14311
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1431214448 if ((mod & SHIFT) == SHIFT)
1431314449 {
1431414450 mouseMode = mouseMode;
....@@ -14324,12 +14460,12 @@
1432414460 void GoLeft(int mod)
1432514461 {
1432614462 MODIFIERS |= COMMAND;
14327
- /*
14463
+ /**/
1432814464 if((mod&SHIFT) == SHIFT)
14329
- manipCamera.RotatePosition(speed, 0);
14330
- else
1433114465 manipCamera.Translate(speed*delta, 0, getWidth());
14332
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1433314469 if ((mod & SHIFT) == SHIFT)
1433414470 {
1433514471 mouseMode = mouseMode;
....@@ -14345,12 +14481,12 @@
1434514481 void GoRight(int mod)
1434614482 {
1434714483 MODIFIERS |= COMMAND;
14348
- /*
14484
+ /**/
1434914485 if((mod&SHIFT) == SHIFT)
14350
- manipCamera.RotatePosition(-speed, 0);
14351
- else
1435214486 manipCamera.Translate(-speed*delta, 0, getWidth());
14353
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1435414490 if ((mod & SHIFT) == SHIFT)
1435514491 {
1435614492 mouseMode = mouseMode;
....@@ -14589,7 +14725,8 @@
1458914725 Globals.MOUSEDRAGGED = false;
1459014726
1459114727 movingcamera = false;
14592
- X = Y = 0;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1459314730 //System.out.println("mouseReleased: " + e);
1459414731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1459514732 }
....@@ -14845,7 +14982,8 @@
1484514982 // break;
1484614983 case 'T':
1484714984 CACHETEXTURE ^= true;
14848
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1484914987 // repaint();
1485014988 break;
1485114989 case 'Y':
....@@ -14930,7 +15068,9 @@
1493015068 case 'E' : COMPACT ^= true;
1493115069 repaint();
1493215070 break;
14933
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1493415074 repaint();
1493515075 break;
1493615076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14956,13 +15096,7 @@
1495615096 repaint();
1495715097 break;
1495815098 case 'l':
14959
- lightMode ^= true;
14960
- Globals.lighttouched = true;
14961
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14962
- targetLookAt.set(manipCamera.lookAt);
14963
- repaint();
14964
- break;
14965
- case 'L':
15099
+ //case 'L':
1496615100 if (lightMode)
1496715101 {
1496815102 lightMode = false;
....@@ -15105,11 +15239,14 @@
1510515239 case '_':
1510615240 kompactbit = 5;
1510715241 break;
15108
- case '+':
15109
- kompactbit = 6;
15110
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1511115245 case ' ':
15112
- ObjEditor.theFrame.ToggleFullScreen();
15246
+ lightMode ^= true;
15247
+ Globals.lighttouched = true;
15248
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15249
+ targetLookAt.set(manipCamera.lookAt);
1511315250 repaint();
1511415251 break;
1511515252 //case '`' :
....@@ -15156,8 +15293,9 @@
1515615293 case DELETE:
1515715294 ClearSelection();
1515815295 break;
15159
- /*
1516015296 case '+':
15297
+
15298
+ /*
1516115299 //fontsize += 1;
1516215300 bbzoom *= 2;
1516315301 repaint();
....@@ -15174,17 +15312,17 @@
1517415312 case '=':
1517515313 IncDepth();
1517615314 //fontsize += 1;
15177
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1517815316 maskbit = 6;
1517915317 break;
1518015318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1518115319 DecDepth();
1518215320 maskbit = 5;
1518315321 //if(fontsize > 1) fontsize -= 1;
15184
- if (object.editWindow == null)
15185
- new Exception().printStackTrace();
15186
- else
15187
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1518815326 break;
1518915327 case '{':
1519015328 manipCamera.shaper_fovy /= 1.1;
....@@ -15408,7 +15546,7 @@
1540815546 }
1540915547 */
1541015548
15411
- object.editWindow.EditSelection(false);
15549
+ object.GetWindow().EditSelection(false);
1541215550 }
1541315551
1541415552 void SelectParent()
....@@ -15425,10 +15563,10 @@
1542515563 {
1542615564 //selectees.remove(i);
1542715565 System.out.println("select parent of " + elem);
15428
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1542915567 } else
1543015568 {
15431
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1543215570 }
1543315571
1543415572 first = false;
....@@ -15470,12 +15608,12 @@
1547015608 for (int j = 0; j < group.children.size(); j++)
1547115609 {
1547215610 elem = (Object3D) group.children.elementAt(j);
15473
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1547415612 first = false;
1547515613 }
1547615614 } else
1547715615 {
15478
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1547915617 }
1548015618
1548115619 first = false;
....@@ -15486,21 +15624,21 @@
1548615624 {
1548715625 //Composite group = (Composite) object;
1548815626 Object3D group = object;
15489
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1549015628 }
1549115629
1549215630 void ResetTransform(int mask)
1549315631 {
1549415632 //Composite group = (Composite) object;
1549515633 Object3D group = object;
15496
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1549715635 }
1549815636
1549915637 void FlipTransform()
1550015638 {
1550115639 //Composite group = (Composite) object;
1550215640 Object3D group = object;
15503
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1550415642 // group.editWindow.ReduceMesh(true);
1550515643 }
1550615644
....@@ -15508,7 +15646,7 @@
1550815646 {
1550915647 //Composite group = (Composite) object;
1551015648 Object3D group = object;
15511
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1551215650 // group.editWindow.ReduceMesh(true);
1551315651 }
1551415652
....@@ -15516,7 +15654,7 @@
1551615654 {
1551715655 //Composite group = (Composite) object;
1551815656 Object3D group = object;
15519
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1552015658 }
1552115659
1552215660 void IncDepth()
....@@ -15692,6 +15830,7 @@
1569215830 info.bounds.y += (height - desired) / 2;
1569315831 }
1569415832 }
15833
+
1569515834 info.g = gr;
1569615835 info.camera = renderCamera;
1569715836 /*
....@@ -15701,23 +15840,44 @@
1570115840 */
1570215841 if (!isRenderer)
1570315842 {
15704
- object.drawEditHandles(info, 0);
15705
-
15706
- 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)
1570715846 {
15708
- 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)
1570915853 {
15710
- case Object3D.hitCenter: gr.setColor(Color.pink);
15711
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15712
- break;
15713
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15714
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15715
- break;
15716
- case Object3D.hitScale: gr.setColor(Color.cyan);
15717
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15718
- 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;
1571915861 }
15720
-
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
+ }
1572115881 }
1572215882 }
1572315883 }
....@@ -16515,6 +16675,14 @@
1651516675 }
1651616676 }
1651716677
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
+
1651816686 class SelectBuffer implements GLEventListener
1651916687 {
1652016688
....@@ -16594,6 +16762,17 @@
1659416762
1659516763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1659616764
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
+
1659716776 //int tmp = selection_view;
1659816777 //selection_view = -1;
1659916778 int temp = DrawMode();
....@@ -16605,6 +16784,17 @@
1660516784 // temp = DEFAULT; // patch for selection debug
1660616785 Globals.drawMode = temp; // WARNING
1660716786
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
+
1660816798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1660916799
1661016800 // trying different ways of getting the depth info over
....@@ -16708,29 +16898,31 @@
1670816898 }
1670916899
1671016900 if (!movingcamera && !PAINTMODE)
16711
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1671216902
16713
- 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)
1671416904 {
16715
- 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);
1671616906
16717
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1671816910
16719
- group.CreateMaterial(); // use a void leaf to select instances
16720
-
16721
- group.add(paintobj); // link
16722
-
16723
- object.editWindow.SnapObject(group);
16724
-
16725
- Object3D folder = object.editWindow.copy;
16726
-
16727
- if (object.editWindow.copy.selection.Size() > 0)
16728
- folder = object.editWindow.copy.selection.elementAt(0);
16729
-
16730
- folder.add(group);
16731
-
16732
- object.editWindow.ResetModel();
16733
- 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
+ }
1673416926 }
1673516927 else
1673616928 paintcount = 0;
....@@ -16769,6 +16961,11 @@
1676916961 //System.out.println("objects[color] = " + objects[color]);
1677016962 //objects[color].Select();
1677116963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1677216969 object.Select(color, deselect);
1677316970 }
1677416971