Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
CameraPane.java
....@@ -106,7 +106,7 @@
106106 static boolean OEIL = true;
107107 static boolean OEILONCE = false; // do oeilon then oeiloff
108108 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
110110 static boolean HANDLES = false; // selection doesn't work!!
111111 static boolean PAINTMODE = false;
112112
....@@ -149,6 +149,8 @@
149149 defaultcaps.setAccumBlueBits(16);
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152154
153155 void SetAsGLRenderer(boolean b)
154156 {
....@@ -462,7 +464,7 @@
462464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463465 {
464466 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466468 if (!hasnorm)
467469 {
468470 // System.out.println("FUCK!!");
....@@ -1628,7 +1630,7 @@
16281630
16291631 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301632
1631
- float[] colorV = GrafreeD.colorV;
1633
+ float[] colorV = Grafreed.colorV;
16321634
16331635 /**/
16341636 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1888,7 +1890,7 @@
18881890 void PushMatrix(double[][] matrix)
18891891 {
18901892 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
18921894 }
18931895
18941896 void PushMatrix()
....@@ -2140,7 +2142,7 @@
21402142 System.err.println("LIVE = " + Globals.isLIVE());
21412143
21422144 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2145
+ Grafreed.savesound = true; // wav.save();
21442146 // else
21452147 repaint(); // start loop // may 2013
21462148 }
....@@ -2265,9 +2267,9 @@
22652267 LOOKAT ^= true;
22662268 }
22672269
2268
- void ToggleRandom()
2270
+ void ToggleSwitch()
22692271 {
2270
- RANDOM ^= true;
2272
+ SWITCH ^= true;
22712273 }
22722274
22732275 void ToggleHandles()
....@@ -2374,7 +2376,7 @@
23742376 {
23752377 return currentGL;
23762378 }
2377
-
2379
+
23782380 /**/
23792381 class CacheTexture
23802382 {
....@@ -7919,6 +7921,64 @@
79197921 ReleaseTexture(pigment, false);
79207922 }
79217923
7924
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7925
+ {
7926
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7927
+ {
7928
+ return;
7929
+ }
7930
+
7931
+ if (tex == null)
7932
+ {
7933
+ ReleaseTexture(null, false);
7934
+ return;
7935
+ }
7936
+
7937
+ String pigment = Object3D.GetPigment(tex);
7938
+
7939
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7940
+ {
7941
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7942
+ // System.out.println("; bump = " + bump);
7943
+ }
7944
+
7945
+ if (pigment.equals(""))
7946
+ {
7947
+ pigment = null;
7948
+ }
7949
+
7950
+ ReleaseTexture(pigment, false);
7951
+ }
7952
+
7953
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7954
+ {
7955
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7956
+ {
7957
+ return;
7958
+ }
7959
+
7960
+ if (tex == null)
7961
+ {
7962
+ ReleaseTexture(null, true);
7963
+ return;
7964
+ }
7965
+
7966
+ String bump = Object3D.GetBump(tex);
7967
+
7968
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7969
+ {
7970
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7971
+ // System.out.println("; bump = " + bump);
7972
+ }
7973
+
7974
+ if (bump.equals(""))
7975
+ {
7976
+ bump = null;
7977
+ }
7978
+
7979
+ ReleaseTexture(bump, true);
7980
+ }
7981
+
79227982 void ReleaseTexture(String tex, boolean bump)
79237983 {
79247984 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8082,7 @@
80228082 }
80238083 }
80248084
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8085
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268086 {
80278087 if (// DrawMode() != 0 || /*tex == null ||*/
80288088 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8127,94 @@
80678127 return; // true;
80688128 }
80698129
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8130
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8131
+ {
8132
+ if (// DrawMode() != 0 || /*tex == null ||*/
8133
+ ambientOcclusion ) // || !textureon)
8134
+ {
8135
+ return; // false;
8136
+ }
8137
+
8138
+ if (tex == null)
8139
+ {
8140
+ BindTexture(null,false,resolution);
8141
+ return;
8142
+ }
8143
+
8144
+ String pigment = Object3D.GetPigment(tex);
8145
+
8146
+ usedtextures.put(pigment, pigment);
8147
+
8148
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8149
+ {
8150
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8151
+ // System.out.println("; bump = " + bump);
8152
+ }
8153
+
8154
+ if (pigment.equals(""))
8155
+ {
8156
+ pigment = null;
8157
+ }
8158
+
8159
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8160
+ BindTexture(pigment, false, resolution);
8161
+ }
8162
+
8163
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8164
+ {
8165
+ if (// DrawMode() != 0 || /*tex == null ||*/
8166
+ ambientOcclusion ) // || !textureon)
8167
+ {
8168
+ return; // false;
8169
+ }
8170
+
8171
+ if (tex == null)
8172
+ {
8173
+ BindTexture(null,true,resolution);
8174
+ return;
8175
+ }
8176
+
8177
+ String bump = Object3D.GetBump(tex);
8178
+
8179
+ usedtextures.put(bump, bump);
8180
+
8181
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8182
+ {
8183
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8184
+ // System.out.println("; bump = " + bump);
8185
+ }
8186
+
8187
+ if (bump.equals(""))
8188
+ {
8189
+ bump = null;
8190
+ }
8191
+
8192
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8193
+ BindTexture(bump, true, resolution);
8194
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8195
+ }
8196
+
8197
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8198
+
8199
+ private boolean FileExists(String tex)
8200
+ {
8201
+ if (missingTextures.contains(tex))
8202
+ {
8203
+ return false;
8204
+ }
8205
+
8206
+ boolean fileExists = new File(tex).exists();
8207
+
8208
+ if (!fileExists)
8209
+ {
8210
+ // If file exists, the "new File()" is not executed sgain
8211
+ missingTextures.add(tex);
8212
+ }
8213
+
8214
+ return fileExists;
8215
+ }
8216
+
8217
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718218 {
80728219 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738220
....@@ -8075,12 +8222,18 @@
80758222 {
80768223 String texname = tex;
80778224
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- texname = "/Users/nbriere/Textures/" + texname;
8225
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8226
+
8227
+// String[] split = tex.split("Textures");
8228
+// if (split.length > 1)
8229
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8230
+// else
8231
+// if (!texname.startsWith("/"))
8232
+// texname = "/Users/nbriere/Textures/" + texname;
8233
+ if (!FileExists(tex))
8234
+ {
8235
+ texname = fallbackTextureName;
8236
+ }
80848237
80858238 if (CACHETEXTURE)
80868239 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8149,7 +8302,7 @@
81498302 }
81508303
81518304 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8305
+ if (!FileExists(cachename))
81538306 cachename = texname;
81548307 else
81558308 processbump = false; // don't process bump map again
....@@ -8171,7 +8324,7 @@
81718324 }
81728325
81738326 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8327
+ if (!FileExists(cachename))
81758328 cachename = texname;
81768329 else
81778330 processbump = false; // don't process bump map again
....@@ -8180,7 +8333,9 @@
81808333 texturedata = GetFileTexture(cachename, processbump, resolution);
81818334
81828335
8183
- if (texturedata != null)
8336
+ if (texturedata == null)
8337
+ throw new Exception();
8338
+
81848339 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81858340 //texture = GetTexture(tex, bump);
81868341 }
....@@ -8302,7 +8457,7 @@
83028457 return texture;
83038458 }
83048459
8305
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8460
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83068461 {
83078462 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83088463
....@@ -8320,14 +8475,14 @@
83208475 return texture!=null?texture.texture:null;
83218476 }
83228477
8323
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8478
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83248479 {
83258480 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83268481
83278482 return texture!=null?texture.texturedata:null;
83288483 }
83298484
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8485
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83318486 {
83328487 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338488 {
....@@ -9304,8 +9459,8 @@
93049459 assert (parentcam != renderCamera);
93059460
93069461 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9462
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9463
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099464
93109465 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119466
....@@ -9320,8 +9475,8 @@
93209475 LA.matCopy(renderCamera.fromScreen, matrix);
93219476
93229477 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9478
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9479
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259480
93269481 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279482
....@@ -9538,7 +9693,7 @@
95389693
95399694 if (!BOXMODE)
95409695 {
9541
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9696
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95429697 }
95439698
95449699 if (!BOXMODE)
....@@ -9576,7 +9731,7 @@
95769731 ABORTED = false;
95779732 }
95789733 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9734
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809735
95819736 if (false)
95829737 {
....@@ -10239,11 +10394,11 @@
1023910394
1024010395 public void display(GLAutoDrawable drawable)
1024110396 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10397
+ if (Grafreed.savesound && Grafreed.hassound)
1024310398 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10399
+ Grafreed.wav.save();
10400
+ Grafreed.savesound = false;
10401
+ Grafreed.hassound = false;
1024710402 }
1024810403 // if (DEBUG_SELECTION)
1024910404 // {
....@@ -10373,7 +10528,7 @@
1037310528 Object3D theobject = object;
1037410529 Object3D theparent = object.parent;
1037510530 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10531
+ object = (Object3D)Grafreed.clone(object);
1037710532 object.Stripify();
1037810533 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910534 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10541,13 @@
1038610541 ambientOcclusion = false;
1038710542 }
1038810543
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10544
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010545 {
1039110546 //if (RENDERSHADOW) // ?
1039210547 if (!IsFrozen())
1039310548 {
1039410549 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10550
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610551 {
1039710552 Globals.framecount++;
1039810553 shadowbuffer.display();
....@@ -10519,8 +10674,8 @@
1051910674
1052010675 // if (parentcam != renderCamera) // not a light
1052110676 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10677
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10678
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410679
1052510680 for (int j = 0; j < 4; j++)
1052610681 {
....@@ -10534,8 +10689,8 @@
1053410689
1053510690 // if (parentcam != renderCamera) // not a light
1053610691 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10692
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10693
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910694
1054010695 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110696
....@@ -10794,7 +10949,16 @@
1079410949 // Bump noise
1079510950 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610951 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- BindTexture(NOISE_TEXTURE, false, 2);
10952
+
10953
+ try
10954
+ {
10955
+ BindTexture(NOISE_TEXTURE, false, 2);
10956
+ }
10957
+ catch (Exception e)
10958
+ {
10959
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10960
+ }
10961
+
1079810962
1079910963 gl.glActiveTexture(GL.GL_TEXTURE0);
1080010964 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +11083,8 @@
1091911083 System.err.println("parentcam != renderCamera");
1092011084
1092111085 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11086
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11087
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092411088 }
1092511089
1092611090 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11105,8 @@
1094111105 if (true) // TODO
1094211106 {
1094311107 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11108
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11109
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094611110 }
1094711111
1094811112 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,8 +11443,8 @@
1127911443 e.printStackTrace();
1128011444 }
1128111445
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11446
+ if (Grafreed.RENDERME > 0)
11447
+ Grafreed.RENDERME--; // mechante magouille
1128411448
1128511449 Globals.ONESTEP = false;
1128611450 }
....@@ -11350,7 +11514,14 @@
1135011514
1135111515 usedtextures.clear();
1135211516
11353
- BindTextures(DEFAULT_TEXTURES, 2);
11517
+ try
11518
+ {
11519
+ BindTextures(DEFAULT_TEXTURES, 2);
11520
+ }
11521
+ catch (Exception e)
11522
+ {
11523
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11524
+ }
1135411525 }
1135511526 //System.out.println("--> " + stackdepth);
1135611527 // GrafreeD.traceon();
....@@ -11441,7 +11612,14 @@
1144111612 if (checker != null && DrawMode() == DEFAULT)
1144211613 {
1144311614 //BindTexture(IMMORTAL_TEXTURE);
11444
- BindTextures(checker.GetTextures(), checker.texres);
11615
+ try
11616
+ {
11617
+ BindTextures(checker.GetTextures(), checker.texres);
11618
+ }
11619
+ catch (Exception e)
11620
+ {
11621
+ System.err.println("FAILED: " + checker.GetTextures());
11622
+ }
1144511623 // NEAREST
1144611624 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711625 DrawChecker(gl);
....@@ -11523,7 +11701,7 @@
1152311701 return;
1152411702 }
1152511703
11526
- String string = obj.GetToolTip();
11704
+ String string = obj.toString(); //.GetToolTip();
1152711705
1152811706 GL gl = GetGL();
1152911707
....@@ -11840,8 +12018,8 @@
1184012018 //obj.TransformToWorld(light, light);
1184112019 for (int i = tp.size(); --i >= 0;)
1184212020 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- LA.xformPos(light, tp.get(i).toParent, light);
12021
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1184512023 }
1184612024
1184712025
....@@ -11858,8 +12036,8 @@
1185812036 parentcam = cameras[0];
1185912037 }
1186012038
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12039
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12040
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186312041
1186412042 LA.xformPos(light, renderCamera.toScreen, light);
1186512043
....@@ -12473,8 +12651,8 @@
1247312651
1247412652 // display shadow only (bump == 0)
1247512653 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12654
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12655
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812656 "SUB temp.y, one.x, temp.z;" +
1247912657 "MUL temp.x, temp.x, temp.y;" +
1248012658 "KIL temp.x;" +
....@@ -12754,7 +12932,7 @@
1275412932 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275512933 "FLR final.x, final.y;" +
1275612934 "SUB final.y, final.y, final.x;" +
12757
- //"MUL final.x, final.x, c256i;" +
12935
+ "MUL final.x, final.x, c256i;" +
1275812936 "MOV final.z, zero.x;" +
1275912937 "MOV final.a, one.w;":""
1276012938 ) +
....@@ -12762,7 +12940,7 @@
1276212940 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276312941 "FLR final.x, final.y;" +
1276412942 "SUB final.y, final.y, final.x;" +
12765
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1276612944 "MOV final.z, zero.x;" +
1276712945 "MOV final.a, one.w;":""
1276812946 ) +
....@@ -12805,7 +12983,7 @@
1280512983 //once = true;
1280612984 }
1280712985
12808
- System.out.print("Program #" + mode + "; length = " + program.length());
12986
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280912987 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281012988 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281112989
....@@ -12938,12 +13116,16 @@
1293813116
1293913117 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294013118 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13119
+
13120
+ // Compare fragment depth in light space with shadowmap.
1294113121 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294213122 "SGE temp.y, temp.x, zero.x;" +
12943
- "SUB " + shadow + ".y, one.x, temp.y;" +
13123
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13124
+
13125
+ // Reverse comparison
1294413126 "SUB temp.x, one.x, temp.x;" +
1294513127 "MUL " + shadow + ".x, temp.x, temp.y;" +
12946
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13128
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294713129 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294813130
1294913131 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12957,6 +13139,10 @@
1295713139 // No shadow for backface
1295813140 "DP3 temp.x, normal, lightd;" +
1295913141 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13142
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13143
+
13144
+ // No shadow when out of frustrum
13145
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296013146 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296113147 "";
1296213148 }
....@@ -13515,7 +13701,7 @@
1351513701 public void mousePressed(MouseEvent e)
1351613702 {
1351713703 //System.out.println("mousePressed: " + e);
13518
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13704
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351913705 }
1352013706
1352113707 static long prevtime = 0;
....@@ -13591,8 +13777,8 @@
1359113777 // mode |= META;
1359213778 //}
1359313779
13594
- SetMouseMode(WHEEL | e.getModifiersEx());
13595
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13780
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13781
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359613782 anchorX = ax;
1359713783 anchorY = ay;
1359813784 prevX = px;
....@@ -13652,6 +13838,10 @@
1365213838 // wasliveok = true;
1365313839 // waslive = false;
1365413840
13841
+ // May 2019 Forget it:
13842
+ if (true)
13843
+ return;
13844
+
1365513845 // source == timer
1365613846 if (mouseDown)
1365713847 {
....@@ -13690,7 +13880,7 @@
1369013880
1369113881 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369213882
13693
- void clickStart(int x, int y, int modifiers)
13883
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369413884 {
1369513885 if (!wasliveok)
1369613886 return;
....@@ -13707,7 +13897,7 @@
1370713897 // touched = true; // main DL
1370813898 if (isRenderer)
1370913899 {
13710
- SetMouseMode(modifiers);
13900
+ SetMouseMode(modifiers, modifiersex);
1371113901 }
1371213902
1371313903 selectX = anchorX = x;
....@@ -13720,7 +13910,7 @@
1372013910 clicked = true;
1372113911 hold = false;
1372213912
13723
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13913
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372413914 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372513915 {
1372613916 // System.out.println("RESTART II " + modifiers);
....@@ -13751,7 +13941,7 @@
1375113941 info.camera = renderCamera;
1375213942 info.x = x;
1375313943 info.y = y;
13754
- info.modifiers = modifiers;
13944
+ info.modifiers = modifiersex;
1375513945 editObj = object.doEditClick(info, 0);
1375613946 if (!editObj)
1375713947 {
....@@ -13768,9 +13958,12 @@
1376813958
1376913959 public void mouseDragged(MouseEvent e)
1377013960 {
13961
+ Globals.MOUSEDRAGGED = true;
13962
+
1377113963 //System.out.println("mouseDragged: " + e);
1377213964 if (isRenderer)
1377313965 movingcamera = true;
13966
+
1377413967 //if (drawing)
1377513968 //return;
1377613969 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13780,7 +13973,7 @@
1378013973 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378113974 }
1378213975 else
13783
- drag(e.getX(), e.getY(), e.getModifiersEx());
13976
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378413977
1378513978 //try { Thread.sleep(1); } catch (Exception ex) {}
1378613979 }
....@@ -14017,7 +14210,7 @@
1401714210 {
1401814211 Globals.lighttouched = true;
1401914212 }
14020
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14213
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402114214 }
1402214215 //else
1402314216 }
....@@ -14117,7 +14310,7 @@
1411714310 int X, Y;
1411814311 boolean SX, SY;
1411914312
14120
- void drag(int x, int y, int modifiers)
14313
+ void drag(int x, int y, int modifiers, int modifiersex)
1412114314 {
1412214315 if (IsFrozen())
1412314316 {
....@@ -14126,17 +14319,17 @@
1412614319
1412714320 drag = true; // NEW
1412814321
14129
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14322
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413014323
1413114324 X = x;
1413214325 Y = y;
1413314326 // floating state for animation
14134
- MODIFIERS = modifiers;
14135
- modifiers &= ~1024;
14327
+ MODIFIERS = modifiersex;
14328
+ modifiersex &= ~1024;
1413614329 if (false) // modifiers != 0)
1413714330 {
1413814331 //new Exception().printStackTrace();
14139
- System.out.println("mouseDragged: " + modifiers);
14332
+ System.out.println("mouseDragged: " + modifiersex);
1414014333 System.out.println("SHIFT = " + SHIFT);
1414114334 System.out.println("CONTROL = " + COMMAND);
1414214335 System.out.println("META = " + META);
....@@ -14156,7 +14349,7 @@
1415614349 info.camera = renderCamera;
1415714350 info.x = x;
1415814351 info.y = y;
14159
- object.editWindow.copy.doEditDrag(info);
14352
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416014353 } else
1416114354 {
1416214355 if (x < startX)
....@@ -14332,7 +14525,10 @@
1433214525
1433314526 public void mouseReleased(MouseEvent e)
1433414527 {
14528
+ Globals.MOUSEDRAGGED = false;
14529
+
1433514530 movingcamera = false;
14531
+ X = Y = 0;
1433614532 //System.out.println("mouseReleased: " + e);
1433714533 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433814534 }
....@@ -14355,9 +14551,9 @@
1435514551 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435614552 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435714553
14358
- if (control || command || IsFrozen())
14554
+// No delay if (control || command || IsFrozen())
1435914555 timeout = true;
14360
- else
14556
+// ?? May 2019 else
1436114557 // timer.setDelay((modifiers & 128) != 0?0:350);
1436214558 mouseDown = false;
1436314559 if (!control && !command) // june 2013
....@@ -14467,7 +14663,7 @@
1446714663 System.out.println("keyReleased: " + e);
1446814664 }
1446914665
14470
- void SetMouseMode(int modifiers)
14666
+ void SetMouseMode(int modifiers, int modifiersex)
1447114667 {
1447214668 //System.out.println("SetMouseMode = " + modifiers);
1447314669 //modifiers &= ~1024;
....@@ -14479,25 +14675,25 @@
1447914675 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448014676 // return;
1448114677 //System.out.println("SetMode = " + modifiers);
14482
- if ((modifiers & WHEEL) == WHEEL)
14678
+ if ((modifiersex & WHEEL) == WHEEL)
1448314679 {
1448414680 mouseMode |= ZOOM;
1448514681 }
1448614682
1448714683 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14488
- if (capsLocked || (modifiers & META) == META)
14684
+ if (capsLocked) // || (modifiers & META) == META)
1448914685 {
1449014686 mouseMode |= VR; // BACKFORTH;
1449114687 }
14492
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14688
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449314689 {
1449414690 mouseMode |= SELECT;
1449514691 }
14496
- if ((modifiers & COMMAND) == COMMAND)
14692
+ if ((modifiersex & COMMAND) == COMMAND)
1449714693 {
1449814694 mouseMode |= SELECT;
1449914695 }
14500
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14696
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450114697 {
1450214698 mouseMode &= ~VR;
1450314699 mouseMode |= TRANSLATE;
....@@ -14526,7 +14722,7 @@
1452614722
1452714723 if (isRenderer) //
1452814724 {
14529
- SetMouseMode(modifiers);
14725
+ SetMouseMode(0, modifiers);
1453014726 }
1453114727
1453214728 Globals.theRenderer.keyPressed(key);
....@@ -14862,7 +15058,7 @@
1486215058 //RESIZETEXTURE ^= true;
1486315059 //break;
1486415060 case 'z':
14865
- RENDERSHADOW ^= true;
15061
+ Globals.RENDERSHADOW ^= true;
1486615062 Globals.lighttouched = true;
1486715063 repaint();
1486815064 break;
....@@ -14986,7 +15182,7 @@
1498615182 //mode = ROTATE;
1498715183 if ((MODIFIERS & COMMAND) == 0) // VR??
1498815184 {
14989
- SetMouseMode(modifiers);
15185
+ SetMouseMode(0, modifiers);
1499015186 }
1499115187 }
1499215188
....@@ -15122,7 +15318,7 @@
1512215318 {
1512315319 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512415320 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15125
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15321
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512615322 {
1512715323 mouseMoved(e);
1512815324 } else
....@@ -15341,7 +15537,9 @@
1534115537 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534215538 //Image img = CreateImage(width, height);
1534315539 //System.out.println("width = " + width + "; height = " + height + "\n");
15540
+
1534415541 Graphics gr = g; // img.getGraphics();
15542
+
1534515543 if (!hasMarquee)
1534615544 {
1534715545 if (Xmin < Xmax) // !locked)
....@@ -15439,14 +15637,33 @@
1543915637 if (!isRenderer)
1544015638 {
1544115639 object.drawEditHandles(info, 0);
15640
+
15641
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15642
+ {
15643
+ switch (object.selection.get(0).hitSomething)
15644
+ {
15645
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15646
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15647
+ break;
15648
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15649
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15650
+ break;
15651
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15652
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15653
+ break;
15654
+ }
15655
+
15656
+ }
1544215657 }
1544315658 }
15659
+
1544415660 if (isRenderer)
1544515661 {
1544615662 //gr.setColor(Color.black);
1544715663 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544815664 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544915665 }
15666
+
1545015667 if (hasMarquee)
1545115668 {
1545215669 gr.setXORMode(Color.white);
....@@ -15559,6 +15776,7 @@
1555915776 public boolean mouseDown(Event evt, int x, int y)
1556015777 {
1556115778 System.out.println("mouseDown: " + evt);
15779
+ System.exit(0);
1556215780 /*
1556315781 locked = true;
1556415782 drag = false;
....@@ -15602,7 +15820,7 @@
1560215820 {
1560315821 keyPressed(0, modifiers);
1560415822 }
15605
- clickStart(x, y, modifiers);
15823
+ // clickStart(x, y, modifiers);
1560615824 return true;
1560715825 }
1560815826
....@@ -15720,7 +15938,7 @@
1572015938 {
1572115939 keyReleased(0, 0);
1572215940 }
15723
- drag(x, y, modifiers);
15941
+ drag(x, y, 0, modifiers);
1572415942 return true;
1572515943 }
1572615944
....@@ -15852,7 +16070,7 @@
1585216070 Object3D object;
1585316071 static Object3D trackedobject;
1585416072 Camera renderCamera; // Light or Eye (or Occlusion)
15855
- /*static*/ Camera manipCamera; // Light or Eye
16073
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585616074 /*static*/ Camera eyeCamera;
1585716075 /*static*/ Camera lightCamera;
1585816076 int cameracount;
....@@ -16418,16 +16636,16 @@
1641816636 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]));
1641916637 }
1642016638
16421
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16639
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642216640 }
1642316641 }
1642416642
1642516643 if (!movingcamera && !PAINTMODE)
1642616644 object.editWindow.ScreenFitPoint(); // fev 2014
1642716645
16428
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16646
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642916647 {
16430
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16648
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643116649
1643216650 Object3D group = new Object3D("inst" + paintcount++);
1643316651
....@@ -16583,7 +16801,7 @@
1658316801 gl.glDisable(gl.GL_CULL_FACE);
1658416802 }
1658516803
16586
- if (!RENDERSHADOW)
16804
+ if (!Globals.RENDERSHADOW)
1658716805 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816806
1658916807 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16593,7 +16811,7 @@
1659316811 //gl.glColorMask(false, false, false, false);
1659416812
1659516813 //render_scene_from_light_view(gl, drawable, 0, 0);
16596
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16814
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659716815 {
1659816816 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659916817