Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -45,6 +44,39 @@
4544 static boolean ABORTED = false;
4645
4746 static int STEP = 1;
47
+
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
+ }
4880
4981 /*static*/ private boolean CULLFACE = false; // true;
5082 /*static*/ boolean NEAREST = false; // true;
....@@ -61,7 +93,7 @@
6193 //boolean REDUCETEXTURE = true;
6294 boolean CACHETEXTURE = true;
6395 boolean CLEANCACHE = false; // true;
64
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
6597 boolean COMPRESSTEXTURE = false;
6698 boolean KOMPACTTEXTURE = false; // true;
6799 boolean RESIZETEXTURE = false;
....@@ -149,6 +181,8 @@
149181 defaultcaps.setAccumBlueBits(16);
150182 defaultcaps.setAccumAlphaBits(16);
151183 }
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152186
153187 void SetAsGLRenderer(boolean b)
154188 {
....@@ -325,7 +359,7 @@
325359 cStatic.objectstack[materialdepth++] = obj;
326360 //System.out.println("material " + material);
327361 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
362
+ //display.vector2buffer = obj.projectedVertices;
329363 if (obj instanceof Camera)
330364 {
331365 display.options1[0] = material.shift;
....@@ -334,14 +368,28 @@
334368 display.options1[2] = material.shadowbias;
335369 display.options1[3] = material.aniso;
336370 display.options1[4] = material.anisoV;
371
+// System.out.println("display.options1[0] " + display.options1[0]);
372
+// System.out.println("display.options1[1] " + display.options1[1]);
373
+// System.out.println("display.options1[2] " + display.options1[2]);
374
+// System.out.println("display.options1[3] " + display.options1[3]);
375
+// System.out.println("display.options1[4] " + display.options1[4]);
337376 display.options2[0] = material.opacity;
338377 display.options2[1] = material.diffuse;
339378 display.options2[2] = material.factor;
379
+// System.out.println("display.options2[0] " + display.options2[0]);
380
+// System.out.println("display.options2[1] " + display.options2[1]);
381
+// System.out.println("display.options2[2] " + display.options2[2]);
340382
341383 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
384
+// System.out.println("display.options3[0] " + display.options3[0]);
385
+// System.out.println("display.options3[1] " + display.options3[1]);
386
+// System.out.println("display.options3[2] " + display.options3[2]);
342387 display.options4[0] = material.cameralight/0.2f;
343388 display.options4[1] = material.subsurface;
344389 display.options4[2] = material.sheen;
390
+// System.out.println("display.options4[0] " + display.options4[0]);
391
+// System.out.println("display.options4[1] " + display.options4[1]);
392
+// System.out.println("display.options4[2] " + display.options4[2]);
345393
346394 // if (display.CURRENTANTIALIAS > 0)
347395 // display.options3[3] /= 4;
....@@ -357,7 +405,7 @@
357405 /**/
358406 } else
359407 {
360
- DrawMaterial(material, selected);
408
+ DrawMaterial(material, selected, obj.projectedVertices);
361409 }
362410 } else
363411 {
....@@ -381,8 +429,8 @@
381429 cStatic.objectstack[materialdepth++] = obj;
382430 //System.out.println("material " + material);
383431 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386434 }
387435 }
388436
....@@ -399,8 +447,8 @@
399447 materialdepth -= 1;
400448 if (materialdepth > 0)
401449 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
450
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
451
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
404452 }
405453 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406454 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +468,8 @@
420468 materialdepth -= 1;
421469 if (materialdepth > 0)
422470 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
471
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
472
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
425473 }
426474 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427475 //else
....@@ -462,10 +510,12 @@
462510 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463511 {
464512 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
513
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
514
+ // TEST LIVE NORMALS && !obj.dontselect
515
+ ;
466516 if (!hasnorm)
467517 {
468
- // System.out.println("FUCK!!");
518
+ // System.out.println("Mesh normal");
469519 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470520 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471521 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1240,12 @@
11901240 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911241 }
11921242 }
1243
+
11931244 if (flipV)
11941245 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951246 else
11961247 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
11971249 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981250 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991251
....@@ -1213,10 +1265,12 @@
12131265 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141266 }
12151267 }
1268
+
12161269 if (flipV)
12171270 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181271 else
12191272 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
12201274 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211275 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221276
....@@ -1244,8 +1298,10 @@
12441298 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451299 else
12461300 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
12471302 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481303 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
12491305 count2 += 2;
12501306 count3 += 3;
12511307 }
....@@ -1601,7 +1657,7 @@
16011657 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021658 }
16031659
1604
- void DrawMaterial(cMaterial material, boolean selected)
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051661 {
16061662 CameraPane display = this;
16071663 //new Exception().printStackTrace();
....@@ -1636,7 +1692,7 @@
16361692 colorV[0] = display.modelParams0[0] * material.diffuse;
16371693 colorV[1] = display.modelParams0[1] * material.diffuse;
16381694 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1695
+ colorV[3] = 1; // material.opacity;
16401696
16411697 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421698 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1800,9 @@
17441800 display.modelParams7[2] = 0;
17451801 display.modelParams7[3] = 0;
17461802
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481804
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501806 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511807 {
17521808 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1944,7 @@
18881944 void PushMatrix(double[][] matrix)
18891945 {
18901946 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
18921948 }
18931949
18941950 void PushMatrix()
....@@ -2042,7 +2098,7 @@
20422098 //System.err.println("Oeil on");
20432099 OEIL = true;
20442100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462102 //pingthread.StepToTarget(true);
20472103 }
20482104
....@@ -2257,7 +2313,7 @@
22572313
22582314 void ToggleDebug()
22592315 {
2260
- DEBUG ^= true;
2316
+ Globals.DEBUG ^= true;
22612317 }
22622318
22632319 void ToggleLookAt()
....@@ -2265,7 +2321,7 @@
22652321 LOOKAT ^= true;
22662322 }
22672323
2268
- void ToggleRandom()
2324
+ void ToggleSwitch()
22692325 {
22702326 SWITCH ^= true;
22712327 }
....@@ -2275,10 +2331,17 @@
22752331 HANDLES ^= true;
22762332 }
22772333
2334
+ Object3D paintFolder;
2335
+
22782336 void TogglePaint()
22792337 {
22802338 PAINTMODE ^= true;
22812339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
22822345 }
22832346
22842347 void SwapCamera(int a, int b)
....@@ -2374,7 +2437,22 @@
23742437 {
23752438 return currentGL;
23762439 }
2377
-
2440
+
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
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);
2454
+ }
2455
+
23782456 /**/
23792457 class CacheTexture
23802458 {
....@@ -2383,28 +2461,31 @@
23832461
23842462 int resolution;
23852463
2386
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23872465 {
2388
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
23892468 resolution = res;
23902469 }
23912470 }
23922471 /**/
23932472
23942473 // TEXTURE static Texture texture;
2395
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2396
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2397
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, 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>();
2478
+
23982479 int pigmentdepth = 0;
23992480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24002481 int bumpdepth = 0;
24012482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24022483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24032484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2404
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24052486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24062487
2407
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24082489 {
24092490 TextureData texturedata = null;
24102491
....@@ -2423,13 +2504,34 @@
24232504 if (bump)
24242505 texturedata = ConvertBump(texturedata, false);
24252506
2426
- com.sun.opengl.util.texture.Texture texture =
2427
- 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);
24282509
2429
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2430
- 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);
24312512
2432
- return texture;
2513
+ return texturedata;
2514
+ }
2515
+
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2517
+ {
2518
+ TextureData texturedata = null;
2519
+
2520
+ try
2521
+ {
2522
+ texturedata =
2523
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2524
+ bim,
2525
+ true);
2526
+ } catch (Exception e)
2527
+ {
2528
+ throw new javax.media.opengl.GLException(e);
2529
+ }
2530
+
2531
+ if (bump)
2532
+ texturedata = ConvertBump(texturedata, false);
2533
+
2534
+ return texturedata;
24332535 }
24342536
24352537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3502,6 +3604,8 @@
35023604
35033605 System.out.println("LOADING TEXTURE : " + name);
35043606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
35053609 //
35063610 if (false) // compressbit > 0)
35073611 {
....@@ -7900,7 +8004,7 @@
79008004 String pigment = Object3D.GetPigment(tex);
79018005 String bump = Object3D.GetBump(tex);
79028006
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79048008 {
79058009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79068010 // System.out.println("; bump = " + bump);
....@@ -7915,11 +8019,69 @@
79158019 pigment = null;
79168020 }
79178021
7918
- ReleaseTexture(bump, true);
7919
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79208024 }
79218025
7922
- void ReleaseTexture(String tex, boolean bump)
8026
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8027
+ {
8028
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8029
+ {
8030
+ return;
8031
+ }
8032
+
8033
+ if (tex == null)
8034
+ {
8035
+ ReleaseTexture(null, false);
8036
+ return;
8037
+ }
8038
+
8039
+ String pigment = Object3D.GetPigment(tex);
8040
+
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ {
8043
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8044
+ // System.out.println("; bump = " + bump);
8045
+ }
8046
+
8047
+ if (pigment.equals(""))
8048
+ {
8049
+ pigment = null;
8050
+ }
8051
+
8052
+ ReleaseTexture(tex, false);
8053
+ }
8054
+
8055
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8056
+ {
8057
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8058
+ {
8059
+ return;
8060
+ }
8061
+
8062
+ if (tex == null)
8063
+ {
8064
+ ReleaseTexture(null, true);
8065
+ return;
8066
+ }
8067
+
8068
+ String bump = Object3D.GetBump(tex);
8069
+
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8071
+ {
8072
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8073
+ // System.out.println("; bump = " + bump);
8074
+ }
8075
+
8076
+ if (bump.equals(""))
8077
+ {
8078
+ bump = null;
8079
+ }
8080
+
8081
+ ReleaseTexture(tex, true);
8082
+ }
8083
+
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
79238085 {
79248086 if (// DrawMode() != 0 || /*tex == null ||*/
79258087 ambientOcclusion ) // || !textureon)
....@@ -7930,7 +8092,7 @@
79308092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79318093
79328094 if (tex != null)
7933
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79348096
79358097 // //assert( texture != null );
79368098 // if (texture == null)
....@@ -8024,6 +8186,54 @@
80248186
80258187 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268188 {
8189
+// if (// DrawMode() != 0 || /*tex == null ||*/
8190
+// ambientOcclusion ) // || !textureon)
8191
+// {
8192
+// return; // false;
8193
+// }
8194
+//
8195
+// if (tex == null)
8196
+// {
8197
+// BindTexture(null,false,resolution);
8198
+// BindTexture(null,true,resolution);
8199
+// return;
8200
+// }
8201
+//
8202
+// String pigment = Object3D.GetPigment(tex);
8203
+// String bump = Object3D.GetBump(tex);
8204
+//
8205
+// usedtextures.add(pigment);
8206
+// usedtextures.add(bump);
8207
+//
8208
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+// {
8210
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8211
+// // System.out.println("; bump = " + bump);
8212
+// }
8213
+//
8214
+// if (bump.equals(""))
8215
+// {
8216
+// bump = null;
8217
+// }
8218
+// if (pigment.equals(""))
8219
+// {
8220
+// pigment = null;
8221
+// }
8222
+//
8223
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8224
+// BindTexture(pigment, false, resolution);
8225
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8226
+// BindTexture(bump, true, resolution);
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+//
8229
+// return; // true;
8230
+
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
8233
+ }
8234
+
8235
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8236
+ {
80278237 if (// DrawMode() != 0 || /*tex == null ||*/
80288238 ambientOcclusion ) // || !textureon)
80298239 {
....@@ -8033,17 +8243,47 @@
80338243 if (tex == null)
80348244 {
80358245 BindTexture(null,false,resolution);
8036
- BindTexture(null,true,resolution);
80378246 return;
80388247 }
80398248
80408249 String pigment = Object3D.GetPigment(tex);
8250
+
8251
+ usedtextures.add(tex);
8252
+
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8254
+ {
8255
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8256
+ // System.out.println("; bump = " + bump);
8257
+ }
8258
+
8259
+ if (pigment.equals(""))
8260
+ {
8261
+ pigment = null;
8262
+ }
8263
+
8264
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
+ BindTexture(tex, false, resolution);
8266
+ }
8267
+
8268
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8269
+ {
8270
+ if (// DrawMode() != 0 || /*tex == null ||*/
8271
+ ambientOcclusion ) // || !textureon)
8272
+ {
8273
+ return; // false;
8274
+ }
8275
+
8276
+ if (tex == null)
8277
+ {
8278
+ BindTexture(null,true,resolution);
8279
+ return;
8280
+ }
8281
+
80418282 String bump = Object3D.GetBump(tex);
80428283
8043
- usedtextures.put(pigment, pigment);
8044
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
80458285
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478287 {
80488288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498289 // System.out.println("; bump = " + bump);
....@@ -8053,47 +8293,82 @@
80538293 {
80548294 bump = null;
80558295 }
8056
- if (pigment.equals(""))
8057
- {
8058
- pigment = null;
8059
- }
80608296
8061
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8062
- BindTexture(pigment, false, resolution);
80638297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8064
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
80658299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8066
-
8067
- return; // true;
80688300 }
80698301
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8302
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8303
+
8304
+ private boolean FileExists(String tex)
80718305 {
8072
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8306
+ if (missingTextures.contains(tex))
8307
+ {
8308
+ return false;
8309
+ }
8310
+
8311
+ boolean fileExists = new File(tex).exists();
8312
+
8313
+ if (!fileExists)
8314
+ {
8315
+ // If file exists, the "new File()" is not executed sgain
8316
+ missingTextures.add(tex);
8317
+ }
8318
+
8319
+ return fileExists;
8320
+ }
8321
+
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8323
+ {
8324
+ CacheTexture texturecache = null;
80738325
80748326 if (tex != null)
80758327 {
8076
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80778330
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
8335
+
8336
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8337
+
80788338 // String[] split = tex.split("Textures");
80798339 // if (split.length > 1)
80808340 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818341 // else
80828342 // if (!texname.startsWith("/"))
80838343 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8344
+ if (!FileExists(texname))
80858345 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8346
+ texname = fallbackTextureName;
80878347 }
80888348
80898349 if (CACHETEXTURE)
8090
- texture = textures.get(texname); // TEXTURE CACHE
8091
-
8092
- TextureData texturedata = null;
8093
-
8094
- if (texture == null || texture.resolution < resolution)
80958350 {
8096
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8353
+ else
8354
+ texturecache = bimtextures.get(texdata);
8355
+ }
8356
+
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8358
+ {
8359
+ TextureData texturedata = null;
8360
+
8361
+ if (texdata != null)
8362
+ {
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
+
8367
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
8369
+ }
8370
+ else
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80978372 {
80988373 assert(!bump);
80998374 // if (bump)
....@@ -8104,19 +8379,23 @@
81048379 // }
81058380 // else
81068381 // {
8107
- texture = textures.get(tex);
8108
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
81098384 {
8110
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81118386 }
8387
+ else
8388
+ new Exception().printStackTrace();
81128389 // }
81138390 } else
8114
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81158392 {
81168393 assert(bump);
8117
- texture = textures.get(tex);
8118
- if (texture == null)
8119
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8394
+ // texturecache = textures.get(texname); // suspicious
8395
+ if (texturecache == null)
8396
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8397
+ else
8398
+ new Exception().printStackTrace();
81208399 } else
81218400 {
81228401 //if (tex.equals("IMMORTAL"))
....@@ -8124,11 +8403,13 @@
81248403 // texture = GetResourceTexture("default.png");
81258404 //} else
81268405 //{
8127
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
81288407 {
8129
- texture = textures.get(tex);
8130
- if (texture == null)
8131
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8408
+ // texturecache = textures.get(texname); // suspicious
8409
+ if (texturecache == null)
8410
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8411
+ else
8412
+ new Exception().printStackTrace();
81328413 } else
81338414 {
81348415 if (textureon)
....@@ -8153,7 +8434,7 @@
81538434 }
81548435
81558436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
81578438 cachename = texname;
81588439 else
81598440 processbump = false; // don't process bump map again
....@@ -8175,7 +8456,7 @@
81758456 }
81768457
81778458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
81798460 cachename = texname;
81808461 else
81818462 processbump = false; // don't process bump map again
....@@ -8187,19 +8468,19 @@
81878468 if (texturedata == null)
81888469 throw new Exception();
81898470
8190
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8471
+ texturecache = new CacheTexture(texturedata,resolution);
81918472 //texture = GetTexture(tex, bump);
81928473 }
81938474 }
81948475 //}
81958476 }
81968477
8197
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81988479 {
81998480 //return false;
82008481
82018482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8202
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82038484 {
82048485 // String ext = "_highres";
82058486 // if (REDUCETEXTURE)
....@@ -8216,52 +8497,17 @@
82168497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82178498 if (!cachefile.exists())
82188499 {
8219
- // cache to disk
8220
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8221
- //buffers[0].
8222
-
8223
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8224
- int[] pixels = new int[bytebuf.capacity()/3];
8225
-
8226
- // squared size heuristic...
8227
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
82288501 {
8229
- for (int i=pixels.length; --i>=0;)
8230
- {
8231
- int i3 = i*3;
8232
- pixels[i] = 0xFF;
8233
- pixels[i] <<= 8;
8234
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8235
- pixels[i] <<= 8;
8236
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8237
- pixels[i] <<= 8;
8238
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8239
- }
8240
-
8241
- /*
8242
- int r=0,g=0,b=0,a=0;
8243
- for (int i=0; i<width; i++)
8244
- for (int j=0; j<height; j++)
8245
- {
8246
- int index = j*width+i;
8247
- int p = pixels[index];
8248
- a = ((p>>24) & 0xFF);
8249
- r = ((p>>16) & 0xFF);
8250
- g = ((p>>8) & 0xFF);
8251
- b = (p & 0xFF);
8252
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8253
- }
8254
- /**/
8255
- int width = (int)Math.sqrt(pixels.length); // squared
8256
- int height = width;
8257
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8258
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
82598504 ImageWriter writer = null;
82608505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82618506 if (iter.hasNext()) {
82628507 writer = (ImageWriter)iter.next();
82638508 }
8264
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
82658511 try
82668512 {
82678513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8278,18 +8524,20 @@
82788524 }
82798525 }
82808526 }
8281
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
82828530 //System.out.println("Texture = " + tex);
8283
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
82848532 {
8285
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
82868534 thetex.texture.disable();
82878535 thetex.texture.dispose();
8288
- textures.remove(texname);
8536
+ textures.remove(tex);
82898537 }
82908538
8291
- texture.texturedata = texturedata;
8292
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
82938541
82948542 // newtex = true;
82958543 }
....@@ -8305,10 +8553,41 @@
83058553 }
83068554 }
83078555
8308
- return texture;
8556
+ return texturecache;
83098557 }
83108558
8311
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8559
+ static void EmbedTextures(cTexture tex)
8560
+ {
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
+ }
8574
+
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
+ }
8588
+ }
8589
+
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
83128591 {
83138592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83148593
....@@ -8326,21 +8605,21 @@
83268605 return texture!=null?texture.texture:null;
83278606 }
83288607
8329
- public com.sun.opengl.util.texture.TextureData GetTextureData(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
83308609 {
83318610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83328611
83338612 return texture!=null?texture.texturedata:null;
83348613 }
83358614
8336
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83378616 {
83388617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83398618 {
83408619 return false;
83418620 }
83428621
8343
- boolean newtex = false;
8622
+ //boolean newtex = false;
83448623
83458624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83468625
....@@ -8372,7 +8651,7 @@
83728651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83738652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83748653
8375
- return newtex;
8654
+ return true; // Warning: not used.
83768655 }
83778656
83788657 ShadowBuffer shadowPBuf;
....@@ -9210,11 +9489,35 @@
92109489 jy8[3] = 0.5f;
92119490 }
92129491
9213
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9492
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92149493 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92159494 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92169495 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92179496
9497
+ void ResetOptions()
9498
+ {
9499
+ options1[0] = 100;
9500
+ options1[1] = 0.025f;
9501
+ options1[2] = 0.01f;
9502
+ options1[3] = 0;
9503
+ options1[4] = 0;
9504
+
9505
+ options2[0] = 0;
9506
+ options2[1] = 0.75f;
9507
+ options2[2] = 0;
9508
+ options2[3] = 0;
9509
+
9510
+ options3[0] = 1;
9511
+ options3[1] = 1;
9512
+ options3[2] = 1;
9513
+ options3[3] = 0;
9514
+
9515
+ options4[0] = 1;
9516
+ options4[1] = 0;
9517
+ options4[2] = 1;
9518
+ options4[3] = 0;
9519
+ }
9520
+
92189521 static int imagecount = 0; // movie generation
92199522
92209523 static int jitter = 0;
....@@ -9310,8 +9613,8 @@
93109613 assert (parentcam != renderCamera);
93119614
93129615 if (renderCamera != lightCamera)
9313
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9314
- LA.matConcat(matrix, parentcam.toParent, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93159618
93169619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93179620
....@@ -9326,8 +9629,8 @@
93269629 LA.matCopy(renderCamera.fromScreen, matrix);
93279630
93289631 if (renderCamera != lightCamera)
9329
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9330
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93319634
93329635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93339636
....@@ -10325,6 +10628,7 @@
1032510628 ANTIALIAS = 0;
1032610629 //System.out.println("RESTART");
1032710630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
1032810632 }
1032910633 }
1033010634 }
....@@ -10392,13 +10696,14 @@
1039210696 ambientOcclusion = false;
1039310697 }
1039410698
10395
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039610701 {
1039710702 //if (RENDERSHADOW) // ?
1039810703 if (!IsFrozen())
1039910704 {
1040010705 // dec 2012
10401
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040210707 {
1040310708 Globals.framecount++;
1040410709 shadowbuffer.display();
....@@ -10525,8 +10830,8 @@
1052510830
1052610831 // if (parentcam != renderCamera) // not a light
1052710832 if (cam != lightCamera)
10528
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10529
- LA.matConcat(matrix, parentcam.toParent, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1053010835
1053110836 for (int j = 0; j < 4; j++)
1053210837 {
....@@ -10540,8 +10845,8 @@
1054010845
1054110846 // if (parentcam != renderCamera) // not a light
1054210847 if (cam != lightCamera)
10543
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10544
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054510850
1054610851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054710852
....@@ -10832,9 +11137,9 @@
1083211137
1083311138 gl.glMatrixMode(GL.GL_MODELVIEW);
1083411139
10835
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10836
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10837
-//gl.glEnable(gl.GL_MULTISAMPLE);
11140
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11141
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11142
+gl.glEnable(gl.GL_MULTISAMPLE);
1083811143 } else
1083911144 {
1084011145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10845,7 +11150,7 @@
1084511150 //System.out.println("BLENDING ON");
1084611151 gl.glEnable(GL.GL_BLEND);
1084711152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10848
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1084911154 gl.glMatrixMode(gl.GL_PROJECTION);
1085011155 gl.glLoadIdentity();
1085111156
....@@ -10934,8 +11239,8 @@
1093411239 System.err.println("parentcam != renderCamera");
1093511240
1093611241 // if (cam != lightCamera)
10937
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10938
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11242
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11243
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1093911244 }
1094011245
1094111246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10956,8 +11261,8 @@
1095611261 if (true) // TODO
1095711262 {
1095811263 if (cam != lightCamera)
10959
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10960
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11264
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11265
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1096111266 }
1096211267
1096311268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11302,15 +11607,36 @@
1130211607
1130311608 static boolean zoomonce = false;
1130411609
11610
+ static void CreateSelectedPoint()
11611
+ {
11612
+ if (selectedpoint == null)
11613
+ {
11614
+ debugpointG = new Sphere();
11615
+ debugpointP = new Sphere();
11616
+ debugpointC = new Sphere();
11617
+ debugpointR = new Sphere();
11618
+
11619
+ selectedpoint = new Superellipsoid();
11620
+
11621
+ for (int i=0; i<8; i++)
11622
+ {
11623
+ debugpoints[i] = new Sphere();
11624
+ }
11625
+ }
11626
+ }
11627
+
1130511628 void DrawObject(GL gl, boolean draw)
1130611629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
1130711633 //System.out.println("DRAW OBJECT " + mouseDown);
1130811634 // DrawMode() = SELECTION;
1130911635 //GL gl = getGL();
1131011636 if ((TRACK || SHADOWTRACK) || zoomonce)
1131111637 {
1131211638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11313
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1131411640 pingthread.StepToTarget(true); // true);
1131511641 // zoomonce = false;
1131611642 }
....@@ -11382,8 +11708,9 @@
1138211708
1138311709 if (DrawMode() == DEFAULT)
1138411710 {
11385
- if (DEBUG)
11711
+ if (Globals.DEBUG)
1138611712 {
11713
+ CreateSelectedPoint();
1138711714 float radius = 0.05f;
1138811715 if (selectedpoint.radius != radius)
1138911716 {
....@@ -11437,20 +11764,32 @@
1143711764 ReleaseTextures(DEFAULT_TEXTURES);
1143811765
1143911766 if (CLEANCACHE)
11440
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1144111768 {
11442
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1144311770
1144411771 // System.out.println("Texture --------- " + tex);
1144511772
11446
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1144711774 continue;
1144811775
11449
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1145011777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1145111779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11452
- textures.get(tex).texture.dispose();
11453
- 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
+ }
1145411793 }
1145511794 }
1145611795 }
....@@ -11552,7 +11891,7 @@
1155211891 return;
1155311892 }
1155411893
11555
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
1155611895
1155711896 GL gl = GetGL();
1155811897
....@@ -11869,8 +12208,8 @@
1186912208 //obj.TransformToWorld(light, light);
1187012209 for (int i = tp.size(); --i >= 0;)
1187112210 {
11872
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11873
- LA.xformPos(light, tp.get(i).toParent, light);
12211
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12212
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1187412213 }
1187512214
1187612215
....@@ -11887,8 +12226,8 @@
1188712226 parentcam = cameras[0];
1188812227 }
1188912228
11890
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11891
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12229
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12230
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1189212231
1189312232 LA.xformPos(light, renderCamera.toScreen, light);
1189412233
....@@ -13140,7 +13479,8 @@
1314013479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1314113480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1314213481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13143
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1314413484
1314513485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1314613486 // OUT : diff, spec
....@@ -13156,9 +13496,10 @@
1315613496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1315713497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1315813498 //"MOV " + dest + ".w," + "normal.z;" +
13159
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13160
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13161
- //"MOV " + dest + ".z," + "params2.w;" +
13499
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13500
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13501
+
13502
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1316213503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1316313504 "RCP " + dest + ".w," + dest + ".w;" +
1316413505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13663,6 +14004,7 @@
1366314004 else
1366414005 if (evt.getSource() == AAtimer)
1366514006 {
14007
+ Globals.TIMERRUNNING = false;
1366614008 if (mouseDown)
1366714009 {
1366814010 //new Exception().printStackTrace();
....@@ -13722,7 +14064,7 @@
1372214064
1372314065 // fev 2014???
1372414066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13725
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1372614068 pingthread.StepToTarget(true); // true);
1372714069 }
1372814070 // if (!LIVE)
....@@ -13737,6 +14079,7 @@
1373714079 return;
1373814080
1373914081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1374014083
1374114084 // waslive = LIVE;
1374214085 // LIVE = false;
....@@ -13809,9 +14152,12 @@
1380914152
1381014153 public void mouseDragged(MouseEvent e)
1381114154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
1381214157 //System.out.println("mouseDragged: " + e);
1381314158 if (isRenderer)
1381414159 movingcamera = true;
14160
+
1381514161 //if (drawing)
1381614162 //return;
1381714163 if ((e.getModifiersEx() & CTRL) != 0
....@@ -14072,12 +14418,12 @@
1407214418 void GoDown(int mod)
1407314419 {
1407414420 MODIFIERS |= COMMAND;
14075
- /*
14421
+ /**/
1407614422 if((mod&SHIFT) == SHIFT)
1407714423 manipCamera.RotatePosition(0, -speed);
1407814424 else
14079
- manipCamera.BackForth(0, -speed*delta, getWidth());
14080
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1408114427 if ((mod & SHIFT) == SHIFT)
1408214428 {
1408314429 mouseMode = mouseMode; // VR??
....@@ -14093,12 +14439,12 @@
1409314439 void GoUp(int mod)
1409414440 {
1409514441 MODIFIERS |= COMMAND;
14096
- /*
14442
+ /**/
1409714443 if((mod&SHIFT) == SHIFT)
1409814444 manipCamera.RotatePosition(0, speed);
1409914445 else
14100
- manipCamera.BackForth(0, speed*delta, getWidth());
14101
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1410214448 if ((mod & SHIFT) == SHIFT)
1410314449 {
1410414450 mouseMode = mouseMode;
....@@ -14114,12 +14460,12 @@
1411414460 void GoLeft(int mod)
1411514461 {
1411614462 MODIFIERS |= COMMAND;
14117
- /*
14463
+ /**/
1411814464 if((mod&SHIFT) == SHIFT)
14119
- manipCamera.RotatePosition(speed, 0);
14120
- else
1412114465 manipCamera.Translate(speed*delta, 0, getWidth());
14122
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1412314469 if ((mod & SHIFT) == SHIFT)
1412414470 {
1412514471 mouseMode = mouseMode;
....@@ -14135,12 +14481,12 @@
1413514481 void GoRight(int mod)
1413614482 {
1413714483 MODIFIERS |= COMMAND;
14138
- /*
14484
+ /**/
1413914485 if((mod&SHIFT) == SHIFT)
14140
- manipCamera.RotatePosition(-speed, 0);
14141
- else
1414214486 manipCamera.Translate(-speed*delta, 0, getWidth());
14143
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1414414490 if ((mod & SHIFT) == SHIFT)
1414514491 {
1414614492 mouseMode = mouseMode;
....@@ -14197,7 +14543,8 @@
1419714543 info.camera = renderCamera;
1419814544 info.x = x;
1419914545 info.y = y;
14200
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1420114548 } else
1420214549 {
1420314550 if (x < startX)
....@@ -14361,7 +14708,9 @@
1436114708 ci.camera = renderCamera;
1436214709 if (!isRenderer)
1436314710 {
14364
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1436514714 {
1436614715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1436714716 } else
....@@ -14373,8 +14722,11 @@
1437314722
1437414723 public void mouseReleased(MouseEvent e)
1437514724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1437614727 movingcamera = false;
14377
- X = Y = 0;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1437814730 //System.out.println("mouseReleased: " + e);
1437914731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1438014732 }
....@@ -14630,7 +14982,8 @@
1463014982 // break;
1463114983 case 'T':
1463214984 CACHETEXTURE ^= true;
14633
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1463414987 // repaint();
1463514988 break;
1463614989 case 'Y':
....@@ -14715,7 +15068,9 @@
1471515068 case 'E' : COMPACT ^= true;
1471615069 repaint();
1471715070 break;
14718
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1471915074 repaint();
1472015075 break;
1472115076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14740,8 +15095,8 @@
1474015095 RevertCamera();
1474115096 repaint();
1474215097 break;
14743
- case 'L':
1474415098 case 'l':
15099
+ //case 'L':
1474515100 if (lightMode)
1474615101 {
1474715102 lightMode = false;
....@@ -14884,9 +15239,9 @@
1488415239 case '_':
1488515240 kompactbit = 5;
1488615241 break;
14887
- case '+':
14888
- kompactbit = 6;
14889
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1489015245 case ' ':
1489115246 lightMode ^= true;
1489215247 Globals.lighttouched = true;
....@@ -14898,6 +15253,7 @@
1489815253 case ESC:
1489915254 RENDERPROGRAM += 1;
1490015255 RENDERPROGRAM %= 3;
15256
+
1490115257 repaint();
1490215258 break;
1490315259 case 'Z':
....@@ -14937,8 +15293,9 @@
1493715293 case DELETE:
1493815294 ClearSelection();
1493915295 break;
14940
- /*
1494115296 case '+':
15297
+
15298
+ /*
1494215299 //fontsize += 1;
1494315300 bbzoom *= 2;
1494415301 repaint();
....@@ -14955,17 +15312,17 @@
1495515312 case '=':
1495615313 IncDepth();
1495715314 //fontsize += 1;
14958
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1495915316 maskbit = 6;
1496015317 break;
1496115318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1496215319 DecDepth();
1496315320 maskbit = 5;
1496415321 //if(fontsize > 1) fontsize -= 1;
14965
- if (object.editWindow == null)
14966
- new Exception().printStackTrace();
14967
- else
14968
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1496915326 break;
1497015327 case '{':
1497115328 manipCamera.shaper_fovy /= 1.1;
....@@ -15189,7 +15546,7 @@
1518915546 }
1519015547 */
1519115548
15192
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1519315550 }
1519415551
1519515552 void SelectParent()
....@@ -15206,10 +15563,10 @@
1520615563 {
1520715564 //selectees.remove(i);
1520815565 System.out.println("select parent of " + elem);
15209
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1521015567 } else
1521115568 {
15212
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1521315570 }
1521415571
1521515572 first = false;
....@@ -15251,12 +15608,12 @@
1525115608 for (int j = 0; j < group.children.size(); j++)
1525215609 {
1525315610 elem = (Object3D) group.children.elementAt(j);
15254
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1525515612 first = false;
1525615613 }
1525715614 } else
1525815615 {
15259
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1526015617 }
1526115618
1526215619 first = false;
....@@ -15267,21 +15624,21 @@
1526715624 {
1526815625 //Composite group = (Composite) object;
1526915626 Object3D group = object;
15270
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1527115628 }
1527215629
1527315630 void ResetTransform(int mask)
1527415631 {
1527515632 //Composite group = (Composite) object;
1527615633 Object3D group = object;
15277
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1527815635 }
1527915636
1528015637 void FlipTransform()
1528115638 {
1528215639 //Composite group = (Composite) object;
1528315640 Object3D group = object;
15284
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1528515642 // group.editWindow.ReduceMesh(true);
1528615643 }
1528715644
....@@ -15289,7 +15646,7 @@
1528915646 {
1529015647 //Composite group = (Composite) object;
1529115648 Object3D group = object;
15292
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1529315650 // group.editWindow.ReduceMesh(true);
1529415651 }
1529515652
....@@ -15297,7 +15654,7 @@
1529715654 {
1529815655 //Composite group = (Composite) object;
1529915656 Object3D group = object;
15300
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1530115658 }
1530215659
1530315660 void IncDepth()
....@@ -15473,6 +15830,7 @@
1547315830 info.bounds.y += (height - desired) / 2;
1547415831 }
1547515832 }
15833
+
1547615834 info.g = gr;
1547715835 info.camera = renderCamera;
1547815836 /*
....@@ -15482,18 +15840,44 @@
1548215840 */
1548315841 if (!isRenderer)
1548415842 {
15485
- object.drawEditHandles(info, 0);
15486
-
15487
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
1548815846 {
15489
- switch (object.selection.get(0).hitSomething)
15847
+ int hitSomething = object.selection.get(0).hitSomething;
15848
+
15849
+ info.DX = 0;
15850
+ info.DY = 0;
15851
+ info.W = 1;
15852
+ if (hitSomething == Object3D.hitCenter)
1549015853 {
15491
- case Object3D.hitCenter: gr.setColor(Color.pink); break;
15492
- case Object3D.hitRotate: gr.setColor(Color.green); break;
15493
- case Object3D.hitScale: gr.setColor(Color.cyan); break;
15854
+ info.DX = X;
15855
+ if (X != 0)
15856
+ info.DX -= info.bounds.width/2;
15857
+
15858
+ info.DY = Y;
15859
+ if (Y != 0)
15860
+ info.DY -= info.bounds.height/2;
1549415861 }
15495
-
15496
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15862
+
15863
+ object.drawEditHandles(info, 0);
15864
+
15865
+ if (drag && (X != 0 || Y != 0))
15866
+ {
15867
+ switch (hitSomething)
15868
+ {
15869
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15870
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15871
+ break;
15872
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15873
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15874
+ break;
15875
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15876
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15877
+ break;
15878
+ }
15879
+
15880
+ }
1549715881 }
1549815882 }
1549915883 }
....@@ -15911,7 +16295,7 @@
1591116295 Object3D object;
1591216296 static Object3D trackedobject;
1591316297 Camera renderCamera; // Light or Eye (or Occlusion)
15914
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1591516299 /*static*/ Camera eyeCamera;
1591616300 /*static*/ Camera lightCamera;
1591716301 int cameracount;
....@@ -16196,16 +16580,16 @@
1619616580 cStatic.objectstack[materialdepth++] = checker;
1619716581 //System.out.println("material " + material);
1619816582 //Applet3D.tracein(this, selected);
16199
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1620016584
1620116585 //checker.GetMaterial().Draw(this, false); // true);
16202
- DrawMaterial(checker.GetMaterial(), false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1620316587
1620416588 materialdepth -= 1;
1620516589 if (materialdepth > 0)
1620616590 {
16207
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16208
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16591
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16592
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1620916593 }
1621016594 //checker.GetMaterial().opacity = 1f;
1621116595 ////checker.GetMaterial().ambient = 1f;
....@@ -16291,6 +16675,14 @@
1629116675 }
1629216676 }
1629316677
16678
+ private Object3D GetFolder()
16679
+ {
16680
+ Object3D folder = object.GetWindow().copy;
16681
+ if (object.GetWindow().copy.selection.Size() > 0)
16682
+ folder = object.GetWindow().copy.selection.elementAt(0);
16683
+ return folder;
16684
+ }
16685
+
1629416686 class SelectBuffer implements GLEventListener
1629516687 {
1629616688
....@@ -16370,6 +16762,17 @@
1637016762
1637116763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1637216764
16765
+ if (PAINTMODE)
16766
+ {
16767
+ if (object.GetWindow().copy.selection.Size() > 0)
16768
+ {
16769
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16770
+
16771
+ // Make what you paint not selectable.
16772
+ paintobj.ResetSelectable();
16773
+ }
16774
+ }
16775
+
1637316776 //int tmp = selection_view;
1637416777 //selection_view = -1;
1637516778 int temp = DrawMode();
....@@ -16381,6 +16784,17 @@
1638116784 // temp = DEFAULT; // patch for selection debug
1638216785 Globals.drawMode = temp; // WARNING
1638316786
16787
+ if (PAINTMODE)
16788
+ {
16789
+ if (object.GetWindow().copy.selection.Size() > 0)
16790
+ {
16791
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16792
+
16793
+ // Revert.
16794
+ paintobj.RestoreSelectable();
16795
+ }
16796
+ }
16797
+
1638416798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1638516799
1638616800 // trying different ways of getting the depth info over
....@@ -16428,6 +16842,8 @@
1642816842 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1642916843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1643016844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16845
+
16846
+ CreateSelectedPoint();
1643116847
1643216848 // Will fit the mesh !!!
1643316849 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16482,29 +16898,31 @@
1648216898 }
1648316899
1648416900 if (!movingcamera && !PAINTMODE)
16485
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1648616902
16487
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16903
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1648816904 {
16489
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16905
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1649016906
16491
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1649216910
16493
- group.CreateMaterial(); // use a void leaf to select instances
16494
-
16495
- group.add(paintobj); // link
16496
-
16497
- object.editWindow.SnapObject(group);
16498
-
16499
- Object3D folder = object.editWindow.copy;
16500
-
16501
- if (object.editWindow.copy.selection.Size() > 0)
16502
- folder = object.editWindow.copy.selection.elementAt(0);
16503
-
16504
- folder.add(group);
16505
-
16506
- object.editWindow.ResetModel();
16507
- object.editWindow.refreshContents();
16911
+ Object3D inst = new Object3D("inst" + paintcount++);
16912
+
16913
+ inst.CreateMaterial(); // use a void leaf to select instances
16914
+
16915
+ inst.add(paintobj); // link
16916
+
16917
+ object.GetWindow().SnapObject(inst);
16918
+
16919
+ Object3D folder = paintFolder; // GetFolder();
16920
+
16921
+ folder.add(inst);
16922
+
16923
+ object.GetWindow().ResetModel();
16924
+ object.GetWindow().refreshContents();
16925
+ }
1650816926 }
1650916927 else
1651016928 paintcount = 0;
....@@ -16543,6 +16961,11 @@
1654316961 //System.out.println("objects[color] = " + objects[color]);
1654416962 //objects[color].Select();
1654516963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1654616969 object.Select(color, deselect);
1654716970 }
1654816971
....@@ -17068,23 +17491,15 @@
1706817491 int AAbuffersize = 0;
1706917492
1707017493 //double[] selectedpoint = new double[3];
17071
- static Superellipsoid selectedpoint = new Superellipsoid();
17494
+ static Superellipsoid selectedpoint;
1707217495 static Sphere previousselectedpoint = null;
17073
- static Sphere debugpointG = new Sphere();
17074
- static Sphere debugpointP = new Sphere();
17075
- static Sphere debugpointC = new Sphere();
17076
- static Sphere debugpointR = new Sphere();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1707717500
1707817501 static Sphere debugpoints[] = new Sphere[8];
1707917502
17080
- static
17081
- {
17082
- for (int i=0; i<8; i++)
17083
- {
17084
- debugpoints[i] = new Sphere();
17085
- }
17086
- }
17087
-
1708817503 static void InitPoints(float radius)
1708917504 {
1709017505 for (int i=0; i<8; i++)