Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
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,8 +55,6 @@
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;
....@@ -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()
....@@ -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()
....@@ -2376,7 +2397,7 @@
23762397 {
23772398 return currentGL;
23782399 }
2379
-
2400
+
23802401 /**/
23812402 class CacheTexture
23822403 {
....@@ -4208,6 +4229,7 @@
42084229
42094230 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104231 {
4232
+ new Exception().printStackTrace();
42114233 System.exit(0);
42124234 com.sun.opengl.util.texture.Texture texture = null;
42134235
....@@ -7920,6 +7942,64 @@
79207942 ReleaseTexture(pigment, false);
79217943 }
79227944
7945
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7946
+ {
7947
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7948
+ {
7949
+ return;
7950
+ }
7951
+
7952
+ if (tex == null)
7953
+ {
7954
+ ReleaseTexture(null, false);
7955
+ return;
7956
+ }
7957
+
7958
+ String pigment = Object3D.GetPigment(tex);
7959
+
7960
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7961
+ {
7962
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7963
+ // System.out.println("; bump = " + bump);
7964
+ }
7965
+
7966
+ if (pigment.equals(""))
7967
+ {
7968
+ pigment = null;
7969
+ }
7970
+
7971
+ ReleaseTexture(pigment, false);
7972
+ }
7973
+
7974
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7975
+ {
7976
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7977
+ {
7978
+ return;
7979
+ }
7980
+
7981
+ if (tex == null)
7982
+ {
7983
+ ReleaseTexture(null, true);
7984
+ return;
7985
+ }
7986
+
7987
+ String bump = Object3D.GetBump(tex);
7988
+
7989
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7990
+ {
7991
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7992
+ // System.out.println("; bump = " + bump);
7993
+ }
7994
+
7995
+ if (bump.equals(""))
7996
+ {
7997
+ bump = null;
7998
+ }
7999
+
8000
+ ReleaseTexture(bump, true);
8001
+ }
8002
+
79238003 void ReleaseTexture(String tex, boolean bump)
79248004 {
79258005 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8023,7 +8103,7 @@
80238103 }
80248104 }
80258105
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8106
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80278107 {
80288108 if (// DrawMode() != 0 || /*tex == null ||*/
80298109 ambientOcclusion ) // || !textureon)
....@@ -8068,7 +8148,94 @@
80688148 return; // true;
80698149 }
80708150
8071
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8151
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8152
+ {
8153
+ if (// DrawMode() != 0 || /*tex == null ||*/
8154
+ ambientOcclusion ) // || !textureon)
8155
+ {
8156
+ return; // false;
8157
+ }
8158
+
8159
+ if (tex == null)
8160
+ {
8161
+ BindTexture(null,false,resolution);
8162
+ return;
8163
+ }
8164
+
8165
+ String pigment = Object3D.GetPigment(tex);
8166
+
8167
+ usedtextures.put(pigment, pigment);
8168
+
8169
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8170
+ {
8171
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8172
+ // System.out.println("; bump = " + bump);
8173
+ }
8174
+
8175
+ if (pigment.equals(""))
8176
+ {
8177
+ pigment = null;
8178
+ }
8179
+
8180
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8181
+ BindTexture(pigment, false, resolution);
8182
+ }
8183
+
8184
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8185
+ {
8186
+ if (// DrawMode() != 0 || /*tex == null ||*/
8187
+ ambientOcclusion ) // || !textureon)
8188
+ {
8189
+ return; // false;
8190
+ }
8191
+
8192
+ if (tex == null)
8193
+ {
8194
+ BindTexture(null,true,resolution);
8195
+ return;
8196
+ }
8197
+
8198
+ String bump = Object3D.GetBump(tex);
8199
+
8200
+ usedtextures.put(bump, bump);
8201
+
8202
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8203
+ {
8204
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8205
+ // System.out.println("; bump = " + bump);
8206
+ }
8207
+
8208
+ if (bump.equals(""))
8209
+ {
8210
+ bump = null;
8211
+ }
8212
+
8213
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8214
+ BindTexture(bump, true, resolution);
8215
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8216
+ }
8217
+
8218
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8219
+
8220
+ private boolean FileExists(String tex)
8221
+ {
8222
+ if (missingTextures.contains(tex))
8223
+ {
8224
+ return false;
8225
+ }
8226
+
8227
+ boolean fileExists = new File(tex).exists();
8228
+
8229
+ if (!fileExists)
8230
+ {
8231
+ // If file exists, the "new File()" is not executed sgain
8232
+ missingTextures.add(tex);
8233
+ }
8234
+
8235
+ return fileExists;
8236
+ }
8237
+
8238
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80728239 {
80738240 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80748241
....@@ -8076,12 +8243,18 @@
80768243 {
80778244 String texname = tex;
80788245
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;
8246
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8247
+
8248
+// String[] split = tex.split("Textures");
8249
+// if (split.length > 1)
8250
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8251
+// else
8252
+// if (!texname.startsWith("/"))
8253
+// texname = "/Users/nbriere/Textures/" + texname;
8254
+ if (!FileExists(tex))
8255
+ {
8256
+ texname = fallbackTextureName;
8257
+ }
80858258
80868259 if (CACHETEXTURE)
80878260 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8150,7 +8323,7 @@
81508323 }
81518324
81528325 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8326
+ if (!FileExists(cachename))
81548327 cachename = texname;
81558328 else
81568329 processbump = false; // don't process bump map again
....@@ -8172,7 +8345,7 @@
81728345 }
81738346
81748347 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8348
+ if (!FileExists(cachename))
81768349 cachename = texname;
81778350 else
81788351 processbump = false; // don't process bump map again
....@@ -8181,7 +8354,9 @@
81818354 texturedata = GetFileTexture(cachename, processbump, resolution);
81828355
81838356
8184
- if (texturedata != null)
8357
+ if (texturedata == null)
8358
+ throw new Exception();
8359
+
81858360 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868361 //texture = GetTexture(tex, bump);
81878362 }
....@@ -8303,7 +8478,7 @@
83038478 return texture;
83048479 }
83058480
8306
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8481
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83078482 {
83088483 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83098484
....@@ -8321,14 +8496,14 @@
83218496 return texture!=null?texture.texture:null;
83228497 }
83238498
8324
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8499
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83258500 {
83268501 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83278502
83288503 return texture!=null?texture.texturedata:null;
83298504 }
83308505
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8506
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83328507 {
83338508 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348509 {
....@@ -9205,11 +9380,35 @@
92059380 jy8[3] = 0.5f;
92069381 }
92079382
9208
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9383
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92099384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92109385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92119386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92129387
9388
+ void ResetOptions()
9389
+ {
9390
+ options1[0] = 100;
9391
+ options1[1] = 0.025f;
9392
+ options1[2] = 0.01f;
9393
+ options1[3] = 0;
9394
+ options1[4] = 0;
9395
+
9396
+ options2[0] = 0;
9397
+ options2[1] = 0.75f;
9398
+ options2[2] = 0;
9399
+ options2[3] = 0;
9400
+
9401
+ options3[0] = 1;
9402
+ options3[1] = 1;
9403
+ options3[2] = 1;
9404
+ options3[3] = 0;
9405
+
9406
+ options4[0] = 1;
9407
+ options4[1] = 0;
9408
+ options4[2] = 1;
9409
+ options4[3] = 0;
9410
+ }
9411
+
92139412 static int imagecount = 0; // movie generation
92149413
92159414 static int jitter = 0;
....@@ -9305,8 +9504,8 @@
93059504 assert (parentcam != renderCamera);
93069505
93079506 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9507
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9508
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109509
93119510 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129511
....@@ -9321,8 +9520,8 @@
93219520 LA.matCopy(renderCamera.fromScreen, matrix);
93229521
93239522 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9523
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9524
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269525
93279526 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289527
....@@ -9394,7 +9593,7 @@
93949593 //gl.glFlush();
93959594 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969595
9397
- if (ANIMATION && ABORTED)
9596
+ if (Globals.ANIMATION && ABORTED)
93989597 {
93999598 System.err.println(" ABORTED FRAME");
94009599 break;
....@@ -9424,7 +9623,7 @@
94249623 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259624
94269625 // save image
9427
- if (ANIMATION && !ABORTED)
9626
+ if (Globals.ANIMATION && !ABORTED)
94289627 {
94299628 VPwidth = viewport[2];
94309629 VPheight = viewport[3];
....@@ -9535,11 +9734,11 @@
95359734
95369735 // imagecount++;
95379736
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9737
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399738
95409739 if (!BOXMODE)
95419740 {
9542
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9741
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95439742 }
95449743
95459744 if (!BOXMODE)
....@@ -9577,7 +9776,7 @@
95779776 ABORTED = false;
95789777 }
95799778 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9779
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819780
95829781 if (false)
95839782 {
....@@ -10240,11 +10439,11 @@
1024010439
1024110440 public void display(GLAutoDrawable drawable)
1024210441 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10442
+ if (Grafreed.savesound && Grafreed.hassound)
1024410443 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10444
+ Grafreed.wav.save();
10445
+ Grafreed.savesound = false;
10446
+ Grafreed.hassound = false;
1024810447 }
1024910448 // if (DEBUG_SELECTION)
1025010449 // {
....@@ -10320,6 +10519,7 @@
1032010519 ANTIALIAS = 0;
1032110520 //System.out.println("RESTART");
1032210521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1032310523 }
1032410524 }
1032510525 }
....@@ -10374,7 +10574,7 @@
1037410574 Object3D theobject = object;
1037510575 Object3D theparent = object.parent;
1037610576 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10577
+ object = (Object3D)Grafreed.clone(object);
1037810578 object.Stripify();
1037910579 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010580 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10587,14 @@
1038710587 ambientOcclusion = false;
1038810588 }
1038910589
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110592 {
1039210593 //if (RENDERSHADOW) // ?
1039310594 if (!IsFrozen())
1039410595 {
1039510596 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10597
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710598 {
1039810599 Globals.framecount++;
1039910600 shadowbuffer.display();
....@@ -10520,8 +10721,8 @@
1052010721
1052110722 // if (parentcam != renderCamera) // not a light
1052210723 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10724
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10725
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510726
1052610727 for (int j = 0; j < 4; j++)
1052710728 {
....@@ -10535,8 +10736,8 @@
1053510736
1053610737 // if (parentcam != renderCamera) // not a light
1053710738 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10739
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10740
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010741
1054110742 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210743
....@@ -10795,7 +10996,16 @@
1079510996 // Bump noise
1079610997 gl.glActiveTexture(GL.GL_TEXTURE6);
1079710998 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- BindTexture(NOISE_TEXTURE, false, 2);
10999
+
11000
+ try
11001
+ {
11002
+ BindTexture(NOISE_TEXTURE, false, 2);
11003
+ }
11004
+ catch (Exception e)
11005
+ {
11006
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11007
+ }
11008
+
1079911009
1080011010 gl.glActiveTexture(GL.GL_TEXTURE0);
1080111011 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10920,8 +11130,8 @@
1092011130 System.err.println("parentcam != renderCamera");
1092111131
1092211132 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11133
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11134
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092511135 }
1092611136
1092711137 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11152,8 @@
1094211152 if (true) // TODO
1094311153 {
1094411154 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11155
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11156
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094711157 }
1094811158
1094911159 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11469,14 @@
1125911469 {
1126011470 renderpass++;
1126111471 // System.out.println("Draw object... ");
11472
+ STEP = 1;
1126211473 if (FAST) // in case there is no script
11263
- STEP = 16;
11474
+ STEP = 8;
11475
+
11476
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11477
+ {
11478
+ STEP *= 4;
11479
+ }
1126411480
1126511481 //object.FullInvariants();
1126611482
....@@ -11274,16 +11490,37 @@
1127411490 e.printStackTrace();
1127511491 }
1127611492
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11493
+ if (Grafreed.RENDERME > 0)
11494
+ Grafreed.RENDERME--; // mechante magouille
1127911495
1128011496 Globals.ONESTEP = false;
1128111497 }
1128211498
1128311499 static boolean zoomonce = false;
1128411500
11501
+ static void CreateSelectedPoint()
11502
+ {
11503
+ if (selectedpoint == null)
11504
+ {
11505
+ debugpointG = new Sphere();
11506
+ debugpointP = new Sphere();
11507
+ debugpointC = new Sphere();
11508
+ debugpointR = new Sphere();
11509
+
11510
+ selectedpoint = new Superellipsoid();
11511
+
11512
+ for (int i=0; i<8; i++)
11513
+ {
11514
+ debugpoints[i] = new Sphere();
11515
+ }
11516
+ }
11517
+ }
11518
+
1128511519 void DrawObject(GL gl, boolean draw)
1128611520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1128711524 //System.out.println("DRAW OBJECT " + mouseDown);
1128811525 // DrawMode() = SELECTION;
1128911526 //GL gl = getGL();
....@@ -11345,7 +11582,14 @@
1134511582
1134611583 usedtextures.clear();
1134711584
11348
- BindTextures(DEFAULT_TEXTURES, 2);
11585
+ try
11586
+ {
11587
+ BindTextures(DEFAULT_TEXTURES, 2);
11588
+ }
11589
+ catch (Exception e)
11590
+ {
11591
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11592
+ }
1134911593 }
1135011594 //System.out.println("--> " + stackdepth);
1135111595 // GrafreeD.traceon();
....@@ -11355,8 +11599,9 @@
1135511599
1135611600 if (DrawMode() == DEFAULT)
1135711601 {
11358
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1135911603 {
11604
+ CreateSelectedPoint();
1136011605 float radius = 0.05f;
1136111606 if (selectedpoint.radius != radius)
1136211607 {
....@@ -11436,7 +11681,14 @@
1143611681 if (checker != null && DrawMode() == DEFAULT)
1143711682 {
1143811683 //BindTexture(IMMORTAL_TEXTURE);
11439
- BindTextures(checker.GetTextures(), checker.texres);
11684
+ try
11685
+ {
11686
+ BindTextures(checker.GetTextures(), checker.texres);
11687
+ }
11688
+ catch (Exception e)
11689
+ {
11690
+ System.err.println("FAILED: " + checker.GetTextures());
11691
+ }
1144011692 // NEAREST
1144111693 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211694 DrawChecker(gl);
....@@ -11518,7 +11770,7 @@
1151811770 return;
1151911771 }
1152011772
11521
- String string = obj.GetToolTip();
11773
+ String string = obj.toString(); //.GetToolTip();
1152211774
1152311775 GL gl = GetGL();
1152411776
....@@ -11835,8 +12087,8 @@
1183512087 //obj.TransformToWorld(light, light);
1183612088 for (int i = tp.size(); --i >= 0;)
1183712089 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- LA.xformPos(light, tp.get(i).toParent, light);
12090
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12091
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184012092 }
1184112093
1184212094
....@@ -11853,8 +12105,8 @@
1185312105 parentcam = cameras[0];
1185412106 }
1185512107
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12108
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12109
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185812110
1185912111 LA.xformPos(light, renderCamera.toScreen, light);
1186012112
....@@ -12468,8 +12720,8 @@
1246812720
1246912721 // display shadow only (bump == 0)
1247012722 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12723
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12724
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312725 "SUB temp.y, one.x, temp.z;" +
1247412726 "MUL temp.x, temp.x, temp.y;" +
1247512727 "KIL temp.x;" +
....@@ -12598,8 +12850,10 @@
1259812850 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912851
1260012852 "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
12853
+ // Tuning for default skin
12854
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12855
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12856
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260312857 "MUL temp.x, temp.x, temp.y;" +
1260412858
1260512859 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12747,7 +13001,7 @@
1274713001 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274813002 "FLR final.x, final.y;" +
1274913003 "SUB final.y, final.y, final.x;" +
12750
- //"MUL final.x, final.x, c256i;" +
13004
+ "MUL final.x, final.x, c256i;" +
1275113005 "MOV final.z, zero.x;" +
1275213006 "MOV final.a, one.w;":""
1275313007 ) +
....@@ -12755,7 +13009,7 @@
1275513009 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275613010 "FLR final.x, final.y;" +
1275713011 "SUB final.y, final.y, final.x;" +
12758
- //"MUL final.x, final.x, c256i;" +
13012
+ "MUL final.x, final.x, c256i;" +
1275913013 "MOV final.z, zero.x;" +
1276013014 "MOV final.a, one.w;":""
1276113015 ) +
....@@ -12798,7 +13052,7 @@
1279813052 //once = true;
1279913053 }
1280013054
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
13055
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280213056 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280313057 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280413058
....@@ -12931,12 +13185,16 @@
1293113185
1293213186 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313187 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13188
+
13189
+ // Compare fragment depth in light space with shadowmap.
1293413190 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513191 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13192
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13193
+
13194
+ // Reverse comparison
1293713195 "SUB temp.x, one.x, temp.x;" +
1293813196 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13197
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013198 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113199
1294213200 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13208,10 @@
1295013208 // No shadow for backface
1295113209 "DP3 temp.x, normal, lightd;" +
1295213210 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13211
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13212
+
13213
+ // No shadow when out of frustrum
13214
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295313215 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413216 "";
1295513217 }
....@@ -13096,7 +13358,8 @@
1309613358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309713359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309813360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13099
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1310013363
1310113364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310213365 // OUT : diff, spec
....@@ -13508,7 +13771,7 @@
1350813771 public void mousePressed(MouseEvent e)
1350913772 {
1351013773 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13774
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213775 }
1351313776
1351413777 static long prevtime = 0;
....@@ -13584,8 +13847,8 @@
1358413847 // mode |= META;
1358513848 //}
1358613849
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13850
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13851
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913852 anchorX = ax;
1359013853 anchorY = ay;
1359113854 prevX = px;
....@@ -13619,6 +13882,7 @@
1361913882 else
1362013883 if (evt.getSource() == AAtimer)
1362113884 {
13885
+ Globals.TIMERRUNNING = false;
1362213886 if (mouseDown)
1362313887 {
1362413888 //new Exception().printStackTrace();
....@@ -13644,6 +13908,10 @@
1364413908 // LIVE = waslive;
1364513909 // wasliveok = true;
1364613910 // waslive = false;
13911
+
13912
+ // May 2019 Forget it:
13913
+ if (true)
13914
+ return;
1364713915
1364813916 // source == timer
1364913917 if (mouseDown)
....@@ -13683,12 +13951,13 @@
1368313951
1368413952 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368513953
13686
- void clickStart(int x, int y, int modifiers)
13954
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368713955 {
1368813956 if (!wasliveok)
1368913957 return;
1369013958
1369113959 AAtimer.restart(); //
13960
+ Globals.TIMERRUNNING = true;
1369213961
1369313962 // waslive = LIVE;
1369413963 // LIVE = false;
....@@ -13700,7 +13969,7 @@
1370013969 // touched = true; // main DL
1370113970 if (isRenderer)
1370213971 {
13703
- SetMouseMode(modifiers);
13972
+ SetMouseMode(modifiers, modifiersex);
1370413973 }
1370513974
1370613975 selectX = anchorX = x;
....@@ -13713,7 +13982,7 @@
1371313982 clicked = true;
1371413983 hold = false;
1371513984
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13985
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371713986 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371813987 {
1371913988 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +14013,7 @@
1374414013 info.camera = renderCamera;
1374514014 info.x = x;
1374614015 info.y = y;
13747
- info.modifiers = modifiers;
14016
+ info.modifiers = modifiersex;
1374814017 editObj = object.doEditClick(info, 0);
1374914018 if (!editObj)
1375014019 {
....@@ -13761,9 +14030,12 @@
1376114030
1376214031 public void mouseDragged(MouseEvent e)
1376314032 {
14033
+ Globals.MOUSEDRAGGED = true;
14034
+
1376414035 //System.out.println("mouseDragged: " + e);
1376514036 if (isRenderer)
1376614037 movingcamera = true;
14038
+
1376714039 //if (drawing)
1376814040 //return;
1376914041 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +14045,7 @@
1377314045 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377414046 }
1377514047 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
14048
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377714049
1377814050 //try { Thread.sleep(1); } catch (Exception ex) {}
1377914051 }
....@@ -13946,6 +14218,7 @@
1394614218
1394714219 public void run()
1394814220 {
14221
+ new Exception().printStackTrace();
1394914222 System.exit(0);
1395014223 for (;;)
1395114224 {
....@@ -14009,7 +14282,7 @@
1400914282 {
1401014283 Globals.lighttouched = true;
1401114284 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14285
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314286 }
1401414287 //else
1401514288 }
....@@ -14109,7 +14382,7 @@
1410914382 int X, Y;
1411014383 boolean SX, SY;
1411114384
14112
- void drag(int x, int y, int modifiers)
14385
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314386 {
1411414387 if (IsFrozen())
1411514388 {
....@@ -14118,17 +14391,17 @@
1411814391
1411914392 drag = true; // NEW
1412014393
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14394
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214395
1412314396 X = x;
1412414397 Y = y;
1412514398 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14399
+ MODIFIERS = modifiersex;
14400
+ modifiersex &= ~1024;
1412814401 if (false) // modifiers != 0)
1412914402 {
1413014403 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14404
+ System.out.println("mouseDragged: " + modifiersex);
1413214405 System.out.println("SHIFT = " + SHIFT);
1413314406 System.out.println("CONTROL = " + COMMAND);
1413414407 System.out.println("META = " + META);
....@@ -14148,7 +14421,8 @@
1414814421 info.camera = renderCamera;
1414914422 info.x = x;
1415014423 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14424
+ object.GetWindow().copy
14425
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214426 } else
1415314427 {
1415414428 if (x < startX)
....@@ -14312,7 +14586,9 @@
1431214586 ci.camera = renderCamera;
1431314587 if (!isRenderer)
1431414588 {
14315
- if (object.editWindow.copy.doEditClick(ci, 0))
14589
+ //ObjEditor editWindow = object.editWindow;
14590
+ //Object3D copy = editWindow.copy;
14591
+ if (object.doEditClick(ci, 0))
1431614592 {
1431714593 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1431814594 } else
....@@ -14324,7 +14600,10 @@
1432414600
1432514601 public void mouseReleased(MouseEvent e)
1432614602 {
14603
+ Globals.MOUSEDRAGGED = false;
14604
+
1432714605 movingcamera = false;
14606
+ X = Y = 0;
1432814607 //System.out.println("mouseReleased: " + e);
1432914608 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014609 }
....@@ -14347,9 +14626,9 @@
1434714626 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814627 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914628
14350
- if (control || command || IsFrozen())
14629
+// No delay if (control || command || IsFrozen())
1435114630 timeout = true;
14352
- else
14631
+// ?? May 2019 else
1435314632 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414633 mouseDown = false;
1435514634 if (!control && !command) // june 2013
....@@ -14459,7 +14738,7 @@
1445914738 System.out.println("keyReleased: " + e);
1446014739 }
1446114740
14462
- void SetMouseMode(int modifiers)
14741
+ void SetMouseMode(int modifiers, int modifiersex)
1446314742 {
1446414743 //System.out.println("SetMouseMode = " + modifiers);
1446514744 //modifiers &= ~1024;
....@@ -14471,25 +14750,25 @@
1447114750 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214751 // return;
1447314752 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14753
+ if ((modifiersex & WHEEL) == WHEEL)
1447514754 {
1447614755 mouseMode |= ZOOM;
1447714756 }
1447814757
1447914758 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14759
+ if (capsLocked) // || (modifiers & META) == META)
1448114760 {
1448214761 mouseMode |= VR; // BACKFORTH;
1448314762 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14763
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514764 {
1448614765 mouseMode |= SELECT;
1448714766 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14767
+ if ((modifiersex & COMMAND) == COMMAND)
1448914768 {
1449014769 mouseMode |= SELECT;
1449114770 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14771
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314772 {
1449414773 mouseMode &= ~VR;
1449514774 mouseMode |= TRANSLATE;
....@@ -14518,7 +14797,7 @@
1451814797
1451914798 if (isRenderer) //
1452014799 {
14521
- SetMouseMode(modifiers);
14800
+ SetMouseMode(0, modifiers);
1452214801 }
1452314802
1452414803 Globals.theRenderer.keyPressed(key);
....@@ -14690,8 +14969,14 @@
1469014969 RevertCamera();
1469114970 repaint();
1469214971 break;
14693
- case 'L':
1469414972 case 'l':
14973
+ lightMode ^= true;
14974
+ Globals.lighttouched = true;
14975
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14976
+ targetLookAt.set(manipCamera.lookAt);
14977
+ repaint();
14978
+ break;
14979
+ case 'L':
1469514980 if (lightMode)
1469614981 {
1469714982 lightMode = false;
....@@ -14838,23 +15123,21 @@
1483815123 kompactbit = 6;
1483915124 break;
1484015125 case ' ':
14841
- lightMode ^= true;
14842
- Globals.lighttouched = true;
14843
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14844
- targetLookAt.set(manipCamera.lookAt);
15126
+ ObjEditor.theFrame.ToggleFullScreen();
1484515127 repaint();
1484615128 break;
1484715129 //case '`' :
1484815130 case ESC:
1484915131 RENDERPROGRAM += 1;
1485015132 RENDERPROGRAM %= 3;
15133
+
1485115134 repaint();
1485215135 break;
1485315136 case 'Z':
1485415137 //RESIZETEXTURE ^= true;
1485515138 //break;
1485615139 case 'z':
14857
- RENDERSHADOW ^= true;
15140
+ Globals.RENDERSHADOW ^= true;
1485815141 Globals.lighttouched = true;
1485915142 repaint();
1486015143 break;
....@@ -14978,7 +15261,7 @@
1497815261 //mode = ROTATE;
1497915262 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015263 {
14981
- SetMouseMode(modifiers);
15264
+ SetMouseMode(0, modifiers);
1498215265 }
1498315266 }
1498415267
....@@ -15114,7 +15397,7 @@
1511415397 {
1511515398 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615399 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15400
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1511815401 {
1511915402 mouseMoved(e);
1512015403 } else
....@@ -15139,11 +15422,12 @@
1513915422 }
1514015423 */
1514115424
15142
- object.editWindow.EditSelection();
15425
+ object.editWindow.EditSelection(false);
1514315426 }
1514415427
1514515428 void SelectParent()
1514615429 {
15430
+ new Exception().printStackTrace();
1514715431 System.exit(0);
1514815432 Composite group = (Composite) object;
1514915433 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15167,6 +15451,7 @@
1516715451
1516815452 void SelectChildren()
1516915453 {
15454
+ new Exception().printStackTrace();
1517015455 System.exit(0);
1517115456 /*
1517215457 Composite group = (Composite) object;
....@@ -15331,7 +15616,9 @@
1533115616 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215617 //Image img = CreateImage(width, height);
1533315618 //System.out.println("width = " + width + "; height = " + height + "\n");
15619
+
1533415620 Graphics gr = g; // img.getGraphics();
15621
+
1533515622 if (!hasMarquee)
1533615623 {
1533715624 if (Xmin < Xmax) // !locked)
....@@ -15429,14 +15716,33 @@
1542915716 if (!isRenderer)
1543015717 {
1543115718 object.drawEditHandles(info, 0);
15719
+
15720
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15721
+ {
15722
+ switch (object.selection.get(0).hitSomething)
15723
+ {
15724
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15725
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15726
+ break;
15727
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15728
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15729
+ break;
15730
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15731
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15732
+ break;
15733
+ }
15734
+
15735
+ }
1543215736 }
1543315737 }
15738
+
1543415739 if (isRenderer)
1543515740 {
1543615741 //gr.setColor(Color.black);
1543715742 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815743 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915744 }
15745
+
1544015746 if (hasMarquee)
1544115747 {
1544215748 gr.setXORMode(Color.white);
....@@ -15549,6 +15855,7 @@
1554915855 public boolean mouseDown(Event evt, int x, int y)
1555015856 {
1555115857 System.out.println("mouseDown: " + evt);
15858
+ System.exit(0);
1555215859 /*
1555315860 locked = true;
1555415861 drag = false;
....@@ -15592,7 +15899,7 @@
1559215899 {
1559315900 keyPressed(0, modifiers);
1559415901 }
15595
- clickStart(x, y, modifiers);
15902
+ // clickStart(x, y, modifiers);
1559615903 return true;
1559715904 }
1559815905
....@@ -15710,7 +16017,7 @@
1571016017 {
1571116018 keyReleased(0, 0);
1571216019 }
15713
- drag(x, y, modifiers);
16020
+ drag(x, y, 0, modifiers);
1571416021 return true;
1571516022 }
1571616023
....@@ -15842,7 +16149,7 @@
1584216149 Object3D object;
1584316150 static Object3D trackedobject;
1584416151 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16152
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616153 /*static*/ Camera eyeCamera;
1584716154 /*static*/ Camera lightCamera;
1584816155 int cameracount;
....@@ -16127,16 +16434,16 @@
1612716434 cStatic.objectstack[materialdepth++] = checker;
1612816435 //System.out.println("material " + material);
1612916436 //Applet3D.tracein(this, selected);
16130
- vector2buffer = checker.projectedVertices;
16437
+ //vector2buffer = checker.projectedVertices;
1613116438
1613216439 //checker.GetMaterial().Draw(this, false); // true);
16133
- DrawMaterial(checker.GetMaterial(), false); // true);
16440
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613416441
1613516442 materialdepth -= 1;
1613616443 if (materialdepth > 0)
1613716444 {
16138
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16139
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16445
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16446
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614016447 }
1614116448 //checker.GetMaterial().opacity = 1f;
1614216449 ////checker.GetMaterial().ambient = 1f;
....@@ -16280,6 +16587,7 @@
1628016587 {
1628116588 if (!selection)
1628216589 {
16590
+ new Exception().printStackTrace();
1628316591 System.exit(0);
1628416592 return;
1628516593 }
....@@ -16359,6 +16667,8 @@
1635916667 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636016668 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1636116669
16670
+ CreateSelectedPoint();
16671
+
1636216672 // Will fit the mesh !!!
1636316673 selectedpoint.toParent[0][0] = 0.0001;
1636416674 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16407,16 +16717,16 @@
1640716717 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]));
1640816718 }
1640916719
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16720
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116721 }
1641216722 }
1641316723
1641416724 if (!movingcamera && !PAINTMODE)
1641516725 object.editWindow.ScreenFitPoint(); // fev 2014
1641616726
16417
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16727
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1641816728 {
16419
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16729
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642016730
1642116731 Object3D group = new Object3D("inst" + paintcount++);
1642216732
....@@ -16572,7 +16882,7 @@
1657216882 gl.glDisable(gl.GL_CULL_FACE);
1657316883 }
1657416884
16575
- if (!RENDERSHADOW)
16885
+ if (!Globals.RENDERSHADOW)
1657616886 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657716887
1657816888 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +16892,7 @@
1658216892 //gl.glColorMask(false, false, false, false);
1658316893
1658416894 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16895
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658616896 {
1658716897 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816898
....@@ -16998,23 +17308,15 @@
1699817308 int AAbuffersize = 0;
1699917309
1700017310 //double[] selectedpoint = new double[3];
17001
- static Superellipsoid selectedpoint = new Superellipsoid();
17311
+ static Superellipsoid selectedpoint;
1700217312 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();
17313
+ static Sphere debugpointG;
17314
+ static Sphere debugpointP;
17315
+ static Sphere debugpointC;
17316
+ static Sphere debugpointR;
1700717317
1700817318 static Sphere debugpoints[] = new Sphere[8];
1700917319
17010
- static
17011
- {
17012
- for (int i=0; i<8; i++)
17013
- {
17014
- debugpoints[i] = new Sphere();
17015
- }
17016
- }
17017
-
1701817320 static void InitPoints(float radius)
1701917321 {
1702017322 for (int i=0; i<8; i++)