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 {
....@@ -7921,6 +7942,64 @@
79217942 ReleaseTexture(pigment, false);
79227943 }
79237944
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
+
79248003 void ReleaseTexture(String tex, boolean bump)
79258004 {
79268005 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8024,7 +8103,7 @@
80248103 }
80258104 }
80268105
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8106
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288107 {
80298108 if (// DrawMode() != 0 || /*tex == null ||*/
80308109 ambientOcclusion ) // || !textureon)
....@@ -8069,7 +8148,94 @@
80698148 return; // true;
80708149 }
80718150
8072
- 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
80738239 {
80748240 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80758241
....@@ -8077,12 +8243,18 @@
80778243 {
80788244 String texname = tex;
80798245
8080
- String[] split = tex.split("Textures");
8081
- if (split.length > 1)
8082
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8083
- else
8084
- if (!texname.startsWith("/"))
8085
- 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
+ }
80868258
80878259 if (CACHETEXTURE)
80888260 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8151,7 +8323,7 @@
81518323 }
81528324
81538325 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8326
+ if (!FileExists(cachename))
81558327 cachename = texname;
81568328 else
81578329 processbump = false; // don't process bump map again
....@@ -8173,7 +8345,7 @@
81738345 }
81748346
81758347 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8348
+ if (!FileExists(cachename))
81778349 cachename = texname;
81788350 else
81798351 processbump = false; // don't process bump map again
....@@ -8182,7 +8354,9 @@
81828354 texturedata = GetFileTexture(cachename, processbump, resolution);
81838355
81848356
8185
- if (texturedata != null)
8357
+ if (texturedata == null)
8358
+ throw new Exception();
8359
+
81868360 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878361 //texture = GetTexture(tex, bump);
81888362 }
....@@ -8304,7 +8478,7 @@
83048478 return texture;
83058479 }
83068480
8307
- 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
83088482 {
83098483 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108484
....@@ -8322,14 +8496,14 @@
83228496 return texture!=null?texture.texture:null;
83238497 }
83248498
8325
- 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
83268500 {
83278501 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288502
83298503 return texture!=null?texture.texturedata:null;
83308504 }
83318505
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8506
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83338507 {
83348508 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358509 {
....@@ -9206,11 +9380,35 @@
92069380 jy8[3] = 0.5f;
92079381 }
92089382
9209
- 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
92109384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139387
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
+
92149412 static int imagecount = 0; // movie generation
92159413
92169414 static int jitter = 0;
....@@ -9306,8 +9504,8 @@
93069504 assert (parentcam != renderCamera);
93079505
93089506 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9507
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9508
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119509
93129510 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139511
....@@ -9322,8 +9520,8 @@
93229520 LA.matCopy(renderCamera.fromScreen, matrix);
93239521
93249522 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9523
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9524
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279525
93289526 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299527
....@@ -9395,7 +9593,7 @@
93959593 //gl.glFlush();
93969594 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979595
9398
- if (ANIMATION && ABORTED)
9596
+ if (Globals.ANIMATION && ABORTED)
93999597 {
94009598 System.err.println(" ABORTED FRAME");
94019599 break;
....@@ -9425,7 +9623,7 @@
94259623 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269624
94279625 // save image
9428
- if (ANIMATION && !ABORTED)
9626
+ if (Globals.ANIMATION && !ABORTED)
94299627 {
94309628 VPwidth = viewport[2];
94319629 VPheight = viewport[3];
....@@ -9536,11 +9734,11 @@
95369734
95379735 // imagecount++;
95389736
9539
- 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;
95409738
95419739 if (!BOXMODE)
95429740 {
9543
- 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) + ")");
95449742 }
95459743
95469744 if (!BOXMODE)
....@@ -9578,7 +9776,7 @@
95789776 ABORTED = false;
95799777 }
95809778 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9779
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829780
95839781 if (false)
95849782 {
....@@ -10241,11 +10439,11 @@
1024110439
1024210440 public void display(GLAutoDrawable drawable)
1024310441 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10442
+ if (Grafreed.savesound && Grafreed.hassound)
1024510443 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10444
+ Grafreed.wav.save();
10445
+ Grafreed.savesound = false;
10446
+ Grafreed.hassound = false;
1024910447 }
1025010448 // if (DEBUG_SELECTION)
1025110449 // {
....@@ -10321,6 +10519,7 @@
1032110519 ANTIALIAS = 0;
1032210520 //System.out.println("RESTART");
1032310521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1032410523 }
1032510524 }
1032610525 }
....@@ -10375,7 +10574,7 @@
1037510574 Object3D theobject = object;
1037610575 Object3D theparent = object.parent;
1037710576 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10577
+ object = (Object3D)Grafreed.clone(object);
1037910578 object.Stripify();
1038010579 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110580 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10587,14 @@
1038810587 ambientOcclusion = false;
1038910588 }
1039010589
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210592 {
1039310593 //if (RENDERSHADOW) // ?
1039410594 if (!IsFrozen())
1039510595 {
1039610596 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10597
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810598 {
1039910599 Globals.framecount++;
1040010600 shadowbuffer.display();
....@@ -10521,8 +10721,8 @@
1052110721
1052210722 // if (parentcam != renderCamera) // not a light
1052310723 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10724
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10725
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610726
1052710727 for (int j = 0; j < 4; j++)
1052810728 {
....@@ -10536,8 +10736,8 @@
1053610736
1053710737 // if (parentcam != renderCamera) // not a light
1053810738 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10739
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10740
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110741
1054210742 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310743
....@@ -10796,7 +10996,16 @@
1079610996 // Bump noise
1079710997 gl.glActiveTexture(GL.GL_TEXTURE6);
1079810998 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080011009
1080111010 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211011 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10921,8 +11130,8 @@
1092111130 System.err.println("parentcam != renderCamera");
1092211131
1092311132 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611135 }
1092711136
1092811137 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11152,8 @@
1094311152 if (true) // TODO
1094411153 {
1094511154 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811157 }
1094911158
1095011159 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11469,14 @@
1126011469 {
1126111470 renderpass++;
1126211471 // System.out.println("Draw object... ");
11472
+ STEP = 1;
1126311473 if (FAST) // in case there is no script
11264
- STEP = 16;
11474
+ STEP = 8;
11475
+
11476
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11477
+ {
11478
+ STEP *= 4;
11479
+ }
1126511480
1126611481 //object.FullInvariants();
1126711482
....@@ -11275,16 +11490,37 @@
1127511490 e.printStackTrace();
1127611491 }
1127711492
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11493
+ if (Grafreed.RENDERME > 0)
11494
+ Grafreed.RENDERME--; // mechante magouille
1128011495
1128111496 Globals.ONESTEP = false;
1128211497 }
1128311498
1128411499 static boolean zoomonce = false;
1128511500
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
+
1128611519 void DrawObject(GL gl, boolean draw)
1128711520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1128811524 //System.out.println("DRAW OBJECT " + mouseDown);
1128911525 // DrawMode() = SELECTION;
1129011526 //GL gl = getGL();
....@@ -11346,7 +11582,14 @@
1134611582
1134711583 usedtextures.clear();
1134811584
11349
- 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
+ }
1135011593 }
1135111594 //System.out.println("--> " + stackdepth);
1135211595 // GrafreeD.traceon();
....@@ -11356,8 +11599,9 @@
1135611599
1135711600 if (DrawMode() == DEFAULT)
1135811601 {
11359
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1136011603 {
11604
+ CreateSelectedPoint();
1136111605 float radius = 0.05f;
1136211606 if (selectedpoint.radius != radius)
1136311607 {
....@@ -11437,7 +11681,14 @@
1143711681 if (checker != null && DrawMode() == DEFAULT)
1143811682 {
1143911683 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111692 // NEAREST
1144211693 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311694 DrawChecker(gl);
....@@ -11519,7 +11770,7 @@
1151911770 return;
1152011771 }
1152111772
11522
- String string = obj.GetToolTip();
11773
+ String string = obj.toString(); //.GetToolTip();
1152311774
1152411775 GL gl = GetGL();
1152511776
....@@ -11836,8 +12087,8 @@
1183612087 //obj.TransformToWorld(light, light);
1183712088 for (int i = tp.size(); --i >= 0;)
1183812089 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112092 }
1184212093
1184312094
....@@ -11854,8 +12105,8 @@
1185412105 parentcam = cameras[0];
1185512106 }
1185612107
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912110
1186012111 LA.xformPos(light, renderCamera.toScreen, light);
1186112112
....@@ -12469,8 +12720,8 @@
1246912720
1247012721 // display shadow only (bump == 0)
1247112722 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12723
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12724
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412725 "SUB temp.y, one.x, temp.z;" +
1247512726 "MUL temp.x, temp.x, temp.y;" +
1247612727 "KIL temp.x;" +
....@@ -12599,8 +12850,10 @@
1259912850 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012851
1260112852 "SUB temp.x, one.x, ndotl.x;" +
12602
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12603
- "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
1260412857 "MUL temp.x, temp.x, temp.y;" +
1260512858
1260612859 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13001,7 @@
1274813001 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913002 "FLR final.x, final.y;" +
1275013003 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13004
+ "MUL final.x, final.x, c256i;" +
1275213005 "MOV final.z, zero.x;" +
1275313006 "MOV final.a, one.w;":""
1275413007 ) +
....@@ -12756,7 +13009,7 @@
1275613009 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713010 "FLR final.x, final.y;" +
1275813011 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13012
+ "MUL final.x, final.x, c256i;" +
1276013013 "MOV final.z, zero.x;" +
1276113014 "MOV final.a, one.w;":""
1276213015 ) +
....@@ -12799,7 +13052,7 @@
1279913052 //once = true;
1280013053 }
1280113054
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13055
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313056 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413057 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513058
....@@ -12932,12 +13185,16 @@
1293213185
1293313186 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413187 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13188
+
13189
+ // Compare fragment depth in light space with shadowmap.
1293513190 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613191 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13192
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13193
+
13194
+ // Reverse comparison
1293813195 "SUB temp.x, one.x, temp.x;" +
1293913196 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13197
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113198 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213199
1294313200 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13208,10 @@
1295113208 // No shadow for backface
1295213209 "DP3 temp.x, normal, lightd;" +
1295313210 "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;" +
1295413215 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513216 "";
1295613217 }
....@@ -13097,7 +13358,8 @@
1309713358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1310113363
1310213364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313365 // OUT : diff, spec
....@@ -13509,7 +13771,7 @@
1350913771 public void mousePressed(MouseEvent e)
1351013772 {
1351113773 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13774
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313775 }
1351413776
1351513777 static long prevtime = 0;
....@@ -13585,8 +13847,8 @@
1358513847 // mode |= META;
1358613848 //}
1358713849
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13850
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13851
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013852 anchorX = ax;
1359113853 anchorY = ay;
1359213854 prevX = px;
....@@ -13620,6 +13882,7 @@
1362013882 else
1362113883 if (evt.getSource() == AAtimer)
1362213884 {
13885
+ Globals.TIMERRUNNING = false;
1362313886 if (mouseDown)
1362413887 {
1362513888 //new Exception().printStackTrace();
....@@ -13645,6 +13908,10 @@
1364513908 // LIVE = waslive;
1364613909 // wasliveok = true;
1364713910 // waslive = false;
13911
+
13912
+ // May 2019 Forget it:
13913
+ if (true)
13914
+ return;
1364813915
1364913916 // source == timer
1365013917 if (mouseDown)
....@@ -13684,12 +13951,13 @@
1368413951
1368513952 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613953
13687
- void clickStart(int x, int y, int modifiers)
13954
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813955 {
1368913956 if (!wasliveok)
1369013957 return;
1369113958
1369213959 AAtimer.restart(); //
13960
+ Globals.TIMERRUNNING = true;
1369313961
1369413962 // waslive = LIVE;
1369513963 // LIVE = false;
....@@ -13701,7 +13969,7 @@
1370113969 // touched = true; // main DL
1370213970 if (isRenderer)
1370313971 {
13704
- SetMouseMode(modifiers);
13972
+ SetMouseMode(modifiers, modifiersex);
1370513973 }
1370613974
1370713975 selectX = anchorX = x;
....@@ -13714,7 +13982,7 @@
1371413982 clicked = true;
1371513983 hold = false;
1371613984
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13985
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813986 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913987 {
1372013988 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14013,7 @@
1374514013 info.camera = renderCamera;
1374614014 info.x = x;
1374714015 info.y = y;
13748
- info.modifiers = modifiers;
14016
+ info.modifiers = modifiersex;
1374914017 editObj = object.doEditClick(info, 0);
1375014018 if (!editObj)
1375114019 {
....@@ -13762,9 +14030,12 @@
1376214030
1376314031 public void mouseDragged(MouseEvent e)
1376414032 {
14033
+ Globals.MOUSEDRAGGED = true;
14034
+
1376514035 //System.out.println("mouseDragged: " + e);
1376614036 if (isRenderer)
1376714037 movingcamera = true;
14038
+
1376814039 //if (drawing)
1376914040 //return;
1377014041 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14045,7 @@
1377414045 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514046 }
1377614047 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14048
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814049
1377914050 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014051 }
....@@ -14011,7 +14282,7 @@
1401114282 {
1401214283 Globals.lighttouched = true;
1401314284 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14285
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514286 }
1401614287 //else
1401714288 }
....@@ -14111,7 +14382,7 @@
1411114382 int X, Y;
1411214383 boolean SX, SY;
1411314384
14114
- void drag(int x, int y, int modifiers)
14385
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514386 {
1411614387 if (IsFrozen())
1411714388 {
....@@ -14120,17 +14391,17 @@
1412014391
1412114392 drag = true; // NEW
1412214393
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14394
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414395
1412514396 X = x;
1412614397 Y = y;
1412714398 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14399
+ MODIFIERS = modifiersex;
14400
+ modifiersex &= ~1024;
1413014401 if (false) // modifiers != 0)
1413114402 {
1413214403 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14404
+ System.out.println("mouseDragged: " + modifiersex);
1413414405 System.out.println("SHIFT = " + SHIFT);
1413514406 System.out.println("CONTROL = " + COMMAND);
1413614407 System.out.println("META = " + META);
....@@ -14150,7 +14421,8 @@
1415014421 info.camera = renderCamera;
1415114422 info.x = x;
1415214423 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14424
+ object.GetWindow().copy
14425
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414426 } else
1415514427 {
1415614428 if (x < startX)
....@@ -14314,7 +14586,9 @@
1431414586 ci.camera = renderCamera;
1431514587 if (!isRenderer)
1431614588 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14589
+ //ObjEditor editWindow = object.editWindow;
14590
+ //Object3D copy = editWindow.copy;
14591
+ if (object.doEditClick(ci, 0))
1431814592 {
1431914593 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014594 } else
....@@ -14326,7 +14600,10 @@
1432614600
1432714601 public void mouseReleased(MouseEvent e)
1432814602 {
14603
+ Globals.MOUSEDRAGGED = false;
14604
+
1432914605 movingcamera = false;
14606
+ X = Y = 0;
1433014607 //System.out.println("mouseReleased: " + e);
1433114608 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214609 }
....@@ -14349,9 +14626,9 @@
1434914626 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014627 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114628
14352
- if (control || command || IsFrozen())
14629
+// No delay if (control || command || IsFrozen())
1435314630 timeout = true;
14354
- else
14631
+// ?? May 2019 else
1435514632 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614633 mouseDown = false;
1435714634 if (!control && !command) // june 2013
....@@ -14461,7 +14738,7 @@
1446114738 System.out.println("keyReleased: " + e);
1446214739 }
1446314740
14464
- void SetMouseMode(int modifiers)
14741
+ void SetMouseMode(int modifiers, int modifiersex)
1446514742 {
1446614743 //System.out.println("SetMouseMode = " + modifiers);
1446714744 //modifiers &= ~1024;
....@@ -14473,25 +14750,25 @@
1447314750 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414751 // return;
1447514752 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14753
+ if ((modifiersex & WHEEL) == WHEEL)
1447714754 {
1447814755 mouseMode |= ZOOM;
1447914756 }
1448014757
1448114758 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14759
+ if (capsLocked) // || (modifiers & META) == META)
1448314760 {
1448414761 mouseMode |= VR; // BACKFORTH;
1448514762 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14763
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714764 {
1448814765 mouseMode |= SELECT;
1448914766 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14767
+ if ((modifiersex & COMMAND) == COMMAND)
1449114768 {
1449214769 mouseMode |= SELECT;
1449314770 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14771
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514772 {
1449614773 mouseMode &= ~VR;
1449714774 mouseMode |= TRANSLATE;
....@@ -14520,7 +14797,7 @@
1452014797
1452114798 if (isRenderer) //
1452214799 {
14523
- SetMouseMode(modifiers);
14800
+ SetMouseMode(0, modifiers);
1452414801 }
1452514802
1452614803 Globals.theRenderer.keyPressed(key);
....@@ -14692,8 +14969,14 @@
1469214969 RevertCamera();
1469314970 repaint();
1469414971 break;
14695
- case 'L':
1469614972 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':
1469714980 if (lightMode)
1469814981 {
1469914982 lightMode = false;
....@@ -14840,23 +15123,21 @@
1484015123 kompactbit = 6;
1484115124 break;
1484215125 case ' ':
14843
- lightMode ^= true;
14844
- Globals.lighttouched = true;
14845
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14846
- targetLookAt.set(manipCamera.lookAt);
15126
+ ObjEditor.theFrame.ToggleFullScreen();
1484715127 repaint();
1484815128 break;
1484915129 //case '`' :
1485015130 case ESC:
1485115131 RENDERPROGRAM += 1;
1485215132 RENDERPROGRAM %= 3;
15133
+
1485315134 repaint();
1485415135 break;
1485515136 case 'Z':
1485615137 //RESIZETEXTURE ^= true;
1485715138 //break;
1485815139 case 'z':
14859
- RENDERSHADOW ^= true;
15140
+ Globals.RENDERSHADOW ^= true;
1486015141 Globals.lighttouched = true;
1486115142 repaint();
1486215143 break;
....@@ -14980,7 +15261,7 @@
1498015261 //mode = ROTATE;
1498115262 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215263 {
14983
- SetMouseMode(modifiers);
15264
+ SetMouseMode(0, modifiers);
1498415265 }
1498515266 }
1498615267
....@@ -15116,7 +15397,7 @@
1511615397 {
1511715398 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815399 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015401 {
1512115402 mouseMoved(e);
1512215403 } else
....@@ -15141,7 +15422,7 @@
1514115422 }
1514215423 */
1514315424
15144
- object.editWindow.EditSelection();
15425
+ object.editWindow.EditSelection(false);
1514515426 }
1514615427
1514715428 void SelectParent()
....@@ -15335,7 +15616,9 @@
1533515616 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615617 //Image img = CreateImage(width, height);
1533715618 //System.out.println("width = " + width + "; height = " + height + "\n");
15619
+
1533815620 Graphics gr = g; // img.getGraphics();
15621
+
1533915622 if (!hasMarquee)
1534015623 {
1534115624 if (Xmin < Xmax) // !locked)
....@@ -15433,14 +15716,33 @@
1543315716 if (!isRenderer)
1543415717 {
1543515718 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
+ }
1543615736 }
1543715737 }
15738
+
1543815739 if (isRenderer)
1543915740 {
1544015741 //gr.setColor(Color.black);
1544115742 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215743 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315744 }
15745
+
1544415746 if (hasMarquee)
1544515747 {
1544615748 gr.setXORMode(Color.white);
....@@ -15553,6 +15855,7 @@
1555315855 public boolean mouseDown(Event evt, int x, int y)
1555415856 {
1555515857 System.out.println("mouseDown: " + evt);
15858
+ System.exit(0);
1555615859 /*
1555715860 locked = true;
1555815861 drag = false;
....@@ -15596,7 +15899,7 @@
1559615899 {
1559715900 keyPressed(0, modifiers);
1559815901 }
15599
- clickStart(x, y, modifiers);
15902
+ // clickStart(x, y, modifiers);
1560015903 return true;
1560115904 }
1560215905
....@@ -15714,7 +16017,7 @@
1571416017 {
1571516018 keyReleased(0, 0);
1571616019 }
15717
- drag(x, y, modifiers);
16020
+ drag(x, y, 0, modifiers);
1571816021 return true;
1571916022 }
1572016023
....@@ -15846,7 +16149,7 @@
1584616149 Object3D object;
1584716150 static Object3D trackedobject;
1584816151 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16152
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016153 /*static*/ Camera eyeCamera;
1585116154 /*static*/ Camera lightCamera;
1585216155 int cameracount;
....@@ -16131,16 +16434,16 @@
1613116434 cStatic.objectstack[materialdepth++] = checker;
1613216435 //System.out.println("material " + material);
1613316436 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16437
+ //vector2buffer = checker.projectedVertices;
1613516438
1613616439 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16440
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816441
1613916442 materialdepth -= 1;
1614016443 if (materialdepth > 0)
1614116444 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- 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);
1614416447 }
1614516448 //checker.GetMaterial().opacity = 1f;
1614616449 ////checker.GetMaterial().ambient = 1f;
....@@ -16364,6 +16667,8 @@
1636416667 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516668 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1636616669
16670
+ CreateSelectedPoint();
16671
+
1636716672 // Will fit the mesh !!!
1636816673 selectedpoint.toParent[0][0] = 0.0001;
1636916674 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16412,16 +16717,16 @@
1641216717 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]));
1641316718 }
1641416719
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16720
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616721 }
1641716722 }
1641816723
1641916724 if (!movingcamera && !PAINTMODE)
1642016725 object.editWindow.ScreenFitPoint(); // fev 2014
1642116726
16422
- 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)
1642316728 {
16424
- 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);
1642516730
1642616731 Object3D group = new Object3D("inst" + paintcount++);
1642716732
....@@ -16577,7 +16882,7 @@
1657716882 gl.glDisable(gl.GL_CULL_FACE);
1657816883 }
1657916884
16580
- if (!RENDERSHADOW)
16885
+ if (!Globals.RENDERSHADOW)
1658116886 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216887
1658316888 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16892,7 @@
1658716892 //gl.glColorMask(false, false, false, false);
1658816893
1658916894 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16895
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116896 {
1659216897 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316898
....@@ -17003,23 +17308,15 @@
1700317308 int AAbuffersize = 0;
1700417309
1700517310 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17311
+ static Superellipsoid selectedpoint;
1700717312 static Sphere previousselectedpoint = null;
17008
- static Sphere debugpointG = new Sphere();
17009
- static Sphere debugpointP = new Sphere();
17010
- static Sphere debugpointC = new Sphere();
17011
- static Sphere debugpointR = new Sphere();
17313
+ static Sphere debugpointG;
17314
+ static Sphere debugpointP;
17315
+ static Sphere debugpointC;
17316
+ static Sphere debugpointR;
1701217317
1701317318 static Sphere debugpoints[] = new Sphere[8];
1701417319
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317320 static void InitPoints(float radius)
1702417321 {
1702517322 for (int i=0; i<8; i++)