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;" +
....@@ -12603,8 +12781,10 @@
1260312781 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260412782
1260512783 "SUB temp.x, one.x, ndotl.x;" +
12606
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12607
- "ADD temp.y, one.y, options2.y;" + // sursurface
12784
+ // Tuning for default skin
12785
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12786
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12787
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260812788 "MUL temp.x, temp.x, temp.y;" +
1260912789
1261012790 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12752,7 +12932,7 @@
1275212932 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275312933 "FLR final.x, final.y;" +
1275412934 "SUB final.y, final.y, final.x;" +
12755
- //"MUL final.x, final.x, c256i;" +
12935
+ "MUL final.x, final.x, c256i;" +
1275612936 "MOV final.z, zero.x;" +
1275712937 "MOV final.a, one.w;":""
1275812938 ) +
....@@ -12760,7 +12940,7 @@
1276012940 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276112941 "FLR final.x, final.y;" +
1276212942 "SUB final.y, final.y, final.x;" +
12763
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1276412944 "MOV final.z, zero.x;" +
1276512945 "MOV final.a, one.w;":""
1276612946 ) +
....@@ -12803,7 +12983,7 @@
1280312983 //once = true;
1280412984 }
1280512985
12806
- System.out.print("Program #" + mode + "; length = " + program.length());
12986
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280712987 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280812988 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280912989
....@@ -12936,12 +13116,16 @@
1293613116
1293713117 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293813118 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13119
+
13120
+ // Compare fragment depth in light space with shadowmap.
1293913121 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294013122 "SGE temp.y, temp.x, zero.x;" +
12941
- "SUB " + shadow + ".y, one.x, temp.y;" +
13123
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13124
+
13125
+ // Reverse comparison
1294213126 "SUB temp.x, one.x, temp.x;" +
1294313127 "MUL " + shadow + ".x, temp.x, temp.y;" +
12944
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13128
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294513129 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294613130
1294713131 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12955,6 +13139,10 @@
1295513139 // No shadow for backface
1295613140 "DP3 temp.x, normal, lightd;" +
1295713141 "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;" +
1295813146 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295913147 "";
1296013148 }
....@@ -13513,7 +13701,7 @@
1351313701 public void mousePressed(MouseEvent e)
1351413702 {
1351513703 //System.out.println("mousePressed: " + e);
13516
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13704
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351713705 }
1351813706
1351913707 static long prevtime = 0;
....@@ -13589,8 +13777,8 @@
1358913777 // mode |= META;
1359013778 //}
1359113779
13592
- SetMouseMode(WHEEL | e.getModifiersEx());
13593
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13780
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13781
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359413782 anchorX = ax;
1359513783 anchorY = ay;
1359613784 prevX = px;
....@@ -13650,6 +13838,10 @@
1365013838 // wasliveok = true;
1365113839 // waslive = false;
1365213840
13841
+ // May 2019 Forget it:
13842
+ if (true)
13843
+ return;
13844
+
1365313845 // source == timer
1365413846 if (mouseDown)
1365513847 {
....@@ -13688,7 +13880,7 @@
1368813880
1368913881 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369013882
13691
- void clickStart(int x, int y, int modifiers)
13883
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369213884 {
1369313885 if (!wasliveok)
1369413886 return;
....@@ -13705,7 +13897,7 @@
1370513897 // touched = true; // main DL
1370613898 if (isRenderer)
1370713899 {
13708
- SetMouseMode(modifiers);
13900
+ SetMouseMode(modifiers, modifiersex);
1370913901 }
1371013902
1371113903 selectX = anchorX = x;
....@@ -13718,7 +13910,7 @@
1371813910 clicked = true;
1371913911 hold = false;
1372013912
13721
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13913
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372213914 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372313915 {
1372413916 // System.out.println("RESTART II " + modifiers);
....@@ -13749,7 +13941,7 @@
1374913941 info.camera = renderCamera;
1375013942 info.x = x;
1375113943 info.y = y;
13752
- info.modifiers = modifiers;
13944
+ info.modifiers = modifiersex;
1375313945 editObj = object.doEditClick(info, 0);
1375413946 if (!editObj)
1375513947 {
....@@ -13766,9 +13958,12 @@
1376613958
1376713959 public void mouseDragged(MouseEvent e)
1376813960 {
13961
+ Globals.MOUSEDRAGGED = true;
13962
+
1376913963 //System.out.println("mouseDragged: " + e);
1377013964 if (isRenderer)
1377113965 movingcamera = true;
13966
+
1377213967 //if (drawing)
1377313968 //return;
1377413969 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13778,7 +13973,7 @@
1377813973 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377913974 }
1378013975 else
13781
- drag(e.getX(), e.getY(), e.getModifiersEx());
13976
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378213977
1378313978 //try { Thread.sleep(1); } catch (Exception ex) {}
1378413979 }
....@@ -14015,7 +14210,7 @@
1401514210 {
1401614211 Globals.lighttouched = true;
1401714212 }
14018
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14213
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401914214 }
1402014215 //else
1402114216 }
....@@ -14115,7 +14310,7 @@
1411514310 int X, Y;
1411614311 boolean SX, SY;
1411714312
14118
- void drag(int x, int y, int modifiers)
14313
+ void drag(int x, int y, int modifiers, int modifiersex)
1411914314 {
1412014315 if (IsFrozen())
1412114316 {
....@@ -14124,17 +14319,17 @@
1412414319
1412514320 drag = true; // NEW
1412614321
14127
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14322
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412814323
1412914324 X = x;
1413014325 Y = y;
1413114326 // floating state for animation
14132
- MODIFIERS = modifiers;
14133
- modifiers &= ~1024;
14327
+ MODIFIERS = modifiersex;
14328
+ modifiersex &= ~1024;
1413414329 if (false) // modifiers != 0)
1413514330 {
1413614331 //new Exception().printStackTrace();
14137
- System.out.println("mouseDragged: " + modifiers);
14332
+ System.out.println("mouseDragged: " + modifiersex);
1413814333 System.out.println("SHIFT = " + SHIFT);
1413914334 System.out.println("CONTROL = " + COMMAND);
1414014335 System.out.println("META = " + META);
....@@ -14154,7 +14349,7 @@
1415414349 info.camera = renderCamera;
1415514350 info.x = x;
1415614351 info.y = y;
14157
- object.editWindow.copy.doEditDrag(info);
14352
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415814353 } else
1415914354 {
1416014355 if (x < startX)
....@@ -14330,7 +14525,10 @@
1433014525
1433114526 public void mouseReleased(MouseEvent e)
1433214527 {
14528
+ Globals.MOUSEDRAGGED = false;
14529
+
1433314530 movingcamera = false;
14531
+ X = Y = 0;
1433414532 //System.out.println("mouseReleased: " + e);
1433514533 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433614534 }
....@@ -14353,9 +14551,9 @@
1435314551 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435414552 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435514553
14356
- if (control || command || IsFrozen())
14554
+// No delay if (control || command || IsFrozen())
1435714555 timeout = true;
14358
- else
14556
+// ?? May 2019 else
1435914557 // timer.setDelay((modifiers & 128) != 0?0:350);
1436014558 mouseDown = false;
1436114559 if (!control && !command) // june 2013
....@@ -14465,7 +14663,7 @@
1446514663 System.out.println("keyReleased: " + e);
1446614664 }
1446714665
14468
- void SetMouseMode(int modifiers)
14666
+ void SetMouseMode(int modifiers, int modifiersex)
1446914667 {
1447014668 //System.out.println("SetMouseMode = " + modifiers);
1447114669 //modifiers &= ~1024;
....@@ -14477,25 +14675,25 @@
1447714675 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447814676 // return;
1447914677 //System.out.println("SetMode = " + modifiers);
14480
- if ((modifiers & WHEEL) == WHEEL)
14678
+ if ((modifiersex & WHEEL) == WHEEL)
1448114679 {
1448214680 mouseMode |= ZOOM;
1448314681 }
1448414682
1448514683 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14486
- if (capsLocked || (modifiers & META) == META)
14684
+ if (capsLocked) // || (modifiers & META) == META)
1448714685 {
1448814686 mouseMode |= VR; // BACKFORTH;
1448914687 }
14490
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14688
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449114689 {
1449214690 mouseMode |= SELECT;
1449314691 }
14494
- if ((modifiers & COMMAND) == COMMAND)
14692
+ if ((modifiersex & COMMAND) == COMMAND)
1449514693 {
1449614694 mouseMode |= SELECT;
1449714695 }
14498
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14696
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449914697 {
1450014698 mouseMode &= ~VR;
1450114699 mouseMode |= TRANSLATE;
....@@ -14524,7 +14722,7 @@
1452414722
1452514723 if (isRenderer) //
1452614724 {
14527
- SetMouseMode(modifiers);
14725
+ SetMouseMode(0, modifiers);
1452814726 }
1452914727
1453014728 Globals.theRenderer.keyPressed(key);
....@@ -14860,7 +15058,7 @@
1486015058 //RESIZETEXTURE ^= true;
1486115059 //break;
1486215060 case 'z':
14863
- RENDERSHADOW ^= true;
15061
+ Globals.RENDERSHADOW ^= true;
1486415062 Globals.lighttouched = true;
1486515063 repaint();
1486615064 break;
....@@ -14984,7 +15182,7 @@
1498415182 //mode = ROTATE;
1498515183 if ((MODIFIERS & COMMAND) == 0) // VR??
1498615184 {
14987
- SetMouseMode(modifiers);
15185
+ SetMouseMode(0, modifiers);
1498815186 }
1498915187 }
1499015188
....@@ -15120,7 +15318,7 @@
1512015318 {
1512115319 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512215320 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15123
- 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)
1512415322 {
1512515323 mouseMoved(e);
1512615324 } else
....@@ -15339,7 +15537,9 @@
1533915537 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534015538 //Image img = CreateImage(width, height);
1534115539 //System.out.println("width = " + width + "; height = " + height + "\n");
15540
+
1534215541 Graphics gr = g; // img.getGraphics();
15542
+
1534315543 if (!hasMarquee)
1534415544 {
1534515545 if (Xmin < Xmax) // !locked)
....@@ -15437,14 +15637,33 @@
1543715637 if (!isRenderer)
1543815638 {
1543915639 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
+ }
1544015657 }
1544115658 }
15659
+
1544215660 if (isRenderer)
1544315661 {
1544415662 //gr.setColor(Color.black);
1544515663 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544615664 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544715665 }
15666
+
1544815667 if (hasMarquee)
1544915668 {
1545015669 gr.setXORMode(Color.white);
....@@ -15557,6 +15776,7 @@
1555715776 public boolean mouseDown(Event evt, int x, int y)
1555815777 {
1555915778 System.out.println("mouseDown: " + evt);
15779
+ System.exit(0);
1556015780 /*
1556115781 locked = true;
1556215782 drag = false;
....@@ -15600,7 +15820,7 @@
1560015820 {
1560115821 keyPressed(0, modifiers);
1560215822 }
15603
- clickStart(x, y, modifiers);
15823
+ // clickStart(x, y, modifiers);
1560415824 return true;
1560515825 }
1560615826
....@@ -15718,7 +15938,7 @@
1571815938 {
1571915939 keyReleased(0, 0);
1572015940 }
15721
- drag(x, y, modifiers);
15941
+ drag(x, y, 0, modifiers);
1572215942 return true;
1572315943 }
1572415944
....@@ -15850,7 +16070,7 @@
1585016070 Object3D object;
1585116071 static Object3D trackedobject;
1585216072 Camera renderCamera; // Light or Eye (or Occlusion)
15853
- /*static*/ Camera manipCamera; // Light or Eye
16073
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585416074 /*static*/ Camera eyeCamera;
1585516075 /*static*/ Camera lightCamera;
1585616076 int cameracount;
....@@ -16416,16 +16636,16 @@
1641616636 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]));
1641716637 }
1641816638
16419
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16639
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642016640 }
1642116641 }
1642216642
1642316643 if (!movingcamera && !PAINTMODE)
1642416644 object.editWindow.ScreenFitPoint(); // fev 2014
1642516645
16426
- 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)
1642716647 {
16428
- 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);
1642916649
1643016650 Object3D group = new Object3D("inst" + paintcount++);
1643116651
....@@ -16581,7 +16801,7 @@
1658116801 gl.glDisable(gl.GL_CULL_FACE);
1658216802 }
1658316803
16584
- if (!RENDERSHADOW)
16804
+ if (!Globals.RENDERSHADOW)
1658516805 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658616806
1658716807 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16591,7 +16811,7 @@
1659116811 //gl.glColorMask(false, false, false, false);
1659216812
1659316813 //render_scene_from_light_view(gl, drawable, 0, 0);
16594
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16814
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659516815 {
1659616816 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716817