Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
Raw embed texture (too big).
6 files modified
328 ■■■■■ changed files
CameraPane.java 266 ●●●●● patch | view | raw | blame | history
GroupEditor.java 34 ●●●●● patch | view | raw | blame | history
ObjEditor.java 1 ●●●● patch | view | raw | blame | history
Object3D.java 17 ●●●● patch | view | raw | blame | history
cTexture.java 8 ●●●● patch | view | raw | blame | history
iCameraPane.java 2 ●●● patch | view | raw | blame | history
CameraPane.java
....@@ -45,6 +45,39 @@
4545
4646 static int STEP = 1;
4747
48
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
49
+ {
50
+ int[] pixels = new int[bytes.length/3];
51
+ for (int i=pixels.length; --i>=0;)
52
+ {
53
+ int i3 = i*3;
54
+ pixels[i] = 0xFF;
55
+ pixels[i] <<= 8;
56
+ pixels[i] |= bytes[i3+2] & 0xFF;
57
+ pixels[i] <<= 8;
58
+ pixels[i] |= bytes[i3+1] & 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3] & 0xFF;
61
+ }
62
+ /*
63
+ int r=0,g=0,b=0,a=0;
64
+ for (int i=0; i<width; i++)
65
+ for (int j=0; j<height; j++)
66
+ {
67
+ int index = j*width+i;
68
+ int p = pixels[index];
69
+ a = ((p>>24) & 0xFF);
70
+ r = ((p>>16) & 0xFF);
71
+ g = ((p>>8) & 0xFF);
72
+ b = (p & 0xFF);
73
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
74
+ }
75
+ /**/
76
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
77
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
78
+ return rendImage;
79
+ }
80
+
4881 /*static*/ private boolean CULLFACE = false; // true;
4982 /*static*/ boolean NEAREST = false; // true;
5083 /*static*/ boolean WIREFRAME = false; // true;
....@@ -2405,43 +2438,19 @@
24052438 return currentGL;
24062439 }
24072440
2408
- private BufferedImage CreateBim(TextureData texturedata)
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
24092442 {
2410
- // cache to disk
2411
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
2412
- //buffers[0].
2413
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
2414
- int[] pixels = new int[bytebuf.capacity()/3];
2415
- int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared
2416
- int height = width;
2417
- for (int i=pixels.length; --i>=0;)
2418
- {
2419
- int i3 = i*3;
2420
- pixels[i] = 0xFF;
2421
- pixels[i] <<= 8;
2422
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
2423
- pixels[i] <<= 8;
2424
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
2425
- pixels[i] <<= 8;
2426
- pixels[i] |= bytebuf.get(i3) & 0xFF;
2427
- }
2428
- /*
2429
- int r=0,g=0,b=0,a=0;
2430
- for (int i=0; i<width; i++)
2431
- for (int j=0; j<height; j++)
2432
- {
2433
- int index = j*width+i;
2434
- int p = pixels[index];
2435
- a = ((p>>24) & 0xFF);
2436
- r = ((p>>16) & 0xFF);
2437
- g = ((p>>8) & 0xFF);
2438
- b = (p & 0xFF);
2439
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
2440
- }
2441
- /**/
2442
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
2443
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
2444
- return rendImage;
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
24452454 }
24462455
24472456 /**/
....@@ -2452,18 +2461,20 @@
24522461
24532462 int resolution;
24542463
2455
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
24562465 {
2457
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
24582468 resolution = res;
24592469 }
24602470 }
24612471 /**/
24622472
24632473 // TEXTURE static Texture texture;
2464
- static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2465
- static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2466
- static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2474
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2475
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2476
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2477
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
24672478
24682479 int pigmentdepth = 0;
24692480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
....@@ -2471,10 +2482,10 @@
24712482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24722483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24732484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2474
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24752486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24762487
2477
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24782489 {
24792490 TextureData texturedata = null;
24802491
....@@ -2493,16 +2504,16 @@
24932504 if (bump)
24942505 texturedata = ConvertBump(texturedata, false);
24952506
2496
- com.sun.opengl.util.texture.Texture texture =
2497
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2507
+// com.sun.opengl.util.texture.Texture texture =
2508
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24982509
2499
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2500
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2510
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2511
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
25012512
2502
- return texture;
2513
+ return texturedata;
25032514 }
25042515
2505
- com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
25062517 {
25072518 TextureData texturedata = null;
25082519
....@@ -2510,7 +2521,7 @@
25102521 {
25112522 texturedata =
25122523 com.sun.opengl.util.texture.TextureIO.newTextureData(
2513
- name,
2524
+ bim,
25142525 true);
25152526 } catch (Exception e)
25162527 {
....@@ -2519,14 +2530,8 @@
25192530
25202531 if (bump)
25212532 texturedata = ConvertBump(texturedata, false);
2522
-
2523
- com.sun.opengl.util.texture.Texture texture =
2524
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2525
-
2526
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2527
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2528
-
2529
- return texture;
2533
+
2534
+ return texturedata;
25302535 }
25312536
25322537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -8014,8 +8019,8 @@
80148019 pigment = null;
80158020 }
80168021
8017
- ReleaseTexture(bump, true);
8018
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
80198024 }
80208025
80218026 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -8044,7 +8049,7 @@
80448049 pigment = null;
80458050 }
80468051
8047
- ReleaseTexture(pigment, false);
8052
+ ReleaseTexture(tex, false);
80488053 }
80498054
80508055 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8073,10 +8078,10 @@
80738078 bump = null;
80748079 }
80758080
8076
- ReleaseTexture(bump, true);
8081
+ ReleaseTexture(tex, true);
80778082 }
80788083
8079
- void ReleaseTexture(String tex, boolean bump)
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
80808085 {
80818086 if (// DrawMode() != 0 || /*tex == null ||*/
80828087 ambientOcclusion ) // || !textureon)
....@@ -8087,7 +8092,7 @@
80878092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80888093
80898094 if (tex != null)
8090
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80918096
80928097 // //assert( texture != null );
80938098 // if (texture == null)
....@@ -8237,13 +8242,13 @@
82378242
82388243 if (tex == null)
82398244 {
8240
- BindTexture(null, null,false,resolution);
8245
+ BindTexture(null,false,resolution);
82418246 return;
82428247 }
82438248
82448249 String pigment = Object3D.GetPigment(tex);
82458250
8246
- usedtextures.add(pigment);
8251
+ usedtextures.add(tex);
82478252
82488253 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82498254 {
....@@ -8257,7 +8262,7 @@
82578262 }
82588263
82598264 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8260
- BindTexture(tex.pigmenttexture, pigment, false, resolution);
8265
+ BindTexture(tex, false, resolution);
82618266 }
82628267
82638268 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8270,13 +8275,13 @@
82708275
82718276 if (tex == null)
82728277 {
8273
- BindTexture(null, null,true,resolution);
8278
+ BindTexture(null,true,resolution);
82748279 return;
82758280 }
82768281
82778282 String bump = Object3D.GetBump(tex);
82788283
8279
- usedtextures.add(bump);
8284
+ usedtextures.add(tex);
82808285
82818286 //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82828287 {
....@@ -8290,7 +8295,7 @@
82908295 }
82918296
82928297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8293
- BindTexture(tex.bumptexture, bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
82948299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82958300 }
82968301
....@@ -8314,13 +8319,19 @@
83148319 return fileExists;
83158320 }
83168321
8317
- CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
83188323 {
83198324 CacheTexture texturecache = null;
83208325
83218326 if (tex != null)
83228327 {
8323
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8330
+
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
83248335
83258336 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
83268337
....@@ -8330,29 +8341,34 @@
83308341 // else
83318342 // if (!texname.startsWith("/"))
83328343 // texname = "/Users/nbriere/Textures/" + texname;
8333
- if (!FileExists(tex))
8344
+ if (!FileExists(texname))
83348345 {
83358346 texname = fallbackTextureName;
83368347 }
83378348
83388349 if (CACHETEXTURE)
83398350 {
8340
- if (bim == null)
8341
- texturecache = textures.get(texname); // TEXTURE CACHE
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
83428353 else
8343
- texturecache = bimtextures.get(bim); // TEXTURE CACHE
8354
+ texturecache = bimtextures.get(texdata);
83448355 }
83458356
8346
- if (texturecache == null || texturecache.resolution < resolution)
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
83478358 {
83488359 TextureData texturedata = null;
83498360
8350
- if (bim != null)
8361
+ if (texdata != null)
83518362 {
8363
+ BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8364
+
8365
+ CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8366
+
83528367 texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
83538369 }
83548370 else
8355
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
83568372 {
83578373 assert(!bump);
83588374 // if (bump)
....@@ -8363,7 +8379,7 @@
83638379 // }
83648380 // else
83658381 // {
8366
- texturecache = textures.get(tex);
8382
+ // texturecache = textures.get(texname); // suspicious
83678383 if (texturecache == null)
83688384 {
83698385 texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
....@@ -8372,10 +8388,10 @@
83728388 new Exception().printStackTrace();
83738389 // }
83748390 } else
8375
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
83768392 {
83778393 assert(bump);
8378
- texturecache = textures.get(tex);
8394
+ // texturecache = textures.get(texname); // suspicious
83798395 if (texturecache == null)
83808396 texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
83818397 else
....@@ -8387,9 +8403,9 @@
83878403 // texture = GetResourceTexture("default.png");
83888404 //} else
83898405 //{
8390
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
83918407 {
8392
- texturecache = textures.get(tex);
8408
+ // texturecache = textures.get(texname); // suspicious
83938409 if (texturecache == null)
83948410 texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
83958411 else
....@@ -8452,17 +8468,16 @@
84528468 if (texturedata == null)
84538469 throw new Exception();
84548470
8455
- texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8471
+ texturecache = new CacheTexture(texturedata,resolution);
84568472 //texture = GetTexture(tex, bump);
84578473 }
84588474 }
84598475 //}
84608476 }
84618477
8462
- if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
84638479 {
84648480 //return false;
8465
- assert(bim == null);
84668481
84678482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
84688483 if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
....@@ -8509,18 +8524,20 @@
85098524 }
85108525 }
85118526 }
8512
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
85138530 //System.out.println("Texture = " + tex);
8514
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
85158532 {
8516
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
85178534 thetex.texture.disable();
85188535 thetex.texture.dispose();
8519
- textures.remove(texname);
8536
+ textures.remove(tex);
85208537 }
85218538
85228539 //texture.texturedata = texturedata;
8523
- textures.put(texname, texturecache);
8540
+ textures.put(tex, texturecache);
85248541
85258542 // newtex = true;
85268543 }
....@@ -8541,12 +8558,38 @@
85418558
85428559 static void EmbedTextures(cTexture tex)
85438560 {
8561
+ if (tex.pigmentdata == null)
8562
+ {
8563
+ String texname = Object3D.GetPigment(tex);
8564
+
8565
+ CacheTexture texturecache = texturepigment.get(tex);
8566
+
8567
+ if (texturecache != null)
8568
+ {
8569
+ tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8570
+ tex.pw = texturecache.texturedata.getWidth();
8571
+ tex.ph = texturecache.texturedata.getHeight();
8572
+ }
8573
+ }
85448574
8575
+ if (tex.bumpdata == null)
8576
+ {
8577
+ String texname = Object3D.GetBump(tex);
8578
+
8579
+ CacheTexture texturecache = texturebump.get(tex);
8580
+
8581
+ if (texturecache != null)
8582
+ {
8583
+ tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8584
+ tex.bw = texturecache.texturedata.getWidth();
8585
+ tex.bh = texturecache.texturedata.getHeight();
8586
+ }
8587
+ }
85458588 }
85468589
8547
- com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
85488591 {
8549
- CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
8592
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
85508593
85518594 if (bump)
85528595 {
....@@ -8562,14 +8605,14 @@
85628605 return texture!=null?texture.texture:null;
85638606 }
85648607
8565
- public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
85668609 {
8567
- CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
8610
+ CacheTexture texture = GetCacheTexture(tex, bump, resolution);
85688611
85698612 return texture!=null?texture.texturedata:null;
85708613 }
85718614
8572
- boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
85738616 {
85748617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
85758618 {
....@@ -8578,7 +8621,7 @@
85788621
85798622 //boolean newtex = false;
85808623
8581
- com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
8624
+ com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85828625
85838626 if (texture == null)
85848627 return false;
....@@ -11065,7 +11108,7 @@
1106511108
1106611109 try
1106711110 {
11068
- BindTexture(null, NOISE_TEXTURE, false, 2);
11111
+ BindTexture(NOISE_TEXTURE, false, 2);
1106911112 }
1107011113 catch (Exception e)
1107111114 {
....@@ -11721,20 +11764,32 @@
1172111764 ReleaseTextures(DEFAULT_TEXTURES);
1172211765
1172311766 if (CLEANCACHE)
11724
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1172511768 {
11726
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1172711770
1172811771 // System.out.println("Texture --------- " + tex);
1172911772
11730
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1173111774 continue;
1173211775
1173311776 if (!usedtextures.contains(tex))
1173411777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1173511779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11736
- textures.get(tex).texture.dispose();
11737
- textures.remove(tex);
11780
+ if (gettex != null)
11781
+ {
11782
+ gettex.texture.dispose();
11783
+ texturepigment.remove(tex);
11784
+ }
11785
+
11786
+ gettex = texturebump.get(tex);
11787
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11788
+ if (gettex != null)
11789
+ {
11790
+ gettex.texture.dispose();
11791
+ texturebump.remove(tex);
11792
+ }
1173811793 }
1173911794 }
1174011795 }
....@@ -14927,7 +14982,8 @@
1492714982 // break;
1492814983 case 'T':
1492914984 CACHETEXTURE ^= true;
14930
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1493114987 // repaint();
1493214988 break;
1493314989 case 'Y':
GroupEditor.java
....@@ -528,10 +528,15 @@
528528 attachBumpItem.addActionListener(this);
529529 pigmentBumpItem = menu.add(new MenuItem("Pigment -> Bump"));
530530 pigmentBumpItem.addActionListener(this);
531
+ //embedTexturesItem
531532 detachPigmentItem = menu.add(new MenuItem("Detach Pigment"));
532533 detachPigmentItem.addActionListener(this);
533534 detachBumpItem = menu.add(new MenuItem("Detach Bump"));
534535 detachBumpItem.addActionListener(this);
536
+ embedTexturesItem = menu.add(new MenuItem("Embed Textures"));
537
+ embedTexturesItem.addActionListener(this);
538
+ deEmbedTexturesItem = menu.add(new MenuItem("De-embed Textures"));
539
+ deEmbedTexturesItem.addActionListener(this);
535540 menu.add("-");
536541 sortbysizeItem = menu.add(new MenuItem("Sort by size"));
537542 sortbysizeItem.addActionListener(this);
....@@ -3169,6 +3174,31 @@
31693174
31703175 refreshContents();
31713176 } else
3177
+ if (source == embedTexturesItem)
3178
+ {
3179
+ Object3D obj;
3180
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3181
+ {
3182
+ obj = (Object3D)e.nextElement();
3183
+ obj.EmbedTextures(true);
3184
+ }
3185
+
3186
+ refreshContents();
3187
+ } else
3188
+ if (source == deEmbedTexturesItem)
3189
+ {
3190
+ Object3D obj;
3191
+ for (Enumeration e = group.selection.elements(); e.hasMoreElements();)
3192
+ {
3193
+ obj = (Object3D)e.nextElement();
3194
+ obj.EmbedTextures(false);
3195
+ }
3196
+
3197
+ CameraPane.texturepigment.clear();
3198
+ CameraPane.texturebump.clear();
3199
+
3200
+ refreshContents();
3201
+ } else
31723202 if (source == flashSelectionButton)
31733203 {
31743204 CameraPane.flash = true;
....@@ -4163,7 +4193,7 @@
41634193
41644194 try
41654195 {
4166
- texturedata = Globals.theRenderer.GetTextureData(tex.pigmenttexture, pigment, false, node.texres);
4196
+ texturedata = Globals.theRenderer.GetTextureData(tex, false, node.texres);
41674197 }
41684198 catch (Exception e)
41694199 {
....@@ -5793,6 +5823,8 @@
57935823 private MenuItem attachBumpItem;
57945824 private MenuItem detachBumpItem;
57955825 private MenuItem pigmentBumpItem;
5826
+ private MenuItem embedTexturesItem;
5827
+ private MenuItem deEmbedTexturesItem;
57965828
57975829 private MenuItem particleItem;
57985830 private MenuItem ragdollItem;
ObjEditor.java
....@@ -5019,6 +5019,7 @@
50195019 //ps.print(buffer.toString());
50205020 } catch (IOException e)
50215021 {
5022
+ e.printStackTrace();
50225023 }
50235024 }
50245025
Object3D.java
....@@ -5775,12 +5775,23 @@
57755775 }
57765776 }
57775777
5778
- void EmbedTextures()
5778
+ void EmbedTextures(boolean embed)
57795779 {
57805780 if (blockloop)
57815781 return;
57825782
5783
- CameraPane.EmbedTextures(texture);
5783
+ //if (GetTextures() != null)
5784
+ if (embed)
5785
+ CameraPane.EmbedTextures(GetTextures());
5786
+ else
5787
+ {
5788
+ GetTextures().pigmentdata = null;
5789
+ GetTextures().bumpdata = null;
5790
+ GetTextures().pw = 0;
5791
+ GetTextures().ph = 0;
5792
+ GetTextures().bw = 0;
5793
+ GetTextures().bh = 0;
5794
+ }
57845795
57855796 int nb = Size();
57865797 for (int i = 0; i < nb; i++)
....@@ -5791,7 +5802,7 @@
57915802 continue;
57925803
57935804 blockloop = true;
5794
- child.EmbedTextures();
5805
+ child.EmbedTextures(embed);
57955806 blockloop = false;
57965807 }
57975808 }
cTexture.java
....@@ -31,6 +31,10 @@
3131 }
3232
3333 String name;
34
- BufferedImage pigmenttexture;
35
- BufferedImage bumptexture;
34
+
35
+ int pw, ph;
36
+ byte[] pigmentdata;
37
+
38
+ int bw, bh;
39
+ byte[] bumpdata;
3640 }
iCameraPane.java
....@@ -86,7 +86,7 @@
8686
8787 void setCursor(java.awt.Cursor cursor);
8888
89
- com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception;
89
+ com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception;
9090
9191 void repaint();
9292