Normand Briere
2019-07-25 7058eef32e524cae08a7373d8bc1061e373b223c
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;
....@@ -169,7 +206,8 @@
169206
170207 SetCamera(cam);
171208
172
- SetLight(new Camera(new cVector(10, 10, -20)));
209
+ // Warning: not used.
210
+ SetLight(new Camera(new cVector(15, 10, -20)));
173211
174212 object = o;
175213
....@@ -2065,7 +2103,7 @@
20652103 //System.err.println("Oeil on");
20662104 OEIL = true;
20672105 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2106
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20692107 //pingthread.StepToTarget(true);
20702108 }
20712109
....@@ -2298,10 +2336,17 @@
22982336 HANDLES ^= true;
22992337 }
23002338
2339
+ Object3D paintFolder;
2340
+
23012341 void TogglePaint()
23022342 {
23032343 PAINTMODE ^= true;
23042344 paintcount = 0;
2345
+
2346
+ if (PAINTMODE)
2347
+ {
2348
+ paintFolder = GetFolder();
2349
+ }
23052350 }
23062351
23072352 void SwapCamera(int a, int b)
....@@ -2398,126 +2443,19 @@
23982443 return currentGL;
23992444 }
24002445
2401
- private void GetRemoteZip(String url, String name, boolean unzip, boolean save)
2446
+ static private BufferedImage CreateBim(TextureData texturedata)
24022447 {
2403
- java.net.URL u;
2404
- InputStream is = null;
2405
- DataInputStream dis;
2406
- java.util.zip.ZipInputStream zis;
2407
- //String s;
2408
-
2409
- System.out.println("GetRemoteZip " + name);
2410
-
2411
- int total = 0; // dis.available();
2412
-
2413
- byte[] bytes = new byte[16384];
2414
-
2415
- try
2416
- {
2417
- u = new java.net.URL(url + name);
2418
- is = u.openStream();
2419
-
2420
- System.out.println(url + name);
2421
-
2422
- if (unzip)
2423
- {
2424
- //dis = new DataInputStream(new BufferedInputStream(is));
2425
- zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is));
2426
- //while ((s = dis.readLine()) != null)
2427
-
2428
- if (save)
2429
- new java.io.File(name).mkdirs();
2430
-
2431
- // FileOutputStream stream = new FileOutputStream("test.zip");
2432
- //
2433
- // int count;
2434
- //
2435
- // while ((count = dis.read(bytes)) != -1)
2436
- // {
2437
- // //System.out.println(s);
2438
- // System.out.println(count);
2439
- // total += count;
2440
- // stream.write(bytes);
2441
- // }
2442
- //
2443
- // stream.close();
2444
-
2445
- // now iterate through each item in the stream. The get next
2446
- // entry call will return a ZipEntry for each file in the
2447
- // stream
2448
- java.util.zip.ZipEntry entry;
2449
- while((entry = zis.getNextEntry())!=null)
2450
- {
2451
- if (entry.getName().endsWith(".gsm"))
2452
- {
2453
- continue;
2454
- }
2455
-
2456
- String s = String.format("Entry: %s len %d added %TD",
2457
- entry.getName(), entry.getSize(),
2458
- new java.util.Date(entry.getTime()));
2459
- System.out.println(s);
2460
-
2461
- if (save)
2462
- {
2463
- // Once we get the entry from the stream, the stream is
2464
- // positioned read to read the raw data, and we keep
2465
- // reading until read returns 0 or less.
2466
- String outpath = name + "/" + entry.getName();
2467
- FileOutputStream output = null;
2468
- try
2469
- {
2470
- output = new FileOutputStream(outpath);
2471
- int len = 0;
2472
- while ((len = zis.read(bytes)) > 0)
2473
- {
2474
- output.write(bytes, 0, len);
2475
- }
2476
- }
2477
- finally
2478
- {
2479
- // we must always close the output file
2480
- if(output!=null) output.close();
2481
- }
2482
- }
2483
- }
2484
- }
2485
- }
2486
- catch (java.net.MalformedURLException mue)
2487
- {
2488
- System.err.println("Ouch - a MalformedURLException happened.");
2489
- mue.printStackTrace();
2490
- //System.exit(2);
2491
- }
2492
- catch (IOException ioe)
2493
- {
2494
- //System.err.println("Oops - an IOException happened.");
2495
- //ioe.printStackTrace();
2496
- //System.exit(3);
2497
- }
2498
- finally
2499
- {
2500
- try
2501
- {
2502
- if (is != null)
2503
- is.close();
2504
- }
2505
- catch (IOException ioe)
2506
- {
2507
- }
2508
- }
2509
-
2510
- // System.out.println("length = " + total);
2511
-
2512
-// try
2513
-// {
2514
-// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905");
2515
-// }
2516
-// catch (Exception e)
2517
-// {
2518
-// e.printStackTrace();
2519
-// }
2520
-
2448
+ Grafreed.Assert(texturedata != null);
2449
+
2450
+ int width = texturedata.getWidth();
2451
+ int height = texturedata.getHeight();
2452
+
2453
+ Buffer buffer = texturedata.getBuffer();
2454
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2455
+
2456
+ byte[] bytes = bytebuf.array();
2457
+
2458
+ return CreateBim(bytes, width, height);
25212459 }
25222460
25232461 /**/
....@@ -2528,28 +2466,31 @@
25282466
25292467 int resolution;
25302468
2531
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2469
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
25322470 {
2533
- texture = tex;
2471
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2472
+ texturedata = texdata;
25342473 resolution = res;
25352474 }
25362475 }
25372476 /**/
25382477
25392478 // TEXTURE static Texture texture;
2540
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2541
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2542
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2481
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2482
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2483
+
25432484 int pigmentdepth = 0;
25442485 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
25452486 int bumpdepth = 0;
25462487 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
25472488 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
25482489 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2549
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2490
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
25502491 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
25512492
2552
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2493
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
25532494 {
25542495 TextureData texturedata = null;
25552496
....@@ -2568,13 +2509,34 @@
25682509 if (bump)
25692510 texturedata = ConvertBump(texturedata, false);
25702511
2571
- com.sun.opengl.util.texture.Texture texture =
2572
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2512
+// com.sun.opengl.util.texture.Texture texture =
2513
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
25732514
2574
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2575
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2516
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
25762517
2577
- return texture;
2518
+ return texturedata;
2519
+ }
2520
+
2521
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2522
+ {
2523
+ TextureData texturedata = null;
2524
+
2525
+ try
2526
+ {
2527
+ texturedata =
2528
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2529
+ bim,
2530
+ true);
2531
+ } catch (Exception e)
2532
+ {
2533
+ throw new javax.media.opengl.GLException(e);
2534
+ }
2535
+
2536
+ if (bump)
2537
+ texturedata = ConvertBump(texturedata, false);
2538
+
2539
+ return texturedata;
25782540 }
25792541
25802542 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3647,6 +3609,8 @@
36473609
36483610 System.out.println("LOADING TEXTURE : " + name);
36493611
3612
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3613
+
36503614 //
36513615 if (false) // compressbit > 0)
36523616 {
....@@ -8045,7 +8009,7 @@
80458009 String pigment = Object3D.GetPigment(tex);
80468010 String bump = Object3D.GetBump(tex);
80478011
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8012
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498013 {
80508014 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80518015 // System.out.println("; bump = " + bump);
....@@ -8060,8 +8024,8 @@
80608024 pigment = null;
80618025 }
80628026
8063
- ReleaseTexture(bump, true);
8064
- ReleaseTexture(pigment, false);
8027
+ ReleaseTexture(tex, true);
8028
+ ReleaseTexture(tex, false);
80658029 }
80668030
80678031 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -8079,7 +8043,7 @@
80798043
80808044 String pigment = Object3D.GetPigment(tex);
80818045
8082
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8046
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80838047 {
80848048 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80858049 // System.out.println("; bump = " + bump);
....@@ -8090,7 +8054,7 @@
80908054 pigment = null;
80918055 }
80928056
8093
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, false);
80948058 }
80958059
80968060 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8108,7 +8072,7 @@
81088072
81098073 String bump = Object3D.GetBump(tex);
81108074
8111
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8075
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81128076 {
81138077 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
81148078 // System.out.println("; bump = " + bump);
....@@ -8119,10 +8083,10 @@
81198083 bump = null;
81208084 }
81218085
8122
- ReleaseTexture(bump, true);
8086
+ ReleaseTexture(tex, true);
81238087 }
81248088
8125
- void ReleaseTexture(String tex, boolean bump)
8089
+ void ReleaseTexture(cTexture tex, boolean bump)
81268090 {
81278091 if (// DrawMode() != 0 || /*tex == null ||*/
81288092 ambientOcclusion ) // || !textureon)
....@@ -8133,7 +8097,7 @@
81338097 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
81348098
81358099 if (tex != null)
8136
- texture = textures.get(tex);
8100
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
81378101
81388102 // //assert( texture != null );
81398103 // if (texture == null)
....@@ -8227,47 +8191,50 @@
82278191
82288192 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
82298193 {
8230
- if (// DrawMode() != 0 || /*tex == null ||*/
8231
- ambientOcclusion ) // || !textureon)
8232
- {
8233
- return; // false;
8234
- }
8235
-
8236
- if (tex == null)
8237
- {
8238
- BindTexture(null,false,resolution);
8239
- BindTexture(null,true,resolution);
8240
- return;
8241
- }
8194
+// if (// DrawMode() != 0 || /*tex == null ||*/
8195
+// ambientOcclusion ) // || !textureon)
8196
+// {
8197
+// return; // false;
8198
+// }
8199
+//
8200
+// if (tex == null)
8201
+// {
8202
+// BindTexture(null,false,resolution);
8203
+// BindTexture(null,true,resolution);
8204
+// return;
8205
+// }
8206
+//
8207
+// String pigment = Object3D.GetPigment(tex);
8208
+// String bump = Object3D.GetBump(tex);
8209
+//
8210
+// usedtextures.add(pigment);
8211
+// usedtextures.add(bump);
8212
+//
8213
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8214
+// {
8215
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8216
+// // System.out.println("; bump = " + bump);
8217
+// }
8218
+//
8219
+// if (bump.equals(""))
8220
+// {
8221
+// bump = null;
8222
+// }
8223
+// if (pigment.equals(""))
8224
+// {
8225
+// pigment = null;
8226
+// }
8227
+//
8228
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8229
+// BindTexture(pigment, false, resolution);
8230
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8231
+// BindTexture(bump, true, resolution);
8232
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8233
+//
8234
+// return; // true;
82428235
8243
- String pigment = Object3D.GetPigment(tex);
8244
- String bump = Object3D.GetBump(tex);
8245
-
8246
- usedtextures.put(pigment, pigment);
8247
- usedtextures.put(bump, bump);
8248
-
8249
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8250
- {
8251
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8252
- // System.out.println("; bump = " + bump);
8253
- }
8254
-
8255
- if (bump.equals(""))
8256
- {
8257
- bump = null;
8258
- }
8259
- if (pigment.equals(""))
8260
- {
8261
- pigment = null;
8262
- }
8263
-
8264
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
- BindTexture(pigment, false, resolution);
8266
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8267
- BindTexture(bump, true, resolution);
8268
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8269
-
8270
- return; // true;
8236
+ BindPigmentTexture(tex, resolution);
8237
+ BindBumpTexture(tex, resolution);
82718238 }
82728239
82738240 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8286,9 +8253,9 @@
82868253
82878254 String pigment = Object3D.GetPigment(tex);
82888255
8289
- usedtextures.put(pigment, pigment);
8256
+ usedtextures.add(tex);
82908257
8291
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8258
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82928259 {
82938260 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
82948261 // System.out.println("; bump = " + bump);
....@@ -8300,7 +8267,7 @@
83008267 }
83018268
83028269 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8303
- BindTexture(pigment, false, resolution);
8270
+ BindTexture(tex, false, resolution);
83048271 }
83058272
83068273 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8319,9 +8286,9 @@
83198286
83208287 String bump = Object3D.GetBump(tex);
83218288
8322
- usedtextures.put(bump, bump);
8289
+ usedtextures.add(tex);
83238290
8324
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8291
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
83258292 {
83268293 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
83278294 // System.out.println("; bump = " + bump);
....@@ -8333,7 +8300,7 @@
83338300 }
83348301
83358302 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8336
- BindTexture(bump, true, resolution);
8303
+ BindTexture(tex, true, resolution);
83378304 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
83388305 }
83398306
....@@ -8357,13 +8324,19 @@
83578324 return fileExists;
83588325 }
83598326
8360
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8327
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
83618328 {
8362
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8329
+ CacheTexture texturecache = null;
83638330
83648331 if (tex != null)
83658332 {
8366
- String texname = tex;
8333
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8334
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8335
+
8336
+ if (texname.equals("") && texdata == null)
8337
+ {
8338
+ return null;
8339
+ }
83678340
83688341 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
83698342
....@@ -8373,19 +8346,46 @@
83738346 // else
83748347 // if (!texname.startsWith("/"))
83758348 // texname = "/Users/nbriere/Textures/" + texname;
8376
- if (!FileExists(tex))
8349
+ if (!FileExists(texname))
83778350 {
83788351 texname = fallbackTextureName;
83798352 }
83808353
83818354 if (CACHETEXTURE)
8382
- texture = textures.get(texname); // TEXTURE CACHE
8383
-
8384
- TextureData texturedata = null;
8385
-
8386
- if (texture == null || texture.resolution < resolution)
83878355 {
8388
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8356
+ if (texdata == null)
8357
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8358
+ else
8359
+ texturecache = bimtextures.get(texdata);
8360
+ }
8361
+
8362
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8363
+ {
8364
+ TextureData texturedata = null;
8365
+
8366
+ if (texdata != null && textureon)
8367
+ {
8368
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8369
+
8370
+ try
8371
+ {
8372
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8373
+ }
8374
+ catch (Exception e)
8375
+ {
8376
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8377
+ }
8378
+
8379
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8380
+ bimtextures.put(texdata, texturecache);
8381
+
8382
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8383
+
8384
+ //Object bim2 = CreateBim(texturecache.texturedata);
8385
+ //bim2 = bim;
8386
+ }
8387
+ else
8388
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
83898389 {
83908390 assert(!bump);
83918391 // if (bump)
....@@ -8396,19 +8396,23 @@
83968396 // }
83978397 // else
83988398 // {
8399
- texture = textures.get(tex);
8400
- if (texture == null)
8399
+ // texturecache = textures.get(texname); // suspicious
8400
+ if (texturecache == null)
84018401 {
8402
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8402
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
84038403 }
8404
+ else
8405
+ new Exception().printStackTrace();
84048406 // }
84058407 } else
8406
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8408
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
84078409 {
84088410 assert(bump);
8409
- texture = textures.get(tex);
8410
- if (texture == null)
8411
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8411
+ // texturecache = textures.get(texname); // suspicious
8412
+ if (texturecache == null)
8413
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8414
+ else
8415
+ new Exception().printStackTrace();
84128416 } else
84138417 {
84148418 //if (tex.equals("IMMORTAL"))
....@@ -8416,11 +8420,13 @@
84168420 // texture = GetResourceTexture("default.png");
84178421 //} else
84188422 //{
8419
- if (tex.equals("WHITE_NOISE"))
8423
+ if (texname.endsWith("WHITE_NOISE"))
84208424 {
8421
- texture = textures.get(tex);
8422
- if (texture == null)
8423
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8425
+ // texturecache = textures.get(texname); // suspicious
8426
+ if (texturecache == null)
8427
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8428
+ else
8429
+ new Exception().printStackTrace();
84248430 } else
84258431 {
84268432 if (textureon)
....@@ -8479,19 +8485,19 @@
84798485 if (texturedata == null)
84808486 throw new Exception();
84818487
8482
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8488
+ texturecache = new CacheTexture(texturedata,resolution);
84838489 //texture = GetTexture(tex, bump);
84848490 }
84858491 }
84868492 //}
84878493 }
84888494
8489
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8495
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
84908496 {
84918497 //return false;
84928498
84938499 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8494
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8500
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
84958501 {
84968502 // String ext = "_highres";
84978503 // if (REDUCETEXTURE)
....@@ -8508,52 +8514,17 @@
85088514 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
85098515 if (!cachefile.exists())
85108516 {
8511
- // cache to disk
8512
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8513
- //buffers[0].
8514
-
8515
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8516
- int[] pixels = new int[bytebuf.capacity()/3];
8517
-
8518
- // squared size heuristic...
8519
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8517
+ //if (texturedata.getWidth() == texturedata.getHeight())
85208518 {
8521
- for (int i=pixels.length; --i>=0;)
8522
- {
8523
- int i3 = i*3;
8524
- pixels[i] = 0xFF;
8525
- pixels[i] <<= 8;
8526
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8527
- pixels[i] <<= 8;
8528
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8529
- pixels[i] <<= 8;
8530
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8531
- }
8532
-
8533
- /*
8534
- int r=0,g=0,b=0,a=0;
8535
- for (int i=0; i<width; i++)
8536
- for (int j=0; j<height; j++)
8537
- {
8538
- int index = j*width+i;
8539
- int p = pixels[index];
8540
- a = ((p>>24) & 0xFF);
8541
- r = ((p>>16) & 0xFF);
8542
- g = ((p>>8) & 0xFF);
8543
- b = (p & 0xFF);
8544
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8545
- }
8546
- /**/
8547
- int width = (int)Math.sqrt(pixels.length); // squared
8548
- int height = width;
8549
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8550
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8519
+ BufferedImage rendImage = CreateBim(texturedata);
8520
+
85518521 ImageWriter writer = null;
85528522 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
85538523 if (iter.hasNext()) {
85548524 writer = (ImageWriter)iter.next();
85558525 }
8556
- float compressionQuality = 0.9f;
8526
+
8527
+ float compressionQuality = 0.85f;
85578528 try
85588529 {
85598530 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8570,18 +8541,20 @@
85708541 }
85718542 }
85728543 }
8573
-
8544
+
8545
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8546
+
85748547 //System.out.println("Texture = " + tex);
8575
- if (textures.containsKey(texname))
8548
+ if (textures.containsKey(tex))
85768549 {
8577
- CacheTexture thetex = textures.get(texname);
8550
+ CacheTexture thetex = textures.get(tex);
85788551 thetex.texture.disable();
85798552 thetex.texture.dispose();
8580
- textures.remove(texname);
8553
+ textures.remove(tex);
85818554 }
85828555
8583
- texture.texturedata = texturedata;
8584
- textures.put(texname, texture);
8556
+ //texture.texturedata = texturedata;
8557
+ textures.put(tex, texturecache);
85858558
85868559 // newtex = true;
85878560 }
....@@ -8597,10 +8570,44 @@
85978570 }
85988571 }
85998572
8600
- return texture;
8573
+ return texturecache;
86018574 }
86028575
8603
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8576
+ static void EmbedTextures(cTexture tex)
8577
+ {
8578
+ if (tex.pigmentdata == null)
8579
+ {
8580
+ //String texname = Object3D.GetPigment(tex);
8581
+
8582
+ CacheTexture texturecache = texturepigment.get(tex);
8583
+
8584
+ if (texturecache != null)
8585
+ {
8586
+ tex.pw = texturecache.texturedata.getWidth();
8587
+ tex.ph = texturecache.texturedata.getHeight();
8588
+ tex.pigmentdata = //CompressJPEG(CreateBim
8589
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8590
+ ;
8591
+ //, tex.pw, tex.ph), 0.5f);
8592
+ }
8593
+ }
8594
+
8595
+ if (tex.bumpdata == null)
8596
+ {
8597
+ //String texname = Object3D.GetBump(tex);
8598
+
8599
+ CacheTexture texturecache = texturebump.get(tex);
8600
+
8601
+ if (texturecache != null)
8602
+ {
8603
+ tex.bw = texturecache.texturedata.getWidth();
8604
+ tex.bh = texturecache.texturedata.getHeight();
8605
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8606
+ }
8607
+ }
8608
+ }
8609
+
8610
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
86048611 {
86058612 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86068613
....@@ -8618,21 +8625,21 @@
86188625 return texture!=null?texture.texture:null;
86198626 }
86208627
8621
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8628
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
86228629 {
86238630 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86248631
86258632 return texture!=null?texture.texturedata:null;
86268633 }
86278634
8628
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8635
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
86298636 {
86308637 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
86318638 {
86328639 return false;
86338640 }
86348641
8635
- boolean newtex = false;
8642
+ //boolean newtex = false;
86368643
86378644 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
86388645
....@@ -8664,9 +8671,75 @@
86648671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
86658672 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
86668673
8667
- return newtex;
8674
+ return true; // Warning: not used.
86688675 }
86698676
8677
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8678
+ {
8679
+ try
8680
+ {
8681
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8682
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8683
+ ImageWriter writer = writers.next();
8684
+
8685
+ ImageWriteParam param = writer.getDefaultWriteParam();
8686
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8687
+ param.setCompressionQuality(quality);
8688
+
8689
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8690
+ writer.setOutput(ios);
8691
+ writer.write(null, new IIOImage(image, null, null), param);
8692
+
8693
+ byte[] data = baos.toByteArray();
8694
+ writer.dispose();
8695
+ return data;
8696
+ }
8697
+ catch (Exception e)
8698
+ {
8699
+ e.printStackTrace();
8700
+ return null;
8701
+ }
8702
+ }
8703
+
8704
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8705
+ {
8706
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8707
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8708
+ ImageReader reader = writers.next();
8709
+
8710
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8711
+
8712
+ ImageReadParam param = reader.getDefaultReadParam();
8713
+ param.setDestination(bim);
8714
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8715
+
8716
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8717
+ reader.setInput(ios);
8718
+ BufferedImage bim2 = reader.read(0, param);
8719
+ reader.dispose();
8720
+
8721
+// WritableRaster raster = bim2.getRaster();
8722
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8723
+// byte[] bytes = data.getData();
8724
+//
8725
+// int[] pixels = new int[bytes.length/3];
8726
+// for (int i=pixels.length; --i>=0;)
8727
+// {
8728
+// int i3 = i*3;
8729
+// pixels[i] = 0xFF;
8730
+// pixels[i] <<= 8;
8731
+// pixels[i] |= bytes[i3+2] & 0xFF;
8732
+// pixels[i] <<= 8;
8733
+// pixels[i] |= bytes[i3+1] & 0xFF;
8734
+// pixels[i] <<= 8;
8735
+// pixels[i] |= bytes[i3] & 0xFF;
8736
+// }
8737
+//
8738
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8739
+
8740
+ return bim;
8741
+ }
8742
+
86708743 ShadowBuffer shadowPBuf;
86718744 AntialiasBuffer antialiasPBuf;
86728745 int MAXSTACK;
....@@ -9627,7 +9700,7 @@
96279700
96289701 if (renderCamera != lightCamera)
96299702 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9630
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9703
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
96319704
96329705 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
96339706
....@@ -9643,7 +9716,7 @@
96439716
96449717 if (renderCamera != lightCamera)
96459718 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9646
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9719
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
96479720
96489721 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
96499722
....@@ -10844,7 +10917,7 @@
1084410917 // if (parentcam != renderCamera) // not a light
1084510918 if (cam != lightCamera)
1084610919 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10847
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10920
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1084810921
1084910922 for (int j = 0; j < 4; j++)
1085010923 {
....@@ -10859,7 +10932,7 @@
1085910932 // if (parentcam != renderCamera) // not a light
1086010933 if (cam != lightCamera)
1086110934 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10862
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10935
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1086310936
1086410937 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1086510938
....@@ -11150,9 +11223,9 @@
1115011223
1115111224 gl.glMatrixMode(GL.GL_MODELVIEW);
1115211225
11153
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11154
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11155
-//gl.glEnable(gl.GL_MULTISAMPLE);
11226
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11227
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11228
+gl.glEnable(gl.GL_MULTISAMPLE);
1115611229 } else
1115711230 {
1115811231 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11163,7 +11236,7 @@
1116311236 //System.out.println("BLENDING ON");
1116411237 gl.glEnable(GL.GL_BLEND);
1116511238 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11166
-
11239
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1116711240 gl.glMatrixMode(gl.GL_PROJECTION);
1116811241 gl.glLoadIdentity();
1116911242
....@@ -11412,7 +11485,7 @@
1141211485 }
1141311486 }
1141411487
11415
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11488
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1141611489 {
1141711490 //gl.glDepthFunc(GL.GL_LEQUAL);
1141811491 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11420,24 +11493,21 @@
1142011493
1142111494 boolean texon = textureon;
1142211495
11423
- if (RENDERPROGRAM > 0)
11424
- {
11425
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11426
- textureon = false;
11427
- }
11496
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11497
+ textureon = false;
11498
+
1142811499 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1142911500 //System.out.println("ALLO");
1143011501 gl.glColorMask(false, false, false, false);
1143111502 DrawObject(gl);
11432
- if (RENDERPROGRAM > 0)
11433
- {
11434
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11435
- textureon = texon;
11436
- }
11503
+
11504
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11505
+ textureon = texon;
11506
+
1143711507 gl.glColorMask(true, true, true, true);
1143811508
1143911509 gl.glDepthFunc(GL.GL_EQUAL);
11440
- //gl.glDepthMask(false);
11510
+ gl.glDepthMask(false);
1144111511 }
1144211512
1144311513 if (false) // DrawMode() == SHADOW)
....@@ -11649,7 +11719,7 @@
1164911719 if ((TRACK || SHADOWTRACK) || zoomonce)
1165011720 {
1165111721 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11652
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11722
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1165311723 pingthread.StepToTarget(true); // true);
1165411724 // zoomonce = false;
1165511725 }
....@@ -11777,20 +11847,32 @@
1177711847 ReleaseTextures(DEFAULT_TEXTURES);
1177811848
1177911849 if (CLEANCACHE)
11780
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11850
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1178111851 {
11782
- String tex = e.nextElement();
11852
+ cTexture tex = e.nextElement();
1178311853
1178411854 // System.out.println("Texture --------- " + tex);
1178511855
11786
- if (tex.equals("WHITE_NOISE"))
11856
+ if (tex.equals("WHITE_NOISE:"))
1178711857 continue;
1178811858
11789
- if (!usedtextures.containsKey(tex))
11859
+ if (!usedtextures.contains(tex))
1179011860 {
11861
+ CacheTexture gettex = texturepigment.get(tex);
1179111862 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11792
- textures.get(tex).texture.dispose();
11793
- textures.remove(tex);
11863
+ if (gettex != null)
11864
+ {
11865
+ gettex.texture.dispose();
11866
+ texturepigment.remove(tex);
11867
+ }
11868
+
11869
+ gettex = texturebump.get(tex);
11870
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11871
+ if (gettex != null)
11872
+ {
11873
+ gettex.texture.dispose();
11874
+ texturebump.remove(tex);
11875
+ }
1179411876 }
1179511877 }
1179611878 }
....@@ -12319,7 +12401,74 @@
1231912401 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1232012402
1232112403 String program =
12404
+ // Min shader
1232212405 "!!ARBfp1.0\n" +
12406
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12407
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12408
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12409
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12410
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12411
+ "PARAM light2cam0 = program.env[10];" +
12412
+ "PARAM light2cam1 = program.env[11];" +
12413
+ "PARAM light2cam2 = program.env[12];" +
12414
+ "TEMP temp;" +
12415
+ "TEMP light;" +
12416
+ "TEMP ndotl;" +
12417
+ "TEMP normal;" +
12418
+ "TEMP depth;" +
12419
+ "TEMP eye;" +
12420
+ "TEMP pos;" +
12421
+
12422
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12423
+ Normalize("normal") +
12424
+ "MOV light, state.light[0].position;" +
12425
+ "DP3 ndotl.x, light, normal;" +
12426
+
12427
+ // shadow
12428
+ "MOV pos, fragment.texcoord[1];" +
12429
+ "MOV temp, pos;" +
12430
+ ShadowTextureFetch("depth", "temp", "1") +
12431
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12432
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12433
+
12434
+ // No shadow when out of frustum
12435
+ //"SGE temp.y, depth.z, zero123.y;" +
12436
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12437
+
12438
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12439
+
12440
+ // Backlit
12441
+ "MOV pos.w, zero123.y;" +
12442
+ "DP4 eye.x, pos, light2cam0;" +
12443
+ "DP4 eye.y, pos, light2cam1;" +
12444
+ "DP4 eye.z, pos, light2cam2;" +
12445
+ Normalize("eye") +
12446
+
12447
+ "DP3 ndotl.y, -eye, normal;" +
12448
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12449
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12450
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12451
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12452
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12453
+
12454
+ "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12455
+
12456
+ // Pigment
12457
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12458
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12459
+ "MUL temp, temp, ndotl.x;" +
12460
+
12461
+ "MUL temp, temp, zero123.z;" +
12462
+
12463
+ //"MUL temp, temp, ndotl.y;" +
12464
+
12465
+ "MOV temp.w, zero123.y;" + // reset alpha
12466
+ "MOV result.color, temp;" +
12467
+ "END";
12468
+
12469
+ String program2 =
12470
+ "!!ARBfp1.0\n" +
12471
+
1232312472 //"OPTION ARB_fragment_program_shadow;" +
1232412473 "PARAM light2cam0 = program.env[10];" +
1232512474 "PARAM light2cam1 = program.env[11];" +
....@@ -12434,8 +12583,7 @@
1243412583 "TEMP shininess;" +
1243512584 "\n" +
1243612585 "MOV texSamp, one;" +
12437
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12438
-
12586
+
1243912587 "MOV mapgrid.x, one2048th.x;" +
1244012588 "MOV temp, fragment.texcoord[1];" +
1244112589 /*
....@@ -12456,20 +12604,20 @@
1245612604 "MUL temp, floor, mapgrid.x;" +
1245712605 //"TEX depth0, temp, texture[1], 2D;" +
1245812606 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12459
- TextureFetch("depth0", "temp", "1") +
12607
+ ShadowTextureFetch("depth0", "temp", "1") +
1246012608 "") +
1246112609 "ADD temp.x, temp.x, mapgrid.x;" +
1246212610 //"TEX depth1, temp, texture[1], 2D;" +
1246312611 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12464
- TextureFetch("depth1", "temp", "1") +
12612
+ ShadowTextureFetch("depth1", "temp", "1") +
1246512613 "") +
1246612614 "ADD temp.y, temp.y, mapgrid.x;" +
1246712615 //"TEX depth2, temp, texture[1], 2D;" +
12468
- TextureFetch("depth2", "temp", "1") +
12616
+ ShadowTextureFetch("depth2", "temp", "1") +
1246912617 "SUB temp.x, temp.x, mapgrid.x;" +
1247012618 //"TEX depth3, temp, texture[1], 2D;" +
1247112619 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12472
- TextureFetch("depth3", "temp", "1") +
12620
+ ShadowTextureFetch("depth3", "temp", "1") +
1247312621 "") +
1247412622 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1247512623 //"MOV params, material;" +
....@@ -12840,7 +12988,7 @@
1284012988 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1284112989 "") +
1284212990
12843
- // display shadow only (bump == 0)
12991
+ // display shadow only (fakedepth == 0)
1284412992 "SUB temp.x, half.x, shadow.x;" +
1284512993 "MOV temp.y, -params5.z;" + // params6.x;" +
1284612994 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13267,25 +13415,26 @@
1326713415 return out;
1326813416 }
1326913417
13270
- String TextureFetch(String dest, String src, String unit)
13418
+ // Also does frustum culling
13419
+ String ShadowTextureFetch(String dest, String src, String unit)
1327113420 {
1327213421 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1327313422 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1327413423 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13424
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13425
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1327513426 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13276
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13277
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13278
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13279
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13427
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13428
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1328013429 //"SWZ buffer, temp, w,w,w,w;";
13281
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13430
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1328213431 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1328313432 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1328413433 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13285
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13434
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1328613435
13287
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13288
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13436
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13437
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1328913438 }
1329013439
1329113440 String Shadow(String depth, String shadow)
....@@ -13332,7 +13481,7 @@
1333213481 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1333313482 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333413483
13335
- // No shadow when out of frustrum
13484
+ // No shadow when out of frustum
1333613485 "SGE temp.x, " + depth + ".z, one.z;" +
1333713486 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333813487 "";
....@@ -14065,7 +14214,7 @@
1406514214
1406614215 // fev 2014???
1406714216 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14217
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1406914218 pingthread.StepToTarget(true); // true);
1407014219 }
1407114220 // if (!LIVE)
....@@ -14130,14 +14279,15 @@
1413014279 drag = false;
1413114280 //System.out.println("Mouse DOWN");
1413214281 editObj = false;
14133
- ClickInfo info = new ClickInfo();
14134
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14135
- info.pane = this;
14136
- info.camera = renderCamera;
14137
- info.x = x;
14138
- info.y = y;
14139
- info.modifiers = modifiersex;
14140
- editObj = object.doEditClick(info, 0);
14282
+ //ClickInfo info = new ClickInfo();
14283
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14284
+ object.clickInfo.pane = this;
14285
+ object.clickInfo.camera = renderCamera;
14286
+ object.clickInfo.x = x;
14287
+ object.clickInfo.y = y;
14288
+ object.clickInfo.modifiers = modifiersex;
14289
+ editObj = object.doEditClick(//info,
14290
+ 0);
1414114291 if (!editObj)
1414214292 {
1414314293 hasMarquee = true;
....@@ -14419,12 +14569,12 @@
1441914569 void GoDown(int mod)
1442014570 {
1442114571 MODIFIERS |= COMMAND;
14422
- /*
14572
+ /**/
1442314573 if((mod&SHIFT) == SHIFT)
1442414574 manipCamera.RotatePosition(0, -speed);
1442514575 else
14426
- manipCamera.BackForth(0, -speed*delta, getWidth());
14427
- */
14576
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14577
+ /**/
1442814578 if ((mod & SHIFT) == SHIFT)
1442914579 {
1443014580 mouseMode = mouseMode; // VR??
....@@ -14440,12 +14590,12 @@
1444014590 void GoUp(int mod)
1444114591 {
1444214592 MODIFIERS |= COMMAND;
14443
- /*
14593
+ /**/
1444414594 if((mod&SHIFT) == SHIFT)
1444514595 manipCamera.RotatePosition(0, speed);
1444614596 else
14447
- manipCamera.BackForth(0, speed*delta, getWidth());
14448
- */
14597
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14598
+ /**/
1444914599 if ((mod & SHIFT) == SHIFT)
1445014600 {
1445114601 mouseMode = mouseMode;
....@@ -14461,12 +14611,12 @@
1446114611 void GoLeft(int mod)
1446214612 {
1446314613 MODIFIERS |= COMMAND;
14464
- /*
14614
+ /**/
1446514615 if((mod&SHIFT) == SHIFT)
14466
- manipCamera.RotatePosition(speed, 0);
14467
- else
1446814616 manipCamera.Translate(speed*delta, 0, getWidth());
14469
- */
14617
+ else
14618
+ manipCamera.RotatePosition(speed, 0);
14619
+ /**/
1447014620 if ((mod & SHIFT) == SHIFT)
1447114621 {
1447214622 mouseMode = mouseMode;
....@@ -14482,12 +14632,12 @@
1448214632 void GoRight(int mod)
1448314633 {
1448414634 MODIFIERS |= COMMAND;
14485
- /*
14635
+ /**/
1448614636 if((mod&SHIFT) == SHIFT)
14487
- manipCamera.RotatePosition(-speed, 0);
14488
- else
1448914637 manipCamera.Translate(-speed*delta, 0, getWidth());
14490
- */
14638
+ else
14639
+ manipCamera.RotatePosition(-speed, 0);
14640
+ /**/
1449114641 if ((mod & SHIFT) == SHIFT)
1449214642 {
1449314643 mouseMode = mouseMode;
....@@ -14537,15 +14687,16 @@
1453714687 if (editObj)
1453814688 {
1453914689 drag = true;
14540
- ClickInfo info = new ClickInfo();
14541
- info.bounds.setBounds(0, 0,
14690
+ //ClickInfo info = new ClickInfo();
14691
+ object.clickInfo.bounds.setBounds(0, 0,
1454214692 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14543
- info.pane = this;
14544
- info.camera = renderCamera;
14545
- info.x = x;
14546
- info.y = y;
14547
- object.GetWindow().copy
14548
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14693
+ object.clickInfo.pane = this;
14694
+ object.clickInfo.camera = renderCamera;
14695
+ object.clickInfo.x = x;
14696
+ object.clickInfo.y = y;
14697
+ object //.GetWindow().copy
14698
+ .doEditDrag(//info,
14699
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1454914700 } else
1455014701 {
1455114702 if (x < startX)
....@@ -14694,24 +14845,27 @@
1469414845 }
1469514846 }
1469614847
14848
+// ClickInfo clickInfo = new ClickInfo();
14849
+
1469714850 public void mouseMoved(MouseEvent e)
1469814851 {
1469914852 //System.out.println("mouseMoved: " + e);
1470014853 if (isRenderer)
1470114854 return;
1470214855
14703
- ClickInfo ci = new ClickInfo();
14704
- ci.x = e.getX();
14705
- ci.y = e.getY();
14706
- ci.modifiers = e.getModifiersEx();
14707
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14708
- ci.pane = this;
14709
- ci.camera = renderCamera;
14856
+ // Mouse cursor feedback
14857
+ object.clickInfo.x = e.getX();
14858
+ object.clickInfo.y = e.getY();
14859
+ object.clickInfo.modifiers = e.getModifiersEx();
14860
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14861
+ object.clickInfo.pane = this;
14862
+ object.clickInfo.camera = renderCamera;
1471014863 if (!isRenderer)
1471114864 {
1471214865 //ObjEditor editWindow = object.editWindow;
1471314866 //Object3D copy = editWindow.copy;
14714
- if (object.doEditClick(ci, 0))
14867
+ if (object.doEditClick(//clickInfo,
14868
+ 0))
1471514869 {
1471614870 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1471714871 } else
....@@ -14726,7 +14880,8 @@
1472614880 Globals.MOUSEDRAGGED = false;
1472714881
1472814882 movingcamera = false;
14729
- X = Y = 0;
14883
+ X = 0; // getBounds().width/2;
14884
+ Y = 0; // getBounds().height/2;
1473014885 //System.out.println("mouseReleased: " + e);
1473114886 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1473214887 }
....@@ -14982,7 +15137,8 @@
1498215137 // break;
1498315138 case 'T':
1498415139 CACHETEXTURE ^= true;
14985
- textures.clear();
15140
+ texturepigment.clear();
15141
+ texturebump.clear();
1498615142 // repaint();
1498715143 break;
1498815144 case 'Y':
....@@ -15067,7 +15223,9 @@
1506715223 case 'E' : COMPACT ^= true;
1506815224 repaint();
1506915225 break;
15070
- case 'W' : DEBUGHSB ^= true;
15226
+ case 'W' : // Wide Window (fullscreen)
15227
+ //DEBUGHSB ^= true;
15228
+ ObjEditor.theFrame.ToggleFullScreen();
1507115229 repaint();
1507215230 break;
1507315231 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -15093,13 +15251,7 @@
1509315251 repaint();
1509415252 break;
1509515253 case 'l':
15096
- lightMode ^= true;
15097
- Globals.lighttouched = true;
15098
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15099
- targetLookAt.set(manipCamera.lookAt);
15100
- repaint();
15101
- break;
15102
- case 'L':
15254
+ //case 'L':
1510315255 if (lightMode)
1510415256 {
1510515257 lightMode = false;
....@@ -15246,7 +15398,10 @@
1524615398 // kompactbit = 6;
1524715399 // break;
1524815400 case ' ':
15249
- ObjEditor.theFrame.ToggleFullScreen();
15401
+ lightMode ^= true;
15402
+ Globals.lighttouched = true;
15403
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15404
+ targetLookAt.set(manipCamera.lookAt);
1525015405 repaint();
1525115406 break;
1525215407 //case '`' :
....@@ -15295,12 +15450,6 @@
1529515450 break;
1529615451 case '+':
1529715452
15298
- //for (int i=0; i<0x7FFFFFFF; i++)
15299
- {
15300
- //String.format("%08X", i); // "7caca905"
15301
- GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true);
15302
- }
15303
-
1530415453 /*
1530515454 //fontsize += 1;
1530615455 bbzoom *= 2;
....@@ -15318,17 +15467,17 @@
1531815467 case '=':
1531915468 IncDepth();
1532015469 //fontsize += 1;
15321
- object.editWindow.refreshContents(true);
15470
+ object.GetWindow().refreshContents(true);
1532215471 maskbit = 6;
1532315472 break;
1532415473 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1532515474 DecDepth();
1532615475 maskbit = 5;
1532715476 //if(fontsize > 1) fontsize -= 1;
15328
- if (object.editWindow == null)
15329
- new Exception().printStackTrace();
15330
- else
15331
- object.editWindow.refreshContents(true);
15477
+// if (object.editWindow == null)
15478
+// new Exception().printStackTrace();
15479
+// else
15480
+ object.GetWindow().refreshContents(true);
1533215481 break;
1533315482 case '{':
1533415483 manipCamera.shaper_fovy /= 1.1;
....@@ -15552,7 +15701,7 @@
1555215701 }
1555315702 */
1555415703
15555
- object.editWindow.EditSelection(false);
15704
+ object.GetWindow().EditSelection(false);
1555615705 }
1555715706
1555815707 void SelectParent()
....@@ -15569,10 +15718,10 @@
1556915718 {
1557015719 //selectees.remove(i);
1557115720 System.out.println("select parent of " + elem);
15572
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15721
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1557315722 } else
1557415723 {
15575
- group.editWindow.Select(elem.GetTreePath(), first, true);
15724
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1557615725 }
1557715726
1557815727 first = false;
....@@ -15614,12 +15763,12 @@
1561415763 for (int j = 0; j < group.children.size(); j++)
1561515764 {
1561615765 elem = (Object3D) group.children.elementAt(j);
15617
- object.editWindow.Select(elem.GetTreePath(), first, true);
15766
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1561815767 first = false;
1561915768 }
1562015769 } else
1562115770 {
15622
- object.editWindow.Select(elem.GetTreePath(), first, true);
15771
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1562315772 }
1562415773
1562515774 first = false;
....@@ -15630,21 +15779,21 @@
1563015779 {
1563115780 //Composite group = (Composite) object;
1563215781 Object3D group = object;
15633
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15782
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1563415783 }
1563515784
1563615785 void ResetTransform(int mask)
1563715786 {
1563815787 //Composite group = (Composite) object;
1563915788 Object3D group = object;
15640
- group.editWindow.ResetTransform(mask);
15789
+ group.GetWindow().ResetTransform(mask);
1564115790 }
1564215791
1564315792 void FlipTransform()
1564415793 {
1564515794 //Composite group = (Composite) object;
1564615795 Object3D group = object;
15647
- group.editWindow.FlipTransform();
15796
+ group.GetWindow().FlipTransform();
1564815797 // group.editWindow.ReduceMesh(true);
1564915798 }
1565015799
....@@ -15652,7 +15801,7 @@
1565215801 {
1565315802 //Composite group = (Composite) object;
1565415803 Object3D group = object;
15655
- group.editWindow.PrintMemory();
15804
+ group.GetWindow().PrintMemory();
1565615805 // group.editWindow.ReduceMesh(true);
1565715806 }
1565815807
....@@ -15660,7 +15809,7 @@
1566015809 {
1566115810 //Composite group = (Composite) object;
1566215811 Object3D group = object;
15663
- group.editWindow.ResetCentroid();
15812
+ group.GetWindow().ResetCentroid();
1566415813 }
1566515814
1566615815 void IncDepth()
....@@ -15742,8 +15891,6 @@
1574215891
1574315892 int width = getBounds().width;
1574415893 int height = getBounds().height;
15745
- ClickInfo info = new ClickInfo();
15746
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1574715894 //Image img = CreateImage(width, height);
1574815895 //System.out.println("width = " + width + "; height = " + height + "\n");
1574915896
....@@ -15820,48 +15967,77 @@
1582015967 }
1582115968 if (object != null && !hasMarquee)
1582215969 {
15970
+ if (object.clickInfo == null)
15971
+ object.clickInfo = new ClickInfo();
15972
+ ClickInfo info = object.clickInfo;
15973
+ //ClickInfo info = new ClickInfo();
15974
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
15975
+
1582315976 if (isRenderer)
1582415977 {
15825
- info.flags++;
15978
+ object.clickInfo.flags++;
1582615979 double frameAspect = (double) width / (double) height;
1582715980 if (frameAspect > renderCamera.aspect)
1582815981 {
1582915982 int desired = (int) ((double) height * renderCamera.aspect);
15830
- info.bounds.width -= width - desired;
15831
- info.bounds.x += (width - desired) / 2;
15983
+ object.clickInfo.bounds.width -= width - desired;
15984
+ object.clickInfo.bounds.x += (width - desired) / 2;
1583215985 } else
1583315986 {
1583415987 int desired = (int) ((double) width / renderCamera.aspect);
15835
- info.bounds.height -= height - desired;
15836
- info.bounds.y += (height - desired) / 2;
15988
+ object.clickInfo.bounds.height -= height - desired;
15989
+ object.clickInfo.bounds.y += (height - desired) / 2;
1583715990 }
1583815991 }
15839
- info.g = gr;
15840
- info.camera = renderCamera;
15992
+
15993
+ object.clickInfo.g = gr;
15994
+ object.clickInfo.camera = renderCamera;
1584115995 /*
1584215996 // Memory intensive (brep.verticescopy)
1584315997 if (!(object instanceof Composite))
1584415998 object.draw(info, 0, false); // SLOW :
1584515999 */
15846
- if (!isRenderer)
16000
+ if (!isRenderer) // && drag)
1584716001 {
15848
- object.drawEditHandles(info, 0);
15849
-
15850
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
16002
+ Grafreed.Assert(object != null);
16003
+ Grafreed.Assert(object.selection != null);
16004
+ if (object.selection.Size() > 0)
1585116005 {
15852
- switch (object.selection.get(0).hitSomething)
16006
+ int hitSomething = object.selection.get(0).hitSomething;
16007
+
16008
+ object.clickInfo.DX = 0;
16009
+ object.clickInfo.DY = 0;
16010
+ object.clickInfo.W = 1;
16011
+ if (hitSomething == Object3D.hitCenter)
1585316012 {
15854
- case Object3D.hitCenter: gr.setColor(Color.pink);
15855
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15856
- break;
15857
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15858
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15859
- break;
15860
- case Object3D.hitScale: gr.setColor(Color.cyan);
15861
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15862
- break;
16013
+ info.DX = X;
16014
+ if (X != 0)
16015
+ info.DX -= info.bounds.width/2;
16016
+
16017
+ info.DY = Y;
16018
+ if (Y != 0)
16019
+ info.DY -= info.bounds.height/2;
1586316020 }
15864
-
16021
+
16022
+ object.drawEditHandles(//info,
16023
+ 0);
16024
+
16025
+ if (drag && (X != 0 || Y != 0))
16026
+ {
16027
+ switch (hitSomething)
16028
+ {
16029
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16030
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16031
+ break;
16032
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16033
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16034
+ break;
16035
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16036
+ gr.drawLine(X, Y, 0, 0);
16037
+ break;
16038
+ }
16039
+
16040
+ }
1586516041 }
1586616042 }
1586716043 }
....@@ -16659,6 +16835,14 @@
1665916835 }
1666016836 }
1666116837
16838
+ private Object3D GetFolder()
16839
+ {
16840
+ Object3D folder = object.GetWindow().copy;
16841
+ if (object.GetWindow().copy.selection.Size() > 0)
16842
+ folder = object.GetWindow().copy.selection.elementAt(0);
16843
+ return folder;
16844
+ }
16845
+
1666216846 class SelectBuffer implements GLEventListener
1666316847 {
1666416848
....@@ -16738,6 +16922,17 @@
1673816922
1673916923 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1674016924
16925
+ if (PAINTMODE)
16926
+ {
16927
+ if (object.GetWindow().copy.selection.Size() > 0)
16928
+ {
16929
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16930
+
16931
+ // Make what you paint not selectable.
16932
+ paintobj.ResetSelectable();
16933
+ }
16934
+ }
16935
+
1674116936 //int tmp = selection_view;
1674216937 //selection_view = -1;
1674316938 int temp = DrawMode();
....@@ -16749,6 +16944,17 @@
1674916944 // temp = DEFAULT; // patch for selection debug
1675016945 Globals.drawMode = temp; // WARNING
1675116946
16947
+ if (PAINTMODE)
16948
+ {
16949
+ if (object.GetWindow().copy.selection.Size() > 0)
16950
+ {
16951
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16952
+
16953
+ // Revert.
16954
+ paintobj.RestoreSelectable();
16955
+ }
16956
+ }
16957
+
1675216958 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1675316959
1675416960 // trying different ways of getting the depth info over
....@@ -16852,29 +17058,31 @@
1685217058 }
1685317059
1685417060 if (!movingcamera && !PAINTMODE)
16855
- object.editWindow.ScreenFitPoint(); // fev 2014
17061
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1685617062
16857
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17063
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1685817064 {
16859
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17065
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1686017066
16861
- Object3D group = new Object3D("inst" + paintcount++);
17067
+ if (object.GetWindow().copy.selection.Size() > 0)
17068
+ {
17069
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1686217070
16863
- group.CreateMaterial(); // use a void leaf to select instances
16864
-
16865
- group.add(paintobj); // link
16866
-
16867
- object.editWindow.SnapObject(group);
16868
-
16869
- Object3D folder = object.editWindow.copy;
16870
-
16871
- if (object.editWindow.copy.selection.Size() > 0)
16872
- folder = object.editWindow.copy.selection.elementAt(0);
16873
-
16874
- folder.add(group);
16875
-
16876
- object.editWindow.ResetModel();
16877
- object.editWindow.refreshContents();
17071
+ Object3D inst = new Object3D("inst" + paintcount++);
17072
+
17073
+ inst.CreateMaterial(); // use a void leaf to select instances
17074
+
17075
+ inst.add(paintobj); // link
17076
+
17077
+ object.GetWindow().SnapObject(inst);
17078
+
17079
+ Object3D folder = paintFolder; // GetFolder();
17080
+
17081
+ folder.add(inst);
17082
+
17083
+ object.GetWindow().ResetModel();
17084
+ object.GetWindow().refreshContents();
17085
+ }
1687817086 }
1687917087 else
1688017088 paintcount = 0;