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 {
....@@ -7921,6 +7929,64 @@
79217929 ReleaseTexture(pigment, false);
79227930 }
79237931
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
+
79247990 void ReleaseTexture(String tex, boolean bump)
79257991 {
79267992 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8024,7 +8090,7 @@
80248090 }
80258091 }
80268092
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8093
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288094 {
80298095 if (// DrawMode() != 0 || /*tex == null ||*/
80308096 ambientOcclusion ) // || !textureon)
....@@ -8069,7 +8135,94 @@
80698135 return; // true;
80708136 }
80718137
8072
- 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
80738226 {
80748227 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80758228
....@@ -8077,12 +8230,18 @@
80778230 {
80788231 String texname = tex;
80798232
8080
- String[] split = tex.split("Textures");
8081
- if (split.length > 1)
8082
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8083
- else
8084
- if (!texname.startsWith("/"))
8085
- 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
+ }
80868245
80878246 if (CACHETEXTURE)
80888247 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8151,7 +8310,7 @@
81518310 }
81528311
81538312 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8313
+ if (!FileExists(cachename))
81558314 cachename = texname;
81568315 else
81578316 processbump = false; // don't process bump map again
....@@ -8173,7 +8332,7 @@
81738332 }
81748333
81758334 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8335
+ if (!FileExists(cachename))
81778336 cachename = texname;
81788337 else
81798338 processbump = false; // don't process bump map again
....@@ -8182,7 +8341,9 @@
81828341 texturedata = GetFileTexture(cachename, processbump, resolution);
81838342
81848343
8185
- if (texturedata != null)
8344
+ if (texturedata == null)
8345
+ throw new Exception();
8346
+
81868347 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878348 //texture = GetTexture(tex, bump);
81888349 }
....@@ -8304,7 +8465,7 @@
83048465 return texture;
83058466 }
83068467
8307
- 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
83088469 {
83098470 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108471
....@@ -8322,14 +8483,14 @@
83228483 return texture!=null?texture.texture:null;
83238484 }
83248485
8325
- 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
83268487 {
83278488 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288489
83298490 return texture!=null?texture.texturedata:null;
83308491 }
83318492
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8493
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83338494 {
83348495 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358496 {
....@@ -9306,8 +9467,8 @@
93069467 assert (parentcam != renderCamera);
93079468
93089469 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9470
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9471
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119472
93129473 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139474
....@@ -9322,8 +9483,8 @@
93229483 LA.matCopy(renderCamera.fromScreen, matrix);
93239484
93249485 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9486
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9487
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279488
93289489 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299490
....@@ -9395,7 +9556,7 @@
93959556 //gl.glFlush();
93969557 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979558
9398
- if (ANIMATION && ABORTED)
9559
+ if (Globals.ANIMATION && ABORTED)
93999560 {
94009561 System.err.println(" ABORTED FRAME");
94019562 break;
....@@ -9425,7 +9586,7 @@
94259586 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269587
94279588 // save image
9428
- if (ANIMATION && !ABORTED)
9589
+ if (Globals.ANIMATION && !ABORTED)
94299590 {
94309591 VPwidth = viewport[2];
94319592 VPheight = viewport[3];
....@@ -9536,11 +9697,11 @@
95369697
95379698 // imagecount++;
95389699
9539
- 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;
95409701
95419702 if (!BOXMODE)
95429703 {
9543
- 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) + ")");
95449705 }
95459706
95469707 if (!BOXMODE)
....@@ -9578,7 +9739,7 @@
95789739 ABORTED = false;
95799740 }
95809741 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9742
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829743
95839744 if (false)
95849745 {
....@@ -10241,11 +10402,11 @@
1024110402
1024210403 public void display(GLAutoDrawable drawable)
1024310404 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10405
+ if (Grafreed.savesound && Grafreed.hassound)
1024510406 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10407
+ Grafreed.wav.save();
10408
+ Grafreed.savesound = false;
10409
+ Grafreed.hassound = false;
1024910410 }
1025010411 // if (DEBUG_SELECTION)
1025110412 // {
....@@ -10375,7 +10536,7 @@
1037510536 Object3D theobject = object;
1037610537 Object3D theparent = object.parent;
1037710538 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1037910540 object.Stripify();
1038010541 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110542 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10549,13 @@
1038810549 ambientOcclusion = false;
1038910550 }
1039010551
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (Globals.lighttouched && DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210553 {
1039310554 //if (RENDERSHADOW) // ?
1039410555 if (!IsFrozen())
1039510556 {
1039610557 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10558
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810559 {
1039910560 Globals.framecount++;
1040010561 shadowbuffer.display();
....@@ -10521,8 +10682,8 @@
1052110682
1052210683 // if (parentcam != renderCamera) // not a light
1052310684 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10685
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610687
1052710688 for (int j = 0; j < 4; j++)
1052810689 {
....@@ -10536,8 +10697,8 @@
1053610697
1053710698 // if (parentcam != renderCamera) // not a light
1053810699 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10700
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110702
1054210703 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310704
....@@ -10796,7 +10957,16 @@
1079610957 // Bump noise
1079710958 gl.glActiveTexture(GL.GL_TEXTURE6);
1079810959 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080010970
1080110971 gl.glActiveTexture(GL.GL_TEXTURE0);
1080210972 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10921,8 +11091,8 @@
1092111091 System.err.println("parentcam != renderCamera");
1092211092
1092311093 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611096 }
1092711097
1092811098 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11113,8 @@
1094311113 if (true) // TODO
1094411114 {
1094511115 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811118 }
1094911119
1095011120 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11430,14 @@
1126011430 {
1126111431 renderpass++;
1126211432 // System.out.println("Draw object... ");
11433
+ STEP = 1;
1126311434 if (FAST) // in case there is no script
11264
- STEP = 16;
11435
+ STEP = 8;
11436
+
11437
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11438
+ {
11439
+ STEP *= 4;
11440
+ }
1126511441
1126611442 //object.FullInvariants();
1126711443
....@@ -11275,8 +11451,8 @@
1127511451 e.printStackTrace();
1127611452 }
1127711453
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11454
+ if (Grafreed.RENDERME > 0)
11455
+ Grafreed.RENDERME--; // mechante magouille
1128011456
1128111457 Globals.ONESTEP = false;
1128211458 }
....@@ -11346,7 +11522,14 @@
1134611522
1134711523 usedtextures.clear();
1134811524
11349
- 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
+ }
1135011533 }
1135111534 //System.out.println("--> " + stackdepth);
1135211535 // GrafreeD.traceon();
....@@ -11437,7 +11620,14 @@
1143711620 if (checker != null && DrawMode() == DEFAULT)
1143811621 {
1143911622 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111631 // NEAREST
1144211632 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311633 DrawChecker(gl);
....@@ -11519,7 +11709,7 @@
1151911709 return;
1152011710 }
1152111711
11522
- String string = obj.GetToolTip();
11712
+ String string = obj.toString(); //.GetToolTip();
1152311713
1152411714 GL gl = GetGL();
1152511715
....@@ -11836,8 +12026,8 @@
1183612026 //obj.TransformToWorld(light, light);
1183712027 for (int i = tp.size(); --i >= 0;)
1183812028 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112031 }
1184212032
1184312033
....@@ -11854,8 +12044,8 @@
1185412044 parentcam = cameras[0];
1185512045 }
1185612046
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912049
1186012050 LA.xformPos(light, renderCamera.toScreen, light);
1186112051
....@@ -12469,8 +12659,8 @@
1246912659
1247012660 // display shadow only (bump == 0)
1247112661 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12662
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12663
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412664 "SUB temp.y, one.x, temp.z;" +
1247512665 "MUL temp.x, temp.x, temp.y;" +
1247612666 "KIL temp.x;" +
....@@ -12599,8 +12789,10 @@
1259912789 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012790
1260112791 "SUB temp.x, one.x, ndotl.x;" +
12602
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12603
- "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
1260412796 "MUL temp.x, temp.x, temp.y;" +
1260512797
1260612798 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +12940,7 @@
1274812940 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274912941 "FLR final.x, final.y;" +
1275012942 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
12943
+ "MUL final.x, final.x, c256i;" +
1275212944 "MOV final.z, zero.x;" +
1275312945 "MOV final.a, one.w;":""
1275412946 ) +
....@@ -12756,7 +12948,7 @@
1275612948 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275712949 "FLR final.x, final.y;" +
1275812950 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
12951
+ "MUL final.x, final.x, c256i;" +
1276012952 "MOV final.z, zero.x;" +
1276112953 "MOV final.a, one.w;":""
1276212954 ) +
....@@ -12799,7 +12991,7 @@
1279912991 //once = true;
1280012992 }
1280112993
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
12994
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280312995 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280412996 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280512997
....@@ -12932,12 +13124,16 @@
1293213124
1293313125 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413126 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13127
+
13128
+ // Compare fragment depth in light space with shadowmap.
1293513129 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613130 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13131
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13132
+
13133
+ // Reverse comparison
1293813134 "SUB temp.x, one.x, temp.x;" +
1293913135 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13136
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113137 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213138
1294313139 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13147,10 @@
1295113147 // No shadow for backface
1295213148 "DP3 temp.x, normal, lightd;" +
1295313149 "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;" +
1295413154 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513155 "";
1295613156 }
....@@ -13509,7 +13709,7 @@
1350913709 public void mousePressed(MouseEvent e)
1351013710 {
1351113711 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13712
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313713 }
1351413714
1351513715 static long prevtime = 0;
....@@ -13585,8 +13785,8 @@
1358513785 // mode |= META;
1358613786 //}
1358713787
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13788
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13789
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013790 anchorX = ax;
1359113791 anchorY = ay;
1359213792 prevX = px;
....@@ -13646,6 +13846,10 @@
1364613846 // wasliveok = true;
1364713847 // waslive = false;
1364813848
13849
+ // May 2019 Forget it:
13850
+ if (true)
13851
+ return;
13852
+
1364913853 // source == timer
1365013854 if (mouseDown)
1365113855 {
....@@ -13684,7 +13888,7 @@
1368413888
1368513889 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613890
13687
- void clickStart(int x, int y, int modifiers)
13891
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813892 {
1368913893 if (!wasliveok)
1369013894 return;
....@@ -13701,7 +13905,7 @@
1370113905 // touched = true; // main DL
1370213906 if (isRenderer)
1370313907 {
13704
- SetMouseMode(modifiers);
13908
+ SetMouseMode(modifiers, modifiersex);
1370513909 }
1370613910
1370713911 selectX = anchorX = x;
....@@ -13714,7 +13918,7 @@
1371413918 clicked = true;
1371513919 hold = false;
1371613920
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13921
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813922 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913923 {
1372013924 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +13949,7 @@
1374513949 info.camera = renderCamera;
1374613950 info.x = x;
1374713951 info.y = y;
13748
- info.modifiers = modifiers;
13952
+ info.modifiers = modifiersex;
1374913953 editObj = object.doEditClick(info, 0);
1375013954 if (!editObj)
1375113955 {
....@@ -13762,9 +13966,12 @@
1376213966
1376313967 public void mouseDragged(MouseEvent e)
1376413968 {
13969
+ Globals.MOUSEDRAGGED = true;
13970
+
1376513971 //System.out.println("mouseDragged: " + e);
1376613972 if (isRenderer)
1376713973 movingcamera = true;
13974
+
1376813975 //if (drawing)
1376913976 //return;
1377013977 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +13981,7 @@
1377413981 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377513982 }
1377613983 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
13984
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377813985
1377913986 //try { Thread.sleep(1); } catch (Exception ex) {}
1378013987 }
....@@ -14011,7 +14218,7 @@
1401114218 {
1401214219 Globals.lighttouched = true;
1401314220 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14221
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514222 }
1401614223 //else
1401714224 }
....@@ -14111,7 +14318,7 @@
1411114318 int X, Y;
1411214319 boolean SX, SY;
1411314320
14114
- void drag(int x, int y, int modifiers)
14321
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514322 {
1411614323 if (IsFrozen())
1411714324 {
....@@ -14120,17 +14327,17 @@
1412014327
1412114328 drag = true; // NEW
1412214329
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14330
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414331
1412514332 X = x;
1412614333 Y = y;
1412714334 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14335
+ MODIFIERS = modifiersex;
14336
+ modifiersex &= ~1024;
1413014337 if (false) // modifiers != 0)
1413114338 {
1413214339 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14340
+ System.out.println("mouseDragged: " + modifiersex);
1413414341 System.out.println("SHIFT = " + SHIFT);
1413514342 System.out.println("CONTROL = " + COMMAND);
1413614343 System.out.println("META = " + META);
....@@ -14150,7 +14357,7 @@
1415014357 info.camera = renderCamera;
1415114358 info.x = x;
1415214359 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14360
+ object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414361 } else
1415514362 {
1415614363 if (x < startX)
....@@ -14326,7 +14533,10 @@
1432614533
1432714534 public void mouseReleased(MouseEvent e)
1432814535 {
14536
+ Globals.MOUSEDRAGGED = false;
14537
+
1432914538 movingcamera = false;
14539
+ X = Y = 0;
1433014540 //System.out.println("mouseReleased: " + e);
1433114541 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214542 }
....@@ -14349,9 +14559,9 @@
1434914559 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014560 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114561
14352
- if (control || command || IsFrozen())
14562
+// No delay if (control || command || IsFrozen())
1435314563 timeout = true;
14354
- else
14564
+// ?? May 2019 else
1435514565 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614566 mouseDown = false;
1435714567 if (!control && !command) // june 2013
....@@ -14461,7 +14671,7 @@
1446114671 System.out.println("keyReleased: " + e);
1446214672 }
1446314673
14464
- void SetMouseMode(int modifiers)
14674
+ void SetMouseMode(int modifiers, int modifiersex)
1446514675 {
1446614676 //System.out.println("SetMouseMode = " + modifiers);
1446714677 //modifiers &= ~1024;
....@@ -14473,25 +14683,25 @@
1447314683 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414684 // return;
1447514685 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14686
+ if ((modifiersex & WHEEL) == WHEEL)
1447714687 {
1447814688 mouseMode |= ZOOM;
1447914689 }
1448014690
1448114691 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14692
+ if (capsLocked) // || (modifiers & META) == META)
1448314693 {
1448414694 mouseMode |= VR; // BACKFORTH;
1448514695 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14696
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714697 {
1448814698 mouseMode |= SELECT;
1448914699 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14700
+ if ((modifiersex & COMMAND) == COMMAND)
1449114701 {
1449214702 mouseMode |= SELECT;
1449314703 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14704
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514705 {
1449614706 mouseMode &= ~VR;
1449714707 mouseMode |= TRANSLATE;
....@@ -14520,7 +14730,7 @@
1452014730
1452114731 if (isRenderer) //
1452214732 {
14523
- SetMouseMode(modifiers);
14733
+ SetMouseMode(0, modifiers);
1452414734 }
1452514735
1452614736 Globals.theRenderer.keyPressed(key);
....@@ -14856,7 +15066,7 @@
1485615066 //RESIZETEXTURE ^= true;
1485715067 //break;
1485815068 case 'z':
14859
- RENDERSHADOW ^= true;
15069
+ Globals.RENDERSHADOW ^= true;
1486015070 Globals.lighttouched = true;
1486115071 repaint();
1486215072 break;
....@@ -14980,7 +15190,7 @@
1498015190 //mode = ROTATE;
1498115191 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215192 {
14983
- SetMouseMode(modifiers);
15193
+ SetMouseMode(0, modifiers);
1498415194 }
1498515195 }
1498615196
....@@ -15116,7 +15326,7 @@
1511615326 {
1511715327 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815328 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015330 {
1512115331 mouseMoved(e);
1512215332 } else
....@@ -15335,7 +15545,9 @@
1533515545 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615546 //Image img = CreateImage(width, height);
1533715547 //System.out.println("width = " + width + "; height = " + height + "\n");
15548
+
1533815549 Graphics gr = g; // img.getGraphics();
15550
+
1533915551 if (!hasMarquee)
1534015552 {
1534115553 if (Xmin < Xmax) // !locked)
....@@ -15433,14 +15645,33 @@
1543315645 if (!isRenderer)
1543415646 {
1543515647 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
+ }
1543615665 }
1543715666 }
15667
+
1543815668 if (isRenderer)
1543915669 {
1544015670 //gr.setColor(Color.black);
1544115671 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215672 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315673 }
15674
+
1544415675 if (hasMarquee)
1544515676 {
1544615677 gr.setXORMode(Color.white);
....@@ -15553,6 +15784,7 @@
1555315784 public boolean mouseDown(Event evt, int x, int y)
1555415785 {
1555515786 System.out.println("mouseDown: " + evt);
15787
+ System.exit(0);
1555615788 /*
1555715789 locked = true;
1555815790 drag = false;
....@@ -15596,7 +15828,7 @@
1559615828 {
1559715829 keyPressed(0, modifiers);
1559815830 }
15599
- clickStart(x, y, modifiers);
15831
+ // clickStart(x, y, modifiers);
1560015832 return true;
1560115833 }
1560215834
....@@ -15714,7 +15946,7 @@
1571415946 {
1571515947 keyReleased(0, 0);
1571615948 }
15717
- drag(x, y, modifiers);
15949
+ drag(x, y, 0, modifiers);
1571815950 return true;
1571915951 }
1572015952
....@@ -15846,7 +16078,7 @@
1584616078 Object3D object;
1584716079 static Object3D trackedobject;
1584816080 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16081
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016082 /*static*/ Camera eyeCamera;
1585116083 /*static*/ Camera lightCamera;
1585216084 int cameracount;
....@@ -16412,16 +16644,16 @@
1641216644 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]));
1641316645 }
1641416646
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16647
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616648 }
1641716649 }
1641816650
1641916651 if (!movingcamera && !PAINTMODE)
1642016652 object.editWindow.ScreenFitPoint(); // fev 2014
1642116653
16422
- 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)
1642316655 {
16424
- 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);
1642516657
1642616658 Object3D group = new Object3D("inst" + paintcount++);
1642716659
....@@ -16577,7 +16809,7 @@
1657716809 gl.glDisable(gl.GL_CULL_FACE);
1657816810 }
1657916811
16580
- if (!RENDERSHADOW)
16812
+ if (!Globals.RENDERSHADOW)
1658116813 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216814
1658316815 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16819,7 @@
1658716819 //gl.glColorMask(false, false, false, false);
1658816820
1658916821 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16822
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116823 {
1659216824 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316825