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;" +
....@@ -12603,8 +12789,10 @@
1260312789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260412790
1260512791 "SUB temp.x, one.x, ndotl.x;" +
12606
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12607
- "ADD temp.y, one.y, options2.y;" + // sursurface
12792
+ // Tuning for default skin
12793
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12794
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12795
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260812796 "MUL temp.x, temp.x, temp.y;" +
1260912797
1261012798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12752,7 +12940,7 @@
1275212940 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275312941 "FLR final.x, final.y;" +
1275412942 "SUB final.y, final.y, final.x;" +
12755
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1275612944 "MOV final.z, zero.x;" +
1275712945 "MOV final.a, one.w;":""
1275812946 ) +
....@@ -12760,7 +12948,7 @@
1276012948 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276112949 "FLR final.x, final.y;" +
1276212950 "SUB final.y, final.y, final.x;" +
12763
- //"MUL final.x, final.x, c256i;" +
12951
+ "MUL final.x, final.x, c256i;" +
1276412952 "MOV final.z, zero.x;" +
1276512953 "MOV final.a, one.w;":""
1276612954 ) +
....@@ -12803,7 +12991,7 @@
1280312991 //once = true;
1280412992 }
1280512993
12806
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280712995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280812996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280912997
....@@ -12936,12 +13124,16 @@
1293613124
1293713125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293813126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1293913129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294013130 "SGE temp.y, temp.x, zero.x;" +
12941
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1294213134 "SUB temp.x, one.x, temp.x;" +
1294313135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12944
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294513137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294613138
1294713139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12955,6 +13147,10 @@
1295513147 // No shadow for backface
1295613148 "DP3 temp.x, normal, lightd;" +
1295713149 "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;" +
1295813154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295913155 "";
1296013156 }
....@@ -13513,7 +13709,7 @@
1351313709 public void mousePressed(MouseEvent e)
1351413710 {
1351513711 //System.out.println("mousePressed: " + e);
13516
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351713713 }
1351813714
1351913715 static long prevtime = 0;
....@@ -13589,8 +13785,8 @@
1358913785 // mode |= META;
1359013786 //}
1359113787
13592
- SetMouseMode(WHEEL | e.getModifiersEx());
13593
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359413790 anchorX = ax;
1359513791 anchorY = ay;
1359613792 prevX = px;
....@@ -13650,6 +13846,10 @@
1365013846 // wasliveok = true;
1365113847 // waslive = false;
1365213848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1365313853 // source == timer
1365413854 if (mouseDown)
1365513855 {
....@@ -13688,7 +13888,7 @@
1368813888
1368913889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369013890
13691
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369213892 {
1369313893 if (!wasliveok)
1369413894 return;
....@@ -13705,7 +13905,7 @@
1370513905 // touched = true; // main DL
1370613906 if (isRenderer)
1370713907 {
13708
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1370913909 }
1371013910
1371113911 selectX = anchorX = x;
....@@ -13718,7 +13918,7 @@
1371813918 clicked = true;
1371913919 hold = false;
1372013920
13721
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372213922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372313923 {
1372413924 // System.out.println("RESTART II " + modifiers);
....@@ -13749,7 +13949,7 @@
1374913949 info.camera = renderCamera;
1375013950 info.x = x;
1375113951 info.y = y;
13752
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1375313953 editObj = object.doEditClick(info, 0);
1375413954 if (!editObj)
1375513955 {
....@@ -13766,9 +13966,12 @@
1376613966
1376713967 public void mouseDragged(MouseEvent e)
1376813968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
1376913971 //System.out.println("mouseDragged: " + e);
1377013972 if (isRenderer)
1377113973 movingcamera = true;
13974
+
1377213975 //if (drawing)
1377313976 //return;
1377413977 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13778,7 +13981,7 @@
1377813981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377913982 }
1378013983 else
13781
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378213985
1378313986 //try { Thread.sleep(1); } catch (Exception ex) {}
1378413987 }
....@@ -14015,7 +14218,7 @@
1401514218 {
1401614219 Globals.lighttouched = true;
1401714220 }
14018
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401914222 }
1402014223 //else
1402114224 }
....@@ -14115,7 +14318,7 @@
1411514318 int X, Y;
1411614319 boolean SX, SY;
1411714320
14118
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1411914322 {
1412014323 if (IsFrozen())
1412114324 {
....@@ -14124,17 +14327,17 @@
1412414327
1412514328 drag = true; // NEW
1412614329
14127
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412814331
1412914332 X = x;
1413014333 Y = y;
1413114334 // floating state for animation
14132
- MODIFIERS = modifiers;
14133
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1413414337 if (false) // modifiers != 0)
1413514338 {
1413614339 //new Exception().printStackTrace();
14137
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1413814341 System.out.println("SHIFT = " + SHIFT);
1413914342 System.out.println("CONTROL = " + COMMAND);
1414014343 System.out.println("META = " + META);
....@@ -14154,7 +14357,7 @@
1415414357 info.camera = renderCamera;
1415514358 info.x = x;
1415614359 info.y = y;
14157
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415814361 } else
1415914362 {
1416014363 if (x < startX)
....@@ -14330,7 +14533,10 @@
1433014533
1433114534 public void mouseReleased(MouseEvent e)
1433214535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1433314538 movingcamera = false;
14539
+ X = Y = 0;
1433414540 //System.out.println("mouseReleased: " + e);
1433514541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433614542 }
....@@ -14353,9 +14559,9 @@
1435314559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435414560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435514561
14356
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1435714563 timeout = true;
14358
- else
14564
+// ?? May 2019 else
1435914565 // timer.setDelay((modifiers & 128) != 0?0:350);
1436014566 mouseDown = false;
1436114567 if (!control && !command) // june 2013
....@@ -14465,7 +14671,7 @@
1446514671 System.out.println("keyReleased: " + e);
1446614672 }
1446714673
14468
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1446914675 {
1447014676 //System.out.println("SetMouseMode = " + modifiers);
1447114677 //modifiers &= ~1024;
....@@ -14477,25 +14683,25 @@
1447714683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447814684 // return;
1447914685 //System.out.println("SetMode = " + modifiers);
14480
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1448114687 {
1448214688 mouseMode |= ZOOM;
1448314689 }
1448414690
1448514691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14486
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1448714693 {
1448814694 mouseMode |= VR; // BACKFORTH;
1448914695 }
14490
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449114697 {
1449214698 mouseMode |= SELECT;
1449314699 }
14494
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1449514701 {
1449614702 mouseMode |= SELECT;
1449714703 }
14498
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449914705 {
1450014706 mouseMode &= ~VR;
1450114707 mouseMode |= TRANSLATE;
....@@ -14524,7 +14730,7 @@
1452414730
1452514731 if (isRenderer) //
1452614732 {
14527
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1452814734 }
1452914735
1453014736 Globals.theRenderer.keyPressed(key);
....@@ -14860,7 +15066,7 @@
1486015066 //RESIZETEXTURE ^= true;
1486115067 //break;
1486215068 case 'z':
14863
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1486415070 Globals.lighttouched = true;
1486515071 repaint();
1486615072 break;
....@@ -14984,7 +15190,7 @@
1498415190 //mode = ROTATE;
1498515191 if ((MODIFIERS & COMMAND) == 0) // VR??
1498615192 {
14987
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1498815194 }
1498915195 }
1499015196
....@@ -15120,7 +15326,7 @@
1512015326 {
1512115327 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512215328 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15123
- 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)
1512415330 {
1512515331 mouseMoved(e);
1512615332 } else
....@@ -15339,7 +15545,9 @@
1533915545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534015546 //Image img = CreateImage(width, height);
1534115547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1534215549 Graphics gr = g; // img.getGraphics();
15550
+
1534315551 if (!hasMarquee)
1534415552 {
1534515553 if (Xmin < Xmax) // !locked)
....@@ -15437,14 +15645,33 @@
1543715645 if (!isRenderer)
1543815646 {
1543915647 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
+ }
1544015665 }
1544115666 }
15667
+
1544215668 if (isRenderer)
1544315669 {
1544415670 //gr.setColor(Color.black);
1544515671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544615672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544715673 }
15674
+
1544815675 if (hasMarquee)
1544915676 {
1545015677 gr.setXORMode(Color.white);
....@@ -15557,6 +15784,7 @@
1555715784 public boolean mouseDown(Event evt, int x, int y)
1555815785 {
1555915786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1556015788 /*
1556115789 locked = true;
1556215790 drag = false;
....@@ -15600,7 +15828,7 @@
1560015828 {
1560115829 keyPressed(0, modifiers);
1560215830 }
15603
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1560415832 return true;
1560515833 }
1560615834
....@@ -15718,7 +15946,7 @@
1571815946 {
1571915947 keyReleased(0, 0);
1572015948 }
15721
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1572215950 return true;
1572315951 }
1572415952
....@@ -15850,7 +16078,7 @@
1585016078 Object3D object;
1585116079 static Object3D trackedobject;
1585216080 Camera renderCamera; // Light or Eye (or Occlusion)
15853
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585416082 /*static*/ Camera eyeCamera;
1585516083 /*static*/ Camera lightCamera;
1585616084 int cameracount;
....@@ -16416,16 +16644,16 @@
1641616644 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]));
1641716645 }
1641816646
16419
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642016648 }
1642116649 }
1642216650
1642316651 if (!movingcamera && !PAINTMODE)
1642416652 object.editWindow.ScreenFitPoint(); // fev 2014
1642516653
16426
- 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)
1642716655 {
16428
- 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);
1642916657
1643016658 Object3D group = new Object3D("inst" + paintcount++);
1643116659
....@@ -16581,7 +16809,7 @@
1658116809 gl.glDisable(gl.GL_CULL_FACE);
1658216810 }
1658316811
16584
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1658516813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658616814
1658716815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16591,7 +16819,7 @@
1659116819 //gl.glColorMask(false, false, false, false);
1659216820
1659316821 //render_scene_from_light_view(gl, drawable, 0, 0);
16594
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659516823 {
1659616824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716825