Normand Briere
2019-07-23 de4f66e0239a736bce24e09c9a0b49b5bb92d84b
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 {
....@@ -37,7 +41,6 @@
3741 static boolean[] selectedstack = new boolean[65536];
3842 static int materialdepth = 0;
3943
40
- static boolean DEBUG = false;
4144 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4245
4346 // camera change fix
....@@ -45,6 +48,39 @@
4548 static boolean ABORTED = false;
4649
4750 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
+ }
4884
4985 /*static*/ private boolean CULLFACE = false; // true;
5086 /*static*/ boolean NEAREST = false; // true;
....@@ -61,7 +97,7 @@
6197 //boolean REDUCETEXTURE = true;
6298 boolean CACHETEXTURE = true;
6399 boolean CLEANCACHE = false; // true;
64
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
65101 boolean COMPRESSTEXTURE = false;
66102 boolean KOMPACTTEXTURE = false; // true;
67103 boolean RESIZETEXTURE = false;
....@@ -327,7 +363,7 @@
327363 cStatic.objectstack[materialdepth++] = obj;
328364 //System.out.println("material " + material);
329365 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
366
+ //display.vector2buffer = obj.projectedVertices;
331367 if (obj instanceof Camera)
332368 {
333369 display.options1[0] = material.shift;
....@@ -336,14 +372,28 @@
336372 display.options1[2] = material.shadowbias;
337373 display.options1[3] = material.aniso;
338374 display.options1[4] = material.anisoV;
375
+// System.out.println("display.options1[0] " + display.options1[0]);
376
+// System.out.println("display.options1[1] " + display.options1[1]);
377
+// System.out.println("display.options1[2] " + display.options1[2]);
378
+// System.out.println("display.options1[3] " + display.options1[3]);
379
+// System.out.println("display.options1[4] " + display.options1[4]);
339380 display.options2[0] = material.opacity;
340381 display.options2[1] = material.diffuse;
341382 display.options2[2] = material.factor;
383
+// System.out.println("display.options2[0] " + display.options2[0]);
384
+// System.out.println("display.options2[1] " + display.options2[1]);
385
+// System.out.println("display.options2[2] " + display.options2[2]);
342386
343387 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
388
+// System.out.println("display.options3[0] " + display.options3[0]);
389
+// System.out.println("display.options3[1] " + display.options3[1]);
390
+// System.out.println("display.options3[2] " + display.options3[2]);
344391 display.options4[0] = material.cameralight/0.2f;
345392 display.options4[1] = material.subsurface;
346393 display.options4[2] = material.sheen;
394
+// System.out.println("display.options4[0] " + display.options4[0]);
395
+// System.out.println("display.options4[1] " + display.options4[1]);
396
+// System.out.println("display.options4[2] " + display.options4[2]);
347397
348398 // if (display.CURRENTANTIALIAS > 0)
349399 // display.options3[3] /= 4;
....@@ -359,7 +409,7 @@
359409 /**/
360410 } else
361411 {
362
- DrawMaterial(material, selected);
412
+ DrawMaterial(material, selected, obj.projectedVertices);
363413 }
364414 } else
365415 {
....@@ -383,8 +433,8 @@
383433 cStatic.objectstack[materialdepth++] = obj;
384434 //System.out.println("material " + material);
385435 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
436
+ //display.vector2buffer = obj.projectedVertices;
437
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388438 }
389439 }
390440
....@@ -401,8 +451,8 @@
401451 materialdepth -= 1;
402452 if (materialdepth > 0)
403453 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
454
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
455
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406456 }
407457 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408458 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +472,8 @@
422472 materialdepth -= 1;
423473 if (materialdepth > 0)
424474 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
475
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
476
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427477 }
428478 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429479 //else
....@@ -1611,7 +1661,7 @@
16111661 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16121662 }
16131663
1614
- void DrawMaterial(cMaterial material, boolean selected)
1664
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16151665 {
16161666 CameraPane display = this;
16171667 //new Exception().printStackTrace();
....@@ -1646,7 +1696,7 @@
16461696 colorV[0] = display.modelParams0[0] * material.diffuse;
16471697 colorV[1] = display.modelParams0[1] * material.diffuse;
16481698 colorV[2] = display.modelParams0[2] * material.diffuse;
1649
- colorV[3] = material.opacity;
1699
+ colorV[3] = 1; // material.opacity;
16501700
16511701 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16521702 //System.out.println("Opacity = " + opacity);
....@@ -1754,9 +1804,9 @@
17541804 display.modelParams7[2] = 0;
17551805 display.modelParams7[3] = 0;
17561806
1757
- display.modelParams6[0] = 100; // criss de bug de bump
1807
+ //display.modelParams6[0] = 100; // criss de bug de bump
17581808
1759
- Object3D.cVector2[] extparams = display.vector2buffer;
1809
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17601810 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17611811 {
17621812 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -2052,7 +2102,7 @@
20522102 //System.err.println("Oeil on");
20532103 OEIL = true;
20542104 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2055
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2105
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20562106 //pingthread.StepToTarget(true);
20572107 }
20582108
....@@ -2267,7 +2317,7 @@
22672317
22682318 void ToggleDebug()
22692319 {
2270
- DEBUG ^= true;
2320
+ Globals.DEBUG ^= true;
22712321 }
22722322
22732323 void ToggleLookAt()
....@@ -2285,10 +2335,17 @@
22852335 HANDLES ^= true;
22862336 }
22872337
2338
+ Object3D paintFolder;
2339
+
22882340 void TogglePaint()
22892341 {
22902342 PAINTMODE ^= true;
22912343 paintcount = 0;
2344
+
2345
+ if (PAINTMODE)
2346
+ {
2347
+ paintFolder = GetFolder();
2348
+ }
22922349 }
22932350
22942351 void SwapCamera(int a, int b)
....@@ -2385,6 +2442,21 @@
23852442 return currentGL;
23862443 }
23872444
2445
+ static private BufferedImage CreateBim(TextureData texturedata)
2446
+ {
2447
+ Grafreed.Assert(texturedata != null);
2448
+
2449
+ int width = texturedata.getWidth();
2450
+ int height = texturedata.getHeight();
2451
+
2452
+ Buffer buffer = texturedata.getBuffer();
2453
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2454
+
2455
+ byte[] bytes = bytebuf.array();
2456
+
2457
+ return CreateBim(bytes, width, height);
2458
+ }
2459
+
23882460 /**/
23892461 class CacheTexture
23902462 {
....@@ -2393,28 +2465,31 @@
23932465
23942466 int resolution;
23952467
2396
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2468
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23972469 {
2398
- texture = tex;
2470
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2471
+ texturedata = texdata;
23992472 resolution = res;
24002473 }
24012474 }
24022475 /**/
24032476
24042477 // TEXTURE static Texture texture;
2405
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2406
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2407
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2478
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2481
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2482
+
24082483 int pigmentdepth = 0;
24092484 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24102485 int bumpdepth = 0;
24112486 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24122487 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24132488 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2414
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2489
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24152490 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24162491
2417
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2492
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24182493 {
24192494 TextureData texturedata = null;
24202495
....@@ -2433,13 +2508,34 @@
24332508 if (bump)
24342509 texturedata = ConvertBump(texturedata, false);
24352510
2436
- com.sun.opengl.util.texture.Texture texture =
2437
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2511
+// com.sun.opengl.util.texture.Texture texture =
2512
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24382513
2439
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2440
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2514
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24412516
2442
- return texture;
2517
+ return texturedata;
2518
+ }
2519
+
2520
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2521
+ {
2522
+ TextureData texturedata = null;
2523
+
2524
+ try
2525
+ {
2526
+ texturedata =
2527
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2528
+ bim,
2529
+ true);
2530
+ } catch (Exception e)
2531
+ {
2532
+ throw new javax.media.opengl.GLException(e);
2533
+ }
2534
+
2535
+ if (bump)
2536
+ texturedata = ConvertBump(texturedata, false);
2537
+
2538
+ return texturedata;
24432539 }
24442540
24452541 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3512,6 +3608,8 @@
35123608
35133609 System.out.println("LOADING TEXTURE : " + name);
35143610
3611
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3612
+
35153613 //
35163614 if (false) // compressbit > 0)
35173615 {
....@@ -7910,7 +8008,7 @@
79108008 String pigment = Object3D.GetPigment(tex);
79118009 String bump = Object3D.GetBump(tex);
79128010
7913
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8011
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79148012 {
79158013 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79168014 // System.out.println("; bump = " + bump);
....@@ -7925,8 +8023,8 @@
79258023 pigment = null;
79268024 }
79278025
7928
- ReleaseTexture(bump, true);
7929
- ReleaseTexture(pigment, false);
8026
+ ReleaseTexture(tex, true);
8027
+ ReleaseTexture(tex, false);
79308028 }
79318029
79328030 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -7944,7 +8042,7 @@
79448042
79458043 String pigment = Object3D.GetPigment(tex);
79468044
7947
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8045
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79488046 {
79498047 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79508048 // System.out.println("; bump = " + bump);
....@@ -7955,7 +8053,7 @@
79558053 pigment = null;
79568054 }
79578055
7958
- ReleaseTexture(pigment, false);
8056
+ ReleaseTexture(tex, false);
79598057 }
79608058
79618059 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -7973,7 +8071,7 @@
79738071
79748072 String bump = Object3D.GetBump(tex);
79758073
7976
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8074
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79778075 {
79788076 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79798077 // System.out.println("; bump = " + bump);
....@@ -7984,10 +8082,10 @@
79848082 bump = null;
79858083 }
79868084
7987
- ReleaseTexture(bump, true);
8085
+ ReleaseTexture(tex, true);
79888086 }
79898087
7990
- void ReleaseTexture(String tex, boolean bump)
8088
+ void ReleaseTexture(cTexture tex, boolean bump)
79918089 {
79928090 if (// DrawMode() != 0 || /*tex == null ||*/
79938091 ambientOcclusion ) // || !textureon)
....@@ -7998,7 +8096,7 @@
79988096 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79998097
80008098 if (tex != null)
8001
- texture = textures.get(tex);
8099
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80028100
80038101 // //assert( texture != null );
80048102 // if (texture == null)
....@@ -8092,47 +8190,50 @@
80928190
80938191 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80948192 {
8095
- if (// DrawMode() != 0 || /*tex == null ||*/
8096
- ambientOcclusion ) // || !textureon)
8097
- {
8098
- return; // false;
8099
- }
8100
-
8101
- if (tex == null)
8102
- {
8103
- BindTexture(null,false,resolution);
8104
- BindTexture(null,true,resolution);
8105
- return;
8106
- }
8193
+// if (// DrawMode() != 0 || /*tex == null ||*/
8194
+// ambientOcclusion ) // || !textureon)
8195
+// {
8196
+// return; // false;
8197
+// }
8198
+//
8199
+// if (tex == null)
8200
+// {
8201
+// BindTexture(null,false,resolution);
8202
+// BindTexture(null,true,resolution);
8203
+// return;
8204
+// }
8205
+//
8206
+// String pigment = Object3D.GetPigment(tex);
8207
+// String bump = Object3D.GetBump(tex);
8208
+//
8209
+// usedtextures.add(pigment);
8210
+// usedtextures.add(bump);
8211
+//
8212
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8213
+// {
8214
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8215
+// // System.out.println("; bump = " + bump);
8216
+// }
8217
+//
8218
+// if (bump.equals(""))
8219
+// {
8220
+// bump = null;
8221
+// }
8222
+// if (pigment.equals(""))
8223
+// {
8224
+// pigment = null;
8225
+// }
8226
+//
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+// BindTexture(pigment, false, resolution);
8229
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8230
+// BindTexture(bump, true, resolution);
8231
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8232
+//
8233
+// return; // true;
81078234
8108
- String pigment = Object3D.GetPigment(tex);
8109
- String bump = Object3D.GetBump(tex);
8110
-
8111
- usedtextures.put(pigment, pigment);
8112
- usedtextures.put(bump, bump);
8113
-
8114
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8115
- {
8116
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8117
- // System.out.println("; bump = " + bump);
8118
- }
8119
-
8120
- if (bump.equals(""))
8121
- {
8122
- bump = null;
8123
- }
8124
- if (pigment.equals(""))
8125
- {
8126
- pigment = null;
8127
- }
8128
-
8129
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8130
- BindTexture(pigment, false, resolution);
8131
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8132
- BindTexture(bump, true, resolution);
8133
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8134
-
8135
- return; // true;
8235
+ BindPigmentTexture(tex, resolution);
8236
+ BindBumpTexture(tex, resolution);
81368237 }
81378238
81388239 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8151,9 +8252,9 @@
81518252
81528253 String pigment = Object3D.GetPigment(tex);
81538254
8154
- usedtextures.put(pigment, pigment);
8255
+ usedtextures.add(tex);
81558256
8156
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8257
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81578258 {
81588259 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81598260 // System.out.println("; bump = " + bump);
....@@ -8165,7 +8266,7 @@
81658266 }
81668267
81678268 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
- BindTexture(pigment, false, resolution);
8269
+ BindTexture(tex, false, resolution);
81698270 }
81708271
81718272 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8184,9 +8285,9 @@
81848285
81858286 String bump = Object3D.GetBump(tex);
81868287
8187
- usedtextures.put(bump, bump);
8288
+ usedtextures.add(tex);
81888289
8189
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8290
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81908291 {
81918292 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81928293 // System.out.println("; bump = " + bump);
....@@ -8198,7 +8299,7 @@
81988299 }
81998300
82008301 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
- BindTexture(bump, true, resolution);
8302
+ BindTexture(tex, true, resolution);
82028303 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82038304 }
82048305
....@@ -8222,13 +8323,19 @@
82228323 return fileExists;
82238324 }
82248325
8225
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8326
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82268327 {
8227
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8328
+ CacheTexture texturecache = null;
82288329
82298330 if (tex != null)
82308331 {
8231
- String texname = tex;
8332
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8333
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8334
+
8335
+ if (texname.equals("") && texdata == null)
8336
+ {
8337
+ return null;
8338
+ }
82328339
82338340 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82348341
....@@ -8238,19 +8345,46 @@
82388345 // else
82398346 // if (!texname.startsWith("/"))
82408347 // texname = "/Users/nbriere/Textures/" + texname;
8241
- if (!FileExists(tex))
8348
+ if (!FileExists(texname))
82428349 {
82438350 texname = fallbackTextureName;
82448351 }
82458352
82468353 if (CACHETEXTURE)
8247
- texture = textures.get(texname); // TEXTURE CACHE
8248
-
8249
- TextureData texturedata = null;
8250
-
8251
- if (texture == null || texture.resolution < resolution)
82528354 {
8253
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8355
+ if (texdata == null)
8356
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8357
+ else
8358
+ texturecache = bimtextures.get(texdata);
8359
+ }
8360
+
8361
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8362
+ {
8363
+ TextureData texturedata = null;
8364
+
8365
+ if (texdata != null && textureon)
8366
+ {
8367
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8368
+
8369
+ try
8370
+ {
8371
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8372
+ }
8373
+ catch (Exception e)
8374
+ {
8375
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8376
+ }
8377
+
8378
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8379
+ bimtextures.put(texdata, texturecache);
8380
+
8381
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8382
+
8383
+ //Object bim2 = CreateBim(texturecache.texturedata);
8384
+ //bim2 = bim;
8385
+ }
8386
+ else
8387
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82548388 {
82558389 assert(!bump);
82568390 // if (bump)
....@@ -8261,19 +8395,23 @@
82618395 // }
82628396 // else
82638397 // {
8264
- texture = textures.get(tex);
8265
- if (texture == null)
8398
+ // texturecache = textures.get(texname); // suspicious
8399
+ if (texturecache == null)
82668400 {
8267
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8401
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82688402 }
8403
+ else
8404
+ new Exception().printStackTrace();
82698405 // }
82708406 } else
8271
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8407
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82728408 {
82738409 assert(bump);
8274
- texture = textures.get(tex);
8275
- if (texture == null)
8276
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8410
+ // texturecache = textures.get(texname); // suspicious
8411
+ if (texturecache == null)
8412
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8413
+ else
8414
+ new Exception().printStackTrace();
82778415 } else
82788416 {
82798417 //if (tex.equals("IMMORTAL"))
....@@ -8281,11 +8419,13 @@
82818419 // texture = GetResourceTexture("default.png");
82828420 //} else
82838421 //{
8284
- if (tex.equals("WHITE_NOISE"))
8422
+ if (texname.endsWith("WHITE_NOISE"))
82858423 {
8286
- texture = textures.get(tex);
8287
- if (texture == null)
8288
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8424
+ // texturecache = textures.get(texname); // suspicious
8425
+ if (texturecache == null)
8426
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8427
+ else
8428
+ new Exception().printStackTrace();
82898429 } else
82908430 {
82918431 if (textureon)
....@@ -8344,19 +8484,19 @@
83448484 if (texturedata == null)
83458485 throw new Exception();
83468486
8347
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8487
+ texturecache = new CacheTexture(texturedata,resolution);
83488488 //texture = GetTexture(tex, bump);
83498489 }
83508490 }
83518491 //}
83528492 }
83538493
8354
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8494
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
83558495 {
83568496 //return false;
83578497
83588498 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8359
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8499
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83608500 {
83618501 // String ext = "_highres";
83628502 // if (REDUCETEXTURE)
....@@ -8373,52 +8513,17 @@
83738513 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83748514 if (!cachefile.exists())
83758515 {
8376
- // cache to disk
8377
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8378
- //buffers[0].
8379
-
8380
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8381
- int[] pixels = new int[bytebuf.capacity()/3];
8382
-
8383
- // squared size heuristic...
8384
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8516
+ //if (texturedata.getWidth() == texturedata.getHeight())
83858517 {
8386
- for (int i=pixels.length; --i>=0;)
8387
- {
8388
- int i3 = i*3;
8389
- pixels[i] = 0xFF;
8390
- pixels[i] <<= 8;
8391
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8392
- pixels[i] <<= 8;
8393
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8394
- pixels[i] <<= 8;
8395
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8396
- }
8397
-
8398
- /*
8399
- int r=0,g=0,b=0,a=0;
8400
- for (int i=0; i<width; i++)
8401
- for (int j=0; j<height; j++)
8402
- {
8403
- int index = j*width+i;
8404
- int p = pixels[index];
8405
- a = ((p>>24) & 0xFF);
8406
- r = ((p>>16) & 0xFF);
8407
- g = ((p>>8) & 0xFF);
8408
- b = (p & 0xFF);
8409
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8410
- }
8411
- /**/
8412
- int width = (int)Math.sqrt(pixels.length); // squared
8413
- int height = width;
8414
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8415
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8518
+ BufferedImage rendImage = CreateBim(texturedata);
8519
+
84168520 ImageWriter writer = null;
84178521 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84188522 if (iter.hasNext()) {
84198523 writer = (ImageWriter)iter.next();
84208524 }
8421
- float compressionQuality = 0.9f;
8525
+
8526
+ float compressionQuality = 0.85f;
84228527 try
84238528 {
84248529 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8435,18 +8540,20 @@
84358540 }
84368541 }
84378542 }
8438
-
8543
+
8544
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8545
+
84398546 //System.out.println("Texture = " + tex);
8440
- if (textures.containsKey(texname))
8547
+ if (textures.containsKey(tex))
84418548 {
8442
- CacheTexture thetex = textures.get(texname);
8549
+ CacheTexture thetex = textures.get(tex);
84438550 thetex.texture.disable();
84448551 thetex.texture.dispose();
8445
- textures.remove(texname);
8552
+ textures.remove(tex);
84468553 }
84478554
8448
- texture.texturedata = texturedata;
8449
- textures.put(texname, texture);
8555
+ //texture.texturedata = texturedata;
8556
+ textures.put(tex, texturecache);
84508557
84518558 // newtex = true;
84528559 }
....@@ -8462,10 +8569,44 @@
84628569 }
84638570 }
84648571
8465
- return texture;
8572
+ return texturecache;
84668573 }
84678574
8468
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8575
+ static void EmbedTextures(cTexture tex)
8576
+ {
8577
+ if (tex.pigmentdata == null)
8578
+ {
8579
+ //String texname = Object3D.GetPigment(tex);
8580
+
8581
+ CacheTexture texturecache = texturepigment.get(tex);
8582
+
8583
+ if (texturecache != null)
8584
+ {
8585
+ tex.pw = texturecache.texturedata.getWidth();
8586
+ tex.ph = texturecache.texturedata.getHeight();
8587
+ tex.pigmentdata = //CompressJPEG(CreateBim
8588
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8589
+ ;
8590
+ //, tex.pw, tex.ph), 0.5f);
8591
+ }
8592
+ }
8593
+
8594
+ if (tex.bumpdata == null)
8595
+ {
8596
+ //String texname = Object3D.GetBump(tex);
8597
+
8598
+ CacheTexture texturecache = texturebump.get(tex);
8599
+
8600
+ if (texturecache != null)
8601
+ {
8602
+ tex.bw = texturecache.texturedata.getWidth();
8603
+ tex.bh = texturecache.texturedata.getHeight();
8604
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8605
+ }
8606
+ }
8607
+ }
8608
+
8609
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
84698610 {
84708611 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84718612
....@@ -8483,21 +8624,21 @@
84838624 return texture!=null?texture.texture:null;
84848625 }
84858626
8486
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8627
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
84878628 {
84888629 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84898630
84908631 return texture!=null?texture.texturedata:null;
84918632 }
84928633
8493
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8634
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
84948635 {
84958636 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84968637 {
84978638 return false;
84988639 }
84998640
8500
- boolean newtex = false;
8641
+ //boolean newtex = false;
85018642
85028643 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85038644
....@@ -8529,9 +8670,75 @@
85298670 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85308671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85318672
8532
- return newtex;
8673
+ return true; // Warning: not used.
85338674 }
85348675
8676
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8677
+ {
8678
+ try
8679
+ {
8680
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8681
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8682
+ ImageWriter writer = writers.next();
8683
+
8684
+ ImageWriteParam param = writer.getDefaultWriteParam();
8685
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8686
+ param.setCompressionQuality(quality);
8687
+
8688
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8689
+ writer.setOutput(ios);
8690
+ writer.write(null, new IIOImage(image, null, null), param);
8691
+
8692
+ byte[] data = baos.toByteArray();
8693
+ writer.dispose();
8694
+ return data;
8695
+ }
8696
+ catch (Exception e)
8697
+ {
8698
+ e.printStackTrace();
8699
+ return null;
8700
+ }
8701
+ }
8702
+
8703
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8704
+ {
8705
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8706
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8707
+ ImageReader reader = writers.next();
8708
+
8709
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8710
+
8711
+ ImageReadParam param = reader.getDefaultReadParam();
8712
+ param.setDestination(bim);
8713
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8714
+
8715
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8716
+ reader.setInput(ios);
8717
+ BufferedImage bim2 = reader.read(0, param);
8718
+ reader.dispose();
8719
+
8720
+// WritableRaster raster = bim2.getRaster();
8721
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8722
+// byte[] bytes = data.getData();
8723
+//
8724
+// int[] pixels = new int[bytes.length/3];
8725
+// for (int i=pixels.length; --i>=0;)
8726
+// {
8727
+// int i3 = i*3;
8728
+// pixels[i] = 0xFF;
8729
+// pixels[i] <<= 8;
8730
+// pixels[i] |= bytes[i3+2] & 0xFF;
8731
+// pixels[i] <<= 8;
8732
+// pixels[i] |= bytes[i3+1] & 0xFF;
8733
+// pixels[i] <<= 8;
8734
+// pixels[i] |= bytes[i3] & 0xFF;
8735
+// }
8736
+//
8737
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8738
+
8739
+ return bim;
8740
+ }
8741
+
85358742 ShadowBuffer shadowPBuf;
85368743 AntialiasBuffer antialiasPBuf;
85378744 int MAXSTACK;
....@@ -9367,11 +9574,35 @@
93679574 jy8[3] = 0.5f;
93689575 }
93699576
9370
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9577
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93719578 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93729579 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93739580 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93749581
9582
+ void ResetOptions()
9583
+ {
9584
+ options1[0] = 100;
9585
+ options1[1] = 0.025f;
9586
+ options1[2] = 0.01f;
9587
+ options1[3] = 0;
9588
+ options1[4] = 0;
9589
+
9590
+ options2[0] = 0;
9591
+ options2[1] = 0.75f;
9592
+ options2[2] = 0;
9593
+ options2[3] = 0;
9594
+
9595
+ options3[0] = 1;
9596
+ options3[1] = 1;
9597
+ options3[2] = 1;
9598
+ options3[3] = 0;
9599
+
9600
+ options4[0] = 1;
9601
+ options4[1] = 0;
9602
+ options4[2] = 1;
9603
+ options4[3] = 0;
9604
+ }
9605
+
93759606 static int imagecount = 0; // movie generation
93769607
93779608 static int jitter = 0;
....@@ -10482,6 +10713,7 @@
1048210713 ANTIALIAS = 0;
1048310714 //System.out.println("RESTART");
1048410715 AAtimer.restart();
10716
+ Globals.TIMERRUNNING = true;
1048510717 }
1048610718 }
1048710719 }
....@@ -10549,7 +10781,8 @@
1054910781 ambientOcclusion = false;
1055010782 }
1055110783
10552
- if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
10784
+ if (//Globals.lighttouched &&
10785
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1055310786 {
1055410787 //if (RENDERSHADOW) // ?
1055510788 if (!IsFrozen())
....@@ -10989,9 +11222,9 @@
1098911222
1099011223 gl.glMatrixMode(GL.GL_MODELVIEW);
1099111224
10992
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10993
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10994
-//gl.glEnable(gl.GL_MULTISAMPLE);
11225
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11226
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11227
+gl.glEnable(gl.GL_MULTISAMPLE);
1099511228 } else
1099611229 {
1099711230 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11002,7 +11235,7 @@
1100211235 //System.out.println("BLENDING ON");
1100311236 gl.glEnable(GL.GL_BLEND);
1100411237 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11005
-
11238
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1100611239 gl.glMatrixMode(gl.GL_PROJECTION);
1100711240 gl.glLoadIdentity();
1100811241
....@@ -11251,7 +11484,7 @@
1125111484 }
1125211485 }
1125311486
11254
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11487
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1125511488 {
1125611489 //gl.glDepthFunc(GL.GL_LEQUAL);
1125711490 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11259,24 +11492,21 @@
1125911492
1126011493 boolean texon = textureon;
1126111494
11262
- if (RENDERPROGRAM > 0)
11263
- {
11264
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11265
- textureon = false;
11266
- }
11495
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11496
+ textureon = false;
11497
+
1126711498 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1126811499 //System.out.println("ALLO");
1126911500 gl.glColorMask(false, false, false, false);
1127011501 DrawObject(gl);
11271
- if (RENDERPROGRAM > 0)
11272
- {
11273
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11274
- textureon = texon;
11275
- }
11502
+
11503
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11504
+ textureon = texon;
11505
+
1127611506 gl.glColorMask(true, true, true, true);
1127711507
1127811508 gl.glDepthFunc(GL.GL_EQUAL);
11279
- //gl.glDepthMask(false);
11509
+ gl.glDepthMask(false);
1128011510 }
1128111511
1128211512 if (false) // DrawMode() == SHADOW)
....@@ -11459,15 +11689,36 @@
1145911689
1146011690 static boolean zoomonce = false;
1146111691
11692
+ static void CreateSelectedPoint()
11693
+ {
11694
+ if (selectedpoint == null)
11695
+ {
11696
+ debugpointG = new Sphere();
11697
+ debugpointP = new Sphere();
11698
+ debugpointC = new Sphere();
11699
+ debugpointR = new Sphere();
11700
+
11701
+ selectedpoint = new Superellipsoid();
11702
+
11703
+ for (int i=0; i<8; i++)
11704
+ {
11705
+ debugpoints[i] = new Sphere();
11706
+ }
11707
+ }
11708
+ }
11709
+
1146211710 void DrawObject(GL gl, boolean draw)
1146311711 {
11712
+ // To clear camera values
11713
+ ResetOptions();
11714
+
1146411715 //System.out.println("DRAW OBJECT " + mouseDown);
1146511716 // DrawMode() = SELECTION;
1146611717 //GL gl = getGL();
1146711718 if ((TRACK || SHADOWTRACK) || zoomonce)
1146811719 {
1146911720 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11470
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11721
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1147111722 pingthread.StepToTarget(true); // true);
1147211723 // zoomonce = false;
1147311724 }
....@@ -11539,8 +11790,9 @@
1153911790
1154011791 if (DrawMode() == DEFAULT)
1154111792 {
11542
- if (DEBUG)
11793
+ if (Globals.DEBUG)
1154311794 {
11795
+ CreateSelectedPoint();
1154411796 float radius = 0.05f;
1154511797 if (selectedpoint.radius != radius)
1154611798 {
....@@ -11594,20 +11846,32 @@
1159411846 ReleaseTextures(DEFAULT_TEXTURES);
1159511847
1159611848 if (CLEANCACHE)
11597
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11849
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1159811850 {
11599
- String tex = e.nextElement();
11851
+ cTexture tex = e.nextElement();
1160011852
1160111853 // System.out.println("Texture --------- " + tex);
1160211854
11603
- if (tex.equals("WHITE_NOISE"))
11855
+ if (tex.equals("WHITE_NOISE:"))
1160411856 continue;
1160511857
11606
- if (!usedtextures.containsKey(tex))
11858
+ if (!usedtextures.contains(tex))
1160711859 {
11860
+ CacheTexture gettex = texturepigment.get(tex);
1160811861 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11609
- textures.get(tex).texture.dispose();
11610
- textures.remove(tex);
11862
+ if (gettex != null)
11863
+ {
11864
+ gettex.texture.dispose();
11865
+ texturepigment.remove(tex);
11866
+ }
11867
+
11868
+ gettex = texturebump.get(tex);
11869
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11870
+ if (gettex != null)
11871
+ {
11872
+ gettex.texture.dispose();
11873
+ texturebump.remove(tex);
11874
+ }
1161111875 }
1161211876 }
1161311877 }
....@@ -12027,7 +12291,7 @@
1202712291 for (int i = tp.size(); --i >= 0;)
1202812292 {
1202912293 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12294
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1203112295 }
1203212296
1203312297
....@@ -12136,7 +12400,51 @@
1213612400 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1213712401
1213812402 String program =
12403
+ // Min shader
1213912404 "!!ARBfp1.0\n" +
12405
+ "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" +
12406
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12407
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12408
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12409
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12410
+ "TEMP temp;" +
12411
+ "TEMP light;" +
12412
+ "TEMP ndotl;" +
12413
+ "TEMP normal;" +
12414
+ "TEMP depth;" +
12415
+
12416
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12417
+
12418
+ "MOV light, state.light[0].position;" +
12419
+ "DP3 ndotl.x, light, normal;" +
12420
+
12421
+ // shadow
12422
+ "MOV temp, fragment.texcoord[1];" +
12423
+ TextureFetch("depth", "temp", "1") +
12424
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12425
+ "SLT temp.x, fragment.texcoord[1].z, depth.z;" +
12426
+
12427
+
12428
+ // No shadow when out of frustum
12429
+ //"SGE temp.y, depth.z, zero123.y;" +
12430
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12431
+
12432
+ "MUL ndotl.x, ndotl.x, temp.x;" +
12433
+ "MAX ndotl.x, ndotl.x, pow2.y;" +
12434
+
12435
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12436
+ "MUL temp, temp, ndotl.x;" +
12437
+
12438
+ "MUL temp, temp, zero123.z;" +
12439
+
12440
+ "MOV temp.w, zero123.y;" + // reset alpha
12441
+
12442
+ "MOV result.color, temp;" +
12443
+ "END";
12444
+
12445
+ String program2 =
12446
+ "!!ARBfp1.0\n" +
12447
+
1214012448 //"OPTION ARB_fragment_program_shadow;" +
1214112449 "PARAM light2cam0 = program.env[10];" +
1214212450 "PARAM light2cam1 = program.env[11];" +
....@@ -12251,8 +12559,7 @@
1225112559 "TEMP shininess;" +
1225212560 "\n" +
1225312561 "MOV texSamp, one;" +
12254
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12255
-
12562
+
1225612563 "MOV mapgrid.x, one2048th.x;" +
1225712564 "MOV temp, fragment.texcoord[1];" +
1225812565 /*
....@@ -12657,7 +12964,7 @@
1265712964 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1265812965 "") +
1265912966
12660
- // display shadow only (bump == 0)
12967
+ // display shadow only (fakedepth == 0)
1266112968 "SUB temp.x, half.x, shadow.x;" +
1266212969 "MOV temp.y, -params5.z;" + // params6.x;" +
1266312970 "SLT temp.z, temp.y, -one2048th.x;" +
....@@ -13149,7 +13456,7 @@
1314913456 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1315013457 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1315113458
13152
- // No shadow when out of frustrum
13459
+ // No shadow when out of frustum
1315313460 "SGE temp.x, " + depth + ".z, one.z;" +
1315413461 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1315513462 "";
....@@ -13297,7 +13604,8 @@
1329713604 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1329813605 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1329913606 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13300
- Object3D.cVector2[] vector2buffer;
13607
+
13608
+ //Object3D.cVector2[] vector2buffer;
1330113609
1330213610 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1330313611 // OUT : diff, spec
....@@ -13313,9 +13621,10 @@
1331313621 "DP3 " + dest + ".z," + "normals," + "eye;" +
1331413622 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1331513623 //"MOV " + dest + ".w," + "normal.z;" +
13316
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13317
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13318
- //"MOV " + dest + ".z," + "params2.w;" +
13624
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13625
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13626
+
13627
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1331913628 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1332013629 "RCP " + dest + ".w," + dest + ".w;" +
1332113630 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13820,6 +14129,7 @@
1382014129 else
1382114130 if (evt.getSource() == AAtimer)
1382214131 {
14132
+ Globals.TIMERRUNNING = false;
1382314133 if (mouseDown)
1382414134 {
1382514135 //new Exception().printStackTrace();
....@@ -13879,7 +14189,7 @@
1387914189
1388014190 // fev 2014???
1388114191 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13882
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14192
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1388314193 pingthread.StepToTarget(true); // true);
1388414194 }
1388514195 // if (!LIVE)
....@@ -13894,6 +14204,7 @@
1389414204 return;
1389514205
1389614206 AAtimer.restart(); //
14207
+ Globals.TIMERRUNNING = true;
1389714208
1389814209 // waslive = LIVE;
1389914210 // LIVE = false;
....@@ -14232,12 +14543,12 @@
1423214543 void GoDown(int mod)
1423314544 {
1423414545 MODIFIERS |= COMMAND;
14235
- /*
14546
+ /**/
1423614547 if((mod&SHIFT) == SHIFT)
1423714548 manipCamera.RotatePosition(0, -speed);
1423814549 else
14239
- manipCamera.BackForth(0, -speed*delta, getWidth());
14240
- */
14550
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14551
+ /**/
1424114552 if ((mod & SHIFT) == SHIFT)
1424214553 {
1424314554 mouseMode = mouseMode; // VR??
....@@ -14253,12 +14564,12 @@
1425314564 void GoUp(int mod)
1425414565 {
1425514566 MODIFIERS |= COMMAND;
14256
- /*
14567
+ /**/
1425714568 if((mod&SHIFT) == SHIFT)
1425814569 manipCamera.RotatePosition(0, speed);
1425914570 else
14260
- manipCamera.BackForth(0, speed*delta, getWidth());
14261
- */
14571
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14572
+ /**/
1426214573 if ((mod & SHIFT) == SHIFT)
1426314574 {
1426414575 mouseMode = mouseMode;
....@@ -14274,12 +14585,12 @@
1427414585 void GoLeft(int mod)
1427514586 {
1427614587 MODIFIERS |= COMMAND;
14277
- /*
14588
+ /**/
1427814589 if((mod&SHIFT) == SHIFT)
14279
- manipCamera.RotatePosition(speed, 0);
14280
- else
1428114590 manipCamera.Translate(speed*delta, 0, getWidth());
14282
- */
14591
+ else
14592
+ manipCamera.RotatePosition(speed, 0);
14593
+ /**/
1428314594 if ((mod & SHIFT) == SHIFT)
1428414595 {
1428514596 mouseMode = mouseMode;
....@@ -14295,12 +14606,12 @@
1429514606 void GoRight(int mod)
1429614607 {
1429714608 MODIFIERS |= COMMAND;
14298
- /*
14609
+ /**/
1429914610 if((mod&SHIFT) == SHIFT)
14300
- manipCamera.RotatePosition(-speed, 0);
14301
- else
1430214611 manipCamera.Translate(-speed*delta, 0, getWidth());
14303
- */
14612
+ else
14613
+ manipCamera.RotatePosition(-speed, 0);
14614
+ /**/
1430414615 if ((mod & SHIFT) == SHIFT)
1430514616 {
1430614617 mouseMode = mouseMode;
....@@ -14357,7 +14668,8 @@
1435714668 info.camera = renderCamera;
1435814669 info.x = x;
1435914670 info.y = y;
14360
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14671
+ object.GetWindow().copy
14672
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1436114673 } else
1436214674 {
1436314675 if (x < startX)
....@@ -14521,7 +14833,9 @@
1452114833 ci.camera = renderCamera;
1452214834 if (!isRenderer)
1452314835 {
14524
- if (object.editWindow.copy.doEditClick(ci, 0))
14836
+ //ObjEditor editWindow = object.editWindow;
14837
+ //Object3D copy = editWindow.copy;
14838
+ if (object.doEditClick(ci, 0))
1452514839 {
1452614840 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1452714841 } else
....@@ -14536,7 +14850,8 @@
1453614850 Globals.MOUSEDRAGGED = false;
1453714851
1453814852 movingcamera = false;
14539
- X = Y = 0;
14853
+ X = 0; // getBounds().width/2;
14854
+ Y = 0; // getBounds().height/2;
1454014855 //System.out.println("mouseReleased: " + e);
1454114856 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1454214857 }
....@@ -14792,7 +15107,8 @@
1479215107 // break;
1479315108 case 'T':
1479415109 CACHETEXTURE ^= true;
14795
- textures.clear();
15110
+ texturepigment.clear();
15111
+ texturebump.clear();
1479615112 // repaint();
1479715113 break;
1479815114 case 'Y':
....@@ -14877,7 +15193,9 @@
1487715193 case 'E' : COMPACT ^= true;
1487815194 repaint();
1487915195 break;
14880
- case 'W' : DEBUGHSB ^= true;
15196
+ case 'W' : // Wide Window (fullscreen)
15197
+ //DEBUGHSB ^= true;
15198
+ ObjEditor.theFrame.ToggleFullScreen();
1488115199 repaint();
1488215200 break;
1488315201 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14902,8 +15220,8 @@
1490215220 RevertCamera();
1490315221 repaint();
1490415222 break;
14905
- case 'L':
1490615223 case 'l':
15224
+ //case 'L':
1490715225 if (lightMode)
1490815226 {
1490915227 lightMode = false;
....@@ -15046,9 +15364,9 @@
1504615364 case '_':
1504715365 kompactbit = 5;
1504815366 break;
15049
- case '+':
15050
- kompactbit = 6;
15051
- break;
15367
+// case '+':
15368
+// kompactbit = 6;
15369
+// break;
1505215370 case ' ':
1505315371 lightMode ^= true;
1505415372 Globals.lighttouched = true;
....@@ -15060,6 +15378,7 @@
1506015378 case ESC:
1506115379 RENDERPROGRAM += 1;
1506215380 RENDERPROGRAM %= 3;
15381
+
1506315382 repaint();
1506415383 break;
1506515384 case 'Z':
....@@ -15099,8 +15418,9 @@
1509915418 case DELETE:
1510015419 ClearSelection();
1510115420 break;
15102
- /*
1510315421 case '+':
15422
+
15423
+ /*
1510415424 //fontsize += 1;
1510515425 bbzoom *= 2;
1510615426 repaint();
....@@ -15117,17 +15437,17 @@
1511715437 case '=':
1511815438 IncDepth();
1511915439 //fontsize += 1;
15120
- object.editWindow.refreshContents(true);
15440
+ object.GetWindow().refreshContents(true);
1512115441 maskbit = 6;
1512215442 break;
1512315443 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1512415444 DecDepth();
1512515445 maskbit = 5;
1512615446 //if(fontsize > 1) fontsize -= 1;
15127
- if (object.editWindow == null)
15128
- new Exception().printStackTrace();
15129
- else
15130
- object.editWindow.refreshContents(true);
15447
+// if (object.editWindow == null)
15448
+// new Exception().printStackTrace();
15449
+// else
15450
+ object.GetWindow().refreshContents(true);
1513115451 break;
1513215452 case '{':
1513315453 manipCamera.shaper_fovy /= 1.1;
....@@ -15351,7 +15671,7 @@
1535115671 }
1535215672 */
1535315673
15354
- object.editWindow.EditSelection();
15674
+ object.GetWindow().EditSelection(false);
1535515675 }
1535615676
1535715677 void SelectParent()
....@@ -15368,10 +15688,10 @@
1536815688 {
1536915689 //selectees.remove(i);
1537015690 System.out.println("select parent of " + elem);
15371
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15691
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1537215692 } else
1537315693 {
15374
- group.editWindow.Select(elem.GetTreePath(), first, true);
15694
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1537515695 }
1537615696
1537715697 first = false;
....@@ -15413,12 +15733,12 @@
1541315733 for (int j = 0; j < group.children.size(); j++)
1541415734 {
1541515735 elem = (Object3D) group.children.elementAt(j);
15416
- object.editWindow.Select(elem.GetTreePath(), first, true);
15736
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1541715737 first = false;
1541815738 }
1541915739 } else
1542015740 {
15421
- object.editWindow.Select(elem.GetTreePath(), first, true);
15741
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1542215742 }
1542315743
1542415744 first = false;
....@@ -15429,21 +15749,21 @@
1542915749 {
1543015750 //Composite group = (Composite) object;
1543115751 Object3D group = object;
15432
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15752
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1543315753 }
1543415754
1543515755 void ResetTransform(int mask)
1543615756 {
1543715757 //Composite group = (Composite) object;
1543815758 Object3D group = object;
15439
- group.editWindow.ResetTransform(mask);
15759
+ group.GetWindow().ResetTransform(mask);
1544015760 }
1544115761
1544215762 void FlipTransform()
1544315763 {
1544415764 //Composite group = (Composite) object;
1544515765 Object3D group = object;
15446
- group.editWindow.FlipTransform();
15766
+ group.GetWindow().FlipTransform();
1544715767 // group.editWindow.ReduceMesh(true);
1544815768 }
1544915769
....@@ -15451,7 +15771,7 @@
1545115771 {
1545215772 //Composite group = (Composite) object;
1545315773 Object3D group = object;
15454
- group.editWindow.PrintMemory();
15774
+ group.GetWindow().PrintMemory();
1545515775 // group.editWindow.ReduceMesh(true);
1545615776 }
1545715777
....@@ -15459,7 +15779,7 @@
1545915779 {
1546015780 //Composite group = (Composite) object;
1546115781 Object3D group = object;
15462
- group.editWindow.ResetCentroid();
15782
+ group.GetWindow().ResetCentroid();
1546315783 }
1546415784
1546515785 void IncDepth()
....@@ -15635,6 +15955,7 @@
1563515955 info.bounds.y += (height - desired) / 2;
1563615956 }
1563715957 }
15958
+
1563815959 info.g = gr;
1563915960 info.camera = renderCamera;
1564015961 /*
....@@ -15644,23 +15965,44 @@
1564415965 */
1564515966 if (!isRenderer)
1564615967 {
15647
- object.drawEditHandles(info, 0);
15648
-
15649
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15968
+ Grafreed.Assert(object != null);
15969
+ Grafreed.Assert(object.selection != null);
15970
+ if (object.selection.Size() > 0)
1565015971 {
15651
- switch (object.selection.get(0).hitSomething)
15972
+ int hitSomething = object.selection.get(0).hitSomething;
15973
+
15974
+ info.DX = 0;
15975
+ info.DY = 0;
15976
+ info.W = 1;
15977
+ if (hitSomething == Object3D.hitCenter)
1565215978 {
15653
- case Object3D.hitCenter: gr.setColor(Color.pink);
15654
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
- break;
15656
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
- break;
15659
- case Object3D.hitScale: gr.setColor(Color.cyan);
15660
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
- break;
15979
+ info.DX = X;
15980
+ if (X != 0)
15981
+ info.DX -= info.bounds.width/2;
15982
+
15983
+ info.DY = Y;
15984
+ if (Y != 0)
15985
+ info.DY -= info.bounds.height/2;
1566215986 }
15663
-
15987
+
15988
+ object.drawEditHandles(info, 0);
15989
+
15990
+ if (drag && (X != 0 || Y != 0))
15991
+ {
15992
+ switch (hitSomething)
15993
+ {
15994
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15995
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15996
+ break;
15997
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15998
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15999
+ break;
16000
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16001
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16002
+ break;
16003
+ }
16004
+
16005
+ }
1566416006 }
1566516007 }
1566616008 }
....@@ -16363,16 +16705,16 @@
1636316705 cStatic.objectstack[materialdepth++] = checker;
1636416706 //System.out.println("material " + material);
1636516707 //Applet3D.tracein(this, selected);
16366
- vector2buffer = checker.projectedVertices;
16708
+ //vector2buffer = checker.projectedVertices;
1636716709
1636816710 //checker.GetMaterial().Draw(this, false); // true);
16369
- DrawMaterial(checker.GetMaterial(), false); // true);
16711
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1637016712
1637116713 materialdepth -= 1;
1637216714 if (materialdepth > 0)
1637316715 {
16374
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16375
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16716
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16717
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1637616718 }
1637716719 //checker.GetMaterial().opacity = 1f;
1637816720 ////checker.GetMaterial().ambient = 1f;
....@@ -16458,6 +16800,14 @@
1645816800 }
1645916801 }
1646016802
16803
+ private Object3D GetFolder()
16804
+ {
16805
+ Object3D folder = object.GetWindow().copy;
16806
+ if (object.GetWindow().copy.selection.Size() > 0)
16807
+ folder = object.GetWindow().copy.selection.elementAt(0);
16808
+ return folder;
16809
+ }
16810
+
1646116811 class SelectBuffer implements GLEventListener
1646216812 {
1646316813
....@@ -16537,6 +16887,17 @@
1653716887
1653816888 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1653916889
16890
+ if (PAINTMODE)
16891
+ {
16892
+ if (object.GetWindow().copy.selection.Size() > 0)
16893
+ {
16894
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16895
+
16896
+ // Make what you paint not selectable.
16897
+ paintobj.ResetSelectable();
16898
+ }
16899
+ }
16900
+
1654016901 //int tmp = selection_view;
1654116902 //selection_view = -1;
1654216903 int temp = DrawMode();
....@@ -16548,6 +16909,17 @@
1654816909 // temp = DEFAULT; // patch for selection debug
1654916910 Globals.drawMode = temp; // WARNING
1655016911
16912
+ if (PAINTMODE)
16913
+ {
16914
+ if (object.GetWindow().copy.selection.Size() > 0)
16915
+ {
16916
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16917
+
16918
+ // Revert.
16919
+ paintobj.RestoreSelectable();
16920
+ }
16921
+ }
16922
+
1655116923 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1655216924
1655316925 // trying different ways of getting the depth info over
....@@ -16595,6 +16967,8 @@
1659516967 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1659616968 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1659716969 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16970
+
16971
+ CreateSelectedPoint();
1659816972
1659916973 // Will fit the mesh !!!
1660016974 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16649,29 +17023,31 @@
1664917023 }
1665017024
1665117025 if (!movingcamera && !PAINTMODE)
16652
- object.editWindow.ScreenFitPoint(); // fev 2014
17026
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1665317027
16654
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17028
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1665517029 {
16656
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17030
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1665717031
16658
- Object3D group = new Object3D("inst" + paintcount++);
17032
+ if (object.GetWindow().copy.selection.Size() > 0)
17033
+ {
17034
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1665917035
16660
- group.CreateMaterial(); // use a void leaf to select instances
16661
-
16662
- group.add(paintobj); // link
16663
-
16664
- object.editWindow.SnapObject(group);
16665
-
16666
- Object3D folder = object.editWindow.copy;
16667
-
16668
- if (object.editWindow.copy.selection.Size() > 0)
16669
- folder = object.editWindow.copy.selection.elementAt(0);
16670
-
16671
- folder.add(group);
16672
-
16673
- object.editWindow.ResetModel();
16674
- object.editWindow.refreshContents();
17036
+ Object3D inst = new Object3D("inst" + paintcount++);
17037
+
17038
+ inst.CreateMaterial(); // use a void leaf to select instances
17039
+
17040
+ inst.add(paintobj); // link
17041
+
17042
+ object.GetWindow().SnapObject(inst);
17043
+
17044
+ Object3D folder = paintFolder; // GetFolder();
17045
+
17046
+ folder.add(inst);
17047
+
17048
+ object.GetWindow().ResetModel();
17049
+ object.GetWindow().refreshContents();
17050
+ }
1667517051 }
1667617052 else
1667717053 paintcount = 0;
....@@ -16710,6 +17086,11 @@
1671017086 //System.out.println("objects[color] = " + objects[color]);
1671117087 //objects[color].Select();
1671217088 indexcount = 0;
17089
+ ObjEditor window = object.GetWindow();
17090
+ if (window != null && deselect)
17091
+ {
17092
+ window.Select(null, deselect, true);
17093
+ }
1671317094 object.Select(color, deselect);
1671417095 }
1671517096
....@@ -17235,23 +17616,15 @@
1723517616 int AAbuffersize = 0;
1723617617
1723717618 //double[] selectedpoint = new double[3];
17238
- static Superellipsoid selectedpoint = new Superellipsoid();
17619
+ static Superellipsoid selectedpoint;
1723917620 static Sphere previousselectedpoint = null;
17240
- static Sphere debugpointG = new Sphere();
17241
- static Sphere debugpointP = new Sphere();
17242
- static Sphere debugpointC = new Sphere();
17243
- static Sphere debugpointR = new Sphere();
17621
+ static Sphere debugpointG;
17622
+ static Sphere debugpointP;
17623
+ static Sphere debugpointC;
17624
+ static Sphere debugpointR;
1724417625
1724517626 static Sphere debugpoints[] = new Sphere[8];
1724617627
17247
- static
17248
- {
17249
- for (int i=0; i<8; i++)
17250
- {
17251
- debugpoints[i] = new Sphere();
17252
- }
17253
- }
17254
-
1725517628 static void InitPoints(float radius)
1725617629 {
1725717630 for (int i=0; i<8; i++)