Normand Briere
2019-07-23 5140c320d8addf4bd8dcaa7f350b6accdc4ffbaf
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -44,6 +48,39 @@
4448 static boolean ABORTED = false;
4549
4650 static int STEP = 1;
51
+
52
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
53
+ {
54
+ int[] pixels = new int[bytes.length/3];
55
+ for (int i=pixels.length; --i>=0;)
56
+ {
57
+ int i3 = i*3;
58
+ pixels[i] = 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3+2] & 0xFF;
61
+ pixels[i] <<= 8;
62
+ pixels[i] |= bytes[i3+1] & 0xFF;
63
+ pixels[i] <<= 8;
64
+ pixels[i] |= bytes[i3] & 0xFF;
65
+ }
66
+ /*
67
+ int r=0,g=0,b=0,a=0;
68
+ for (int i=0; i<width; i++)
69
+ for (int j=0; j<height; j++)
70
+ {
71
+ int index = j*width+i;
72
+ int p = pixels[index];
73
+ a = ((p>>24) & 0xFF);
74
+ r = ((p>>16) & 0xFF);
75
+ g = ((p>>8) & 0xFF);
76
+ b = (p & 0xFF);
77
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
78
+ }
79
+ /**/
80
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
81
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
82
+ return rendImage;
83
+ }
4784
4885 /*static*/ private boolean CULLFACE = false; // true;
4986 /*static*/ boolean NEAREST = false; // true;
....@@ -60,7 +97,7 @@
6097 //boolean REDUCETEXTURE = true;
6198 boolean CACHETEXTURE = true;
6299 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
64101 boolean COMPRESSTEXTURE = false;
65102 boolean KOMPACTTEXTURE = false; // true;
66103 boolean RESIZETEXTURE = false;
....@@ -335,14 +372,28 @@
335372 display.options1[2] = material.shadowbias;
336373 display.options1[3] = material.aniso;
337374 display.options1[4] = material.anisoV;
375
+// System.out.println("display.options1[0] " + display.options1[0]);
376
+// System.out.println("display.options1[1] " + display.options1[1]);
377
+// System.out.println("display.options1[2] " + display.options1[2]);
378
+// System.out.println("display.options1[3] " + display.options1[3]);
379
+// System.out.println("display.options1[4] " + display.options1[4]);
338380 display.options2[0] = material.opacity;
339381 display.options2[1] = material.diffuse;
340382 display.options2[2] = material.factor;
383
+// System.out.println("display.options2[0] " + display.options2[0]);
384
+// System.out.println("display.options2[1] " + display.options2[1]);
385
+// System.out.println("display.options2[2] " + display.options2[2]);
341386
342387 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
388
+// System.out.println("display.options3[0] " + display.options3[0]);
389
+// System.out.println("display.options3[1] " + display.options3[1]);
390
+// System.out.println("display.options3[2] " + display.options3[2]);
343391 display.options4[0] = material.cameralight/0.2f;
344392 display.options4[1] = material.subsurface;
345393 display.options4[2] = material.sheen;
394
+// System.out.println("display.options4[0] " + display.options4[0]);
395
+// System.out.println("display.options4[1] " + display.options4[1]);
396
+// System.out.println("display.options4[2] " + display.options4[2]);
346397
347398 // if (display.CURRENTANTIALIAS > 0)
348399 // display.options3[3] /= 4;
....@@ -2051,7 +2102,7 @@
20512102 //System.err.println("Oeil on");
20522103 OEIL = true;
20532104 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2054
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2105
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20552106 //pingthread.StepToTarget(true);
20562107 }
20572108
....@@ -2284,10 +2335,17 @@
22842335 HANDLES ^= true;
22852336 }
22862337
2338
+ Object3D paintFolder;
2339
+
22872340 void TogglePaint()
22882341 {
22892342 PAINTMODE ^= true;
22902343 paintcount = 0;
2344
+
2345
+ if (PAINTMODE)
2346
+ {
2347
+ paintFolder = GetFolder();
2348
+ }
22912349 }
22922350
22932351 void SwapCamera(int a, int b)
....@@ -2384,6 +2442,21 @@
23842442 return currentGL;
23852443 }
23862444
2445
+ static private BufferedImage CreateBim(TextureData texturedata)
2446
+ {
2447
+ Grafreed.Assert(texturedata != null);
2448
+
2449
+ int width = texturedata.getWidth();
2450
+ int height = texturedata.getHeight();
2451
+
2452
+ Buffer buffer = texturedata.getBuffer();
2453
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2454
+
2455
+ byte[] bytes = bytebuf.array();
2456
+
2457
+ return CreateBim(bytes, width, height);
2458
+ }
2459
+
23872460 /**/
23882461 class CacheTexture
23892462 {
....@@ -2392,28 +2465,31 @@
23922465
23932466 int resolution;
23942467
2395
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2468
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23962469 {
2397
- texture = tex;
2470
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2471
+ texturedata = texdata;
23982472 resolution = res;
23992473 }
24002474 }
24012475 /**/
24022476
24032477 // 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>();
2478
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2481
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2482
+
24072483 int pigmentdepth = 0;
24082484 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24092485 int bumpdepth = 0;
24102486 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24112487 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24122488 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2413
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2489
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24142490 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24152491
2416
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2492
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24172493 {
24182494 TextureData texturedata = null;
24192495
....@@ -2432,13 +2508,34 @@
24322508 if (bump)
24332509 texturedata = ConvertBump(texturedata, false);
24342510
2435
- com.sun.opengl.util.texture.Texture texture =
2436
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2511
+// com.sun.opengl.util.texture.Texture texture =
2512
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24372513
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);
2514
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24402516
2441
- return texture;
2517
+ return texturedata;
2518
+ }
2519
+
2520
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2521
+ {
2522
+ TextureData texturedata = null;
2523
+
2524
+ try
2525
+ {
2526
+ texturedata =
2527
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2528
+ bim,
2529
+ true);
2530
+ } catch (Exception e)
2531
+ {
2532
+ throw new javax.media.opengl.GLException(e);
2533
+ }
2534
+
2535
+ if (bump)
2536
+ texturedata = ConvertBump(texturedata, false);
2537
+
2538
+ return texturedata;
24422539 }
24432540
24442541 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3511,6 +3608,8 @@
35113608
35123609 System.out.println("LOADING TEXTURE : " + name);
35133610
3611
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3612
+
35143613 //
35153614 if (false) // compressbit > 0)
35163615 {
....@@ -7909,7 +8008,7 @@
79098008 String pigment = Object3D.GetPigment(tex);
79108009 String bump = Object3D.GetBump(tex);
79118010
7912
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8011
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79138012 {
79148013 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79158014 // System.out.println("; bump = " + bump);
....@@ -7924,8 +8023,8 @@
79248023 pigment = null;
79258024 }
79268025
7927
- ReleaseTexture(bump, true);
7928
- ReleaseTexture(pigment, false);
8026
+ ReleaseTexture(tex, true);
8027
+ ReleaseTexture(tex, false);
79298028 }
79308029
79318030 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -7943,7 +8042,7 @@
79438042
79448043 String pigment = Object3D.GetPigment(tex);
79458044
7946
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8045
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79478046 {
79488047 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79498048 // System.out.println("; bump = " + bump);
....@@ -7954,7 +8053,7 @@
79548053 pigment = null;
79558054 }
79568055
7957
- ReleaseTexture(pigment, false);
8056
+ ReleaseTexture(tex, false);
79588057 }
79598058
79608059 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -7972,7 +8071,7 @@
79728071
79738072 String bump = Object3D.GetBump(tex);
79748073
7975
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8074
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79768075 {
79778076 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79788077 // System.out.println("; bump = " + bump);
....@@ -7983,10 +8082,10 @@
79838082 bump = null;
79848083 }
79858084
7986
- ReleaseTexture(bump, true);
8085
+ ReleaseTexture(tex, true);
79878086 }
79888087
7989
- void ReleaseTexture(String tex, boolean bump)
8088
+ void ReleaseTexture(cTexture tex, boolean bump)
79908089 {
79918090 if (// DrawMode() != 0 || /*tex == null ||*/
79928091 ambientOcclusion ) // || !textureon)
....@@ -7997,7 +8096,7 @@
79978096 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79988097
79998098 if (tex != null)
8000
- texture = textures.get(tex);
8099
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80018100
80028101 // //assert( texture != null );
80038102 // if (texture == null)
....@@ -8091,47 +8190,50 @@
80918190
80928191 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80938192 {
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
- }
8193
+// if (// DrawMode() != 0 || /*tex == null ||*/
8194
+// ambientOcclusion ) // || !textureon)
8195
+// {
8196
+// return; // false;
8197
+// }
8198
+//
8199
+// if (tex == null)
8200
+// {
8201
+// BindTexture(null,false,resolution);
8202
+// BindTexture(null,true,resolution);
8203
+// return;
8204
+// }
8205
+//
8206
+// String pigment = Object3D.GetPigment(tex);
8207
+// String bump = Object3D.GetBump(tex);
8208
+//
8209
+// usedtextures.add(pigment);
8210
+// usedtextures.add(bump);
8211
+//
8212
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8213
+// {
8214
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8215
+// // System.out.println("; bump = " + bump);
8216
+// }
8217
+//
8218
+// if (bump.equals(""))
8219
+// {
8220
+// bump = null;
8221
+// }
8222
+// if (pigment.equals(""))
8223
+// {
8224
+// pigment = null;
8225
+// }
8226
+//
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+// BindTexture(pigment, false, resolution);
8229
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8230
+// BindTexture(bump, true, resolution);
8231
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8232
+//
8233
+// return; // true;
81068234
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;
8235
+ BindPigmentTexture(tex, resolution);
8236
+ BindBumpTexture(tex, resolution);
81358237 }
81368238
81378239 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8150,9 +8252,9 @@
81508252
81518253 String pigment = Object3D.GetPigment(tex);
81528254
8153
- usedtextures.put(pigment, pigment);
8255
+ usedtextures.add(tex);
81548256
8155
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8257
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81568258 {
81578259 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81588260 // System.out.println("; bump = " + bump);
....@@ -8164,7 +8266,7 @@
81648266 }
81658267
81668268 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8167
- BindTexture(pigment, false, resolution);
8269
+ BindTexture(tex, false, resolution);
81688270 }
81698271
81708272 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8183,9 +8285,9 @@
81838285
81848286 String bump = Object3D.GetBump(tex);
81858287
8186
- usedtextures.put(bump, bump);
8288
+ usedtextures.add(tex);
81878289
8188
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8290
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81898291 {
81908292 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81918293 // System.out.println("; bump = " + bump);
....@@ -8197,7 +8299,7 @@
81978299 }
81988300
81998301 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8200
- BindTexture(bump, true, resolution);
8302
+ BindTexture(tex, true, resolution);
82018303 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82028304 }
82038305
....@@ -8221,13 +8323,19 @@
82218323 return fileExists;
82228324 }
82238325
8224
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8326
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82258327 {
8226
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8328
+ CacheTexture texturecache = null;
82278329
82288330 if (tex != null)
82298331 {
8230
- String texname = tex;
8332
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8333
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8334
+
8335
+ if (texname.equals("") && texdata == null)
8336
+ {
8337
+ return null;
8338
+ }
82318339
82328340 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82338341
....@@ -8237,19 +8345,46 @@
82378345 // else
82388346 // if (!texname.startsWith("/"))
82398347 // texname = "/Users/nbriere/Textures/" + texname;
8240
- if (!FileExists(tex))
8348
+ if (!FileExists(texname))
82418349 {
82428350 texname = fallbackTextureName;
82438351 }
82448352
82458353 if (CACHETEXTURE)
8246
- texture = textures.get(texname); // TEXTURE CACHE
8247
-
8248
- TextureData texturedata = null;
8249
-
8250
- if (texture == null || texture.resolution < resolution)
82518354 {
8252
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8355
+ if (texdata == null)
8356
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8357
+ else
8358
+ texturecache = bimtextures.get(texdata);
8359
+ }
8360
+
8361
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8362
+ {
8363
+ TextureData texturedata = null;
8364
+
8365
+ if (texdata != null && textureon)
8366
+ {
8367
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8368
+
8369
+ try
8370
+ {
8371
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8372
+ }
8373
+ catch (Exception e)
8374
+ {
8375
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8376
+ }
8377
+
8378
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8379
+ bimtextures.put(texdata, texturecache);
8380
+
8381
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8382
+
8383
+ //Object bim2 = CreateBim(texturecache.texturedata);
8384
+ //bim2 = bim;
8385
+ }
8386
+ else
8387
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82538388 {
82548389 assert(!bump);
82558390 // if (bump)
....@@ -8260,19 +8395,23 @@
82608395 // }
82618396 // else
82628397 // {
8263
- texture = textures.get(tex);
8264
- if (texture == null)
8398
+ // texturecache = textures.get(texname); // suspicious
8399
+ if (texturecache == null)
82658400 {
8266
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8401
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82678402 }
8403
+ else
8404
+ new Exception().printStackTrace();
82688405 // }
82698406 } else
8270
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8407
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82718408 {
82728409 assert(bump);
8273
- texture = textures.get(tex);
8274
- if (texture == null)
8275
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8410
+ // texturecache = textures.get(texname); // suspicious
8411
+ if (texturecache == null)
8412
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8413
+ else
8414
+ new Exception().printStackTrace();
82768415 } else
82778416 {
82788417 //if (tex.equals("IMMORTAL"))
....@@ -8280,11 +8419,13 @@
82808419 // texture = GetResourceTexture("default.png");
82818420 //} else
82828421 //{
8283
- if (tex.equals("WHITE_NOISE"))
8422
+ if (texname.endsWith("WHITE_NOISE"))
82848423 {
8285
- texture = textures.get(tex);
8286
- if (texture == null)
8287
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8424
+ // texturecache = textures.get(texname); // suspicious
8425
+ if (texturecache == null)
8426
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8427
+ else
8428
+ new Exception().printStackTrace();
82888429 } else
82898430 {
82908431 if (textureon)
....@@ -8343,19 +8484,19 @@
83438484 if (texturedata == null)
83448485 throw new Exception();
83458486
8346
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8487
+ texturecache = new CacheTexture(texturedata,resolution);
83478488 //texture = GetTexture(tex, bump);
83488489 }
83498490 }
83508491 //}
83518492 }
83528493
8353
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8494
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
83548495 {
83558496 //return false;
83568497
83578498 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8358
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8499
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83598500 {
83608501 // String ext = "_highres";
83618502 // if (REDUCETEXTURE)
....@@ -8372,52 +8513,17 @@
83728513 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83738514 if (!cachefile.exists())
83748515 {
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))
8516
+ //if (texturedata.getWidth() == texturedata.getHeight())
83848517 {
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);
8518
+ BufferedImage rendImage = CreateBim(texturedata);
8519
+
84158520 ImageWriter writer = null;
84168521 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84178522 if (iter.hasNext()) {
84188523 writer = (ImageWriter)iter.next();
84198524 }
8420
- float compressionQuality = 0.9f;
8525
+
8526
+ float compressionQuality = 0.85f;
84218527 try
84228528 {
84238529 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8434,18 +8540,20 @@
84348540 }
84358541 }
84368542 }
8437
-
8543
+
8544
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8545
+
84388546 //System.out.println("Texture = " + tex);
8439
- if (textures.containsKey(texname))
8547
+ if (textures.containsKey(tex))
84408548 {
8441
- CacheTexture thetex = textures.get(texname);
8549
+ CacheTexture thetex = textures.get(tex);
84428550 thetex.texture.disable();
84438551 thetex.texture.dispose();
8444
- textures.remove(texname);
8552
+ textures.remove(tex);
84458553 }
84468554
8447
- texture.texturedata = texturedata;
8448
- textures.put(texname, texture);
8555
+ //texture.texturedata = texturedata;
8556
+ textures.put(tex, texturecache);
84498557
84508558 // newtex = true;
84518559 }
....@@ -8461,10 +8569,44 @@
84618569 }
84628570 }
84638571
8464
- return texture;
8572
+ return texturecache;
84658573 }
84668574
8467
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8575
+ static void EmbedTextures(cTexture tex)
8576
+ {
8577
+ if (tex.pigmentdata == null)
8578
+ {
8579
+ //String texname = Object3D.GetPigment(tex);
8580
+
8581
+ CacheTexture texturecache = texturepigment.get(tex);
8582
+
8583
+ if (texturecache != null)
8584
+ {
8585
+ tex.pw = texturecache.texturedata.getWidth();
8586
+ tex.ph = texturecache.texturedata.getHeight();
8587
+ tex.pigmentdata = //CompressJPEG(CreateBim
8588
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8589
+ ;
8590
+ //, tex.pw, tex.ph), 0.5f);
8591
+ }
8592
+ }
8593
+
8594
+ if (tex.bumpdata == null)
8595
+ {
8596
+ //String texname = Object3D.GetBump(tex);
8597
+
8598
+ CacheTexture texturecache = texturebump.get(tex);
8599
+
8600
+ if (texturecache != null)
8601
+ {
8602
+ tex.bw = texturecache.texturedata.getWidth();
8603
+ tex.bh = texturecache.texturedata.getHeight();
8604
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8605
+ }
8606
+ }
8607
+ }
8608
+
8609
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
84688610 {
84698611 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84708612
....@@ -8482,21 +8624,21 @@
84828624 return texture!=null?texture.texture:null;
84838625 }
84848626
8485
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8627
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
84868628 {
84878629 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84888630
84898631 return texture!=null?texture.texturedata:null;
84908632 }
84918633
8492
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8634
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
84938635 {
84948636 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84958637 {
84968638 return false;
84978639 }
84988640
8499
- boolean newtex = false;
8641
+ //boolean newtex = false;
85008642
85018643 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85028644
....@@ -8528,9 +8670,75 @@
85288670 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85298671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85308672
8531
- return newtex;
8673
+ return true; // Warning: not used.
85328674 }
85338675
8676
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8677
+ {
8678
+ try
8679
+ {
8680
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8681
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8682
+ ImageWriter writer = writers.next();
8683
+
8684
+ ImageWriteParam param = writer.getDefaultWriteParam();
8685
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8686
+ param.setCompressionQuality(quality);
8687
+
8688
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8689
+ writer.setOutput(ios);
8690
+ writer.write(null, new IIOImage(image, null, null), param);
8691
+
8692
+ byte[] data = baos.toByteArray();
8693
+ writer.dispose();
8694
+ return data;
8695
+ }
8696
+ catch (Exception e)
8697
+ {
8698
+ e.printStackTrace();
8699
+ return null;
8700
+ }
8701
+ }
8702
+
8703
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8704
+ {
8705
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8706
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8707
+ ImageReader reader = writers.next();
8708
+
8709
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8710
+
8711
+ ImageReadParam param = reader.getDefaultReadParam();
8712
+ param.setDestination(bim);
8713
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8714
+
8715
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8716
+ reader.setInput(ios);
8717
+ BufferedImage bim2 = reader.read(0, param);
8718
+ reader.dispose();
8719
+
8720
+// WritableRaster raster = bim2.getRaster();
8721
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8722
+// byte[] bytes = data.getData();
8723
+//
8724
+// int[] pixels = new int[bytes.length/3];
8725
+// for (int i=pixels.length; --i>=0;)
8726
+// {
8727
+// int i3 = i*3;
8728
+// pixels[i] = 0xFF;
8729
+// pixels[i] <<= 8;
8730
+// pixels[i] |= bytes[i3+2] & 0xFF;
8731
+// pixels[i] <<= 8;
8732
+// pixels[i] |= bytes[i3+1] & 0xFF;
8733
+// pixels[i] <<= 8;
8734
+// pixels[i] |= bytes[i3] & 0xFF;
8735
+// }
8736
+//
8737
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8738
+
8739
+ return bim;
8740
+ }
8741
+
85348742 ShadowBuffer shadowPBuf;
85358743 AntialiasBuffer antialiasPBuf;
85368744 int MAXSTACK;
....@@ -9366,11 +9574,35 @@
93669574 jy8[3] = 0.5f;
93679575 }
93689576
9369
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9577
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93709578 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93719579 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93729580 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93739581
9582
+ void ResetOptions()
9583
+ {
9584
+ options1[0] = 100;
9585
+ options1[1] = 0.025f;
9586
+ options1[2] = 0.01f;
9587
+ options1[3] = 0;
9588
+ options1[4] = 0;
9589
+
9590
+ options2[0] = 0;
9591
+ options2[1] = 0.75f;
9592
+ options2[2] = 0;
9593
+ options2[3] = 0;
9594
+
9595
+ options3[0] = 1;
9596
+ options3[1] = 1;
9597
+ options3[2] = 1;
9598
+ options3[3] = 0;
9599
+
9600
+ options4[0] = 1;
9601
+ options4[1] = 0;
9602
+ options4[2] = 1;
9603
+ options4[3] = 0;
9604
+ }
9605
+
93749606 static int imagecount = 0; // movie generation
93759607
93769608 static int jitter = 0;
....@@ -10481,6 +10713,7 @@
1048110713 ANTIALIAS = 0;
1048210714 //System.out.println("RESTART");
1048310715 AAtimer.restart();
10716
+ Globals.TIMERRUNNING = true;
1048410717 }
1048510718 }
1048610719 }
....@@ -10989,9 +11222,9 @@
1098911222
1099011223 gl.glMatrixMode(GL.GL_MODELVIEW);
1099111224
10992
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10993
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10994
-//gl.glEnable(gl.GL_MULTISAMPLE);
11225
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11226
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11227
+gl.glEnable(gl.GL_MULTISAMPLE);
1099511228 } else
1099611229 {
1099711230 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11002,7 +11235,7 @@
1100211235 //System.out.println("BLENDING ON");
1100311236 gl.glEnable(GL.GL_BLEND);
1100411237 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11005
-
11238
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1100611239 gl.glMatrixMode(gl.GL_PROJECTION);
1100711240 gl.glLoadIdentity();
1100811241
....@@ -11251,7 +11484,7 @@
1125111484 }
1125211485 }
1125311486
11254
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11487
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1125511488 {
1125611489 //gl.glDepthFunc(GL.GL_LEQUAL);
1125711490 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11259,24 +11492,21 @@
1125911492
1126011493 boolean texon = textureon;
1126111494
11262
- if (RENDERPROGRAM > 0)
11263
- {
11264
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11265
- textureon = false;
11266
- }
11495
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11496
+ textureon = false;
11497
+
1126711498 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1126811499 //System.out.println("ALLO");
1126911500 gl.glColorMask(false, false, false, false);
1127011501 DrawObject(gl);
11271
- if (RENDERPROGRAM > 0)
11272
- {
11273
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11274
- textureon = texon;
11275
- }
11502
+
11503
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11504
+ textureon = texon;
11505
+
1127611506 gl.glColorMask(true, true, true, true);
1127711507
1127811508 gl.glDepthFunc(GL.GL_EQUAL);
11279
- //gl.glDepthMask(false);
11509
+ gl.glDepthMask(false);
1128011510 }
1128111511
1128211512 if (false) // DrawMode() == SHADOW)
....@@ -11459,7 +11689,7 @@
1145911689
1146011690 static boolean zoomonce = false;
1146111691
11462
- void CreateSelectedPoint()
11692
+ static void CreateSelectedPoint()
1146311693 {
1146411694 if (selectedpoint == null)
1146511695 {
....@@ -11479,13 +11709,16 @@
1147911709
1148011710 void DrawObject(GL gl, boolean draw)
1148111711 {
11712
+ // To clear camera values
11713
+ ResetOptions();
11714
+
1148211715 //System.out.println("DRAW OBJECT " + mouseDown);
1148311716 // DrawMode() = SELECTION;
1148411717 //GL gl = getGL();
1148511718 if ((TRACK || SHADOWTRACK) || zoomonce)
1148611719 {
1148711720 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11488
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11721
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1148911722 pingthread.StepToTarget(true); // true);
1149011723 // zoomonce = false;
1149111724 }
....@@ -11613,20 +11846,32 @@
1161311846 ReleaseTextures(DEFAULT_TEXTURES);
1161411847
1161511848 if (CLEANCACHE)
11616
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11849
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1161711850 {
11618
- String tex = e.nextElement();
11851
+ cTexture tex = e.nextElement();
1161911852
1162011853 // System.out.println("Texture --------- " + tex);
1162111854
11622
- if (tex.equals("WHITE_NOISE"))
11855
+ if (tex.equals("WHITE_NOISE:"))
1162311856 continue;
1162411857
11625
- if (!usedtextures.containsKey(tex))
11858
+ if (!usedtextures.contains(tex))
1162611859 {
11860
+ CacheTexture gettex = texturepigment.get(tex);
1162711861 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11628
- textures.get(tex).texture.dispose();
11629
- textures.remove(tex);
11862
+ if (gettex != null)
11863
+ {
11864
+ gettex.texture.dispose();
11865
+ texturepigment.remove(tex);
11866
+ }
11867
+
11868
+ gettex = texturebump.get(tex);
11869
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11870
+ if (gettex != null)
11871
+ {
11872
+ gettex.texture.dispose();
11873
+ texturebump.remove(tex);
11874
+ }
1163011875 }
1163111876 }
1163211877 }
....@@ -12046,7 +12291,7 @@
1204612291 for (int i = tp.size(); --i >= 0;)
1204712292 {
1204812293 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12049
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12294
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1205012295 }
1205112296
1205212297
....@@ -12155,7 +12400,52 @@
1215512400 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1215612401
1215712402 String program =
12403
+ // Min shader
1215812404 "!!ARBfp1.0\n" +
12405
+ "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" +
12406
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12407
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12408
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12409
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12410
+ "TEMP temp;" +
12411
+ "TEMP light;" +
12412
+ "TEMP ndotl;" +
12413
+ "TEMP normal;" +
12414
+ "TEMP depth;" +
12415
+
12416
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
+
12418
+ "MOV light, state.light[0].position;" +
12419
+ "DP3 ndotl.x, light, normal;" +
12420
+
12421
+ // shadow
12422
+ "MOV temp, fragment.texcoord[1];" +
12423
+ TextureFetch("depth", "temp", "1") +
12424
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
+ "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
+
12427
+
12428
+ // No shadow when out of frustum
12429
+ //"SGE temp.y, depth.z, zero123.y;" +
12430
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12431
+
12432
+ "MUL ndotl.x, ndotl.x, temp.x;" +
12433
+ "MAX ndotl.x, ndotl.x, pow2.y;" +
12434
+
12435
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12436
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12437
+ "MUL temp, temp, ndotl.x;" +
12438
+
12439
+ "MUL temp, temp, zero123.z;" +
12440
+
12441
+ "MOV temp.w, zero123.y;" + // reset alpha
12442
+
12443
+ "MOV result.color, temp;" +
12444
+ "END";
12445
+
12446
+ String program2 =
12447
+ "!!ARBfp1.0\n" +
12448
+
1215912449 //"OPTION ARB_fragment_program_shadow;" +
1216012450 "PARAM light2cam0 = program.env[10];" +
1216112451 "PARAM light2cam1 = program.env[11];" +
....@@ -12270,8 +12560,7 @@
1227012560 "TEMP shininess;" +
1227112561 "\n" +
1227212562 "MOV texSamp, one;" +
12273
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12274
-
12563
+
1227512564 "MOV mapgrid.x, one2048th.x;" +
1227612565 "MOV temp, fragment.texcoord[1];" +
1227712566 /*
....@@ -12676,7 +12965,7 @@
1267612965 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1267712966 "") +
1267812967
12679
- // display shadow only (bump == 0)
12968
+ // display shadow only (fakedepth == 0)
1268012969 "SUB temp.x, half.x, shadow.x;" +
1268112970 "MOV temp.y, -params5.z;" + // params6.x;" +
1268212971 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13108,20 +13397,20 @@
1310813397 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1310913398 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1311013399 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13400
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13401
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1311113402 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13112
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13113
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13114
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13115
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13403
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13404
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1311613405 //"SWZ buffer, temp, w,w,w,w;";
13117
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13406
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1311813407 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1311913408 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1312013409 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13121
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13410
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1312213411
13123
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13124
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13412
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13413
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1312513414 }
1312613415
1312713416 String Shadow(String depth, String shadow)
....@@ -13168,7 +13457,7 @@
1316813457 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1316913458 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1317013459
13171
- // No shadow when out of frustrum
13460
+ // No shadow when out of frustum
1317213461 "SGE temp.x, " + depth + ".z, one.z;" +
1317313462 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1317413463 "";
....@@ -13333,9 +13622,10 @@
1333313622 "DP3 " + dest + ".z," + "normals," + "eye;" +
1333413623 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1333513624 //"MOV " + dest + ".w," + "normal.z;" +
13336
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13337
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13338
- //"MOV " + dest + ".z," + "params2.w;" +
13625
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13626
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13627
+
13628
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1333913629 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1334013630 "RCP " + dest + ".w," + dest + ".w;" +
1334113631 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13840,6 +14130,7 @@
1384014130 else
1384114131 if (evt.getSource() == AAtimer)
1384214132 {
14133
+ Globals.TIMERRUNNING = false;
1384314134 if (mouseDown)
1384414135 {
1384514136 //new Exception().printStackTrace();
....@@ -13899,7 +14190,7 @@
1389914190
1390014191 // fev 2014???
1390114192 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13902
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14193
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1390314194 pingthread.StepToTarget(true); // true);
1390414195 }
1390514196 // if (!LIVE)
....@@ -13914,6 +14205,7 @@
1391414205 return;
1391514206
1391614207 AAtimer.restart(); //
14208
+ Globals.TIMERRUNNING = true;
1391714209
1391814210 // waslive = LIVE;
1391914211 // LIVE = false;
....@@ -13963,14 +14255,15 @@
1396314255 drag = false;
1396414256 //System.out.println("Mouse DOWN");
1396514257 editObj = false;
13966
- ClickInfo info = new ClickInfo();
13967
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13968
- info.pane = this;
13969
- info.camera = renderCamera;
13970
- info.x = x;
13971
- info.y = y;
13972
- info.modifiers = modifiersex;
13973
- editObj = object.doEditClick(info, 0);
14258
+ //ClickInfo info = new ClickInfo();
14259
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14260
+ object.clickInfo.pane = this;
14261
+ object.clickInfo.camera = renderCamera;
14262
+ object.clickInfo.x = x;
14263
+ object.clickInfo.y = y;
14264
+ object.clickInfo.modifiers = modifiersex;
14265
+ editObj = object.doEditClick(//info,
14266
+ 0);
1397414267 if (!editObj)
1397514268 {
1397614269 hasMarquee = true;
....@@ -14252,12 +14545,12 @@
1425214545 void GoDown(int mod)
1425314546 {
1425414547 MODIFIERS |= COMMAND;
14255
- /*
14548
+ /**/
1425614549 if((mod&SHIFT) == SHIFT)
1425714550 manipCamera.RotatePosition(0, -speed);
1425814551 else
14259
- manipCamera.BackForth(0, -speed*delta, getWidth());
14260
- */
14552
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14553
+ /**/
1426114554 if ((mod & SHIFT) == SHIFT)
1426214555 {
1426314556 mouseMode = mouseMode; // VR??
....@@ -14273,12 +14566,12 @@
1427314566 void GoUp(int mod)
1427414567 {
1427514568 MODIFIERS |= COMMAND;
14276
- /*
14569
+ /**/
1427714570 if((mod&SHIFT) == SHIFT)
1427814571 manipCamera.RotatePosition(0, speed);
1427914572 else
14280
- manipCamera.BackForth(0, speed*delta, getWidth());
14281
- */
14573
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14574
+ /**/
1428214575 if ((mod & SHIFT) == SHIFT)
1428314576 {
1428414577 mouseMode = mouseMode;
....@@ -14294,12 +14587,12 @@
1429414587 void GoLeft(int mod)
1429514588 {
1429614589 MODIFIERS |= COMMAND;
14297
- /*
14590
+ /**/
1429814591 if((mod&SHIFT) == SHIFT)
14299
- manipCamera.RotatePosition(speed, 0);
14300
- else
1430114592 manipCamera.Translate(speed*delta, 0, getWidth());
14302
- */
14593
+ else
14594
+ manipCamera.RotatePosition(speed, 0);
14595
+ /**/
1430314596 if ((mod & SHIFT) == SHIFT)
1430414597 {
1430514598 mouseMode = mouseMode;
....@@ -14315,12 +14608,12 @@
1431514608 void GoRight(int mod)
1431614609 {
1431714610 MODIFIERS |= COMMAND;
14318
- /*
14611
+ /**/
1431914612 if((mod&SHIFT) == SHIFT)
14320
- manipCamera.RotatePosition(-speed, 0);
14321
- else
1432214613 manipCamera.Translate(-speed*delta, 0, getWidth());
14323
- */
14614
+ else
14615
+ manipCamera.RotatePosition(-speed, 0);
14616
+ /**/
1432414617 if ((mod & SHIFT) == SHIFT)
1432514618 {
1432614619 mouseMode = mouseMode;
....@@ -14370,14 +14663,16 @@
1437014663 if (editObj)
1437114664 {
1437214665 drag = true;
14373
- ClickInfo info = new ClickInfo();
14374
- info.bounds.setBounds(0, 0,
14666
+ //ClickInfo info = new ClickInfo();
14667
+ object.clickInfo.bounds.setBounds(0, 0,
1437514668 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14376
- info.pane = this;
14377
- info.camera = renderCamera;
14378
- info.x = x;
14379
- info.y = y;
14380
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14669
+ object.clickInfo.pane = this;
14670
+ object.clickInfo.camera = renderCamera;
14671
+ object.clickInfo.x = x;
14672
+ object.clickInfo.y = y;
14673
+ object //.GetWindow().copy
14674
+ .doEditDrag(//info,
14675
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1438114676 } else
1438214677 {
1438314678 if (x < startX)
....@@ -14526,24 +14821,27 @@
1452614821 }
1452714822 }
1452814823
14824
+// ClickInfo clickInfo = new ClickInfo();
14825
+
1452914826 public void mouseMoved(MouseEvent e)
1453014827 {
1453114828 //System.out.println("mouseMoved: " + e);
1453214829 if (isRenderer)
1453314830 return;
1453414831
14535
- ClickInfo ci = new ClickInfo();
14536
- ci.x = e.getX();
14537
- ci.y = e.getY();
14538
- ci.modifiers = e.getModifiersEx();
14539
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14540
- ci.pane = this;
14541
- ci.camera = renderCamera;
14832
+ // Mouse cursor feedback
14833
+ object.clickInfo.x = e.getX();
14834
+ object.clickInfo.y = e.getY();
14835
+ object.clickInfo.modifiers = e.getModifiersEx();
14836
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14837
+ object.clickInfo.pane = this;
14838
+ object.clickInfo.camera = renderCamera;
1454214839 if (!isRenderer)
1454314840 {
14544
- ObjEditor editWindow = object.editWindow;
14545
- Object3D copy = editWindow.copy;
14546
- if (copy.doEditClick(ci, 0))
14841
+ //ObjEditor editWindow = object.editWindow;
14842
+ //Object3D copy = editWindow.copy;
14843
+ if (object.doEditClick(//clickInfo,
14844
+ 0))
1454714845 {
1454814846 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1454914847 } else
....@@ -14558,7 +14856,8 @@
1455814856 Globals.MOUSEDRAGGED = false;
1455914857
1456014858 movingcamera = false;
14561
- X = Y = 0;
14859
+ X = 0; // getBounds().width/2;
14860
+ Y = 0; // getBounds().height/2;
1456214861 //System.out.println("mouseReleased: " + e);
1456314862 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1456414863 }
....@@ -14814,7 +15113,8 @@
1481415113 // break;
1481515114 case 'T':
1481615115 CACHETEXTURE ^= true;
14817
- textures.clear();
15116
+ texturepigment.clear();
15117
+ texturebump.clear();
1481815118 // repaint();
1481915119 break;
1482015120 case 'Y':
....@@ -14899,7 +15199,9 @@
1489915199 case 'E' : COMPACT ^= true;
1490015200 repaint();
1490115201 break;
14902
- case 'W' : DEBUGHSB ^= true;
15202
+ case 'W' : // Wide Window (fullscreen)
15203
+ //DEBUGHSB ^= true;
15204
+ ObjEditor.theFrame.ToggleFullScreen();
1490315205 repaint();
1490415206 break;
1490515207 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14925,13 +15227,7 @@
1492515227 repaint();
1492615228 break;
1492715229 case 'l':
14928
- lightMode ^= true;
14929
- Globals.lighttouched = true;
14930
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14931
- targetLookAt.set(manipCamera.lookAt);
14932
- repaint();
14933
- break;
14934
- case 'L':
15230
+ //case 'L':
1493515231 if (lightMode)
1493615232 {
1493715233 lightMode = false;
....@@ -15074,11 +15370,14 @@
1507415370 case '_':
1507515371 kompactbit = 5;
1507615372 break;
15077
- case '+':
15078
- kompactbit = 6;
15079
- break;
15373
+// case '+':
15374
+// kompactbit = 6;
15375
+// break;
1508015376 case ' ':
15081
- ObjEditor.theFrame.ToggleFullScreen();
15377
+ lightMode ^= true;
15378
+ Globals.lighttouched = true;
15379
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15380
+ targetLookAt.set(manipCamera.lookAt);
1508215381 repaint();
1508315382 break;
1508415383 //case '`' :
....@@ -15125,8 +15424,9 @@
1512515424 case DELETE:
1512615425 ClearSelection();
1512715426 break;
15128
- /*
1512915427 case '+':
15428
+
15429
+ /*
1513015430 //fontsize += 1;
1513115431 bbzoom *= 2;
1513215432 repaint();
....@@ -15143,17 +15443,17 @@
1514315443 case '=':
1514415444 IncDepth();
1514515445 //fontsize += 1;
15146
- object.editWindow.refreshContents(true);
15446
+ object.GetWindow().refreshContents(true);
1514715447 maskbit = 6;
1514815448 break;
1514915449 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1515015450 DecDepth();
1515115451 maskbit = 5;
1515215452 //if(fontsize > 1) fontsize -= 1;
15153
- if (object.editWindow == null)
15154
- new Exception().printStackTrace();
15155
- else
15156
- object.editWindow.refreshContents(true);
15453
+// if (object.editWindow == null)
15454
+// new Exception().printStackTrace();
15455
+// else
15456
+ object.GetWindow().refreshContents(true);
1515715457 break;
1515815458 case '{':
1515915459 manipCamera.shaper_fovy /= 1.1;
....@@ -15377,7 +15677,7 @@
1537715677 }
1537815678 */
1537915679
15380
- object.editWindow.EditSelection();
15680
+ object.GetWindow().EditSelection(false);
1538115681 }
1538215682
1538315683 void SelectParent()
....@@ -15394,10 +15694,10 @@
1539415694 {
1539515695 //selectees.remove(i);
1539615696 System.out.println("select parent of " + elem);
15397
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15697
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1539815698 } else
1539915699 {
15400
- group.editWindow.Select(elem.GetTreePath(), first, true);
15700
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1540115701 }
1540215702
1540315703 first = false;
....@@ -15439,12 +15739,12 @@
1543915739 for (int j = 0; j < group.children.size(); j++)
1544015740 {
1544115741 elem = (Object3D) group.children.elementAt(j);
15442
- object.editWindow.Select(elem.GetTreePath(), first, true);
15742
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1544315743 first = false;
1544415744 }
1544515745 } else
1544615746 {
15447
- object.editWindow.Select(elem.GetTreePath(), first, true);
15747
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1544815748 }
1544915749
1545015750 first = false;
....@@ -15455,21 +15755,21 @@
1545515755 {
1545615756 //Composite group = (Composite) object;
1545715757 Object3D group = object;
15458
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15758
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1545915759 }
1546015760
1546115761 void ResetTransform(int mask)
1546215762 {
1546315763 //Composite group = (Composite) object;
1546415764 Object3D group = object;
15465
- group.editWindow.ResetTransform(mask);
15765
+ group.GetWindow().ResetTransform(mask);
1546615766 }
1546715767
1546815768 void FlipTransform()
1546915769 {
1547015770 //Composite group = (Composite) object;
1547115771 Object3D group = object;
15472
- group.editWindow.FlipTransform();
15772
+ group.GetWindow().FlipTransform();
1547315773 // group.editWindow.ReduceMesh(true);
1547415774 }
1547515775
....@@ -15477,7 +15777,7 @@
1547715777 {
1547815778 //Composite group = (Composite) object;
1547915779 Object3D group = object;
15480
- group.editWindow.PrintMemory();
15780
+ group.GetWindow().PrintMemory();
1548115781 // group.editWindow.ReduceMesh(true);
1548215782 }
1548315783
....@@ -15485,7 +15785,7 @@
1548515785 {
1548615786 //Composite group = (Composite) object;
1548715787 Object3D group = object;
15488
- group.editWindow.ResetCentroid();
15788
+ group.GetWindow().ResetCentroid();
1548915789 }
1549015790
1549115791 void IncDepth()
....@@ -15567,8 +15867,6 @@
1556715867
1556815868 int width = getBounds().width;
1556915869 int height = getBounds().height;
15570
- ClickInfo info = new ClickInfo();
15571
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1557215870 //Image img = CreateImage(width, height);
1557315871 //System.out.println("width = " + width + "; height = " + height + "\n");
1557415872
....@@ -15645,48 +15943,77 @@
1564515943 }
1564615944 if (object != null && !hasMarquee)
1564715945 {
15946
+ if (object.clickInfo == null)
15947
+ object.clickInfo = new ClickInfo();
15948
+ ClickInfo info = object.clickInfo;
15949
+ //ClickInfo info = new ClickInfo();
15950
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
15951
+
1564815952 if (isRenderer)
1564915953 {
15650
- info.flags++;
15954
+ object.clickInfo.flags++;
1565115955 double frameAspect = (double) width / (double) height;
1565215956 if (frameAspect > renderCamera.aspect)
1565315957 {
1565415958 int desired = (int) ((double) height * renderCamera.aspect);
15655
- info.bounds.width -= width - desired;
15656
- info.bounds.x += (width - desired) / 2;
15959
+ object.clickInfo.bounds.width -= width - desired;
15960
+ object.clickInfo.bounds.x += (width - desired) / 2;
1565715961 } else
1565815962 {
1565915963 int desired = (int) ((double) width / renderCamera.aspect);
15660
- info.bounds.height -= height - desired;
15661
- info.bounds.y += (height - desired) / 2;
15964
+ object.clickInfo.bounds.height -= height - desired;
15965
+ object.clickInfo.bounds.y += (height - desired) / 2;
1566215966 }
1566315967 }
15664
- info.g = gr;
15665
- info.camera = renderCamera;
15968
+
15969
+ object.clickInfo.g = gr;
15970
+ object.clickInfo.camera = renderCamera;
1566615971 /*
1566715972 // Memory intensive (brep.verticescopy)
1566815973 if (!(object instanceof Composite))
1566915974 object.draw(info, 0, false); // SLOW :
1567015975 */
15671
- if (!isRenderer)
15976
+ if (!isRenderer) // && drag)
1567215977 {
15673
- object.drawEditHandles(info, 0);
15674
-
15675
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15978
+ Grafreed.Assert(object != null);
15979
+ Grafreed.Assert(object.selection != null);
15980
+ if (object.selection.Size() > 0)
1567615981 {
15677
- switch (object.selection.get(0).hitSomething)
15982
+ int hitSomething = object.selection.get(0).hitSomething;
15983
+
15984
+ object.clickInfo.DX = 0;
15985
+ object.clickInfo.DY = 0;
15986
+ object.clickInfo.W = 1;
15987
+ if (hitSomething == Object3D.hitCenter)
1567815988 {
15679
- case Object3D.hitCenter: gr.setColor(Color.pink);
15680
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15681
- break;
15682
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15683
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15684
- break;
15685
- case Object3D.hitScale: gr.setColor(Color.cyan);
15686
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15687
- break;
15989
+ info.DX = X;
15990
+ if (X != 0)
15991
+ info.DX -= info.bounds.width/2;
15992
+
15993
+ info.DY = Y;
15994
+ if (Y != 0)
15995
+ info.DY -= info.bounds.height/2;
1568815996 }
15689
-
15997
+
15998
+ object.drawEditHandles(//info,
15999
+ 0);
16000
+
16001
+ if (drag && (X != 0 || Y != 0))
16002
+ {
16003
+ switch (hitSomething)
16004
+ {
16005
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16006
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16007
+ break;
16008
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16009
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16010
+ break;
16011
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16012
+ gr.drawLine(X, Y, 0, 0);
16013
+ break;
16014
+ }
16015
+
16016
+ }
1569016017 }
1569116018 }
1569216019 }
....@@ -16484,6 +16811,14 @@
1648416811 }
1648516812 }
1648616813
16814
+ private Object3D GetFolder()
16815
+ {
16816
+ Object3D folder = object.GetWindow().copy;
16817
+ if (object.GetWindow().copy.selection.Size() > 0)
16818
+ folder = object.GetWindow().copy.selection.elementAt(0);
16819
+ return folder;
16820
+ }
16821
+
1648716822 class SelectBuffer implements GLEventListener
1648816823 {
1648916824
....@@ -16563,6 +16898,17 @@
1656316898
1656416899 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1656516900
16901
+ if (PAINTMODE)
16902
+ {
16903
+ if (object.GetWindow().copy.selection.Size() > 0)
16904
+ {
16905
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16906
+
16907
+ // Make what you paint not selectable.
16908
+ paintobj.ResetSelectable();
16909
+ }
16910
+ }
16911
+
1656616912 //int tmp = selection_view;
1656716913 //selection_view = -1;
1656816914 int temp = DrawMode();
....@@ -16574,6 +16920,17 @@
1657416920 // temp = DEFAULT; // patch for selection debug
1657516921 Globals.drawMode = temp; // WARNING
1657616922
16923
+ if (PAINTMODE)
16924
+ {
16925
+ if (object.GetWindow().copy.selection.Size() > 0)
16926
+ {
16927
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16928
+
16929
+ // Revert.
16930
+ paintobj.RestoreSelectable();
16931
+ }
16932
+ }
16933
+
1657716934 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1657816935
1657916936 // trying different ways of getting the depth info over
....@@ -16621,6 +16978,8 @@
1662116978 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1662216979 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1662316980 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16981
+
16982
+ CreateSelectedPoint();
1662416983
1662516984 // Will fit the mesh !!!
1662616985 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16675,29 +17034,31 @@
1667517034 }
1667617035
1667717036 if (!movingcamera && !PAINTMODE)
16678
- object.editWindow.ScreenFitPoint(); // fev 2014
17037
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1667917038
16680
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17039
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1668117040 {
16682
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17041
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1668317042
16684
- Object3D group = new Object3D("inst" + paintcount++);
17043
+ if (object.GetWindow().copy.selection.Size() > 0)
17044
+ {
17045
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1668517046
16686
- group.CreateMaterial(); // use a void leaf to select instances
16687
-
16688
- group.add(paintobj); // link
16689
-
16690
- object.editWindow.SnapObject(group);
16691
-
16692
- Object3D folder = object.editWindow.copy;
16693
-
16694
- if (object.editWindow.copy.selection.Size() > 0)
16695
- folder = object.editWindow.copy.selection.elementAt(0);
16696
-
16697
- folder.add(group);
16698
-
16699
- object.editWindow.ResetModel();
16700
- object.editWindow.refreshContents();
17047
+ Object3D inst = new Object3D("inst" + paintcount++);
17048
+
17049
+ inst.CreateMaterial(); // use a void leaf to select instances
17050
+
17051
+ inst.add(paintobj); // link
17052
+
17053
+ object.GetWindow().SnapObject(inst);
17054
+
17055
+ Object3D folder = paintFolder; // GetFolder();
17056
+
17057
+ folder.add(inst);
17058
+
17059
+ object.GetWindow().ResetModel();
17060
+ object.GetWindow().refreshContents();
17061
+ }
1670117062 }
1670217063 else
1670317064 paintcount = 0;
....@@ -16736,6 +17097,11 @@
1673617097 //System.out.println("objects[color] = " + objects[color]);
1673717098 //objects[color].Select();
1673817099 indexcount = 0;
17100
+ ObjEditor window = object.GetWindow();
17101
+ if (window != null && deselect)
17102
+ {
17103
+ window.Select(null, deselect, true);
17104
+ }
1673917105 object.Select(color, deselect);
1674017106 }
1674117107