Normand Briere
2019-06-17 e36047725ce3217618d4e5807ac7c8769b9e3598
CameraPane.java
....@@ -56,8 +56,6 @@
5656 static int CURRENTANTIALIAS = 0; // 1;
5757 /*static*/ boolean RENDERSHADOW = true;
5858 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6159
6260 boolean DISPLAYTEXT = false;
6361 //boolean REDUCETEXTURE = true;
....@@ -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
....@@ -7908,6 +7921,64 @@
79087921 ReleaseTexture(pigment, false);
79097922 }
79107923
7924
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7925
+ {
7926
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7927
+ {
7928
+ return;
7929
+ }
7930
+
7931
+ if (tex == null)
7932
+ {
7933
+ ReleaseTexture(null, false);
7934
+ return;
7935
+ }
7936
+
7937
+ String pigment = Object3D.GetPigment(tex);
7938
+
7939
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7940
+ {
7941
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7942
+ // System.out.println("; bump = " + bump);
7943
+ }
7944
+
7945
+ if (pigment.equals(""))
7946
+ {
7947
+ pigment = null;
7948
+ }
7949
+
7950
+ ReleaseTexture(pigment, false);
7951
+ }
7952
+
7953
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7954
+ {
7955
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7956
+ {
7957
+ return;
7958
+ }
7959
+
7960
+ if (tex == null)
7961
+ {
7962
+ ReleaseTexture(null, true);
7963
+ return;
7964
+ }
7965
+
7966
+ String bump = Object3D.GetBump(tex);
7967
+
7968
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7969
+ {
7970
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7971
+ // System.out.println("; bump = " + bump);
7972
+ }
7973
+
7974
+ if (bump.equals(""))
7975
+ {
7976
+ bump = null;
7977
+ }
7978
+
7979
+ ReleaseTexture(bump, true);
7980
+ }
7981
+
79117982 void ReleaseTexture(String tex, boolean bump)
79127983 {
79137984 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8011,7 +8082,7 @@
80118082 }
80128083 }
80138084
8014
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8085
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80158086 {
80168087 if (// DrawMode() != 0 || /*tex == null ||*/
80178088 ambientOcclusion ) // || !textureon)
....@@ -8056,7 +8127,94 @@
80568127 return; // true;
80578128 }
80588129
8059
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8130
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8131
+ {
8132
+ if (// DrawMode() != 0 || /*tex == null ||*/
8133
+ ambientOcclusion ) // || !textureon)
8134
+ {
8135
+ return; // false;
8136
+ }
8137
+
8138
+ if (tex == null)
8139
+ {
8140
+ BindTexture(null,false,resolution);
8141
+ return;
8142
+ }
8143
+
8144
+ String pigment = Object3D.GetPigment(tex);
8145
+
8146
+ usedtextures.put(pigment, pigment);
8147
+
8148
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8149
+ {
8150
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8151
+ // System.out.println("; bump = " + bump);
8152
+ }
8153
+
8154
+ if (pigment.equals(""))
8155
+ {
8156
+ pigment = null;
8157
+ }
8158
+
8159
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8160
+ BindTexture(pigment, false, resolution);
8161
+ }
8162
+
8163
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8164
+ {
8165
+ if (// DrawMode() != 0 || /*tex == null ||*/
8166
+ ambientOcclusion ) // || !textureon)
8167
+ {
8168
+ return; // false;
8169
+ }
8170
+
8171
+ if (tex == null)
8172
+ {
8173
+ BindTexture(null,true,resolution);
8174
+ return;
8175
+ }
8176
+
8177
+ String bump = Object3D.GetBump(tex);
8178
+
8179
+ usedtextures.put(bump, bump);
8180
+
8181
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8182
+ {
8183
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8184
+ // System.out.println("; bump = " + bump);
8185
+ }
8186
+
8187
+ if (bump.equals(""))
8188
+ {
8189
+ bump = null;
8190
+ }
8191
+
8192
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8193
+ BindTexture(bump, true, resolution);
8194
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8195
+ }
8196
+
8197
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8198
+
8199
+ private boolean FileExists(String tex)
8200
+ {
8201
+ if (missingTextures.contains(tex))
8202
+ {
8203
+ return false;
8204
+ }
8205
+
8206
+ boolean fileExists = new File(tex).exists();
8207
+
8208
+ if (!fileExists)
8209
+ {
8210
+ // If file exists, the "new File()" is not executed sgain
8211
+ missingTextures.add(tex);
8212
+ }
8213
+
8214
+ return fileExists;
8215
+ }
8216
+
8217
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80608218 {
80618219 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80628220
....@@ -8064,12 +8222,18 @@
80648222 {
80658223 String texname = tex;
80668224
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;
8225
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8226
+
8227
+// String[] split = tex.split("Textures");
8228
+// if (split.length > 1)
8229
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8230
+// else
8231
+// if (!texname.startsWith("/"))
8232
+// texname = "/Users/nbriere/Textures/" + texname;
8233
+ if (!FileExists(tex))
8234
+ {
8235
+ texname = fallbackTextureName;
8236
+ }
80738237
80748238 if (CACHETEXTURE)
80758239 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8138,7 +8302,7 @@
81388302 }
81398303
81408304 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8305
+ if (!FileExists(cachename))
81428306 cachename = texname;
81438307 else
81448308 processbump = false; // don't process bump map again
....@@ -8160,7 +8324,7 @@
81608324 }
81618325
81628326 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8327
+ if (!FileExists(cachename))
81648328 cachename = texname;
81658329 else
81668330 processbump = false; // don't process bump map again
....@@ -8169,7 +8333,9 @@
81698333 texturedata = GetFileTexture(cachename, processbump, resolution);
81708334
81718335
8172
- if (texturedata != null)
8336
+ if (texturedata == null)
8337
+ throw new Exception();
8338
+
81738339 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81748340 //texture = GetTexture(tex, bump);
81758341 }
....@@ -8291,7 +8457,7 @@
82918457 return texture;
82928458 }
82938459
8294
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8460
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
82958461 {
82968462 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
82978463
....@@ -8309,14 +8475,14 @@
83098475 return texture!=null?texture.texture:null;
83108476 }
83118477
8312
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8478
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83138479 {
83148480 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83158481
83168482 return texture!=null?texture.texturedata:null;
83178483 }
83188484
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8485
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83208486 {
83218487 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228488 {
....@@ -9293,8 +9459,8 @@
92939459 assert (parentcam != renderCamera);
92949460
92959461 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9462
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9463
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
92989464
92999465 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009466
....@@ -9309,8 +9475,8 @@
93099475 LA.matCopy(renderCamera.fromScreen, matrix);
93109476
93119477 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9478
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9479
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93149480
93159481 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169482
....@@ -9382,7 +9548,7 @@
93829548 //gl.glFlush();
93839549 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849550
9385
- if (ANIMATION && ABORTED)
9551
+ if (Globals.ANIMATION && ABORTED)
93869552 {
93879553 System.err.println(" ABORTED FRAME");
93889554 break;
....@@ -9412,7 +9578,7 @@
94129578 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139579
94149580 // save image
9415
- if (ANIMATION && !ABORTED)
9581
+ if (Globals.ANIMATION && !ABORTED)
94169582 {
94179583 VPwidth = viewport[2];
94189584 VPheight = viewport[3];
....@@ -9523,11 +9689,11 @@
95239689
95249690 // imagecount++;
95259691
9526
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9692
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95279693
95289694 if (!BOXMODE)
95299695 {
9530
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9696
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95319697 }
95329698
95339699 if (!BOXMODE)
....@@ -9565,7 +9731,7 @@
95659731 ABORTED = false;
95669732 }
95679733 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9734
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699735
95709736 if (false)
95719737 {
....@@ -10228,11 +10394,11 @@
1022810394
1022910395 public void display(GLAutoDrawable drawable)
1023010396 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10397
+ if (Grafreed.savesound && Grafreed.hassound)
1023210398 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10399
+ Grafreed.wav.save();
10400
+ Grafreed.savesound = false;
10401
+ Grafreed.hassound = false;
1023610402 }
1023710403 // if (DEBUG_SELECTION)
1023810404 // {
....@@ -10362,7 +10528,7 @@
1036210528 Object3D theobject = object;
1036310529 Object3D theparent = object.parent;
1036410530 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10531
+ object = (Object3D)Grafreed.clone(object);
1036610532 object.Stripify();
1036710533 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810534 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10541,13 @@
1037510541 ambientOcclusion = false;
1037610542 }
1037710543
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10544
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910545 {
1038010546 //if (RENDERSHADOW) // ?
1038110547 if (!IsFrozen())
1038210548 {
1038310549 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10550
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510551 {
1038610552 Globals.framecount++;
1038710553 shadowbuffer.display();
....@@ -10508,8 +10674,8 @@
1050810674
1050910675 // if (parentcam != renderCamera) // not a light
1051010676 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10677
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10678
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1051310679
1051410680 for (int j = 0; j < 4; j++)
1051510681 {
....@@ -10523,8 +10689,8 @@
1052310689
1052410690 // if (parentcam != renderCamera) // not a light
1052510691 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10692
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10693
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1052810694
1052910695 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010696
....@@ -10783,7 +10949,16 @@
1078310949 // Bump noise
1078410950 gl.glActiveTexture(GL.GL_TEXTURE6);
1078510951 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- BindTexture(NOISE_TEXTURE, false, 2);
10952
+
10953
+ try
10954
+ {
10955
+ BindTexture(NOISE_TEXTURE, false, 2);
10956
+ }
10957
+ catch (Exception e)
10958
+ {
10959
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10960
+ }
10961
+
1078710962
1078810963 gl.glActiveTexture(GL.GL_TEXTURE0);
1078910964 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10908,8 +11083,8 @@
1090811083 System.err.println("parentcam != renderCamera");
1090911084
1091011085 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11086
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11087
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1091311088 }
1091411089
1091511090 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +11105,8 @@
1093011105 if (true) // TODO
1093111106 {
1093211107 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11108
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11109
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1093511110 }
1093611111
1093711112 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11247,8 +11422,14 @@
1124711422 {
1124811423 renderpass++;
1124911424 // System.out.println("Draw object... ");
11425
+ STEP = 1;
1125011426 if (FAST) // in case there is no script
11251
- STEP = 16;
11427
+ STEP = 8;
11428
+
11429
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11430
+ {
11431
+ STEP *= 4;
11432
+ }
1125211433
1125311434 //object.FullInvariants();
1125411435
....@@ -11262,8 +11443,8 @@
1126211443 e.printStackTrace();
1126311444 }
1126411445
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11446
+ if (Grafreed.RENDERME > 0)
11447
+ Grafreed.RENDERME--; // mechante magouille
1126711448
1126811449 Globals.ONESTEP = false;
1126911450 }
....@@ -11333,7 +11514,14 @@
1133311514
1133411515 usedtextures.clear();
1133511516
11336
- BindTextures(DEFAULT_TEXTURES, 2);
11517
+ try
11518
+ {
11519
+ BindTextures(DEFAULT_TEXTURES, 2);
11520
+ }
11521
+ catch (Exception e)
11522
+ {
11523
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11524
+ }
1133711525 }
1133811526 //System.out.println("--> " + stackdepth);
1133911527 // GrafreeD.traceon();
....@@ -11424,7 +11612,14 @@
1142411612 if (checker != null && DrawMode() == DEFAULT)
1142511613 {
1142611614 //BindTexture(IMMORTAL_TEXTURE);
11427
- BindTextures(checker.GetTextures(), checker.texres);
11615
+ try
11616
+ {
11617
+ BindTextures(checker.GetTextures(), checker.texres);
11618
+ }
11619
+ catch (Exception e)
11620
+ {
11621
+ System.err.println("FAILED: " + checker.GetTextures());
11622
+ }
1142811623 // NEAREST
1142911624 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011625 DrawChecker(gl);
....@@ -11506,7 +11701,7 @@
1150611701 return;
1150711702 }
1150811703
11509
- String string = obj.GetToolTip();
11704
+ String string = obj.toString(); //.GetToolTip();
1151011705
1151111706 GL gl = GetGL();
1151211707
....@@ -11823,8 +12018,8 @@
1182312018 //obj.TransformToWorld(light, light);
1182412019 for (int i = tp.size(); --i >= 0;)
1182512020 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- LA.xformPos(light, tp.get(i).toParent, light);
12021
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12022
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1182812023 }
1182912024
1183012025
....@@ -11841,8 +12036,8 @@
1184112036 parentcam = cameras[0];
1184212037 }
1184312038
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12039
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12040
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1184612041
1184712042 LA.xformPos(light, renderCamera.toScreen, light);
1184812043
....@@ -12456,8 +12651,8 @@
1245612651
1245712652 // display shadow only (bump == 0)
1245812653 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12654
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12655
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112656 "SUB temp.y, one.x, temp.z;" +
1246212657 "MUL temp.x, temp.x, temp.y;" +
1246312658 "KIL temp.x;" +
....@@ -12586,8 +12781,10 @@
1258612781 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258712782
1258812783 "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
12784
+ // Tuning for default skin
12785
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12786
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12787
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1259112788 "MUL temp.x, temp.x, temp.y;" +
1259212789
1259312790 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +12983,7 @@
1278612983 //once = true;
1278712984 }
1278812985
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
12986
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279012987 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279112988 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279212989
....@@ -12919,12 +13116,16 @@
1291913116
1292013117 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292113118 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13119
+
13120
+ // Compare fragment depth in light space with shadowmap.
1292213121 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292313122 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
13123
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13124
+
13125
+ // Reverse comparison
1292513126 "SUB temp.x, one.x, temp.x;" +
1292613127 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13128
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813129 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913130
1293013131 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13139,10 @@
1293813139 // No shadow for backface
1293913140 "DP3 temp.x, normal, lightd;" +
1294013141 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13142
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13143
+
13144
+ // No shadow when out of frustrum
13145
+ "SGE temp.x, " + depth + ".z, one.z;" +
1294113146 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213147 "";
1294313148 }
....@@ -13496,7 +13701,7 @@
1349613701 public void mousePressed(MouseEvent e)
1349713702 {
1349813703 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13704
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350013705 }
1350113706
1350213707 static long prevtime = 0;
....@@ -13523,6 +13728,7 @@
1352313728
1352413729 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513730
13731
+ if (BUTTONLESSWHEEL)
1352613732 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713733 {
1352813734 return;
....@@ -13531,7 +13737,7 @@
1353113737 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213738
1353313739 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13740
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513741 {
1353613742 keepboxmode = BOXMODE;
1353713743 keepsupport = SUPPORT;
....@@ -13571,8 +13777,8 @@
1357113777 // mode |= META;
1357213778 //}
1357313779
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13780
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13781
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357613782 anchorX = ax;
1357713783 anchorY = ay;
1357813784 prevX = px;
....@@ -13632,6 +13838,10 @@
1363213838 // wasliveok = true;
1363313839 // waslive = false;
1363413840
13841
+ // May 2019 Forget it:
13842
+ if (true)
13843
+ return;
13844
+
1363513845 // source == timer
1363613846 if (mouseDown)
1363713847 {
....@@ -13670,7 +13880,7 @@
1367013880
1367113881 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367213882
13673
- void clickStart(int x, int y, int modifiers)
13883
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367413884 {
1367513885 if (!wasliveok)
1367613886 return;
....@@ -13687,7 +13897,7 @@
1368713897 // touched = true; // main DL
1368813898 if (isRenderer)
1368913899 {
13690
- SetMouseMode(modifiers);
13900
+ SetMouseMode(modifiers, modifiersex);
1369113901 }
1369213902
1369313903 selectX = anchorX = x;
....@@ -13700,7 +13910,7 @@
1370013910 clicked = true;
1370113911 hold = false;
1370213912
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13913
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370413914 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370513915 {
1370613916 // System.out.println("RESTART II " + modifiers);
....@@ -13731,7 +13941,7 @@
1373113941 info.camera = renderCamera;
1373213942 info.x = x;
1373313943 info.y = y;
13734
- info.modifiers = modifiers;
13944
+ info.modifiers = modifiersex;
1373513945 editObj = object.doEditClick(info, 0);
1373613946 if (!editObj)
1373713947 {
....@@ -13748,11 +13958,14 @@
1374813958
1374913959 public void mouseDragged(MouseEvent e)
1375013960 {
13961
+ Globals.MOUSEDRAGGED = true;
13962
+
13963
+ //System.out.println("mouseDragged: " + e);
1375113964 if (isRenderer)
1375213965 movingcamera = true;
13966
+
1375313967 //if (drawing)
1375413968 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375613969 if ((e.getModifiersEx() & CTRL) != 0
1375713970 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375813971 {
....@@ -13760,7 +13973,7 @@
1376013973 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376113974 }
1376213975 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
13976
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376413977
1376513978 //try { Thread.sleep(1); } catch (Exception ex) {}
1376613979 }
....@@ -13933,6 +14146,7 @@
1393314146
1393414147 public void run()
1393514148 {
14149
+ new Exception().printStackTrace();
1393614150 System.exit(0);
1393714151 for (;;)
1393814152 {
....@@ -13996,7 +14210,7 @@
1399614210 {
1399714211 Globals.lighttouched = true;
1399814212 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14213
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014214 }
1400114215 //else
1400214216 }
....@@ -14096,7 +14310,7 @@
1409614310 int X, Y;
1409714311 boolean SX, SY;
1409814312
14099
- void drag(int x, int y, int modifiers)
14313
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014314 {
1410114315 if (IsFrozen())
1410214316 {
....@@ -14105,17 +14319,17 @@
1410514319
1410614320 drag = true; // NEW
1410714321
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14322
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914323
1411014324 X = x;
1411114325 Y = y;
1411214326 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14327
+ MODIFIERS = modifiersex;
14328
+ modifiersex &= ~1024;
1411514329 if (false) // modifiers != 0)
1411614330 {
1411714331 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14332
+ System.out.println("mouseDragged: " + modifiersex);
1411914333 System.out.println("SHIFT = " + SHIFT);
1412014334 System.out.println("CONTROL = " + COMMAND);
1412114335 System.out.println("META = " + META);
....@@ -14135,7 +14349,7 @@
1413514349 info.camera = renderCamera;
1413614350 info.x = x;
1413714351 info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14352
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914353 } else
1414014354 {
1414114355 if (x < startX)
....@@ -14287,7 +14501,6 @@
1428714501 public void mouseMoved(MouseEvent e)
1428814502 {
1428914503 //System.out.println("mouseMoved: " + e);
14290
-
1429114504 if (isRenderer)
1429214505 return;
1429314506
....@@ -14312,7 +14525,10 @@
1431214525
1431314526 public void mouseReleased(MouseEvent e)
1431414527 {
14528
+ Globals.MOUSEDRAGGED = false;
14529
+
1431514530 movingcamera = false;
14531
+ X = Y = 0;
1431614532 //System.out.println("mouseReleased: " + e);
1431714533 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814534 }
....@@ -14335,9 +14551,9 @@
1433514551 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614552 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714553
14338
- if (control || command || IsFrozen())
14554
+// No delay if (control || command || IsFrozen())
1433914555 timeout = true;
14340
- else
14556
+// ?? May 2019 else
1434114557 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214558 mouseDown = false;
1434314559 if (!control && !command) // june 2013
....@@ -14447,7 +14663,7 @@
1444714663 System.out.println("keyReleased: " + e);
1444814664 }
1444914665
14450
- void SetMouseMode(int modifiers)
14666
+ void SetMouseMode(int modifiers, int modifiersex)
1445114667 {
1445214668 //System.out.println("SetMouseMode = " + modifiers);
1445314669 //modifiers &= ~1024;
....@@ -14459,25 +14675,25 @@
1445914675 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446014676 // return;
1446114677 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
14678
+ if ((modifiersex & WHEEL) == WHEEL)
1446314679 {
1446414680 mouseMode |= ZOOM;
1446514681 }
1446614682
1446714683 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
14684
+ if (capsLocked) // || (modifiers & META) == META)
1446914685 {
1447014686 mouseMode |= VR; // BACKFORTH;
1447114687 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14688
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447314689 {
1447414690 mouseMode |= SELECT;
1447514691 }
14476
- if ((modifiers & COMMAND) == COMMAND)
14692
+ if ((modifiersex & COMMAND) == COMMAND)
1447714693 {
1447814694 mouseMode |= SELECT;
1447914695 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14696
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448114697 {
1448214698 mouseMode &= ~VR;
1448314699 mouseMode |= TRANSLATE;
....@@ -14506,7 +14722,7 @@
1450614722
1450714723 if (isRenderer) //
1450814724 {
14509
- SetMouseMode(modifiers);
14725
+ SetMouseMode(0, modifiers);
1451014726 }
1451114727
1451214728 Globals.theRenderer.keyPressed(key);
....@@ -14842,7 +15058,7 @@
1484215058 //RESIZETEXTURE ^= true;
1484315059 //break;
1484415060 case 'z':
14845
- RENDERSHADOW ^= true;
15061
+ Globals.RENDERSHADOW ^= true;
1484615062 Globals.lighttouched = true;
1484715063 repaint();
1484815064 break;
....@@ -14966,7 +15182,7 @@
1496615182 //mode = ROTATE;
1496715183 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815184 {
14969
- SetMouseMode(modifiers);
15185
+ SetMouseMode(0, modifiers);
1497015186 }
1497115187 }
1497215188
....@@ -15100,8 +15316,9 @@
1510015316
1510115317 protected void processMouseMotionEvent(MouseEvent e)
1510215318 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15319
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15320
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15321
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515322 {
1510615323 mouseMoved(e);
1510715324 } else
....@@ -15131,6 +15348,7 @@
1513115348
1513215349 void SelectParent()
1513315350 {
15351
+ new Exception().printStackTrace();
1513415352 System.exit(0);
1513515353 Composite group = (Composite) object;
1513615354 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15154,6 +15372,7 @@
1515415372
1515515373 void SelectChildren()
1515615374 {
15375
+ new Exception().printStackTrace();
1515715376 System.exit(0);
1515815377 /*
1515915378 Composite group = (Composite) object;
....@@ -15318,7 +15537,9 @@
1531815537 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915538 //Image img = CreateImage(width, height);
1532015539 //System.out.println("width = " + width + "; height = " + height + "\n");
15540
+
1532115541 Graphics gr = g; // img.getGraphics();
15542
+
1532215543 if (!hasMarquee)
1532315544 {
1532415545 if (Xmin < Xmax) // !locked)
....@@ -15416,14 +15637,33 @@
1541615637 if (!isRenderer)
1541715638 {
1541815639 object.drawEditHandles(info, 0);
15640
+
15641
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15642
+ {
15643
+ switch (object.selection.get(0).hitSomething)
15644
+ {
15645
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15646
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15647
+ break;
15648
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15649
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15650
+ break;
15651
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15652
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15653
+ break;
15654
+ }
15655
+
15656
+ }
1541915657 }
1542015658 }
15659
+
1542115660 if (isRenderer)
1542215661 {
1542315662 //gr.setColor(Color.black);
1542415663 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542515664 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542615665 }
15666
+
1542715667 if (hasMarquee)
1542815668 {
1542915669 gr.setXORMode(Color.white);
....@@ -15536,6 +15776,7 @@
1553615776 public boolean mouseDown(Event evt, int x, int y)
1553715777 {
1553815778 System.out.println("mouseDown: " + evt);
15779
+ System.exit(0);
1553915780 /*
1554015781 locked = true;
1554115782 drag = false;
....@@ -15579,7 +15820,7 @@
1557915820 {
1558015821 keyPressed(0, modifiers);
1558115822 }
15582
- clickStart(x, y, modifiers);
15823
+ // clickStart(x, y, modifiers);
1558315824 return true;
1558415825 }
1558515826
....@@ -15697,7 +15938,7 @@
1569715938 {
1569815939 keyReleased(0, 0);
1569915940 }
15700
- drag(x, y, modifiers);
15941
+ drag(x, y, 0, modifiers);
1570115942 return true;
1570215943 }
1570315944
....@@ -15829,7 +16070,7 @@
1582916070 Object3D object;
1583016071 static Object3D trackedobject;
1583116072 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
16073
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583316074 /*static*/ Camera eyeCamera;
1583416075 /*static*/ Camera lightCamera;
1583516076 int cameracount;
....@@ -16267,6 +16508,7 @@
1626716508 {
1626816509 if (!selection)
1626916510 {
16511
+ new Exception().printStackTrace();
1627016512 System.exit(0);
1627116513 return;
1627216514 }
....@@ -16394,16 +16636,16 @@
1639416636 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]));
1639516637 }
1639616638
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16639
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639816640 }
1639916641 }
1640016642
1640116643 if (!movingcamera && !PAINTMODE)
1640216644 object.editWindow.ScreenFitPoint(); // fev 2014
1640316645
16404
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16646
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1640516647 {
16406
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16648
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1640716649
1640816650 Object3D group = new Object3D("inst" + paintcount++);
1640916651
....@@ -16559,7 +16801,7 @@
1655916801 gl.glDisable(gl.GL_CULL_FACE);
1656016802 }
1656116803
16562
- if (!RENDERSHADOW)
16804
+ if (!Globals.RENDERSHADOW)
1656316805 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656416806
1656516807 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +16811,7 @@
1656916811 //gl.glColorMask(false, false, false, false);
1657016812
1657116813 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16814
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657316815 {
1657416816 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657516817