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 = true; // 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
....@@ -2405,6 +2443,21 @@
24052443 return currentGL;
24062444 }
24072445
2446
+ static private BufferedImage CreateBim(TextureData texturedata)
2447
+ {
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);
2459
+ }
2460
+
24082461 /**/
24092462 class CacheTexture
24102463 {
....@@ -2413,18 +2466,20 @@
24132466
24142467 int resolution;
24152468
2416
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2469
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
24172470 {
2418
- texture = tex;
2471
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2472
+ texturedata = texdata;
24192473 resolution = res;
24202474 }
24212475 }
24222476 /**/
24232477
24242478 // TEXTURE static Texture texture;
2425
- static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2426
- static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2427
- static public java.util.HashSet<String> usedtextures = new java.util.HashSet<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>();
24282483
24292484 int pigmentdepth = 0;
24302485 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
....@@ -2432,10 +2487,10 @@
24322487 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24332488 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24342489 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2435
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2490
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24362491 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24372492
2438
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2493
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24392494 {
24402495 TextureData texturedata = null;
24412496
....@@ -2454,16 +2509,16 @@
24542509 if (bump)
24552510 texturedata = ConvertBump(texturedata, false);
24562511
2457
- com.sun.opengl.util.texture.Texture texture =
2458
- 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);
24592514
2460
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2461
- 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);
24622517
2463
- return texture;
2518
+ return texturedata;
24642519 }
24652520
2466
- com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2521
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
24672522 {
24682523 TextureData texturedata = null;
24692524
....@@ -2471,7 +2526,7 @@
24712526 {
24722527 texturedata =
24732528 com.sun.opengl.util.texture.TextureIO.newTextureData(
2474
- name,
2529
+ bim,
24752530 true);
24762531 } catch (Exception e)
24772532 {
....@@ -2480,14 +2535,8 @@
24802535
24812536 if (bump)
24822537 texturedata = ConvertBump(texturedata, false);
2483
-
2484
- com.sun.opengl.util.texture.Texture texture =
2485
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2486
-
2487
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2488
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2489
-
2490
- return texture;
2538
+
2539
+ return texturedata;
24912540 }
24922541
24932542 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -7975,8 +8024,8 @@
79758024 pigment = null;
79768025 }
79778026
7978
- ReleaseTexture(bump, true);
7979
- ReleaseTexture(pigment, false);
8027
+ ReleaseTexture(tex, true);
8028
+ ReleaseTexture(tex, false);
79808029 }
79818030
79828031 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -8005,7 +8054,7 @@
80058054 pigment = null;
80068055 }
80078056
8008
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, false);
80098058 }
80108059
80118060 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8034,10 +8083,10 @@
80348083 bump = null;
80358084 }
80368085
8037
- ReleaseTexture(bump, true);
8086
+ ReleaseTexture(tex, true);
80388087 }
80398088
8040
- void ReleaseTexture(String tex, boolean bump)
8089
+ void ReleaseTexture(cTexture tex, boolean bump)
80418090 {
80428091 if (// DrawMode() != 0 || /*tex == null ||*/
80438092 ambientOcclusion ) // || !textureon)
....@@ -8048,7 +8097,7 @@
80488097 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80498098
80508099 if (tex != null)
8051
- texture = textures.get(tex);
8100
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80528101
80538102 // //assert( texture != null );
80548103 // if (texture == null)
....@@ -8198,13 +8247,13 @@
81988247
81998248 if (tex == null)
82008249 {
8201
- BindTexture(null, null,false,resolution);
8250
+ BindTexture(null,false,resolution);
82028251 return;
82038252 }
82048253
82058254 String pigment = Object3D.GetPigment(tex);
82068255
8207
- usedtextures.add(pigment);
8256
+ usedtextures.add(tex);
82088257
82098258 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82108259 {
....@@ -8218,7 +8267,7 @@
82188267 }
82198268
82208269 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8221
- BindTexture(tex.pigmenttexture, pigment, false, resolution);
8270
+ BindTexture(tex, false, resolution);
82228271 }
82238272
82248273 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8231,13 +8280,13 @@
82318280
82328281 if (tex == null)
82338282 {
8234
- BindTexture(null, null,true,resolution);
8283
+ BindTexture(null,true,resolution);
82358284 return;
82368285 }
82378286
82388287 String bump = Object3D.GetBump(tex);
82398288
8240
- usedtextures.add(bump);
8289
+ usedtextures.add(tex);
82418290
82428291 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82438292 {
....@@ -8251,7 +8300,7 @@
82518300 }
82528301
82538302 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8254
- BindTexture(tex.bumptexture, bump, true, resolution);
8303
+ BindTexture(tex, true, resolution);
82558304 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82568305 }
82578306
....@@ -8275,13 +8324,19 @@
82758324 return fileExists;
82768325 }
82778326
8278
- CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8327
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82798328 {
82808329 CacheTexture texturecache = null;
82818330
82828331 if (tex != null)
82838332 {
8284
- 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
+ }
82858340
82868341 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82878342
....@@ -8291,29 +8346,46 @@
82918346 // else
82928347 // if (!texname.startsWith("/"))
82938348 // texname = "/Users/nbriere/Textures/" + texname;
8294
- if (!FileExists(tex))
8349
+ if (!FileExists(texname))
82958350 {
82968351 texname = fallbackTextureName;
82978352 }
82988353
82998354 if (CACHETEXTURE)
83008355 {
8301
- if (bim == null)
8302
- texturecache = textures.get(texname); // TEXTURE CACHE
8356
+ if (texdata == null)
8357
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
83038358 else
8304
- texturecache = bimtextures.get(bim); // TEXTURE CACHE
8359
+ texturecache = bimtextures.get(texdata);
83058360 }
83068361
8307
- if (texturecache == null || texturecache.resolution < resolution)
8362
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
83088363 {
83098364 TextureData texturedata = null;
83108365
8311
- if (bim == null)
8366
+ if (texdata != null && textureon)
83128367 {
8368
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
83138369
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;
83148386 }
83158387 else
8316
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8388
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
83178389 {
83188390 assert(!bump);
83198391 // if (bump)
....@@ -8324,19 +8396,23 @@
83248396 // }
83258397 // else
83268398 // {
8327
- texturecache = textures.get(tex);
8399
+ // texturecache = textures.get(texname); // suspicious
83288400 if (texturecache == null)
83298401 {
83308402 texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
83318403 }
8404
+ else
8405
+ new Exception().printStackTrace();
83328406 // }
83338407 } else
8334
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8408
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
83358409 {
83368410 assert(bump);
8337
- texturecache = textures.get(tex);
8411
+ // texturecache = textures.get(texname); // suspicious
83388412 if (texturecache == null)
83398413 texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8414
+ else
8415
+ new Exception().printStackTrace();
83408416 } else
83418417 {
83428418 //if (tex.equals("IMMORTAL"))
....@@ -8344,11 +8420,13 @@
83448420 // texture = GetResourceTexture("default.png");
83458421 //} else
83468422 //{
8347
- if (tex.equals("WHITE_NOISE"))
8423
+ if (texname.endsWith("WHITE_NOISE"))
83488424 {
8349
- texturecache = textures.get(tex);
8425
+ // texturecache = textures.get(texname); // suspicious
83508426 if (texturecache == null)
83518427 texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8428
+ else
8429
+ new Exception().printStackTrace();
83528430 } else
83538431 {
83548432 if (textureon)
....@@ -8407,14 +8485,14 @@
84078485 if (texturedata == null)
84088486 throw new Exception();
84098487
8410
- texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8488
+ texturecache = new CacheTexture(texturedata,resolution);
84118489 //texture = GetTexture(tex, bump);
84128490 }
84138491 }
84148492 //}
84158493 }
84168494
8417
- if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
8495
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
84188496 {
84198497 //return false;
84208498
....@@ -8436,52 +8514,17 @@
84368514 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
84378515 if (!cachefile.exists())
84388516 {
8439
- // cache to disk
8440
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8441
- //buffers[0].
8442
-
8443
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8444
- int[] pixels = new int[bytebuf.capacity()/3];
8445
-
8446
- // squared size heuristic...
8447
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8517
+ //if (texturedata.getWidth() == texturedata.getHeight())
84488518 {
8449
- for (int i=pixels.length; --i>=0;)
8450
- {
8451
- int i3 = i*3;
8452
- pixels[i] = 0xFF;
8453
- pixels[i] <<= 8;
8454
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8455
- pixels[i] <<= 8;
8456
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8457
- pixels[i] <<= 8;
8458
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8459
- }
8460
-
8461
- /*
8462
- int r=0,g=0,b=0,a=0;
8463
- for (int i=0; i<width; i++)
8464
- for (int j=0; j<height; j++)
8465
- {
8466
- int index = j*width+i;
8467
- int p = pixels[index];
8468
- a = ((p>>24) & 0xFF);
8469
- r = ((p>>16) & 0xFF);
8470
- g = ((p>>8) & 0xFF);
8471
- b = (p & 0xFF);
8472
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8473
- }
8474
- /**/
8475
- int width = (int)Math.sqrt(pixels.length); // squared
8476
- int height = width;
8477
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8478
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8519
+ BufferedImage rendImage = CreateBim(texturedata);
8520
+
84798521 ImageWriter writer = null;
84808522 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84818523 if (iter.hasNext()) {
84828524 writer = (ImageWriter)iter.next();
84838525 }
8484
- float compressionQuality = 0.9f;
8526
+
8527
+ float compressionQuality = 0.85f;
84858528 try
84868529 {
84878530 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8498,18 +8541,20 @@
84988541 }
84998542 }
85008543 }
8501
-
8544
+
8545
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8546
+
85028547 //System.out.println("Texture = " + tex);
8503
- if (textures.containsKey(texname))
8548
+ if (textures.containsKey(tex))
85048549 {
8505
- CacheTexture thetex = textures.get(texname);
8550
+ CacheTexture thetex = textures.get(tex);
85068551 thetex.texture.disable();
85078552 thetex.texture.dispose();
8508
- textures.remove(texname);
8553
+ textures.remove(tex);
85098554 }
85108555
85118556 //texture.texturedata = texturedata;
8512
- textures.put(texname, texturecache);
8557
+ textures.put(tex, texturecache);
85138558
85148559 // newtex = true;
85158560 }
....@@ -8528,9 +8573,43 @@
85288573 return texturecache;
85298574 }
85308575
8531
- com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8576
+ static void EmbedTextures(cTexture tex)
85328577 {
8533
- CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
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
8611
+ {
8612
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
85348613
85358614 if (bump)
85368615 {
....@@ -8546,14 +8625,14 @@
85468625 return texture!=null?texture.texture:null;
85478626 }
85488627
8549
- public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, 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
85508629 {
8551
- CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
8630
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
85528631
85538632 return texture!=null?texture.texturedata:null;
85548633 }
85558634
8556
- boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8635
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
85578636 {
85588637 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
85598638 {
....@@ -8562,7 +8641,7 @@
85628641
85638642 //boolean newtex = false;
85648643
8565
- com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
8644
+ com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85668645
85678646 if (texture == null)
85688647 return false;
....@@ -8595,6 +8674,72 @@
85958674 return true; // Warning: not used.
85968675 }
85978676
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
+
85988743 ShadowBuffer shadowPBuf;
85998744 AntialiasBuffer antialiasPBuf;
86008745 int MAXSTACK;
....@@ -9555,7 +9700,7 @@
95559700
95569701 if (renderCamera != lightCamera)
95579702 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9703
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
95599704
95609705 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
95619706
....@@ -9571,7 +9716,7 @@
95719716
95729717 if (renderCamera != lightCamera)
95739718 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9719
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
95759720
95769721 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
95779722
....@@ -10772,7 +10917,7 @@
1077210917 // if (parentcam != renderCamera) // not a light
1077310918 if (cam != lightCamera)
1077410919 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10920
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1077610921
1077710922 for (int j = 0; j < 4; j++)
1077810923 {
....@@ -10787,7 +10932,7 @@
1078710932 // if (parentcam != renderCamera) // not a light
1078810933 if (cam != lightCamera)
1078910934 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10935
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1079110936
1079210937 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1079310938
....@@ -11049,7 +11194,7 @@
1104911194
1105011195 try
1105111196 {
11052
- BindTexture(null, NOISE_TEXTURE, false, 2);
11197
+ BindTexture(NOISE_TEXTURE, false, 2);
1105311198 }
1105411199 catch (Exception e)
1105511200 {
....@@ -11340,7 +11485,7 @@
1134011485 }
1134111486 }
1134211487
11343
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11488
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1134411489 {
1134511490 //gl.glDepthFunc(GL.GL_LEQUAL);
1134611491 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11348,24 +11493,21 @@
1134811493
1134911494 boolean texon = textureon;
1135011495
11351
- if (RENDERPROGRAM > 0)
11352
- {
11353
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11354
- textureon = false;
11355
- }
11496
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11497
+ textureon = false;
11498
+
1135611499 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1135711500 //System.out.println("ALLO");
1135811501 gl.glColorMask(false, false, false, false);
1135911502 DrawObject(gl);
11360
- if (RENDERPROGRAM > 0)
11361
- {
11362
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11363
- textureon = texon;
11364
- }
11503
+
11504
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11505
+ textureon = texon;
11506
+
1136511507 gl.glColorMask(true, true, true, true);
1136611508
1136711509 gl.glDepthFunc(GL.GL_EQUAL);
11368
- //gl.glDepthMask(false);
11510
+ gl.glDepthMask(false);
1136911511 }
1137011512
1137111513 if (false) // DrawMode() == SHADOW)
....@@ -11705,20 +11847,32 @@
1170511847 ReleaseTextures(DEFAULT_TEXTURES);
1170611848
1170711849 if (CLEANCACHE)
11708
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11850
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1170911851 {
11710
- String tex = e.nextElement();
11852
+ cTexture tex = e.nextElement();
1171111853
1171211854 // System.out.println("Texture --------- " + tex);
1171311855
11714
- if (tex.equals("WHITE_NOISE"))
11856
+ if (tex.equals("WHITE_NOISE:"))
1171511857 continue;
1171611858
1171711859 if (!usedtextures.contains(tex))
1171811860 {
11861
+ CacheTexture gettex = texturepigment.get(tex);
1171911862 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11720
- textures.get(tex).texture.dispose();
11721
- 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
+ }
1172211876 }
1172311877 }
1172411878 }
....@@ -12247,7 +12401,74 @@
1224712401 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1224812402
1224912403 String program =
12404
+ // Min shader
1225012405 "!!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
+
1225112472 //"OPTION ARB_fragment_program_shadow;" +
1225212473 "PARAM light2cam0 = program.env[10];" +
1225312474 "PARAM light2cam1 = program.env[11];" +
....@@ -12362,8 +12583,7 @@
1236212583 "TEMP shininess;" +
1236312584 "\n" +
1236412585 "MOV texSamp, one;" +
12365
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12366
-
12586
+
1236712587 "MOV mapgrid.x, one2048th.x;" +
1236812588 "MOV temp, fragment.texcoord[1];" +
1236912589 /*
....@@ -12384,20 +12604,20 @@
1238412604 "MUL temp, floor, mapgrid.x;" +
1238512605 //"TEX depth0, temp, texture[1], 2D;" +
1238612606 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12387
- TextureFetch("depth0", "temp", "1") +
12607
+ ShadowTextureFetch("depth0", "temp", "1") +
1238812608 "") +
1238912609 "ADD temp.x, temp.x, mapgrid.x;" +
1239012610 //"TEX depth1, temp, texture[1], 2D;" +
1239112611 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12392
- TextureFetch("depth1", "temp", "1") +
12612
+ ShadowTextureFetch("depth1", "temp", "1") +
1239312613 "") +
1239412614 "ADD temp.y, temp.y, mapgrid.x;" +
1239512615 //"TEX depth2, temp, texture[1], 2D;" +
12396
- TextureFetch("depth2", "temp", "1") +
12616
+ ShadowTextureFetch("depth2", "temp", "1") +
1239712617 "SUB temp.x, temp.x, mapgrid.x;" +
1239812618 //"TEX depth3, temp, texture[1], 2D;" +
1239912619 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12400
- TextureFetch("depth3", "temp", "1") +
12620
+ ShadowTextureFetch("depth3", "temp", "1") +
1240112621 "") +
1240212622 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1240312623 //"MOV params, material;" +
....@@ -12768,7 +12988,7 @@
1276812988 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1276912989 "") +
1277012990
12771
- // display shadow only (bump == 0)
12991
+ // display shadow only (fakedepth == 0)
1277212992 "SUB temp.x, half.x, shadow.x;" +
1277312993 "MOV temp.y, -params5.z;" + // params6.x;" +
1277412994 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13195,25 +13415,26 @@
1319513415 return out;
1319613416 }
1319713417
13198
- String TextureFetch(String dest, String src, String unit)
13418
+ // Also does frustum culling
13419
+ String ShadowTextureFetch(String dest, String src, String unit)
1319913420 {
1320013421 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1320113422 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1320213423 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13424
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13425
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1320313426 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13204
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13205
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13206
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13207
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13427
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13428
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1320813429 //"SWZ buffer, temp, w,w,w,w;";
13209
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13430
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1321013431 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1321113432 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1321213433 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13213
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13434
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1321413435
13215
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13216
- //"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;";
1321713438 }
1321813439
1321913440 String Shadow(String depth, String shadow)
....@@ -13260,7 +13481,7 @@
1326013481 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1326113482 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1326213483
13263
- // No shadow when out of frustrum
13484
+ // No shadow when out of frustum
1326413485 "SGE temp.x, " + depth + ".z, one.z;" +
1326513486 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1326613487 "";
....@@ -14058,14 +14279,15 @@
1405814279 drag = false;
1405914280 //System.out.println("Mouse DOWN");
1406014281 editObj = false;
14061
- ClickInfo info = new ClickInfo();
14062
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14063
- info.pane = this;
14064
- info.camera = renderCamera;
14065
- info.x = x;
14066
- info.y = y;
14067
- info.modifiers = modifiersex;
14068
- 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);
1406914291 if (!editObj)
1407014292 {
1407114293 hasMarquee = true;
....@@ -14465,15 +14687,16 @@
1446514687 if (editObj)
1446614688 {
1446714689 drag = true;
14468
- ClickInfo info = new ClickInfo();
14469
- info.bounds.setBounds(0, 0,
14690
+ //ClickInfo info = new ClickInfo();
14691
+ object.clickInfo.bounds.setBounds(0, 0,
1447014692 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14471
- info.pane = this;
14472
- info.camera = renderCamera;
14473
- info.x = x;
14474
- info.y = y;
14475
- object.GetWindow().copy
14476
- .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);
1447714700 } else
1447814701 {
1447914702 if (x < startX)
....@@ -14622,24 +14845,27 @@
1462214845 }
1462314846 }
1462414847
14848
+// ClickInfo clickInfo = new ClickInfo();
14849
+
1462514850 public void mouseMoved(MouseEvent e)
1462614851 {
1462714852 //System.out.println("mouseMoved: " + e);
1462814853 if (isRenderer)
1462914854 return;
1463014855
14631
- ClickInfo ci = new ClickInfo();
14632
- ci.x = e.getX();
14633
- ci.y = e.getY();
14634
- ci.modifiers = e.getModifiersEx();
14635
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14636
- ci.pane = this;
14637
- 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;
1463814863 if (!isRenderer)
1463914864 {
1464014865 //ObjEditor editWindow = object.editWindow;
1464114866 //Object3D copy = editWindow.copy;
14642
- if (object.doEditClick(ci, 0))
14867
+ if (object.doEditClick(//clickInfo,
14868
+ 0))
1464314869 {
1464414870 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1464514871 } else
....@@ -14911,7 +15137,8 @@
1491115137 // break;
1491215138 case 'T':
1491315139 CACHETEXTURE ^= true;
14914
- textures.clear();
15140
+ texturepigment.clear();
15141
+ texturebump.clear();
1491515142 // repaint();
1491615143 break;
1491715144 case 'Y':
....@@ -15664,8 +15891,6 @@
1566415891
1566515892 int width = getBounds().width;
1566615893 int height = getBounds().height;
15667
- ClickInfo info = new ClickInfo();
15668
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1566915894 //Image img = CreateImage(width, height);
1567015895 //System.out.println("width = " + width + "; height = " + height + "\n");
1567115896
....@@ -15742,31 +15967,37 @@
1574215967 }
1574315968 if (object != null && !hasMarquee)
1574415969 {
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
+
1574515976 if (isRenderer)
1574615977 {
15747
- info.flags++;
15978
+ object.clickInfo.flags++;
1574815979 double frameAspect = (double) width / (double) height;
1574915980 if (frameAspect > renderCamera.aspect)
1575015981 {
1575115982 int desired = (int) ((double) height * renderCamera.aspect);
15752
- info.bounds.width -= width - desired;
15753
- info.bounds.x += (width - desired) / 2;
15983
+ object.clickInfo.bounds.width -= width - desired;
15984
+ object.clickInfo.bounds.x += (width - desired) / 2;
1575415985 } else
1575515986 {
1575615987 int desired = (int) ((double) width / renderCamera.aspect);
15757
- info.bounds.height -= height - desired;
15758
- info.bounds.y += (height - desired) / 2;
15988
+ object.clickInfo.bounds.height -= height - desired;
15989
+ object.clickInfo.bounds.y += (height - desired) / 2;
1575915990 }
1576015991 }
1576115992
15762
- info.g = gr;
15763
- info.camera = renderCamera;
15993
+ object.clickInfo.g = gr;
15994
+ object.clickInfo.camera = renderCamera;
1576415995 /*
1576515996 // Memory intensive (brep.verticescopy)
1576615997 if (!(object instanceof Composite))
1576715998 object.draw(info, 0, false); // SLOW :
1576815999 */
15769
- if (!isRenderer)
16000
+ if (!isRenderer) // && drag)
1577016001 {
1577116002 Grafreed.Assert(object != null);
1577216003 Grafreed.Assert(object.selection != null);
....@@ -15774,9 +16005,9 @@
1577416005 {
1577516006 int hitSomething = object.selection.get(0).hitSomething;
1577616007
15777
- info.DX = 0;
15778
- info.DY = 0;
15779
- info.W = 1;
16008
+ object.clickInfo.DX = 0;
16009
+ object.clickInfo.DY = 0;
16010
+ object.clickInfo.W = 1;
1578016011 if (hitSomething == Object3D.hitCenter)
1578116012 {
1578216013 info.DX = X;
....@@ -15788,7 +16019,8 @@
1578816019 info.DY -= info.bounds.height/2;
1578916020 }
1579016021
15791
- object.drawEditHandles(info, 0);
16022
+ object.drawEditHandles(//info,
16023
+ 0);
1579216024
1579316025 if (drag && (X != 0 || Y != 0))
1579416026 {
....@@ -15801,7 +16033,7 @@
1580116033 gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
1580216034 break;
1580316035 case Object3D.hitScale: gr.setColor(Color.cyan);
15804
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16036
+ gr.drawLine(X, Y, 0, 0);
1580516037 break;
1580616038 }
1580716039