Normand Briere
2019-06-17 26b49d8e26625491f4a407a05e9bc9d72037f938
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;
....@@ -92,6 +90,8 @@
9290
9391 static int tickcount = 0; // slow pose issue
9492
93
+static boolean BUTTONLESSWHEEL = false;
94
+static boolean ZOOMBOXMODE = false;
9595 static boolean BOXMODE = false;
9696 static boolean IMAGEFLIP = false;
9797 static boolean SMOOTHFOCUS = false;
....@@ -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 {
....@@ -223,6 +225,11 @@
223225 public boolean IsBoxMode()
224226 {
225227 return BOXMODE;
228
+ }
229
+
230
+ public boolean IsZoomBoxMode()
231
+ {
232
+ return ZOOMBOXMODE;
226233 }
227234
228235 public void ClearDepth()
....@@ -457,7 +464,7 @@
457464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458465 {
459466 //gl.glBegin(gl.GL_TRIANGLES);
460
- 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);
461468 if (!hasnorm)
462469 {
463470 // System.out.println("FUCK!!");
....@@ -1612,18 +1619,18 @@
16121619 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131620 if (!material.multiply)
16141621 {
1615
- display.color = color;
1622
+ display.color = material.color;
16161623 display.saturation = material.modulation;
16171624 }
16181625 else
16191626 {
1620
- display.color *= color*2;
1627
+ display.color *= material.color*2;
16211628 display.saturation *= material.modulation*2;
16221629 }
16231630
16241631 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16251632
1626
- float[] colorV = GrafreeD.colorV;
1633
+ float[] colorV = Grafreed.colorV;
16271634
16281635 /**/
16291636 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1883,7 +1890,7 @@
18831890 void PushMatrix(double[][] matrix)
18841891 {
18851892 // GrafreeD.tracein(matrix);
1886
- PushMatrix(matrix,1);
1893
+ PushMatrix(matrix, 1);
18871894 }
18881895
18891896 void PushMatrix()
....@@ -2135,7 +2142,7 @@
21352142 System.err.println("LIVE = " + Globals.isLIVE());
21362143
21372144 if (!Globals.isLIVE()) // save sound
2138
- GrafreeD.savesound = true; // wav.save();
2145
+ Grafreed.savesound = true; // wav.save();
21392146 // else
21402147 repaint(); // start loop // may 2013
21412148 }
....@@ -2168,6 +2175,11 @@
21682175 public void ToggleBoxMode()
21692176 {
21702177 BOXMODE ^= true;
2178
+ }
2179
+
2180
+ public void ToggleZoomBoxMode()
2181
+ {
2182
+ ZOOMBOXMODE ^= true;
21712183 }
21722184
21732185 public void ToggleSmoothFocus()
....@@ -2255,9 +2267,9 @@
22552267 LOOKAT ^= true;
22562268 }
22572269
2258
- void ToggleRandom()
2270
+ void ToggleSwitch()
22592271 {
2260
- RANDOM ^= true;
2272
+ SWITCH ^= true;
22612273 }
22622274
22632275 void ToggleHandles()
....@@ -2364,7 +2376,7 @@
23642376 {
23652377 return currentGL;
23662378 }
2367
-
2379
+
23682380 /**/
23692381 class CacheTexture
23702382 {
....@@ -4196,6 +4208,7 @@
41964208
41974209 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
41984210 {
4211
+ new Exception().printStackTrace();
41994212 System.exit(0);
42004213 com.sun.opengl.util.texture.Texture texture = null;
42014214
....@@ -8011,7 +8024,7 @@
80118024 }
80128025 }
80138026
8014
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8027
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80158028 {
80168029 if (// DrawMode() != 0 || /*tex == null ||*/
80178030 ambientOcclusion ) // || !textureon)
....@@ -8056,7 +8069,27 @@
80568069 return; // true;
80578070 }
80588071
8059
- 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
80608093 {
80618094 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80628095
....@@ -8064,12 +8097,18 @@
80648097 {
80658098 String texname = tex;
80668099
8067
- String[] split = tex.split("Textures");
8068
- if (split.length > 1)
8069
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8070
- else
8071
- if (!texname.startsWith("/"))
8072
- 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
+ }
80738112
80748113 if (CACHETEXTURE)
80758114 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8138,7 +8177,7 @@
81388177 }
81398178
81408179 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8180
+ if (!FileExists(cachename))
81428181 cachename = texname;
81438182 else
81448183 processbump = false; // don't process bump map again
....@@ -8160,7 +8199,7 @@
81608199 }
81618200
81628201 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8202
+ if (!FileExists(cachename))
81648203 cachename = texname;
81658204 else
81668205 processbump = false; // don't process bump map again
....@@ -8169,7 +8208,9 @@
81698208 texturedata = GetFileTexture(cachename, processbump, resolution);
81708209
81718210
8172
- if (texturedata != null)
8211
+ if (texturedata == null)
8212
+ throw new Exception();
8213
+
81738214 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81748215 //texture = GetTexture(tex, bump);
81758216 }
....@@ -8291,7 +8332,7 @@
82918332 return texture;
82928333 }
82938334
8294
- 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
82958336 {
82968337 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
82978338
....@@ -8309,14 +8350,14 @@
83098350 return texture!=null?texture.texture:null;
83108351 }
83118352
8312
- 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
83138354 {
83148355 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83158356
83168357 return texture!=null?texture.texturedata:null;
83178358 }
83188359
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8360
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83208361 {
83218362 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228363 {
....@@ -9293,8 +9334,8 @@
92939334 assert (parentcam != renderCamera);
92949335
92959336 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9337
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9338
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
92989339
92999340 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009341
....@@ -9309,8 +9350,8 @@
93099350 LA.matCopy(renderCamera.fromScreen, matrix);
93109351
93119352 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9353
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9354
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93149355
93159356 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169357
....@@ -9382,7 +9423,7 @@
93829423 //gl.glFlush();
93839424 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849425
9385
- if (ANIMATION && ABORTED)
9426
+ if (Globals.ANIMATION && ABORTED)
93869427 {
93879428 System.err.println(" ABORTED FRAME");
93889429 break;
....@@ -9412,7 +9453,7 @@
94129453 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139454
94149455 // save image
9415
- if (ANIMATION && !ABORTED)
9456
+ if (Globals.ANIMATION && !ABORTED)
94169457 {
94179458 VPwidth = viewport[2];
94189459 VPheight = viewport[3];
....@@ -9523,11 +9564,11 @@
95239564
95249565 // imagecount++;
95259566
9526
- 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;
95279568
95289569 if (!BOXMODE)
95299570 {
9530
- 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) + ")");
95319572 }
95329573
95339574 if (!BOXMODE)
....@@ -9565,7 +9606,7 @@
95659606 ABORTED = false;
95669607 }
95679608 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9609
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699610
95709611 if (false)
95719612 {
....@@ -10228,11 +10269,11 @@
1022810269
1022910270 public void display(GLAutoDrawable drawable)
1023010271 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10272
+ if (Grafreed.savesound && Grafreed.hassound)
1023210273 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10274
+ Grafreed.wav.save();
10275
+ Grafreed.savesound = false;
10276
+ Grafreed.hassound = false;
1023610277 }
1023710278 // if (DEBUG_SELECTION)
1023810279 // {
....@@ -10362,7 +10403,7 @@
1036210403 Object3D theobject = object;
1036310404 Object3D theparent = object.parent;
1036410405 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10406
+ object = (Object3D)Grafreed.clone(object);
1036610407 object.Stripify();
1036710408 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810409 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10416,13 @@
1037510416 ambientOcclusion = false;
1037610417 }
1037710418
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10419
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910420 {
1038010421 //if (RENDERSHADOW) // ?
1038110422 if (!IsFrozen())
1038210423 {
1038310424 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10425
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510426 {
1038610427 Globals.framecount++;
1038710428 shadowbuffer.display();
....@@ -10508,8 +10549,8 @@
1050810549
1050910550 // if (parentcam != renderCamera) // not a light
1051010551 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10552
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10553
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1051310554
1051410555 for (int j = 0; j < 4; j++)
1051510556 {
....@@ -10523,8 +10564,8 @@
1052310564
1052410565 // if (parentcam != renderCamera) // not a light
1052510566 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10567
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10568
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1052810569
1052910570 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010571
....@@ -10783,7 +10824,16 @@
1078310824 // Bump noise
1078410825 gl.glActiveTexture(GL.GL_TEXTURE6);
1078510826 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- 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
+
1078710837
1078810838 gl.glActiveTexture(GL.GL_TEXTURE0);
1078910839 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10908,8 +10958,8 @@
1090810958 System.err.println("parentcam != renderCamera");
1090910959
1091010960 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- 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
1091310963 }
1091410964
1091510965 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +10980,8 @@
1093010980 if (true) // TODO
1093110981 {
1093210982 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- 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
1093510985 }
1093610986
1093710987 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11247,8 +11297,14 @@
1124711297 {
1124811298 renderpass++;
1124911299 // System.out.println("Draw object... ");
11300
+ STEP = 1;
1125011301 if (FAST) // in case there is no script
11251
- STEP = 16;
11302
+ STEP = 8;
11303
+
11304
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11305
+ {
11306
+ STEP *= 4;
11307
+ }
1125211308
1125311309 //object.FullInvariants();
1125411310
....@@ -11262,8 +11318,8 @@
1126211318 e.printStackTrace();
1126311319 }
1126411320
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11321
+ if (Grafreed.RENDERME > 0)
11322
+ Grafreed.RENDERME--; // mechante magouille
1126711323
1126811324 Globals.ONESTEP = false;
1126911325 }
....@@ -11333,7 +11389,14 @@
1133311389
1133411390 usedtextures.clear();
1133511391
11336
- 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
+ }
1133711400 }
1133811401 //System.out.println("--> " + stackdepth);
1133911402 // GrafreeD.traceon();
....@@ -11424,7 +11487,14 @@
1142411487 if (checker != null && DrawMode() == DEFAULT)
1142511488 {
1142611489 //BindTexture(IMMORTAL_TEXTURE);
11427
- 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
+ }
1142811498 // NEAREST
1142911499 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011500 DrawChecker(gl);
....@@ -11506,7 +11576,7 @@
1150611576 return;
1150711577 }
1150811578
11509
- String string = obj.GetToolTip();
11579
+ String string = obj.toString(); //.GetToolTip();
1151011580
1151111581 GL gl = GetGL();
1151211582
....@@ -11823,8 +11893,8 @@
1182311893 //obj.TransformToWorld(light, light);
1182411894 for (int i = tp.size(); --i >= 0;)
1182511895 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- 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);
1182811898 }
1182911899
1183011900
....@@ -11841,8 +11911,8 @@
1184111911 parentcam = cameras[0];
1184211912 }
1184311913
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- 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
1184611916
1184711917 LA.xformPos(light, renderCamera.toScreen, light);
1184811918
....@@ -12456,8 +12526,8 @@
1245612526
1245712527 // display shadow only (bump == 0)
1245812528 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12529
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12530
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112531 "SUB temp.y, one.x, temp.z;" +
1246212532 "MUL temp.x, temp.x, temp.y;" +
1246312533 "KIL temp.x;" +
....@@ -12586,8 +12656,10 @@
1258612656 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258712657
1258812658 "SUB temp.x, one.x, ndotl.x;" +
12589
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12590
- "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
1259112663 "MUL temp.x, temp.x, temp.y;" +
1259212664
1259312665 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +12858,7 @@
1278612858 //once = true;
1278712859 }
1278812860
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
12861
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279012862 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279112863 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279212864
....@@ -12919,12 +12991,16 @@
1291912991
1292012992 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292112993 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
12994
+
12995
+ // Compare fragment depth in light space with shadowmap.
1292212996 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292312997 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
12998
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
12999
+
13000
+ // Reverse comparison
1292513001 "SUB temp.x, one.x, temp.x;" +
1292613002 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13003
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813004 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913005
1293013006 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13014,10 @@
1293813014 // No shadow for backface
1293913015 "DP3 temp.x, normal, lightd;" +
1294013016 "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;" +
1294113021 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213022 "";
1294313023 }
....@@ -13496,7 +13576,7 @@
1349613576 public void mousePressed(MouseEvent e)
1349713577 {
1349813578 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13579
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350013580 }
1350113581
1350213582 static long prevtime = 0;
....@@ -13523,6 +13603,7 @@
1352313603
1352413604 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513605
13606
+ if (BUTTONLESSWHEEL)
1352613607 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713608 {
1352813609 return;
....@@ -13531,7 +13612,7 @@
1353113612 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213613
1353313614 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13615
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513616 {
1353613617 keepboxmode = BOXMODE;
1353713618 keepsupport = SUPPORT;
....@@ -13571,8 +13652,8 @@
1357113652 // mode |= META;
1357213653 //}
1357313654
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13655
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13656
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357613657 anchorX = ax;
1357713658 anchorY = ay;
1357813659 prevX = px;
....@@ -13632,6 +13713,10 @@
1363213713 // wasliveok = true;
1363313714 // waslive = false;
1363413715
13716
+ // May 2019 Forget it:
13717
+ if (true)
13718
+ return;
13719
+
1363513720 // source == timer
1363613721 if (mouseDown)
1363713722 {
....@@ -13670,7 +13755,7 @@
1367013755
1367113756 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367213757
13673
- void clickStart(int x, int y, int modifiers)
13758
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367413759 {
1367513760 if (!wasliveok)
1367613761 return;
....@@ -13687,7 +13772,7 @@
1368713772 // touched = true; // main DL
1368813773 if (isRenderer)
1368913774 {
13690
- SetMouseMode(modifiers);
13775
+ SetMouseMode(modifiers, modifiersex);
1369113776 }
1369213777
1369313778 selectX = anchorX = x;
....@@ -13700,7 +13785,7 @@
1370013785 clicked = true;
1370113786 hold = false;
1370213787
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13788
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370413789 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370513790 {
1370613791 // System.out.println("RESTART II " + modifiers);
....@@ -13731,7 +13816,7 @@
1373113816 info.camera = renderCamera;
1373213817 info.x = x;
1373313818 info.y = y;
13734
- info.modifiers = modifiers;
13819
+ info.modifiers = modifiersex;
1373513820 editObj = object.doEditClick(info, 0);
1373613821 if (!editObj)
1373713822 {
....@@ -13748,11 +13833,14 @@
1374813833
1374913834 public void mouseDragged(MouseEvent e)
1375013835 {
13836
+ Globals.MOUSEDRAGGED = true;
13837
+
13838
+ //System.out.println("mouseDragged: " + e);
1375113839 if (isRenderer)
1375213840 movingcamera = true;
13841
+
1375313842 //if (drawing)
1375413843 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375613844 if ((e.getModifiersEx() & CTRL) != 0
1375713845 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375813846 {
....@@ -13760,7 +13848,7 @@
1376013848 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376113849 }
1376213850 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
13851
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376413852
1376513853 //try { Thread.sleep(1); } catch (Exception ex) {}
1376613854 }
....@@ -13933,6 +14021,7 @@
1393314021
1393414022 public void run()
1393514023 {
14024
+ new Exception().printStackTrace();
1393614025 System.exit(0);
1393714026 for (;;)
1393814027 {
....@@ -13996,7 +14085,7 @@
1399614085 {
1399714086 Globals.lighttouched = true;
1399814087 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14088
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014089 }
1400114090 //else
1400214091 }
....@@ -14096,7 +14185,7 @@
1409614185 int X, Y;
1409714186 boolean SX, SY;
1409814187
14099
- void drag(int x, int y, int modifiers)
14188
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014189 {
1410114190 if (IsFrozen())
1410214191 {
....@@ -14105,17 +14194,17 @@
1410514194
1410614195 drag = true; // NEW
1410714196
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14197
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914198
1411014199 X = x;
1411114200 Y = y;
1411214201 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14202
+ MODIFIERS = modifiersex;
14203
+ modifiersex &= ~1024;
1411514204 if (false) // modifiers != 0)
1411614205 {
1411714206 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14207
+ System.out.println("mouseDragged: " + modifiersex);
1411914208 System.out.println("SHIFT = " + SHIFT);
1412014209 System.out.println("CONTROL = " + COMMAND);
1412114210 System.out.println("META = " + META);
....@@ -14135,7 +14224,7 @@
1413514224 info.camera = renderCamera;
1413614225 info.x = x;
1413714226 info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14227
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914228 } else
1414014229 {
1414114230 if (x < startX)
....@@ -14287,7 +14376,6 @@
1428714376 public void mouseMoved(MouseEvent e)
1428814377 {
1428914378 //System.out.println("mouseMoved: " + e);
14290
-
1429114379 if (isRenderer)
1429214380 return;
1429314381
....@@ -14312,7 +14400,10 @@
1431214400
1431314401 public void mouseReleased(MouseEvent e)
1431414402 {
14403
+ Globals.MOUSEDRAGGED = false;
14404
+
1431514405 movingcamera = false;
14406
+ X = Y = 0;
1431614407 //System.out.println("mouseReleased: " + e);
1431714408 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814409 }
....@@ -14335,9 +14426,9 @@
1433514426 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614427 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714428
14338
- if (control || command || IsFrozen())
14429
+// No delay if (control || command || IsFrozen())
1433914430 timeout = true;
14340
- else
14431
+// ?? May 2019 else
1434114432 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214433 mouseDown = false;
1434314434 if (!control && !command) // june 2013
....@@ -14447,7 +14538,7 @@
1444714538 System.out.println("keyReleased: " + e);
1444814539 }
1444914540
14450
- void SetMouseMode(int modifiers)
14541
+ void SetMouseMode(int modifiers, int modifiersex)
1445114542 {
1445214543 //System.out.println("SetMouseMode = " + modifiers);
1445314544 //modifiers &= ~1024;
....@@ -14459,25 +14550,25 @@
1445914550 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446014551 // return;
1446114552 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
14553
+ if ((modifiersex & WHEEL) == WHEEL)
1446314554 {
1446414555 mouseMode |= ZOOM;
1446514556 }
1446614557
1446714558 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
14559
+ if (capsLocked) // || (modifiers & META) == META)
1446914560 {
1447014561 mouseMode |= VR; // BACKFORTH;
1447114562 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14563
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447314564 {
1447414565 mouseMode |= SELECT;
1447514566 }
14476
- if ((modifiers & COMMAND) == COMMAND)
14567
+ if ((modifiersex & COMMAND) == COMMAND)
1447714568 {
1447814569 mouseMode |= SELECT;
1447914570 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14571
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448114572 {
1448214573 mouseMode &= ~VR;
1448314574 mouseMode |= TRANSLATE;
....@@ -14506,7 +14597,7 @@
1450614597
1450714598 if (isRenderer) //
1450814599 {
14509
- SetMouseMode(modifiers);
14600
+ SetMouseMode(0, modifiers);
1451014601 }
1451114602
1451214603 Globals.theRenderer.keyPressed(key);
....@@ -14842,7 +14933,7 @@
1484214933 //RESIZETEXTURE ^= true;
1484314934 //break;
1484414935 case 'z':
14845
- RENDERSHADOW ^= true;
14936
+ Globals.RENDERSHADOW ^= true;
1484614937 Globals.lighttouched = true;
1484714938 repaint();
1484814939 break;
....@@ -14966,7 +15057,7 @@
1496615057 //mode = ROTATE;
1496715058 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815059 {
14969
- SetMouseMode(modifiers);
15060
+ SetMouseMode(0, modifiers);
1497015061 }
1497115062 }
1497215063
....@@ -15100,8 +15191,9 @@
1510015191
1510115192 protected void processMouseMotionEvent(MouseEvent e)
1510215193 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15194
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15195
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15196
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515197 {
1510615198 mouseMoved(e);
1510715199 } else
....@@ -15131,6 +15223,7 @@
1513115223
1513215224 void SelectParent()
1513315225 {
15226
+ new Exception().printStackTrace();
1513415227 System.exit(0);
1513515228 Composite group = (Composite) object;
1513615229 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15154,6 +15247,7 @@
1515415247
1515515248 void SelectChildren()
1515615249 {
15250
+ new Exception().printStackTrace();
1515715251 System.exit(0);
1515815252 /*
1515915253 Composite group = (Composite) object;
....@@ -15318,7 +15412,9 @@
1531815412 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915413 //Image img = CreateImage(width, height);
1532015414 //System.out.println("width = " + width + "; height = " + height + "\n");
15415
+
1532115416 Graphics gr = g; // img.getGraphics();
15417
+
1532215418 if (!hasMarquee)
1532315419 {
1532415420 if (Xmin < Xmax) // !locked)
....@@ -15416,14 +15512,33 @@
1541615512 if (!isRenderer)
1541715513 {
1541815514 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
+ }
1541915532 }
1542015533 }
15534
+
1542115535 if (isRenderer)
1542215536 {
1542315537 //gr.setColor(Color.black);
1542415538 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542515539 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542615540 }
15541
+
1542715542 if (hasMarquee)
1542815543 {
1542915544 gr.setXORMode(Color.white);
....@@ -15536,6 +15651,7 @@
1553615651 public boolean mouseDown(Event evt, int x, int y)
1553715652 {
1553815653 System.out.println("mouseDown: " + evt);
15654
+ System.exit(0);
1553915655 /*
1554015656 locked = true;
1554115657 drag = false;
....@@ -15579,7 +15695,7 @@
1557915695 {
1558015696 keyPressed(0, modifiers);
1558115697 }
15582
- clickStart(x, y, modifiers);
15698
+ // clickStart(x, y, modifiers);
1558315699 return true;
1558415700 }
1558515701
....@@ -15697,7 +15813,7 @@
1569715813 {
1569815814 keyReleased(0, 0);
1569915815 }
15700
- drag(x, y, modifiers);
15816
+ drag(x, y, 0, modifiers);
1570115817 return true;
1570215818 }
1570315819
....@@ -15829,7 +15945,7 @@
1582915945 Object3D object;
1583015946 static Object3D trackedobject;
1583115947 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
15948
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583315949 /*static*/ Camera eyeCamera;
1583415950 /*static*/ Camera lightCamera;
1583515951 int cameracount;
....@@ -16267,6 +16383,7 @@
1626716383 {
1626816384 if (!selection)
1626916385 {
16386
+ new Exception().printStackTrace();
1627016387 System.exit(0);
1627116388 return;
1627216389 }
....@@ -16394,16 +16511,16 @@
1639416511 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]));
1639516512 }
1639616513
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16514
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639816515 }
1639916516 }
1640016517
1640116518 if (!movingcamera && !PAINTMODE)
1640216519 object.editWindow.ScreenFitPoint(); // fev 2014
1640316520
16404
- 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)
1640516522 {
16406
- 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);
1640716524
1640816525 Object3D group = new Object3D("inst" + paintcount++);
1640916526
....@@ -16559,7 +16676,7 @@
1655916676 gl.glDisable(gl.GL_CULL_FACE);
1656016677 }
1656116678
16562
- if (!RENDERSHADOW)
16679
+ if (!Globals.RENDERSHADOW)
1656316680 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656416681
1656516682 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +16686,7 @@
1656916686 //gl.glColorMask(false, false, false, false);
1657016687
1657116688 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16689
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657316690 {
1657416691 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657516692