Normand Briere
2019-06-25 ecff440ceef3ad352aa64cedbb913107ec4863a5
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
....@@ -106,7 +105,7 @@
106105 static boolean OEIL = true;
107106 static boolean OEILONCE = false; // do oeilon then oeiloff
108107 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
110109 static boolean HANDLES = false; // selection doesn't work!!
111110 static boolean PAINTMODE = false;
112111
....@@ -149,6 +148,8 @@
149148 defaultcaps.setAccumBlueBits(16);
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152153
153154 void SetAsGLRenderer(boolean b)
154155 {
....@@ -325,7 +326,7 @@
325326 cStatic.objectstack[materialdepth++] = obj;
326327 //System.out.println("material " + material);
327328 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
329330 if (obj instanceof Camera)
330331 {
331332 display.options1[0] = material.shift;
....@@ -357,7 +358,7 @@
357358 /**/
358359 } else
359360 {
360
- DrawMaterial(material, selected);
361
+ DrawMaterial(material, selected, obj.projectedVertices);
361362 }
362363 } else
363364 {
....@@ -381,8 +382,8 @@
381382 cStatic.objectstack[materialdepth++] = obj;
382383 //System.out.println("material " + material);
383384 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
385
+ //display.vector2buffer = obj.projectedVertices;
386
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386387 }
387388 }
388389
....@@ -399,8 +400,8 @@
399400 materialdepth -= 1;
400401 if (materialdepth > 0)
401402 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
403
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
404
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
404405 }
405406 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406407 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +421,8 @@
420421 materialdepth -= 1;
421422 if (materialdepth > 0)
422423 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
424
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
425
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
425426 }
426427 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427428 //else
....@@ -462,10 +463,12 @@
462463 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463464 {
464465 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
466
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
467
+ // TEST LIVE NORMALS && !obj.dontselect
468
+ ;
466469 if (!hasnorm)
467470 {
468
- // System.out.println("FUCK!!");
471
+ // System.out.println("Mesh normal");
469472 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470473 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471474 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1193,12 @@
11901193 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911194 }
11921195 }
1196
+
11931197 if (flipV)
11941198 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951199 else
11961200 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1201
+
11971202 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981203 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991204
....@@ -1213,10 +1218,12 @@
12131218 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141219 }
12151220 }
1221
+
12161222 if (flipV)
12171223 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181224 else
12191225 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1226
+
12201227 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211228 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221229
....@@ -1244,8 +1251,10 @@
12441251 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451252 else
12461253 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1254
+
12471255 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481256 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1257
+
12491258 count2 += 2;
12501259 count3 += 3;
12511260 }
....@@ -1601,7 +1610,7 @@
16011610 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021611 }
16031612
1604
- void DrawMaterial(cMaterial material, boolean selected)
1613
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051614 {
16061615 CameraPane display = this;
16071616 //new Exception().printStackTrace();
....@@ -1628,7 +1637,7 @@
16281637
16291638 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301639
1631
- float[] colorV = GrafreeD.colorV;
1640
+ float[] colorV = Grafreed.colorV;
16321641
16331642 /**/
16341643 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1645,7 @@
16361645 colorV[0] = display.modelParams0[0] * material.diffuse;
16371646 colorV[1] = display.modelParams0[1] * material.diffuse;
16381647 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1648
+ colorV[3] = 1; // material.opacity;
16401649
16411650 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421651 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1753,9 @@
17441753 display.modelParams7[2] = 0;
17451754 display.modelParams7[3] = 0;
17461755
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1756
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481757
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1758
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501759 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511760 {
17521761 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1897,7 @@
18881897 void PushMatrix(double[][] matrix)
18891898 {
18901899 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1900
+ PushMatrix(matrix, 1);
18921901 }
18931902
18941903 void PushMatrix()
....@@ -2140,7 +2149,7 @@
21402149 System.err.println("LIVE = " + Globals.isLIVE());
21412150
21422151 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2152
+ Grafreed.savesound = true; // wav.save();
21442153 // else
21452154 repaint(); // start loop // may 2013
21462155 }
....@@ -2257,7 +2266,7 @@
22572266
22582267 void ToggleDebug()
22592268 {
2260
- DEBUG ^= true;
2269
+ Globals.DEBUG ^= true;
22612270 }
22622271
22632272 void ToggleLookAt()
....@@ -2265,9 +2274,9 @@
22652274 LOOKAT ^= true;
22662275 }
22672276
2268
- void ToggleRandom()
2277
+ void ToggleSwitch()
22692278 {
2270
- RANDOM ^= true;
2279
+ SWITCH ^= true;
22712280 }
22722281
22732282 void ToggleHandles()
....@@ -2374,7 +2383,7 @@
23742383 {
23752384 return currentGL;
23762385 }
2377
-
2386
+
23782387 /**/
23792388 class CacheTexture
23802389 {
....@@ -7919,6 +7928,64 @@
79197928 ReleaseTexture(pigment, false);
79207929 }
79217930
7931
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7932
+ {
7933
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7934
+ {
7935
+ return;
7936
+ }
7937
+
7938
+ if (tex == null)
7939
+ {
7940
+ ReleaseTexture(null, false);
7941
+ return;
7942
+ }
7943
+
7944
+ String pigment = Object3D.GetPigment(tex);
7945
+
7946
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7947
+ {
7948
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7949
+ // System.out.println("; bump = " + bump);
7950
+ }
7951
+
7952
+ if (pigment.equals(""))
7953
+ {
7954
+ pigment = null;
7955
+ }
7956
+
7957
+ ReleaseTexture(pigment, false);
7958
+ }
7959
+
7960
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7961
+ {
7962
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7963
+ {
7964
+ return;
7965
+ }
7966
+
7967
+ if (tex == null)
7968
+ {
7969
+ ReleaseTexture(null, true);
7970
+ return;
7971
+ }
7972
+
7973
+ String bump = Object3D.GetBump(tex);
7974
+
7975
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7976
+ {
7977
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7978
+ // System.out.println("; bump = " + bump);
7979
+ }
7980
+
7981
+ if (bump.equals(""))
7982
+ {
7983
+ bump = null;
7984
+ }
7985
+
7986
+ ReleaseTexture(bump, true);
7987
+ }
7988
+
79227989 void ReleaseTexture(String tex, boolean bump)
79237990 {
79247991 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8089,7 @@
80228089 }
80238090 }
80248091
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8092
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268093 {
80278094 if (// DrawMode() != 0 || /*tex == null ||*/
80288095 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8134,94 @@
80678134 return; // true;
80688135 }
80698136
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8137
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8138
+ {
8139
+ if (// DrawMode() != 0 || /*tex == null ||*/
8140
+ ambientOcclusion ) // || !textureon)
8141
+ {
8142
+ return; // false;
8143
+ }
8144
+
8145
+ if (tex == null)
8146
+ {
8147
+ BindTexture(null,false,resolution);
8148
+ return;
8149
+ }
8150
+
8151
+ String pigment = Object3D.GetPigment(tex);
8152
+
8153
+ usedtextures.put(pigment, pigment);
8154
+
8155
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8156
+ {
8157
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8158
+ // System.out.println("; bump = " + bump);
8159
+ }
8160
+
8161
+ if (pigment.equals(""))
8162
+ {
8163
+ pigment = null;
8164
+ }
8165
+
8166
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8167
+ BindTexture(pigment, false, resolution);
8168
+ }
8169
+
8170
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8171
+ {
8172
+ if (// DrawMode() != 0 || /*tex == null ||*/
8173
+ ambientOcclusion ) // || !textureon)
8174
+ {
8175
+ return; // false;
8176
+ }
8177
+
8178
+ if (tex == null)
8179
+ {
8180
+ BindTexture(null,true,resolution);
8181
+ return;
8182
+ }
8183
+
8184
+ String bump = Object3D.GetBump(tex);
8185
+
8186
+ usedtextures.put(bump, bump);
8187
+
8188
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8189
+ {
8190
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8191
+ // System.out.println("; bump = " + bump);
8192
+ }
8193
+
8194
+ if (bump.equals(""))
8195
+ {
8196
+ bump = null;
8197
+ }
8198
+
8199
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8200
+ BindTexture(bump, true, resolution);
8201
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8202
+ }
8203
+
8204
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8205
+
8206
+ private boolean FileExists(String tex)
8207
+ {
8208
+ if (missingTextures.contains(tex))
8209
+ {
8210
+ return false;
8211
+ }
8212
+
8213
+ boolean fileExists = new File(tex).exists();
8214
+
8215
+ if (!fileExists)
8216
+ {
8217
+ // If file exists, the "new File()" is not executed sgain
8218
+ missingTextures.add(tex);
8219
+ }
8220
+
8221
+ return fileExists;
8222
+ }
8223
+
8224
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718225 {
80728226 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738227
....@@ -8075,12 +8229,18 @@
80758229 {
80768230 String texname = tex;
80778231
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- texname = "/Users/nbriere/Textures/" + texname;
8232
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8233
+
8234
+// String[] split = tex.split("Textures");
8235
+// if (split.length > 1)
8236
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8237
+// else
8238
+// if (!texname.startsWith("/"))
8239
+// texname = "/Users/nbriere/Textures/" + texname;
8240
+ if (!FileExists(tex))
8241
+ {
8242
+ texname = fallbackTextureName;
8243
+ }
80848244
80858245 if (CACHETEXTURE)
80868246 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8149,7 +8309,7 @@
81498309 }
81508310
81518311 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8312
+ if (!FileExists(cachename))
81538313 cachename = texname;
81548314 else
81558315 processbump = false; // don't process bump map again
....@@ -8171,7 +8331,7 @@
81718331 }
81728332
81738333 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8334
+ if (!FileExists(cachename))
81758335 cachename = texname;
81768336 else
81778337 processbump = false; // don't process bump map again
....@@ -8180,7 +8340,9 @@
81808340 texturedata = GetFileTexture(cachename, processbump, resolution);
81818341
81828342
8183
- if (texturedata != null)
8343
+ if (texturedata == null)
8344
+ throw new Exception();
8345
+
81848346 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81858347 //texture = GetTexture(tex, bump);
81868348 }
....@@ -8302,7 +8464,7 @@
83028464 return texture;
83038465 }
83048466
8305
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8467
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83068468 {
83078469 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83088470
....@@ -8320,14 +8482,14 @@
83208482 return texture!=null?texture.texture:null;
83218483 }
83228484
8323
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8485
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83248486 {
83258487 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83268488
83278489 return texture!=null?texture.texturedata:null;
83288490 }
83298491
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8492
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83318493 {
83328494 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338495 {
....@@ -9204,11 +9366,35 @@
92049366 jy8[3] = 0.5f;
92059367 }
92069368
9207
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9369
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92089370 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92099371 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92109372 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92119373
9374
+ void ResetOptions()
9375
+ {
9376
+ options1[0] = 100;
9377
+ options1[1] = 0.00001f;
9378
+ options1[2] = 20;
9379
+ options1[3] = 0;
9380
+ options1[4] = 0;
9381
+
9382
+ options2[0] = 0;
9383
+ options2[1] = 1;
9384
+ options2[2] = 0;
9385
+ options2[3] = 0;
9386
+
9387
+ options3[0] = 1;
9388
+ options3[1] = 1;
9389
+ options3[2] = 1;
9390
+ options3[3] = 0;
9391
+
9392
+ options4[0] = 1;
9393
+ options4[1] = 0;
9394
+ options4[2] = 1;
9395
+ options4[3] = 0;
9396
+ }
9397
+
92129398 static int imagecount = 0; // movie generation
92139399
92149400 static int jitter = 0;
....@@ -9304,8 +9490,8 @@
93049490 assert (parentcam != renderCamera);
93059491
93069492 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9493
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9494
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099495
93109496 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119497
....@@ -9320,8 +9506,8 @@
93209506 LA.matCopy(renderCamera.fromScreen, matrix);
93219507
93229508 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9509
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9510
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259511
93269512 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279513
....@@ -9538,7 +9724,7 @@
95389724
95399725 if (!BOXMODE)
95409726 {
9541
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9727
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95429728 }
95439729
95449730 if (!BOXMODE)
....@@ -9576,7 +9762,7 @@
95769762 ABORTED = false;
95779763 }
95789764 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9765
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809766
95819767 if (false)
95829768 {
....@@ -10239,11 +10425,11 @@
1023910425
1024010426 public void display(GLAutoDrawable drawable)
1024110427 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10428
+ if (Grafreed.savesound && Grafreed.hassound)
1024310429 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10430
+ Grafreed.wav.save();
10431
+ Grafreed.savesound = false;
10432
+ Grafreed.hassound = false;
1024710433 }
1024810434 // if (DEBUG_SELECTION)
1024910435 // {
....@@ -10319,6 +10505,7 @@
1031910505 ANTIALIAS = 0;
1032010506 //System.out.println("RESTART");
1032110507 AAtimer.restart();
10508
+ Globals.TIMERRUNNING = true;
1032210509 }
1032310510 }
1032410511 }
....@@ -10373,7 +10560,7 @@
1037310560 Object3D theobject = object;
1037410561 Object3D theparent = object.parent;
1037510562 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10563
+ object = (Object3D)Grafreed.clone(object);
1037710564 object.Stripify();
1037810565 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910566 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10573,14 @@
1038610573 ambientOcclusion = false;
1038710574 }
1038810575
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10576
+ if (//Globals.lighttouched &&
10577
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010578 {
1039110579 //if (RENDERSHADOW) // ?
1039210580 if (!IsFrozen())
1039310581 {
1039410582 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10583
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610584 {
1039710585 Globals.framecount++;
1039810586 shadowbuffer.display();
....@@ -10519,8 +10707,8 @@
1051910707
1052010708 // if (parentcam != renderCamera) // not a light
1052110709 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10710
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10711
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410712
1052510713 for (int j = 0; j < 4; j++)
1052610714 {
....@@ -10534,8 +10722,8 @@
1053410722
1053510723 // if (parentcam != renderCamera) // not a light
1053610724 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10725
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10726
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910727
1054010728 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110729
....@@ -10794,7 +10982,16 @@
1079410982 // Bump noise
1079510983 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610984 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- BindTexture(NOISE_TEXTURE, false, 2);
10985
+
10986
+ try
10987
+ {
10988
+ BindTexture(NOISE_TEXTURE, false, 2);
10989
+ }
10990
+ catch (Exception e)
10991
+ {
10992
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10993
+ }
10994
+
1079810995
1079910996 gl.glActiveTexture(GL.GL_TEXTURE0);
1080010997 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +11116,8 @@
1091911116 System.err.println("parentcam != renderCamera");
1092011117
1092111118 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11119
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11120
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092411121 }
1092511122
1092611123 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11138,8 @@
1094111138 if (true) // TODO
1094211139 {
1094311140 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11141
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11142
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094611143 }
1094711144
1094811145 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,16 +11476,37 @@
1127911476 e.printStackTrace();
1128011477 }
1128111478
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11479
+ if (Grafreed.RENDERME > 0)
11480
+ Grafreed.RENDERME--; // mechante magouille
1128411481
1128511482 Globals.ONESTEP = false;
1128611483 }
1128711484
1128811485 static boolean zoomonce = false;
1128911486
11487
+ static void CreateSelectedPoint()
11488
+ {
11489
+ if (selectedpoint == null)
11490
+ {
11491
+ debugpointG = new Sphere();
11492
+ debugpointP = new Sphere();
11493
+ debugpointC = new Sphere();
11494
+ debugpointR = new Sphere();
11495
+
11496
+ selectedpoint = new Superellipsoid();
11497
+
11498
+ for (int i=0; i<8; i++)
11499
+ {
11500
+ debugpoints[i] = new Sphere();
11501
+ }
11502
+ }
11503
+ }
11504
+
1129011505 void DrawObject(GL gl, boolean draw)
1129111506 {
11507
+ // To clear camera values
11508
+ ResetOptions();
11509
+
1129211510 //System.out.println("DRAW OBJECT " + mouseDown);
1129311511 // DrawMode() = SELECTION;
1129411512 //GL gl = getGL();
....@@ -11350,7 +11568,14 @@
1135011568
1135111569 usedtextures.clear();
1135211570
11353
- BindTextures(DEFAULT_TEXTURES, 2);
11571
+ try
11572
+ {
11573
+ BindTextures(DEFAULT_TEXTURES, 2);
11574
+ }
11575
+ catch (Exception e)
11576
+ {
11577
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11578
+ }
1135411579 }
1135511580 //System.out.println("--> " + stackdepth);
1135611581 // GrafreeD.traceon();
....@@ -11360,8 +11585,9 @@
1136011585
1136111586 if (DrawMode() == DEFAULT)
1136211587 {
11363
- if (DEBUG)
11588
+ if (Globals.DEBUG)
1136411589 {
11590
+ CreateSelectedPoint();
1136511591 float radius = 0.05f;
1136611592 if (selectedpoint.radius != radius)
1136711593 {
....@@ -11441,7 +11667,14 @@
1144111667 if (checker != null && DrawMode() == DEFAULT)
1144211668 {
1144311669 //BindTexture(IMMORTAL_TEXTURE);
11444
- BindTextures(checker.GetTextures(), checker.texres);
11670
+ try
11671
+ {
11672
+ BindTextures(checker.GetTextures(), checker.texres);
11673
+ }
11674
+ catch (Exception e)
11675
+ {
11676
+ System.err.println("FAILED: " + checker.GetTextures());
11677
+ }
1144511678 // NEAREST
1144611679 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711680 DrawChecker(gl);
....@@ -11523,7 +11756,7 @@
1152311756 return;
1152411757 }
1152511758
11526
- String string = obj.GetToolTip();
11759
+ String string = obj.toString(); //.GetToolTip();
1152711760
1152811761 GL gl = GetGL();
1152911762
....@@ -11840,8 +12073,8 @@
1184012073 //obj.TransformToWorld(light, light);
1184112074 for (int i = tp.size(); --i >= 0;)
1184212075 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- LA.xformPos(light, tp.get(i).toParent, light);
12076
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12077
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184512078 }
1184612079
1184712080
....@@ -11858,8 +12091,8 @@
1185812091 parentcam = cameras[0];
1185912092 }
1186012093
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12094
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12095
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186312096
1186412097 LA.xformPos(light, renderCamera.toScreen, light);
1186512098
....@@ -12473,8 +12706,8 @@
1247312706
1247412707 // display shadow only (bump == 0)
1247512708 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12709
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12710
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812711 "SUB temp.y, one.x, temp.z;" +
1247912712 "MUL temp.x, temp.x, temp.y;" +
1248012713 "KIL temp.x;" +
....@@ -12603,8 +12836,10 @@
1260312836 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260412837
1260512838 "SUB temp.x, one.x, ndotl.x;" +
12606
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12607
- "ADD temp.y, one.y, options2.y;" + // sursurface
12839
+ // Tuning for default skin
12840
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12841
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12842
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260812843 "MUL temp.x, temp.x, temp.y;" +
1260912844
1261012845 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12752,7 +12987,7 @@
1275212987 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275312988 "FLR final.x, final.y;" +
1275412989 "SUB final.y, final.y, final.x;" +
12755
- //"MUL final.x, final.x, c256i;" +
12990
+ "MUL final.x, final.x, c256i;" +
1275612991 "MOV final.z, zero.x;" +
1275712992 "MOV final.a, one.w;":""
1275812993 ) +
....@@ -12760,7 +12995,7 @@
1276012995 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276112996 "FLR final.x, final.y;" +
1276212997 "SUB final.y, final.y, final.x;" +
12763
- //"MUL final.x, final.x, c256i;" +
12998
+ "MUL final.x, final.x, c256i;" +
1276412999 "MOV final.z, zero.x;" +
1276513000 "MOV final.a, one.w;":""
1276613001 ) +
....@@ -12803,7 +13038,7 @@
1280313038 //once = true;
1280413039 }
1280513040
12806
- System.out.print("Program #" + mode + "; length = " + program.length());
13041
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280713042 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280813043 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280913044
....@@ -12936,12 +13171,16 @@
1293613171
1293713172 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293813173 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13174
+
13175
+ // Compare fragment depth in light space with shadowmap.
1293913176 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294013177 "SGE temp.y, temp.x, zero.x;" +
12941
- "SUB " + shadow + ".y, one.x, temp.y;" +
13178
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13179
+
13180
+ // Reverse comparison
1294213181 "SUB temp.x, one.x, temp.x;" +
1294313182 "MUL " + shadow + ".x, temp.x, temp.y;" +
12944
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13183
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294513184 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294613185
1294713186 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12955,6 +13194,10 @@
1295513194 // No shadow for backface
1295613195 "DP3 temp.x, normal, lightd;" +
1295713196 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13197
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13198
+
13199
+ // No shadow when out of frustrum
13200
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295813201 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295913202 "";
1296013203 }
....@@ -13101,7 +13344,8 @@
1310113344 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310213345 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310313346 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13104
- Object3D.cVector2[] vector2buffer;
13347
+
13348
+ //Object3D.cVector2[] vector2buffer;
1310513349
1310613350 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310713351 // OUT : diff, spec
....@@ -13513,7 +13757,7 @@
1351313757 public void mousePressed(MouseEvent e)
1351413758 {
1351513759 //System.out.println("mousePressed: " + e);
13516
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13760
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351713761 }
1351813762
1351913763 static long prevtime = 0;
....@@ -13589,8 +13833,8 @@
1358913833 // mode |= META;
1359013834 //}
1359113835
13592
- SetMouseMode(WHEEL | e.getModifiersEx());
13593
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13836
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13837
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359413838 anchorX = ax;
1359513839 anchorY = ay;
1359613840 prevX = px;
....@@ -13624,6 +13868,7 @@
1362413868 else
1362513869 if (evt.getSource() == AAtimer)
1362613870 {
13871
+ Globals.TIMERRUNNING = false;
1362713872 if (mouseDown)
1362813873 {
1362913874 //new Exception().printStackTrace();
....@@ -13649,6 +13894,10 @@
1364913894 // LIVE = waslive;
1365013895 // wasliveok = true;
1365113896 // waslive = false;
13897
+
13898
+ // May 2019 Forget it:
13899
+ if (true)
13900
+ return;
1365213901
1365313902 // source == timer
1365413903 if (mouseDown)
....@@ -13688,12 +13937,13 @@
1368813937
1368913938 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369013939
13691
- void clickStart(int x, int y, int modifiers)
13940
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369213941 {
1369313942 if (!wasliveok)
1369413943 return;
1369513944
1369613945 AAtimer.restart(); //
13946
+ Globals.TIMERRUNNING = true;
1369713947
1369813948 // waslive = LIVE;
1369913949 // LIVE = false;
....@@ -13705,7 +13955,7 @@
1370513955 // touched = true; // main DL
1370613956 if (isRenderer)
1370713957 {
13708
- SetMouseMode(modifiers);
13958
+ SetMouseMode(modifiers, modifiersex);
1370913959 }
1371013960
1371113961 selectX = anchorX = x;
....@@ -13718,7 +13968,7 @@
1371813968 clicked = true;
1371913969 hold = false;
1372013970
13721
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13971
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372213972 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372313973 {
1372413974 // System.out.println("RESTART II " + modifiers);
....@@ -13749,7 +13999,7 @@
1374913999 info.camera = renderCamera;
1375014000 info.x = x;
1375114001 info.y = y;
13752
- info.modifiers = modifiers;
14002
+ info.modifiers = modifiersex;
1375314003 editObj = object.doEditClick(info, 0);
1375414004 if (!editObj)
1375514005 {
....@@ -13766,9 +14016,12 @@
1376614016
1376714017 public void mouseDragged(MouseEvent e)
1376814018 {
14019
+ Globals.MOUSEDRAGGED = true;
14020
+
1376914021 //System.out.println("mouseDragged: " + e);
1377014022 if (isRenderer)
1377114023 movingcamera = true;
14024
+
1377214025 //if (drawing)
1377314026 //return;
1377414027 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13778,7 +14031,7 @@
1377814031 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377914032 }
1378014033 else
13781
- drag(e.getX(), e.getY(), e.getModifiersEx());
14034
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378214035
1378314036 //try { Thread.sleep(1); } catch (Exception ex) {}
1378414037 }
....@@ -14015,7 +14268,7 @@
1401514268 {
1401614269 Globals.lighttouched = true;
1401714270 }
14018
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14271
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401914272 }
1402014273 //else
1402114274 }
....@@ -14115,7 +14368,7 @@
1411514368 int X, Y;
1411614369 boolean SX, SY;
1411714370
14118
- void drag(int x, int y, int modifiers)
14371
+ void drag(int x, int y, int modifiers, int modifiersex)
1411914372 {
1412014373 if (IsFrozen())
1412114374 {
....@@ -14124,17 +14377,17 @@
1412414377
1412514378 drag = true; // NEW
1412614379
14127
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14380
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412814381
1412914382 X = x;
1413014383 Y = y;
1413114384 // floating state for animation
14132
- MODIFIERS = modifiers;
14133
- modifiers &= ~1024;
14385
+ MODIFIERS = modifiersex;
14386
+ modifiersex &= ~1024;
1413414387 if (false) // modifiers != 0)
1413514388 {
1413614389 //new Exception().printStackTrace();
14137
- System.out.println("mouseDragged: " + modifiers);
14390
+ System.out.println("mouseDragged: " + modifiersex);
1413814391 System.out.println("SHIFT = " + SHIFT);
1413914392 System.out.println("CONTROL = " + COMMAND);
1414014393 System.out.println("META = " + META);
....@@ -14154,7 +14407,8 @@
1415414407 info.camera = renderCamera;
1415514408 info.x = x;
1415614409 info.y = y;
14157
- object.editWindow.copy.doEditDrag(info);
14410
+ object.GetWindow().copy
14411
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415814412 } else
1415914413 {
1416014414 if (x < startX)
....@@ -14318,7 +14572,9 @@
1431814572 ci.camera = renderCamera;
1431914573 if (!isRenderer)
1432014574 {
14321
- if (object.editWindow.copy.doEditClick(ci, 0))
14575
+ //ObjEditor editWindow = object.editWindow;
14576
+ //Object3D copy = editWindow.copy;
14577
+ if (object.doEditClick(ci, 0))
1432214578 {
1432314579 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432414580 } else
....@@ -14330,7 +14586,10 @@
1433014586
1433114587 public void mouseReleased(MouseEvent e)
1433214588 {
14589
+ Globals.MOUSEDRAGGED = false;
14590
+
1433314591 movingcamera = false;
14592
+ X = Y = 0;
1433414593 //System.out.println("mouseReleased: " + e);
1433514594 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433614595 }
....@@ -14353,9 +14612,9 @@
1435314612 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435414613 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435514614
14356
- if (control || command || IsFrozen())
14615
+// No delay if (control || command || IsFrozen())
1435714616 timeout = true;
14358
- else
14617
+// ?? May 2019 else
1435914618 // timer.setDelay((modifiers & 128) != 0?0:350);
1436014619 mouseDown = false;
1436114620 if (!control && !command) // june 2013
....@@ -14465,7 +14724,7 @@
1446514724 System.out.println("keyReleased: " + e);
1446614725 }
1446714726
14468
- void SetMouseMode(int modifiers)
14727
+ void SetMouseMode(int modifiers, int modifiersex)
1446914728 {
1447014729 //System.out.println("SetMouseMode = " + modifiers);
1447114730 //modifiers &= ~1024;
....@@ -14477,25 +14736,25 @@
1447714736 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447814737 // return;
1447914738 //System.out.println("SetMode = " + modifiers);
14480
- if ((modifiers & WHEEL) == WHEEL)
14739
+ if ((modifiersex & WHEEL) == WHEEL)
1448114740 {
1448214741 mouseMode |= ZOOM;
1448314742 }
1448414743
1448514744 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14486
- if (capsLocked || (modifiers & META) == META)
14745
+ if (capsLocked) // || (modifiers & META) == META)
1448714746 {
1448814747 mouseMode |= VR; // BACKFORTH;
1448914748 }
14490
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14749
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449114750 {
1449214751 mouseMode |= SELECT;
1449314752 }
14494
- if ((modifiers & COMMAND) == COMMAND)
14753
+ if ((modifiersex & COMMAND) == COMMAND)
1449514754 {
1449614755 mouseMode |= SELECT;
1449714756 }
14498
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14757
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449914758 {
1450014759 mouseMode &= ~VR;
1450114760 mouseMode |= TRANSLATE;
....@@ -14524,7 +14783,7 @@
1452414783
1452514784 if (isRenderer) //
1452614785 {
14527
- SetMouseMode(modifiers);
14786
+ SetMouseMode(0, modifiers);
1452814787 }
1452914788
1453014789 Globals.theRenderer.keyPressed(key);
....@@ -14696,8 +14955,14 @@
1469614955 RevertCamera();
1469714956 repaint();
1469814957 break;
14699
- case 'L':
1470014958 case 'l':
14959
+ lightMode ^= true;
14960
+ Globals.lighttouched = true;
14961
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14962
+ targetLookAt.set(manipCamera.lookAt);
14963
+ repaint();
14964
+ break;
14965
+ case 'L':
1470114966 if (lightMode)
1470214967 {
1470314968 lightMode = false;
....@@ -14844,23 +15109,21 @@
1484415109 kompactbit = 6;
1484515110 break;
1484615111 case ' ':
14847
- lightMode ^= true;
14848
- Globals.lighttouched = true;
14849
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14850
- targetLookAt.set(manipCamera.lookAt);
15112
+ ObjEditor.theFrame.ToggleFullScreen();
1485115113 repaint();
1485215114 break;
1485315115 //case '`' :
1485415116 case ESC:
1485515117 RENDERPROGRAM += 1;
1485615118 RENDERPROGRAM %= 3;
15119
+
1485715120 repaint();
1485815121 break;
1485915122 case 'Z':
1486015123 //RESIZETEXTURE ^= true;
1486115124 //break;
1486215125 case 'z':
14863
- RENDERSHADOW ^= true;
15126
+ Globals.RENDERSHADOW ^= true;
1486415127 Globals.lighttouched = true;
1486515128 repaint();
1486615129 break;
....@@ -14984,7 +15247,7 @@
1498415247 //mode = ROTATE;
1498515248 if ((MODIFIERS & COMMAND) == 0) // VR??
1498615249 {
14987
- SetMouseMode(modifiers);
15250
+ SetMouseMode(0, modifiers);
1498815251 }
1498915252 }
1499015253
....@@ -15120,7 +15383,7 @@
1512015383 {
1512115384 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512215385 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15123
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15386
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512415387 {
1512515388 mouseMoved(e);
1512615389 } else
....@@ -15145,7 +15408,7 @@
1514515408 }
1514615409 */
1514715410
15148
- object.editWindow.EditSelection();
15411
+ object.editWindow.EditSelection(false);
1514915412 }
1515015413
1515115414 void SelectParent()
....@@ -15339,7 +15602,9 @@
1533915602 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534015603 //Image img = CreateImage(width, height);
1534115604 //System.out.println("width = " + width + "; height = " + height + "\n");
15605
+
1534215606 Graphics gr = g; // img.getGraphics();
15607
+
1534315608 if (!hasMarquee)
1534415609 {
1534515610 if (Xmin < Xmax) // !locked)
....@@ -15437,14 +15702,33 @@
1543715702 if (!isRenderer)
1543815703 {
1543915704 object.drawEditHandles(info, 0);
15705
+
15706
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15707
+ {
15708
+ switch (object.selection.get(0).hitSomething)
15709
+ {
15710
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15711
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15712
+ break;
15713
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15714
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15715
+ break;
15716
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15717
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15718
+ break;
15719
+ }
15720
+
15721
+ }
1544015722 }
1544115723 }
15724
+
1544215725 if (isRenderer)
1544315726 {
1544415727 //gr.setColor(Color.black);
1544515728 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544615729 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544715730 }
15731
+
1544815732 if (hasMarquee)
1544915733 {
1545015734 gr.setXORMode(Color.white);
....@@ -15557,6 +15841,7 @@
1555715841 public boolean mouseDown(Event evt, int x, int y)
1555815842 {
1555915843 System.out.println("mouseDown: " + evt);
15844
+ System.exit(0);
1556015845 /*
1556115846 locked = true;
1556215847 drag = false;
....@@ -15600,7 +15885,7 @@
1560015885 {
1560115886 keyPressed(0, modifiers);
1560215887 }
15603
- clickStart(x, y, modifiers);
15888
+ // clickStart(x, y, modifiers);
1560415889 return true;
1560515890 }
1560615891
....@@ -15718,7 +16003,7 @@
1571816003 {
1571916004 keyReleased(0, 0);
1572016005 }
15721
- drag(x, y, modifiers);
16006
+ drag(x, y, 0, modifiers);
1572216007 return true;
1572316008 }
1572416009
....@@ -15850,7 +16135,7 @@
1585016135 Object3D object;
1585116136 static Object3D trackedobject;
1585216137 Camera renderCamera; // Light or Eye (or Occlusion)
15853
- /*static*/ Camera manipCamera; // Light or Eye
16138
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585416139 /*static*/ Camera eyeCamera;
1585516140 /*static*/ Camera lightCamera;
1585616141 int cameracount;
....@@ -16135,16 +16420,16 @@
1613516420 cStatic.objectstack[materialdepth++] = checker;
1613616421 //System.out.println("material " + material);
1613716422 //Applet3D.tracein(this, selected);
16138
- vector2buffer = checker.projectedVertices;
16423
+ //vector2buffer = checker.projectedVertices;
1613916424
1614016425 //checker.GetMaterial().Draw(this, false); // true);
16141
- DrawMaterial(checker.GetMaterial(), false); // true);
16426
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614216427
1614316428 materialdepth -= 1;
1614416429 if (materialdepth > 0)
1614516430 {
16146
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16147
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16431
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16432
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614816433 }
1614916434 //checker.GetMaterial().opacity = 1f;
1615016435 ////checker.GetMaterial().ambient = 1f;
....@@ -16368,6 +16653,8 @@
1636816653 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636916654 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1637016655
16656
+ CreateSelectedPoint();
16657
+
1637116658 // Will fit the mesh !!!
1637216659 selectedpoint.toParent[0][0] = 0.0001;
1637316660 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16416,16 +16703,16 @@
1641616703 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]));
1641716704 }
1641816705
16419
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16706
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642016707 }
1642116708 }
1642216709
1642316710 if (!movingcamera && !PAINTMODE)
1642416711 object.editWindow.ScreenFitPoint(); // fev 2014
1642516712
16426
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16713
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642716714 {
16428
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16715
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642916716
1643016717 Object3D group = new Object3D("inst" + paintcount++);
1643116718
....@@ -16581,7 +16868,7 @@
1658116868 gl.glDisable(gl.GL_CULL_FACE);
1658216869 }
1658316870
16584
- if (!RENDERSHADOW)
16871
+ if (!Globals.RENDERSHADOW)
1658516872 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658616873
1658716874 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16591,7 +16878,7 @@
1659116878 //gl.glColorMask(false, false, false, false);
1659216879
1659316880 //render_scene_from_light_view(gl, drawable, 0, 0);
16594
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16881
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659516882 {
1659616883 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716884
....@@ -17007,23 +17294,15 @@
1700717294 int AAbuffersize = 0;
1700817295
1700917296 //double[] selectedpoint = new double[3];
17010
- static Superellipsoid selectedpoint = new Superellipsoid();
17297
+ static Superellipsoid selectedpoint;
1701117298 static Sphere previousselectedpoint = null;
17012
- static Sphere debugpointG = new Sphere();
17013
- static Sphere debugpointP = new Sphere();
17014
- static Sphere debugpointC = new Sphere();
17015
- static Sphere debugpointR = new Sphere();
17299
+ static Sphere debugpointG;
17300
+ static Sphere debugpointP;
17301
+ static Sphere debugpointC;
17302
+ static Sphere debugpointR;
1701617303
1701717304 static Sphere debugpoints[] = new Sphere[8];
1701817305
17019
- static
17020
- {
17021
- for (int i=0; i<8; i++)
17022
- {
17023
- debugpoints[i] = new Sphere();
17024
- }
17025
- }
17026
-
1702717306 static void InitPoints(float radius)
1702817307 {
1702917308 for (int i=0; i<8; i++)