Normand Briere
2019-06-17 13e9febe94aaeebad9c97f6d3e2aa4d73b2495c8
CameraPane.java
....@@ -106,7 +106,7 @@
106106 static boolean OEIL = true;
107107 static boolean OEILONCE = false; // do oeilon then oeiloff
108108 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
110110 static boolean HANDLES = false; // selection doesn't work!!
111111 static boolean PAINTMODE = false;
112112
....@@ -149,6 +149,8 @@
149149 defaultcaps.setAccumBlueBits(16);
150150 defaultcaps.setAccumAlphaBits(16);
151151 }
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152154
153155 void SetAsGLRenderer(boolean b)
154156 {
....@@ -462,7 +464,7 @@
462464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463465 {
464466 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
467
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466468 if (!hasnorm)
467469 {
468470 // System.out.println("FUCK!!");
....@@ -1628,7 +1630,7 @@
16281630
16291631 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301632
1631
- float[] colorV = GrafreeD.colorV;
1633
+ float[] colorV = Grafreed.colorV;
16321634
16331635 /**/
16341636 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1888,7 +1890,7 @@
18881890 void PushMatrix(double[][] matrix)
18891891 {
18901892 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
18921894 }
18931895
18941896 void PushMatrix()
....@@ -2140,7 +2142,7 @@
21402142 System.err.println("LIVE = " + Globals.isLIVE());
21412143
21422144 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2145
+ Grafreed.savesound = true; // wav.save();
21442146 // else
21452147 repaint(); // start loop // may 2013
21462148 }
....@@ -2265,9 +2267,9 @@
22652267 LOOKAT ^= true;
22662268 }
22672269
2268
- void ToggleRandom()
2270
+ void ToggleSwitch()
22692271 {
2270
- RANDOM ^= true;
2272
+ SWITCH ^= true;
22712273 }
22722274
22732275 void ToggleHandles()
....@@ -2374,7 +2376,7 @@
23742376 {
23752377 return currentGL;
23762378 }
2377
-
2379
+
23782380 /**/
23792381 class CacheTexture
23802382 {
....@@ -8022,7 +8024,7 @@
80228024 }
80238025 }
80248026
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268028 {
80278029 if (// DrawMode() != 0 || /*tex == null ||*/
80288030 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8069,27 @@
80678069 return; // true;
80688070 }
80698071
8070
- 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
80718093 {
80728094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738095
....@@ -8075,12 +8097,18 @@
80758097 {
80768098 String texname = tex;
80778099
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- texname = "/Users/nbriere/Textures/" + texname;
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
+ }
80848112
80858113 if (CACHETEXTURE)
80868114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8149,7 +8177,7 @@
81498177 }
81508178
81518179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
81538181 cachename = texname;
81548182 else
81558183 processbump = false; // don't process bump map again
....@@ -8171,7 +8199,7 @@
81718199 }
81728200
81738201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
81758203 cachename = texname;
81768204 else
81778205 processbump = false; // don't process bump map again
....@@ -8180,7 +8208,9 @@
81808208 texturedata = GetFileTexture(cachename, processbump, resolution);
81818209
81828210
8183
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
81848214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81858215 //texture = GetTexture(tex, bump);
81868216 }
....@@ -8302,7 +8332,7 @@
83028332 return texture;
83038333 }
83048334
8305
- 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
83068336 {
83078337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83088338
....@@ -8320,14 +8350,14 @@
83208350 return texture!=null?texture.texture:null;
83218351 }
83228352
8323
- 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
83248354 {
83258355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83268356
83278357 return texture!=null?texture.texturedata:null;
83288358 }
83298359
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83318361 {
83328362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338363 {
....@@ -9304,8 +9334,8 @@
93049334 assert (parentcam != renderCamera);
93059335
93069336 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099339
93109340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119341
....@@ -9320,8 +9350,8 @@
93209350 LA.matCopy(renderCamera.fromScreen, matrix);
93219351
93229352 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259355
93269356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279357
....@@ -9538,7 +9568,7 @@
95389568
95399569 if (!BOXMODE)
95409570 {
9541
- 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) + ")");
95429572 }
95439573
95449574 if (!BOXMODE)
....@@ -9576,7 +9606,7 @@
95769606 ABORTED = false;
95779607 }
95789608 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809610
95819611 if (false)
95829612 {
....@@ -10239,11 +10269,11 @@
1023910269
1024010270 public void display(GLAutoDrawable drawable)
1024110271 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
1024310273 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
1024710277 }
1024810278 // if (DEBUG_SELECTION)
1024910279 // {
....@@ -10373,7 +10403,7 @@
1037310403 Object3D theobject = object;
1037410404 Object3D theparent = object.parent;
1037510405 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
1037710407 object.Stripify();
1037810408 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910409 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10416,13 @@
1038610416 ambientOcclusion = false;
1038710417 }
1038810418
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010420 {
1039110421 //if (RENDERSHADOW) // ?
1039210422 if (!IsFrozen())
1039310423 {
1039410424 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610426 {
1039710427 Globals.framecount++;
1039810428 shadowbuffer.display();
....@@ -10519,8 +10549,8 @@
1051910549
1052010550 // if (parentcam != renderCamera) // not a light
1052110551 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410554
1052510555 for (int j = 0; j < 4; j++)
1052610556 {
....@@ -10534,8 +10564,8 @@
1053410564
1053510565 // if (parentcam != renderCamera) // not a light
1053610566 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910569
1054010570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110571
....@@ -10794,7 +10824,16 @@
1079410824 // Bump noise
1079510825 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- 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
+
1079810837
1079910838 gl.glActiveTexture(GL.GL_TEXTURE0);
1080010839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +10958,8 @@
1091910958 System.err.println("parentcam != renderCamera");
1092010959
1092110960 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- 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
1092410963 }
1092510964
1092610965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +10980,8 @@
1094110980 if (true) // TODO
1094210981 {
1094310982 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- 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
1094610985 }
1094710986
1094810987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,8 +11318,8 @@
1127911318 e.printStackTrace();
1128011319 }
1128111320
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
1128411323
1128511324 Globals.ONESTEP = false;
1128611325 }
....@@ -11350,7 +11389,14 @@
1135011389
1135111390 usedtextures.clear();
1135211391
11353
- 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
+ }
1135411400 }
1135511401 //System.out.println("--> " + stackdepth);
1135611402 // GrafreeD.traceon();
....@@ -11441,7 +11487,14 @@
1144111487 if (checker != null && DrawMode() == DEFAULT)
1144211488 {
1144311489 //BindTexture(IMMORTAL_TEXTURE);
11444
- 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
+ }
1144511498 // NEAREST
1144611499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711500 DrawChecker(gl);
....@@ -11523,7 +11576,7 @@
1152311576 return;
1152411577 }
1152511578
11526
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1152711580
1152811581 GL gl = GetGL();
1152911582
....@@ -11840,8 +11893,8 @@
1184011893 //obj.TransformToWorld(light, light);
1184111894 for (int i = tp.size(); --i >= 0;)
1184211895 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- 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);
1184511898 }
1184611899
1184711900
....@@ -11858,8 +11911,8 @@
1185811911 parentcam = cameras[0];
1185911912 }
1186011913
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- 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
1186311916
1186411917 LA.xformPos(light, renderCamera.toScreen, light);
1186511918
....@@ -12473,8 +12526,8 @@
1247312526
1247412527 // display shadow only (bump == 0)
1247512528 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812531 "SUB temp.y, one.x, temp.z;" +
1247912532 "MUL temp.x, temp.x, temp.y;" +
1248012533 "KIL temp.x;" +
....@@ -12754,7 +12807,7 @@
1275412807 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275512808 "FLR final.x, final.y;" +
1275612809 "SUB final.y, final.y, final.x;" +
12757
- //"MUL final.x, final.x, c256i;" +
12810
+ "MUL final.x, final.x, c256i;" +
1275812811 "MOV final.z, zero.x;" +
1275912812 "MOV final.a, one.w;":""
1276012813 ) +
....@@ -12762,7 +12815,7 @@
1276212815 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276312816 "FLR final.x, final.y;" +
1276412817 "SUB final.y, final.y, final.x;" +
12765
- //"MUL final.x, final.x, c256i;" +
12818
+ "MUL final.x, final.x, c256i;" +
1276612819 "MOV final.z, zero.x;" +
1276712820 "MOV final.a, one.w;":""
1276812821 ) +
....@@ -12805,7 +12858,7 @@
1280512858 //once = true;
1280612859 }
1280712860
12808
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280912862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281012863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281112864
....@@ -12938,12 +12991,16 @@
1293812991
1293912992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294012993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1294112996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294212997 "SGE temp.y, temp.x, zero.x;" +
12943
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1294413001 "SUB temp.x, one.x, temp.x;" +
1294513002 "MUL " + shadow + ".x, temp.x, temp.y;" +
12946
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294713004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294813005
1294913006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12957,6 +13014,10 @@
1295713014 // No shadow for backface
1295813015 "DP3 temp.x, normal, lightd;" +
1295913016 "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;" +
1296013021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296113022 "";
1296213023 }
....@@ -13515,7 +13576,7 @@
1351513576 public void mousePressed(MouseEvent e)
1351613577 {
1351713578 //System.out.println("mousePressed: " + e);
13518
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351913580 }
1352013581
1352113582 static long prevtime = 0;
....@@ -13591,8 +13652,8 @@
1359113652 // mode |= META;
1359213653 //}
1359313654
13594
- SetMouseMode(WHEEL | e.getModifiersEx());
13595
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359613657 anchorX = ax;
1359713658 anchorY = ay;
1359813659 prevX = px;
....@@ -13652,6 +13713,10 @@
1365213713 // wasliveok = true;
1365313714 // waslive = false;
1365413715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1365513720 // source == timer
1365613721 if (mouseDown)
1365713722 {
....@@ -13690,7 +13755,7 @@
1369013755
1369113756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369213757
13693
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369413759 {
1369513760 if (!wasliveok)
1369613761 return;
....@@ -13707,7 +13772,7 @@
1370713772 // touched = true; // main DL
1370813773 if (isRenderer)
1370913774 {
13710
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1371113776 }
1371213777
1371313778 selectX = anchorX = x;
....@@ -13720,7 +13785,7 @@
1372013785 clicked = true;
1372113786 hold = false;
1372213787
13723
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372413789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372513790 {
1372613791 // System.out.println("RESTART II " + modifiers);
....@@ -13751,7 +13816,7 @@
1375113816 info.camera = renderCamera;
1375213817 info.x = x;
1375313818 info.y = y;
13754
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1375513820 editObj = object.doEditClick(info, 0);
1375613821 if (!editObj)
1375713822 {
....@@ -13768,9 +13833,12 @@
1376813833
1376913834 public void mouseDragged(MouseEvent e)
1377013835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
1377113838 //System.out.println("mouseDragged: " + e);
1377213839 if (isRenderer)
1377313840 movingcamera = true;
13841
+
1377413842 //if (drawing)
1377513843 //return;
1377613844 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13780,7 +13848,7 @@
1378013848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378113849 }
1378213850 else
13783
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378413852
1378513853 //try { Thread.sleep(1); } catch (Exception ex) {}
1378613854 }
....@@ -14017,7 +14085,7 @@
1401714085 {
1401814086 Globals.lighttouched = true;
1401914087 }
14020
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402114089 }
1402214090 //else
1402314091 }
....@@ -14117,7 +14185,7 @@
1411714185 int X, Y;
1411814186 boolean SX, SY;
1411914187
14120
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1412114189 {
1412214190 if (IsFrozen())
1412314191 {
....@@ -14126,17 +14194,17 @@
1412614194
1412714195 drag = true; // NEW
1412814196
14129
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413014198
1413114199 X = x;
1413214200 Y = y;
1413314201 // floating state for animation
14134
- MODIFIERS = modifiers;
14135
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1413614204 if (false) // modifiers != 0)
1413714205 {
1413814206 //new Exception().printStackTrace();
14139
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1414014208 System.out.println("SHIFT = " + SHIFT);
1414114209 System.out.println("CONTROL = " + COMMAND);
1414214210 System.out.println("META = " + META);
....@@ -14156,7 +14224,7 @@
1415614224 info.camera = renderCamera;
1415714225 info.x = x;
1415814226 info.y = y;
14159
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416014228 } else
1416114229 {
1416214230 if (x < startX)
....@@ -14332,7 +14400,10 @@
1433214400
1433314401 public void mouseReleased(MouseEvent e)
1433414402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1433514405 movingcamera = false;
14406
+ X = Y = 0;
1433614407 //System.out.println("mouseReleased: " + e);
1433714408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433814409 }
....@@ -14355,9 +14426,9 @@
1435514426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435614427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435714428
14358
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1435914430 timeout = true;
14360
- else
14431
+// ?? May 2019 else
1436114432 // timer.setDelay((modifiers & 128) != 0?0:350);
1436214433 mouseDown = false;
1436314434 if (!control && !command) // june 2013
....@@ -14467,7 +14538,7 @@
1446714538 System.out.println("keyReleased: " + e);
1446814539 }
1446914540
14470
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1447114542 {
1447214543 //System.out.println("SetMouseMode = " + modifiers);
1447314544 //modifiers &= ~1024;
....@@ -14479,25 +14550,25 @@
1447914550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448014551 // return;
1448114552 //System.out.println("SetMode = " + modifiers);
14482
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1448314554 {
1448414555 mouseMode |= ZOOM;
1448514556 }
1448614557
1448714558 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14488
- if (capsLocked || (modifiers & META) == META)
14559
+ if (capsLocked) // || (modifiers & META) == META)
1448914560 {
1449014561 mouseMode |= VR; // BACKFORTH;
1449114562 }
14492
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449314564 {
1449414565 mouseMode |= SELECT;
1449514566 }
14496
- if ((modifiers & COMMAND) == COMMAND)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1449714568 {
1449814569 mouseMode |= SELECT;
1449914570 }
14500
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450114572 {
1450214573 mouseMode &= ~VR;
1450314574 mouseMode |= TRANSLATE;
....@@ -14526,7 +14597,7 @@
1452614597
1452714598 if (isRenderer) //
1452814599 {
14529
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1453014601 }
1453114602
1453214603 Globals.theRenderer.keyPressed(key);
....@@ -14862,7 +14933,7 @@
1486214933 //RESIZETEXTURE ^= true;
1486314934 //break;
1486414935 case 'z':
14865
- RENDERSHADOW ^= true;
14936
+ Globals.RENDERSHADOW ^= true;
1486614937 Globals.lighttouched = true;
1486714938 repaint();
1486814939 break;
....@@ -14986,7 +15057,7 @@
1498615057 //mode = ROTATE;
1498715058 if ((MODIFIERS & COMMAND) == 0) // VR??
1498815059 {
14989
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1499015061 }
1499115062 }
1499215063
....@@ -15122,7 +15193,7 @@
1512215193 {
1512315194 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512415195 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15125
- 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)
1512615197 {
1512715198 mouseMoved(e);
1512815199 } else
....@@ -15341,7 +15412,9 @@
1534115412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534215413 //Image img = CreateImage(width, height);
1534315414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1534415416 Graphics gr = g; // img.getGraphics();
15417
+
1534515418 if (!hasMarquee)
1534615419 {
1534715420 if (Xmin < Xmax) // !locked)
....@@ -15439,14 +15512,33 @@
1543915512 if (!isRenderer)
1544015513 {
1544115514 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
+ }
1544215532 }
1544315533 }
15534
+
1544415535 if (isRenderer)
1544515536 {
1544615537 //gr.setColor(Color.black);
1544715538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544815539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544915540 }
15541
+
1545015542 if (hasMarquee)
1545115543 {
1545215544 gr.setXORMode(Color.white);
....@@ -15559,6 +15651,7 @@
1555915651 public boolean mouseDown(Event evt, int x, int y)
1556015652 {
1556115653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1556215655 /*
1556315656 locked = true;
1556415657 drag = false;
....@@ -15602,7 +15695,7 @@
1560215695 {
1560315696 keyPressed(0, modifiers);
1560415697 }
15605
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1560615699 return true;
1560715700 }
1560815701
....@@ -15720,7 +15813,7 @@
1572015813 {
1572115814 keyReleased(0, 0);
1572215815 }
15723
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1572415817 return true;
1572515818 }
1572615819
....@@ -15852,7 +15945,7 @@
1585215945 Object3D object;
1585315946 static Object3D trackedobject;
1585415947 Camera renderCamera; // Light or Eye (or Occlusion)
15855
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585615949 /*static*/ Camera eyeCamera;
1585715950 /*static*/ Camera lightCamera;
1585815951 int cameracount;
....@@ -16418,16 +16511,16 @@
1641816511 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]));
1641916512 }
1642016513
16421
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642216515 }
1642316516 }
1642416517
1642516518 if (!movingcamera && !PAINTMODE)
1642616519 object.editWindow.ScreenFitPoint(); // fev 2014
1642716520
16428
- 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)
1642916522 {
16430
- 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);
1643116524
1643216525 Object3D group = new Object3D("inst" + paintcount++);
1643316526
....@@ -16583,7 +16676,7 @@
1658316676 gl.glDisable(gl.GL_CULL_FACE);
1658416677 }
1658516678
16586
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1658716680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816681
1658916682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16593,7 +16686,7 @@
1659316686 //gl.glColorMask(false, false, false, false);
1659416687
1659516688 //render_scene_from_light_view(gl, drawable, 0, 0);
16596
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659716690 {
1659816691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659916692