Normand Briere
2019-06-21 15123b19e7bc8da2869429b07f0fbaa0598e945e
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;
....@@ -86,7 +84,7 @@
8684 static boolean FULLSCREEN = false;
8785 static boolean SUPPORT = true;
8886 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
87
+static boolean FAST = false;
9088 static boolean SLOWPOSE = false;
9189 static boolean FOOTCONTACT = true;
9290
....@@ -108,7 +106,7 @@
108106 static boolean OEIL = true;
109107 static boolean OEILONCE = false; // do oeilon then oeiloff
110108 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
109
+static boolean SWITCH = true; // false;
112110 static boolean HANDLES = false; // selection doesn't work!!
113111 static boolean PAINTMODE = false;
114112
....@@ -151,6 +149,8 @@
151149 defaultcaps.setAccumBlueBits(16);
152150 defaultcaps.setAccumAlphaBits(16);
153151 }
152
+
153
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154154
155155 void SetAsGLRenderer(boolean b)
156156 {
....@@ -464,10 +464,12 @@
464464 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465465 {
466466 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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
+ ;
468470 if (!hasnorm)
469471 {
470
- // System.out.println("FUCK!!");
472
+ // System.out.println("Mesh normal");
471473 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472474 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473475 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1194,12 @@
11921194 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931195 }
11941196 }
1197
+
11951198 if (flipV)
11961199 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971200 else
11981201 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1202
+
11991203 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001204 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011205
....@@ -1215,10 +1219,12 @@
12151219 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161220 }
12171221 }
1222
+
12181223 if (flipV)
12191224 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201225 else
12211226 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1227
+
12221228 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231229 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241230
....@@ -1246,8 +1252,10 @@
12461252 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471253 else
12481254 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1255
+
12491256 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501257 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1258
+
12511259 count2 += 2;
12521260 count3 += 3;
12531261 }
....@@ -1630,7 +1638,7 @@
16301638
16311639 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321640
1633
- float[] colorV = GrafreeD.colorV;
1641
+ float[] colorV = Grafreed.colorV;
16341642
16351643 /**/
16361644 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1890,7 +1898,7 @@
18901898 void PushMatrix(double[][] matrix)
18911899 {
18921900 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1901
+ PushMatrix(matrix, 1);
18941902 }
18951903
18961904 void PushMatrix()
....@@ -2142,7 +2150,7 @@
21422150 System.err.println("LIVE = " + Globals.isLIVE());
21432151
21442152 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2153
+ Grafreed.savesound = true; // wav.save();
21462154 // else
21472155 repaint(); // start loop // may 2013
21482156 }
....@@ -2267,9 +2275,9 @@
22672275 LOOKAT ^= true;
22682276 }
22692277
2270
- void ToggleRandom()
2278
+ void ToggleSwitch()
22712279 {
2272
- RANDOM ^= true;
2280
+ SWITCH ^= true;
22732281 }
22742282
22752283 void ToggleHandles()
....@@ -2376,7 +2384,7 @@
23762384 {
23772385 return currentGL;
23782386 }
2379
-
2387
+
23802388 /**/
23812389 class CacheTexture
23822390 {
....@@ -4208,6 +4216,7 @@
42084216
42094217 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104218 {
4219
+ new Exception().printStackTrace();
42114220 System.exit(0);
42124221 com.sun.opengl.util.texture.Texture texture = null;
42134222
....@@ -7920,6 +7929,64 @@
79207929 ReleaseTexture(pigment, false);
79217930 }
79227931
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
+
79237990 void ReleaseTexture(String tex, boolean bump)
79247991 {
79257992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8023,7 +8090,7 @@
80238090 }
80248091 }
80258092
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80278094 {
80288095 if (// DrawMode() != 0 || /*tex == null ||*/
80298096 ambientOcclusion ) // || !textureon)
....@@ -8068,7 +8135,94 @@
80688135 return; // true;
80698136 }
80708137
8071
- 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
80728226 {
80738227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80748228
....@@ -8076,12 +8230,18 @@
80768230 {
80778231 String texname = tex;
80788232
8079
- String[] split = tex.split("Textures");
8080
- if (split.length > 1)
8081
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8082
- else
8083
- if (!texname.startsWith("/"))
8084
- 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
+ }
80858245
80868246 if (CACHETEXTURE)
80878247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8150,7 +8310,7 @@
81508310 }
81518311
81528312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
81548314 cachename = texname;
81558315 else
81568316 processbump = false; // don't process bump map again
....@@ -8172,7 +8332,7 @@
81728332 }
81738333
81748334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
81768336 cachename = texname;
81778337 else
81788338 processbump = false; // don't process bump map again
....@@ -8181,7 +8341,9 @@
81818341 texturedata = GetFileTexture(cachename, processbump, resolution);
81828342
81838343
8184
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
81858347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868348 //texture = GetTexture(tex, bump);
81878349 }
....@@ -8303,7 +8465,7 @@
83038465 return texture;
83048466 }
83058467
8306
- 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
83078469 {
83088470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83098471
....@@ -8321,14 +8483,14 @@
83218483 return texture!=null?texture.texture:null;
83228484 }
83238485
8324
- 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
83258487 {
83268488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83278489
83288490 return texture!=null?texture.texturedata:null;
83298491 }
83308492
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83328494 {
83338495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348496 {
....@@ -9305,8 +9467,8 @@
93059467 assert (parentcam != renderCamera);
93069468
93079469 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109472
93119473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129474
....@@ -9321,8 +9483,8 @@
93219483 LA.matCopy(renderCamera.fromScreen, matrix);
93229484
93239485 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269488
93279489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289490
....@@ -9394,7 +9556,7 @@
93949556 //gl.glFlush();
93959557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969558
9397
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
93989560 {
93999561 System.err.println(" ABORTED FRAME");
94009562 break;
....@@ -9424,7 +9586,7 @@
94249586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259587
94269588 // save image
9427
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
94289590 {
94299591 VPwidth = viewport[2];
94309592 VPheight = viewport[3];
....@@ -9535,11 +9697,11 @@
95359697
95369698 // imagecount++;
95379699
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9700
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399701
95409702 if (!BOXMODE)
95419703 {
9542
- 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) + ")");
95439705 }
95449706
95459707 if (!BOXMODE)
....@@ -9577,7 +9739,7 @@
95779739 ABORTED = false;
95789740 }
95799741 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819743
95829744 if (false)
95839745 {
....@@ -10240,11 +10402,11 @@
1024010402
1024110403 public void display(GLAutoDrawable drawable)
1024210404 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
1024410406 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
1024810410 }
1024910411 // if (DEBUG_SELECTION)
1025010412 // {
....@@ -10374,7 +10536,7 @@
1037410536 Object3D theobject = object;
1037510537 Object3D theparent = object.parent;
1037610538 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1037810540 object.Stripify();
1037910541 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010542 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10549,13 @@
1038710549 ambientOcclusion = false;
1038810550 }
1038910551
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110553 {
1039210554 //if (RENDERSHADOW) // ?
1039310555 if (!IsFrozen())
1039410556 {
1039510557 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710559 {
1039810560 Globals.framecount++;
1039910561 shadowbuffer.display();
....@@ -10520,8 +10682,8 @@
1052010682
1052110683 // if (parentcam != renderCamera) // not a light
1052210684 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510687
1052610688 for (int j = 0; j < 4; j++)
1052710689 {
....@@ -10535,8 +10697,8 @@
1053510697
1053610698 // if (parentcam != renderCamera) // not a light
1053710699 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010702
1054110703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210704
....@@ -10795,7 +10957,16 @@
1079510957 // Bump noise
1079610958 gl.glActiveTexture(GL.GL_TEXTURE6);
1079710959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- 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
+
1079910970
1080010971 gl.glActiveTexture(GL.GL_TEXTURE0);
1080110972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10920,8 +11091,8 @@
1092011091 System.err.println("parentcam != renderCamera");
1092111092
1092211093 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- 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
1092511096 }
1092611097
1092711098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11113,8 @@
1094211113 if (true) // TODO
1094311114 {
1094411115 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- 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
1094711118 }
1094811119
1094911120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11430,14 @@
1125911430 {
1126011431 renderpass++;
1126111432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1126211434 if (FAST) // in case there is no script
11263
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1126411441
1126511442 //object.FullInvariants();
1126611443
....@@ -11274,8 +11451,8 @@
1127411451 e.printStackTrace();
1127511452 }
1127611453
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1127911456
1128011457 Globals.ONESTEP = false;
1128111458 }
....@@ -11345,7 +11522,14 @@
1134511522
1134611523 usedtextures.clear();
1134711524
11348
- 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
+ }
1134911533 }
1135011534 //System.out.println("--> " + stackdepth);
1135111535 // GrafreeD.traceon();
....@@ -11436,7 +11620,14 @@
1143611620 if (checker != null && DrawMode() == DEFAULT)
1143711621 {
1143811622 //BindTexture(IMMORTAL_TEXTURE);
11439
- 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
+ }
1144011631 // NEAREST
1144111632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211633 DrawChecker(gl);
....@@ -11518,7 +11709,7 @@
1151811709 return;
1151911710 }
1152011711
11521
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1152211713
1152311714 GL gl = GetGL();
1152411715
....@@ -11835,8 +12026,8 @@
1183512026 //obj.TransformToWorld(light, light);
1183612027 for (int i = tp.size(); --i >= 0;)
1183712028 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- 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);
1184012031 }
1184112032
1184212033
....@@ -11853,8 +12044,8 @@
1185312044 parentcam = cameras[0];
1185412045 }
1185512046
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- 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
1185812049
1185912050 LA.xformPos(light, renderCamera.toScreen, light);
1186012051
....@@ -12468,8 +12659,8 @@
1246812659
1246912660 // display shadow only (bump == 0)
1247012661 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312664 "SUB temp.y, one.x, temp.z;" +
1247412665 "MUL temp.x, temp.x, temp.y;" +
1247512666 "KIL temp.x;" +
....@@ -12598,8 +12789,10 @@
1259812789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912790
1260012791 "SUB temp.x, one.x, ndotl.x;" +
12601
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12602
- "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
1260312796 "MUL temp.x, temp.x, temp.y;" +
1260412797
1260512798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12798,7 +12991,7 @@
1279812991 //once = true;
1279912992 }
1280012993
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280212995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280312996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280412997
....@@ -12931,12 +13124,16 @@
1293113124
1293213125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1293413129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513130 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1293713134 "SUB temp.x, one.x, temp.x;" +
1293813135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113138
1294213139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13147,10 @@
1295013147 // No shadow for backface
1295113148 "DP3 temp.x, normal, lightd;" +
1295213149 "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;" +
1295313154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413155 "";
1295513156 }
....@@ -13508,7 +13709,7 @@
1350813709 public void mousePressed(MouseEvent e)
1350913710 {
1351013711 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213713 }
1351313714
1351413715 static long prevtime = 0;
....@@ -13584,8 +13785,8 @@
1358413785 // mode |= META;
1358513786 //}
1358613787
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913790 anchorX = ax;
1359013791 anchorY = ay;
1359113792 prevX = px;
....@@ -13645,6 +13846,10 @@
1364513846 // wasliveok = true;
1364613847 // waslive = false;
1364713848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1364813853 // source == timer
1364913854 if (mouseDown)
1365013855 {
....@@ -13683,7 +13888,7 @@
1368313888
1368413889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368513890
13686
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368713892 {
1368813893 if (!wasliveok)
1368913894 return;
....@@ -13700,7 +13905,7 @@
1370013905 // touched = true; // main DL
1370113906 if (isRenderer)
1370213907 {
13703
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1370413909 }
1370513910
1370613911 selectX = anchorX = x;
....@@ -13713,7 +13918,7 @@
1371313918 clicked = true;
1371413919 hold = false;
1371513920
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371713922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371813923 {
1371913924 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +13949,7 @@
1374413949 info.camera = renderCamera;
1374513950 info.x = x;
1374613951 info.y = y;
13747
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1374813953 editObj = object.doEditClick(info, 0);
1374913954 if (!editObj)
1375013955 {
....@@ -13761,9 +13966,12 @@
1376113966
1376213967 public void mouseDragged(MouseEvent e)
1376313968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
1376413971 //System.out.println("mouseDragged: " + e);
1376513972 if (isRenderer)
1376613973 movingcamera = true;
13974
+
1376713975 //if (drawing)
1376813976 //return;
1376913977 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +13981,7 @@
1377313981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377413982 }
1377513983 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377713985
1377813986 //try { Thread.sleep(1); } catch (Exception ex) {}
1377913987 }
....@@ -13946,6 +14154,7 @@
1394614154
1394714155 public void run()
1394814156 {
14157
+ new Exception().printStackTrace();
1394914158 System.exit(0);
1395014159 for (;;)
1395114160 {
....@@ -14009,7 +14218,7 @@
1400914218 {
1401014219 Globals.lighttouched = true;
1401114220 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314222 }
1401414223 //else
1401514224 }
....@@ -14109,7 +14318,7 @@
1410914318 int X, Y;
1411014319 boolean SX, SY;
1411114320
14112
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314322 {
1411414323 if (IsFrozen())
1411514324 {
....@@ -14118,17 +14327,17 @@
1411814327
1411914328 drag = true; // NEW
1412014329
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214331
1412314332 X = x;
1412414333 Y = y;
1412514334 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1412814337 if (false) // modifiers != 0)
1412914338 {
1413014339 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1413214341 System.out.println("SHIFT = " + SHIFT);
1413314342 System.out.println("CONTROL = " + COMMAND);
1413414343 System.out.println("META = " + META);
....@@ -14148,7 +14357,7 @@
1414814357 info.camera = renderCamera;
1414914358 info.x = x;
1415014359 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214361 } else
1415314362 {
1415414363 if (x < startX)
....@@ -14324,7 +14533,10 @@
1432414533
1432514534 public void mouseReleased(MouseEvent e)
1432614535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1432714538 movingcamera = false;
14539
+ X = Y = 0;
1432814540 //System.out.println("mouseReleased: " + e);
1432914541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014542 }
....@@ -14347,9 +14559,9 @@
1434714559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914561
14350
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1435114563 timeout = true;
14352
- else
14564
+// ?? May 2019 else
1435314565 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414566 mouseDown = false;
1435514567 if (!control && !command) // june 2013
....@@ -14459,7 +14671,7 @@
1445914671 System.out.println("keyReleased: " + e);
1446014672 }
1446114673
14462
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1446314675 {
1446414676 //System.out.println("SetMouseMode = " + modifiers);
1446514677 //modifiers &= ~1024;
....@@ -14471,25 +14683,25 @@
1447114683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214684 // return;
1447314685 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1447514687 {
1447614688 mouseMode |= ZOOM;
1447714689 }
1447814690
1447914691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1448114693 {
1448214694 mouseMode |= VR; // BACKFORTH;
1448314695 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514697 {
1448614698 mouseMode |= SELECT;
1448714699 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1448914701 {
1449014702 mouseMode |= SELECT;
1449114703 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314705 {
1449414706 mouseMode &= ~VR;
1449514707 mouseMode |= TRANSLATE;
....@@ -14518,7 +14730,7 @@
1451814730
1451914731 if (isRenderer) //
1452014732 {
14521
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1452214734 }
1452314735
1452414736 Globals.theRenderer.keyPressed(key);
....@@ -14854,7 +15066,7 @@
1485415066 //RESIZETEXTURE ^= true;
1485515067 //break;
1485615068 case 'z':
14857
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1485815070 Globals.lighttouched = true;
1485915071 repaint();
1486015072 break;
....@@ -14978,7 +15190,7 @@
1497815190 //mode = ROTATE;
1497915191 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015192 {
14981
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1498215194 }
1498315195 }
1498415196
....@@ -15114,7 +15326,7 @@
1511415326 {
1511515327 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615328 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- 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)
1511815330 {
1511915331 mouseMoved(e);
1512015332 } else
....@@ -15144,6 +15356,7 @@
1514415356
1514515357 void SelectParent()
1514615358 {
15359
+ new Exception().printStackTrace();
1514715360 System.exit(0);
1514815361 Composite group = (Composite) object;
1514915362 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15167,6 +15380,7 @@
1516715380
1516815381 void SelectChildren()
1516915382 {
15383
+ new Exception().printStackTrace();
1517015384 System.exit(0);
1517115385 /*
1517215386 Composite group = (Composite) object;
....@@ -15331,7 +15545,9 @@
1533115545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215546 //Image img = CreateImage(width, height);
1533315547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1533415549 Graphics gr = g; // img.getGraphics();
15550
+
1533515551 if (!hasMarquee)
1533615552 {
1533715553 if (Xmin < Xmax) // !locked)
....@@ -15429,14 +15645,33 @@
1542915645 if (!isRenderer)
1543015646 {
1543115647 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
+ }
1543215665 }
1543315666 }
15667
+
1543415668 if (isRenderer)
1543515669 {
1543615670 //gr.setColor(Color.black);
1543715671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915673 }
15674
+
1544015675 if (hasMarquee)
1544115676 {
1544215677 gr.setXORMode(Color.white);
....@@ -15549,6 +15784,7 @@
1554915784 public boolean mouseDown(Event evt, int x, int y)
1555015785 {
1555115786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1555215788 /*
1555315789 locked = true;
1555415790 drag = false;
....@@ -15592,7 +15828,7 @@
1559215828 {
1559315829 keyPressed(0, modifiers);
1559415830 }
15595
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1559615832 return true;
1559715833 }
1559815834
....@@ -15710,7 +15946,7 @@
1571015946 {
1571115947 keyReleased(0, 0);
1571215948 }
15713
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1571415950 return true;
1571515951 }
1571615952
....@@ -15842,7 +16078,7 @@
1584216078 Object3D object;
1584316079 static Object3D trackedobject;
1584416080 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616082 /*static*/ Camera eyeCamera;
1584716083 /*static*/ Camera lightCamera;
1584816084 int cameracount;
....@@ -16280,6 +16516,7 @@
1628016516 {
1628116517 if (!selection)
1628216518 {
16519
+ new Exception().printStackTrace();
1628316520 System.exit(0);
1628416521 return;
1628516522 }
....@@ -16407,16 +16644,16 @@
1640716644 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]));
1640816645 }
1640916646
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116648 }
1641216649 }
1641316650
1641416651 if (!movingcamera && !PAINTMODE)
1641516652 object.editWindow.ScreenFitPoint(); // fev 2014
1641616653
16417
- 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)
1641816655 {
16419
- 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);
1642016657
1642116658 Object3D group = new Object3D("inst" + paintcount++);
1642216659
....@@ -16572,7 +16809,7 @@
1657216809 gl.glDisable(gl.GL_CULL_FACE);
1657316810 }
1657416811
16575
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1657616813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657716814
1657816815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +16819,7 @@
1658216819 //gl.glColorMask(false, false, false, false);
1658316820
1658416821 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658616823 {
1658716824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658816825