Normand Briere
2019-07-14 bc829f47837b5a001f911542140b0b8e63c2bb0c
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
....@@ -149,6 +148,8 @@
149148 defaultcaps.setAccumBlueBits(16);
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152153
153154 void SetAsGLRenderer(boolean b)
154155 {
....@@ -325,7 +326,7 @@
325326 cStatic.objectstack[materialdepth++] = obj;
326327 //System.out.println("material " + material);
327328 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
329330 if (obj instanceof Camera)
330331 {
331332 display.options1[0] = material.shift;
....@@ -334,14 +335,28 @@
334335 display.options1[2] = material.shadowbias;
335336 display.options1[3] = material.aniso;
336337 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]);
337343 display.options2[0] = material.opacity;
338344 display.options2[1] = material.diffuse;
339345 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]);
340349
341350 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]);
342354 display.options4[0] = material.cameralight/0.2f;
343355 display.options4[1] = material.subsurface;
344356 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]);
345360
346361 // if (display.CURRENTANTIALIAS > 0)
347362 // display.options3[3] /= 4;
....@@ -357,7 +372,7 @@
357372 /**/
358373 } else
359374 {
360
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
361376 }
362377 } else
363378 {
....@@ -381,8 +396,8 @@
381396 cStatic.objectstack[materialdepth++] = obj;
382397 //System.out.println("material " + material);
383398 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386401 }
387402 }
388403
....@@ -399,8 +414,8 @@
399414 materialdepth -= 1;
400415 if (materialdepth > 0)
401416 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- 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);
404419 }
405420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +435,8 @@
420435 materialdepth -= 1;
421436 if (materialdepth > 0)
422437 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- 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);
425440 }
426441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427442 //else
....@@ -462,10 +477,12 @@
462477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463478 {
464479 //gl.glBegin(gl.GL_TRIANGLES);
465
- 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
+ ;
466483 if (!hasnorm)
467484 {
468
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
469486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1207,12 @@
11901207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911208 }
11921209 }
1210
+
11931211 if (flipV)
11941212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951213 else
11961214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11971216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991218
....@@ -1213,10 +1232,12 @@
12131232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141233 }
12151234 }
1235
+
12161236 if (flipV)
12171237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181238 else
12191239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12201241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221243
....@@ -1244,8 +1265,10 @@
12441265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451266 else
12461267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12471269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12491272 count2 += 2;
12501273 count3 += 3;
12511274 }
....@@ -1601,7 +1624,7 @@
16011624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021625 }
16031626
1604
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051628 {
16061629 CameraPane display = this;
16071630 //new Exception().printStackTrace();
....@@ -1628,7 +1651,7 @@
16281651
16291652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301653
1631
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16321655
16331656 /**/
16341657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1659,7 @@
16361659 colorV[0] = display.modelParams0[0] * material.diffuse;
16371660 colorV[1] = display.modelParams0[1] * material.diffuse;
16381661 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16401663
16411664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421665 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1767,9 @@
17441767 display.modelParams7[2] = 0;
17451768 display.modelParams7[3] = 0;
17461769
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481771
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511774 {
17521775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1911,7 @@
18881911 void PushMatrix(double[][] matrix)
18891912 {
18901913 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18921915 }
18931916
18941917 void PushMatrix()
....@@ -2042,7 +2065,7 @@
20422065 //System.err.println("Oeil on");
20432066 OEIL = true;
20442067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462069 //pingthread.StepToTarget(true);
20472070 }
20482071
....@@ -2140,7 +2163,7 @@
21402163 System.err.println("LIVE = " + Globals.isLIVE());
21412164
21422165 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21442167 // else
21452168 repaint(); // start loop // may 2013
21462169 }
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,7 +2288,7 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
22702293 SWITCH ^= true;
22712294 }
....@@ -2374,7 +2397,7 @@
23742397 {
23752398 return currentGL;
23762399 }
2377
-
2400
+
23782401 /**/
23792402 class CacheTexture
23802403 {
....@@ -7919,6 +7942,64 @@
79197942 ReleaseTexture(pigment, false);
79207943 }
79217944
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
+
79228003 void ReleaseTexture(String tex, boolean bump)
79238004 {
79248005 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8103,7 @@
80228103 }
80238104 }
80248105
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8106
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268107 {
80278108 if (// DrawMode() != 0 || /*tex == null ||*/
80288109 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8148,94 @@
80678148 return; // true;
80688149 }
80698150
8070
- 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
80718239 {
80728240 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738241
....@@ -8075,15 +8243,17 @@
80758243 {
80768244 String texname = tex;
80778245
8246
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8247
+
80788248 // String[] split = tex.split("Textures");
80798249 // if (split.length > 1)
80808250 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818251 // else
80828252 // if (!texname.startsWith("/"))
80838253 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8254
+ if (!FileExists(tex))
80858255 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8256
+ texname = fallbackTextureName;
80878257 }
80888258
80898259 if (CACHETEXTURE)
....@@ -8153,7 +8323,7 @@
81538323 }
81548324
81558325 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8326
+ if (!FileExists(cachename))
81578327 cachename = texname;
81588328 else
81598329 processbump = false; // don't process bump map again
....@@ -8175,7 +8345,7 @@
81758345 }
81768346
81778347 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8348
+ if (!FileExists(cachename))
81798349 cachename = texname;
81808350 else
81818351 processbump = false; // don't process bump map again
....@@ -8184,7 +8354,9 @@
81848354 texturedata = GetFileTexture(cachename, processbump, resolution);
81858355
81868356
8187
- if (texturedata != null)
8357
+ if (texturedata == null)
8358
+ throw new Exception();
8359
+
81888360 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81898361 //texture = GetTexture(tex, bump);
81908362 }
....@@ -8306,7 +8478,7 @@
83068478 return texture;
83078479 }
83088480
8309
- 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
83108482 {
83118483 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128484
....@@ -8324,14 +8496,14 @@
83248496 return texture!=null?texture.texture:null;
83258497 }
83268498
8327
- 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
83288500 {
83298501 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308502
83318503 return texture!=null?texture.texturedata:null;
83328504 }
83338505
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8506
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83358507 {
83368508 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378509 {
....@@ -9208,11 +9380,35 @@
92089380 jy8[3] = 0.5f;
92099381 }
92109382
9211
- 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
92129384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92139385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92149386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92159387
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
+
92169412 static int imagecount = 0; // movie generation
92179413
92189414 static int jitter = 0;
....@@ -9308,8 +9504,8 @@
93089504 assert (parentcam != renderCamera);
93099505
93109506 if (renderCamera != lightCamera)
9311
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9312
- LA.matConcat(matrix, parentcam.toParent, matrix);
9507
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9508
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93139509
93149510 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93159511
....@@ -9324,8 +9520,8 @@
93249520 LA.matCopy(renderCamera.fromScreen, matrix);
93259521
93269522 if (renderCamera != lightCamera)
9327
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9328
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9523
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9524
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93299525
93309526 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93319527
....@@ -9542,7 +9738,7 @@
95429738
95439739 if (!BOXMODE)
95449740 {
9545
- 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) + ")");
95469742 }
95479743
95489744 if (!BOXMODE)
....@@ -9580,7 +9776,7 @@
95809776 ABORTED = false;
95819777 }
95829778 else
9583
- GrafreeD.wav.cursor += 735 * ACSIZE;
9779
+ Grafreed.wav.cursor += 735 * ACSIZE;
95849780
95859781 if (false)
95869782 {
....@@ -10243,11 +10439,11 @@
1024310439
1024410440 public void display(GLAutoDrawable drawable)
1024510441 {
10246
- if (GrafreeD.savesound && GrafreeD.hassound)
10442
+ if (Grafreed.savesound && Grafreed.hassound)
1024710443 {
10248
- GrafreeD.wav.save();
10249
- GrafreeD.savesound = false;
10250
- GrafreeD.hassound = false;
10444
+ Grafreed.wav.save();
10445
+ Grafreed.savesound = false;
10446
+ Grafreed.hassound = false;
1025110447 }
1025210448 // if (DEBUG_SELECTION)
1025310449 // {
....@@ -10323,6 +10519,7 @@
1032310519 ANTIALIAS = 0;
1032410520 //System.out.println("RESTART");
1032510521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1032610523 }
1032710524 }
1032810525 }
....@@ -10377,7 +10574,7 @@
1037710574 Object3D theobject = object;
1037810575 Object3D theparent = object.parent;
1037910576 object.parent = null;
10380
- object = (Object3D)GrafreeD.clone(object);
10577
+ object = (Object3D)Grafreed.clone(object);
1038110578 object.Stripify();
1038210579 if (theobject.selection == null || theobject.selection.Size() == 0)
1038310580 theobject.PreprocessOcclusion(this);
....@@ -10390,13 +10587,14 @@
1039010587 ambientOcclusion = false;
1039110588 }
1039210589
10393
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039410592 {
1039510593 //if (RENDERSHADOW) // ?
1039610594 if (!IsFrozen())
1039710595 {
1039810596 // dec 2012
10399
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10597
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040010598 {
1040110599 Globals.framecount++;
1040210600 shadowbuffer.display();
....@@ -10523,8 +10721,8 @@
1052310721
1052410722 // if (parentcam != renderCamera) // not a light
1052510723 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(matrix, parentcam.toParent, matrix);
10724
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10725
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052810726
1052910727 for (int j = 0; j < 4; j++)
1053010728 {
....@@ -10538,8 +10736,8 @@
1053810736
1053910737 // if (parentcam != renderCamera) // not a light
1054010738 if (cam != lightCamera)
10541
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10542
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10739
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10740
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054310741
1054410742 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054510743
....@@ -10798,7 +10996,16 @@
1079810996 // Bump noise
1079910997 gl.glActiveTexture(GL.GL_TEXTURE6);
1080010998 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- 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
+
1080211009
1080311010 gl.glActiveTexture(GL.GL_TEXTURE0);
1080411011 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10821,9 +11028,9 @@
1082111028
1082211029 gl.glMatrixMode(GL.GL_MODELVIEW);
1082311030
10824
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10825
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10826
-//gl.glEnable(gl.GL_MULTISAMPLE);
11031
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11032
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11033
+gl.glEnable(gl.GL_MULTISAMPLE);
1082711034 } else
1082811035 {
1082911036 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10834,7 +11041,7 @@
1083411041 //System.out.println("BLENDING ON");
1083511042 gl.glEnable(GL.GL_BLEND);
1083611043 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10837
-
11044
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083811045 gl.glMatrixMode(gl.GL_PROJECTION);
1083911046 gl.glLoadIdentity();
1084011047
....@@ -10923,8 +11130,8 @@
1092311130 System.err.println("parentcam != renderCamera");
1092411131
1092511132 // if (cam != lightCamera)
10926
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10927
- 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
1092811135 }
1092911136
1093011137 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10945,8 +11152,8 @@
1094511152 if (true) // TODO
1094611153 {
1094711154 if (cam != lightCamera)
10948
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10949
- 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
1095011157 }
1095111158
1095211159 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11283,23 +11490,44 @@
1128311490 e.printStackTrace();
1128411491 }
1128511492
11286
- if (GrafreeD.RENDERME > 0)
11287
- GrafreeD.RENDERME--; // mechante magouille
11493
+ if (Grafreed.RENDERME > 0)
11494
+ Grafreed.RENDERME--; // mechante magouille
1128811495
1128911496 Globals.ONESTEP = false;
1129011497 }
1129111498
1129211499 static boolean zoomonce = false;
1129311500
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
+
1129411519 void DrawObject(GL gl, boolean draw)
1129511520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1129611524 //System.out.println("DRAW OBJECT " + mouseDown);
1129711525 // DrawMode() = SELECTION;
1129811526 //GL gl = getGL();
1129911527 if ((TRACK || SHADOWTRACK) || zoomonce)
1130011528 {
1130111529 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11302
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11530
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1130311531 pingthread.StepToTarget(true); // true);
1130411532 // zoomonce = false;
1130511533 }
....@@ -11354,7 +11582,14 @@
1135411582
1135511583 usedtextures.clear();
1135611584
11357
- 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
+ }
1135811593 }
1135911594 //System.out.println("--> " + stackdepth);
1136011595 // GrafreeD.traceon();
....@@ -11364,8 +11599,9 @@
1136411599
1136511600 if (DrawMode() == DEFAULT)
1136611601 {
11367
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1136811603 {
11604
+ CreateSelectedPoint();
1136911605 float radius = 0.05f;
1137011606 if (selectedpoint.radius != radius)
1137111607 {
....@@ -11445,7 +11681,14 @@
1144511681 if (checker != null && DrawMode() == DEFAULT)
1144611682 {
1144711683 //BindTexture(IMMORTAL_TEXTURE);
11448
- 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
+ }
1144911692 // NEAREST
1145011693 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111694 DrawChecker(gl);
....@@ -11527,7 +11770,7 @@
1152711770 return;
1152811771 }
1152911772
11530
- String string = obj.GetToolTip();
11773
+ String string = obj.toString(); //.GetToolTip();
1153111774
1153211775 GL gl = GetGL();
1153311776
....@@ -11844,8 +12087,8 @@
1184412087 //obj.TransformToWorld(light, light);
1184512088 for (int i = tp.size(); --i >= 0;)
1184612089 {
11847
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11848
- 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);
1184912092 }
1185012093
1185112094
....@@ -11862,8 +12105,8 @@
1186212105 parentcam = cameras[0];
1186312106 }
1186412107
11865
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11866
- 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
1186712110
1186812111 LA.xformPos(light, renderCamera.toScreen, light);
1186912112
....@@ -12477,8 +12720,8 @@
1247712720
1247812721 // display shadow only (bump == 0)
1247912722 "SUB temp.x, half.x, shadow.x;" +
12480
- "MOV temp.y, -params6.x;" +
12481
- "SLT temp.z, temp.y, zero.x;" +
12723
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12724
+ "SLT temp.z, temp.y, -one2048th.x;" +
1248212725 "SUB temp.y, one.x, temp.z;" +
1248312726 "MUL temp.x, temp.x, temp.y;" +
1248412727 "KIL temp.x;" +
....@@ -12758,7 +13001,7 @@
1275813001 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275913002 "FLR final.x, final.y;" +
1276013003 "SUB final.y, final.y, final.x;" +
12761
- //"MUL final.x, final.x, c256i;" +
13004
+ "MUL final.x, final.x, c256i;" +
1276213005 "MOV final.z, zero.x;" +
1276313006 "MOV final.a, one.w;":""
1276413007 ) +
....@@ -12766,7 +13009,7 @@
1276613009 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276713010 "FLR final.x, final.y;" +
1276813011 "SUB final.y, final.y, final.x;" +
12769
- //"MUL final.x, final.x, c256i;" +
13012
+ "MUL final.x, final.x, c256i;" +
1277013013 "MOV final.z, zero.x;" +
1277113014 "MOV final.a, one.w;":""
1277213015 ) +
....@@ -12809,7 +13052,7 @@
1280913052 //once = true;
1281013053 }
1281113054
12812
- System.out.print("Program #" + mode + "; length = " + program.length());
13055
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1281313056 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281413057 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281513058
....@@ -12942,12 +13185,16 @@
1294213185
1294313186 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294413187 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13188
+
13189
+ // Compare fragment depth in light space with shadowmap.
1294513190 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294613191 "SGE temp.y, temp.x, zero.x;" +
12947
- "SUB " + shadow + ".y, one.x, temp.y;" +
13192
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13193
+
13194
+ // Reverse comparison
1294813195 "SUB temp.x, one.x, temp.x;" +
1294913196 "MUL " + shadow + ".x, temp.x, temp.y;" +
12950
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13197
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1295113198 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1295213199
1295313200 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12961,6 +13208,10 @@
1296113208 // No shadow for backface
1296213209 "DP3 temp.x, normal, lightd;" +
1296313210 "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;" +
1296413215 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296513216 "";
1296613217 }
....@@ -13107,7 +13358,8 @@
1310713358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310813359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310913360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13110
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1311113363
1311213364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1311313365 // OUT : diff, spec
....@@ -13123,9 +13375,10 @@
1312313375 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312413376 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312513377 //"MOV " + dest + ".w," + "normal.z;" +
13126
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13127
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13128
- //"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
1312913382 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1313013383 "RCP " + dest + ".w," + dest + ".w;" +
1313113384 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13519,7 +13772,7 @@
1351913772 public void mousePressed(MouseEvent e)
1352013773 {
1352113774 //System.out.println("mousePressed: " + e);
13522
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13775
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1352313776 }
1352413777
1352513778 static long prevtime = 0;
....@@ -13595,8 +13848,8 @@
1359513848 // mode |= META;
1359613849 //}
1359713850
13598
- SetMouseMode(WHEEL | e.getModifiersEx());
13599
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13851
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13852
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1360013853 anchorX = ax;
1360113854 anchorY = ay;
1360213855 prevX = px;
....@@ -13630,6 +13883,7 @@
1363013883 else
1363113884 if (evt.getSource() == AAtimer)
1363213885 {
13886
+ Globals.TIMERRUNNING = false;
1363313887 if (mouseDown)
1363413888 {
1363513889 //new Exception().printStackTrace();
....@@ -13655,6 +13909,10 @@
1365513909 // LIVE = waslive;
1365613910 // wasliveok = true;
1365713911 // waslive = false;
13912
+
13913
+ // May 2019 Forget it:
13914
+ if (true)
13915
+ return;
1365813916
1365913917 // source == timer
1366013918 if (mouseDown)
....@@ -13685,7 +13943,7 @@
1368513943
1368613944 // fev 2014???
1368713945 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13688
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13946
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368913947 pingthread.StepToTarget(true); // true);
1369013948 }
1369113949 // if (!LIVE)
....@@ -13694,12 +13952,13 @@
1369413952
1369513953 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369613954
13697
- void clickStart(int x, int y, int modifiers)
13955
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369813956 {
1369913957 if (!wasliveok)
1370013958 return;
1370113959
1370213960 AAtimer.restart(); //
13961
+ Globals.TIMERRUNNING = true;
1370313962
1370413963 // waslive = LIVE;
1370513964 // LIVE = false;
....@@ -13711,7 +13970,7 @@
1371113970 // touched = true; // main DL
1371213971 if (isRenderer)
1371313972 {
13714
- SetMouseMode(modifiers);
13973
+ SetMouseMode(modifiers, modifiersex);
1371513974 }
1371613975
1371713976 selectX = anchorX = x;
....@@ -13724,7 +13983,7 @@
1372413983 clicked = true;
1372513984 hold = false;
1372613985
13727
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13986
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372813987 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372913988 {
1373013989 // System.out.println("RESTART II " + modifiers);
....@@ -13755,7 +14014,7 @@
1375514014 info.camera = renderCamera;
1375614015 info.x = x;
1375714016 info.y = y;
13758
- info.modifiers = modifiers;
14017
+ info.modifiers = modifiersex;
1375914018 editObj = object.doEditClick(info, 0);
1376014019 if (!editObj)
1376114020 {
....@@ -13772,9 +14031,12 @@
1377214031
1377314032 public void mouseDragged(MouseEvent e)
1377414033 {
14034
+ Globals.MOUSEDRAGGED = true;
14035
+
1377514036 //System.out.println("mouseDragged: " + e);
1377614037 if (isRenderer)
1377714038 movingcamera = true;
14039
+
1377814040 //if (drawing)
1377914041 //return;
1378014042 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13784,7 +14046,7 @@
1378414046 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378514047 }
1378614048 else
13787
- drag(e.getX(), e.getY(), e.getModifiersEx());
14049
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378814050
1378914051 //try { Thread.sleep(1); } catch (Exception ex) {}
1379014052 }
....@@ -14021,7 +14283,7 @@
1402114283 {
1402214284 Globals.lighttouched = true;
1402314285 }
14024
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14286
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402514287 }
1402614288 //else
1402714289 }
....@@ -14035,12 +14297,12 @@
1403514297 void GoDown(int mod)
1403614298 {
1403714299 MODIFIERS |= COMMAND;
14038
- /*
14300
+ /**/
1403914301 if((mod&SHIFT) == SHIFT)
1404014302 manipCamera.RotatePosition(0, -speed);
1404114303 else
14042
- manipCamera.BackForth(0, -speed*delta, getWidth());
14043
- */
14304
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14305
+ /**/
1404414306 if ((mod & SHIFT) == SHIFT)
1404514307 {
1404614308 mouseMode = mouseMode; // VR??
....@@ -14056,12 +14318,12 @@
1405614318 void GoUp(int mod)
1405714319 {
1405814320 MODIFIERS |= COMMAND;
14059
- /*
14321
+ /**/
1406014322 if((mod&SHIFT) == SHIFT)
1406114323 manipCamera.RotatePosition(0, speed);
1406214324 else
14063
- manipCamera.BackForth(0, speed*delta, getWidth());
14064
- */
14325
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14326
+ /**/
1406514327 if ((mod & SHIFT) == SHIFT)
1406614328 {
1406714329 mouseMode = mouseMode;
....@@ -14077,12 +14339,12 @@
1407714339 void GoLeft(int mod)
1407814340 {
1407914341 MODIFIERS |= COMMAND;
14080
- /*
14342
+ /**/
1408114343 if((mod&SHIFT) == SHIFT)
14082
- manipCamera.RotatePosition(speed, 0);
14083
- else
1408414344 manipCamera.Translate(speed*delta, 0, getWidth());
14085
- */
14345
+ else
14346
+ manipCamera.RotatePosition(speed, 0);
14347
+ /**/
1408614348 if ((mod & SHIFT) == SHIFT)
1408714349 {
1408814350 mouseMode = mouseMode;
....@@ -14098,12 +14360,12 @@
1409814360 void GoRight(int mod)
1409914361 {
1410014362 MODIFIERS |= COMMAND;
14101
- /*
14363
+ /**/
1410214364 if((mod&SHIFT) == SHIFT)
14103
- manipCamera.RotatePosition(-speed, 0);
14104
- else
1410514365 manipCamera.Translate(-speed*delta, 0, getWidth());
14106
- */
14366
+ else
14367
+ manipCamera.RotatePosition(-speed, 0);
14368
+ /**/
1410714369 if ((mod & SHIFT) == SHIFT)
1410814370 {
1410914371 mouseMode = mouseMode;
....@@ -14121,7 +14383,7 @@
1412114383 int X, Y;
1412214384 boolean SX, SY;
1412314385
14124
- void drag(int x, int y, int modifiers)
14386
+ void drag(int x, int y, int modifiers, int modifiersex)
1412514387 {
1412614388 if (IsFrozen())
1412714389 {
....@@ -14130,17 +14392,17 @@
1413014392
1413114393 drag = true; // NEW
1413214394
14133
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14395
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413414396
1413514397 X = x;
1413614398 Y = y;
1413714399 // floating state for animation
14138
- MODIFIERS = modifiers;
14139
- modifiers &= ~1024;
14400
+ MODIFIERS = modifiersex;
14401
+ modifiersex &= ~1024;
1414014402 if (false) // modifiers != 0)
1414114403 {
1414214404 //new Exception().printStackTrace();
14143
- System.out.println("mouseDragged: " + modifiers);
14405
+ System.out.println("mouseDragged: " + modifiersex);
1414414406 System.out.println("SHIFT = " + SHIFT);
1414514407 System.out.println("CONTROL = " + COMMAND);
1414614408 System.out.println("META = " + META);
....@@ -14160,7 +14422,8 @@
1416014422 info.camera = renderCamera;
1416114423 info.x = x;
1416214424 info.y = y;
14163
- object.editWindow.copy.doEditDrag(info);
14425
+ object.GetWindow().copy
14426
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416414427 } else
1416514428 {
1416614429 if (x < startX)
....@@ -14324,7 +14587,9 @@
1432414587 ci.camera = renderCamera;
1432514588 if (!isRenderer)
1432614589 {
14327
- if (object.editWindow.copy.doEditClick(ci, 0))
14590
+ //ObjEditor editWindow = object.editWindow;
14591
+ //Object3D copy = editWindow.copy;
14592
+ if (object.doEditClick(ci, 0))
1432814593 {
1432914594 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1433014595 } else
....@@ -14336,7 +14601,11 @@
1433614601
1433714602 public void mouseReleased(MouseEvent e)
1433814603 {
14604
+ Globals.MOUSEDRAGGED = false;
14605
+
1433914606 movingcamera = false;
14607
+ X = 0; // getBounds().width/2;
14608
+ Y = 0; // getBounds().height/2;
1434014609 //System.out.println("mouseReleased: " + e);
1434114610 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1434214611 }
....@@ -14359,9 +14628,9 @@
1435914628 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1436014629 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1436114630
14362
- if (control || command || IsFrozen())
14631
+// No delay if (control || command || IsFrozen())
1436314632 timeout = true;
14364
- else
14633
+// ?? May 2019 else
1436514634 // timer.setDelay((modifiers & 128) != 0?0:350);
1436614635 mouseDown = false;
1436714636 if (!control && !command) // june 2013
....@@ -14471,7 +14740,7 @@
1447114740 System.out.println("keyReleased: " + e);
1447214741 }
1447314742
14474
- void SetMouseMode(int modifiers)
14743
+ void SetMouseMode(int modifiers, int modifiersex)
1447514744 {
1447614745 //System.out.println("SetMouseMode = " + modifiers);
1447714746 //modifiers &= ~1024;
....@@ -14483,25 +14752,25 @@
1448314752 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448414753 // return;
1448514754 //System.out.println("SetMode = " + modifiers);
14486
- if ((modifiers & WHEEL) == WHEEL)
14755
+ if ((modifiersex & WHEEL) == WHEEL)
1448714756 {
1448814757 mouseMode |= ZOOM;
1448914758 }
1449014759
1449114760 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14492
- if (capsLocked || (modifiers & META) == META)
14761
+ if (capsLocked) // || (modifiers & META) == META)
1449314762 {
1449414763 mouseMode |= VR; // BACKFORTH;
1449514764 }
14496
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14765
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449714766 {
1449814767 mouseMode |= SELECT;
1449914768 }
14500
- if ((modifiers & COMMAND) == COMMAND)
14769
+ if ((modifiersex & COMMAND) == COMMAND)
1450114770 {
1450214771 mouseMode |= SELECT;
1450314772 }
14504
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14773
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450514774 {
1450614775 mouseMode &= ~VR;
1450714776 mouseMode |= TRANSLATE;
....@@ -14530,7 +14799,7 @@
1453014799
1453114800 if (isRenderer) //
1453214801 {
14533
- SetMouseMode(modifiers);
14802
+ SetMouseMode(0, modifiers);
1453414803 }
1453514804
1453614805 Globals.theRenderer.keyPressed(key);
....@@ -14677,7 +14946,9 @@
1467714946 case 'E' : COMPACT ^= true;
1467814947 repaint();
1467914948 break;
14680
- case 'W' : DEBUGHSB ^= true;
14949
+ case 'W' : // Wide Window (fullscreen)
14950
+ //DEBUGHSB ^= true;
14951
+ ObjEditor.theFrame.ToggleFullScreen();
1468114952 repaint();
1468214953 break;
1468314954 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14702,8 +14973,8 @@
1470214973 RevertCamera();
1470314974 repaint();
1470414975 break;
14705
- case 'L':
1470614976 case 'l':
14977
+ //case 'L':
1470714978 if (lightMode)
1470814979 {
1470914980 lightMode = false;
....@@ -14846,9 +15117,9 @@
1484615117 case '_':
1484715118 kompactbit = 5;
1484815119 break;
14849
- case '+':
14850
- kompactbit = 6;
14851
- break;
15120
+// case '+':
15121
+// kompactbit = 6;
15122
+// break;
1485215123 case ' ':
1485315124 lightMode ^= true;
1485415125 Globals.lighttouched = true;
....@@ -14860,13 +15131,14 @@
1486015131 case ESC:
1486115132 RENDERPROGRAM += 1;
1486215133 RENDERPROGRAM %= 3;
15134
+
1486315135 repaint();
1486415136 break;
1486515137 case 'Z':
1486615138 //RESIZETEXTURE ^= true;
1486715139 //break;
1486815140 case 'z':
14869
- RENDERSHADOW ^= true;
15141
+ Globals.RENDERSHADOW ^= true;
1487015142 Globals.lighttouched = true;
1487115143 repaint();
1487215144 break;
....@@ -14899,8 +15171,9 @@
1489915171 case DELETE:
1490015172 ClearSelection();
1490115173 break;
14902
- /*
1490315174 case '+':
15175
+
15176
+ /*
1490415177 //fontsize += 1;
1490515178 bbzoom *= 2;
1490615179 repaint();
....@@ -14917,17 +15190,17 @@
1491715190 case '=':
1491815191 IncDepth();
1491915192 //fontsize += 1;
14920
- object.editWindow.refreshContents(true);
15193
+ object.GetWindow().refreshContents(true);
1492115194 maskbit = 6;
1492215195 break;
1492315196 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492415197 DecDepth();
1492515198 maskbit = 5;
1492615199 //if(fontsize > 1) fontsize -= 1;
14927
- if (object.editWindow == null)
14928
- new Exception().printStackTrace();
14929
- else
14930
- object.editWindow.refreshContents(true);
15200
+// if (object.editWindow == null)
15201
+// new Exception().printStackTrace();
15202
+// else
15203
+ object.GetWindow().refreshContents(true);
1493115204 break;
1493215205 case '{':
1493315206 manipCamera.shaper_fovy /= 1.1;
....@@ -14990,7 +15263,7 @@
1499015263 //mode = ROTATE;
1499115264 if ((MODIFIERS & COMMAND) == 0) // VR??
1499215265 {
14993
- SetMouseMode(modifiers);
15266
+ SetMouseMode(0, modifiers);
1499415267 }
1499515268 }
1499615269
....@@ -15126,7 +15399,7 @@
1512615399 {
1512715400 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512815401 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15129
- 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)
1513015403 {
1513115404 mouseMoved(e);
1513215405 } else
....@@ -15151,7 +15424,7 @@
1515115424 }
1515215425 */
1515315426
15154
- object.editWindow.EditSelection();
15427
+ object.GetWindow().EditSelection(false);
1515515428 }
1515615429
1515715430 void SelectParent()
....@@ -15168,10 +15441,10 @@
1516815441 {
1516915442 //selectees.remove(i);
1517015443 System.out.println("select parent of " + elem);
15171
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15444
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1517215445 } else
1517315446 {
15174
- group.editWindow.Select(elem.GetTreePath(), first, true);
15447
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517515448 }
1517615449
1517715450 first = false;
....@@ -15213,12 +15486,12 @@
1521315486 for (int j = 0; j < group.children.size(); j++)
1521415487 {
1521515488 elem = (Object3D) group.children.elementAt(j);
15216
- object.editWindow.Select(elem.GetTreePath(), first, true);
15489
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521715490 first = false;
1521815491 }
1521915492 } else
1522015493 {
15221
- object.editWindow.Select(elem.GetTreePath(), first, true);
15494
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522215495 }
1522315496
1522415497 first = false;
....@@ -15229,21 +15502,21 @@
1522915502 {
1523015503 //Composite group = (Composite) object;
1523115504 Object3D group = object;
15232
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15505
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1523315506 }
1523415507
1523515508 void ResetTransform(int mask)
1523615509 {
1523715510 //Composite group = (Composite) object;
1523815511 Object3D group = object;
15239
- group.editWindow.ResetTransform(mask);
15512
+ group.GetWindow().ResetTransform(mask);
1524015513 }
1524115514
1524215515 void FlipTransform()
1524315516 {
1524415517 //Composite group = (Composite) object;
1524515518 Object3D group = object;
15246
- group.editWindow.FlipTransform();
15519
+ group.GetWindow().FlipTransform();
1524715520 // group.editWindow.ReduceMesh(true);
1524815521 }
1524915522
....@@ -15251,7 +15524,7 @@
1525115524 {
1525215525 //Composite group = (Composite) object;
1525315526 Object3D group = object;
15254
- group.editWindow.PrintMemory();
15527
+ group.GetWindow().PrintMemory();
1525515528 // group.editWindow.ReduceMesh(true);
1525615529 }
1525715530
....@@ -15259,7 +15532,7 @@
1525915532 {
1526015533 //Composite group = (Composite) object;
1526115534 Object3D group = object;
15262
- group.editWindow.ResetCentroid();
15535
+ group.GetWindow().ResetCentroid();
1526315536 }
1526415537
1526515538 void IncDepth()
....@@ -15345,7 +15618,9 @@
1534515618 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534615619 //Image img = CreateImage(width, height);
1534715620 //System.out.println("width = " + width + "; height = " + height + "\n");
15621
+
1534815622 Graphics gr = g; // img.getGraphics();
15623
+
1534915624 if (!hasMarquee)
1535015625 {
1535115626 if (Xmin < Xmax) // !locked)
....@@ -15442,15 +15717,53 @@
1544215717 */
1544315718 if (!isRenderer)
1544415719 {
15445
- object.drawEditHandles(info, 0);
15720
+ if (object.selection.Size() > 0)
15721
+ {
15722
+ int hitSomething = object.selection.get(0).hitSomething;
15723
+
15724
+ info.DX = 0;
15725
+ info.DY = 0;
15726
+ info.W = 1;
15727
+ if (hitSomething == Object3D.hitCenter)
15728
+ {
15729
+ info.DX = X;
15730
+ if (X != 0)
15731
+ info.DX -= info.bounds.width/2;
15732
+
15733
+ info.DY = Y;
15734
+ if (Y != 0)
15735
+ info.DY -= info.bounds.height/2;
15736
+ }
15737
+
15738
+ object.drawEditHandles(info, 0);
15739
+
15740
+ if (drag && (X != 0 || Y != 0))
15741
+ {
15742
+ switch (hitSomething)
15743
+ {
15744
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15745
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15746
+ break;
15747
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15748
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15749
+ break;
15750
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15751
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15752
+ break;
15753
+ }
15754
+
15755
+ }
15756
+ }
1544615757 }
1544715758 }
15759
+
1544815760 if (isRenderer)
1544915761 {
1545015762 //gr.setColor(Color.black);
1545115763 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1545215764 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1545315765 }
15766
+
1545415767 if (hasMarquee)
1545515768 {
1545615769 gr.setXORMode(Color.white);
....@@ -15563,6 +15876,7 @@
1556315876 public boolean mouseDown(Event evt, int x, int y)
1556415877 {
1556515878 System.out.println("mouseDown: " + evt);
15879
+ System.exit(0);
1556615880 /*
1556715881 locked = true;
1556815882 drag = false;
....@@ -15606,7 +15920,7 @@
1560615920 {
1560715921 keyPressed(0, modifiers);
1560815922 }
15609
- clickStart(x, y, modifiers);
15923
+ // clickStart(x, y, modifiers);
1561015924 return true;
1561115925 }
1561215926
....@@ -15724,7 +16038,7 @@
1572416038 {
1572516039 keyReleased(0, 0);
1572616040 }
15727
- drag(x, y, modifiers);
16041
+ drag(x, y, 0, modifiers);
1572816042 return true;
1572916043 }
1573016044
....@@ -15856,7 +16170,7 @@
1585616170 Object3D object;
1585716171 static Object3D trackedobject;
1585816172 Camera renderCamera; // Light or Eye (or Occlusion)
15859
- /*static*/ Camera manipCamera; // Light or Eye
16173
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1586016174 /*static*/ Camera eyeCamera;
1586116175 /*static*/ Camera lightCamera;
1586216176 int cameracount;
....@@ -16141,16 +16455,16 @@
1614116455 cStatic.objectstack[materialdepth++] = checker;
1614216456 //System.out.println("material " + material);
1614316457 //Applet3D.tracein(this, selected);
16144
- vector2buffer = checker.projectedVertices;
16458
+ //vector2buffer = checker.projectedVertices;
1614516459
1614616460 //checker.GetMaterial().Draw(this, false); // true);
16147
- DrawMaterial(checker.GetMaterial(), false); // true);
16461
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614816462
1614916463 materialdepth -= 1;
1615016464 if (materialdepth > 0)
1615116465 {
16152
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16153
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16466
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16467
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1615416468 }
1615516469 //checker.GetMaterial().opacity = 1f;
1615616470 ////checker.GetMaterial().ambient = 1f;
....@@ -16374,6 +16688,8 @@
1637416688 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637516689 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1637616690
16691
+ CreateSelectedPoint();
16692
+
1637716693 // Will fit the mesh !!!
1637816694 selectedpoint.toParent[0][0] = 0.0001;
1637916695 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16422,16 +16738,16 @@
1642216738 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]));
1642316739 }
1642416740
16425
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16741
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642616742 }
1642716743 }
1642816744
1642916745 if (!movingcamera && !PAINTMODE)
16430
- object.editWindow.ScreenFitPoint(); // fev 2014
16746
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1643116747
16432
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16748
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1643316749 {
16434
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16750
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643516751
1643616752 Object3D group = new Object3D("inst" + paintcount++);
1643716753
....@@ -16439,17 +16755,17 @@
1643916755
1644016756 group.add(paintobj); // link
1644116757
16442
- object.editWindow.SnapObject(group);
16758
+ object.GetWindow().SnapObject(group);
1644316759
16444
- Object3D folder = object.editWindow.copy;
16760
+ Object3D folder = object.GetWindow().copy;
1644516761
16446
- if (object.editWindow.copy.selection.Size() > 0)
16447
- folder = object.editWindow.copy.selection.elementAt(0);
16762
+ if (object.GetWindow().copy.selection.Size() > 0)
16763
+ folder = object.GetWindow().copy.selection.elementAt(0);
1644816764
1644916765 folder.add(group);
1645016766
16451
- object.editWindow.ResetModel();
16452
- object.editWindow.refreshContents();
16767
+ object.GetWindow().ResetModel();
16768
+ object.GetWindow().refreshContents();
1645316769 }
1645416770 else
1645516771 paintcount = 0;
....@@ -16488,6 +16804,11 @@
1648816804 //System.out.println("objects[color] = " + objects[color]);
1648916805 //objects[color].Select();
1649016806 indexcount = 0;
16807
+ ObjEditor window = object.GetWindow();
16808
+ if (window != null && deselect)
16809
+ {
16810
+ window.Select(null, deselect, true);
16811
+ }
1649116812 object.Select(color, deselect);
1649216813 }
1649316814
....@@ -16587,7 +16908,7 @@
1658716908 gl.glDisable(gl.GL_CULL_FACE);
1658816909 }
1658916910
16590
- if (!RENDERSHADOW)
16911
+ if (!Globals.RENDERSHADOW)
1659116912 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659216913
1659316914 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16597,7 +16918,7 @@
1659716918 //gl.glColorMask(false, false, false, false);
1659816919
1659916920 //render_scene_from_light_view(gl, drawable, 0, 0);
16600
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16921
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660116922 {
1660216923 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660316924
....@@ -17013,23 +17334,15 @@
1701317334 int AAbuffersize = 0;
1701417335
1701517336 //double[] selectedpoint = new double[3];
17016
- static Superellipsoid selectedpoint = new Superellipsoid();
17337
+ static Superellipsoid selectedpoint;
1701717338 static Sphere previousselectedpoint = null;
17018
- static Sphere debugpointG = new Sphere();
17019
- static Sphere debugpointP = new Sphere();
17020
- static Sphere debugpointC = new Sphere();
17021
- static Sphere debugpointR = new Sphere();
17339
+ static Sphere debugpointG;
17340
+ static Sphere debugpointP;
17341
+ static Sphere debugpointC;
17342
+ static Sphere debugpointR;
1702217343
1702317344 static Sphere debugpoints[] = new Sphere[8];
1702417345
17025
- static
17026
- {
17027
- for (int i=0; i<8; i++)
17028
- {
17029
- debugpoints[i] = new Sphere();
17030
- }
17031
- }
17032
-
1703317346 static void InitPoints(float radius)
1703417347 {
1703517348 for (int i=0; i<8; i++)