Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
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,10 +464,12 @@
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)
468
+ // TEST LIVE NORMALS && !obj.dontselect
469
+ ;
466470 if (!hasnorm)
467471 {
468
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
469473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1194,12 @@
11901194 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911195 }
11921196 }
1197
+
11931198 if (flipV)
11941199 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951200 else
11961201 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
11971203 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981204 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991205
....@@ -1213,10 +1219,12 @@
12131219 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141220 }
12151221 }
1222
+
12161223 if (flipV)
12171224 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181225 else
12191226 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
12201228 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211229 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221230
....@@ -1244,8 +1252,10 @@
12441252 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451253 else
12461254 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
12471256 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481257 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
12491259 count2 += 2;
12501260 count3 += 3;
12511261 }
....@@ -1628,7 +1638,7 @@
16281638
16291639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301640
1631
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
16321642
16331643 /**/
16341644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1888,7 +1898,7 @@
18881898 void PushMatrix(double[][] matrix)
18891899 {
18901900 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
18921902 }
18931903
18941904 void PushMatrix()
....@@ -2140,7 +2150,7 @@
21402150 System.err.println("LIVE = " + Globals.isLIVE());
21412151
21422152 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2153
+ Grafreed.savesound = true; // wav.save();
21442154 // else
21452155 repaint(); // start loop // may 2013
21462156 }
....@@ -2265,9 +2275,9 @@
22652275 LOOKAT ^= true;
22662276 }
22672277
2268
- void ToggleRandom()
2278
+ void ToggleSwitch()
22692279 {
2270
- RANDOM ^= true;
2280
+ SWITCH ^= true;
22712281 }
22722282
22732283 void ToggleHandles()
....@@ -2374,7 +2384,7 @@
23742384 {
23752385 return currentGL;
23762386 }
2377
-
2387
+
23782388 /**/
23792389 class CacheTexture
23802390 {
....@@ -7919,6 +7929,64 @@
79197929 ReleaseTexture(pigment, false);
79207930 }
79217931
7932
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7933
+ {
7934
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7935
+ {
7936
+ return;
7937
+ }
7938
+
7939
+ if (tex == null)
7940
+ {
7941
+ ReleaseTexture(null, false);
7942
+ return;
7943
+ }
7944
+
7945
+ String pigment = Object3D.GetPigment(tex);
7946
+
7947
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7948
+ {
7949
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7950
+ // System.out.println("; bump = " + bump);
7951
+ }
7952
+
7953
+ if (pigment.equals(""))
7954
+ {
7955
+ pigment = null;
7956
+ }
7957
+
7958
+ ReleaseTexture(pigment, false);
7959
+ }
7960
+
7961
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7962
+ {
7963
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7964
+ {
7965
+ return;
7966
+ }
7967
+
7968
+ if (tex == null)
7969
+ {
7970
+ ReleaseTexture(null, true);
7971
+ return;
7972
+ }
7973
+
7974
+ String bump = Object3D.GetBump(tex);
7975
+
7976
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7977
+ {
7978
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7979
+ // System.out.println("; bump = " + bump);
7980
+ }
7981
+
7982
+ if (bump.equals(""))
7983
+ {
7984
+ bump = null;
7985
+ }
7986
+
7987
+ ReleaseTexture(bump, true);
7988
+ }
7989
+
79227990 void ReleaseTexture(String tex, boolean bump)
79237991 {
79247992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8090,7 @@
80228090 }
80238091 }
80248092
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268094 {
80278095 if (// DrawMode() != 0 || /*tex == null ||*/
80288096 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8135,94 @@
80678135 return; // true;
80688136 }
80698137
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8138
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8139
+ {
8140
+ if (// DrawMode() != 0 || /*tex == null ||*/
8141
+ ambientOcclusion ) // || !textureon)
8142
+ {
8143
+ return; // false;
8144
+ }
8145
+
8146
+ if (tex == null)
8147
+ {
8148
+ BindTexture(null,false,resolution);
8149
+ return;
8150
+ }
8151
+
8152
+ String pigment = Object3D.GetPigment(tex);
8153
+
8154
+ usedtextures.put(pigment, pigment);
8155
+
8156
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8157
+ {
8158
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8159
+ // System.out.println("; bump = " + bump);
8160
+ }
8161
+
8162
+ if (pigment.equals(""))
8163
+ {
8164
+ pigment = null;
8165
+ }
8166
+
8167
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8168
+ BindTexture(pigment, false, resolution);
8169
+ }
8170
+
8171
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8172
+ {
8173
+ if (// DrawMode() != 0 || /*tex == null ||*/
8174
+ ambientOcclusion ) // || !textureon)
8175
+ {
8176
+ return; // false;
8177
+ }
8178
+
8179
+ if (tex == null)
8180
+ {
8181
+ BindTexture(null,true,resolution);
8182
+ return;
8183
+ }
8184
+
8185
+ String bump = Object3D.GetBump(tex);
8186
+
8187
+ usedtextures.put(bump, bump);
8188
+
8189
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8190
+ {
8191
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8192
+ // System.out.println("; bump = " + bump);
8193
+ }
8194
+
8195
+ if (bump.equals(""))
8196
+ {
8197
+ bump = null;
8198
+ }
8199
+
8200
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8201
+ BindTexture(bump, true, resolution);
8202
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8203
+ }
8204
+
8205
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8206
+
8207
+ private boolean FileExists(String tex)
8208
+ {
8209
+ if (missingTextures.contains(tex))
8210
+ {
8211
+ return false;
8212
+ }
8213
+
8214
+ boolean fileExists = new File(tex).exists();
8215
+
8216
+ if (!fileExists)
8217
+ {
8218
+ // If file exists, the "new File()" is not executed sgain
8219
+ missingTextures.add(tex);
8220
+ }
8221
+
8222
+ return fileExists;
8223
+ }
8224
+
8225
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718226 {
80728227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738228
....@@ -8075,12 +8230,18 @@
80758230 {
80768231 String texname = tex;
80778232
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;
8233
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8234
+
8235
+// String[] split = tex.split("Textures");
8236
+// if (split.length > 1)
8237
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8238
+// else
8239
+// if (!texname.startsWith("/"))
8240
+// texname = "/Users/nbriere/Textures/" + texname;
8241
+ if (!FileExists(tex))
8242
+ {
8243
+ texname = fallbackTextureName;
8244
+ }
80848245
80858246 if (CACHETEXTURE)
80868247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8149,7 +8310,7 @@
81498310 }
81508311
81518312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
81538314 cachename = texname;
81548315 else
81558316 processbump = false; // don't process bump map again
....@@ -8171,7 +8332,7 @@
81718332 }
81728333
81738334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
81758336 cachename = texname;
81768337 else
81778338 processbump = false; // don't process bump map again
....@@ -8180,7 +8341,9 @@
81808341 texturedata = GetFileTexture(cachename, processbump, resolution);
81818342
81828343
8183
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
81848347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81858348 //texture = GetTexture(tex, bump);
81868349 }
....@@ -8302,7 +8465,7 @@
83028465 return texture;
83038466 }
83048467
8305
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8468
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83068469 {
83078470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83088471
....@@ -8320,14 +8483,14 @@
83208483 return texture!=null?texture.texture:null;
83218484 }
83228485
8323
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8486
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83248487 {
83258488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83268489
83278490 return texture!=null?texture.texturedata:null;
83288491 }
83298492
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83318494 {
83328495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338496 {
....@@ -9304,8 +9467,8 @@
93049467 assert (parentcam != renderCamera);
93059468
93069469 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099472
93109473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119474
....@@ -9320,8 +9483,8 @@
93209483 LA.matCopy(renderCamera.fromScreen, matrix);
93219484
93229485 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259488
93269489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279490
....@@ -9538,7 +9701,7 @@
95389701
95399702 if (!BOXMODE)
95409703 {
9541
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9704
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95429705 }
95439706
95449707 if (!BOXMODE)
....@@ -9576,7 +9739,7 @@
95769739 ABORTED = false;
95779740 }
95789741 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809743
95819744 if (false)
95829745 {
....@@ -10239,11 +10402,11 @@
1023910402
1024010403 public void display(GLAutoDrawable drawable)
1024110404 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
1024310406 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
1024710410 }
1024810411 // if (DEBUG_SELECTION)
1024910412 // {
....@@ -10373,7 +10536,7 @@
1037310536 Object3D theobject = object;
1037410537 Object3D theparent = object.parent;
1037510538 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1037710540 object.Stripify();
1037810541 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910542 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10549,13 @@
1038610549 ambientOcclusion = false;
1038710550 }
1038810551
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010553 {
1039110554 //if (RENDERSHADOW) // ?
1039210555 if (!IsFrozen())
1039310556 {
1039410557 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610559 {
1039710560 Globals.framecount++;
1039810561 shadowbuffer.display();
....@@ -10519,8 +10682,8 @@
1051910682
1052010683 // if (parentcam != renderCamera) // not a light
1052110684 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410687
1052510688 for (int j = 0; j < 4; j++)
1052610689 {
....@@ -10534,8 +10697,8 @@
1053410697
1053510698 // if (parentcam != renderCamera) // not a light
1053610699 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910702
1054010703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110704
....@@ -10794,7 +10957,16 @@
1079410957 // Bump noise
1079510958 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- BindTexture(NOISE_TEXTURE, false, 2);
10960
+
10961
+ try
10962
+ {
10963
+ BindTexture(NOISE_TEXTURE, false, 2);
10964
+ }
10965
+ catch (Exception e)
10966
+ {
10967
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10968
+ }
10969
+
1079810970
1079910971 gl.glActiveTexture(GL.GL_TEXTURE0);
1080010972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +11091,8 @@
1091911091 System.err.println("parentcam != renderCamera");
1092011092
1092111093 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11094
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11095
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092411096 }
1092511097
1092611098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11113,8 @@
1094111113 if (true) // TODO
1094211114 {
1094311115 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11116
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11117
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094611118 }
1094711119
1094811120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,8 +11451,8 @@
1127911451 e.printStackTrace();
1128011452 }
1128111453
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1128411456
1128511457 Globals.ONESTEP = false;
1128611458 }
....@@ -11350,7 +11522,14 @@
1135011522
1135111523 usedtextures.clear();
1135211524
11353
- BindTextures(DEFAULT_TEXTURES, 2);
11525
+ try
11526
+ {
11527
+ BindTextures(DEFAULT_TEXTURES, 2);
11528
+ }
11529
+ catch (Exception e)
11530
+ {
11531
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11532
+ }
1135411533 }
1135511534 //System.out.println("--> " + stackdepth);
1135611535 // GrafreeD.traceon();
....@@ -11441,7 +11620,14 @@
1144111620 if (checker != null && DrawMode() == DEFAULT)
1144211621 {
1144311622 //BindTexture(IMMORTAL_TEXTURE);
11444
- BindTextures(checker.GetTextures(), checker.texres);
11623
+ try
11624
+ {
11625
+ BindTextures(checker.GetTextures(), checker.texres);
11626
+ }
11627
+ catch (Exception e)
11628
+ {
11629
+ System.err.println("FAILED: " + checker.GetTextures());
11630
+ }
1144511631 // NEAREST
1144611632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711633 DrawChecker(gl);
....@@ -11523,7 +11709,7 @@
1152311709 return;
1152411710 }
1152511711
11526
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1152711713
1152811714 GL gl = GetGL();
1152911715
....@@ -11840,8 +12026,8 @@
1184012026 //obj.TransformToWorld(light, light);
1184112027 for (int i = tp.size(); --i >= 0;)
1184212028 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- LA.xformPos(light, tp.get(i).toParent, light);
12029
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12030
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1184512031 }
1184612032
1184712033
....@@ -11858,8 +12044,8 @@
1185812044 parentcam = cameras[0];
1185912045 }
1186012046
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12047
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12048
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186312049
1186412050 LA.xformPos(light, renderCamera.toScreen, light);
1186512051
....@@ -12473,8 +12659,8 @@
1247312659
1247412660 // display shadow only (bump == 0)
1247512661 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812664 "SUB temp.y, one.x, temp.z;" +
1247912665 "MUL temp.x, temp.x, temp.y;" +
1248012666 "KIL temp.x;" +
....@@ -12754,7 +12940,7 @@
1275412940 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275512941 "FLR final.x, final.y;" +
1275612942 "SUB final.y, final.y, final.x;" +
12757
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1275812944 "MOV final.z, zero.x;" +
1275912945 "MOV final.a, one.w;":""
1276012946 ) +
....@@ -12762,7 +12948,7 @@
1276212948 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276312949 "FLR final.x, final.y;" +
1276412950 "SUB final.y, final.y, final.x;" +
12765
- //"MUL final.x, final.x, c256i;" +
12951
+ "MUL final.x, final.x, c256i;" +
1276612952 "MOV final.z, zero.x;" +
1276712953 "MOV final.a, one.w;":""
1276812954 ) +
....@@ -12805,7 +12991,7 @@
1280512991 //once = true;
1280612992 }
1280712993
12808
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280912995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281012996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281112997
....@@ -12938,12 +13124,16 @@
1293813124
1293913125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294013126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1294113129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294213130 "SGE temp.y, temp.x, zero.x;" +
12943
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1294413134 "SUB temp.x, one.x, temp.x;" +
1294513135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12946
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294713137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294813138
1294913139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12957,6 +13147,10 @@
1295713147 // No shadow for backface
1295813148 "DP3 temp.x, normal, lightd;" +
1295913149 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13150
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13151
+
13152
+ // No shadow when out of frustrum
13153
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296013154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296113155 "";
1296213156 }
....@@ -13515,7 +13709,7 @@
1351513709 public void mousePressed(MouseEvent e)
1351613710 {
1351713711 //System.out.println("mousePressed: " + e);
13518
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351913713 }
1352013714
1352113715 static long prevtime = 0;
....@@ -13591,8 +13785,8 @@
1359113785 // mode |= META;
1359213786 //}
1359313787
13594
- SetMouseMode(WHEEL | e.getModifiersEx());
13595
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359613790 anchorX = ax;
1359713791 anchorY = ay;
1359813792 prevX = px;
....@@ -13652,6 +13846,10 @@
1365213846 // wasliveok = true;
1365313847 // waslive = false;
1365413848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1365513853 // source == timer
1365613854 if (mouseDown)
1365713855 {
....@@ -13690,7 +13888,7 @@
1369013888
1369113889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369213890
13693
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369413892 {
1369513893 if (!wasliveok)
1369613894 return;
....@@ -13707,7 +13905,7 @@
1370713905 // touched = true; // main DL
1370813906 if (isRenderer)
1370913907 {
13710
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1371113909 }
1371213910
1371313911 selectX = anchorX = x;
....@@ -13720,7 +13918,7 @@
1372013918 clicked = true;
1372113919 hold = false;
1372213920
13723
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372413922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372513923 {
1372613924 // System.out.println("RESTART II " + modifiers);
....@@ -13751,7 +13949,7 @@
1375113949 info.camera = renderCamera;
1375213950 info.x = x;
1375313951 info.y = y;
13754
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1375513953 editObj = object.doEditClick(info, 0);
1375613954 if (!editObj)
1375713955 {
....@@ -13768,9 +13966,12 @@
1376813966
1376913967 public void mouseDragged(MouseEvent e)
1377013968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
1377113971 //System.out.println("mouseDragged: " + e);
1377213972 if (isRenderer)
1377313973 movingcamera = true;
13974
+
1377413975 //if (drawing)
1377513976 //return;
1377613977 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13780,7 +13981,7 @@
1378013981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378113982 }
1378213983 else
13783
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378413985
1378513986 //try { Thread.sleep(1); } catch (Exception ex) {}
1378613987 }
....@@ -14017,7 +14218,7 @@
1401714218 {
1401814219 Globals.lighttouched = true;
1401914220 }
14020
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402114222 }
1402214223 //else
1402314224 }
....@@ -14117,7 +14318,7 @@
1411714318 int X, Y;
1411814319 boolean SX, SY;
1411914320
14120
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1412114322 {
1412214323 if (IsFrozen())
1412314324 {
....@@ -14126,17 +14327,17 @@
1412614327
1412714328 drag = true; // NEW
1412814329
14129
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413014331
1413114332 X = x;
1413214333 Y = y;
1413314334 // floating state for animation
14134
- MODIFIERS = modifiers;
14135
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1413614337 if (false) // modifiers != 0)
1413714338 {
1413814339 //new Exception().printStackTrace();
14139
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1414014341 System.out.println("SHIFT = " + SHIFT);
1414114342 System.out.println("CONTROL = " + COMMAND);
1414214343 System.out.println("META = " + META);
....@@ -14156,7 +14357,7 @@
1415614357 info.camera = renderCamera;
1415714358 info.x = x;
1415814359 info.y = y;
14159
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416014361 } else
1416114362 {
1416214363 if (x < startX)
....@@ -14332,7 +14533,10 @@
1433214533
1433314534 public void mouseReleased(MouseEvent e)
1433414535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1433514538 movingcamera = false;
14539
+ X = Y = 0;
1433614540 //System.out.println("mouseReleased: " + e);
1433714541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433814542 }
....@@ -14355,9 +14559,9 @@
1435514559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435614560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435714561
14358
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1435914563 timeout = true;
14360
- else
14564
+// ?? May 2019 else
1436114565 // timer.setDelay((modifiers & 128) != 0?0:350);
1436214566 mouseDown = false;
1436314567 if (!control && !command) // june 2013
....@@ -14467,7 +14671,7 @@
1446714671 System.out.println("keyReleased: " + e);
1446814672 }
1446914673
14470
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1447114675 {
1447214676 //System.out.println("SetMouseMode = " + modifiers);
1447314677 //modifiers &= ~1024;
....@@ -14479,25 +14683,25 @@
1447914683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448014684 // return;
1448114685 //System.out.println("SetMode = " + modifiers);
14482
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1448314687 {
1448414688 mouseMode |= ZOOM;
1448514689 }
1448614690
1448714691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14488
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1448914693 {
1449014694 mouseMode |= VR; // BACKFORTH;
1449114695 }
14492
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449314697 {
1449414698 mouseMode |= SELECT;
1449514699 }
14496
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1449714701 {
1449814702 mouseMode |= SELECT;
1449914703 }
14500
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450114705 {
1450214706 mouseMode &= ~VR;
1450314707 mouseMode |= TRANSLATE;
....@@ -14526,7 +14730,7 @@
1452614730
1452714731 if (isRenderer) //
1452814732 {
14529
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1453014734 }
1453114735
1453214736 Globals.theRenderer.keyPressed(key);
....@@ -14862,7 +15066,7 @@
1486215066 //RESIZETEXTURE ^= true;
1486315067 //break;
1486415068 case 'z':
14865
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1486615070 Globals.lighttouched = true;
1486715071 repaint();
1486815072 break;
....@@ -14986,7 +15190,7 @@
1498615190 //mode = ROTATE;
1498715191 if ((MODIFIERS & COMMAND) == 0) // VR??
1498815192 {
14989
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1499015194 }
1499115195 }
1499215196
....@@ -15122,7 +15326,7 @@
1512215326 {
1512315327 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512415328 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15125
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15329
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512615330 {
1512715331 mouseMoved(e);
1512815332 } else
....@@ -15341,7 +15545,9 @@
1534115545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534215546 //Image img = CreateImage(width, height);
1534315547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1534415549 Graphics gr = g; // img.getGraphics();
15550
+
1534515551 if (!hasMarquee)
1534615552 {
1534715553 if (Xmin < Xmax) // !locked)
....@@ -15439,14 +15645,33 @@
1543915645 if (!isRenderer)
1544015646 {
1544115647 object.drawEditHandles(info, 0);
15648
+
15649
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15650
+ {
15651
+ switch (object.selection.get(0).hitSomething)
15652
+ {
15653
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15654
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15655
+ break;
15656
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15657
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15658
+ break;
15659
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15660
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15661
+ break;
15662
+ }
15663
+
15664
+ }
1544215665 }
1544315666 }
15667
+
1544415668 if (isRenderer)
1544515669 {
1544615670 //gr.setColor(Color.black);
1544715671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544815672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544915673 }
15674
+
1545015675 if (hasMarquee)
1545115676 {
1545215677 gr.setXORMode(Color.white);
....@@ -15559,6 +15784,7 @@
1555915784 public boolean mouseDown(Event evt, int x, int y)
1556015785 {
1556115786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1556215788 /*
1556315789 locked = true;
1556415790 drag = false;
....@@ -15602,7 +15828,7 @@
1560215828 {
1560315829 keyPressed(0, modifiers);
1560415830 }
15605
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1560615832 return true;
1560715833 }
1560815834
....@@ -15720,7 +15946,7 @@
1572015946 {
1572115947 keyReleased(0, 0);
1572215948 }
15723
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1572415950 return true;
1572515951 }
1572615952
....@@ -15852,7 +16078,7 @@
1585216078 Object3D object;
1585316079 static Object3D trackedobject;
1585416080 Camera renderCamera; // Light or Eye (or Occlusion)
15855
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585616082 /*static*/ Camera eyeCamera;
1585716083 /*static*/ Camera lightCamera;
1585816084 int cameracount;
....@@ -16418,16 +16644,16 @@
1641816644 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]));
1641916645 }
1642016646
16421
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642216648 }
1642316649 }
1642416650
1642516651 if (!movingcamera && !PAINTMODE)
1642616652 object.editWindow.ScreenFitPoint(); // fev 2014
1642716653
16428
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16654
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642916655 {
16430
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16656
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643116657
1643216658 Object3D group = new Object3D("inst" + paintcount++);
1643316659
....@@ -16583,7 +16809,7 @@
1658316809 gl.glDisable(gl.GL_CULL_FACE);
1658416810 }
1658516811
16586
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1658716813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816814
1658916815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16593,7 +16819,7 @@
1659316819 //gl.glColorMask(false, false, false, false);
1659416820
1659516821 //render_scene_from_light_view(gl, drawable, 0, 0);
16596
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659716823 {
1659816824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659916825