Normand Briere
2019-06-17 13e9febe94aaeebad9c97f6d3e2aa4d73b2495c8
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
....@@ -8023,7 +8024,7 @@
80238024 }
80248025 }
80258026
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80278028 {
80288029 if (// DrawMode() != 0 || /*tex == null ||*/
80298030 ambientOcclusion ) // || !textureon)
....@@ -8068,7 +8069,27 @@
80688069 return; // true;
80698070 }
80708071
8071
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8072
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8073
+
8074
+ private boolean FileExists(String tex)
8075
+ {
8076
+ if (missingTextures.contains(tex))
8077
+ {
8078
+ return false;
8079
+ }
8080
+
8081
+ boolean fileExists = new File(tex).exists();
8082
+
8083
+ if (!fileExists)
8084
+ {
8085
+ // If file exists, the "new File()" is not executed sgain
8086
+ missingTextures.add(tex);
8087
+ }
8088
+
8089
+ return fileExists;
8090
+ }
8091
+
8092
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80728093 {
80738094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80748095
....@@ -8076,12 +8097,18 @@
80768097 {
80778098 String texname = tex;
80788099
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;
8100
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8101
+
8102
+// String[] split = tex.split("Textures");
8103
+// if (split.length > 1)
8104
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8105
+// else
8106
+// if (!texname.startsWith("/"))
8107
+// texname = "/Users/nbriere/Textures/" + texname;
8108
+ if (!FileExists(tex))
8109
+ {
8110
+ texname = fallbackTextureName;
8111
+ }
80858112
80868113 if (CACHETEXTURE)
80878114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8150,7 +8177,7 @@
81508177 }
81518178
81528179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
81548181 cachename = texname;
81558182 else
81568183 processbump = false; // don't process bump map again
....@@ -8172,7 +8199,7 @@
81728199 }
81738200
81748201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
81768203 cachename = texname;
81778204 else
81788205 processbump = false; // don't process bump map again
....@@ -8181,7 +8208,9 @@
81818208 texturedata = GetFileTexture(cachename, processbump, resolution);
81828209
81838210
8184
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
81858214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868215 //texture = GetTexture(tex, bump);
81878216 }
....@@ -8303,7 +8332,7 @@
83038332 return texture;
83048333 }
83058334
8306
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8335
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83078336 {
83088337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83098338
....@@ -8321,14 +8350,14 @@
83218350 return texture!=null?texture.texture:null;
83228351 }
83238352
8324
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8353
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83258354 {
83268355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83278356
83288357 return texture!=null?texture.texturedata:null;
83298358 }
83308359
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83328361 {
83338362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348363 {
....@@ -9305,8 +9334,8 @@
93059334 assert (parentcam != renderCamera);
93069335
93079336 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109339
93119340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129341
....@@ -9321,8 +9350,8 @@
93219350 LA.matCopy(renderCamera.fromScreen, matrix);
93229351
93239352 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269355
93279356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289357
....@@ -9394,7 +9423,7 @@
93949423 //gl.glFlush();
93959424 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969425
9397
- if (ANIMATION && ABORTED)
9426
+ if (Globals.ANIMATION && ABORTED)
93989427 {
93999428 System.err.println(" ABORTED FRAME");
94009429 break;
....@@ -9424,7 +9453,7 @@
94249453 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259454
94269455 // save image
9427
- if (ANIMATION && !ABORTED)
9456
+ if (Globals.ANIMATION && !ABORTED)
94289457 {
94299458 VPwidth = viewport[2];
94309459 VPheight = viewport[3];
....@@ -9535,11 +9564,11 @@
95359564
95369565 // imagecount++;
95379566
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9567
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399568
95409569 if (!BOXMODE)
95419570 {
9542
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9571
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95439572 }
95449573
95459574 if (!BOXMODE)
....@@ -9577,7 +9606,7 @@
95779606 ABORTED = false;
95789607 }
95799608 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819610
95829611 if (false)
95839612 {
....@@ -10240,11 +10269,11 @@
1024010269
1024110270 public void display(GLAutoDrawable drawable)
1024210271 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
1024410273 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
1024810277 }
1024910278 // if (DEBUG_SELECTION)
1025010279 // {
....@@ -10374,7 +10403,7 @@
1037410403 Object3D theobject = object;
1037510404 Object3D theparent = object.parent;
1037610405 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
1037810407 object.Stripify();
1037910408 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010409 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10416,13 @@
1038710416 ambientOcclusion = false;
1038810417 }
1038910418
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110420 {
1039210421 //if (RENDERSHADOW) // ?
1039310422 if (!IsFrozen())
1039410423 {
1039510424 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710426 {
1039810427 Globals.framecount++;
1039910428 shadowbuffer.display();
....@@ -10520,8 +10549,8 @@
1052010549
1052110550 // if (parentcam != renderCamera) // not a light
1052210551 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510554
1052610555 for (int j = 0; j < 4; j++)
1052710556 {
....@@ -10535,8 +10564,8 @@
1053510564
1053610565 // if (parentcam != renderCamera) // not a light
1053710566 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010569
1054110570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210571
....@@ -10795,7 +10824,16 @@
1079510824 // Bump noise
1079610825 gl.glActiveTexture(GL.GL_TEXTURE6);
1079710826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- BindTexture(NOISE_TEXTURE, false, 2);
10827
+
10828
+ try
10829
+ {
10830
+ BindTexture(NOISE_TEXTURE, false, 2);
10831
+ }
10832
+ catch (Exception e)
10833
+ {
10834
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10835
+ }
10836
+
1079910837
1080010838 gl.glActiveTexture(GL.GL_TEXTURE0);
1080110839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10920,8 +10958,8 @@
1092010958 System.err.println("parentcam != renderCamera");
1092110959
1092210960 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
10961
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10962
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092510963 }
1092610964
1092710965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +10980,8 @@
1094210980 if (true) // TODO
1094310981 {
1094410982 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
10983
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10984
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094710985 }
1094810986
1094910987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11297,14 @@
1125911297 {
1126011298 renderpass++;
1126111299 // System.out.println("Draw object... ");
11300
+ STEP = 1;
1126211301 if (FAST) // in case there is no script
11263
- STEP = 16;
11302
+ STEP = 8;
11303
+
11304
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11305
+ {
11306
+ STEP *= 4;
11307
+ }
1126411308
1126511309 //object.FullInvariants();
1126611310
....@@ -11274,8 +11318,8 @@
1127411318 e.printStackTrace();
1127511319 }
1127611320
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
1127911323
1128011324 Globals.ONESTEP = false;
1128111325 }
....@@ -11345,7 +11389,14 @@
1134511389
1134611390 usedtextures.clear();
1134711391
11348
- BindTextures(DEFAULT_TEXTURES, 2);
11392
+ try
11393
+ {
11394
+ BindTextures(DEFAULT_TEXTURES, 2);
11395
+ }
11396
+ catch (Exception e)
11397
+ {
11398
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11399
+ }
1134911400 }
1135011401 //System.out.println("--> " + stackdepth);
1135111402 // GrafreeD.traceon();
....@@ -11436,7 +11487,14 @@
1143611487 if (checker != null && DrawMode() == DEFAULT)
1143711488 {
1143811489 //BindTexture(IMMORTAL_TEXTURE);
11439
- BindTextures(checker.GetTextures(), checker.texres);
11490
+ try
11491
+ {
11492
+ BindTextures(checker.GetTextures(), checker.texres);
11493
+ }
11494
+ catch (Exception e)
11495
+ {
11496
+ System.err.println("FAILED: " + checker.GetTextures());
11497
+ }
1144011498 // NEAREST
1144111499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211500 DrawChecker(gl);
....@@ -11518,7 +11576,7 @@
1151811576 return;
1151911577 }
1152011578
11521
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1152211580
1152311581 GL gl = GetGL();
1152411582
....@@ -11835,8 +11893,8 @@
1183511893 //obj.TransformToWorld(light, light);
1183611894 for (int i = tp.size(); --i >= 0;)
1183711895 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- LA.xformPos(light, tp.get(i).toParent, light);
11896
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11897
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1184011898 }
1184111899
1184211900
....@@ -11853,8 +11911,8 @@
1185311911 parentcam = cameras[0];
1185411912 }
1185511913
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- LA.xformPos(light, parentcam.toParent, light); // may 2013
11914
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11915
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185811916
1185911917 LA.xformPos(light, renderCamera.toScreen, light);
1186011918
....@@ -12468,8 +12526,8 @@
1246812526
1246912527 // display shadow only (bump == 0)
1247012528 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312531 "SUB temp.y, one.x, temp.z;" +
1247412532 "MUL temp.x, temp.x, temp.y;" +
1247512533 "KIL temp.x;" +
....@@ -12598,8 +12656,10 @@
1259812656 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912657
1260012658 "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
12659
+ // Tuning for default skin
12660
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12661
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12662
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260312663 "MUL temp.x, temp.x, temp.y;" +
1260412664
1260512665 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12747,7 +12807,7 @@
1274712807 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274812808 "FLR final.x, final.y;" +
1274912809 "SUB final.y, final.y, final.x;" +
12750
- //"MUL final.x, final.x, c256i;" +
12810
+ "MUL final.x, final.x, c256i;" +
1275112811 "MOV final.z, zero.x;" +
1275212812 "MOV final.a, one.w;":""
1275312813 ) +
....@@ -12755,7 +12815,7 @@
1275512815 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275612816 "FLR final.x, final.y;" +
1275712817 "SUB final.y, final.y, final.x;" +
12758
- //"MUL final.x, final.x, c256i;" +
12818
+ "MUL final.x, final.x, c256i;" +
1275912819 "MOV final.z, zero.x;" +
1276012820 "MOV final.a, one.w;":""
1276112821 ) +
....@@ -12798,7 +12858,7 @@
1279812858 //once = true;
1279912859 }
1280012860
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280212862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280312863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280412864
....@@ -12931,12 +12991,16 @@
1293112991
1293212992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293312993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1293412996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293512997 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1293713001 "SUB temp.x, one.x, temp.x;" +
1293813002 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113005
1294213006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13014,10 @@
1295013014 // No shadow for backface
1295113015 "DP3 temp.x, normal, lightd;" +
1295213016 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13017
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13018
+
13019
+ // No shadow when out of frustrum
13020
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295313021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413022 "";
1295513023 }
....@@ -13508,7 +13576,7 @@
1350813576 public void mousePressed(MouseEvent e)
1350913577 {
1351013578 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213580 }
1351313581
1351413582 static long prevtime = 0;
....@@ -13584,8 +13652,8 @@
1358413652 // mode |= META;
1358513653 //}
1358613654
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913657 anchorX = ax;
1359013658 anchorY = ay;
1359113659 prevX = px;
....@@ -13645,6 +13713,10 @@
1364513713 // wasliveok = true;
1364613714 // waslive = false;
1364713715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1364813720 // source == timer
1364913721 if (mouseDown)
1365013722 {
....@@ -13683,7 +13755,7 @@
1368313755
1368413756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368513757
13686
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368713759 {
1368813760 if (!wasliveok)
1368913761 return;
....@@ -13700,7 +13772,7 @@
1370013772 // touched = true; // main DL
1370113773 if (isRenderer)
1370213774 {
13703
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1370413776 }
1370513777
1370613778 selectX = anchorX = x;
....@@ -13713,7 +13785,7 @@
1371313785 clicked = true;
1371413786 hold = false;
1371513787
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371713789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371813790 {
1371913791 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +13816,7 @@
1374413816 info.camera = renderCamera;
1374513817 info.x = x;
1374613818 info.y = y;
13747
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1374813820 editObj = object.doEditClick(info, 0);
1374913821 if (!editObj)
1375013822 {
....@@ -13761,9 +13833,12 @@
1376113833
1376213834 public void mouseDragged(MouseEvent e)
1376313835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
1376413838 //System.out.println("mouseDragged: " + e);
1376513839 if (isRenderer)
1376613840 movingcamera = true;
13841
+
1376713842 //if (drawing)
1376813843 //return;
1376913844 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +13848,7 @@
1377313848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377413849 }
1377513850 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377713852
1377813853 //try { Thread.sleep(1); } catch (Exception ex) {}
1377913854 }
....@@ -13946,6 +14021,7 @@
1394614021
1394714022 public void run()
1394814023 {
14024
+ new Exception().printStackTrace();
1394914025 System.exit(0);
1395014026 for (;;)
1395114027 {
....@@ -14009,7 +14085,7 @@
1400914085 {
1401014086 Globals.lighttouched = true;
1401114087 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314089 }
1401414090 //else
1401514091 }
....@@ -14109,7 +14185,7 @@
1410914185 int X, Y;
1411014186 boolean SX, SY;
1411114187
14112
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314189 {
1411414190 if (IsFrozen())
1411514191 {
....@@ -14118,17 +14194,17 @@
1411814194
1411914195 drag = true; // NEW
1412014196
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214198
1412314199 X = x;
1412414200 Y = y;
1412514201 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1412814204 if (false) // modifiers != 0)
1412914205 {
1413014206 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1413214208 System.out.println("SHIFT = " + SHIFT);
1413314209 System.out.println("CONTROL = " + COMMAND);
1413414210 System.out.println("META = " + META);
....@@ -14148,7 +14224,7 @@
1414814224 info.camera = renderCamera;
1414914225 info.x = x;
1415014226 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214228 } else
1415314229 {
1415414230 if (x < startX)
....@@ -14324,7 +14400,10 @@
1432414400
1432514401 public void mouseReleased(MouseEvent e)
1432614402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1432714405 movingcamera = false;
14406
+ X = Y = 0;
1432814407 //System.out.println("mouseReleased: " + e);
1432914408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014409 }
....@@ -14347,9 +14426,9 @@
1434714426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914428
14350
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1435114430 timeout = true;
14352
- else
14431
+// ?? May 2019 else
1435314432 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414433 mouseDown = false;
1435514434 if (!control && !command) // june 2013
....@@ -14459,7 +14538,7 @@
1445914538 System.out.println("keyReleased: " + e);
1446014539 }
1446114540
14462
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1446314542 {
1446414543 //System.out.println("SetMouseMode = " + modifiers);
1446514544 //modifiers &= ~1024;
....@@ -14471,25 +14550,25 @@
1447114550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214551 // return;
1447314552 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1447514554 {
1447614555 mouseMode |= ZOOM;
1447714556 }
1447814557
1447914558 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14559
+ if (capsLocked) // || (modifiers & META) == META)
1448114560 {
1448214561 mouseMode |= VR; // BACKFORTH;
1448314562 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514564 {
1448614565 mouseMode |= SELECT;
1448714566 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1448914568 {
1449014569 mouseMode |= SELECT;
1449114570 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314572 {
1449414573 mouseMode &= ~VR;
1449514574 mouseMode |= TRANSLATE;
....@@ -14518,7 +14597,7 @@
1451814597
1451914598 if (isRenderer) //
1452014599 {
14521
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1452214601 }
1452314602
1452414603 Globals.theRenderer.keyPressed(key);
....@@ -14854,7 +14933,7 @@
1485414933 //RESIZETEXTURE ^= true;
1485514934 //break;
1485614935 case 'z':
14857
- RENDERSHADOW ^= true;
14936
+ Globals.RENDERSHADOW ^= true;
1485814937 Globals.lighttouched = true;
1485914938 repaint();
1486014939 break;
....@@ -14978,7 +15057,7 @@
1497815057 //mode = ROTATE;
1497915058 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015059 {
14981
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1498215061 }
1498315062 }
1498415063
....@@ -15114,7 +15193,7 @@
1511415193 {
1511515194 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615195 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15196
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1511815197 {
1511915198 mouseMoved(e);
1512015199 } else
....@@ -15144,6 +15223,7 @@
1514415223
1514515224 void SelectParent()
1514615225 {
15226
+ new Exception().printStackTrace();
1514715227 System.exit(0);
1514815228 Composite group = (Composite) object;
1514915229 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15167,6 +15247,7 @@
1516715247
1516815248 void SelectChildren()
1516915249 {
15250
+ new Exception().printStackTrace();
1517015251 System.exit(0);
1517115252 /*
1517215253 Composite group = (Composite) object;
....@@ -15331,7 +15412,9 @@
1533115412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215413 //Image img = CreateImage(width, height);
1533315414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1533415416 Graphics gr = g; // img.getGraphics();
15417
+
1533515418 if (!hasMarquee)
1533615419 {
1533715420 if (Xmin < Xmax) // !locked)
....@@ -15429,14 +15512,33 @@
1542915512 if (!isRenderer)
1543015513 {
1543115514 object.drawEditHandles(info, 0);
15515
+
15516
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15517
+ {
15518
+ switch (object.selection.get(0).hitSomething)
15519
+ {
15520
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15521
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15522
+ break;
15523
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15524
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15525
+ break;
15526
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15527
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15528
+ break;
15529
+ }
15530
+
15531
+ }
1543215532 }
1543315533 }
15534
+
1543415535 if (isRenderer)
1543515536 {
1543615537 //gr.setColor(Color.black);
1543715538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915540 }
15541
+
1544015542 if (hasMarquee)
1544115543 {
1544215544 gr.setXORMode(Color.white);
....@@ -15549,6 +15651,7 @@
1554915651 public boolean mouseDown(Event evt, int x, int y)
1555015652 {
1555115653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1555215655 /*
1555315656 locked = true;
1555415657 drag = false;
....@@ -15592,7 +15695,7 @@
1559215695 {
1559315696 keyPressed(0, modifiers);
1559415697 }
15595
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1559615699 return true;
1559715700 }
1559815701
....@@ -15710,7 +15813,7 @@
1571015813 {
1571115814 keyReleased(0, 0);
1571215815 }
15713
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1571415817 return true;
1571515818 }
1571615819
....@@ -15842,7 +15945,7 @@
1584215945 Object3D object;
1584315946 static Object3D trackedobject;
1584415947 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584615949 /*static*/ Camera eyeCamera;
1584715950 /*static*/ Camera lightCamera;
1584815951 int cameracount;
....@@ -16280,6 +16383,7 @@
1628016383 {
1628116384 if (!selection)
1628216385 {
16386
+ new Exception().printStackTrace();
1628316387 System.exit(0);
1628416388 return;
1628516389 }
....@@ -16407,16 +16511,16 @@
1640716511 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]));
1640816512 }
1640916513
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116515 }
1641216516 }
1641316517
1641416518 if (!movingcamera && !PAINTMODE)
1641516519 object.editWindow.ScreenFitPoint(); // fev 2014
1641616520
16417
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16521
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1641816522 {
16419
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16523
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642016524
1642116525 Object3D group = new Object3D("inst" + paintcount++);
1642216526
....@@ -16572,7 +16676,7 @@
1657216676 gl.glDisable(gl.GL_CULL_FACE);
1657316677 }
1657416678
16575
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1657616680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657716681
1657816682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +16686,7 @@
1658216686 //gl.glColorMask(false, false, false, false);
1658316687
1658416688 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658616690 {
1658716691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816692