Normand Briere
2019-06-16 372b7fd481a476cd659713a4a01bf28bf6760cbe
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 {
....@@ -8024,7 +8024,7 @@
80248024 }
80258025 }
80268026
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288028 {
80298029 if (// DrawMode() != 0 || /*tex == null ||*/
80308030 ambientOcclusion ) // || !textureon)
....@@ -8069,7 +8069,27 @@
80698069 return; // true;
80708070 }
80718071
8072
- 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
80738093 {
80748094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80758095
....@@ -8077,12 +8097,18 @@
80778097 {
80788098 String texname = tex;
80798099
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;
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
+ }
80868112
80878113 if (CACHETEXTURE)
80888114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8151,7 +8177,7 @@
81518177 }
81528178
81538179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
81558181 cachename = texname;
81568182 else
81578183 processbump = false; // don't process bump map again
....@@ -8173,7 +8199,7 @@
81738199 }
81748200
81758201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
81778203 cachename = texname;
81788204 else
81798205 processbump = false; // don't process bump map again
....@@ -8182,7 +8208,9 @@
81828208 texturedata = GetFileTexture(cachename, processbump, resolution);
81838209
81848210
8185
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
81868214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878215 //texture = GetTexture(tex, bump);
81888216 }
....@@ -8304,7 +8332,7 @@
83048332 return texture;
83058333 }
83068334
8307
- 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
83088336 {
83098337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108338
....@@ -8322,14 +8350,14 @@
83228350 return texture!=null?texture.texture:null;
83238351 }
83248352
8325
- 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
83268354 {
83278355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288356
83298357 return texture!=null?texture.texturedata:null;
83308358 }
83318359
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83338361 {
83348362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358363 {
....@@ -9306,8 +9334,8 @@
93069334 assert (parentcam != renderCamera);
93079335
93089336 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119339
93129340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139341
....@@ -9322,8 +9350,8 @@
93229350 LA.matCopy(renderCamera.fromScreen, matrix);
93239351
93249352 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279355
93289356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299357
....@@ -9395,7 +9423,7 @@
93959423 //gl.glFlush();
93969424 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979425
9398
- if (ANIMATION && ABORTED)
9426
+ if (Globals.ANIMATION && ABORTED)
93999427 {
94009428 System.err.println(" ABORTED FRAME");
94019429 break;
....@@ -9425,7 +9453,7 @@
94259453 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269454
94279455 // save image
9428
- if (ANIMATION && !ABORTED)
9456
+ if (Globals.ANIMATION && !ABORTED)
94299457 {
94309458 VPwidth = viewport[2];
94319459 VPheight = viewport[3];
....@@ -9536,11 +9564,11 @@
95369564
95379565 // imagecount++;
95389566
9539
- 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;
95409568
95419569 if (!BOXMODE)
95429570 {
9543
- 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) + ")");
95449572 }
95459573
95469574 if (!BOXMODE)
....@@ -9578,7 +9606,7 @@
95789606 ABORTED = false;
95799607 }
95809608 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829610
95839611 if (false)
95849612 {
....@@ -10241,11 +10269,11 @@
1024110269
1024210270 public void display(GLAutoDrawable drawable)
1024310271 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
1024510273 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
1024910277 }
1025010278 // if (DEBUG_SELECTION)
1025110279 // {
....@@ -10375,7 +10403,7 @@
1037510403 Object3D theobject = object;
1037610404 Object3D theparent = object.parent;
1037710405 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
1037910407 object.Stripify();
1038010408 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110409 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10416,13 @@
1038810416 ambientOcclusion = false;
1038910417 }
1039010418
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210420 {
1039310421 //if (RENDERSHADOW) // ?
1039410422 if (!IsFrozen())
1039510423 {
1039610424 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810426 {
1039910427 Globals.framecount++;
1040010428 shadowbuffer.display();
....@@ -10521,8 +10549,8 @@
1052110549
1052210550 // if (parentcam != renderCamera) // not a light
1052310551 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610554
1052710555 for (int j = 0; j < 4; j++)
1052810556 {
....@@ -10536,8 +10564,8 @@
1053610564
1053710565 // if (parentcam != renderCamera) // not a light
1053810566 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110569
1054210570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310571
....@@ -10796,7 +10824,16 @@
1079610824 // Bump noise
1079710825 gl.glActiveTexture(GL.GL_TEXTURE6);
1079810826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080010837
1080110838 gl.glActiveTexture(GL.GL_TEXTURE0);
1080210839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10921,8 +10958,8 @@
1092110958 System.err.println("parentcam != renderCamera");
1092210959
1092310960 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092610963 }
1092710964
1092810965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +10980,8 @@
1094310980 if (true) // TODO
1094410981 {
1094510982 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094810985 }
1094910986
1095010987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11297,14 @@
1126011297 {
1126111298 renderpass++;
1126211299 // System.out.println("Draw object... ");
11300
+ STEP = 1;
1126311301 if (FAST) // in case there is no script
11264
- STEP = 16;
11302
+ STEP = 8;
11303
+
11304
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11305
+ {
11306
+ STEP *= 4;
11307
+ }
1126511308
1126611309 //object.FullInvariants();
1126711310
....@@ -11275,8 +11318,8 @@
1127511318 e.printStackTrace();
1127611319 }
1127711320
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
1128011323
1128111324 Globals.ONESTEP = false;
1128211325 }
....@@ -11346,7 +11389,14 @@
1134611389
1134711390 usedtextures.clear();
1134811391
11349
- 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
+ }
1135011400 }
1135111401 //System.out.println("--> " + stackdepth);
1135211402 // GrafreeD.traceon();
....@@ -11437,7 +11487,14 @@
1143711487 if (checker != null && DrawMode() == DEFAULT)
1143811488 {
1143911489 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111498 // NEAREST
1144211499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311500 DrawChecker(gl);
....@@ -11519,7 +11576,7 @@
1151911576 return;
1152011577 }
1152111578
11522
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1152311580
1152411581 GL gl = GetGL();
1152511582
....@@ -11836,8 +11893,8 @@
1183611893 //obj.TransformToWorld(light, light);
1183711894 for (int i = tp.size(); --i >= 0;)
1183811895 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184111898 }
1184211899
1184311900
....@@ -11854,8 +11911,8 @@
1185411911 parentcam = cameras[0];
1185511912 }
1185611913
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185911916
1186011917 LA.xformPos(light, renderCamera.toScreen, light);
1186111918
....@@ -12469,8 +12526,8 @@
1246912526
1247012527 // display shadow only (bump == 0)
1247112528 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412531 "SUB temp.y, one.x, temp.z;" +
1247512532 "MUL temp.x, temp.x, temp.y;" +
1247612533 "KIL temp.x;" +
....@@ -12599,8 +12656,10 @@
1259912656 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012657
1260112658 "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
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
1260412663 "MUL temp.x, temp.x, temp.y;" +
1260512664
1260612665 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +12807,7 @@
1274812807 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274912808 "FLR final.x, final.y;" +
1275012809 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
12810
+ "MUL final.x, final.x, c256i;" +
1275212811 "MOV final.z, zero.x;" +
1275312812 "MOV final.a, one.w;":""
1275412813 ) +
....@@ -12756,7 +12815,7 @@
1275612815 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275712816 "FLR final.x, final.y;" +
1275812817 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
12818
+ "MUL final.x, final.x, c256i;" +
1276012819 "MOV final.z, zero.x;" +
1276112820 "MOV final.a, one.w;":""
1276212821 ) +
....@@ -12799,7 +12858,7 @@
1279912858 //once = true;
1280012859 }
1280112860
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280312862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280412863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280512864
....@@ -12932,12 +12991,16 @@
1293212991
1293312992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293412993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1293512996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293612997 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1293813001 "SUB temp.x, one.x, temp.x;" +
1293913002 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213005
1294313006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13014,10 @@
1295113014 // No shadow for backface
1295213015 "DP3 temp.x, normal, lightd;" +
1295313016 "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;" +
1295413021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513022 "";
1295613023 }
....@@ -13509,7 +13576,7 @@
1350913576 public void mousePressed(MouseEvent e)
1351013577 {
1351113578 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313580 }
1351413581
1351513582 static long prevtime = 0;
....@@ -13585,8 +13652,8 @@
1358513652 // mode |= META;
1358613653 //}
1358713654
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013657 anchorX = ax;
1359113658 anchorY = ay;
1359213659 prevX = px;
....@@ -13646,6 +13713,10 @@
1364613713 // wasliveok = true;
1364713714 // waslive = false;
1364813715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1364913720 // source == timer
1365013721 if (mouseDown)
1365113722 {
....@@ -13684,7 +13755,7 @@
1368413755
1368513756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613757
13687
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813759 {
1368913760 if (!wasliveok)
1369013761 return;
....@@ -13701,7 +13772,7 @@
1370113772 // touched = true; // main DL
1370213773 if (isRenderer)
1370313774 {
13704
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1370513776 }
1370613777
1370713778 selectX = anchorX = x;
....@@ -13714,7 +13785,7 @@
1371413785 clicked = true;
1371513786 hold = false;
1371613787
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913790 {
1372013791 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +13816,7 @@
1374513816 info.camera = renderCamera;
1374613817 info.x = x;
1374713818 info.y = y;
13748
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1374913820 editObj = object.doEditClick(info, 0);
1375013821 if (!editObj)
1375113822 {
....@@ -13762,9 +13833,12 @@
1376213833
1376313834 public void mouseDragged(MouseEvent e)
1376413835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
1376513838 //System.out.println("mouseDragged: " + e);
1376613839 if (isRenderer)
1376713840 movingcamera = true;
13841
+
1376813842 //if (drawing)
1376913843 //return;
1377013844 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +13848,7 @@
1377413848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377513849 }
1377613850 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377813852
1377913853 //try { Thread.sleep(1); } catch (Exception ex) {}
1378013854 }
....@@ -14011,7 +14085,7 @@
1401114085 {
1401214086 Globals.lighttouched = true;
1401314087 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514089 }
1401614090 //else
1401714091 }
....@@ -14111,7 +14185,7 @@
1411114185 int X, Y;
1411214186 boolean SX, SY;
1411314187
14114
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514189 {
1411614190 if (IsFrozen())
1411714191 {
....@@ -14120,17 +14194,17 @@
1412014194
1412114195 drag = true; // NEW
1412214196
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414198
1412514199 X = x;
1412614200 Y = y;
1412714201 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1413014204 if (false) // modifiers != 0)
1413114205 {
1413214206 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1413414208 System.out.println("SHIFT = " + SHIFT);
1413514209 System.out.println("CONTROL = " + COMMAND);
1413614210 System.out.println("META = " + META);
....@@ -14150,7 +14224,7 @@
1415014224 info.camera = renderCamera;
1415114225 info.x = x;
1415214226 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414228 } else
1415514229 {
1415614230 if (x < startX)
....@@ -14326,7 +14400,10 @@
1432614400
1432714401 public void mouseReleased(MouseEvent e)
1432814402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1432914405 movingcamera = false;
14406
+ X = Y = 0;
1433014407 //System.out.println("mouseReleased: " + e);
1433114408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214409 }
....@@ -14349,9 +14426,9 @@
1434914426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114428
14352
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1435314430 timeout = true;
14354
- else
14431
+// ?? May 2019 else
1435514432 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614433 mouseDown = false;
1435714434 if (!control && !command) // june 2013
....@@ -14461,7 +14538,7 @@
1446114538 System.out.println("keyReleased: " + e);
1446214539 }
1446314540
14464
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1446514542 {
1446614543 //System.out.println("SetMouseMode = " + modifiers);
1446714544 //modifiers &= ~1024;
....@@ -14473,25 +14550,25 @@
1447314550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414551 // return;
1447514552 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1447714554 {
1447814555 mouseMode |= ZOOM;
1447914556 }
1448014557
1448114558 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14559
+ if (capsLocked) // || (modifiers & META) == META)
1448314560 {
1448414561 mouseMode |= VR; // BACKFORTH;
1448514562 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714564 {
1448814565 mouseMode |= SELECT;
1448914566 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1449114568 {
1449214569 mouseMode |= SELECT;
1449314570 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514572 {
1449614573 mouseMode &= ~VR;
1449714574 mouseMode |= TRANSLATE;
....@@ -14520,7 +14597,7 @@
1452014597
1452114598 if (isRenderer) //
1452214599 {
14523
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1452414601 }
1452514602
1452614603 Globals.theRenderer.keyPressed(key);
....@@ -14856,7 +14933,7 @@
1485614933 //RESIZETEXTURE ^= true;
1485714934 //break;
1485814935 case 'z':
14859
- RENDERSHADOW ^= true;
14936
+ Globals.RENDERSHADOW ^= true;
1486014937 Globals.lighttouched = true;
1486114938 repaint();
1486214939 break;
....@@ -14980,7 +15057,7 @@
1498015057 //mode = ROTATE;
1498115058 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215059 {
14983
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1498415061 }
1498515062 }
1498615063
....@@ -15116,7 +15193,7 @@
1511615193 {
1511715194 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815195 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015197 {
1512115198 mouseMoved(e);
1512215199 } else
....@@ -15335,7 +15412,9 @@
1533515412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615413 //Image img = CreateImage(width, height);
1533715414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1533815416 Graphics gr = g; // img.getGraphics();
15417
+
1533915418 if (!hasMarquee)
1534015419 {
1534115420 if (Xmin < Xmax) // !locked)
....@@ -15433,14 +15512,33 @@
1543315512 if (!isRenderer)
1543415513 {
1543515514 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
+ }
1543615532 }
1543715533 }
15534
+
1543815535 if (isRenderer)
1543915536 {
1544015537 //gr.setColor(Color.black);
1544115538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315540 }
15541
+
1544415542 if (hasMarquee)
1544515543 {
1544615544 gr.setXORMode(Color.white);
....@@ -15553,6 +15651,7 @@
1555315651 public boolean mouseDown(Event evt, int x, int y)
1555415652 {
1555515653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1555615655 /*
1555715656 locked = true;
1555815657 drag = false;
....@@ -15596,7 +15695,7 @@
1559615695 {
1559715696 keyPressed(0, modifiers);
1559815697 }
15599
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1560015699 return true;
1560115700 }
1560215701
....@@ -15714,7 +15813,7 @@
1571415813 {
1571515814 keyReleased(0, 0);
1571615815 }
15717
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1571815817 return true;
1571915818 }
1572015819
....@@ -15846,7 +15945,7 @@
1584615945 Object3D object;
1584715946 static Object3D trackedobject;
1584815947 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585015949 /*static*/ Camera eyeCamera;
1585115950 /*static*/ Camera lightCamera;
1585215951 int cameracount;
....@@ -16412,16 +16511,16 @@
1641216511 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]));
1641316512 }
1641416513
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616515 }
1641716516 }
1641816517
1641916518 if (!movingcamera && !PAINTMODE)
1642016519 object.editWindow.ScreenFitPoint(); // fev 2014
1642116520
16422
- 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)
1642316522 {
16424
- 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);
1642516524
1642616525 Object3D group = new Object3D("inst" + paintcount++);
1642716526
....@@ -16577,7 +16676,7 @@
1657716676 gl.glDisable(gl.GL_CULL_FACE);
1657816677 }
1657916678
16580
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1658116680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216681
1658316682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16686,7 @@
1658716686 //gl.glColorMask(false, false, false, false);
1658816687
1658916688 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116690 {
1659216691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316692