Normand Briere
2019-06-26 89b25e7cc97f6fe221dfd41c4d463500f8a31bc1
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;
....@@ -334,14 +335,28 @@
334335 display.options1[2] = material.shadowbias;
335336 display.options1[3] = material.aniso;
336337 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]);
337343 display.options2[0] = material.opacity;
338344 display.options2[1] = material.diffuse;
339345 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]);
340349
341350 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]);
342354 display.options4[0] = material.cameralight/0.2f;
343355 display.options4[1] = material.subsurface;
344356 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]);
345360
346361 // if (display.CURRENTANTIALIAS > 0)
347362 // display.options3[3] /= 4;
....@@ -357,7 +372,7 @@
357372 /**/
358373 } else
359374 {
360
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
361376 }
362377 } else
363378 {
....@@ -381,8 +396,8 @@
381396 cStatic.objectstack[materialdepth++] = obj;
382397 //System.out.println("material " + material);
383398 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386401 }
387402 }
388403
....@@ -399,8 +414,8 @@
399414 materialdepth -= 1;
400415 if (materialdepth > 0)
401416 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- 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);
404419 }
405420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +435,8 @@
420435 materialdepth -= 1;
421436 if (materialdepth > 0)
422437 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- 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);
425440 }
426441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427442 //else
....@@ -462,10 +477,12 @@
462477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463478 {
464479 //gl.glBegin(gl.GL_TRIANGLES);
465
- 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
+ ;
466483 if (!hasnorm)
467484 {
468
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
469486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1207,12 @@
11901207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911208 }
11921209 }
1210
+
11931211 if (flipV)
11941212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951213 else
11961214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11971216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991218
....@@ -1213,10 +1232,12 @@
12131232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141233 }
12151234 }
1235
+
12161236 if (flipV)
12171237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181238 else
12191239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12201241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221243
....@@ -1244,8 +1265,10 @@
12441265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451266 else
12461267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12471269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12491272 count2 += 2;
12501273 count3 += 3;
12511274 }
....@@ -1601,7 +1624,7 @@
16011624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021625 }
16031626
1604
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051628 {
16061629 CameraPane display = this;
16071630 //new Exception().printStackTrace();
....@@ -1628,7 +1651,7 @@
16281651
16291652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301653
1631
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16321655
16331656 /**/
16341657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1659,7 @@
16361659 colorV[0] = display.modelParams0[0] * material.diffuse;
16371660 colorV[1] = display.modelParams0[1] * material.diffuse;
16381661 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16401663
16411664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421665 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1767,9 @@
17441767 display.modelParams7[2] = 0;
17451768 display.modelParams7[3] = 0;
17461769
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481771
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511774 {
17521775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1911,7 @@
18881911 void PushMatrix(double[][] matrix)
18891912 {
18901913 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18921915 }
18931916
18941917 void PushMatrix()
....@@ -2140,7 +2163,7 @@
21402163 System.err.println("LIVE = " + Globals.isLIVE());
21412164
21422165 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21442167 // else
21452168 repaint(); // start loop // may 2013
21462169 }
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,9 +2288,9 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
2270
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22712294 }
22722295
22732296 void ToggleHandles()
....@@ -2374,7 +2397,7 @@
23742397 {
23752398 return currentGL;
23762399 }
2377
-
2400
+
23782401 /**/
23792402 class CacheTexture
23802403 {
....@@ -7919,6 +7942,64 @@
79197942 ReleaseTexture(pigment, false);
79207943 }
79217944
7945
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7946
+ {
7947
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7948
+ {
7949
+ return;
7950
+ }
7951
+
7952
+ if (tex == null)
7953
+ {
7954
+ ReleaseTexture(null, false);
7955
+ return;
7956
+ }
7957
+
7958
+ String pigment = Object3D.GetPigment(tex);
7959
+
7960
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7961
+ {
7962
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7963
+ // System.out.println("; bump = " + bump);
7964
+ }
7965
+
7966
+ if (pigment.equals(""))
7967
+ {
7968
+ pigment = null;
7969
+ }
7970
+
7971
+ ReleaseTexture(pigment, false);
7972
+ }
7973
+
7974
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
7975
+ {
7976
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7977
+ {
7978
+ return;
7979
+ }
7980
+
7981
+ if (tex == null)
7982
+ {
7983
+ ReleaseTexture(null, true);
7984
+ return;
7985
+ }
7986
+
7987
+ String bump = Object3D.GetBump(tex);
7988
+
7989
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7990
+ {
7991
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
7992
+ // System.out.println("; bump = " + bump);
7993
+ }
7994
+
7995
+ if (bump.equals(""))
7996
+ {
7997
+ bump = null;
7998
+ }
7999
+
8000
+ ReleaseTexture(bump, true);
8001
+ }
8002
+
79228003 void ReleaseTexture(String tex, boolean bump)
79238004 {
79248005 if (// DrawMode() != 0 || /*tex == null ||*/
....@@ -8022,7 +8103,7 @@
80228103 }
80238104 }
80248105
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8106
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80268107 {
80278108 if (// DrawMode() != 0 || /*tex == null ||*/
80288109 ambientOcclusion ) // || !textureon)
....@@ -8067,7 +8148,94 @@
80678148 return; // true;
80688149 }
80698150
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8151
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8152
+ {
8153
+ if (// DrawMode() != 0 || /*tex == null ||*/
8154
+ ambientOcclusion ) // || !textureon)
8155
+ {
8156
+ return; // false;
8157
+ }
8158
+
8159
+ if (tex == null)
8160
+ {
8161
+ BindTexture(null,false,resolution);
8162
+ return;
8163
+ }
8164
+
8165
+ String pigment = Object3D.GetPigment(tex);
8166
+
8167
+ usedtextures.put(pigment, pigment);
8168
+
8169
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8170
+ {
8171
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8172
+ // System.out.println("; bump = " + bump);
8173
+ }
8174
+
8175
+ if (pigment.equals(""))
8176
+ {
8177
+ pigment = null;
8178
+ }
8179
+
8180
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8181
+ BindTexture(pigment, false, resolution);
8182
+ }
8183
+
8184
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8185
+ {
8186
+ if (// DrawMode() != 0 || /*tex == null ||*/
8187
+ ambientOcclusion ) // || !textureon)
8188
+ {
8189
+ return; // false;
8190
+ }
8191
+
8192
+ if (tex == null)
8193
+ {
8194
+ BindTexture(null,true,resolution);
8195
+ return;
8196
+ }
8197
+
8198
+ String bump = Object3D.GetBump(tex);
8199
+
8200
+ usedtextures.put(bump, bump);
8201
+
8202
+ if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8203
+ {
8204
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8205
+ // System.out.println("; bump = " + bump);
8206
+ }
8207
+
8208
+ if (bump.equals(""))
8209
+ {
8210
+ bump = null;
8211
+ }
8212
+
8213
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8214
+ BindTexture(bump, true, resolution);
8215
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8216
+ }
8217
+
8218
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8219
+
8220
+ private boolean FileExists(String tex)
8221
+ {
8222
+ if (missingTextures.contains(tex))
8223
+ {
8224
+ return false;
8225
+ }
8226
+
8227
+ boolean fileExists = new File(tex).exists();
8228
+
8229
+ if (!fileExists)
8230
+ {
8231
+ // If file exists, the "new File()" is not executed sgain
8232
+ missingTextures.add(tex);
8233
+ }
8234
+
8235
+ return fileExists;
8236
+ }
8237
+
8238
+ CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
80718239 {
80728240 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
80738241
....@@ -8075,12 +8243,18 @@
80758243 {
80768244 String texname = tex;
80778245
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;
8246
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8247
+
8248
+// String[] split = tex.split("Textures");
8249
+// if (split.length > 1)
8250
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8251
+// else
8252
+// if (!texname.startsWith("/"))
8253
+// texname = "/Users/nbriere/Textures/" + texname;
8254
+ if (!FileExists(tex))
8255
+ {
8256
+ texname = fallbackTextureName;
8257
+ }
80848258
80858259 if (CACHETEXTURE)
80868260 texture = textures.get(texname); // TEXTURE CACHE
....@@ -8149,7 +8323,7 @@
81498323 }
81508324
81518325 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8326
+ if (!FileExists(cachename))
81538327 cachename = texname;
81548328 else
81558329 processbump = false; // don't process bump map again
....@@ -8171,7 +8345,7 @@
81718345 }
81728346
81738347 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8348
+ if (!FileExists(cachename))
81758349 cachename = texname;
81768350 else
81778351 processbump = false; // don't process bump map again
....@@ -8180,7 +8354,9 @@
81808354 texturedata = GetFileTexture(cachename, processbump, resolution);
81818355
81828356
8183
- if (texturedata != null)
8357
+ if (texturedata == null)
8358
+ throw new Exception();
8359
+
81848360 texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81858361 //texture = GetTexture(tex, bump);
81868362 }
....@@ -8302,7 +8478,7 @@
83028478 return texture;
83038479 }
83048480
8305
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8481
+ com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
83068482 {
83078483 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83088484
....@@ -8320,14 +8496,14 @@
83208496 return texture!=null?texture.texture:null;
83218497 }
83228498
8323
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8499
+ public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
83248500 {
83258501 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83268502
83278503 return texture!=null?texture.texturedata:null;
83288504 }
83298505
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8506
+ boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
83318507 {
83328508 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338509 {
....@@ -9204,11 +9380,35 @@
92049380 jy8[3] = 0.5f;
92059381 }
92069382
9207
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9383
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92089384 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92099385 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92109386 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92119387
9388
+ void ResetOptions()
9389
+ {
9390
+ options1[0] = 100;
9391
+ options1[1] = 0.025f;
9392
+ options1[2] = 0.01f;
9393
+ options1[3] = 0;
9394
+ options1[4] = 0;
9395
+
9396
+ options2[0] = 0;
9397
+ options2[1] = 0.75f;
9398
+ options2[2] = 0;
9399
+ options2[3] = 0;
9400
+
9401
+ options3[0] = 1;
9402
+ options3[1] = 1;
9403
+ options3[2] = 1;
9404
+ options3[3] = 0;
9405
+
9406
+ options4[0] = 1;
9407
+ options4[1] = 0;
9408
+ options4[2] = 1;
9409
+ options4[3] = 0;
9410
+ }
9411
+
92129412 static int imagecount = 0; // movie generation
92139413
92149414 static int jitter = 0;
....@@ -9304,8 +9504,8 @@
93049504 assert (parentcam != renderCamera);
93059505
93069506 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9507
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9508
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099509
93109510 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119511
....@@ -9320,8 +9520,8 @@
93209520 LA.matCopy(renderCamera.fromScreen, matrix);
93219521
93229522 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9523
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9524
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259525
93269526 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279527
....@@ -9538,7 +9738,7 @@
95389738
95399739 if (!BOXMODE)
95409740 {
9541
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9741
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95429742 }
95439743
95449744 if (!BOXMODE)
....@@ -9576,7 +9776,7 @@
95769776 ABORTED = false;
95779777 }
95789778 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9779
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809780
95819781 if (false)
95829782 {
....@@ -10239,11 +10439,11 @@
1023910439
1024010440 public void display(GLAutoDrawable drawable)
1024110441 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10442
+ if (Grafreed.savesound && Grafreed.hassound)
1024310443 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10444
+ Grafreed.wav.save();
10445
+ Grafreed.savesound = false;
10446
+ Grafreed.hassound = false;
1024710447 }
1024810448 // if (DEBUG_SELECTION)
1024910449 // {
....@@ -10319,6 +10519,7 @@
1031910519 ANTIALIAS = 0;
1032010520 //System.out.println("RESTART");
1032110521 AAtimer.restart();
10522
+ Globals.TIMERRUNNING = true;
1032210523 }
1032310524 }
1032410525 }
....@@ -10373,7 +10574,7 @@
1037310574 Object3D theobject = object;
1037410575 Object3D theparent = object.parent;
1037510576 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10577
+ object = (Object3D)Grafreed.clone(object);
1037710578 object.Stripify();
1037810579 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910580 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10587,14 @@
1038610587 ambientOcclusion = false;
1038710588 }
1038810589
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10590
+ if (//Globals.lighttouched &&
10591
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010592 {
1039110593 //if (RENDERSHADOW) // ?
1039210594 if (!IsFrozen())
1039310595 {
1039410596 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10597
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610598 {
1039710599 Globals.framecount++;
1039810600 shadowbuffer.display();
....@@ -10519,8 +10721,8 @@
1051910721
1052010722 // if (parentcam != renderCamera) // not a light
1052110723 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10724
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10725
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410726
1052510727 for (int j = 0; j < 4; j++)
1052610728 {
....@@ -10534,8 +10736,8 @@
1053410736
1053510737 // if (parentcam != renderCamera) // not a light
1053610738 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10739
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10740
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910741
1054010742 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110743
....@@ -10794,7 +10996,16 @@
1079410996 // Bump noise
1079510997 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610998 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- BindTexture(NOISE_TEXTURE, false, 2);
10999
+
11000
+ try
11001
+ {
11002
+ BindTexture(NOISE_TEXTURE, false, 2);
11003
+ }
11004
+ catch (Exception e)
11005
+ {
11006
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11007
+ }
11008
+
1079811009
1079911010 gl.glActiveTexture(GL.GL_TEXTURE0);
1080011011 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +11130,8 @@
1091911130 System.err.println("parentcam != renderCamera");
1092011131
1092111132 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11133
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11134
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092411135 }
1092511136
1092611137 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11152,8 @@
1094111152 if (true) // TODO
1094211153 {
1094311154 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11155
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11156
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094611157 }
1094711158
1094811159 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,16 +11490,37 @@
1127911490 e.printStackTrace();
1128011491 }
1128111492
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11493
+ if (Grafreed.RENDERME > 0)
11494
+ Grafreed.RENDERME--; // mechante magouille
1128411495
1128511496 Globals.ONESTEP = false;
1128611497 }
1128711498
1128811499 static boolean zoomonce = false;
1128911500
11501
+ static void CreateSelectedPoint()
11502
+ {
11503
+ if (selectedpoint == null)
11504
+ {
11505
+ debugpointG = new Sphere();
11506
+ debugpointP = new Sphere();
11507
+ debugpointC = new Sphere();
11508
+ debugpointR = new Sphere();
11509
+
11510
+ selectedpoint = new Superellipsoid();
11511
+
11512
+ for (int i=0; i<8; i++)
11513
+ {
11514
+ debugpoints[i] = new Sphere();
11515
+ }
11516
+ }
11517
+ }
11518
+
1129011519 void DrawObject(GL gl, boolean draw)
1129111520 {
11521
+ // To clear camera values
11522
+ ResetOptions();
11523
+
1129211524 //System.out.println("DRAW OBJECT " + mouseDown);
1129311525 // DrawMode() = SELECTION;
1129411526 //GL gl = getGL();
....@@ -11350,7 +11582,14 @@
1135011582
1135111583 usedtextures.clear();
1135211584
11353
- BindTextures(DEFAULT_TEXTURES, 2);
11585
+ try
11586
+ {
11587
+ BindTextures(DEFAULT_TEXTURES, 2);
11588
+ }
11589
+ catch (Exception e)
11590
+ {
11591
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11592
+ }
1135411593 }
1135511594 //System.out.println("--> " + stackdepth);
1135611595 // GrafreeD.traceon();
....@@ -11360,8 +11599,9 @@
1136011599
1136111600 if (DrawMode() == DEFAULT)
1136211601 {
11363
- if (DEBUG)
11602
+ if (Globals.DEBUG)
1136411603 {
11604
+ CreateSelectedPoint();
1136511605 float radius = 0.05f;
1136611606 if (selectedpoint.radius != radius)
1136711607 {
....@@ -11441,7 +11681,14 @@
1144111681 if (checker != null && DrawMode() == DEFAULT)
1144211682 {
1144311683 //BindTexture(IMMORTAL_TEXTURE);
11444
- BindTextures(checker.GetTextures(), checker.texres);
11684
+ try
11685
+ {
11686
+ BindTextures(checker.GetTextures(), checker.texres);
11687
+ }
11688
+ catch (Exception e)
11689
+ {
11690
+ System.err.println("FAILED: " + checker.GetTextures());
11691
+ }
1144511692 // NEAREST
1144611693 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711694 DrawChecker(gl);
....@@ -11523,7 +11770,7 @@
1152311770 return;
1152411771 }
1152511772
11526
- String string = obj.GetToolTip();
11773
+ String string = obj.toString(); //.GetToolTip();
1152711774
1152811775 GL gl = GetGL();
1152911776
....@@ -11840,8 +12087,8 @@
1184012087 //obj.TransformToWorld(light, light);
1184112088 for (int i = tp.size(); --i >= 0;)
1184212089 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- LA.xformPos(light, tp.get(i).toParent, light);
12090
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12091
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184512092 }
1184612093
1184712094
....@@ -11858,8 +12105,8 @@
1185812105 parentcam = cameras[0];
1185912106 }
1186012107
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12108
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12109
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186312110
1186412111 LA.xformPos(light, renderCamera.toScreen, light);
1186512112
....@@ -12473,8 +12720,8 @@
1247312720
1247412721 // display shadow only (bump == 0)
1247512722 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12723
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12724
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812725 "SUB temp.y, one.x, temp.z;" +
1247912726 "MUL temp.x, temp.x, temp.y;" +
1248012727 "KIL temp.x;" +
....@@ -12603,8 +12850,10 @@
1260312850 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260412851
1260512852 "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
12853
+ // Tuning for default skin
12854
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12855
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12856
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260812857 "MUL temp.x, temp.x, temp.y;" +
1260912858
1261012859 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12752,7 +13001,7 @@
1275213001 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275313002 "FLR final.x, final.y;" +
1275413003 "SUB final.y, final.y, final.x;" +
12755
- //"MUL final.x, final.x, c256i;" +
13004
+ "MUL final.x, final.x, c256i;" +
1275613005 "MOV final.z, zero.x;" +
1275713006 "MOV final.a, one.w;":""
1275813007 ) +
....@@ -12760,7 +13009,7 @@
1276013009 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276113010 "FLR final.x, final.y;" +
1276213011 "SUB final.y, final.y, final.x;" +
12763
- //"MUL final.x, final.x, c256i;" +
13012
+ "MUL final.x, final.x, c256i;" +
1276413013 "MOV final.z, zero.x;" +
1276513014 "MOV final.a, one.w;":""
1276613015 ) +
....@@ -12803,7 +13052,7 @@
1280313052 //once = true;
1280413053 }
1280513054
12806
- System.out.print("Program #" + mode + "; length = " + program.length());
13055
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280713056 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280813057 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280913058
....@@ -12936,12 +13185,16 @@
1293613185
1293713186 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293813187 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13188
+
13189
+ // Compare fragment depth in light space with shadowmap.
1293913190 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294013191 "SGE temp.y, temp.x, zero.x;" +
12941
- "SUB " + shadow + ".y, one.x, temp.y;" +
13192
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13193
+
13194
+ // Reverse comparison
1294213195 "SUB temp.x, one.x, temp.x;" +
1294313196 "MUL " + shadow + ".x, temp.x, temp.y;" +
12944
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13197
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294513198 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294613199
1294713200 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12955,6 +13208,10 @@
1295513208 // No shadow for backface
1295613209 "DP3 temp.x, normal, lightd;" +
1295713210 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13211
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13212
+
13213
+ // No shadow when out of frustrum
13214
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295813215 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295913216 "";
1296013217 }
....@@ -13101,7 +13358,8 @@
1310113358 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310213359 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310313360 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13104
- Object3D.cVector2[] vector2buffer;
13361
+
13362
+ //Object3D.cVector2[] vector2buffer;
1310513363
1310613364 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310713365 // OUT : diff, spec
....@@ -13513,7 +13771,7 @@
1351313771 public void mousePressed(MouseEvent e)
1351413772 {
1351513773 //System.out.println("mousePressed: " + e);
13516
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13774
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351713775 }
1351813776
1351913777 static long prevtime = 0;
....@@ -13589,8 +13847,8 @@
1358913847 // mode |= META;
1359013848 //}
1359113849
13592
- SetMouseMode(WHEEL | e.getModifiersEx());
13593
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13850
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13851
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359413852 anchorX = ax;
1359513853 anchorY = ay;
1359613854 prevX = px;
....@@ -13624,6 +13882,7 @@
1362413882 else
1362513883 if (evt.getSource() == AAtimer)
1362613884 {
13885
+ Globals.TIMERRUNNING = false;
1362713886 if (mouseDown)
1362813887 {
1362913888 //new Exception().printStackTrace();
....@@ -13649,6 +13908,10 @@
1364913908 // LIVE = waslive;
1365013909 // wasliveok = true;
1365113910 // waslive = false;
13911
+
13912
+ // May 2019 Forget it:
13913
+ if (true)
13914
+ return;
1365213915
1365313916 // source == timer
1365413917 if (mouseDown)
....@@ -13688,12 +13951,13 @@
1368813951
1368913952 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369013953
13691
- void clickStart(int x, int y, int modifiers)
13954
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369213955 {
1369313956 if (!wasliveok)
1369413957 return;
1369513958
1369613959 AAtimer.restart(); //
13960
+ Globals.TIMERRUNNING = true;
1369713961
1369813962 // waslive = LIVE;
1369913963 // LIVE = false;
....@@ -13705,7 +13969,7 @@
1370513969 // touched = true; // main DL
1370613970 if (isRenderer)
1370713971 {
13708
- SetMouseMode(modifiers);
13972
+ SetMouseMode(modifiers, modifiersex);
1370913973 }
1371013974
1371113975 selectX = anchorX = x;
....@@ -13718,7 +13982,7 @@
1371813982 clicked = true;
1371913983 hold = false;
1372013984
13721
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13985
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372213986 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372313987 {
1372413988 // System.out.println("RESTART II " + modifiers);
....@@ -13749,7 +14013,7 @@
1374914013 info.camera = renderCamera;
1375014014 info.x = x;
1375114015 info.y = y;
13752
- info.modifiers = modifiers;
14016
+ info.modifiers = modifiersex;
1375314017 editObj = object.doEditClick(info, 0);
1375414018 if (!editObj)
1375514019 {
....@@ -13766,9 +14030,12 @@
1376614030
1376714031 public void mouseDragged(MouseEvent e)
1376814032 {
14033
+ Globals.MOUSEDRAGGED = true;
14034
+
1376914035 //System.out.println("mouseDragged: " + e);
1377014036 if (isRenderer)
1377114037 movingcamera = true;
14038
+
1377214039 //if (drawing)
1377314040 //return;
1377414041 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13778,7 +14045,7 @@
1377814045 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377914046 }
1378014047 else
13781
- drag(e.getX(), e.getY(), e.getModifiersEx());
14048
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378214049
1378314050 //try { Thread.sleep(1); } catch (Exception ex) {}
1378414051 }
....@@ -14015,7 +14282,7 @@
1401514282 {
1401614283 Globals.lighttouched = true;
1401714284 }
14018
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14285
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401914286 }
1402014287 //else
1402114288 }
....@@ -14115,7 +14382,7 @@
1411514382 int X, Y;
1411614383 boolean SX, SY;
1411714384
14118
- void drag(int x, int y, int modifiers)
14385
+ void drag(int x, int y, int modifiers, int modifiersex)
1411914386 {
1412014387 if (IsFrozen())
1412114388 {
....@@ -14124,17 +14391,17 @@
1412414391
1412514392 drag = true; // NEW
1412614393
14127
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14394
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412814395
1412914396 X = x;
1413014397 Y = y;
1413114398 // floating state for animation
14132
- MODIFIERS = modifiers;
14133
- modifiers &= ~1024;
14399
+ MODIFIERS = modifiersex;
14400
+ modifiersex &= ~1024;
1413414401 if (false) // modifiers != 0)
1413514402 {
1413614403 //new Exception().printStackTrace();
14137
- System.out.println("mouseDragged: " + modifiers);
14404
+ System.out.println("mouseDragged: " + modifiersex);
1413814405 System.out.println("SHIFT = " + SHIFT);
1413914406 System.out.println("CONTROL = " + COMMAND);
1414014407 System.out.println("META = " + META);
....@@ -14154,7 +14421,8 @@
1415414421 info.camera = renderCamera;
1415514422 info.x = x;
1415614423 info.y = y;
14157
- object.editWindow.copy.doEditDrag(info);
14424
+ object.GetWindow().copy
14425
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415814426 } else
1415914427 {
1416014428 if (x < startX)
....@@ -14318,7 +14586,9 @@
1431814586 ci.camera = renderCamera;
1431914587 if (!isRenderer)
1432014588 {
14321
- if (object.editWindow.copy.doEditClick(ci, 0))
14589
+ //ObjEditor editWindow = object.editWindow;
14590
+ //Object3D copy = editWindow.copy;
14591
+ if (object.doEditClick(ci, 0))
1432214592 {
1432314593 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432414594 } else
....@@ -14330,7 +14600,10 @@
1433014600
1433114601 public void mouseReleased(MouseEvent e)
1433214602 {
14603
+ Globals.MOUSEDRAGGED = false;
14604
+
1433314605 movingcamera = false;
14606
+ X = Y = 0;
1433414607 //System.out.println("mouseReleased: " + e);
1433514608 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433614609 }
....@@ -14353,9 +14626,9 @@
1435314626 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435414627 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435514628
14356
- if (control || command || IsFrozen())
14629
+// No delay if (control || command || IsFrozen())
1435714630 timeout = true;
14358
- else
14631
+// ?? May 2019 else
1435914632 // timer.setDelay((modifiers & 128) != 0?0:350);
1436014633 mouseDown = false;
1436114634 if (!control && !command) // june 2013
....@@ -14465,7 +14738,7 @@
1446514738 System.out.println("keyReleased: " + e);
1446614739 }
1446714740
14468
- void SetMouseMode(int modifiers)
14741
+ void SetMouseMode(int modifiers, int modifiersex)
1446914742 {
1447014743 //System.out.println("SetMouseMode = " + modifiers);
1447114744 //modifiers &= ~1024;
....@@ -14477,25 +14750,25 @@
1447714750 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447814751 // return;
1447914752 //System.out.println("SetMode = " + modifiers);
14480
- if ((modifiers & WHEEL) == WHEEL)
14753
+ if ((modifiersex & WHEEL) == WHEEL)
1448114754 {
1448214755 mouseMode |= ZOOM;
1448314756 }
1448414757
1448514758 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14486
- if (capsLocked || (modifiers & META) == META)
14759
+ if (capsLocked) // || (modifiers & META) == META)
1448714760 {
1448814761 mouseMode |= VR; // BACKFORTH;
1448914762 }
14490
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14763
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449114764 {
1449214765 mouseMode |= SELECT;
1449314766 }
14494
- if ((modifiers & COMMAND) == COMMAND)
14767
+ if ((modifiersex & COMMAND) == COMMAND)
1449514768 {
1449614769 mouseMode |= SELECT;
1449714770 }
14498
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14771
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449914772 {
1450014773 mouseMode &= ~VR;
1450114774 mouseMode |= TRANSLATE;
....@@ -14524,7 +14797,7 @@
1452414797
1452514798 if (isRenderer) //
1452614799 {
14527
- SetMouseMode(modifiers);
14800
+ SetMouseMode(0, modifiers);
1452814801 }
1452914802
1453014803 Globals.theRenderer.keyPressed(key);
....@@ -14696,8 +14969,14 @@
1469614969 RevertCamera();
1469714970 repaint();
1469814971 break;
14699
- case 'L':
1470014972 case 'l':
14973
+ lightMode ^= true;
14974
+ Globals.lighttouched = true;
14975
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14976
+ targetLookAt.set(manipCamera.lookAt);
14977
+ repaint();
14978
+ break;
14979
+ case 'L':
1470114980 if (lightMode)
1470214981 {
1470314982 lightMode = false;
....@@ -14844,23 +15123,21 @@
1484415123 kompactbit = 6;
1484515124 break;
1484615125 case ' ':
14847
- lightMode ^= true;
14848
- Globals.lighttouched = true;
14849
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14850
- targetLookAt.set(manipCamera.lookAt);
15126
+ ObjEditor.theFrame.ToggleFullScreen();
1485115127 repaint();
1485215128 break;
1485315129 //case '`' :
1485415130 case ESC:
1485515131 RENDERPROGRAM += 1;
1485615132 RENDERPROGRAM %= 3;
15133
+
1485715134 repaint();
1485815135 break;
1485915136 case 'Z':
1486015137 //RESIZETEXTURE ^= true;
1486115138 //break;
1486215139 case 'z':
14863
- RENDERSHADOW ^= true;
15140
+ Globals.RENDERSHADOW ^= true;
1486415141 Globals.lighttouched = true;
1486515142 repaint();
1486615143 break;
....@@ -14984,7 +15261,7 @@
1498415261 //mode = ROTATE;
1498515262 if ((MODIFIERS & COMMAND) == 0) // VR??
1498615263 {
14987
- SetMouseMode(modifiers);
15264
+ SetMouseMode(0, modifiers);
1498815265 }
1498915266 }
1499015267
....@@ -15120,7 +15397,7 @@
1512015397 {
1512115398 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512215399 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15123
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15400
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512415401 {
1512515402 mouseMoved(e);
1512615403 } else
....@@ -15145,7 +15422,7 @@
1514515422 }
1514615423 */
1514715424
15148
- object.editWindow.EditSelection();
15425
+ object.editWindow.EditSelection(false);
1514915426 }
1515015427
1515115428 void SelectParent()
....@@ -15339,7 +15616,9 @@
1533915616 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534015617 //Image img = CreateImage(width, height);
1534115618 //System.out.println("width = " + width + "; height = " + height + "\n");
15619
+
1534215620 Graphics gr = g; // img.getGraphics();
15621
+
1534315622 if (!hasMarquee)
1534415623 {
1534515624 if (Xmin < Xmax) // !locked)
....@@ -15437,14 +15716,33 @@
1543715716 if (!isRenderer)
1543815717 {
1543915718 object.drawEditHandles(info, 0);
15719
+
15720
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15721
+ {
15722
+ switch (object.selection.get(0).hitSomething)
15723
+ {
15724
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15725
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15726
+ break;
15727
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15728
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15729
+ break;
15730
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15731
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15732
+ break;
15733
+ }
15734
+
15735
+ }
1544015736 }
1544115737 }
15738
+
1544215739 if (isRenderer)
1544315740 {
1544415741 //gr.setColor(Color.black);
1544515742 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544615743 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544715744 }
15745
+
1544815746 if (hasMarquee)
1544915747 {
1545015748 gr.setXORMode(Color.white);
....@@ -15557,6 +15855,7 @@
1555715855 public boolean mouseDown(Event evt, int x, int y)
1555815856 {
1555915857 System.out.println("mouseDown: " + evt);
15858
+ System.exit(0);
1556015859 /*
1556115860 locked = true;
1556215861 drag = false;
....@@ -15600,7 +15899,7 @@
1560015899 {
1560115900 keyPressed(0, modifiers);
1560215901 }
15603
- clickStart(x, y, modifiers);
15902
+ // clickStart(x, y, modifiers);
1560415903 return true;
1560515904 }
1560615905
....@@ -15718,7 +16017,7 @@
1571816017 {
1571916018 keyReleased(0, 0);
1572016019 }
15721
- drag(x, y, modifiers);
16020
+ drag(x, y, 0, modifiers);
1572216021 return true;
1572316022 }
1572416023
....@@ -15850,7 +16149,7 @@
1585016149 Object3D object;
1585116150 static Object3D trackedobject;
1585216151 Camera renderCamera; // Light or Eye (or Occlusion)
15853
- /*static*/ Camera manipCamera; // Light or Eye
16152
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585416153 /*static*/ Camera eyeCamera;
1585516154 /*static*/ Camera lightCamera;
1585616155 int cameracount;
....@@ -16135,16 +16434,16 @@
1613516434 cStatic.objectstack[materialdepth++] = checker;
1613616435 //System.out.println("material " + material);
1613716436 //Applet3D.tracein(this, selected);
16138
- vector2buffer = checker.projectedVertices;
16437
+ //vector2buffer = checker.projectedVertices;
1613916438
1614016439 //checker.GetMaterial().Draw(this, false); // true);
16141
- DrawMaterial(checker.GetMaterial(), false); // true);
16440
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614216441
1614316442 materialdepth -= 1;
1614416443 if (materialdepth > 0)
1614516444 {
16146
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16147
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16445
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16446
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614816447 }
1614916448 //checker.GetMaterial().opacity = 1f;
1615016449 ////checker.GetMaterial().ambient = 1f;
....@@ -16368,6 +16667,8 @@
1636816667 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636916668 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1637016669
16670
+ CreateSelectedPoint();
16671
+
1637116672 // Will fit the mesh !!!
1637216673 selectedpoint.toParent[0][0] = 0.0001;
1637316674 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16416,16 +16717,16 @@
1641616717 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]));
1641716718 }
1641816719
16419
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16720
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642016721 }
1642116722 }
1642216723
1642316724 if (!movingcamera && !PAINTMODE)
1642416725 object.editWindow.ScreenFitPoint(); // fev 2014
1642516726
16426
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16727
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642716728 {
16428
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16729
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642916730
1643016731 Object3D group = new Object3D("inst" + paintcount++);
1643116732
....@@ -16581,7 +16882,7 @@
1658116882 gl.glDisable(gl.GL_CULL_FACE);
1658216883 }
1658316884
16584
- if (!RENDERSHADOW)
16885
+ if (!Globals.RENDERSHADOW)
1658516886 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658616887
1658716888 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16591,7 +16892,7 @@
1659116892 //gl.glColorMask(false, false, false, false);
1659216893
1659316894 //render_scene_from_light_view(gl, drawable, 0, 0);
16594
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16895
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659516896 {
1659616897 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716898
....@@ -17007,23 +17308,15 @@
1700717308 int AAbuffersize = 0;
1700817309
1700917310 //double[] selectedpoint = new double[3];
17010
- static Superellipsoid selectedpoint = new Superellipsoid();
17311
+ static Superellipsoid selectedpoint;
1701117312 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();
17313
+ static Sphere debugpointG;
17314
+ static Sphere debugpointP;
17315
+ static Sphere debugpointC;
17316
+ static Sphere debugpointR;
1701617317
1701717318 static Sphere debugpoints[] = new Sphere[8];
1701817319
17019
- static
17020
- {
17021
- for (int i=0; i<8; i++)
17022
- {
17023
- debugpoints[i] = new Sphere();
17024
- }
17025
- }
17026
-
1702717320 static void InitPoints(float radius)
1702817321 {
1702917322 for (int i=0; i<8; i++)