Normand Briere
2019-07-21 d32f24f147068e6cbecb31c7f98047f68bc8b58a
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
....@@ -56,14 +55,12 @@
5655 static int CURRENTANTIALIAS = 0; // 1;
5756 /*static*/ boolean RENDERSHADOW = true;
5857 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6158
6259 boolean DISPLAYTEXT = false;
6360 //boolean REDUCETEXTURE = true;
6461 boolean CACHETEXTURE = true;
6562 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6764 boolean COMPRESSTEXTURE = false;
6865 boolean KOMPACTTEXTURE = false; // true;
6966 boolean RESIZETEXTURE = false;
....@@ -86,7 +83,7 @@
8683 static boolean FULLSCREEN = false;
8784 static boolean SUPPORT = true;
8885 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
86
+static boolean FAST = false;
9087 static boolean SLOWPOSE = false;
9188 static boolean FOOTCONTACT = true;
9289
....@@ -108,7 +105,7 @@
108105 static boolean OEIL = true;
109106 static boolean OEILONCE = false; // do oeilon then oeiloff
110107 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
112109 static boolean HANDLES = false; // selection doesn't work!!
113110 static boolean PAINTMODE = false;
114111
....@@ -151,6 +148,8 @@
151148 defaultcaps.setAccumBlueBits(16);
152149 defaultcaps.setAccumAlphaBits(16);
153150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154153
155154 void SetAsGLRenderer(boolean b)
156155 {
....@@ -327,7 +326,7 @@
327326 cStatic.objectstack[materialdepth++] = obj;
328327 //System.out.println("material " + material);
329328 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
331330 if (obj instanceof Camera)
332331 {
333332 display.options1[0] = material.shift;
....@@ -336,14 +335,28 @@
336335 display.options1[2] = material.shadowbias;
337336 display.options1[3] = material.aniso;
338337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
339343 display.options2[0] = material.opacity;
340344 display.options2[1] = material.diffuse;
341345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
342349
343350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
344354 display.options4[0] = material.cameralight/0.2f;
345355 display.options4[1] = material.subsurface;
346356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
347360
348361 // if (display.CURRENTANTIALIAS > 0)
349362 // display.options3[3] /= 4;
....@@ -359,7 +372,7 @@
359372 /**/
360373 } else
361374 {
362
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
363376 }
364377 } else
365378 {
....@@ -383,8 +396,8 @@
383396 cStatic.objectstack[materialdepth++] = obj;
384397 //System.out.println("material " + material);
385398 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388401 }
389402 }
390403
....@@ -401,8 +414,8 @@
401414 materialdepth -= 1;
402415 if (materialdepth > 0)
403416 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406419 }
407420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +435,8 @@
422435 materialdepth -= 1;
423436 if (materialdepth > 0)
424437 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427440 }
428441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429442 //else
....@@ -464,10 +477,12 @@
464477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465478 {
466479 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
468483 if (!hasnorm)
469484 {
470
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
471486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1207,12 @@
11921207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931208 }
11941209 }
1210
+
11951211 if (flipV)
11961212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971213 else
11981214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11991216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011218
....@@ -1215,10 +1232,12 @@
12151232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161233 }
12171234 }
1235
+
12181236 if (flipV)
12191237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201238 else
12211239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12221241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241243
....@@ -1246,8 +1265,10 @@
12461265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471266 else
12481267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12491269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12511272 count2 += 2;
12521273 count3 += 3;
12531274 }
....@@ -1603,7 +1624,7 @@
16031624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041625 }
16051626
1606
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071628 {
16081629 CameraPane display = this;
16091630 //new Exception().printStackTrace();
....@@ -1630,7 +1651,7 @@
16301651
16311652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321653
1633
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16341655
16351656 /**/
16361657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1659,7 @@
16381659 colorV[0] = display.modelParams0[0] * material.diffuse;
16391660 colorV[1] = display.modelParams0[1] * material.diffuse;
16401661 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16421663
16431664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441665 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1767,9 @@
17461767 display.modelParams7[2] = 0;
17471768 display.modelParams7[3] = 0;
17481769
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501771
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531774 {
17541775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2142,7 +2163,7 @@
21422163 System.err.println("LIVE = " + Globals.isLIVE());
21432164
21442165 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21462167 // else
21472168 repaint(); // start loop // may 2013
21482169 }
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2267,9 +2288,9 @@
22672288 LOOKAT ^= true;
22682289 }
22692290
2270
- void ToggleRandom()
2291
+ void ToggleSwitch()
22712292 {
2272
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22732294 }
22742295
22752296 void ToggleHandles()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -2376,7 +2404,46 @@
23762404 {
23772405 return currentGL;
23782406 }
2379
-
2407
+
2408
+ private BufferedImage CreateBim(TextureData texturedata)
2409
+ {
2410
+ // cache to disk
2411
+ Buffer buffer = texturedata.getBuffer(); // getMipmapData();
2412
+ //buffers[0].
2413
+ ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
2414
+ int[] pixels = new int[bytebuf.capacity()/3];
2415
+ int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared
2416
+ int height = width;
2417
+ for (int i=pixels.length; --i>=0;)
2418
+ {
2419
+ int i3 = i*3;
2420
+ pixels[i] = 0xFF;
2421
+ pixels[i] <<= 8;
2422
+ pixels[i] |= bytebuf.get(i3+2) & 0xFF;
2423
+ pixels[i] <<= 8;
2424
+ pixels[i] |= bytebuf.get(i3+1) & 0xFF;
2425
+ pixels[i] <<= 8;
2426
+ pixels[i] |= bytebuf.get(i3) & 0xFF;
2427
+ }
2428
+ /*
2429
+ int r=0,g=0,b=0,a=0;
2430
+ for (int i=0; i<width; i++)
2431
+ for (int j=0; j<height; j++)
2432
+ {
2433
+ int index = j*width+i;
2434
+ int p = pixels[index];
2435
+ a = ((p>>24) & 0xFF);
2436
+ r = ((p>>16) & 0xFF);
2437
+ g = ((p>>8) & 0xFF);
2438
+ b = (p & 0xFF);
2439
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
2440
+ }
2441
+ /**/
2442
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
2443
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
2444
+ return rendImage;
2445
+ }
2446
+
23802447 /**/
23812448 class CacheTexture
23822449 {
....@@ -2394,9 +2461,10 @@
23942461 /**/
23952462
23962463 // 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>();
2464
+ static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2465
+ static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2466
+ static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2467
+
24002468 int pigmentdepth = 0;
24012469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022470 int bumpdepth = 0;
....@@ -2418,6 +2486,33 @@
24182486 true,
24192487 com.sun.opengl.util.texture.TextureIO.PNG);
24202488 } catch (java.io.IOException e)
2489
+ {
2490
+ throw new javax.media.opengl.GLException(e);
2491
+ }
2492
+
2493
+ if (bump)
2494
+ texturedata = ConvertBump(texturedata, false);
2495
+
2496
+ com.sun.opengl.util.texture.Texture texture =
2497
+ com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2498
+
2499
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2500
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2501
+
2502
+ return texture;
2503
+ }
2504
+
2505
+ com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2506
+ {
2507
+ TextureData texturedata = null;
2508
+
2509
+ try
2510
+ {
2511
+ texturedata =
2512
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2513
+ name,
2514
+ true);
2515
+ } catch (Exception e)
24212516 {
24222517 throw new javax.media.opengl.GLException(e);
24232518 }
....@@ -3504,6 +3599,8 @@
35043599
35053600 System.out.println("LOADING TEXTURE : " + name);
35063601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35073604 //
35083605 if (false) // compressbit > 0)
35093606 {
....@@ -4208,6 +4305,7 @@
42084305
42094306 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104307 {
4308
+ new Exception().printStackTrace();
42114309 System.exit(0);
42124310 com.sun.opengl.util.texture.Texture texture = null;
42134311
....@@ -7901,7 +7999,7 @@
79017999 String pigment = Object3D.GetPigment(tex);
79028000 String bump = Object3D.GetBump(tex);
79038001
7904
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79058003 {
79068004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79078005 // System.out.println("; bump = " + bump);
....@@ -7918,6 +8016,64 @@
79188016
79198017 ReleaseTexture(bump, true);
79208018 ReleaseTexture(pigment, false);
8019
+ }
8020
+
8021
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8022
+ {
8023
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8024
+ {
8025
+ return;
8026
+ }
8027
+
8028
+ if (tex == null)
8029
+ {
8030
+ ReleaseTexture(null, false);
8031
+ return;
8032
+ }
8033
+
8034
+ String pigment = Object3D.GetPigment(tex);
8035
+
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8037
+ {
8038
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8039
+ // System.out.println("; bump = " + bump);
8040
+ }
8041
+
8042
+ if (pigment.equals(""))
8043
+ {
8044
+ pigment = null;
8045
+ }
8046
+
8047
+ ReleaseTexture(pigment, false);
8048
+ }
8049
+
8050
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8051
+ {
8052
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8053
+ {
8054
+ return;
8055
+ }
8056
+
8057
+ if (tex == null)
8058
+ {
8059
+ ReleaseTexture(null, true);
8060
+ return;
8061
+ }
8062
+
8063
+ String bump = Object3D.GetBump(tex);
8064
+
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8066
+ {
8067
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8068
+ // System.out.println("; bump = " + bump);
8069
+ }
8070
+
8071
+ if (bump.equals(""))
8072
+ {
8073
+ bump = null;
8074
+ }
8075
+
8076
+ ReleaseTexture(bump, true);
79218077 }
79228078
79238079 void ReleaseTexture(String tex, boolean bump)
....@@ -8023,7 +8179,55 @@
80238179 }
80248180 }
80258181
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8182
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8183
+ {
8184
+// if (// DrawMode() != 0 || /*tex == null ||*/
8185
+// ambientOcclusion ) // || !textureon)
8186
+// {
8187
+// return; // false;
8188
+// }
8189
+//
8190
+// if (tex == null)
8191
+// {
8192
+// BindTexture(null,false,resolution);
8193
+// BindTexture(null,true,resolution);
8194
+// return;
8195
+// }
8196
+//
8197
+// String pigment = Object3D.GetPigment(tex);
8198
+// String bump = Object3D.GetBump(tex);
8199
+//
8200
+// usedtextures.add(pigment);
8201
+// usedtextures.add(bump);
8202
+//
8203
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8204
+// {
8205
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8206
+// // System.out.println("; bump = " + bump);
8207
+// }
8208
+//
8209
+// if (bump.equals(""))
8210
+// {
8211
+// bump = null;
8212
+// }
8213
+// if (pigment.equals(""))
8214
+// {
8215
+// pigment = null;
8216
+// }
8217
+//
8218
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8219
+// BindTexture(pigment, false, resolution);
8220
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+// BindTexture(bump, true, resolution);
8222
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+//
8224
+// return; // true;
8225
+
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
8228
+ }
8229
+
8230
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80278231 {
80288232 if (// DrawMode() != 0 || /*tex == null ||*/
80298233 ambientOcclusion ) // || !textureon)
....@@ -8033,18 +8237,48 @@
80338237
80348238 if (tex == null)
80358239 {
8036
- BindTexture(null,false,resolution);
8037
- BindTexture(null,true,resolution);
8240
+ BindTexture(null, null,false,resolution);
80388241 return;
80398242 }
80408243
80418244 String pigment = Object3D.GetPigment(tex);
8245
+
8246
+ usedtextures.add(pigment);
8247
+
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8249
+ {
8250
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8251
+ // System.out.println("; bump = " + bump);
8252
+ }
8253
+
8254
+ if (pigment.equals(""))
8255
+ {
8256
+ pigment = null;
8257
+ }
8258
+
8259
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
8261
+ }
8262
+
8263
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8264
+ {
8265
+ if (// DrawMode() != 0 || /*tex == null ||*/
8266
+ ambientOcclusion ) // || !textureon)
8267
+ {
8268
+ return; // false;
8269
+ }
8270
+
8271
+ if (tex == null)
8272
+ {
8273
+ BindTexture(null, null,true,resolution);
8274
+ return;
8275
+ }
8276
+
80428277 String bump = Object3D.GetBump(tex);
80438278
8044
- usedtextures.put(pigment, pigment);
8045
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
80468280
8047
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80488282 {
80498283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80508284 // System.out.println("; bump = " + bump);
....@@ -8054,42 +8288,70 @@
80548288 {
80558289 bump = null;
80568290 }
8057
- if (pigment.equals(""))
8058
- {
8059
- pigment = null;
8060
- }
80618291
8062
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8063
- BindTexture(pigment, false, resolution);
80648292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8065
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
80668294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8067
-
8068
- return; // true;
80698295 }
80708296
8071
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8297
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8298
+
8299
+ private boolean FileExists(String tex)
80728300 {
8073
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8301
+ if (missingTextures.contains(tex))
8302
+ {
8303
+ return false;
8304
+ }
8305
+
8306
+ boolean fileExists = new File(tex).exists();
8307
+
8308
+ if (!fileExists)
8309
+ {
8310
+ // If file exists, the "new File()" is not executed sgain
8311
+ missingTextures.add(tex);
8312
+ }
8313
+
8314
+ return fileExists;
8315
+ }
8316
+
8317
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8318
+ {
8319
+ CacheTexture texturecache = null;
80748320
80758321 if (tex != null)
80768322 {
80778323 String texname = tex;
80788324
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;
8325
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8326
+
8327
+// String[] split = tex.split("Textures");
8328
+// if (split.length > 1)
8329
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8330
+// else
8331
+// if (!texname.startsWith("/"))
8332
+// texname = "/Users/nbriere/Textures/" + texname;
8333
+ if (!FileExists(tex))
8334
+ {
8335
+ texname = fallbackTextureName;
8336
+ }
80858337
80868338 if (CACHETEXTURE)
8087
- texture = textures.get(texname); // TEXTURE CACHE
8088
-
8089
- TextureData texturedata = null;
8090
-
8091
- if (texture == null || texture.resolution < resolution)
80928339 {
8340
+ if (bim == null)
8341
+ texturecache = textures.get(texname); // TEXTURE CACHE
8342
+ else
8343
+ texturecache = bimtextures.get(bim); // TEXTURE CACHE
8344
+ }
8345
+
8346
+ if (texturecache == null || texturecache.resolution < resolution)
8347
+ {
8348
+ TextureData texturedata = null;
8349
+
8350
+ if (bim != null)
8351
+ {
8352
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8353
+ }
8354
+ else
80938355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80948356 {
80958357 assert(!bump);
....@@ -8101,19 +8363,23 @@
81018363 // }
81028364 // else
81038365 // {
8104
- texture = textures.get(tex);
8105
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
81068368 {
8107
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81088370 }
8371
+ else
8372
+ new Exception().printStackTrace();
81098373 // }
81108374 } else
81118375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81128376 {
81138377 assert(bump);
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8378
+ texturecache = textures.get(tex);
8379
+ if (texturecache == null)
8380
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8381
+ else
8382
+ new Exception().printStackTrace();
81178383 } else
81188384 {
81198385 //if (tex.equals("IMMORTAL"))
....@@ -8123,9 +8389,11 @@
81238389 //{
81248390 if (tex.equals("WHITE_NOISE"))
81258391 {
8126
- texture = textures.get(tex);
8127
- if (texture == null)
8128
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8392
+ texturecache = textures.get(tex);
8393
+ if (texturecache == null)
8394
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8395
+ else
8396
+ new Exception().printStackTrace();
81298397 } else
81308398 {
81318399 if (textureon)
....@@ -8150,7 +8418,7 @@
81508418 }
81518419
81528420 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8421
+ if (!FileExists(cachename))
81548422 cachename = texname;
81558423 else
81568424 processbump = false; // don't process bump map again
....@@ -8172,7 +8440,7 @@
81728440 }
81738441
81748442 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8443
+ if (!FileExists(cachename))
81768444 cachename = texname;
81778445 else
81788446 processbump = false; // don't process bump map again
....@@ -8181,20 +8449,23 @@
81818449 texturedata = GetFileTexture(cachename, processbump, resolution);
81828450
81838451
8184
- if (texturedata != null)
8185
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8452
+ if (texturedata == null)
8453
+ throw new Exception();
8454
+
8455
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868456 //texture = GetTexture(tex, bump);
81878457 }
81888458 }
81898459 //}
81908460 }
81918461
8192
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81938463 {
81948464 //return false;
8465
+ assert(bim == null);
81958466
81968467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8197
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81988469 {
81998470 // String ext = "_highres";
82008471 // if (REDUCETEXTURE)
....@@ -8211,52 +8482,17 @@
82118482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82128483 if (!cachefile.exists())
82138484 {
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))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
82238486 {
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);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
82548489 ImageWriter writer = null;
82558490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82568491 if (iter.hasNext()) {
82578492 writer = (ImageWriter)iter.next();
82588493 }
8259
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
82608496 try
82618497 {
82628498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8283,8 +8519,8 @@
82838519 textures.remove(texname);
82848520 }
82858521
8286
- texture.texturedata = texturedata;
8287
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
82888524
82898525 // newtex = true;
82908526 }
....@@ -8300,12 +8536,17 @@
83008536 }
83018537 }
83028538
8303
- return texture;
8539
+ return texturecache;
83048540 }
83058541
8306
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8542
+ static void EmbedTextures(cTexture tex)
83078543 {
8308
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8544
+
8545
+ }
8546
+
8547
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8548
+ {
8549
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83098550
83108551 if (bump)
83118552 {
....@@ -8321,23 +8562,23 @@
83218562 return texture!=null?texture.texture:null;
83228563 }
83238564
8324
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8565
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83258566 {
8326
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83278568
83288569 return texture!=null?texture.texturedata:null;
83298570 }
83308571
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8572
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83328573 {
83338574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348575 {
83358576 return false;
83368577 }
83378578
8338
- boolean newtex = false;
8579
+ //boolean newtex = false;
83398580
8340
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83418582
83428583 if (texture == null)
83438584 return false;
....@@ -8367,7 +8608,7 @@
83678608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83688609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83698610
8370
- return newtex;
8611
+ return true; // Warning: not used.
83718612 }
83728613
83738614 ShadowBuffer shadowPBuf;
....@@ -9205,11 +9446,35 @@
92059446 jy8[3] = 0.5f;
92069447 }
92079448
9208
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9449
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92099450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92109451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92119452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92129453
9454
+ void ResetOptions()
9455
+ {
9456
+ options1[0] = 100;
9457
+ options1[1] = 0.025f;
9458
+ options1[2] = 0.01f;
9459
+ options1[3] = 0;
9460
+ options1[4] = 0;
9461
+
9462
+ options2[0] = 0;
9463
+ options2[1] = 0.75f;
9464
+ options2[2] = 0;
9465
+ options2[3] = 0;
9466
+
9467
+ options3[0] = 1;
9468
+ options3[1] = 1;
9469
+ options3[2] = 1;
9470
+ options3[3] = 0;
9471
+
9472
+ options4[0] = 1;
9473
+ options4[1] = 0;
9474
+ options4[2] = 1;
9475
+ options4[3] = 0;
9476
+ }
9477
+
92139478 static int imagecount = 0; // movie generation
92149479
92159480 static int jitter = 0;
....@@ -9305,8 +9570,8 @@
93059570 assert (parentcam != renderCamera);
93069571
93079572 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109575
93119576 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129577
....@@ -9321,8 +9586,8 @@
93219586 LA.matCopy(renderCamera.fromScreen, matrix);
93229587
93239588 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9589
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9590
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269591
93279592 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289593
....@@ -9394,7 +9659,7 @@
93949659 //gl.glFlush();
93959660 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969661
9397
- if (ANIMATION && ABORTED)
9662
+ if (Globals.ANIMATION && ABORTED)
93989663 {
93999664 System.err.println(" ABORTED FRAME");
94009665 break;
....@@ -9424,7 +9689,7 @@
94249689 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259690
94269691 // save image
9427
- if (ANIMATION && !ABORTED)
9692
+ if (Globals.ANIMATION && !ABORTED)
94289693 {
94299694 VPwidth = viewport[2];
94309695 VPheight = viewport[3];
....@@ -9535,11 +9800,11 @@
95359800
95369801 // imagecount++;
95379802
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9803
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399804
95409805 if (!BOXMODE)
95419806 {
9542
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9807
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95439808 }
95449809
95459810 if (!BOXMODE)
....@@ -9577,7 +9842,7 @@
95779842 ABORTED = false;
95789843 }
95799844 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9845
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819846
95829847 if (false)
95839848 {
....@@ -10240,11 +10505,11 @@
1024010505
1024110506 public void display(GLAutoDrawable drawable)
1024210507 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10508
+ if (Grafreed.savesound && Grafreed.hassound)
1024410509 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10510
+ Grafreed.wav.save();
10511
+ Grafreed.savesound = false;
10512
+ Grafreed.hassound = false;
1024810513 }
1024910514 // if (DEBUG_SELECTION)
1025010515 // {
....@@ -10320,6 +10585,7 @@
1032010585 ANTIALIAS = 0;
1032110586 //System.out.println("RESTART");
1032210587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1032310589 }
1032410590 }
1032510591 }
....@@ -10374,7 +10640,7 @@
1037410640 Object3D theobject = object;
1037510641 Object3D theparent = object.parent;
1037610642 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10643
+ object = (Object3D)Grafreed.clone(object);
1037810644 object.Stripify();
1037910645 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010646 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10653,14 @@
1038710653 ambientOcclusion = false;
1038810654 }
1038910655
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110658 {
1039210659 //if (RENDERSHADOW) // ?
1039310660 if (!IsFrozen())
1039410661 {
1039510662 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10663
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710664 {
1039810665 Globals.framecount++;
1039910666 shadowbuffer.display();
....@@ -10520,8 +10787,8 @@
1052010787
1052110788 // if (parentcam != renderCamera) // not a light
1052210789 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10790
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10791
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510792
1052610793 for (int j = 0; j < 4; j++)
1052710794 {
....@@ -10535,8 +10802,8 @@
1053510802
1053610803 // if (parentcam != renderCamera) // not a light
1053710804 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10805
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10806
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010807
1054110808 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210809
....@@ -10795,7 +11062,16 @@
1079511062 // Bump noise
1079611063 gl.glActiveTexture(GL.GL_TEXTURE6);
1079711064 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- BindTexture(NOISE_TEXTURE, false, 2);
11065
+
11066
+ try
11067
+ {
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
11069
+ }
11070
+ catch (Exception e)
11071
+ {
11072
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11073
+ }
11074
+
1079911075
1080011076 gl.glActiveTexture(GL.GL_TEXTURE0);
1080111077 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10818,9 +11094,9 @@
1081811094
1081911095 gl.glMatrixMode(GL.GL_MODELVIEW);
1082011096
10821
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10822
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10823
-//gl.glEnable(gl.GL_MULTISAMPLE);
11097
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11098
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11099
+gl.glEnable(gl.GL_MULTISAMPLE);
1082411100 } else
1082511101 {
1082611102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10831,7 +11107,7 @@
1083111107 //System.out.println("BLENDING ON");
1083211108 gl.glEnable(GL.GL_BLEND);
1083311109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10834
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083511111 gl.glMatrixMode(gl.GL_PROJECTION);
1083611112 gl.glLoadIdentity();
1083711113
....@@ -10920,8 +11196,8 @@
1092011196 System.err.println("parentcam != renderCamera");
1092111197
1092211198 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11199
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11200
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092511201 }
1092611202
1092711203 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11218,8 @@
1094211218 if (true) // TODO
1094311219 {
1094411220 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11221
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11222
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094711223 }
1094811224
1094911225 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11535,14 @@
1125911535 {
1126011536 renderpass++;
1126111537 // System.out.println("Draw object... ");
11538
+ STEP = 1;
1126211539 if (FAST) // in case there is no script
11263
- STEP = 16;
11540
+ STEP = 8;
11541
+
11542
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11543
+ {
11544
+ STEP *= 4;
11545
+ }
1126411546
1126511547 //object.FullInvariants();
1126611548
....@@ -11274,23 +11556,44 @@
1127411556 e.printStackTrace();
1127511557 }
1127611558
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11559
+ if (Grafreed.RENDERME > 0)
11560
+ Grafreed.RENDERME--; // mechante magouille
1127911561
1128011562 Globals.ONESTEP = false;
1128111563 }
1128211564
1128311565 static boolean zoomonce = false;
1128411566
11567
+ static void CreateSelectedPoint()
11568
+ {
11569
+ if (selectedpoint == null)
11570
+ {
11571
+ debugpointG = new Sphere();
11572
+ debugpointP = new Sphere();
11573
+ debugpointC = new Sphere();
11574
+ debugpointR = new Sphere();
11575
+
11576
+ selectedpoint = new Superellipsoid();
11577
+
11578
+ for (int i=0; i<8; i++)
11579
+ {
11580
+ debugpoints[i] = new Sphere();
11581
+ }
11582
+ }
11583
+ }
11584
+
1128511585 void DrawObject(GL gl, boolean draw)
1128611586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1128711590 //System.out.println("DRAW OBJECT " + mouseDown);
1128811591 // DrawMode() = SELECTION;
1128911592 //GL gl = getGL();
1129011593 if ((TRACK || SHADOWTRACK) || zoomonce)
1129111594 {
1129211595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11293
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129411597 pingthread.StepToTarget(true); // true);
1129511598 // zoomonce = false;
1129611599 }
....@@ -11345,7 +11648,14 @@
1134511648
1134611649 usedtextures.clear();
1134711650
11348
- BindTextures(DEFAULT_TEXTURES, 2);
11651
+ try
11652
+ {
11653
+ BindTextures(DEFAULT_TEXTURES, 2);
11654
+ }
11655
+ catch (Exception e)
11656
+ {
11657
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11658
+ }
1134911659 }
1135011660 //System.out.println("--> " + stackdepth);
1135111661 // GrafreeD.traceon();
....@@ -11355,8 +11665,9 @@
1135511665
1135611666 if (DrawMode() == DEFAULT)
1135711667 {
11358
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1135911669 {
11670
+ CreateSelectedPoint();
1136011671 float radius = 0.05f;
1136111672 if (selectedpoint.radius != radius)
1136211673 {
....@@ -11419,7 +11730,7 @@
1141911730 if (tex.equals("WHITE_NOISE"))
1142011731 continue;
1142111732
11422
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1142311734 {
1142411735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1142511736 textures.get(tex).texture.dispose();
....@@ -11436,7 +11747,14 @@
1143611747 if (checker != null && DrawMode() == DEFAULT)
1143711748 {
1143811749 //BindTexture(IMMORTAL_TEXTURE);
11439
- BindTextures(checker.GetTextures(), checker.texres);
11750
+ try
11751
+ {
11752
+ BindTextures(checker.GetTextures(), checker.texres);
11753
+ }
11754
+ catch (Exception e)
11755
+ {
11756
+ System.err.println("FAILED: " + checker.GetTextures());
11757
+ }
1144011758 // NEAREST
1144111759 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211760 DrawChecker(gl);
....@@ -11518,7 +11836,7 @@
1151811836 return;
1151911837 }
1152011838
11521
- String string = obj.GetToolTip();
11839
+ String string = obj.toString(); //.GetToolTip();
1152211840
1152311841 GL gl = GetGL();
1152411842
....@@ -11835,8 +12153,8 @@
1183512153 //obj.TransformToWorld(light, light);
1183612154 for (int i = tp.size(); --i >= 0;)
1183712155 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- LA.xformPos(light, tp.get(i).toParent, light);
12156
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12157
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184012158 }
1184112159
1184212160
....@@ -11853,8 +12171,8 @@
1185312171 parentcam = cameras[0];
1185412172 }
1185512173
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12174
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12175
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185812176
1185912177 LA.xformPos(light, renderCamera.toScreen, light);
1186012178
....@@ -12468,8 +12786,8 @@
1246812786
1246912787 // display shadow only (bump == 0)
1247012788 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12789
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12790
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312791 "SUB temp.y, one.x, temp.z;" +
1247412792 "MUL temp.x, temp.x, temp.y;" +
1247512793 "KIL temp.x;" +
....@@ -12598,8 +12916,10 @@
1259812916 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912917
1260012918 "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
12919
+ // Tuning for default skin
12920
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12921
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12922
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260312923 "MUL temp.x, temp.x, temp.y;" +
1260412924
1260512925 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12798,7 +13118,7 @@
1279813118 //once = true;
1279913119 }
1280013120
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
13121
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280213122 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280313123 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280413124
....@@ -12931,12 +13251,16 @@
1293113251
1293213252 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313253 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13254
+
13255
+ // Compare fragment depth in light space with shadowmap.
1293413256 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513257 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13258
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13259
+
13260
+ // Reverse comparison
1293713261 "SUB temp.x, one.x, temp.x;" +
1293813262 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13263
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013264 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113265
1294213266 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13274,10 @@
1295013274 // No shadow for backface
1295113275 "DP3 temp.x, normal, lightd;" +
1295213276 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13277
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13278
+
13279
+ // No shadow when out of frustrum
13280
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295313281 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413282 "";
1295513283 }
....@@ -13096,7 +13424,8 @@
1309613424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309713425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309813426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13099
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1310013429
1310113430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310213431 // OUT : diff, spec
....@@ -13112,9 +13441,10 @@
1311213441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311313442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311413443 //"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;" +
13444
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13445
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13446
+
13447
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1311813448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1311913449 "RCP " + dest + ".w," + dest + ".w;" +
1312013450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13508,7 +13838,7 @@
1350813838 public void mousePressed(MouseEvent e)
1350913839 {
1351013840 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13841
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213842 }
1351313843
1351413844 static long prevtime = 0;
....@@ -13584,8 +13914,8 @@
1358413914 // mode |= META;
1358513915 //}
1358613916
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13917
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13918
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913919 anchorX = ax;
1359013920 anchorY = ay;
1359113921 prevX = px;
....@@ -13619,6 +13949,7 @@
1361913949 else
1362013950 if (evt.getSource() == AAtimer)
1362113951 {
13952
+ Globals.TIMERRUNNING = false;
1362213953 if (mouseDown)
1362313954 {
1362413955 //new Exception().printStackTrace();
....@@ -13644,6 +13975,10 @@
1364413975 // LIVE = waslive;
1364513976 // wasliveok = true;
1364613977 // waslive = false;
13978
+
13979
+ // May 2019 Forget it:
13980
+ if (true)
13981
+ return;
1364713982
1364813983 // source == timer
1364913984 if (mouseDown)
....@@ -13674,7 +14009,7 @@
1367414009
1367514010 // fev 2014???
1367614011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13677
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367814013 pingthread.StepToTarget(true); // true);
1367914014 }
1368014015 // if (!LIVE)
....@@ -13683,12 +14018,13 @@
1368314018
1368414019 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368514020
13686
- void clickStart(int x, int y, int modifiers)
14021
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368714022 {
1368814023 if (!wasliveok)
1368914024 return;
1369014025
1369114026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1369214028
1369314029 // waslive = LIVE;
1369414030 // LIVE = false;
....@@ -13700,7 +14036,7 @@
1370014036 // touched = true; // main DL
1370114037 if (isRenderer)
1370214038 {
13703
- SetMouseMode(modifiers);
14039
+ SetMouseMode(modifiers, modifiersex);
1370414040 }
1370514041
1370614042 selectX = anchorX = x;
....@@ -13713,7 +14049,7 @@
1371314049 clicked = true;
1371414050 hold = false;
1371514051
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14052
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371714053 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371814054 {
1371914055 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +14080,7 @@
1374414080 info.camera = renderCamera;
1374514081 info.x = x;
1374614082 info.y = y;
13747
- info.modifiers = modifiers;
14083
+ info.modifiers = modifiersex;
1374814084 editObj = object.doEditClick(info, 0);
1374914085 if (!editObj)
1375014086 {
....@@ -13761,9 +14097,12 @@
1376114097
1376214098 public void mouseDragged(MouseEvent e)
1376314099 {
14100
+ Globals.MOUSEDRAGGED = true;
14101
+
1376414102 //System.out.println("mouseDragged: " + e);
1376514103 if (isRenderer)
1376614104 movingcamera = true;
14105
+
1376714106 //if (drawing)
1376814107 //return;
1376914108 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +14112,7 @@
1377314112 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377414113 }
1377514114 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
14115
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377714116
1377814117 //try { Thread.sleep(1); } catch (Exception ex) {}
1377914118 }
....@@ -13946,6 +14285,7 @@
1394614285
1394714286 public void run()
1394814287 {
14288
+ new Exception().printStackTrace();
1394914289 System.exit(0);
1395014290 for (;;)
1395114291 {
....@@ -14009,7 +14349,7 @@
1400914349 {
1401014350 Globals.lighttouched = true;
1401114351 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14352
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314353 }
1401414354 //else
1401514355 }
....@@ -14023,12 +14363,12 @@
1402314363 void GoDown(int mod)
1402414364 {
1402514365 MODIFIERS |= COMMAND;
14026
- /*
14366
+ /**/
1402714367 if((mod&SHIFT) == SHIFT)
1402814368 manipCamera.RotatePosition(0, -speed);
1402914369 else
14030
- manipCamera.BackForth(0, -speed*delta, getWidth());
14031
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1403214372 if ((mod & SHIFT) == SHIFT)
1403314373 {
1403414374 mouseMode = mouseMode; // VR??
....@@ -14044,12 +14384,12 @@
1404414384 void GoUp(int mod)
1404514385 {
1404614386 MODIFIERS |= COMMAND;
14047
- /*
14387
+ /**/
1404814388 if((mod&SHIFT) == SHIFT)
1404914389 manipCamera.RotatePosition(0, speed);
1405014390 else
14051
- manipCamera.BackForth(0, speed*delta, getWidth());
14052
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1405314393 if ((mod & SHIFT) == SHIFT)
1405414394 {
1405514395 mouseMode = mouseMode;
....@@ -14065,12 +14405,12 @@
1406514405 void GoLeft(int mod)
1406614406 {
1406714407 MODIFIERS |= COMMAND;
14068
- /*
14408
+ /**/
1406914409 if((mod&SHIFT) == SHIFT)
14070
- manipCamera.RotatePosition(speed, 0);
14071
- else
1407214410 manipCamera.Translate(speed*delta, 0, getWidth());
14073
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1407414414 if ((mod & SHIFT) == SHIFT)
1407514415 {
1407614416 mouseMode = mouseMode;
....@@ -14086,12 +14426,12 @@
1408614426 void GoRight(int mod)
1408714427 {
1408814428 MODIFIERS |= COMMAND;
14089
- /*
14429
+ /**/
1409014430 if((mod&SHIFT) == SHIFT)
14091
- manipCamera.RotatePosition(-speed, 0);
14092
- else
1409314431 manipCamera.Translate(-speed*delta, 0, getWidth());
14094
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1409514435 if ((mod & SHIFT) == SHIFT)
1409614436 {
1409714437 mouseMode = mouseMode;
....@@ -14109,7 +14449,7 @@
1410914449 int X, Y;
1411014450 boolean SX, SY;
1411114451
14112
- void drag(int x, int y, int modifiers)
14452
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314453 {
1411414454 if (IsFrozen())
1411514455 {
....@@ -14118,17 +14458,17 @@
1411814458
1411914459 drag = true; // NEW
1412014460
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14461
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214462
1412314463 X = x;
1412414464 Y = y;
1412514465 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14466
+ MODIFIERS = modifiersex;
14467
+ modifiersex &= ~1024;
1412814468 if (false) // modifiers != 0)
1412914469 {
1413014470 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14471
+ System.out.println("mouseDragged: " + modifiersex);
1413214472 System.out.println("SHIFT = " + SHIFT);
1413314473 System.out.println("CONTROL = " + COMMAND);
1413414474 System.out.println("META = " + META);
....@@ -14148,7 +14488,8 @@
1414814488 info.camera = renderCamera;
1414914489 info.x = x;
1415014490 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214493 } else
1415314494 {
1415414495 if (x < startX)
....@@ -14312,7 +14653,9 @@
1431214653 ci.camera = renderCamera;
1431314654 if (!isRenderer)
1431414655 {
14315
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1431614659 {
1431714660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1431814661 } else
....@@ -14324,7 +14667,11 @@
1432414667
1432514668 public void mouseReleased(MouseEvent e)
1432614669 {
14670
+ Globals.MOUSEDRAGGED = false;
14671
+
1432714672 movingcamera = false;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1432814675 //System.out.println("mouseReleased: " + e);
1432914676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014677 }
....@@ -14347,9 +14694,9 @@
1434714694 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814695 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914696
14350
- if (control || command || IsFrozen())
14697
+// No delay if (control || command || IsFrozen())
1435114698 timeout = true;
14352
- else
14699
+// ?? May 2019 else
1435314700 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414701 mouseDown = false;
1435514702 if (!control && !command) // june 2013
....@@ -14459,7 +14806,7 @@
1445914806 System.out.println("keyReleased: " + e);
1446014807 }
1446114808
14462
- void SetMouseMode(int modifiers)
14809
+ void SetMouseMode(int modifiers, int modifiersex)
1446314810 {
1446414811 //System.out.println("SetMouseMode = " + modifiers);
1446514812 //modifiers &= ~1024;
....@@ -14471,25 +14818,25 @@
1447114818 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214819 // return;
1447314820 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14821
+ if ((modifiersex & WHEEL) == WHEEL)
1447514822 {
1447614823 mouseMode |= ZOOM;
1447714824 }
1447814825
1447914826 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14827
+ if (capsLocked) // || (modifiers & META) == META)
1448114828 {
1448214829 mouseMode |= VR; // BACKFORTH;
1448314830 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14831
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514832 {
1448614833 mouseMode |= SELECT;
1448714834 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14835
+ if ((modifiersex & COMMAND) == COMMAND)
1448914836 {
1449014837 mouseMode |= SELECT;
1449114838 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14839
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314840 {
1449414841 mouseMode &= ~VR;
1449514842 mouseMode |= TRANSLATE;
....@@ -14518,7 +14865,7 @@
1451814865
1451914866 if (isRenderer) //
1452014867 {
14521
- SetMouseMode(modifiers);
14868
+ SetMouseMode(0, modifiers);
1452214869 }
1452314870
1452414871 Globals.theRenderer.keyPressed(key);
....@@ -14665,7 +15012,9 @@
1466515012 case 'E' : COMPACT ^= true;
1466615013 repaint();
1466715014 break;
14668
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1466915018 repaint();
1467015019 break;
1467115020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14690,8 +15039,8 @@
1469015039 RevertCamera();
1469115040 repaint();
1469215041 break;
14693
- case 'L':
1469415042 case 'l':
15043
+ //case 'L':
1469515044 if (lightMode)
1469615045 {
1469715046 lightMode = false;
....@@ -14834,9 +15183,9 @@
1483415183 case '_':
1483515184 kompactbit = 5;
1483615185 break;
14837
- case '+':
14838
- kompactbit = 6;
14839
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1484015189 case ' ':
1484115190 lightMode ^= true;
1484215191 Globals.lighttouched = true;
....@@ -14848,13 +15197,14 @@
1484815197 case ESC:
1484915198 RENDERPROGRAM += 1;
1485015199 RENDERPROGRAM %= 3;
15200
+
1485115201 repaint();
1485215202 break;
1485315203 case 'Z':
1485415204 //RESIZETEXTURE ^= true;
1485515205 //break;
1485615206 case 'z':
14857
- RENDERSHADOW ^= true;
15207
+ Globals.RENDERSHADOW ^= true;
1485815208 Globals.lighttouched = true;
1485915209 repaint();
1486015210 break;
....@@ -14887,8 +15237,9 @@
1488715237 case DELETE:
1488815238 ClearSelection();
1488915239 break;
14890
- /*
1489115240 case '+':
15241
+
15242
+ /*
1489215243 //fontsize += 1;
1489315244 bbzoom *= 2;
1489415245 repaint();
....@@ -14905,17 +15256,17 @@
1490515256 case '=':
1490615257 IncDepth();
1490715258 //fontsize += 1;
14908
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1490915260 maskbit = 6;
1491015261 break;
1491115262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491215263 DecDepth();
1491315264 maskbit = 5;
1491415265 //if(fontsize > 1) fontsize -= 1;
14915
- if (object.editWindow == null)
14916
- new Exception().printStackTrace();
14917
- else
14918
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1491915270 break;
1492015271 case '{':
1492115272 manipCamera.shaper_fovy /= 1.1;
....@@ -14978,7 +15329,7 @@
1497815329 //mode = ROTATE;
1497915330 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015331 {
14981
- SetMouseMode(modifiers);
15332
+ SetMouseMode(0, modifiers);
1498215333 }
1498315334 }
1498415335
....@@ -15114,7 +15465,7 @@
1511415465 {
1511515466 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615467 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15468
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1511815469 {
1511915470 mouseMoved(e);
1512015471 } else
....@@ -15139,11 +15490,12 @@
1513915490 }
1514015491 */
1514115492
15142
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1514315494 }
1514415495
1514515496 void SelectParent()
1514615497 {
15498
+ new Exception().printStackTrace();
1514715499 System.exit(0);
1514815500 Composite group = (Composite) object;
1514915501 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15155,10 +15507,10 @@
1515515507 {
1515615508 //selectees.remove(i);
1515715509 System.out.println("select parent of " + elem);
15158
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1515915511 } else
1516015512 {
15161
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516215514 }
1516315515
1516415516 first = false;
....@@ -15167,6 +15519,7 @@
1516715519
1516815520 void SelectChildren()
1516915521 {
15522
+ new Exception().printStackTrace();
1517015523 System.exit(0);
1517115524 /*
1517215525 Composite group = (Composite) object;
....@@ -15199,12 +15552,12 @@
1519915552 for (int j = 0; j < group.children.size(); j++)
1520015553 {
1520115554 elem = (Object3D) group.children.elementAt(j);
15202
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520315556 first = false;
1520415557 }
1520515558 } else
1520615559 {
15207
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520815561 }
1520915562
1521015563 first = false;
....@@ -15215,21 +15568,21 @@
1521515568 {
1521615569 //Composite group = (Composite) object;
1521715570 Object3D group = object;
15218
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1521915572 }
1522015573
1522115574 void ResetTransform(int mask)
1522215575 {
1522315576 //Composite group = (Composite) object;
1522415577 Object3D group = object;
15225
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1522615579 }
1522715580
1522815581 void FlipTransform()
1522915582 {
1523015583 //Composite group = (Composite) object;
1523115584 Object3D group = object;
15232
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1523315586 // group.editWindow.ReduceMesh(true);
1523415587 }
1523515588
....@@ -15237,7 +15590,7 @@
1523715590 {
1523815591 //Composite group = (Composite) object;
1523915592 Object3D group = object;
15240
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1524115594 // group.editWindow.ReduceMesh(true);
1524215595 }
1524315596
....@@ -15245,7 +15598,7 @@
1524515598 {
1524615599 //Composite group = (Composite) object;
1524715600 Object3D group = object;
15248
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1524915602 }
1525015603
1525115604 void IncDepth()
....@@ -15331,7 +15684,9 @@
1533115684 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215685 //Image img = CreateImage(width, height);
1533315686 //System.out.println("width = " + width + "; height = " + height + "\n");
15687
+
1533415688 Graphics gr = g; // img.getGraphics();
15689
+
1533515690 if (!hasMarquee)
1533615691 {
1533715692 if (Xmin < Xmax) // !locked)
....@@ -15419,6 +15774,7 @@
1541915774 info.bounds.y += (height - desired) / 2;
1542015775 }
1542115776 }
15777
+
1542215778 info.g = gr;
1542315779 info.camera = renderCamera;
1542415780 /*
....@@ -15428,15 +15784,55 @@
1542815784 */
1542915785 if (!isRenderer)
1543015786 {
15431
- object.drawEditHandles(info, 0);
15787
+ Grafreed.Assert(object != null);
15788
+ Grafreed.Assert(object.selection != null);
15789
+ if (object.selection.Size() > 0)
15790
+ {
15791
+ int hitSomething = object.selection.get(0).hitSomething;
15792
+
15793
+ info.DX = 0;
15794
+ info.DY = 0;
15795
+ info.W = 1;
15796
+ if (hitSomething == Object3D.hitCenter)
15797
+ {
15798
+ info.DX = X;
15799
+ if (X != 0)
15800
+ info.DX -= info.bounds.width/2;
15801
+
15802
+ info.DY = Y;
15803
+ if (Y != 0)
15804
+ info.DY -= info.bounds.height/2;
15805
+ }
15806
+
15807
+ object.drawEditHandles(info, 0);
15808
+
15809
+ if (drag && (X != 0 || Y != 0))
15810
+ {
15811
+ switch (hitSomething)
15812
+ {
15813
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15814
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15815
+ break;
15816
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15817
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15818
+ break;
15819
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15820
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15821
+ break;
15822
+ }
15823
+
15824
+ }
15825
+ }
1543215826 }
1543315827 }
15828
+
1543415829 if (isRenderer)
1543515830 {
1543615831 //gr.setColor(Color.black);
1543715832 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815833 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915834 }
15835
+
1544015836 if (hasMarquee)
1544115837 {
1544215838 gr.setXORMode(Color.white);
....@@ -15549,6 +15945,7 @@
1554915945 public boolean mouseDown(Event evt, int x, int y)
1555015946 {
1555115947 System.out.println("mouseDown: " + evt);
15948
+ System.exit(0);
1555215949 /*
1555315950 locked = true;
1555415951 drag = false;
....@@ -15592,7 +15989,7 @@
1559215989 {
1559315990 keyPressed(0, modifiers);
1559415991 }
15595
- clickStart(x, y, modifiers);
15992
+ // clickStart(x, y, modifiers);
1559615993 return true;
1559715994 }
1559815995
....@@ -15710,7 +16107,7 @@
1571016107 {
1571116108 keyReleased(0, 0);
1571216109 }
15713
- drag(x, y, modifiers);
16110
+ drag(x, y, 0, modifiers);
1571416111 return true;
1571516112 }
1571616113
....@@ -15842,7 +16239,7 @@
1584216239 Object3D object;
1584316240 static Object3D trackedobject;
1584416241 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16242
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616243 /*static*/ Camera eyeCamera;
1584716244 /*static*/ Camera lightCamera;
1584816245 int cameracount;
....@@ -16127,16 +16524,16 @@
1612716524 cStatic.objectstack[materialdepth++] = checker;
1612816525 //System.out.println("material " + material);
1612916526 //Applet3D.tracein(this, selected);
16130
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1613116528
1613216529 //checker.GetMaterial().Draw(this, false); // true);
16133
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613416531
1613516532 materialdepth -= 1;
1613616533 if (materialdepth > 0)
1613716534 {
16138
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16139
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16535
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16536
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614016537 }
1614116538 //checker.GetMaterial().opacity = 1f;
1614216539 ////checker.GetMaterial().ambient = 1f;
....@@ -16222,6 +16619,14 @@
1622216619 }
1622316620 }
1622416621
16622
+ private Object3D GetFolder()
16623
+ {
16624
+ Object3D folder = object.GetWindow().copy;
16625
+ if (object.GetWindow().copy.selection.Size() > 0)
16626
+ folder = object.GetWindow().copy.selection.elementAt(0);
16627
+ return folder;
16628
+ }
16629
+
1622516630 class SelectBuffer implements GLEventListener
1622616631 {
1622716632
....@@ -16280,6 +16685,7 @@
1628016685 {
1628116686 if (!selection)
1628216687 {
16688
+ new Exception().printStackTrace();
1628316689 System.exit(0);
1628416690 return;
1628516691 }
....@@ -16300,6 +16706,17 @@
1630016706
1630116707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630216708
16709
+ if (PAINTMODE)
16710
+ {
16711
+ if (object.GetWindow().copy.selection.Size() > 0)
16712
+ {
16713
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16714
+
16715
+ // Make what you paint not selectable.
16716
+ paintobj.ResetSelectable();
16717
+ }
16718
+ }
16719
+
1630316720 //int tmp = selection_view;
1630416721 //selection_view = -1;
1630516722 int temp = DrawMode();
....@@ -16311,6 +16728,17 @@
1631116728 // temp = DEFAULT; // patch for selection debug
1631216729 Globals.drawMode = temp; // WARNING
1631316730
16731
+ if (PAINTMODE)
16732
+ {
16733
+ if (object.GetWindow().copy.selection.Size() > 0)
16734
+ {
16735
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16736
+
16737
+ // Revert.
16738
+ paintobj.RestoreSelectable();
16739
+ }
16740
+ }
16741
+
1631416742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1631516743
1631616744 // trying different ways of getting the depth info over
....@@ -16358,6 +16786,8 @@
1635816786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1635916787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636016788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1636116791
1636216792 // Will fit the mesh !!!
1636316793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16407,34 +16837,36 @@
1640716837 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]));
1640816838 }
1640916839
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16840
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116841 }
1641216842 }
1641316843
1641416844 if (!movingcamera && !PAINTMODE)
16415
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1641616846
16417
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16847
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1641816848 {
16419
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16849
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642016850
16421
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642216854
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();
16855
+ Object3D inst = new Object3D("inst" + paintcount++);
16856
+
16857
+ inst.CreateMaterial(); // use a void leaf to select instances
16858
+
16859
+ inst.add(paintobj); // link
16860
+
16861
+ object.GetWindow().SnapObject(inst);
16862
+
16863
+ Object3D folder = paintFolder; // GetFolder();
16864
+
16865
+ folder.add(inst);
16866
+
16867
+ object.GetWindow().ResetModel();
16868
+ object.GetWindow().refreshContents();
16869
+ }
1643816870 }
1643916871 else
1644016872 paintcount = 0;
....@@ -16473,6 +16905,11 @@
1647316905 //System.out.println("objects[color] = " + objects[color]);
1647416906 //objects[color].Select();
1647516907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1647616913 object.Select(color, deselect);
1647716914 }
1647816915
....@@ -16572,7 +17009,7 @@
1657217009 gl.glDisable(gl.GL_CULL_FACE);
1657317010 }
1657417011
16575
- if (!RENDERSHADOW)
17012
+ if (!Globals.RENDERSHADOW)
1657617013 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657717014
1657817015 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +17019,7 @@
1658217019 //gl.glColorMask(false, false, false, false);
1658317020
1658417021 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17022
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658617023 {
1658717024 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658817025
....@@ -16998,23 +17435,15 @@
1699817435 int AAbuffersize = 0;
1699917436
1700017437 //double[] selectedpoint = new double[3];
17001
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1700217439 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();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1700717444
1700817445 static Sphere debugpoints[] = new Sphere[8];
1700917446
17010
- static
17011
- {
17012
- for (int i=0; i<8; i++)
17013
- {
17014
- debugpoints[i] = new Sphere();
17015
- }
17016
- }
17017
-
1701817447 static void InitPoints(float radius)
1701917448 {
1702017449 for (int i=0; i<8; i++)