Normand Briere
2019-07-21 76522bc3ee92bd50dbd946d7f865666be4ad7bac
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -56,8 +55,6 @@
5655 static int CURRENTANTIALIAS = 0; // 1;
5756 /*static*/ boolean RENDERSHADOW = true;
5857 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6158
6259 boolean DISPLAYTEXT = false;
6360 //boolean REDUCETEXTURE = true;
....@@ -86,7 +83,7 @@
8683 static boolean FULLSCREEN = false;
8784 static boolean SUPPORT = true;
8885 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
86
+static boolean FAST = false;
9087 static boolean SLOWPOSE = false;
9188 static boolean FOOTCONTACT = true;
9289
....@@ -108,7 +105,7 @@
108105 static boolean OEIL = true;
109106 static boolean OEILONCE = false; // do oeilon then oeiloff
110107 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
112109 static boolean HANDLES = false; // selection doesn't work!!
113110 static boolean PAINTMODE = false;
114111
....@@ -151,6 +148,8 @@
151148 defaultcaps.setAccumBlueBits(16);
152149 defaultcaps.setAccumAlphaBits(16);
153150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154153
155154 void SetAsGLRenderer(boolean b)
156155 {
....@@ -327,7 +326,7 @@
327326 cStatic.objectstack[materialdepth++] = obj;
328327 //System.out.println("material " + material);
329328 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
331330 if (obj instanceof Camera)
332331 {
333332 display.options1[0] = material.shift;
....@@ -336,14 +335,28 @@
336335 display.options1[2] = material.shadowbias;
337336 display.options1[3] = material.aniso;
338337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
339343 display.options2[0] = material.opacity;
340344 display.options2[1] = material.diffuse;
341345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
342349
343350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
344354 display.options4[0] = material.cameralight/0.2f;
345355 display.options4[1] = material.subsurface;
346356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
347360
348361 // if (display.CURRENTANTIALIAS > 0)
349362 // display.options3[3] /= 4;
....@@ -359,7 +372,7 @@
359372 /**/
360373 } else
361374 {
362
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
363376 }
364377 } else
365378 {
....@@ -383,8 +396,8 @@
383396 cStatic.objectstack[materialdepth++] = obj;
384397 //System.out.println("material " + material);
385398 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388401 }
389402 }
390403
....@@ -401,8 +414,8 @@
401414 materialdepth -= 1;
402415 if (materialdepth > 0)
403416 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406419 }
407420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +435,8 @@
422435 materialdepth -= 1;
423436 if (materialdepth > 0)
424437 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427440 }
428441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429442 //else
....@@ -464,10 +477,12 @@
464477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465478 {
466479 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
468483 if (!hasnorm)
469484 {
470
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
471486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1207,12 @@
11921207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931208 }
11941209 }
1210
+
11951211 if (flipV)
11961212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971213 else
11981214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11991216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011218
....@@ -1215,10 +1232,12 @@
12151232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161233 }
12171234 }
1235
+
12181236 if (flipV)
12191237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201238 else
12211239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12221241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241243
....@@ -1246,8 +1265,10 @@
12461265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471266 else
12481267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12491269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12511272 count2 += 2;
12521273 count3 += 3;
12531274 }
....@@ -1603,7 +1624,7 @@
16031624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041625 }
16051626
1606
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071628 {
16081629 CameraPane display = this;
16091630 //new Exception().printStackTrace();
....@@ -1630,7 +1651,7 @@
16301651
16311652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321653
1633
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16341655
16351656 /**/
16361657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1659,7 @@
16381659 colorV[0] = display.modelParams0[0] * material.diffuse;
16391660 colorV[1] = display.modelParams0[1] * material.diffuse;
16401661 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16421663
16431664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441665 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1767,9 @@
17461767 display.modelParams7[2] = 0;
17471768 display.modelParams7[3] = 0;
17481769
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501771
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531774 {
17541775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2142,7 +2163,7 @@
21422163 System.err.println("LIVE = " + Globals.isLIVE());
21432164
21442165 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21462167 // else
21472168 repaint(); // start loop // may 2013
21482169 }
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2267,9 +2288,9 @@
22672288 LOOKAT ^= true;
22682289 }
22692290
2270
- void ToggleRandom()
2291
+ void ToggleSwitch()
22712292 {
2272
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22732294 }
22742295
22752296 void ToggleHandles()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -2376,7 +2404,7 @@
23762404 {
23772405 return currentGL;
23782406 }
2379
-
2407
+
23802408 /**/
23812409 class CacheTexture
23822410 {
....@@ -7902,7 +7930,7 @@
79027930 String pigment = Object3D.GetPigment(tex);
79037931 String bump = Object3D.GetBump(tex);
79047932
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7933
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79067934 {
79077935 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79087936 // System.out.println("; bump = " + bump);
....@@ -7919,6 +7947,64 @@
79197947
79207948 ReleaseTexture(bump, true);
79217949 ReleaseTexture(pigment, false);
7950
+ }
7951
+
7952
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7953
+ {
7954
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7955
+ {
7956
+ return;
7957
+ }
7958
+
7959
+ if (tex == null)
7960
+ {
7961
+ ReleaseTexture(null, false);
7962
+ return;
7963
+ }
7964
+
7965
+ String pigment = Object3D.GetPigment(tex);
7966
+
7967
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7968
+ {
7969
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7970
+ // System.out.println("; bump = " + bump);
7971
+ }
7972
+
7973
+ if (pigment.equals(""))
7974
+ {
7975
+ pigment = null;
7976
+ }
7977
+
7978
+ ReleaseTexture(pigment, false);
7979
+ }
7980
+
7981
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7982
+ {
7983
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7984
+ {
7985
+ return;
7986
+ }
7987
+
7988
+ if (tex == null)
7989
+ {
7990
+ ReleaseTexture(null, true);
7991
+ return;
7992
+ }
7993
+
7994
+ String bump = Object3D.GetBump(tex);
7995
+
7996
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7997
+ {
7998
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7999
+ // System.out.println("; bump = " + bump);
8000
+ }
8001
+
8002
+ if (bump.equals(""))
8003
+ {
8004
+ bump = null;
8005
+ }
8006
+
8007
+ ReleaseTexture(bump, true);
79228008 }
79238009
79248010 void ReleaseTexture(String tex, boolean bump)
....@@ -8024,7 +8110,7 @@
80248110 }
80258111 }
80268112
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8113
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80288114 {
80298115 if (// DrawMode() != 0 || /*tex == null ||*/
80308116 ambientOcclusion ) // || !textureon)
....@@ -8045,7 +8131,7 @@
80458131 usedtextures.put(pigment, pigment);
80468132 usedtextures.put(bump, bump);
80478133
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8134
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498135 {
80508136 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518137 // System.out.println("; bump = " + bump);
....@@ -8069,7 +8155,94 @@
80698155 return; // true;
80708156 }
80718157
8072
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8158
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8159
+ {
8160
+ if (// DrawMode() != 0 || /*tex == null ||*/
8161
+ ambientOcclusion ) // || !textureon)
8162
+ {
8163
+ return; // false;
8164
+ }
8165
+
8166
+ if (tex == null)
8167
+ {
8168
+ BindTexture(null,false,resolution);
8169
+ return;
8170
+ }
8171
+
8172
+ String pigment = Object3D.GetPigment(tex);
8173
+
8174
+ usedtextures.put(pigment, pigment);
8175
+
8176
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8177
+ {
8178
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8179
+ // System.out.println("; bump = " + bump);
8180
+ }
8181
+
8182
+ if (pigment.equals(""))
8183
+ {
8184
+ pigment = null;
8185
+ }
8186
+
8187
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8188
+ BindTexture(pigment, false, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+ if (// DrawMode() != 0 || /*tex == null ||*/
8194
+ ambientOcclusion ) // || !textureon)
8195
+ {
8196
+ return; // false;
8197
+ }
8198
+
8199
+ if (tex == null)
8200
+ {
8201
+ BindTexture(null,true,resolution);
8202
+ return;
8203
+ }
8204
+
8205
+ String bump = Object3D.GetBump(tex);
8206
+
8207
+ usedtextures.put(bump, bump);
8208
+
8209
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (bump.equals(""))
8216
+ {
8217
+ bump = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+ BindTexture(bump, true, resolution);
8222
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+ }
8224
+
8225
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8226
+
8227
+ private boolean FileExists(String tex)
8228
+ {
8229
+ if (missingTextures.contains(tex))
8230
+ {
8231
+ return false;
8232
+ }
8233
+
8234
+ boolean fileExists = new File(tex).exists();
8235
+
8236
+ if (!fileExists)
8237
+ {
8238
+ // If file exists, the "new File()" is not executed sgain
8239
+ missingTextures.add(tex);
8240
+ }
8241
+
8242
+ return fileExists;
8243
+ }
8244
+
8245
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80738246 {
80748247 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80758248
....@@ -8077,12 +8250,18 @@
80778250 {
80788251 String texname = tex;
80798252
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;
8253
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8254
+
8255
+// String[] split = tex.split("Textures");
8256
+// if (split.length > 1)
8257
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8258
+// else
8259
+// if (!texname.startsWith("/"))
8260
+// texname = "/Users/nbriere/Textures/" + texname;
8261
+ if (!FileExists(tex))
8262
+ {
8263
+ texname = fallbackTextureName;
8264
+ }
80868265
80878266 if (CACHETEXTURE)
80888267 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8151,7 +8330,7 @@
81518330 }
81528331
81538332 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8333
+ if (!FileExists(cachename))
81558334 cachename = texname;
81568335 else
81578336 processbump = false; // don't process bump map again
....@@ -8173,7 +8352,7 @@
81738352 }
81748353
81758354 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8355
+ if (!FileExists(cachename))
81778356 cachename = texname;
81788357 else
81798358 processbump = false; // don't process bump map again
....@@ -8182,7 +8361,9 @@
81828361 texturedata = GetFileTexture(cachename, processbump, resolution);
81838362
81848363
8185
- if (texturedata != null)
8364
+ if (texturedata == null)
8365
+ throw new Exception();
8366
+
81868367 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878368 //texture = GetTexture(tex, bump);
81888369 }
....@@ -8304,7 +8485,7 @@
83048485 return texture;
83058486 }
83068487
8307
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8488
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83088489 {
83098490 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108491
....@@ -8322,21 +8503,21 @@
83228503 return texture!=null?texture.texture:null;
83238504 }
83248505
8325
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8506
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83268507 {
83278508 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288509
83298510 return texture!=null?texture.texturedata:null;
83308511 }
83318512
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8513
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83338514 {
83348515 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358516 {
83368517 return false;
83378518 }
83388519
8339
- boolean newtex = false;
8520
+ //boolean newtex = false;
83408521
83418522 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83428523
....@@ -8368,7 +8549,7 @@
83688549 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83698550 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83708551
8371
- return newtex;
8552
+ return true; // Warning: not used.
83728553 }
83738554
83748555 ShadowBuffer shadowPBuf;
....@@ -9206,11 +9387,35 @@
92069387 jy8[3] = 0.5f;
92079388 }
92089389
9209
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9390
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92109391 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119392 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129393 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139394
9395
+ void ResetOptions()
9396
+ {
9397
+ options1[0] = 100;
9398
+ options1[1] = 0.025f;
9399
+ options1[2] = 0.01f;
9400
+ options1[3] = 0;
9401
+ options1[4] = 0;
9402
+
9403
+ options2[0] = 0;
9404
+ options2[1] = 0.75f;
9405
+ options2[2] = 0;
9406
+ options2[3] = 0;
9407
+
9408
+ options3[0] = 1;
9409
+ options3[1] = 1;
9410
+ options3[2] = 1;
9411
+ options3[3] = 0;
9412
+
9413
+ options4[0] = 1;
9414
+ options4[1] = 0;
9415
+ options4[2] = 1;
9416
+ options4[3] = 0;
9417
+ }
9418
+
92149419 static int imagecount = 0; // movie generation
92159420
92169421 static int jitter = 0;
....@@ -9306,8 +9511,8 @@
93069511 assert (parentcam != renderCamera);
93079512
93089513 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9514
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9515
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119516
93129517 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139518
....@@ -9322,8 +9527,8 @@
93229527 LA.matCopy(renderCamera.fromScreen, matrix);
93239528
93249529 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9530
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9531
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279532
93289533 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299534
....@@ -9395,7 +9600,7 @@
93959600 //gl.glFlush();
93969601 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979602
9398
- if (ANIMATION && ABORTED)
9603
+ if (Globals.ANIMATION && ABORTED)
93999604 {
94009605 System.err.println(" ABORTED FRAME");
94019606 break;
....@@ -9425,7 +9630,7 @@
94259630 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269631
94279632 // save image
9428
- if (ANIMATION && !ABORTED)
9633
+ if (Globals.ANIMATION && !ABORTED)
94299634 {
94309635 VPwidth = viewport[2];
94319636 VPheight = viewport[3];
....@@ -9536,11 +9741,11 @@
95369741
95379742 // imagecount++;
95389743
9539
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9744
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95409745
95419746 if (!BOXMODE)
95429747 {
9543
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9748
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95449749 }
95459750
95469751 if (!BOXMODE)
....@@ -9578,7 +9783,7 @@
95789783 ABORTED = false;
95799784 }
95809785 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9786
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829787
95839788 if (false)
95849789 {
....@@ -10241,11 +10446,11 @@
1024110446
1024210447 public void display(GLAutoDrawable drawable)
1024310448 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10449
+ if (Grafreed.savesound && Grafreed.hassound)
1024510450 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10451
+ Grafreed.wav.save();
10452
+ Grafreed.savesound = false;
10453
+ Grafreed.hassound = false;
1024910454 }
1025010455 // if (DEBUG_SELECTION)
1025110456 // {
....@@ -10321,6 +10526,7 @@
1032110526 ANTIALIAS = 0;
1032210527 //System.out.println("RESTART");
1032310528 AAtimer.restart();
10529
+ Globals.TIMERRUNNING = true;
1032410530 }
1032510531 }
1032610532 }
....@@ -10375,7 +10581,7 @@
1037510581 Object3D theobject = object;
1037610582 Object3D theparent = object.parent;
1037710583 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10584
+ object = (Object3D)Grafreed.clone(object);
1037910585 object.Stripify();
1038010586 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110587 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10594,14 @@
1038810594 ambientOcclusion = false;
1038910595 }
1039010596
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10597
+ if (//Globals.lighttouched &&
10598
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210599 {
1039310600 //if (RENDERSHADOW) // ?
1039410601 if (!IsFrozen())
1039510602 {
1039610603 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10604
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810605 {
1039910606 Globals.framecount++;
1040010607 shadowbuffer.display();
....@@ -10521,8 +10728,8 @@
1052110728
1052210729 // if (parentcam != renderCamera) // not a light
1052310730 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10731
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10732
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610733
1052710734 for (int j = 0; j < 4; j++)
1052810735 {
....@@ -10536,8 +10743,8 @@
1053610743
1053710744 // if (parentcam != renderCamera) // not a light
1053810745 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10746
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10747
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110748
1054210749 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310750
....@@ -10796,7 +11003,16 @@
1079611003 // Bump noise
1079711004 gl.glActiveTexture(GL.GL_TEXTURE6);
1079811005 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- BindTexture(NOISE_TEXTURE, false, 2);
11006
+
11007
+ try
11008
+ {
11009
+ BindTexture(NOISE_TEXTURE, false, 2);
11010
+ }
11011
+ catch (Exception e)
11012
+ {
11013
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11014
+ }
11015
+
1080011016
1080111017 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211018 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10819,9 +11035,9 @@
1081911035
1082011036 gl.glMatrixMode(GL.GL_MODELVIEW);
1082111037
10822
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10823
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10824
-//gl.glEnable(gl.GL_MULTISAMPLE);
11038
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11039
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11040
+gl.glEnable(gl.GL_MULTISAMPLE);
1082511041 } else
1082611042 {
1082711043 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10832,7 +11048,7 @@
1083211048 //System.out.println("BLENDING ON");
1083311049 gl.glEnable(GL.GL_BLEND);
1083411050 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10835
-
11051
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083611052 gl.glMatrixMode(gl.GL_PROJECTION);
1083711053 gl.glLoadIdentity();
1083811054
....@@ -10921,8 +11137,8 @@
1092111137 System.err.println("parentcam != renderCamera");
1092211138
1092311139 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11140
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11141
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092611142 }
1092711143
1092811144 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11159,8 @@
1094311159 if (true) // TODO
1094411160 {
1094511161 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11162
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11163
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094811164 }
1094911165
1095011166 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11476,14 @@
1126011476 {
1126111477 renderpass++;
1126211478 // System.out.println("Draw object... ");
11479
+ STEP = 1;
1126311480 if (FAST) // in case there is no script
11264
- STEP = 16;
11481
+ STEP = 8;
11482
+
11483
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11484
+ {
11485
+ STEP *= 4;
11486
+ }
1126511487
1126611488 //object.FullInvariants();
1126711489
....@@ -11275,23 +11497,44 @@
1127511497 e.printStackTrace();
1127611498 }
1127711499
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11500
+ if (Grafreed.RENDERME > 0)
11501
+ Grafreed.RENDERME--; // mechante magouille
1128011502
1128111503 Globals.ONESTEP = false;
1128211504 }
1128311505
1128411506 static boolean zoomonce = false;
1128511507
11508
+ static void CreateSelectedPoint()
11509
+ {
11510
+ if (selectedpoint == null)
11511
+ {
11512
+ debugpointG = new Sphere();
11513
+ debugpointP = new Sphere();
11514
+ debugpointC = new Sphere();
11515
+ debugpointR = new Sphere();
11516
+
11517
+ selectedpoint = new Superellipsoid();
11518
+
11519
+ for (int i=0; i<8; i++)
11520
+ {
11521
+ debugpoints[i] = new Sphere();
11522
+ }
11523
+ }
11524
+ }
11525
+
1128611526 void DrawObject(GL gl, boolean draw)
1128711527 {
11528
+ // To clear camera values
11529
+ ResetOptions();
11530
+
1128811531 //System.out.println("DRAW OBJECT " + mouseDown);
1128911532 // DrawMode() = SELECTION;
1129011533 //GL gl = getGL();
1129111534 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211535 {
1129311536 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11537
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511538 pingthread.StepToTarget(true); // true);
1129611539 // zoomonce = false;
1129711540 }
....@@ -11346,7 +11589,14 @@
1134611589
1134711590 usedtextures.clear();
1134811591
11349
- BindTextures(DEFAULT_TEXTURES, 2);
11592
+ try
11593
+ {
11594
+ BindTextures(DEFAULT_TEXTURES, 2);
11595
+ }
11596
+ catch (Exception e)
11597
+ {
11598
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11599
+ }
1135011600 }
1135111601 //System.out.println("--> " + stackdepth);
1135211602 // GrafreeD.traceon();
....@@ -11356,8 +11606,9 @@
1135611606
1135711607 if (DrawMode() == DEFAULT)
1135811608 {
11359
- if (DEBUG)
11609
+ if (Globals.DEBUG)
1136011610 {
11611
+ CreateSelectedPoint();
1136111612 float radius = 0.05f;
1136211613 if (selectedpoint.radius != radius)
1136311614 {
....@@ -11437,7 +11688,14 @@
1143711688 if (checker != null && DrawMode() == DEFAULT)
1143811689 {
1143911690 //BindTexture(IMMORTAL_TEXTURE);
11440
- BindTextures(checker.GetTextures(), checker.texres);
11691
+ try
11692
+ {
11693
+ BindTextures(checker.GetTextures(), checker.texres);
11694
+ }
11695
+ catch (Exception e)
11696
+ {
11697
+ System.err.println("FAILED: " + checker.GetTextures());
11698
+ }
1144111699 // NEAREST
1144211700 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311701 DrawChecker(gl);
....@@ -11519,7 +11777,7 @@
1151911777 return;
1152011778 }
1152111779
11522
- String string = obj.GetToolTip();
11780
+ String string = obj.toString(); //.GetToolTip();
1152311781
1152411782 GL gl = GetGL();
1152511783
....@@ -11836,8 +12094,8 @@
1183612094 //obj.TransformToWorld(light, light);
1183712095 for (int i = tp.size(); --i >= 0;)
1183812096 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- LA.xformPos(light, tp.get(i).toParent, light);
12097
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12098
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184112099 }
1184212100
1184312101
....@@ -11854,8 +12112,8 @@
1185412112 parentcam = cameras[0];
1185512113 }
1185612114
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12115
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12116
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185912117
1186012118 LA.xformPos(light, renderCamera.toScreen, light);
1186112119
....@@ -12469,8 +12727,8 @@
1246912727
1247012728 // display shadow only (bump == 0)
1247112729 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12730
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12731
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412732 "SUB temp.y, one.x, temp.z;" +
1247512733 "MUL temp.x, temp.x, temp.y;" +
1247612734 "KIL temp.x;" +
....@@ -12599,8 +12857,10 @@
1259912857 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012858
1260112859 "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
12860
+ // Tuning for default skin
12861
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12862
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12863
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260412864 "MUL temp.x, temp.x, temp.y;" +
1260512865
1260612866 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13008,7 @@
1274813008 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913009 "FLR final.x, final.y;" +
1275013010 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13011
+ "MUL final.x, final.x, c256i;" +
1275213012 "MOV final.z, zero.x;" +
1275313013 "MOV final.a, one.w;":""
1275413014 ) +
....@@ -12756,7 +13016,7 @@
1275613016 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713017 "FLR final.x, final.y;" +
1275813018 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13019
+ "MUL final.x, final.x, c256i;" +
1276013020 "MOV final.z, zero.x;" +
1276113021 "MOV final.a, one.w;":""
1276213022 ) +
....@@ -12799,7 +13059,7 @@
1279913059 //once = true;
1280013060 }
1280113061
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13062
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313063 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413064 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513065
....@@ -12932,12 +13192,16 @@
1293213192
1293313193 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413194 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13195
+
13196
+ // Compare fragment depth in light space with shadowmap.
1293513197 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613198 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13199
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13200
+
13201
+ // Reverse comparison
1293813202 "SUB temp.x, one.x, temp.x;" +
1293913203 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13204
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113205 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213206
1294313207 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13215,10 @@
1295113215 // No shadow for backface
1295213216 "DP3 temp.x, normal, lightd;" +
1295313217 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13218
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13219
+
13220
+ // No shadow when out of frustrum
13221
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295413222 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513223 "";
1295613224 }
....@@ -13097,7 +13365,8 @@
1309713365 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813366 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913367 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13368
+
13369
+ //Object3D.cVector2[] vector2buffer;
1310113370
1310213371 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313372 // OUT : diff, spec
....@@ -13113,9 +13382,10 @@
1311313382 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413383 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513384 //"MOV " + dest + ".w," + "normal.z;" +
13116
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13117
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13118
- //"MOV " + dest + ".z," + "params2.w;" +
13385
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13386
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13387
+
13388
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1311913389 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013390 "RCP " + dest + ".w," + dest + ".w;" +
1312113391 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13779,7 @@
1350913779 public void mousePressed(MouseEvent e)
1351013780 {
1351113781 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13782
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313783 }
1351413784
1351513785 static long prevtime = 0;
....@@ -13585,8 +13855,8 @@
1358513855 // mode |= META;
1358613856 //}
1358713857
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13858
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13859
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013860 anchorX = ax;
1359113861 anchorY = ay;
1359213862 prevX = px;
....@@ -13620,6 +13890,7 @@
1362013890 else
1362113891 if (evt.getSource() == AAtimer)
1362213892 {
13893
+ Globals.TIMERRUNNING = false;
1362313894 if (mouseDown)
1362413895 {
1362513896 //new Exception().printStackTrace();
....@@ -13645,6 +13916,10 @@
1364513916 // LIVE = waslive;
1364613917 // wasliveok = true;
1364713918 // waslive = false;
13919
+
13920
+ // May 2019 Forget it:
13921
+ if (true)
13922
+ return;
1364813923
1364913924 // source == timer
1365013925 if (mouseDown)
....@@ -13675,7 +13950,7 @@
1367513950
1367613951 // fev 2014???
1367713952 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13953
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367913954 pingthread.StepToTarget(true); // true);
1368013955 }
1368113956 // if (!LIVE)
....@@ -13684,12 +13959,13 @@
1368413959
1368513960 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368613961
13687
- void clickStart(int x, int y, int modifiers)
13962
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368813963 {
1368913964 if (!wasliveok)
1369013965 return;
1369113966
1369213967 AAtimer.restart(); //
13968
+ Globals.TIMERRUNNING = true;
1369313969
1369413970 // waslive = LIVE;
1369513971 // LIVE = false;
....@@ -13701,7 +13977,7 @@
1370113977 // touched = true; // main DL
1370213978 if (isRenderer)
1370313979 {
13704
- SetMouseMode(modifiers);
13980
+ SetMouseMode(modifiers, modifiersex);
1370513981 }
1370613982
1370713983 selectX = anchorX = x;
....@@ -13714,7 +13990,7 @@
1371413990 clicked = true;
1371513991 hold = false;
1371613992
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13993
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371813994 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371913995 {
1372013996 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14021,7 @@
1374514021 info.camera = renderCamera;
1374614022 info.x = x;
1374714023 info.y = y;
13748
- info.modifiers = modifiers;
14024
+ info.modifiers = modifiersex;
1374914025 editObj = object.doEditClick(info, 0);
1375014026 if (!editObj)
1375114027 {
....@@ -13762,9 +14038,12 @@
1376214038
1376314039 public void mouseDragged(MouseEvent e)
1376414040 {
14041
+ Globals.MOUSEDRAGGED = true;
14042
+
1376514043 //System.out.println("mouseDragged: " + e);
1376614044 if (isRenderer)
1376714045 movingcamera = true;
14046
+
1376814047 //if (drawing)
1376914048 //return;
1377014049 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14053,7 @@
1377414053 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514054 }
1377614055 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14056
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814057
1377914058 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014059 }
....@@ -14011,7 +14290,7 @@
1401114290 {
1401214291 Globals.lighttouched = true;
1401314292 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14293
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514294 }
1401614295 //else
1401714296 }
....@@ -14025,12 +14304,12 @@
1402514304 void GoDown(int mod)
1402614305 {
1402714306 MODIFIERS |= COMMAND;
14028
- /*
14307
+ /**/
1402914308 if((mod&SHIFT) == SHIFT)
1403014309 manipCamera.RotatePosition(0, -speed);
1403114310 else
14032
- manipCamera.BackForth(0, -speed*delta, getWidth());
14033
- */
14311
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14312
+ /**/
1403414313 if ((mod & SHIFT) == SHIFT)
1403514314 {
1403614315 mouseMode = mouseMode; // VR??
....@@ -14046,12 +14325,12 @@
1404614325 void GoUp(int mod)
1404714326 {
1404814327 MODIFIERS |= COMMAND;
14049
- /*
14328
+ /**/
1405014329 if((mod&SHIFT) == SHIFT)
1405114330 manipCamera.RotatePosition(0, speed);
1405214331 else
14053
- manipCamera.BackForth(0, speed*delta, getWidth());
14054
- */
14332
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14333
+ /**/
1405514334 if ((mod & SHIFT) == SHIFT)
1405614335 {
1405714336 mouseMode = mouseMode;
....@@ -14067,12 +14346,12 @@
1406714346 void GoLeft(int mod)
1406814347 {
1406914348 MODIFIERS |= COMMAND;
14070
- /*
14349
+ /**/
1407114350 if((mod&SHIFT) == SHIFT)
14072
- manipCamera.RotatePosition(speed, 0);
14073
- else
1407414351 manipCamera.Translate(speed*delta, 0, getWidth());
14075
- */
14352
+ else
14353
+ manipCamera.RotatePosition(speed, 0);
14354
+ /**/
1407614355 if ((mod & SHIFT) == SHIFT)
1407714356 {
1407814357 mouseMode = mouseMode;
....@@ -14088,12 +14367,12 @@
1408814367 void GoRight(int mod)
1408914368 {
1409014369 MODIFIERS |= COMMAND;
14091
- /*
14370
+ /**/
1409214371 if((mod&SHIFT) == SHIFT)
14093
- manipCamera.RotatePosition(-speed, 0);
14094
- else
1409514372 manipCamera.Translate(-speed*delta, 0, getWidth());
14096
- */
14373
+ else
14374
+ manipCamera.RotatePosition(-speed, 0);
14375
+ /**/
1409714376 if ((mod & SHIFT) == SHIFT)
1409814377 {
1409914378 mouseMode = mouseMode;
....@@ -14111,7 +14390,7 @@
1411114390 int X, Y;
1411214391 boolean SX, SY;
1411314392
14114
- void drag(int x, int y, int modifiers)
14393
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514394 {
1411614395 if (IsFrozen())
1411714396 {
....@@ -14120,17 +14399,17 @@
1412014399
1412114400 drag = true; // NEW
1412214401
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14402
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414403
1412514404 X = x;
1412614405 Y = y;
1412714406 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14407
+ MODIFIERS = modifiersex;
14408
+ modifiersex &= ~1024;
1413014409 if (false) // modifiers != 0)
1413114410 {
1413214411 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14412
+ System.out.println("mouseDragged: " + modifiersex);
1413414413 System.out.println("SHIFT = " + SHIFT);
1413514414 System.out.println("CONTROL = " + COMMAND);
1413614415 System.out.println("META = " + META);
....@@ -14150,7 +14429,8 @@
1415014429 info.camera = renderCamera;
1415114430 info.x = x;
1415214431 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14432
+ object.GetWindow().copy
14433
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414434 } else
1415514435 {
1415614436 if (x < startX)
....@@ -14314,7 +14594,9 @@
1431414594 ci.camera = renderCamera;
1431514595 if (!isRenderer)
1431614596 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14597
+ //ObjEditor editWindow = object.editWindow;
14598
+ //Object3D copy = editWindow.copy;
14599
+ if (object.doEditClick(ci, 0))
1431814600 {
1431914601 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014602 } else
....@@ -14326,7 +14608,11 @@
1432614608
1432714609 public void mouseReleased(MouseEvent e)
1432814610 {
14611
+ Globals.MOUSEDRAGGED = false;
14612
+
1432914613 movingcamera = false;
14614
+ X = 0; // getBounds().width/2;
14615
+ Y = 0; // getBounds().height/2;
1433014616 //System.out.println("mouseReleased: " + e);
1433114617 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214618 }
....@@ -14349,9 +14635,9 @@
1434914635 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014636 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114637
14352
- if (control || command || IsFrozen())
14638
+// No delay if (control || command || IsFrozen())
1435314639 timeout = true;
14354
- else
14640
+// ?? May 2019 else
1435514641 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614642 mouseDown = false;
1435714643 if (!control && !command) // june 2013
....@@ -14461,7 +14747,7 @@
1446114747 System.out.println("keyReleased: " + e);
1446214748 }
1446314749
14464
- void SetMouseMode(int modifiers)
14750
+ void SetMouseMode(int modifiers, int modifiersex)
1446514751 {
1446614752 //System.out.println("SetMouseMode = " + modifiers);
1446714753 //modifiers &= ~1024;
....@@ -14473,25 +14759,25 @@
1447314759 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414760 // return;
1447514761 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14762
+ if ((modifiersex & WHEEL) == WHEEL)
1447714763 {
1447814764 mouseMode |= ZOOM;
1447914765 }
1448014766
1448114767 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14768
+ if (capsLocked) // || (modifiers & META) == META)
1448314769 {
1448414770 mouseMode |= VR; // BACKFORTH;
1448514771 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14772
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714773 {
1448814774 mouseMode |= SELECT;
1448914775 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14776
+ if ((modifiersex & COMMAND) == COMMAND)
1449114777 {
1449214778 mouseMode |= SELECT;
1449314779 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14780
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514781 {
1449614782 mouseMode &= ~VR;
1449714783 mouseMode |= TRANSLATE;
....@@ -14520,7 +14806,7 @@
1452014806
1452114807 if (isRenderer) //
1452214808 {
14523
- SetMouseMode(modifiers);
14809
+ SetMouseMode(0, modifiers);
1452414810 }
1452514811
1452614812 Globals.theRenderer.keyPressed(key);
....@@ -14667,7 +14953,9 @@
1466714953 case 'E' : COMPACT ^= true;
1466814954 repaint();
1466914955 break;
14670
- case 'W' : DEBUGHSB ^= true;
14956
+ case 'W' : // Wide Window (fullscreen)
14957
+ //DEBUGHSB ^= true;
14958
+ ObjEditor.theFrame.ToggleFullScreen();
1467114959 repaint();
1467214960 break;
1467314961 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14692,8 +14980,8 @@
1469214980 RevertCamera();
1469314981 repaint();
1469414982 break;
14695
- case 'L':
1469614983 case 'l':
14984
+ //case 'L':
1469714985 if (lightMode)
1469814986 {
1469914987 lightMode = false;
....@@ -14836,9 +15124,9 @@
1483615124 case '_':
1483715125 kompactbit = 5;
1483815126 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15127
+// case '+':
15128
+// kompactbit = 6;
15129
+// break;
1484215130 case ' ':
1484315131 lightMode ^= true;
1484415132 Globals.lighttouched = true;
....@@ -14850,13 +15138,14 @@
1485015138 case ESC:
1485115139 RENDERPROGRAM += 1;
1485215140 RENDERPROGRAM %= 3;
15141
+
1485315142 repaint();
1485415143 break;
1485515144 case 'Z':
1485615145 //RESIZETEXTURE ^= true;
1485715146 //break;
1485815147 case 'z':
14859
- RENDERSHADOW ^= true;
15148
+ Globals.RENDERSHADOW ^= true;
1486015149 Globals.lighttouched = true;
1486115150 repaint();
1486215151 break;
....@@ -14889,8 +15178,9 @@
1488915178 case DELETE:
1489015179 ClearSelection();
1489115180 break;
14892
- /*
1489315181 case '+':
15182
+
15183
+ /*
1489415184 //fontsize += 1;
1489515185 bbzoom *= 2;
1489615186 repaint();
....@@ -14907,17 +15197,17 @@
1490715197 case '=':
1490815198 IncDepth();
1490915199 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15200
+ object.GetWindow().refreshContents(true);
1491115201 maskbit = 6;
1491215202 break;
1491315203 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415204 DecDepth();
1491515205 maskbit = 5;
1491615206 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15207
+// if (object.editWindow == null)
15208
+// new Exception().printStackTrace();
15209
+// else
15210
+ object.GetWindow().refreshContents(true);
1492115211 break;
1492215212 case '{':
1492315213 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15270,7 @@
1498015270 //mode = ROTATE;
1498115271 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215272 {
14983
- SetMouseMode(modifiers);
15273
+ SetMouseMode(0, modifiers);
1498415274 }
1498515275 }
1498615276
....@@ -15116,7 +15406,7 @@
1511615406 {
1511715407 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815408 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15409
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512015410 {
1512115411 mouseMoved(e);
1512215412 } else
....@@ -15141,7 +15431,7 @@
1514115431 }
1514215432 */
1514315433
15144
- object.editWindow.EditSelection();
15434
+ object.GetWindow().EditSelection(false);
1514515435 }
1514615436
1514715437 void SelectParent()
....@@ -15158,10 +15448,10 @@
1515815448 {
1515915449 //selectees.remove(i);
1516015450 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15451
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215452 } else
1516315453 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15454
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515455 }
1516615456
1516715457 first = false;
....@@ -15203,12 +15493,12 @@
1520315493 for (int j = 0; j < group.children.size(); j++)
1520415494 {
1520515495 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15496
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715497 first = false;
1520815498 }
1520915499 } else
1521015500 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15501
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215502 }
1521315503
1521415504 first = false;
....@@ -15219,21 +15509,21 @@
1521915509 {
1522015510 //Composite group = (Composite) object;
1522115511 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15512
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315513 }
1522415514
1522515515 void ResetTransform(int mask)
1522615516 {
1522715517 //Composite group = (Composite) object;
1522815518 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15519
+ group.GetWindow().ResetTransform(mask);
1523015520 }
1523115521
1523215522 void FlipTransform()
1523315523 {
1523415524 //Composite group = (Composite) object;
1523515525 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15526
+ group.GetWindow().FlipTransform();
1523715527 // group.editWindow.ReduceMesh(true);
1523815528 }
1523915529
....@@ -15241,7 +15531,7 @@
1524115531 {
1524215532 //Composite group = (Composite) object;
1524315533 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15534
+ group.GetWindow().PrintMemory();
1524515535 // group.editWindow.ReduceMesh(true);
1524615536 }
1524715537
....@@ -15249,7 +15539,7 @@
1524915539 {
1525015540 //Composite group = (Composite) object;
1525115541 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15542
+ group.GetWindow().ResetCentroid();
1525315543 }
1525415544
1525515545 void IncDepth()
....@@ -15335,7 +15625,9 @@
1533515625 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615626 //Image img = CreateImage(width, height);
1533715627 //System.out.println("width = " + width + "; height = " + height + "\n");
15628
+
1533815629 Graphics gr = g; // img.getGraphics();
15630
+
1533915631 if (!hasMarquee)
1534015632 {
1534115633 if (Xmin < Xmax) // !locked)
....@@ -15423,6 +15715,7 @@
1542315715 info.bounds.y += (height - desired) / 2;
1542415716 }
1542515717 }
15718
+
1542615719 info.g = gr;
1542715720 info.camera = renderCamera;
1542815721 /*
....@@ -15432,15 +15725,55 @@
1543215725 */
1543315726 if (!isRenderer)
1543415727 {
15435
- object.drawEditHandles(info, 0);
15728
+ Grafreed.Assert(object != null);
15729
+ Grafreed.Assert(object.selection != null);
15730
+ if (object.selection.Size() > 0)
15731
+ {
15732
+ int hitSomething = object.selection.get(0).hitSomething;
15733
+
15734
+ info.DX = 0;
15735
+ info.DY = 0;
15736
+ info.W = 1;
15737
+ if (hitSomething == Object3D.hitCenter)
15738
+ {
15739
+ info.DX = X;
15740
+ if (X != 0)
15741
+ info.DX -= info.bounds.width/2;
15742
+
15743
+ info.DY = Y;
15744
+ if (Y != 0)
15745
+ info.DY -= info.bounds.height/2;
15746
+ }
15747
+
15748
+ object.drawEditHandles(info, 0);
15749
+
15750
+ if (drag && (X != 0 || Y != 0))
15751
+ {
15752
+ switch (hitSomething)
15753
+ {
15754
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15755
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15756
+ break;
15757
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15758
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15759
+ break;
15760
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15761
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15762
+ break;
15763
+ }
15764
+
15765
+ }
15766
+ }
1543615767 }
1543715768 }
15769
+
1543815770 if (isRenderer)
1543915771 {
1544015772 //gr.setColor(Color.black);
1544115773 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215774 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315775 }
15776
+
1544415777 if (hasMarquee)
1544515778 {
1544615779 gr.setXORMode(Color.white);
....@@ -15553,6 +15886,7 @@
1555315886 public boolean mouseDown(Event evt, int x, int y)
1555415887 {
1555515888 System.out.println("mouseDown: " + evt);
15889
+ System.exit(0);
1555615890 /*
1555715891 locked = true;
1555815892 drag = false;
....@@ -15596,7 +15930,7 @@
1559615930 {
1559715931 keyPressed(0, modifiers);
1559815932 }
15599
- clickStart(x, y, modifiers);
15933
+ // clickStart(x, y, modifiers);
1560015934 return true;
1560115935 }
1560215936
....@@ -15714,7 +16048,7 @@
1571416048 {
1571516049 keyReleased(0, 0);
1571616050 }
15717
- drag(x, y, modifiers);
16051
+ drag(x, y, 0, modifiers);
1571816052 return true;
1571916053 }
1572016054
....@@ -15846,7 +16180,7 @@
1584616180 Object3D object;
1584716181 static Object3D trackedobject;
1584816182 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16183
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016184 /*static*/ Camera eyeCamera;
1585116185 /*static*/ Camera lightCamera;
1585216186 int cameracount;
....@@ -16131,16 +16465,16 @@
1613116465 cStatic.objectstack[materialdepth++] = checker;
1613216466 //System.out.println("material " + material);
1613316467 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16468
+ //vector2buffer = checker.projectedVertices;
1613516469
1613616470 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16471
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816472
1613916473 materialdepth -= 1;
1614016474 if (materialdepth > 0)
1614116475 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16476
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16477
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614416478 }
1614516479 //checker.GetMaterial().opacity = 1f;
1614616480 ////checker.GetMaterial().ambient = 1f;
....@@ -16226,6 +16560,14 @@
1622616560 }
1622716561 }
1622816562
16563
+ private Object3D GetFolder()
16564
+ {
16565
+ Object3D folder = object.GetWindow().copy;
16566
+ if (object.GetWindow().copy.selection.Size() > 0)
16567
+ folder = object.GetWindow().copy.selection.elementAt(0);
16568
+ return folder;
16569
+ }
16570
+
1622916571 class SelectBuffer implements GLEventListener
1623016572 {
1623116573
....@@ -16305,6 +16647,17 @@
1630516647
1630616648 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630716649
16650
+ if (PAINTMODE)
16651
+ {
16652
+ if (object.GetWindow().copy.selection.Size() > 0)
16653
+ {
16654
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16655
+
16656
+ // Make what you paint not selectable.
16657
+ paintobj.ResetSelectable();
16658
+ }
16659
+ }
16660
+
1630816661 //int tmp = selection_view;
1630916662 //selection_view = -1;
1631016663 int temp = DrawMode();
....@@ -16316,6 +16669,17 @@
1631616669 // temp = DEFAULT; // patch for selection debug
1631716670 Globals.drawMode = temp; // WARNING
1631816671
16672
+ if (PAINTMODE)
16673
+ {
16674
+ if (object.GetWindow().copy.selection.Size() > 0)
16675
+ {
16676
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16677
+
16678
+ // Revert.
16679
+ paintobj.RestoreSelectable();
16680
+ }
16681
+ }
16682
+
1631916683 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632016684
1632116685 // trying different ways of getting the depth info over
....@@ -16363,6 +16727,8 @@
1636316727 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1636416728 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516729 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16730
+
16731
+ CreateSelectedPoint();
1636616732
1636716733 // Will fit the mesh !!!
1636816734 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16412,34 +16778,36 @@
1641216778 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]));
1641316779 }
1641416780
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16781
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616782 }
1641716783 }
1641816784
1641916785 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16786
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116787
16422
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16788
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642316789 {
16424
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16790
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642516791
16426
- Object3D group = new Object3D("inst" + paintcount++);
16792
+ if (object.GetWindow().copy.selection.Size() > 0)
16793
+ {
16794
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642716795
16428
- group.CreateMaterial(); // use a void leaf to select instances
16429
-
16430
- group.add(paintobj); // link
16431
-
16432
- object.editWindow.SnapObject(group);
16433
-
16434
- Object3D folder = object.editWindow.copy;
16435
-
16436
- if (object.editWindow.copy.selection.Size() > 0)
16437
- folder = object.editWindow.copy.selection.elementAt(0);
16438
-
16439
- folder.add(group);
16440
-
16441
- object.editWindow.ResetModel();
16442
- object.editWindow.refreshContents();
16796
+ Object3D inst = new Object3D("inst" + paintcount++);
16797
+
16798
+ inst.CreateMaterial(); // use a void leaf to select instances
16799
+
16800
+ inst.add(paintobj); // link
16801
+
16802
+ object.GetWindow().SnapObject(inst);
16803
+
16804
+ Object3D folder = paintFolder; // GetFolder();
16805
+
16806
+ folder.add(inst);
16807
+
16808
+ object.GetWindow().ResetModel();
16809
+ object.GetWindow().refreshContents();
16810
+ }
1644316811 }
1644416812 else
1644516813 paintcount = 0;
....@@ -16478,6 +16846,11 @@
1647816846 //System.out.println("objects[color] = " + objects[color]);
1647916847 //objects[color].Select();
1648016848 indexcount = 0;
16849
+ ObjEditor window = object.GetWindow();
16850
+ if (window != null && deselect)
16851
+ {
16852
+ window.Select(null, deselect, true);
16853
+ }
1648116854 object.Select(color, deselect);
1648216855 }
1648316856
....@@ -16577,7 +16950,7 @@
1657716950 gl.glDisable(gl.GL_CULL_FACE);
1657816951 }
1657916952
16580
- if (!RENDERSHADOW)
16953
+ if (!Globals.RENDERSHADOW)
1658116954 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216955
1658316956 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +16960,7 @@
1658716960 //gl.glColorMask(false, false, false, false);
1658816961
1658916962 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16963
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659116964 {
1659216965 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659316966
....@@ -17003,23 +17376,15 @@
1700317376 int AAbuffersize = 0;
1700417377
1700517378 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17379
+ static Superellipsoid selectedpoint;
1700717380 static Sphere previousselectedpoint = null;
17008
- static Sphere debugpointG = new Sphere();
17009
- static Sphere debugpointP = new Sphere();
17010
- static Sphere debugpointC = new Sphere();
17011
- static Sphere debugpointR = new Sphere();
17381
+ static Sphere debugpointG;
17382
+ static Sphere debugpointP;
17383
+ static Sphere debugpointC;
17384
+ static Sphere debugpointR;
1701217385
1701317386 static Sphere debugpoints[] = new Sphere[8];
1701417387
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317388 static void InitPoints(float radius)
1702417389 {
1702517390 for (int i=0; i<8; i++)