Normand Briere
2019-07-01 6600d22461ccc1cb602f238a9ffa83cf07dd830e
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()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2142,7 +2163,7 @@
21422163 System.err.println("LIVE = " + Globals.isLIVE());
21432164
21442165 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21462167 // else
21472168 repaint(); // start loop // may 2013
21482169 }
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2267,9 +2288,9 @@
22672288 LOOKAT ^= true;
22682289 }
22692290
2270
- void ToggleRandom()
2291
+ void ToggleSwitch()
22712292 {
2272
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22732294 }
22742295
22752296 void ToggleHandles()
....@@ -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,23 +11490,44 @@
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();
1129111527 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211528 {
1129311529 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11530
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511531 pingthread.StepToTarget(true); // true);
1129611532 // zoomonce = false;
1129711533 }
....@@ -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
....@@ -13113,9 +13375,10 @@
1311313375 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413376 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513377 //"MOV " + dest + ".w," + "normal.z;" +
13116
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13117
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13118
- //"MOV " + dest + ".z," + "params2.w;" +
13378
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13379
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13380
+
13381
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1311913382 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013383 "RCP " + dest + ".w," + dest + ".w;" +
1312113384 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13772,7 @@
1350913772 public void mousePressed(MouseEvent e)
1351013773 {
1351113774 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13775
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313776 }
1351413777
1351513778 static long prevtime = 0;
....@@ -13585,8 +13848,8 @@
1358513848 // mode |= META;
1358613849 //}
1358713850
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13851
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13852
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013853 anchorX = ax;
1359113854 anchorY = ay;
1359213855 prevX = px;
....@@ -13620,6 +13883,7 @@
1362013883 else
1362113884 if (evt.getSource() == AAtimer)
1362213885 {
13886
+ Globals.TIMERRUNNING = false;
1362313887 if (mouseDown)
1362413888 {
1362513889 //new Exception().printStackTrace();
....@@ -13645,6 +13909,10 @@
1364513909 // LIVE = waslive;
1364613910 // wasliveok = true;
1364713911 // waslive = false;
13912
+
13913
+ // May 2019 Forget it:
13914
+ if (true)
13915
+ return;
1364813916
1364913917 // source == timer
1365013918 if (mouseDown)
....@@ -13675,7 +13943,7 @@
1367513943
1367613944 // fev 2014???
1367713945 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13946
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367913947 pingthread.StepToTarget(true); // true);
1368013948 }
1368113949 // if (!LIVE)
....@@ -13684,12 +13952,13 @@
1368413952
1368513953 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613954
13687
- void clickStart(int x, int y, int modifiers)
13955
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813956 {
1368913957 if (!wasliveok)
1369013958 return;
1369113959
1369213960 AAtimer.restart(); //
13961
+ Globals.TIMERRUNNING = true;
1369313962
1369413963 // waslive = LIVE;
1369513964 // LIVE = false;
....@@ -13701,7 +13970,7 @@
1370113970 // touched = true; // main DL
1370213971 if (isRenderer)
1370313972 {
13704
- SetMouseMode(modifiers);
13973
+ SetMouseMode(modifiers, modifiersex);
1370513974 }
1370613975
1370713976 selectX = anchorX = x;
....@@ -13714,7 +13983,7 @@
1371413983 clicked = true;
1371513984 hold = false;
1371613985
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13986
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813987 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913988 {
1372013989 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14014,7 @@
1374514014 info.camera = renderCamera;
1374614015 info.x = x;
1374714016 info.y = y;
13748
- info.modifiers = modifiers;
14017
+ info.modifiers = modifiersex;
1374914018 editObj = object.doEditClick(info, 0);
1375014019 if (!editObj)
1375114020 {
....@@ -13762,9 +14031,12 @@
1376214031
1376314032 public void mouseDragged(MouseEvent e)
1376414033 {
14034
+ Globals.MOUSEDRAGGED = true;
14035
+
1376514036 //System.out.println("mouseDragged: " + e);
1376614037 if (isRenderer)
1376714038 movingcamera = true;
14039
+
1376814040 //if (drawing)
1376914041 //return;
1377014042 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14046,7 @@
1377414046 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514047 }
1377614048 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14049
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814050
1377914051 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014052 }
....@@ -14011,7 +14283,7 @@
1401114283 {
1401214284 Globals.lighttouched = true;
1401314285 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14286
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514287 }
1401614288 //else
1401714289 }
....@@ -14111,7 +14383,7 @@
1411114383 int X, Y;
1411214384 boolean SX, SY;
1411314385
14114
- void drag(int x, int y, int modifiers)
14386
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514387 {
1411614388 if (IsFrozen())
1411714389 {
....@@ -14120,17 +14392,17 @@
1412014392
1412114393 drag = true; // NEW
1412214394
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14395
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414396
1412514397 X = x;
1412614398 Y = y;
1412714399 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14400
+ MODIFIERS = modifiersex;
14401
+ modifiersex &= ~1024;
1413014402 if (false) // modifiers != 0)
1413114403 {
1413214404 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14405
+ System.out.println("mouseDragged: " + modifiersex);
1413414406 System.out.println("SHIFT = " + SHIFT);
1413514407 System.out.println("CONTROL = " + COMMAND);
1413614408 System.out.println("META = " + META);
....@@ -14150,7 +14422,8 @@
1415014422 info.camera = renderCamera;
1415114423 info.x = x;
1415214424 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14425
+ object.GetWindow().copy
14426
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414427 } else
1415514428 {
1415614429 if (x < startX)
....@@ -14314,7 +14587,9 @@
1431414587 ci.camera = renderCamera;
1431514588 if (!isRenderer)
1431614589 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14590
+ //ObjEditor editWindow = object.editWindow;
14591
+ //Object3D copy = editWindow.copy;
14592
+ if (object.doEditClick(ci, 0))
1431814593 {
1431914594 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014595 } else
....@@ -14326,7 +14601,10 @@
1432614601
1432714602 public void mouseReleased(MouseEvent e)
1432814603 {
14604
+ Globals.MOUSEDRAGGED = false;
14605
+
1432914606 movingcamera = false;
14607
+ X = Y = 0;
1433014608 //System.out.println("mouseReleased: " + e);
1433114609 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214610 }
....@@ -14349,9 +14627,9 @@
1434914627 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014628 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114629
14352
- if (control || command || IsFrozen())
14630
+// No delay if (control || command || IsFrozen())
1435314631 timeout = true;
14354
- else
14632
+// ?? May 2019 else
1435514633 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614634 mouseDown = false;
1435714635 if (!control && !command) // june 2013
....@@ -14461,7 +14739,7 @@
1446114739 System.out.println("keyReleased: " + e);
1446214740 }
1446314741
14464
- void SetMouseMode(int modifiers)
14742
+ void SetMouseMode(int modifiers, int modifiersex)
1446514743 {
1446614744 //System.out.println("SetMouseMode = " + modifiers);
1446714745 //modifiers &= ~1024;
....@@ -14473,25 +14751,25 @@
1447314751 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414752 // return;
1447514753 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14754
+ if ((modifiersex & WHEEL) == WHEEL)
1447714755 {
1447814756 mouseMode |= ZOOM;
1447914757 }
1448014758
1448114759 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14760
+ if (capsLocked) // || (modifiers & META) == META)
1448314761 {
1448414762 mouseMode |= VR; // BACKFORTH;
1448514763 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14764
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714765 {
1448814766 mouseMode |= SELECT;
1448914767 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14768
+ if ((modifiersex & COMMAND) == COMMAND)
1449114769 {
1449214770 mouseMode |= SELECT;
1449314771 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14772
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514773 {
1449614774 mouseMode &= ~VR;
1449714775 mouseMode |= TRANSLATE;
....@@ -14520,7 +14798,7 @@
1452014798
1452114799 if (isRenderer) //
1452214800 {
14523
- SetMouseMode(modifiers);
14801
+ SetMouseMode(0, modifiers);
1452414802 }
1452514803
1452614804 Globals.theRenderer.keyPressed(key);
....@@ -14692,8 +14970,14 @@
1469214970 RevertCamera();
1469314971 repaint();
1469414972 break;
14695
- case 'L':
1469614973 case 'l':
14974
+ lightMode ^= true;
14975
+ Globals.lighttouched = true;
14976
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14977
+ targetLookAt.set(manipCamera.lookAt);
14978
+ repaint();
14979
+ break;
14980
+ case 'L':
1469714981 if (lightMode)
1469814982 {
1469914983 lightMode = false;
....@@ -14836,27 +15120,25 @@
1483615120 case '_':
1483715121 kompactbit = 5;
1483815122 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15123
+// case '+':
15124
+// kompactbit = 6;
15125
+// break;
1484215126 case ' ':
14843
- lightMode ^= true;
14844
- Globals.lighttouched = true;
14845
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14846
- targetLookAt.set(manipCamera.lookAt);
15127
+ ObjEditor.theFrame.ToggleFullScreen();
1484715128 repaint();
1484815129 break;
1484915130 //case '`' :
1485015131 case ESC:
1485115132 RENDERPROGRAM += 1;
1485215133 RENDERPROGRAM %= 3;
15134
+
1485315135 repaint();
1485415136 break;
1485515137 case 'Z':
1485615138 //RESIZETEXTURE ^= true;
1485715139 //break;
1485815140 case 'z':
14859
- RENDERSHADOW ^= true;
15141
+ Globals.RENDERSHADOW ^= true;
1486015142 Globals.lighttouched = true;
1486115143 repaint();
1486215144 break;
....@@ -14889,8 +15171,9 @@
1488915171 case DELETE:
1489015172 ClearSelection();
1489115173 break;
14892
- /*
1489315174 case '+':
15175
+
15176
+ /*
1489415177 //fontsize += 1;
1489515178 bbzoom *= 2;
1489615179 repaint();
....@@ -14907,17 +15190,17 @@
1490715190 case '=':
1490815191 IncDepth();
1490915192 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15193
+ object.GetWindow().refreshContents(true);
1491115194 maskbit = 6;
1491215195 break;
1491315196 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415197 DecDepth();
1491515198 maskbit = 5;
1491615199 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15200
+// if (object.editWindow == null)
15201
+// new Exception().printStackTrace();
15202
+// else
15203
+ object.GetWindow().refreshContents(true);
1492115204 break;
1492215205 case '{':
1492315206 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15263,7 @@
1498015263 //mode = ROTATE;
1498115264 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215265 {
14983
- SetMouseMode(modifiers);
15266
+ SetMouseMode(0, modifiers);
1498415267 }
1498515268 }
1498615269
....@@ -15116,7 +15399,7 @@
1511615399 {
1511715400 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815401 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15402
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512015403 {
1512115404 mouseMoved(e);
1512215405 } else
....@@ -15141,7 +15424,7 @@
1514115424 }
1514215425 */
1514315426
15144
- object.editWindow.EditSelection();
15427
+ object.GetWindow().EditSelection(false);
1514515428 }
1514615429
1514715430 void SelectParent()
....@@ -15158,10 +15441,10 @@
1515815441 {
1515915442 //selectees.remove(i);
1516015443 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15444
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215445 } else
1516315446 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15447
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515448 }
1516615449
1516715450 first = false;
....@@ -15203,12 +15486,12 @@
1520315486 for (int j = 0; j < group.children.size(); j++)
1520415487 {
1520515488 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15489
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715490 first = false;
1520815491 }
1520915492 } else
1521015493 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15494
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215495 }
1521315496
1521415497 first = false;
....@@ -15219,21 +15502,21 @@
1521915502 {
1522015503 //Composite group = (Composite) object;
1522115504 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15505
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315506 }
1522415507
1522515508 void ResetTransform(int mask)
1522615509 {
1522715510 //Composite group = (Composite) object;
1522815511 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15512
+ group.GetWindow().ResetTransform(mask);
1523015513 }
1523115514
1523215515 void FlipTransform()
1523315516 {
1523415517 //Composite group = (Composite) object;
1523515518 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15519
+ group.GetWindow().FlipTransform();
1523715520 // group.editWindow.ReduceMesh(true);
1523815521 }
1523915522
....@@ -15241,7 +15524,7 @@
1524115524 {
1524215525 //Composite group = (Composite) object;
1524315526 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15527
+ group.GetWindow().PrintMemory();
1524515528 // group.editWindow.ReduceMesh(true);
1524615529 }
1524715530
....@@ -15249,7 +15532,7 @@
1524915532 {
1525015533 //Composite group = (Composite) object;
1525115534 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15535
+ group.GetWindow().ResetCentroid();
1525315536 }
1525415537
1525515538 void IncDepth()
....@@ -15335,7 +15618,9 @@
1533515618 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615619 //Image img = CreateImage(width, height);
1533715620 //System.out.println("width = " + width + "; height = " + height + "\n");
15621
+
1533815622 Graphics gr = g; // img.getGraphics();
15623
+
1533915624 if (!hasMarquee)
1534015625 {
1534115626 if (Xmin < Xmax) // !locked)
....@@ -15433,14 +15718,33 @@
1543315718 if (!isRenderer)
1543415719 {
1543515720 object.drawEditHandles(info, 0);
15721
+
15722
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15723
+ {
15724
+ switch (object.selection.get(0).hitSomething)
15725
+ {
15726
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15727
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15728
+ break;
15729
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15730
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15731
+ break;
15732
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15733
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15734
+ break;
15735
+ }
15736
+
15737
+ }
1543615738 }
1543715739 }
15740
+
1543815741 if (isRenderer)
1543915742 {
1544015743 //gr.setColor(Color.black);
1544115744 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215745 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315746 }
15747
+
1544415748 if (hasMarquee)
1544515749 {
1544615750 gr.setXORMode(Color.white);
....@@ -15553,6 +15857,7 @@
1555315857 public boolean mouseDown(Event evt, int x, int y)
1555415858 {
1555515859 System.out.println("mouseDown: " + evt);
15860
+ System.exit(0);
1555615861 /*
1555715862 locked = true;
1555815863 drag = false;
....@@ -15596,7 +15901,7 @@
1559615901 {
1559715902 keyPressed(0, modifiers);
1559815903 }
15599
- clickStart(x, y, modifiers);
15904
+ // clickStart(x, y, modifiers);
1560015905 return true;
1560115906 }
1560215907
....@@ -15714,7 +16019,7 @@
1571416019 {
1571516020 keyReleased(0, 0);
1571616021 }
15717
- drag(x, y, modifiers);
16022
+ drag(x, y, 0, modifiers);
1571816023 return true;
1571916024 }
1572016025
....@@ -15846,7 +16151,7 @@
1584616151 Object3D object;
1584716152 static Object3D trackedobject;
1584816153 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16154
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016155 /*static*/ Camera eyeCamera;
1585116156 /*static*/ Camera lightCamera;
1585216157 int cameracount;
....@@ -16131,16 +16436,16 @@
1613116436 cStatic.objectstack[materialdepth++] = checker;
1613216437 //System.out.println("material " + material);
1613316438 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16439
+ //vector2buffer = checker.projectedVertices;
1613516440
1613616441 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16442
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816443
1613916444 materialdepth -= 1;
1614016445 if (materialdepth > 0)
1614116446 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16447
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16448
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614416449 }
1614516450 //checker.GetMaterial().opacity = 1f;
1614616451 ////checker.GetMaterial().ambient = 1f;
....@@ -16364,6 +16669,8 @@
1636416669 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516670 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1636616671
16672
+ CreateSelectedPoint();
16673
+
1636716674 // Will fit the mesh !!!
1636816675 selectedpoint.toParent[0][0] = 0.0001;
1636916676 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16412,16 +16719,16 @@
1641216719 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]));
1641316720 }
1641416721
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16722
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616723 }
1641716724 }
1641816725
1641916726 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16727
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116728
16422
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16729
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642316730 {
16424
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16731
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642516732
1642616733 Object3D group = new Object3D("inst" + paintcount++);
1642716734
....@@ -16429,17 +16736,17 @@
1642916736
1643016737 group.add(paintobj); // link
1643116738
16432
- object.editWindow.SnapObject(group);
16739
+ object.GetWindow().SnapObject(group);
1643316740
16434
- Object3D folder = object.editWindow.copy;
16741
+ Object3D folder = object.GetWindow().copy;
1643516742
16436
- if (object.editWindow.copy.selection.Size() > 0)
16437
- folder = object.editWindow.copy.selection.elementAt(0);
16743
+ if (object.GetWindow().copy.selection.Size() > 0)
16744
+ folder = object.GetWindow().copy.selection.elementAt(0);
1643816745
1643916746 folder.add(group);
1644016747
16441
- object.editWindow.ResetModel();
16442
- object.editWindow.refreshContents();
16748
+ object.GetWindow().ResetModel();
16749
+ object.GetWindow().refreshContents();
1644316750 }
1644416751 else
1644516752 paintcount = 0;
....@@ -16478,6 +16785,11 @@
1647816785 //System.out.println("objects[color] = " + objects[color]);
1647916786 //objects[color].Select();
1648016787 indexcount = 0;
16788
+ ObjEditor window = object.GetWindow();
16789
+ if (window != null && deselect)
16790
+ {
16791
+ window.Select(null, deselect, true);
16792
+ }
1648116793 object.Select(color, deselect);
1648216794 }
1648316795
....@@ -16577,7 +16889,7 @@
1657716889 gl.glDisable(gl.GL_CULL_FACE);
1657816890 }
1657916891
16580
- if (!RENDERSHADOW)
16892
+ if (!Globals.RENDERSHADOW)
1658116893 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216894
1658316895 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16899,7 @@
1658716899 //gl.glColorMask(false, false, false, false);
1658816900
1658916901 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16902
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116903 {
1659216904 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316905
....@@ -17003,23 +17315,15 @@
1700317315 int AAbuffersize = 0;
1700417316
1700517317 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17318
+ static Superellipsoid selectedpoint;
1700717319 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();
17320
+ static Sphere debugpointG;
17321
+ static Sphere debugpointP;
17322
+ static Sphere debugpointC;
17323
+ static Sphere debugpointR;
1701217324
1701317325 static Sphere debugpoints[] = new Sphere[8];
1701417326
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317327 static void InitPoints(float radius)
1702417328 {
1702517329 for (int i=0; i<8; i++)