Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
CameraPane.java
....@@ -56,8 +56,6 @@
5656 static int CURRENTANTIALIAS = 0; // 1;
5757 /*static*/ boolean RENDERSHADOW = true;
5858 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6159
6260 boolean DISPLAYTEXT = false;
6361 //boolean REDUCETEXTURE = true;
....@@ -86,7 +84,7 @@
8684 static boolean FULLSCREEN = false;
8785 static boolean SUPPORT = true;
8886 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
87
+static boolean FAST = false;
9088 static boolean SLOWPOSE = false;
9189 static boolean FOOTCONTACT = true;
9290
....@@ -108,7 +106,7 @@
108106 static boolean OEIL = true;
109107 static boolean OEILONCE = false; // do oeilon then oeiloff
110108 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
112110 static boolean HANDLES = false; // selection doesn't work!!
113111 static boolean PAINTMODE = false;
114112
....@@ -151,6 +149,8 @@
151149 defaultcaps.setAccumBlueBits(16);
152150 defaultcaps.setAccumAlphaBits(16);
153151 }
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154154
155155 void SetAsGLRenderer(boolean b)
156156 {
....@@ -464,7 +464,7 @@
464464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465465 {
466466 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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);
468468 if (!hasnorm)
469469 {
470470 // System.out.println("FUCK!!");
....@@ -1630,7 +1630,7 @@
16301630
16311631 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321632
1633
- float[] colorV = GrafreeD.colorV;
1633
+ float[] colorV = Grafreed.colorV;
16341634
16351635 /**/
16361636 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1890,7 +1890,7 @@
18901890 void PushMatrix(double[][] matrix)
18911891 {
18921892 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
18941894 }
18951895
18961896 void PushMatrix()
....@@ -2142,7 +2142,7 @@
21422142 System.err.println("LIVE = " + Globals.isLIVE());
21432143
21442144 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2145
+ Grafreed.savesound = true; // wav.save();
21462146 // else
21472147 repaint(); // start loop // may 2013
21482148 }
....@@ -2267,9 +2267,9 @@
22672267 LOOKAT ^= true;
22682268 }
22692269
2270
- void ToggleRandom()
2270
+ void ToggleSwitch()
22712271 {
2272
- RANDOM ^= true;
2272
+ SWITCH ^= true;
22732273 }
22742274
22752275 void ToggleHandles()
....@@ -2376,7 +2376,7 @@
23762376 {
23772377 return currentGL;
23782378 }
2379
-
2379
+
23802380 /**/
23812381 class CacheTexture
23822382 {
....@@ -7921,6 +7921,64 @@
79217921 ReleaseTexture(pigment, false);
79227922 }
79237923
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
+
79247982 void ReleaseTexture(String tex, boolean bump)
79257983 {
79267984 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8024,7 +8082,7 @@
80248082 }
80258083 }
80268084
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8085
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288086 {
80298087 if (// DrawMode() != 0 || /*tex == null ||*/
80308088 ambientOcclusion ) // || !textureon)
....@@ -8069,7 +8127,94 @@
80698127 return; // true;
80708128 }
80718129
8072
- 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
80738218 {
80748219 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80758220
....@@ -8077,12 +8222,18 @@
80778222 {
80788223 String texname = tex;
80798224
8080
- String[] split = tex.split("Textures");
8081
- if (split.length > 1)
8082
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8083
- else
8084
- if (!texname.startsWith("/"))
8085
- texname = "/Users/nbriere/Textures/" + texname;
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
+ }
80868237
80878238 if (CACHETEXTURE)
80888239 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8151,7 +8302,7 @@
81518302 }
81528303
81538304 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8305
+ if (!FileExists(cachename))
81558306 cachename = texname;
81568307 else
81578308 processbump = false; // don't process bump map again
....@@ -8173,7 +8324,7 @@
81738324 }
81748325
81758326 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8327
+ if (!FileExists(cachename))
81778328 cachename = texname;
81788329 else
81798330 processbump = false; // don't process bump map again
....@@ -8182,7 +8333,9 @@
81828333 texturedata = GetFileTexture(cachename, processbump, resolution);
81838334
81848335
8185
- if (texturedata != null)
8336
+ if (texturedata == null)
8337
+ throw new Exception();
8338
+
81868339 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878340 //texture = GetTexture(tex, bump);
81888341 }
....@@ -8304,7 +8457,7 @@
83048457 return texture;
83058458 }
83068459
8307
- 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
83088461 {
83098462 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108463
....@@ -8322,14 +8475,14 @@
83228475 return texture!=null?texture.texture:null;
83238476 }
83248477
8325
- 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
83268479 {
83278480 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288481
83298482 return texture!=null?texture.texturedata:null;
83308483 }
83318484
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8485
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83338486 {
83348487 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358488 {
....@@ -9306,8 +9459,8 @@
93069459 assert (parentcam != renderCamera);
93079460
93089461 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9462
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9463
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119464
93129465 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139466
....@@ -9322,8 +9475,8 @@
93229475 LA.matCopy(renderCamera.fromScreen, matrix);
93239476
93249477 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9478
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9479
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279480
93289481 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299482
....@@ -9395,7 +9548,7 @@
93959548 //gl.glFlush();
93969549 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979550
9398
- if (ANIMATION && ABORTED)
9551
+ if (Globals.ANIMATION && ABORTED)
93999552 {
94009553 System.err.println(" ABORTED FRAME");
94019554 break;
....@@ -9425,7 +9578,7 @@
94259578 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269579
94279580 // save image
9428
- if (ANIMATION && !ABORTED)
9581
+ if (Globals.ANIMATION && !ABORTED)
94299582 {
94309583 VPwidth = viewport[2];
94319584 VPheight = viewport[3];
....@@ -9536,11 +9689,11 @@
95369689
95379690 // imagecount++;
95389691
9539
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9692
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95409693
95419694 if (!BOXMODE)
95429695 {
9543
- 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) + ")");
95449697 }
95459698
95469699 if (!BOXMODE)
....@@ -9578,7 +9731,7 @@
95789731 ABORTED = false;
95799732 }
95809733 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9734
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829735
95839736 if (false)
95849737 {
....@@ -10241,11 +10394,11 @@
1024110394
1024210395 public void display(GLAutoDrawable drawable)
1024310396 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10397
+ if (Grafreed.savesound && Grafreed.hassound)
1024510398 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10399
+ Grafreed.wav.save();
10400
+ Grafreed.savesound = false;
10401
+ Grafreed.hassound = false;
1024910402 }
1025010403 // if (DEBUG_SELECTION)
1025110404 // {
....@@ -10375,7 +10528,7 @@
1037510528 Object3D theobject = object;
1037610529 Object3D theparent = object.parent;
1037710530 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10531
+ object = (Object3D)Grafreed.clone(object);
1037910532 object.Stripify();
1038010533 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110534 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10541,13 @@
1038810541 ambientOcclusion = false;
1038910542 }
1039010543
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10544
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210545 {
1039310546 //if (RENDERSHADOW) // ?
1039410547 if (!IsFrozen())
1039510548 {
1039610549 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10550
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810551 {
1039910552 Globals.framecount++;
1040010553 shadowbuffer.display();
....@@ -10521,8 +10674,8 @@
1052110674
1052210675 // if (parentcam != renderCamera) // not a light
1052310676 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10677
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10678
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610679
1052710680 for (int j = 0; j < 4; j++)
1052810681 {
....@@ -10536,8 +10689,8 @@
1053610689
1053710690 // if (parentcam != renderCamera) // not a light
1053810691 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10692
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10693
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110694
1054210695 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310696
....@@ -10796,7 +10949,16 @@
1079610949 // Bump noise
1079710950 gl.glActiveTexture(GL.GL_TEXTURE6);
1079810951 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080010962
1080110963 gl.glActiveTexture(GL.GL_TEXTURE0);
1080210964 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10921,8 +11083,8 @@
1092111083 System.err.println("parentcam != renderCamera");
1092211084
1092311085 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611088 }
1092711089
1092811090 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11105,8 @@
1094311105 if (true) // TODO
1094411106 {
1094511107 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811110 }
1094911111
1095011112 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11422,14 @@
1126011422 {
1126111423 renderpass++;
1126211424 // System.out.println("Draw object... ");
11425
+ STEP = 1;
1126311426 if (FAST) // in case there is no script
11264
- STEP = 16;
11427
+ STEP = 8;
11428
+
11429
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11430
+ {
11431
+ STEP *= 4;
11432
+ }
1126511433
1126611434 //object.FullInvariants();
1126711435
....@@ -11275,8 +11443,8 @@
1127511443 e.printStackTrace();
1127611444 }
1127711445
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11446
+ if (Grafreed.RENDERME > 0)
11447
+ Grafreed.RENDERME--; // mechante magouille
1128011448
1128111449 Globals.ONESTEP = false;
1128211450 }
....@@ -11346,7 +11514,14 @@
1134611514
1134711515 usedtextures.clear();
1134811516
11349
- 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
+ }
1135011525 }
1135111526 //System.out.println("--> " + stackdepth);
1135211527 // GrafreeD.traceon();
....@@ -11437,7 +11612,14 @@
1143711612 if (checker != null && DrawMode() == DEFAULT)
1143811613 {
1143911614 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111623 // NEAREST
1144211624 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311625 DrawChecker(gl);
....@@ -11519,7 +11701,7 @@
1151911701 return;
1152011702 }
1152111703
11522
- String string = obj.GetToolTip();
11704
+ String string = obj.toString(); //.GetToolTip();
1152311705
1152411706 GL gl = GetGL();
1152511707
....@@ -11836,8 +12018,8 @@
1183612018 //obj.TransformToWorld(light, light);
1183712019 for (int i = tp.size(); --i >= 0;)
1183812020 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112023 }
1184212024
1184312025
....@@ -11854,8 +12036,8 @@
1185412036 parentcam = cameras[0];
1185512037 }
1185612038
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912041
1186012042 LA.xformPos(light, renderCamera.toScreen, light);
1186112043
....@@ -12469,8 +12651,8 @@
1246912651
1247012652 // display shadow only (bump == 0)
1247112653 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12654
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12655
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412656 "SUB temp.y, one.x, temp.z;" +
1247512657 "MUL temp.x, temp.x, temp.y;" +
1247612658 "KIL temp.x;" +
....@@ -12599,8 +12781,10 @@
1259912781 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012782
1260112783 "SUB temp.x, one.x, ndotl.x;" +
12602
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12603
- "ADD temp.y, one.y, options2.y;" + // sursurface
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
1260412788 "MUL temp.x, temp.x, temp.y;" +
1260512789
1260612790 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +12932,7 @@
1274812932 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274912933 "FLR final.x, final.y;" +
1275012934 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
12935
+ "MUL final.x, final.x, c256i;" +
1275212936 "MOV final.z, zero.x;" +
1275312937 "MOV final.a, one.w;":""
1275412938 ) +
....@@ -12756,7 +12940,7 @@
1275612940 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275712941 "FLR final.x, final.y;" +
1275812942 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1276012944 "MOV final.z, zero.x;" +
1276112945 "MOV final.a, one.w;":""
1276212946 ) +
....@@ -12799,7 +12983,7 @@
1279912983 //once = true;
1280012984 }
1280112985
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
12986
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280312987 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280412988 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280512989
....@@ -12932,12 +13116,16 @@
1293213116
1293313117 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413118 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13119
+
13120
+ // Compare fragment depth in light space with shadowmap.
1293513121 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613122 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13123
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13124
+
13125
+ // Reverse comparison
1293813126 "SUB temp.x, one.x, temp.x;" +
1293913127 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13128
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113129 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213130
1294313131 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13139,10 @@
1295113139 // No shadow for backface
1295213140 "DP3 temp.x, normal, lightd;" +
1295313141 "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;" +
1295413146 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513147 "";
1295613148 }
....@@ -13509,7 +13701,7 @@
1350913701 public void mousePressed(MouseEvent e)
1351013702 {
1351113703 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13704
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313705 }
1351413706
1351513707 static long prevtime = 0;
....@@ -13585,8 +13777,8 @@
1358513777 // mode |= META;
1358613778 //}
1358713779
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13780
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13781
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013782 anchorX = ax;
1359113783 anchorY = ay;
1359213784 prevX = px;
....@@ -13646,6 +13838,10 @@
1364613838 // wasliveok = true;
1364713839 // waslive = false;
1364813840
13841
+ // May 2019 Forget it:
13842
+ if (true)
13843
+ return;
13844
+
1364913845 // source == timer
1365013846 if (mouseDown)
1365113847 {
....@@ -13684,7 +13880,7 @@
1368413880
1368513881 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613882
13687
- void clickStart(int x, int y, int modifiers)
13883
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813884 {
1368913885 if (!wasliveok)
1369013886 return;
....@@ -13701,7 +13897,7 @@
1370113897 // touched = true; // main DL
1370213898 if (isRenderer)
1370313899 {
13704
- SetMouseMode(modifiers);
13900
+ SetMouseMode(modifiers, modifiersex);
1370513901 }
1370613902
1370713903 selectX = anchorX = x;
....@@ -13714,7 +13910,7 @@
1371413910 clicked = true;
1371513911 hold = false;
1371613912
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13913
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813914 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913915 {
1372013916 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +13941,7 @@
1374513941 info.camera = renderCamera;
1374613942 info.x = x;
1374713943 info.y = y;
13748
- info.modifiers = modifiers;
13944
+ info.modifiers = modifiersex;
1374913945 editObj = object.doEditClick(info, 0);
1375013946 if (!editObj)
1375113947 {
....@@ -13762,9 +13958,12 @@
1376213958
1376313959 public void mouseDragged(MouseEvent e)
1376413960 {
13961
+ Globals.MOUSEDRAGGED = true;
13962
+
1376513963 //System.out.println("mouseDragged: " + e);
1376613964 if (isRenderer)
1376713965 movingcamera = true;
13966
+
1376813967 //if (drawing)
1376913968 //return;
1377013969 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +13973,7 @@
1377413973 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377513974 }
1377613975 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
13976
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377813977
1377913978 //try { Thread.sleep(1); } catch (Exception ex) {}
1378013979 }
....@@ -14011,7 +14210,7 @@
1401114210 {
1401214211 Globals.lighttouched = true;
1401314212 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14213
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514214 }
1401614215 //else
1401714216 }
....@@ -14111,7 +14310,7 @@
1411114310 int X, Y;
1411214311 boolean SX, SY;
1411314312
14114
- void drag(int x, int y, int modifiers)
14313
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514314 {
1411614315 if (IsFrozen())
1411714316 {
....@@ -14120,17 +14319,17 @@
1412014319
1412114320 drag = true; // NEW
1412214321
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14322
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414323
1412514324 X = x;
1412614325 Y = y;
1412714326 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14327
+ MODIFIERS = modifiersex;
14328
+ modifiersex &= ~1024;
1413014329 if (false) // modifiers != 0)
1413114330 {
1413214331 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14332
+ System.out.println("mouseDragged: " + modifiersex);
1413414333 System.out.println("SHIFT = " + SHIFT);
1413514334 System.out.println("CONTROL = " + COMMAND);
1413614335 System.out.println("META = " + META);
....@@ -14150,7 +14349,7 @@
1415014349 info.camera = renderCamera;
1415114350 info.x = x;
1415214351 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14352
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414353 } else
1415514354 {
1415614355 if (x < startX)
....@@ -14326,7 +14525,10 @@
1432614525
1432714526 public void mouseReleased(MouseEvent e)
1432814527 {
14528
+ Globals.MOUSEDRAGGED = false;
14529
+
1432914530 movingcamera = false;
14531
+ X = Y = 0;
1433014532 //System.out.println("mouseReleased: " + e);
1433114533 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214534 }
....@@ -14349,9 +14551,9 @@
1434914551 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014552 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114553
14352
- if (control || command || IsFrozen())
14554
+// No delay if (control || command || IsFrozen())
1435314555 timeout = true;
14354
- else
14556
+// ?? May 2019 else
1435514557 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614558 mouseDown = false;
1435714559 if (!control && !command) // june 2013
....@@ -14461,7 +14663,7 @@
1446114663 System.out.println("keyReleased: " + e);
1446214664 }
1446314665
14464
- void SetMouseMode(int modifiers)
14666
+ void SetMouseMode(int modifiers, int modifiersex)
1446514667 {
1446614668 //System.out.println("SetMouseMode = " + modifiers);
1446714669 //modifiers &= ~1024;
....@@ -14473,25 +14675,25 @@
1447314675 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414676 // return;
1447514677 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14678
+ if ((modifiersex & WHEEL) == WHEEL)
1447714679 {
1447814680 mouseMode |= ZOOM;
1447914681 }
1448014682
1448114683 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14684
+ if (capsLocked) // || (modifiers & META) == META)
1448314685 {
1448414686 mouseMode |= VR; // BACKFORTH;
1448514687 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14688
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714689 {
1448814690 mouseMode |= SELECT;
1448914691 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14692
+ if ((modifiersex & COMMAND) == COMMAND)
1449114693 {
1449214694 mouseMode |= SELECT;
1449314695 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14696
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514697 {
1449614698 mouseMode &= ~VR;
1449714699 mouseMode |= TRANSLATE;
....@@ -14520,7 +14722,7 @@
1452014722
1452114723 if (isRenderer) //
1452214724 {
14523
- SetMouseMode(modifiers);
14725
+ SetMouseMode(0, modifiers);
1452414726 }
1452514727
1452614728 Globals.theRenderer.keyPressed(key);
....@@ -14856,7 +15058,7 @@
1485615058 //RESIZETEXTURE ^= true;
1485715059 //break;
1485815060 case 'z':
14859
- RENDERSHADOW ^= true;
15061
+ Globals.RENDERSHADOW ^= true;
1486015062 Globals.lighttouched = true;
1486115063 repaint();
1486215064 break;
....@@ -14980,7 +15182,7 @@
1498015182 //mode = ROTATE;
1498115183 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215184 {
14983
- SetMouseMode(modifiers);
15185
+ SetMouseMode(0, modifiers);
1498415186 }
1498515187 }
1498615188
....@@ -15116,7 +15318,7 @@
1511615318 {
1511715319 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815320 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015322 {
1512115323 mouseMoved(e);
1512215324 } else
....@@ -15335,7 +15537,9 @@
1533515537 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615538 //Image img = CreateImage(width, height);
1533715539 //System.out.println("width = " + width + "; height = " + height + "\n");
15540
+
1533815541 Graphics gr = g; // img.getGraphics();
15542
+
1533915543 if (!hasMarquee)
1534015544 {
1534115545 if (Xmin < Xmax) // !locked)
....@@ -15433,14 +15637,33 @@
1543315637 if (!isRenderer)
1543415638 {
1543515639 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
+ }
1543615657 }
1543715658 }
15659
+
1543815660 if (isRenderer)
1543915661 {
1544015662 //gr.setColor(Color.black);
1544115663 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215664 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315665 }
15666
+
1544415667 if (hasMarquee)
1544515668 {
1544615669 gr.setXORMode(Color.white);
....@@ -15553,6 +15776,7 @@
1555315776 public boolean mouseDown(Event evt, int x, int y)
1555415777 {
1555515778 System.out.println("mouseDown: " + evt);
15779
+ System.exit(0);
1555615780 /*
1555715781 locked = true;
1555815782 drag = false;
....@@ -15596,7 +15820,7 @@
1559615820 {
1559715821 keyPressed(0, modifiers);
1559815822 }
15599
- clickStart(x, y, modifiers);
15823
+ // clickStart(x, y, modifiers);
1560015824 return true;
1560115825 }
1560215826
....@@ -15714,7 +15938,7 @@
1571415938 {
1571515939 keyReleased(0, 0);
1571615940 }
15717
- drag(x, y, modifiers);
15941
+ drag(x, y, 0, modifiers);
1571815942 return true;
1571915943 }
1572015944
....@@ -15846,7 +16070,7 @@
1584616070 Object3D object;
1584716071 static Object3D trackedobject;
1584816072 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16073
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016074 /*static*/ Camera eyeCamera;
1585116075 /*static*/ Camera lightCamera;
1585216076 int cameracount;
....@@ -16412,16 +16636,16 @@
1641216636 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]));
1641316637 }
1641416638
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16639
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616640 }
1641716641 }
1641816642
1641916643 if (!movingcamera && !PAINTMODE)
1642016644 object.editWindow.ScreenFitPoint(); // fev 2014
1642116645
16422
- 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)
1642316647 {
16424
- 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);
1642516649
1642616650 Object3D group = new Object3D("inst" + paintcount++);
1642716651
....@@ -16577,7 +16801,7 @@
1657716801 gl.glDisable(gl.GL_CULL_FACE);
1657816802 }
1657916803
16580
- if (!RENDERSHADOW)
16804
+ if (!Globals.RENDERSHADOW)
1658116805 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216806
1658316807 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16811,7 @@
1658716811 //gl.glColorMask(false, false, false, false);
1658816812
1658916813 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16814
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116815 {
1659216816 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316817