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;
....@@ -56,14 +88,12 @@
5688 static int CURRENTANTIALIAS = 0; // 1;
5789 /*static*/ boolean RENDERSHADOW = true;
5890 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6191
6292 boolean DISPLAYTEXT = false;
6393 //boolean REDUCETEXTURE = true;
6494 boolean CACHETEXTURE = true;
6595 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
6797 boolean COMPRESSTEXTURE = false;
6898 boolean KOMPACTTEXTURE = false; // true;
6999 boolean RESIZETEXTURE = false;
....@@ -86,7 +116,7 @@
86116 static boolean FULLSCREEN = false;
87117 static boolean SUPPORT = true;
88118 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
119
+static boolean FAST = false;
90120 static boolean SLOWPOSE = false;
91121 static boolean FOOTCONTACT = true;
92122
....@@ -108,7 +138,7 @@
108138 static boolean OEIL = true;
109139 static boolean OEILONCE = false; // do oeilon then oeiloff
110140 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
141
+static boolean SWITCH = true; // false;
112142 static boolean HANDLES = false; // selection doesn't work!!
113143 static boolean PAINTMODE = false;
114144
....@@ -151,6 +181,8 @@
151181 defaultcaps.setAccumBlueBits(16);
152182 defaultcaps.setAccumAlphaBits(16);
153183 }
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154186
155187 void SetAsGLRenderer(boolean b)
156188 {
....@@ -327,7 +359,7 @@
327359 cStatic.objectstack[materialdepth++] = obj;
328360 //System.out.println("material " + material);
329361 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
362
+ //display.vector2buffer = obj.projectedVertices;
331363 if (obj instanceof Camera)
332364 {
333365 display.options1[0] = material.shift;
....@@ -336,14 +368,28 @@
336368 display.options1[2] = material.shadowbias;
337369 display.options1[3] = material.aniso;
338370 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]);
339376 display.options2[0] = material.opacity;
340377 display.options2[1] = material.diffuse;
341378 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]);
342382
343383 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]);
344387 display.options4[0] = material.cameralight/0.2f;
345388 display.options4[1] = material.subsurface;
346389 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]);
347393
348394 // if (display.CURRENTANTIALIAS > 0)
349395 // display.options3[3] /= 4;
....@@ -359,7 +405,7 @@
359405 /**/
360406 } else
361407 {
362
- DrawMaterial(material, selected);
408
+ DrawMaterial(material, selected, obj.projectedVertices);
363409 }
364410 } else
365411 {
....@@ -383,8 +429,8 @@
383429 cStatic.objectstack[materialdepth++] = obj;
384430 //System.out.println("material " + material);
385431 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388434 }
389435 }
390436
....@@ -401,8 +447,8 @@
401447 materialdepth -= 1;
402448 if (materialdepth > 0)
403449 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- 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);
406452 }
407453 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408454 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +468,8 @@
422468 materialdepth -= 1;
423469 if (materialdepth > 0)
424470 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- 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);
427473 }
428474 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429475 //else
....@@ -464,10 +510,12 @@
464510 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465511 {
466512 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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
+ ;
468516 if (!hasnorm)
469517 {
470
- // System.out.println("FUCK!!");
518
+ // System.out.println("Mesh normal");
471519 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472520 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473521 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1240,12 @@
11921240 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931241 }
11941242 }
1243
+
11951244 if (flipV)
11961245 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971246 else
11981247 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
11991249 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001250 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011251
....@@ -1215,10 +1265,12 @@
12151265 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161266 }
12171267 }
1268
+
12181269 if (flipV)
12191270 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201271 else
12211272 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
12221274 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231275 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241276
....@@ -1246,8 +1298,10 @@
12461298 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471299 else
12481300 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
12491302 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501303 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
12511305 count2 += 2;
12521306 count3 += 3;
12531307 }
....@@ -1603,7 +1657,7 @@
16031657 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041658 }
16051659
1606
- void DrawMaterial(cMaterial material, boolean selected)
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071661 {
16081662 CameraPane display = this;
16091663 //new Exception().printStackTrace();
....@@ -1630,7 +1684,7 @@
16301684
16311685 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321686
1633
- float[] colorV = GrafreeD.colorV;
1687
+ float[] colorV = Grafreed.colorV;
16341688
16351689 /**/
16361690 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1692,7 @@
16381692 colorV[0] = display.modelParams0[0] * material.diffuse;
16391693 colorV[1] = display.modelParams0[1] * material.diffuse;
16401694 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1695
+ colorV[3] = 1; // material.opacity;
16421696
16431697 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441698 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1800,9 @@
17461800 display.modelParams7[2] = 0;
17471801 display.modelParams7[3] = 0;
17481802
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501804
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521806 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531807 {
17541808 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1944,7 @@
18901944 void PushMatrix(double[][] matrix)
18911945 {
18921946 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
18941948 }
18951949
18961950 void PushMatrix()
....@@ -2044,7 +2098,7 @@
20442098 //System.err.println("Oeil on");
20452099 OEIL = true;
20462100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482102 //pingthread.StepToTarget(true);
20492103 }
20502104
....@@ -2142,7 +2196,7 @@
21422196 System.err.println("LIVE = " + Globals.isLIVE());
21432197
21442198 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2199
+ Grafreed.savesound = true; // wav.save();
21462200 // else
21472201 repaint(); // start loop // may 2013
21482202 }
....@@ -2259,7 +2313,7 @@
22592313
22602314 void ToggleDebug()
22612315 {
2262
- DEBUG ^= true;
2316
+ Globals.DEBUG ^= true;
22632317 }
22642318
22652319 void ToggleLookAt()
....@@ -2267,9 +2321,9 @@
22672321 LOOKAT ^= true;
22682322 }
22692323
2270
- void ToggleRandom()
2324
+ void ToggleSwitch()
22712325 {
2272
- RANDOM ^= true;
2326
+ SWITCH ^= true;
22732327 }
22742328
22752329 void ToggleHandles()
....@@ -2277,10 +2331,17 @@
22772331 HANDLES ^= true;
22782332 }
22792333
2334
+ Object3D paintFolder;
2335
+
22802336 void TogglePaint()
22812337 {
22822338 PAINTMODE ^= true;
22832339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
22842345 }
22852346
22862347 void SwapCamera(int a, int b)
....@@ -2376,7 +2437,22 @@
23762437 {
23772438 return currentGL;
23782439 }
2379
-
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
+
23802456 /**/
23812457 class CacheTexture
23822458 {
....@@ -2385,28 +2461,31 @@
23852461
23862462 int resolution;
23872463
2388
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23892465 {
2390
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
23912468 resolution = res;
23922469 }
23932470 }
23942471 /**/
23952472
23962473 // TEXTURE static Texture texture;
2397
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2398
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2399
- 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
+
24002479 int pigmentdepth = 0;
24012480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022481 int bumpdepth = 0;
24032482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24042483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24052484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2406
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24072486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24082487
2409
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24102489 {
24112490 TextureData texturedata = null;
24122491
....@@ -2425,13 +2504,34 @@
24252504 if (bump)
24262505 texturedata = ConvertBump(texturedata, false);
24272506
2428
- com.sun.opengl.util.texture.Texture texture =
2429
- 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);
24302509
2431
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2432
- 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);
24332512
2434
- 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;
24352535 }
24362536
24372537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3504,6 +3604,8 @@
35043604
35053605 System.out.println("LOADING TEXTURE : " + name);
35063606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
35073609 //
35083610 if (false) // compressbit > 0)
35093611 {
....@@ -4208,6 +4310,7 @@
42084310
42094311 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104312 {
4313
+ new Exception().printStackTrace();
42114314 System.exit(0);
42124315 com.sun.opengl.util.texture.Texture texture = null;
42134316
....@@ -7901,7 +8004,7 @@
79018004 String pigment = Object3D.GetPigment(tex);
79028005 String bump = Object3D.GetBump(tex);
79038006
7904
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79058008 {
79068009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79078010 // System.out.println("; bump = " + bump);
....@@ -7916,11 +8019,69 @@
79168019 pigment = null;
79178020 }
79188021
7919
- ReleaseTexture(bump, true);
7920
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79218024 }
79228025
7923
- 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)
79248085 {
79258086 if (// DrawMode() != 0 || /*tex == null ||*/
79268087 ambientOcclusion ) // || !textureon)
....@@ -7931,7 +8092,7 @@
79318092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79328093
79338094 if (tex != null)
7934
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79358096
79368097 // //assert( texture != null );
79378098 // if (texture == null)
....@@ -8023,7 +8184,55 @@
80238184 }
80248185 }
80258186
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8187
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8188
+ {
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
80278236 {
80288237 if (// DrawMode() != 0 || /*tex == null ||*/
80298238 ambientOcclusion ) // || !textureon)
....@@ -8034,17 +8243,47 @@
80348243 if (tex == null)
80358244 {
80368245 BindTexture(null,false,resolution);
8037
- BindTexture(null,true,resolution);
80388246 return;
80398247 }
80408248
80418249 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
+
80428282 String bump = Object3D.GetBump(tex);
80438283
8044
- usedtextures.put(pigment, pigment);
8045
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
80468285
8047
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80488287 {
80498288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80508289 // System.out.println("; bump = " + bump);
....@@ -8054,43 +8293,82 @@
80548293 {
80558294 bump = null;
80568295 }
8057
- if (pigment.equals(""))
8058
- {
8059
- pigment = null;
8060
- }
80618296
8062
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8063
- BindTexture(pigment, false, resolution);
80648297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8065
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
80668299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8067
-
8068
- return; // true;
80698300 }
80708301
8071
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8302
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8303
+
8304
+ private boolean FileExists(String tex)
80728305 {
8073
- 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;
80748325
80758326 if (tex != null)
80768327 {
8077
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80788330
8079
- String[] split = tex.split("Textures");
8080
- if (split.length > 1)
8081
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8082
- else
8083
- if (!texname.startsWith("/"))
8084
- texname = "/Users/nbriere/Textures/" + texname;
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
8335
+
8336
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8337
+
8338
+// String[] split = tex.split("Textures");
8339
+// if (split.length > 1)
8340
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8341
+// else
8342
+// if (!texname.startsWith("/"))
8343
+// texname = "/Users/nbriere/Textures/" + texname;
8344
+ if (!FileExists(texname))
8345
+ {
8346
+ texname = fallbackTextureName;
8347
+ }
80858348
80868349 if (CACHETEXTURE)
8087
- texture = textures.get(texname); // TEXTURE CACHE
8088
-
8089
- TextureData texturedata = null;
8090
-
8091
- if (texture == null || texture.resolution < resolution)
80928350 {
8093
- 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(""))
80948372 {
80958373 assert(!bump);
80968374 // if (bump)
....@@ -8101,19 +8379,23 @@
81018379 // }
81028380 // else
81038381 // {
8104
- texture = textures.get(tex);
8105
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
81068384 {
8107
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81088386 }
8387
+ else
8388
+ new Exception().printStackTrace();
81098389 // }
81108390 } else
8111
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81128392 {
81138393 assert(bump);
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- 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();
81178399 } else
81188400 {
81198401 //if (tex.equals("IMMORTAL"))
....@@ -8121,11 +8403,13 @@
81218403 // texture = GetResourceTexture("default.png");
81228404 //} else
81238405 //{
8124
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
81258407 {
8126
- texture = textures.get(tex);
8127
- if (texture == null)
8128
- 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();
81298413 } else
81308414 {
81318415 if (textureon)
....@@ -8150,7 +8434,7 @@
81508434 }
81518435
81528436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
81548438 cachename = texname;
81558439 else
81568440 processbump = false; // don't process bump map again
....@@ -8172,7 +8456,7 @@
81728456 }
81738457
81748458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
81768460 cachename = texname;
81778461 else
81788462 processbump = false; // don't process bump map again
....@@ -8181,20 +8465,22 @@
81818465 texturedata = GetFileTexture(cachename, processbump, resolution);
81828466
81838467
8184
- if (texturedata != null)
8185
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8468
+ if (texturedata == null)
8469
+ throw new Exception();
8470
+
8471
+ texturecache = new CacheTexture(texturedata,resolution);
81868472 //texture = GetTexture(tex, bump);
81878473 }
81888474 }
81898475 //}
81908476 }
81918477
8192
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81938479 {
81948480 //return false;
81958481
81968482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8197
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81988484 {
81998485 // String ext = "_highres";
82008486 // if (REDUCETEXTURE)
....@@ -8211,52 +8497,17 @@
82118497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82128498 if (!cachefile.exists())
82138499 {
8214
- // cache to disk
8215
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8216
- //buffers[0].
8217
-
8218
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8219
- int[] pixels = new int[bytebuf.capacity()/3];
8220
-
8221
- // squared size heuristic...
8222
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
82238501 {
8224
- for (int i=pixels.length; --i>=0;)
8225
- {
8226
- int i3 = i*3;
8227
- pixels[i] = 0xFF;
8228
- pixels[i] <<= 8;
8229
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8230
- pixels[i] <<= 8;
8231
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8232
- pixels[i] <<= 8;
8233
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8234
- }
8235
-
8236
- /*
8237
- int r=0,g=0,b=0,a=0;
8238
- for (int i=0; i<width; i++)
8239
- for (int j=0; j<height; j++)
8240
- {
8241
- int index = j*width+i;
8242
- int p = pixels[index];
8243
- a = ((p>>24) & 0xFF);
8244
- r = ((p>>16) & 0xFF);
8245
- g = ((p>>8) & 0xFF);
8246
- b = (p & 0xFF);
8247
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8248
- }
8249
- /**/
8250
- int width = (int)Math.sqrt(pixels.length); // squared
8251
- int height = width;
8252
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8253
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
82548504 ImageWriter writer = null;
82558505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82568506 if (iter.hasNext()) {
82578507 writer = (ImageWriter)iter.next();
82588508 }
8259
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
82608511 try
82618512 {
82628513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8273,18 +8524,20 @@
82738524 }
82748525 }
82758526 }
8276
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
82778530 //System.out.println("Texture = " + tex);
8278
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
82798532 {
8280
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
82818534 thetex.texture.disable();
82828535 thetex.texture.dispose();
8283
- textures.remove(texname);
8536
+ textures.remove(tex);
82848537 }
82858538
8286
- texture.texturedata = texturedata;
8287
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
82888541
82898542 // newtex = true;
82908543 }
....@@ -8300,10 +8553,41 @@
83008553 }
83018554 }
83028555
8303
- return texture;
8556
+ return texturecache;
83048557 }
83058558
8306
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
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
83078591 {
83088592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83098593
....@@ -8321,21 +8605,21 @@
83218605 return texture!=null?texture.texture:null;
83228606 }
83238607
8324
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
83258609 {
83268610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83278611
83288612 return texture!=null?texture.texturedata:null;
83298613 }
83308614
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83328616 {
83338617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348618 {
83358619 return false;
83368620 }
83378621
8338
- boolean newtex = false;
8622
+ //boolean newtex = false;
83398623
83408624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83418625
....@@ -8367,7 +8651,7 @@
83678651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83688652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83698653
8370
- return newtex;
8654
+ return true; // Warning: not used.
83718655 }
83728656
83738657 ShadowBuffer shadowPBuf;
....@@ -9205,11 +9489,35 @@
92059489 jy8[3] = 0.5f;
92069490 }
92079491
9208
- 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
92099493 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92109494 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92119495 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92129496
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
+
92139521 static int imagecount = 0; // movie generation
92149522
92159523 static int jitter = 0;
....@@ -9305,8 +9613,8 @@
93059613 assert (parentcam != renderCamera);
93069614
93079615 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109618
93119619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129620
....@@ -9321,8 +9629,8 @@
93219629 LA.matCopy(renderCamera.fromScreen, matrix);
93229630
93239631 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269634
93279635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289636
....@@ -9394,7 +9702,7 @@
93949702 //gl.glFlush();
93959703 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969704
9397
- if (ANIMATION && ABORTED)
9705
+ if (Globals.ANIMATION && ABORTED)
93989706 {
93999707 System.err.println(" ABORTED FRAME");
94009708 break;
....@@ -9424,7 +9732,7 @@
94249732 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259733
94269734 // save image
9427
- if (ANIMATION && !ABORTED)
9735
+ if (Globals.ANIMATION && !ABORTED)
94289736 {
94299737 VPwidth = viewport[2];
94309738 VPheight = viewport[3];
....@@ -9535,11 +9843,11 @@
95359843
95369844 // imagecount++;
95379845
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9846
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399847
95409848 if (!BOXMODE)
95419849 {
9542
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9850
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95439851 }
95449852
95459853 if (!BOXMODE)
....@@ -9577,7 +9885,7 @@
95779885 ABORTED = false;
95789886 }
95799887 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9888
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819889
95829890 if (false)
95839891 {
....@@ -10240,11 +10548,11 @@
1024010548
1024110549 public void display(GLAutoDrawable drawable)
1024210550 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10551
+ if (Grafreed.savesound && Grafreed.hassound)
1024410552 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10553
+ Grafreed.wav.save();
10554
+ Grafreed.savesound = false;
10555
+ Grafreed.hassound = false;
1024810556 }
1024910557 // if (DEBUG_SELECTION)
1025010558 // {
....@@ -10320,6 +10628,7 @@
1032010628 ANTIALIAS = 0;
1032110629 //System.out.println("RESTART");
1032210630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
1032310632 }
1032410633 }
1032510634 }
....@@ -10374,7 +10683,7 @@
1037410683 Object3D theobject = object;
1037510684 Object3D theparent = object.parent;
1037610685 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10686
+ object = (Object3D)Grafreed.clone(object);
1037810687 object.Stripify();
1037910688 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010689 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10696,14 @@
1038710696 ambientOcclusion = false;
1038810697 }
1038910698
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110701 {
1039210702 //if (RENDERSHADOW) // ?
1039310703 if (!IsFrozen())
1039410704 {
1039510705 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710707 {
1039810708 Globals.framecount++;
1039910709 shadowbuffer.display();
....@@ -10520,8 +10830,8 @@
1052010830
1052110831 // if (parentcam != renderCamera) // not a light
1052210832 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510835
1052610836 for (int j = 0; j < 4; j++)
1052710837 {
....@@ -10535,8 +10845,8 @@
1053510845
1053610846 // if (parentcam != renderCamera) // not a light
1053710847 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010850
1054110851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210852
....@@ -10795,7 +11105,16 @@
1079511105 // Bump noise
1079611106 gl.glActiveTexture(GL.GL_TEXTURE6);
1079711107 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- BindTexture(NOISE_TEXTURE, false, 2);
11108
+
11109
+ try
11110
+ {
11111
+ BindTexture(NOISE_TEXTURE, false, 2);
11112
+ }
11113
+ catch (Exception e)
11114
+ {
11115
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11116
+ }
11117
+
1079911118
1080011119 gl.glActiveTexture(GL.GL_TEXTURE0);
1080111120 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10818,9 +11137,9 @@
1081811137
1081911138 gl.glMatrixMode(GL.GL_MODELVIEW);
1082011139
10821
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10822
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10823
-//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);
1082411143 } else
1082511144 {
1082611145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10831,7 +11150,7 @@
1083111150 //System.out.println("BLENDING ON");
1083211151 gl.glEnable(GL.GL_BLEND);
1083311152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10834
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083511154 gl.glMatrixMode(gl.GL_PROJECTION);
1083611155 gl.glLoadIdentity();
1083711156
....@@ -10920,8 +11239,8 @@
1092011239 System.err.println("parentcam != renderCamera");
1092111240
1092211241 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- 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
1092511244 }
1092611245
1092711246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11261,8 @@
1094211261 if (true) // TODO
1094311262 {
1094411263 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- 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
1094711266 }
1094811267
1094911268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11578,14 @@
1125911578 {
1126011579 renderpass++;
1126111580 // System.out.println("Draw object... ");
11581
+ STEP = 1;
1126211582 if (FAST) // in case there is no script
11263
- STEP = 16;
11583
+ STEP = 8;
11584
+
11585
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11586
+ {
11587
+ STEP *= 4;
11588
+ }
1126411589
1126511590 //object.FullInvariants();
1126611591
....@@ -11274,23 +11599,44 @@
1127411599 e.printStackTrace();
1127511600 }
1127611601
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11602
+ if (Grafreed.RENDERME > 0)
11603
+ Grafreed.RENDERME--; // mechante magouille
1127911604
1128011605 Globals.ONESTEP = false;
1128111606 }
1128211607
1128311608 static boolean zoomonce = false;
1128411609
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
+
1128511628 void DrawObject(GL gl, boolean draw)
1128611629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
1128711633 //System.out.println("DRAW OBJECT " + mouseDown);
1128811634 // DrawMode() = SELECTION;
1128911635 //GL gl = getGL();
1129011636 if ((TRACK || SHADOWTRACK) || zoomonce)
1129111637 {
1129211638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11293
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129411640 pingthread.StepToTarget(true); // true);
1129511641 // zoomonce = false;
1129611642 }
....@@ -11345,7 +11691,14 @@
1134511691
1134611692 usedtextures.clear();
1134711693
11348
- BindTextures(DEFAULT_TEXTURES, 2);
11694
+ try
11695
+ {
11696
+ BindTextures(DEFAULT_TEXTURES, 2);
11697
+ }
11698
+ catch (Exception e)
11699
+ {
11700
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11701
+ }
1134911702 }
1135011703 //System.out.println("--> " + stackdepth);
1135111704 // GrafreeD.traceon();
....@@ -11355,8 +11708,9 @@
1135511708
1135611709 if (DrawMode() == DEFAULT)
1135711710 {
11358
- if (DEBUG)
11711
+ if (Globals.DEBUG)
1135911712 {
11713
+ CreateSelectedPoint();
1136011714 float radius = 0.05f;
1136111715 if (selectedpoint.radius != radius)
1136211716 {
....@@ -11410,20 +11764,32 @@
1141011764 ReleaseTextures(DEFAULT_TEXTURES);
1141111765
1141211766 if (CLEANCACHE)
11413
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1141411768 {
11415
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1141611770
1141711771 // System.out.println("Texture --------- " + tex);
1141811772
11419
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1142011774 continue;
1142111775
11422
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1142311777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1142411779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11425
- textures.get(tex).texture.dispose();
11426
- 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
+ }
1142711793 }
1142811794 }
1142911795 }
....@@ -11436,7 +11802,14 @@
1143611802 if (checker != null && DrawMode() == DEFAULT)
1143711803 {
1143811804 //BindTexture(IMMORTAL_TEXTURE);
11439
- BindTextures(checker.GetTextures(), checker.texres);
11805
+ try
11806
+ {
11807
+ BindTextures(checker.GetTextures(), checker.texres);
11808
+ }
11809
+ catch (Exception e)
11810
+ {
11811
+ System.err.println("FAILED: " + checker.GetTextures());
11812
+ }
1144011813 // NEAREST
1144111814 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211815 DrawChecker(gl);
....@@ -11518,7 +11891,7 @@
1151811891 return;
1151911892 }
1152011893
11521
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
1152211895
1152311896 GL gl = GetGL();
1152411897
....@@ -11835,8 +12208,8 @@
1183512208 //obj.TransformToWorld(light, light);
1183612209 for (int i = tp.size(); --i >= 0;)
1183712210 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- 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);
1184012213 }
1184112214
1184212215
....@@ -11853,8 +12226,8 @@
1185312226 parentcam = cameras[0];
1185412227 }
1185512228
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- 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
1185812231
1185912232 LA.xformPos(light, renderCamera.toScreen, light);
1186012233
....@@ -12468,8 +12841,8 @@
1246812841
1246912842 // display shadow only (bump == 0)
1247012843 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12844
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12845
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312846 "SUB temp.y, one.x, temp.z;" +
1247412847 "MUL temp.x, temp.x, temp.y;" +
1247512848 "KIL temp.x;" +
....@@ -12598,8 +12971,10 @@
1259812971 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912972
1260012973 "SUB temp.x, one.x, ndotl.x;" +
12601
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12602
- "ADD temp.y, one.y, options2.y;" + // sursurface
12974
+ // Tuning for default skin
12975
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12976
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12977
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260312978 "MUL temp.x, temp.x, temp.y;" +
1260412979
1260512980 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12747,7 +13122,7 @@
1274713122 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274813123 "FLR final.x, final.y;" +
1274913124 "SUB final.y, final.y, final.x;" +
12750
- //"MUL final.x, final.x, c256i;" +
13125
+ "MUL final.x, final.x, c256i;" +
1275113126 "MOV final.z, zero.x;" +
1275213127 "MOV final.a, one.w;":""
1275313128 ) +
....@@ -12755,7 +13130,7 @@
1275513130 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275613131 "FLR final.x, final.y;" +
1275713132 "SUB final.y, final.y, final.x;" +
12758
- //"MUL final.x, final.x, c256i;" +
13133
+ "MUL final.x, final.x, c256i;" +
1275913134 "MOV final.z, zero.x;" +
1276013135 "MOV final.a, one.w;":""
1276113136 ) +
....@@ -12798,7 +13173,7 @@
1279813173 //once = true;
1279913174 }
1280013175
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
13176
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280213177 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280313178 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280413179
....@@ -12931,12 +13306,16 @@
1293113306
1293213307 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313308 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13309
+
13310
+ // Compare fragment depth in light space with shadowmap.
1293413311 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513312 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13313
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13314
+
13315
+ // Reverse comparison
1293713316 "SUB temp.x, one.x, temp.x;" +
1293813317 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13318
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013319 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113320
1294213321 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13329,10 @@
1295013329 // No shadow for backface
1295113330 "DP3 temp.x, normal, lightd;" +
1295213331 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13332
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13333
+
13334
+ // No shadow when out of frustrum
13335
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295313336 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413337 "";
1295513338 }
....@@ -13096,7 +13479,8 @@
1309613479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309713480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309813481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13099
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1310013484
1310113485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310213486 // OUT : diff, spec
....@@ -13112,9 +13496,10 @@
1311213496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311313497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311413498 //"MOV " + dest + ".w," + "normal.z;" +
13115
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13116
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13117
- //"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
1311813503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1311913504 "RCP " + dest + ".w," + dest + ".w;" +
1312013505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13508,7 +13893,7 @@
1350813893 public void mousePressed(MouseEvent e)
1350913894 {
1351013895 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13896
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213897 }
1351313898
1351413899 static long prevtime = 0;
....@@ -13584,8 +13969,8 @@
1358413969 // mode |= META;
1358513970 //}
1358613971
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13972
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13973
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913974 anchorX = ax;
1359013975 anchorY = ay;
1359113976 prevX = px;
....@@ -13619,6 +14004,7 @@
1361914004 else
1362014005 if (evt.getSource() == AAtimer)
1362114006 {
14007
+ Globals.TIMERRUNNING = false;
1362214008 if (mouseDown)
1362314009 {
1362414010 //new Exception().printStackTrace();
....@@ -13644,6 +14030,10 @@
1364414030 // LIVE = waslive;
1364514031 // wasliveok = true;
1364614032 // waslive = false;
14033
+
14034
+ // May 2019 Forget it:
14035
+ if (true)
14036
+ return;
1364714037
1364814038 // source == timer
1364914039 if (mouseDown)
....@@ -13674,7 +14064,7 @@
1367414064
1367514065 // fev 2014???
1367614066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13677
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367814068 pingthread.StepToTarget(true); // true);
1367914069 }
1368014070 // if (!LIVE)
....@@ -13683,12 +14073,13 @@
1368314073
1368414074 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368514075
13686
- void clickStart(int x, int y, int modifiers)
14076
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368714077 {
1368814078 if (!wasliveok)
1368914079 return;
1369014080
1369114081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1369214083
1369314084 // waslive = LIVE;
1369414085 // LIVE = false;
....@@ -13700,7 +14091,7 @@
1370014091 // touched = true; // main DL
1370114092 if (isRenderer)
1370214093 {
13703
- SetMouseMode(modifiers);
14094
+ SetMouseMode(modifiers, modifiersex);
1370414095 }
1370514096
1370614097 selectX = anchorX = x;
....@@ -13713,7 +14104,7 @@
1371314104 clicked = true;
1371414105 hold = false;
1371514106
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14107
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371714108 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371814109 {
1371914110 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +14135,7 @@
1374414135 info.camera = renderCamera;
1374514136 info.x = x;
1374614137 info.y = y;
13747
- info.modifiers = modifiers;
14138
+ info.modifiers = modifiersex;
1374814139 editObj = object.doEditClick(info, 0);
1374914140 if (!editObj)
1375014141 {
....@@ -13761,9 +14152,12 @@
1376114152
1376214153 public void mouseDragged(MouseEvent e)
1376314154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
1376414157 //System.out.println("mouseDragged: " + e);
1376514158 if (isRenderer)
1376614159 movingcamera = true;
14160
+
1376714161 //if (drawing)
1376814162 //return;
1376914163 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +14167,7 @@
1377314167 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377414168 }
1377514169 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
14170
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377714171
1377814172 //try { Thread.sleep(1); } catch (Exception ex) {}
1377914173 }
....@@ -13946,6 +14340,7 @@
1394614340
1394714341 public void run()
1394814342 {
14343
+ new Exception().printStackTrace();
1394914344 System.exit(0);
1395014345 for (;;)
1395114346 {
....@@ -14009,7 +14404,7 @@
1400914404 {
1401014405 Globals.lighttouched = true;
1401114406 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14407
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314408 }
1401414409 //else
1401514410 }
....@@ -14023,12 +14418,12 @@
1402314418 void GoDown(int mod)
1402414419 {
1402514420 MODIFIERS |= COMMAND;
14026
- /*
14421
+ /**/
1402714422 if((mod&SHIFT) == SHIFT)
1402814423 manipCamera.RotatePosition(0, -speed);
1402914424 else
14030
- manipCamera.BackForth(0, -speed*delta, getWidth());
14031
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1403214427 if ((mod & SHIFT) == SHIFT)
1403314428 {
1403414429 mouseMode = mouseMode; // VR??
....@@ -14044,12 +14439,12 @@
1404414439 void GoUp(int mod)
1404514440 {
1404614441 MODIFIERS |= COMMAND;
14047
- /*
14442
+ /**/
1404814443 if((mod&SHIFT) == SHIFT)
1404914444 manipCamera.RotatePosition(0, speed);
1405014445 else
14051
- manipCamera.BackForth(0, speed*delta, getWidth());
14052
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1405314448 if ((mod & SHIFT) == SHIFT)
1405414449 {
1405514450 mouseMode = mouseMode;
....@@ -14065,12 +14460,12 @@
1406514460 void GoLeft(int mod)
1406614461 {
1406714462 MODIFIERS |= COMMAND;
14068
- /*
14463
+ /**/
1406914464 if((mod&SHIFT) == SHIFT)
14070
- manipCamera.RotatePosition(speed, 0);
14071
- else
1407214465 manipCamera.Translate(speed*delta, 0, getWidth());
14073
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1407414469 if ((mod & SHIFT) == SHIFT)
1407514470 {
1407614471 mouseMode = mouseMode;
....@@ -14086,12 +14481,12 @@
1408614481 void GoRight(int mod)
1408714482 {
1408814483 MODIFIERS |= COMMAND;
14089
- /*
14484
+ /**/
1409014485 if((mod&SHIFT) == SHIFT)
14091
- manipCamera.RotatePosition(-speed, 0);
14092
- else
1409314486 manipCamera.Translate(-speed*delta, 0, getWidth());
14094
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1409514490 if ((mod & SHIFT) == SHIFT)
1409614491 {
1409714492 mouseMode = mouseMode;
....@@ -14109,7 +14504,7 @@
1410914504 int X, Y;
1411014505 boolean SX, SY;
1411114506
14112
- void drag(int x, int y, int modifiers)
14507
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314508 {
1411414509 if (IsFrozen())
1411514510 {
....@@ -14118,17 +14513,17 @@
1411814513
1411914514 drag = true; // NEW
1412014515
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14516
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214517
1412314518 X = x;
1412414519 Y = y;
1412514520 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14521
+ MODIFIERS = modifiersex;
14522
+ modifiersex &= ~1024;
1412814523 if (false) // modifiers != 0)
1412914524 {
1413014525 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14526
+ System.out.println("mouseDragged: " + modifiersex);
1413214527 System.out.println("SHIFT = " + SHIFT);
1413314528 System.out.println("CONTROL = " + COMMAND);
1413414529 System.out.println("META = " + META);
....@@ -14148,7 +14543,8 @@
1414814543 info.camera = renderCamera;
1414914544 info.x = x;
1415014545 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214548 } else
1415314549 {
1415414550 if (x < startX)
....@@ -14312,7 +14708,9 @@
1431214708 ci.camera = renderCamera;
1431314709 if (!isRenderer)
1431414710 {
14315
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1431614714 {
1431714715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1431814716 } else
....@@ -14324,7 +14722,11 @@
1432414722
1432514723 public void mouseReleased(MouseEvent e)
1432614724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1432714727 movingcamera = false;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1432814730 //System.out.println("mouseReleased: " + e);
1432914731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014732 }
....@@ -14347,9 +14749,9 @@
1434714749 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814750 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914751
14350
- if (control || command || IsFrozen())
14752
+// No delay if (control || command || IsFrozen())
1435114753 timeout = true;
14352
- else
14754
+// ?? May 2019 else
1435314755 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414756 mouseDown = false;
1435514757 if (!control && !command) // june 2013
....@@ -14459,7 +14861,7 @@
1445914861 System.out.println("keyReleased: " + e);
1446014862 }
1446114863
14462
- void SetMouseMode(int modifiers)
14864
+ void SetMouseMode(int modifiers, int modifiersex)
1446314865 {
1446414866 //System.out.println("SetMouseMode = " + modifiers);
1446514867 //modifiers &= ~1024;
....@@ -14471,25 +14873,25 @@
1447114873 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214874 // return;
1447314875 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14876
+ if ((modifiersex & WHEEL) == WHEEL)
1447514877 {
1447614878 mouseMode |= ZOOM;
1447714879 }
1447814880
1447914881 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14882
+ if (capsLocked) // || (modifiers & META) == META)
1448114883 {
1448214884 mouseMode |= VR; // BACKFORTH;
1448314885 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14886
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514887 {
1448614888 mouseMode |= SELECT;
1448714889 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14890
+ if ((modifiersex & COMMAND) == COMMAND)
1448914891 {
1449014892 mouseMode |= SELECT;
1449114893 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14894
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314895 {
1449414896 mouseMode &= ~VR;
1449514897 mouseMode |= TRANSLATE;
....@@ -14518,7 +14920,7 @@
1451814920
1451914921 if (isRenderer) //
1452014922 {
14521
- SetMouseMode(modifiers);
14923
+ SetMouseMode(0, modifiers);
1452214924 }
1452314925
1452414926 Globals.theRenderer.keyPressed(key);
....@@ -14580,7 +14982,8 @@
1458014982 // break;
1458114983 case 'T':
1458214984 CACHETEXTURE ^= true;
14583
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1458414987 // repaint();
1458514988 break;
1458614989 case 'Y':
....@@ -14665,7 +15068,9 @@
1466515068 case 'E' : COMPACT ^= true;
1466615069 repaint();
1466715070 break;
14668
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1466915074 repaint();
1467015075 break;
1467115076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14690,8 +15095,8 @@
1469015095 RevertCamera();
1469115096 repaint();
1469215097 break;
14693
- case 'L':
1469415098 case 'l':
15099
+ //case 'L':
1469515100 if (lightMode)
1469615101 {
1469715102 lightMode = false;
....@@ -14834,9 +15239,9 @@
1483415239 case '_':
1483515240 kompactbit = 5;
1483615241 break;
14837
- case '+':
14838
- kompactbit = 6;
14839
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1484015245 case ' ':
1484115246 lightMode ^= true;
1484215247 Globals.lighttouched = true;
....@@ -14848,13 +15253,14 @@
1484815253 case ESC:
1484915254 RENDERPROGRAM += 1;
1485015255 RENDERPROGRAM %= 3;
15256
+
1485115257 repaint();
1485215258 break;
1485315259 case 'Z':
1485415260 //RESIZETEXTURE ^= true;
1485515261 //break;
1485615262 case 'z':
14857
- RENDERSHADOW ^= true;
15263
+ Globals.RENDERSHADOW ^= true;
1485815264 Globals.lighttouched = true;
1485915265 repaint();
1486015266 break;
....@@ -14887,8 +15293,9 @@
1488715293 case DELETE:
1488815294 ClearSelection();
1488915295 break;
14890
- /*
1489115296 case '+':
15297
+
15298
+ /*
1489215299 //fontsize += 1;
1489315300 bbzoom *= 2;
1489415301 repaint();
....@@ -14905,17 +15312,17 @@
1490515312 case '=':
1490615313 IncDepth();
1490715314 //fontsize += 1;
14908
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1490915316 maskbit = 6;
1491015317 break;
1491115318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491215319 DecDepth();
1491315320 maskbit = 5;
1491415321 //if(fontsize > 1) fontsize -= 1;
14915
- if (object.editWindow == null)
14916
- new Exception().printStackTrace();
14917
- else
14918
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1491915326 break;
1492015327 case '{':
1492115328 manipCamera.shaper_fovy /= 1.1;
....@@ -14978,7 +15385,7 @@
1497815385 //mode = ROTATE;
1497915386 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015387 {
14981
- SetMouseMode(modifiers);
15388
+ SetMouseMode(0, modifiers);
1498215389 }
1498315390 }
1498415391
....@@ -15114,7 +15521,7 @@
1511415521 {
1511515522 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615523 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15524
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1511815525 {
1511915526 mouseMoved(e);
1512015527 } else
....@@ -15139,11 +15546,12 @@
1513915546 }
1514015547 */
1514115548
15142
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1514315550 }
1514415551
1514515552 void SelectParent()
1514615553 {
15554
+ new Exception().printStackTrace();
1514715555 System.exit(0);
1514815556 Composite group = (Composite) object;
1514915557 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15155,10 +15563,10 @@
1515515563 {
1515615564 //selectees.remove(i);
1515715565 System.out.println("select parent of " + elem);
15158
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1515915567 } else
1516015568 {
15161
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516215570 }
1516315571
1516415572 first = false;
....@@ -15167,6 +15575,7 @@
1516715575
1516815576 void SelectChildren()
1516915577 {
15578
+ new Exception().printStackTrace();
1517015579 System.exit(0);
1517115580 /*
1517215581 Composite group = (Composite) object;
....@@ -15199,12 +15608,12 @@
1519915608 for (int j = 0; j < group.children.size(); j++)
1520015609 {
1520115610 elem = (Object3D) group.children.elementAt(j);
15202
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520315612 first = false;
1520415613 }
1520515614 } else
1520615615 {
15207
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520815617 }
1520915618
1521015619 first = false;
....@@ -15215,21 +15624,21 @@
1521515624 {
1521615625 //Composite group = (Composite) object;
1521715626 Object3D group = object;
15218
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1521915628 }
1522015629
1522115630 void ResetTransform(int mask)
1522215631 {
1522315632 //Composite group = (Composite) object;
1522415633 Object3D group = object;
15225
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1522615635 }
1522715636
1522815637 void FlipTransform()
1522915638 {
1523015639 //Composite group = (Composite) object;
1523115640 Object3D group = object;
15232
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1523315642 // group.editWindow.ReduceMesh(true);
1523415643 }
1523515644
....@@ -15237,7 +15646,7 @@
1523715646 {
1523815647 //Composite group = (Composite) object;
1523915648 Object3D group = object;
15240
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1524115650 // group.editWindow.ReduceMesh(true);
1524215651 }
1524315652
....@@ -15245,7 +15654,7 @@
1524515654 {
1524615655 //Composite group = (Composite) object;
1524715656 Object3D group = object;
15248
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1524915658 }
1525015659
1525115660 void IncDepth()
....@@ -15331,7 +15740,9 @@
1533115740 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215741 //Image img = CreateImage(width, height);
1533315742 //System.out.println("width = " + width + "; height = " + height + "\n");
15743
+
1533415744 Graphics gr = g; // img.getGraphics();
15745
+
1533515746 if (!hasMarquee)
1533615747 {
1533715748 if (Xmin < Xmax) // !locked)
....@@ -15419,6 +15830,7 @@
1541915830 info.bounds.y += (height - desired) / 2;
1542015831 }
1542115832 }
15833
+
1542215834 info.g = gr;
1542315835 info.camera = renderCamera;
1542415836 /*
....@@ -15428,15 +15840,55 @@
1542815840 */
1542915841 if (!isRenderer)
1543015842 {
15431
- object.drawEditHandles(info, 0);
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
15846
+ {
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)
15853
+ {
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;
15861
+ }
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
+ }
15881
+ }
1543215882 }
1543315883 }
15884
+
1543415885 if (isRenderer)
1543515886 {
1543615887 //gr.setColor(Color.black);
1543715888 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815889 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915890 }
15891
+
1544015892 if (hasMarquee)
1544115893 {
1544215894 gr.setXORMode(Color.white);
....@@ -15549,6 +16001,7 @@
1554916001 public boolean mouseDown(Event evt, int x, int y)
1555016002 {
1555116003 System.out.println("mouseDown: " + evt);
16004
+ System.exit(0);
1555216005 /*
1555316006 locked = true;
1555416007 drag = false;
....@@ -15592,7 +16045,7 @@
1559216045 {
1559316046 keyPressed(0, modifiers);
1559416047 }
15595
- clickStart(x, y, modifiers);
16048
+ // clickStart(x, y, modifiers);
1559616049 return true;
1559716050 }
1559816051
....@@ -15710,7 +16163,7 @@
1571016163 {
1571116164 keyReleased(0, 0);
1571216165 }
15713
- drag(x, y, modifiers);
16166
+ drag(x, y, 0, modifiers);
1571416167 return true;
1571516168 }
1571616169
....@@ -15842,7 +16295,7 @@
1584216295 Object3D object;
1584316296 static Object3D trackedobject;
1584416297 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616299 /*static*/ Camera eyeCamera;
1584716300 /*static*/ Camera lightCamera;
1584816301 int cameracount;
....@@ -16127,16 +16580,16 @@
1612716580 cStatic.objectstack[materialdepth++] = checker;
1612816581 //System.out.println("material " + material);
1612916582 //Applet3D.tracein(this, selected);
16130
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1613116584
1613216585 //checker.GetMaterial().Draw(this, false); // true);
16133
- DrawMaterial(checker.GetMaterial(), false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613416587
1613516588 materialdepth -= 1;
1613616589 if (materialdepth > 0)
1613716590 {
16138
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16139
- 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);
1614016593 }
1614116594 //checker.GetMaterial().opacity = 1f;
1614216595 ////checker.GetMaterial().ambient = 1f;
....@@ -16222,6 +16675,14 @@
1622216675 }
1622316676 }
1622416677
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
+
1622516686 class SelectBuffer implements GLEventListener
1622616687 {
1622716688
....@@ -16280,6 +16741,7 @@
1628016741 {
1628116742 if (!selection)
1628216743 {
16744
+ new Exception().printStackTrace();
1628316745 System.exit(0);
1628416746 return;
1628516747 }
....@@ -16300,6 +16762,17 @@
1630016762
1630116763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630216764
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
+
1630316776 //int tmp = selection_view;
1630416777 //selection_view = -1;
1630516778 int temp = DrawMode();
....@@ -16311,6 +16784,17 @@
1631116784 // temp = DEFAULT; // patch for selection debug
1631216785 Globals.drawMode = temp; // WARNING
1631316786
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
+
1631416798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1631516799
1631616800 // trying different ways of getting the depth info over
....@@ -16358,6 +16842,8 @@
1635816842 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1635916843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636016844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16845
+
16846
+ CreateSelectedPoint();
1636116847
1636216848 // Will fit the mesh !!!
1636316849 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16407,34 +16893,36 @@
1640716893 System.out.println("; fromto " + sel + " " + Trunk(previousselectedpoint.toParent[3][0]) + " " + Trunk(previousselectedpoint.toParent[3][2]) + " " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][2]));
1640816894 }
1640916895
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16896
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116897 }
1641216898 }
1641316899
1641416900 if (!movingcamera && !PAINTMODE)
16415
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1641616902
16417
- 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)
1641816904 {
16419
- 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);
1642016906
16421
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642216910
16423
- group.CreateMaterial(); // use a void leaf to select instances
16424
-
16425
- group.add(paintobj); // link
16426
-
16427
- object.editWindow.SnapObject(group);
16428
-
16429
- Object3D folder = object.editWindow.copy;
16430
-
16431
- if (object.editWindow.copy.selection.Size() > 0)
16432
- folder = object.editWindow.copy.selection.elementAt(0);
16433
-
16434
- folder.add(group);
16435
-
16436
- object.editWindow.ResetModel();
16437
- 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
+ }
1643816926 }
1643916927 else
1644016928 paintcount = 0;
....@@ -16473,6 +16961,11 @@
1647316961 //System.out.println("objects[color] = " + objects[color]);
1647416962 //objects[color].Select();
1647516963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1647616969 object.Select(color, deselect);
1647716970 }
1647816971
....@@ -16572,7 +17065,7 @@
1657217065 gl.glDisable(gl.GL_CULL_FACE);
1657317066 }
1657417067
16575
- if (!RENDERSHADOW)
17068
+ if (!Globals.RENDERSHADOW)
1657617069 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657717070
1657817071 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +17075,7 @@
1658217075 //gl.glColorMask(false, false, false, false);
1658317076
1658417077 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17078
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658617079 {
1658717080 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658817081
....@@ -16998,23 +17491,15 @@
1699817491 int AAbuffersize = 0;
1699917492
1700017493 //double[] selectedpoint = new double[3];
17001
- static Superellipsoid selectedpoint = new Superellipsoid();
17494
+ static Superellipsoid selectedpoint;
1700217495 static Sphere previousselectedpoint = null;
17003
- static Sphere debugpointG = new Sphere();
17004
- static Sphere debugpointP = new Sphere();
17005
- static Sphere debugpointC = new Sphere();
17006
- static Sphere debugpointR = new Sphere();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1700717500
1700817501 static Sphere debugpoints[] = new Sphere[8];
1700917502
17010
- static
17011
- {
17012
- for (int i=0; i<8; i++)
17013
- {
17014
- debugpoints[i] = new Sphere();
17015
- }
17016
- }
17017
-
1701817503 static void InitPoints(float radius)
1701917504 {
1702017505 for (int i=0; i<8; i++)