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 {
....@@ -4208,6 +4208,7 @@
42084208
42094209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104210 {
4211
+ new Exception().printStackTrace();
42114212 System.exit(0);
42124213 com.sun.opengl.util.texture.Texture texture = null;
42134214
....@@ -7920,6 +7921,64 @@
79207921 ReleaseTexture(pigment, false);
79217922 }
79227923
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
+
79237982 void ReleaseTexture(String tex, boolean bump)
79247983 {
79257984 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8023,7 +8082,7 @@
80238082 }
80248083 }
80258084
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8085
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80278086 {
80288087 if (// DrawMode() != 0 || /*tex == null ||*/
80298088 ambientOcclusion ) // || !textureon)
....@@ -8068,7 +8127,94 @@
80688127 return; // true;
80698128 }
80708129
8071
- 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
80728218 {
80738219 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80748220
....@@ -8076,12 +8222,18 @@
80768222 {
80778223 String texname = tex;
80788224
8079
- String[] split = tex.split("Textures");
8080
- if (split.length > 1)
8081
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8082
- else
8083
- if (!texname.startsWith("/"))
8084
- 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
+ }
80858237
80868238 if (CACHETEXTURE)
80878239 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8150,7 +8302,7 @@
81508302 }
81518303
81528304 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8305
+ if (!FileExists(cachename))
81548306 cachename = texname;
81558307 else
81568308 processbump = false; // don't process bump map again
....@@ -8172,7 +8324,7 @@
81728324 }
81738325
81748326 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8327
+ if (!FileExists(cachename))
81768328 cachename = texname;
81778329 else
81788330 processbump = false; // don't process bump map again
....@@ -8181,7 +8333,9 @@
81818333 texturedata = GetFileTexture(cachename, processbump, resolution);
81828334
81838335
8184
- if (texturedata != null)
8336
+ if (texturedata == null)
8337
+ throw new Exception();
8338
+
81858339 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868340 //texture = GetTexture(tex, bump);
81878341 }
....@@ -8303,7 +8457,7 @@
83038457 return texture;
83048458 }
83058459
8306
- 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
83078461 {
83088462 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83098463
....@@ -8321,14 +8475,14 @@
83218475 return texture!=null?texture.texture:null;
83228476 }
83238477
8324
- 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
83258479 {
83268480 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83278481
83288482 return texture!=null?texture.texturedata:null;
83298483 }
83308484
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8485
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83328486 {
83338487 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348488 {
....@@ -9305,8 +9459,8 @@
93059459 assert (parentcam != renderCamera);
93069460
93079461 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9462
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9463
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109464
93119465 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129466
....@@ -9321,8 +9475,8 @@
93219475 LA.matCopy(renderCamera.fromScreen, matrix);
93229476
93239477 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9478
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9479
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269480
93279481 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289482
....@@ -9394,7 +9548,7 @@
93949548 //gl.glFlush();
93959549 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969550
9397
- if (ANIMATION && ABORTED)
9551
+ if (Globals.ANIMATION && ABORTED)
93989552 {
93999553 System.err.println(" ABORTED FRAME");
94009554 break;
....@@ -9424,7 +9578,7 @@
94249578 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259579
94269580 // save image
9427
- if (ANIMATION && !ABORTED)
9581
+ if (Globals.ANIMATION && !ABORTED)
94289582 {
94299583 VPwidth = viewport[2];
94309584 VPheight = viewport[3];
....@@ -9535,11 +9689,11 @@
95359689
95369690 // imagecount++;
95379691
9538
- 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;
95399693
95409694 if (!BOXMODE)
95419695 {
9542
- 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) + ")");
95439697 }
95449698
95459699 if (!BOXMODE)
....@@ -9577,7 +9731,7 @@
95779731 ABORTED = false;
95789732 }
95799733 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9734
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819735
95829736 if (false)
95839737 {
....@@ -10240,11 +10394,11 @@
1024010394
1024110395 public void display(GLAutoDrawable drawable)
1024210396 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10397
+ if (Grafreed.savesound && Grafreed.hassound)
1024410398 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10399
+ Grafreed.wav.save();
10400
+ Grafreed.savesound = false;
10401
+ Grafreed.hassound = false;
1024810402 }
1024910403 // if (DEBUG_SELECTION)
1025010404 // {
....@@ -10374,7 +10528,7 @@
1037410528 Object3D theobject = object;
1037510529 Object3D theparent = object.parent;
1037610530 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10531
+ object = (Object3D)Grafreed.clone(object);
1037810532 object.Stripify();
1037910533 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010534 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10541,13 @@
1038710541 ambientOcclusion = false;
1038810542 }
1038910543
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10544
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110545 {
1039210546 //if (RENDERSHADOW) // ?
1039310547 if (!IsFrozen())
1039410548 {
1039510549 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10550
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710551 {
1039810552 Globals.framecount++;
1039910553 shadowbuffer.display();
....@@ -10520,8 +10674,8 @@
1052010674
1052110675 // if (parentcam != renderCamera) // not a light
1052210676 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10677
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10678
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510679
1052610680 for (int j = 0; j < 4; j++)
1052710681 {
....@@ -10535,8 +10689,8 @@
1053510689
1053610690 // if (parentcam != renderCamera) // not a light
1053710691 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10692
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10693
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010694
1054110695 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210696
....@@ -10795,7 +10949,16 @@
1079510949 // Bump noise
1079610950 gl.glActiveTexture(GL.GL_TEXTURE6);
1079710951 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- 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
+
1079910962
1080010963 gl.glActiveTexture(GL.GL_TEXTURE0);
1080110964 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10920,8 +11083,8 @@
1092011083 System.err.println("parentcam != renderCamera");
1092111084
1092211085 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- 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
1092511088 }
1092611089
1092711090 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11105,8 @@
1094211105 if (true) // TODO
1094311106 {
1094411107 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- 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
1094711110 }
1094811111
1094911112 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11422,14 @@
1125911422 {
1126011423 renderpass++;
1126111424 // System.out.println("Draw object... ");
11425
+ STEP = 1;
1126211426 if (FAST) // in case there is no script
11263
- STEP = 16;
11427
+ STEP = 8;
11428
+
11429
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11430
+ {
11431
+ STEP *= 4;
11432
+ }
1126411433
1126511434 //object.FullInvariants();
1126611435
....@@ -11274,8 +11443,8 @@
1127411443 e.printStackTrace();
1127511444 }
1127611445
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11446
+ if (Grafreed.RENDERME > 0)
11447
+ Grafreed.RENDERME--; // mechante magouille
1127911448
1128011449 Globals.ONESTEP = false;
1128111450 }
....@@ -11345,7 +11514,14 @@
1134511514
1134611515 usedtextures.clear();
1134711516
11348
- 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
+ }
1134911525 }
1135011526 //System.out.println("--> " + stackdepth);
1135111527 // GrafreeD.traceon();
....@@ -11436,7 +11612,14 @@
1143611612 if (checker != null && DrawMode() == DEFAULT)
1143711613 {
1143811614 //BindTexture(IMMORTAL_TEXTURE);
11439
- 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
+ }
1144011623 // NEAREST
1144111624 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211625 DrawChecker(gl);
....@@ -11518,7 +11701,7 @@
1151811701 return;
1151911702 }
1152011703
11521
- String string = obj.GetToolTip();
11704
+ String string = obj.toString(); //.GetToolTip();
1152211705
1152311706 GL gl = GetGL();
1152411707
....@@ -11835,8 +12018,8 @@
1183512018 //obj.TransformToWorld(light, light);
1183612019 for (int i = tp.size(); --i >= 0;)
1183712020 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- 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);
1184012023 }
1184112024
1184212025
....@@ -11853,8 +12036,8 @@
1185312036 parentcam = cameras[0];
1185412037 }
1185512038
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- 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
1185812041
1185912042 LA.xformPos(light, renderCamera.toScreen, light);
1186012043
....@@ -12468,8 +12651,8 @@
1246812651
1246912652 // display shadow only (bump == 0)
1247012653 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12654
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12655
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312656 "SUB temp.y, one.x, temp.z;" +
1247412657 "MUL temp.x, temp.x, temp.y;" +
1247512658 "KIL temp.x;" +
....@@ -12598,8 +12781,10 @@
1259812781 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912782
1260012783 "SUB temp.x, one.x, ndotl.x;" +
12601
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12602
- "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
1260312788 "MUL temp.x, temp.x, temp.y;" +
1260412789
1260512790 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12747,7 +12932,7 @@
1274712932 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274812933 "FLR final.x, final.y;" +
1274912934 "SUB final.y, final.y, final.x;" +
12750
- //"MUL final.x, final.x, c256i;" +
12935
+ "MUL final.x, final.x, c256i;" +
1275112936 "MOV final.z, zero.x;" +
1275212937 "MOV final.a, one.w;":""
1275312938 ) +
....@@ -12755,7 +12940,7 @@
1275512940 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275612941 "FLR final.x, final.y;" +
1275712942 "SUB final.y, final.y, final.x;" +
12758
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1275912944 "MOV final.z, zero.x;" +
1276012945 "MOV final.a, one.w;":""
1276112946 ) +
....@@ -12798,7 +12983,7 @@
1279812983 //once = true;
1279912984 }
1280012985
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
12986
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280212987 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280312988 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280412989
....@@ -12931,12 +13116,16 @@
1293113116
1293213117 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313118 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13119
+
13120
+ // Compare fragment depth in light space with shadowmap.
1293413121 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513122 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13123
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13124
+
13125
+ // Reverse comparison
1293713126 "SUB temp.x, one.x, temp.x;" +
1293813127 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13128
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013129 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113130
1294213131 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13139,10 @@
1295013139 // No shadow for backface
1295113140 "DP3 temp.x, normal, lightd;" +
1295213141 "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;" +
1295313146 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413147 "";
1295513148 }
....@@ -13508,7 +13701,7 @@
1350813701 public void mousePressed(MouseEvent e)
1350913702 {
1351013703 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13704
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213705 }
1351313706
1351413707 static long prevtime = 0;
....@@ -13584,8 +13777,8 @@
1358413777 // mode |= META;
1358513778 //}
1358613779
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13780
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13781
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913782 anchorX = ax;
1359013783 anchorY = ay;
1359113784 prevX = px;
....@@ -13645,6 +13838,10 @@
1364513838 // wasliveok = true;
1364613839 // waslive = false;
1364713840
13841
+ // May 2019 Forget it:
13842
+ if (true)
13843
+ return;
13844
+
1364813845 // source == timer
1364913846 if (mouseDown)
1365013847 {
....@@ -13683,7 +13880,7 @@
1368313880
1368413881 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368513882
13686
- void clickStart(int x, int y, int modifiers)
13883
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368713884 {
1368813885 if (!wasliveok)
1368913886 return;
....@@ -13700,7 +13897,7 @@
1370013897 // touched = true; // main DL
1370113898 if (isRenderer)
1370213899 {
13703
- SetMouseMode(modifiers);
13900
+ SetMouseMode(modifiers, modifiersex);
1370413901 }
1370513902
1370613903 selectX = anchorX = x;
....@@ -13713,7 +13910,7 @@
1371313910 clicked = true;
1371413911 hold = false;
1371513912
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13913
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371713914 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371813915 {
1371913916 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +13941,7 @@
1374413941 info.camera = renderCamera;
1374513942 info.x = x;
1374613943 info.y = y;
13747
- info.modifiers = modifiers;
13944
+ info.modifiers = modifiersex;
1374813945 editObj = object.doEditClick(info, 0);
1374913946 if (!editObj)
1375013947 {
....@@ -13761,9 +13958,12 @@
1376113958
1376213959 public void mouseDragged(MouseEvent e)
1376313960 {
13961
+ Globals.MOUSEDRAGGED = true;
13962
+
1376413963 //System.out.println("mouseDragged: " + e);
1376513964 if (isRenderer)
1376613965 movingcamera = true;
13966
+
1376713967 //if (drawing)
1376813968 //return;
1376913969 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +13973,7 @@
1377313973 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377413974 }
1377513975 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
13976
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377713977
1377813978 //try { Thread.sleep(1); } catch (Exception ex) {}
1377913979 }
....@@ -13946,6 +14146,7 @@
1394614146
1394714147 public void run()
1394814148 {
14149
+ new Exception().printStackTrace();
1394914150 System.exit(0);
1395014151 for (;;)
1395114152 {
....@@ -14009,7 +14210,7 @@
1400914210 {
1401014211 Globals.lighttouched = true;
1401114212 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14213
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314214 }
1401414215 //else
1401514216 }
....@@ -14109,7 +14310,7 @@
1410914310 int X, Y;
1411014311 boolean SX, SY;
1411114312
14112
- void drag(int x, int y, int modifiers)
14313
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314314 {
1411414315 if (IsFrozen())
1411514316 {
....@@ -14118,17 +14319,17 @@
1411814319
1411914320 drag = true; // NEW
1412014321
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14322
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214323
1412314324 X = x;
1412414325 Y = y;
1412514326 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14327
+ MODIFIERS = modifiersex;
14328
+ modifiersex &= ~1024;
1412814329 if (false) // modifiers != 0)
1412914330 {
1413014331 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14332
+ System.out.println("mouseDragged: " + modifiersex);
1413214333 System.out.println("SHIFT = " + SHIFT);
1413314334 System.out.println("CONTROL = " + COMMAND);
1413414335 System.out.println("META = " + META);
....@@ -14148,7 +14349,7 @@
1414814349 info.camera = renderCamera;
1414914350 info.x = x;
1415014351 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14352
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214353 } else
1415314354 {
1415414355 if (x < startX)
....@@ -14324,7 +14525,10 @@
1432414525
1432514526 public void mouseReleased(MouseEvent e)
1432614527 {
14528
+ Globals.MOUSEDRAGGED = false;
14529
+
1432714530 movingcamera = false;
14531
+ X = Y = 0;
1432814532 //System.out.println("mouseReleased: " + e);
1432914533 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014534 }
....@@ -14347,9 +14551,9 @@
1434714551 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814552 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914553
14350
- if (control || command || IsFrozen())
14554
+// No delay if (control || command || IsFrozen())
1435114555 timeout = true;
14352
- else
14556
+// ?? May 2019 else
1435314557 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414558 mouseDown = false;
1435514559 if (!control && !command) // june 2013
....@@ -14459,7 +14663,7 @@
1445914663 System.out.println("keyReleased: " + e);
1446014664 }
1446114665
14462
- void SetMouseMode(int modifiers)
14666
+ void SetMouseMode(int modifiers, int modifiersex)
1446314667 {
1446414668 //System.out.println("SetMouseMode = " + modifiers);
1446514669 //modifiers &= ~1024;
....@@ -14471,25 +14675,25 @@
1447114675 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214676 // return;
1447314677 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14678
+ if ((modifiersex & WHEEL) == WHEEL)
1447514679 {
1447614680 mouseMode |= ZOOM;
1447714681 }
1447814682
1447914683 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14684
+ if (capsLocked) // || (modifiers & META) == META)
1448114685 {
1448214686 mouseMode |= VR; // BACKFORTH;
1448314687 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14688
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514689 {
1448614690 mouseMode |= SELECT;
1448714691 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14692
+ if ((modifiersex & COMMAND) == COMMAND)
1448914693 {
1449014694 mouseMode |= SELECT;
1449114695 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14696
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314697 {
1449414698 mouseMode &= ~VR;
1449514699 mouseMode |= TRANSLATE;
....@@ -14518,7 +14722,7 @@
1451814722
1451914723 if (isRenderer) //
1452014724 {
14521
- SetMouseMode(modifiers);
14725
+ SetMouseMode(0, modifiers);
1452214726 }
1452314727
1452414728 Globals.theRenderer.keyPressed(key);
....@@ -14854,7 +15058,7 @@
1485415058 //RESIZETEXTURE ^= true;
1485515059 //break;
1485615060 case 'z':
14857
- RENDERSHADOW ^= true;
15061
+ Globals.RENDERSHADOW ^= true;
1485815062 Globals.lighttouched = true;
1485915063 repaint();
1486015064 break;
....@@ -14978,7 +15182,7 @@
1497815182 //mode = ROTATE;
1497915183 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015184 {
14981
- SetMouseMode(modifiers);
15185
+ SetMouseMode(0, modifiers);
1498215186 }
1498315187 }
1498415188
....@@ -15114,7 +15318,7 @@
1511415318 {
1511515319 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615320 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- 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)
1511815322 {
1511915323 mouseMoved(e);
1512015324 } else
....@@ -15144,6 +15348,7 @@
1514415348
1514515349 void SelectParent()
1514615350 {
15351
+ new Exception().printStackTrace();
1514715352 System.exit(0);
1514815353 Composite group = (Composite) object;
1514915354 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15167,6 +15372,7 @@
1516715372
1516815373 void SelectChildren()
1516915374 {
15375
+ new Exception().printStackTrace();
1517015376 System.exit(0);
1517115377 /*
1517215378 Composite group = (Composite) object;
....@@ -15331,7 +15537,9 @@
1533115537 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215538 //Image img = CreateImage(width, height);
1533315539 //System.out.println("width = " + width + "; height = " + height + "\n");
15540
+
1533415541 Graphics gr = g; // img.getGraphics();
15542
+
1533515543 if (!hasMarquee)
1533615544 {
1533715545 if (Xmin < Xmax) // !locked)
....@@ -15429,14 +15637,33 @@
1542915637 if (!isRenderer)
1543015638 {
1543115639 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
+ }
1543215657 }
1543315658 }
15659
+
1543415660 if (isRenderer)
1543515661 {
1543615662 //gr.setColor(Color.black);
1543715663 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815664 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915665 }
15666
+
1544015667 if (hasMarquee)
1544115668 {
1544215669 gr.setXORMode(Color.white);
....@@ -15549,6 +15776,7 @@
1554915776 public boolean mouseDown(Event evt, int x, int y)
1555015777 {
1555115778 System.out.println("mouseDown: " + evt);
15779
+ System.exit(0);
1555215780 /*
1555315781 locked = true;
1555415782 drag = false;
....@@ -15592,7 +15820,7 @@
1559215820 {
1559315821 keyPressed(0, modifiers);
1559415822 }
15595
- clickStart(x, y, modifiers);
15823
+ // clickStart(x, y, modifiers);
1559615824 return true;
1559715825 }
1559815826
....@@ -15710,7 +15938,7 @@
1571015938 {
1571115939 keyReleased(0, 0);
1571215940 }
15713
- drag(x, y, modifiers);
15941
+ drag(x, y, 0, modifiers);
1571415942 return true;
1571515943 }
1571615944
....@@ -15842,7 +16070,7 @@
1584216070 Object3D object;
1584316071 static Object3D trackedobject;
1584416072 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16073
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616074 /*static*/ Camera eyeCamera;
1584716075 /*static*/ Camera lightCamera;
1584816076 int cameracount;
....@@ -16280,6 +16508,7 @@
1628016508 {
1628116509 if (!selection)
1628216510 {
16511
+ new Exception().printStackTrace();
1628316512 System.exit(0);
1628416513 return;
1628516514 }
....@@ -16407,16 +16636,16 @@
1640716636 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]));
1640816637 }
1640916638
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16639
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116640 }
1641216641 }
1641316642
1641416643 if (!movingcamera && !PAINTMODE)
1641516644 object.editWindow.ScreenFitPoint(); // fev 2014
1641616645
16417
- 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)
1641816647 {
16419
- 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);
1642016649
1642116650 Object3D group = new Object3D("inst" + paintcount++);
1642216651
....@@ -16572,7 +16801,7 @@
1657216801 gl.glDisable(gl.GL_CULL_FACE);
1657316802 }
1657416803
16575
- if (!RENDERSHADOW)
16804
+ if (!Globals.RENDERSHADOW)
1657616805 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657716806
1657816807 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +16811,7 @@
1658216811 //gl.glColorMask(false, false, false, false);
1658316812
1658416813 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16814
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658616815 {
1658716816 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816817