Normand Briere
2019-06-25 d2f456cf5280f59425084532bd2397ec625f7577
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 {
....@@ -9304,8 +9466,8 @@
93049466 assert (parentcam != renderCamera);
93059467
93069468 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9469
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9470
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099471
93109472 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119473
....@@ -9320,8 +9482,8 @@
93209482 LA.matCopy(renderCamera.fromScreen, matrix);
93219483
93229484 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9485
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9486
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259487
93269488 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279489
....@@ -9538,7 +9700,7 @@
95389700
95399701 if (!BOXMODE)
95409702 {
9541
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9703
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95429704 }
95439705
95449706 if (!BOXMODE)
....@@ -9576,7 +9738,7 @@
95769738 ABORTED = false;
95779739 }
95789740 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9741
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809742
95819743 if (false)
95829744 {
....@@ -10239,11 +10401,11 @@
1023910401
1024010402 public void display(GLAutoDrawable drawable)
1024110403 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10404
+ if (Grafreed.savesound && Grafreed.hassound)
1024310405 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10406
+ Grafreed.wav.save();
10407
+ Grafreed.savesound = false;
10408
+ Grafreed.hassound = false;
1024710409 }
1024810410 // if (DEBUG_SELECTION)
1024910411 // {
....@@ -10319,6 +10481,7 @@
1031910481 ANTIALIAS = 0;
1032010482 //System.out.println("RESTART");
1032110483 AAtimer.restart();
10484
+ Globals.TIMERRUNNING = true;
1032210485 }
1032310486 }
1032410487 }
....@@ -10373,7 +10536,7 @@
1037310536 Object3D theobject = object;
1037410537 Object3D theparent = object.parent;
1037510538 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10539
+ object = (Object3D)Grafreed.clone(object);
1037710540 object.Stripify();
1037810541 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910542 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10549,14 @@
1038610549 ambientOcclusion = false;
1038710550 }
1038810551
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10552
+ if (//Globals.lighttouched &&
10553
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010554 {
1039110555 //if (RENDERSHADOW) // ?
1039210556 if (!IsFrozen())
1039310557 {
1039410558 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10559
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610560 {
1039710561 Globals.framecount++;
1039810562 shadowbuffer.display();
....@@ -10519,8 +10683,8 @@
1051910683
1052010684 // if (parentcam != renderCamera) // not a light
1052110685 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10686
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10687
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410688
1052510689 for (int j = 0; j < 4; j++)
1052610690 {
....@@ -10534,8 +10698,8 @@
1053410698
1053510699 // if (parentcam != renderCamera) // not a light
1053610700 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10701
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10702
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910703
1054010704 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110705
....@@ -10794,7 +10958,16 @@
1079410958 // Bump noise
1079510959 gl.glActiveTexture(GL.GL_TEXTURE6);
1079610960 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- BindTexture(NOISE_TEXTURE, false, 2);
10961
+
10962
+ try
10963
+ {
10964
+ BindTexture(NOISE_TEXTURE, false, 2);
10965
+ }
10966
+ catch (Exception e)
10967
+ {
10968
+ System.err.println("FAILED: " + NOISE_TEXTURE);
10969
+ }
10970
+
1079810971
1079910972 gl.glActiveTexture(GL.GL_TEXTURE0);
1080010973 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10919,8 +11092,8 @@
1091911092 System.err.println("parentcam != renderCamera");
1092011093
1092111094 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11095
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11096
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092411097 }
1092511098
1092611099 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11114,8 @@
1094111114 if (true) // TODO
1094211115 {
1094311116 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11117
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11118
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094611119 }
1094711120
1094811121 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,13 +11452,31 @@
1127911452 e.printStackTrace();
1128011453 }
1128111454
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11455
+ if (Grafreed.RENDERME > 0)
11456
+ Grafreed.RENDERME--; // mechante magouille
1128411457
1128511458 Globals.ONESTEP = false;
1128611459 }
1128711460
1128811461 static boolean zoomonce = false;
11462
+
11463
+ static void CreateSelectedPoint()
11464
+ {
11465
+ if (selectedpoint == null)
11466
+ {
11467
+ debugpointG = new Sphere();
11468
+ debugpointP = new Sphere();
11469
+ debugpointC = new Sphere();
11470
+ debugpointR = new Sphere();
11471
+
11472
+ selectedpoint = new Superellipsoid();
11473
+
11474
+ for (int i=0; i<8; i++)
11475
+ {
11476
+ debugpoints[i] = new Sphere();
11477
+ }
11478
+ }
11479
+ }
1128911480
1129011481 void DrawObject(GL gl, boolean draw)
1129111482 {
....@@ -11350,7 +11541,14 @@
1135011541
1135111542 usedtextures.clear();
1135211543
11353
- BindTextures(DEFAULT_TEXTURES, 2);
11544
+ try
11545
+ {
11546
+ BindTextures(DEFAULT_TEXTURES, 2);
11547
+ }
11548
+ catch (Exception e)
11549
+ {
11550
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11551
+ }
1135411552 }
1135511553 //System.out.println("--> " + stackdepth);
1135611554 // GrafreeD.traceon();
....@@ -11360,8 +11558,9 @@
1136011558
1136111559 if (DrawMode() == DEFAULT)
1136211560 {
11363
- if (DEBUG)
11561
+ if (Globals.DEBUG)
1136411562 {
11563
+ CreateSelectedPoint();
1136511564 float radius = 0.05f;
1136611565 if (selectedpoint.radius != radius)
1136711566 {
....@@ -11441,7 +11640,14 @@
1144111640 if (checker != null && DrawMode() == DEFAULT)
1144211641 {
1144311642 //BindTexture(IMMORTAL_TEXTURE);
11444
- BindTextures(checker.GetTextures(), checker.texres);
11643
+ try
11644
+ {
11645
+ BindTextures(checker.GetTextures(), checker.texres);
11646
+ }
11647
+ catch (Exception e)
11648
+ {
11649
+ System.err.println("FAILED: " + checker.GetTextures());
11650
+ }
1144511651 // NEAREST
1144611652 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711653 DrawChecker(gl);
....@@ -11523,7 +11729,7 @@
1152311729 return;
1152411730 }
1152511731
11526
- String string = obj.GetToolTip();
11732
+ String string = obj.toString(); //.GetToolTip();
1152711733
1152811734 GL gl = GetGL();
1152911735
....@@ -11840,8 +12046,8 @@
1184012046 //obj.TransformToWorld(light, light);
1184112047 for (int i = tp.size(); --i >= 0;)
1184212048 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- LA.xformPos(light, tp.get(i).toParent, light);
12049
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12050
+ LA.xformPos(light, tp.get(i).GlobalTransform(), light);
1184512051 }
1184612052
1184712053
....@@ -11858,8 +12064,8 @@
1185812064 parentcam = cameras[0];
1185912065 }
1186012066
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12067
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12068
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186312069
1186412070 LA.xformPos(light, renderCamera.toScreen, light);
1186512071
....@@ -12473,8 +12679,8 @@
1247312679
1247412680 // display shadow only (bump == 0)
1247512681 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12682
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12683
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812684 "SUB temp.y, one.x, temp.z;" +
1247912685 "MUL temp.x, temp.x, temp.y;" +
1248012686 "KIL temp.x;" +
....@@ -12603,8 +12809,10 @@
1260312809 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260412810
1260512811 "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
12812
+ // Tuning for default skin
12813
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12814
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12815
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260812816 "MUL temp.x, temp.x, temp.y;" +
1260912817
1261012818 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12752,7 +12960,7 @@
1275212960 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275312961 "FLR final.x, final.y;" +
1275412962 "SUB final.y, final.y, final.x;" +
12755
- //"MUL final.x, final.x, c256i;" +
12963
+ "MUL final.x, final.x, c256i;" +
1275612964 "MOV final.z, zero.x;" +
1275712965 "MOV final.a, one.w;":""
1275812966 ) +
....@@ -12760,7 +12968,7 @@
1276012968 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276112969 "FLR final.x, final.y;" +
1276212970 "SUB final.y, final.y, final.x;" +
12763
- //"MUL final.x, final.x, c256i;" +
12971
+ "MUL final.x, final.x, c256i;" +
1276412972 "MOV final.z, zero.x;" +
1276512973 "MOV final.a, one.w;":""
1276612974 ) +
....@@ -12803,7 +13011,7 @@
1280313011 //once = true;
1280413012 }
1280513013
12806
- System.out.print("Program #" + mode + "; length = " + program.length());
13014
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280713015 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280813016 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280913017
....@@ -12936,12 +13144,16 @@
1293613144
1293713145 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293813146 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13147
+
13148
+ // Compare fragment depth in light space with shadowmap.
1293913149 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294013150 "SGE temp.y, temp.x, zero.x;" +
12941
- "SUB " + shadow + ".y, one.x, temp.y;" +
13151
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13152
+
13153
+ // Reverse comparison
1294213154 "SUB temp.x, one.x, temp.x;" +
1294313155 "MUL " + shadow + ".x, temp.x, temp.y;" +
12944
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13156
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294513157 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294613158
1294713159 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12955,6 +13167,10 @@
1295513167 // No shadow for backface
1295613168 "DP3 temp.x, normal, lightd;" +
1295713169 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13170
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13171
+
13172
+ // No shadow when out of frustrum
13173
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295813174 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295913175 "";
1296013176 }
....@@ -13101,7 +13317,8 @@
1310113317 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310213318 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310313319 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13104
- Object3D.cVector2[] vector2buffer;
13320
+
13321
+ //Object3D.cVector2[] vector2buffer;
1310513322
1310613323 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310713324 // OUT : diff, spec
....@@ -13513,7 +13730,7 @@
1351313730 public void mousePressed(MouseEvent e)
1351413731 {
1351513732 //System.out.println("mousePressed: " + e);
13516
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13733
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351713734 }
1351813735
1351913736 static long prevtime = 0;
....@@ -13589,8 +13806,8 @@
1358913806 // mode |= META;
1359013807 //}
1359113808
13592
- SetMouseMode(WHEEL | e.getModifiersEx());
13593
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13809
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13810
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359413811 anchorX = ax;
1359513812 anchorY = ay;
1359613813 prevX = px;
....@@ -13624,6 +13841,7 @@
1362413841 else
1362513842 if (evt.getSource() == AAtimer)
1362613843 {
13844
+ Globals.TIMERRUNNING = false;
1362713845 if (mouseDown)
1362813846 {
1362913847 //new Exception().printStackTrace();
....@@ -13649,6 +13867,10 @@
1364913867 // LIVE = waslive;
1365013868 // wasliveok = true;
1365113869 // waslive = false;
13870
+
13871
+ // May 2019 Forget it:
13872
+ if (true)
13873
+ return;
1365213874
1365313875 // source == timer
1365413876 if (mouseDown)
....@@ -13688,12 +13910,13 @@
1368813910
1368913911 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369013912
13691
- void clickStart(int x, int y, int modifiers)
13913
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369213914 {
1369313915 if (!wasliveok)
1369413916 return;
1369513917
1369613918 AAtimer.restart(); //
13919
+ Globals.TIMERRUNNING = true;
1369713920
1369813921 // waslive = LIVE;
1369913922 // LIVE = false;
....@@ -13705,7 +13928,7 @@
1370513928 // touched = true; // main DL
1370613929 if (isRenderer)
1370713930 {
13708
- SetMouseMode(modifiers);
13931
+ SetMouseMode(modifiers, modifiersex);
1370913932 }
1371013933
1371113934 selectX = anchorX = x;
....@@ -13718,7 +13941,7 @@
1371813941 clicked = true;
1371913942 hold = false;
1372013943
13721
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
13944
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372213945 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372313946 {
1372413947 // System.out.println("RESTART II " + modifiers);
....@@ -13749,7 +13972,7 @@
1374913972 info.camera = renderCamera;
1375013973 info.x = x;
1375113974 info.y = y;
13752
- info.modifiers = modifiers;
13975
+ info.modifiers = modifiersex;
1375313976 editObj = object.doEditClick(info, 0);
1375413977 if (!editObj)
1375513978 {
....@@ -13766,9 +13989,12 @@
1376613989
1376713990 public void mouseDragged(MouseEvent e)
1376813991 {
13992
+ Globals.MOUSEDRAGGED = true;
13993
+
1376913994 //System.out.println("mouseDragged: " + e);
1377013995 if (isRenderer)
1377113996 movingcamera = true;
13997
+
1377213998 //if (drawing)
1377313999 //return;
1377414000 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13778,7 +14004,7 @@
1377814004 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377914005 }
1378014006 else
13781
- drag(e.getX(), e.getY(), e.getModifiersEx());
14007
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378214008
1378314009 //try { Thread.sleep(1); } catch (Exception ex) {}
1378414010 }
....@@ -14015,7 +14241,7 @@
1401514241 {
1401614242 Globals.lighttouched = true;
1401714243 }
14018
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14244
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401914245 }
1402014246 //else
1402114247 }
....@@ -14115,7 +14341,7 @@
1411514341 int X, Y;
1411614342 boolean SX, SY;
1411714343
14118
- void drag(int x, int y, int modifiers)
14344
+ void drag(int x, int y, int modifiers, int modifiersex)
1411914345 {
1412014346 if (IsFrozen())
1412114347 {
....@@ -14124,17 +14350,17 @@
1412414350
1412514351 drag = true; // NEW
1412614352
14127
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14353
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412814354
1412914355 X = x;
1413014356 Y = y;
1413114357 // floating state for animation
14132
- MODIFIERS = modifiers;
14133
- modifiers &= ~1024;
14358
+ MODIFIERS = modifiersex;
14359
+ modifiersex &= ~1024;
1413414360 if (false) // modifiers != 0)
1413514361 {
1413614362 //new Exception().printStackTrace();
14137
- System.out.println("mouseDragged: " + modifiers);
14363
+ System.out.println("mouseDragged: " + modifiersex);
1413814364 System.out.println("SHIFT = " + SHIFT);
1413914365 System.out.println("CONTROL = " + COMMAND);
1414014366 System.out.println("META = " + META);
....@@ -14154,7 +14380,8 @@
1415414380 info.camera = renderCamera;
1415514381 info.x = x;
1415614382 info.y = y;
14157
- object.editWindow.copy.doEditDrag(info);
14383
+ object.GetWindow().copy
14384
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415814385 } else
1415914386 {
1416014387 if (x < startX)
....@@ -14318,7 +14545,9 @@
1431814545 ci.camera = renderCamera;
1431914546 if (!isRenderer)
1432014547 {
14321
- if (object.editWindow.copy.doEditClick(ci, 0))
14548
+ //ObjEditor editWindow = object.editWindow;
14549
+ //Object3D copy = editWindow.copy;
14550
+ if (object.doEditClick(ci, 0))
1432214551 {
1432314552 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432414553 } else
....@@ -14330,7 +14559,10 @@
1433014559
1433114560 public void mouseReleased(MouseEvent e)
1433214561 {
14562
+ Globals.MOUSEDRAGGED = false;
14563
+
1433314564 movingcamera = false;
14565
+ X = Y = 0;
1433414566 //System.out.println("mouseReleased: " + e);
1433514567 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433614568 }
....@@ -14353,9 +14585,9 @@
1435314585 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435414586 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435514587
14356
- if (control || command || IsFrozen())
14588
+// No delay if (control || command || IsFrozen())
1435714589 timeout = true;
14358
- else
14590
+// ?? May 2019 else
1435914591 // timer.setDelay((modifiers & 128) != 0?0:350);
1436014592 mouseDown = false;
1436114593 if (!control && !command) // june 2013
....@@ -14465,7 +14697,7 @@
1446514697 System.out.println("keyReleased: " + e);
1446614698 }
1446714699
14468
- void SetMouseMode(int modifiers)
14700
+ void SetMouseMode(int modifiers, int modifiersex)
1446914701 {
1447014702 //System.out.println("SetMouseMode = " + modifiers);
1447114703 //modifiers &= ~1024;
....@@ -14477,25 +14709,25 @@
1447714709 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447814710 // return;
1447914711 //System.out.println("SetMode = " + modifiers);
14480
- if ((modifiers & WHEEL) == WHEEL)
14712
+ if ((modifiersex & WHEEL) == WHEEL)
1448114713 {
1448214714 mouseMode |= ZOOM;
1448314715 }
1448414716
1448514717 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14486
- if (capsLocked || (modifiers & META) == META)
14718
+ if (capsLocked) // || (modifiers & META) == META)
1448714719 {
1448814720 mouseMode |= VR; // BACKFORTH;
1448914721 }
14490
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14722
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449114723 {
1449214724 mouseMode |= SELECT;
1449314725 }
14494
- if ((modifiers & COMMAND) == COMMAND)
14726
+ if ((modifiersex & COMMAND) == COMMAND)
1449514727 {
1449614728 mouseMode |= SELECT;
1449714729 }
14498
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14730
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449914731 {
1450014732 mouseMode &= ~VR;
1450114733 mouseMode |= TRANSLATE;
....@@ -14524,7 +14756,7 @@
1452414756
1452514757 if (isRenderer) //
1452614758 {
14527
- SetMouseMode(modifiers);
14759
+ SetMouseMode(0, modifiers);
1452814760 }
1452914761
1453014762 Globals.theRenderer.keyPressed(key);
....@@ -14696,8 +14928,14 @@
1469614928 RevertCamera();
1469714929 repaint();
1469814930 break;
14699
- case 'L':
1470014931 case 'l':
14932
+ lightMode ^= true;
14933
+ Globals.lighttouched = true;
14934
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14935
+ targetLookAt.set(manipCamera.lookAt);
14936
+ repaint();
14937
+ break;
14938
+ case 'L':
1470114939 if (lightMode)
1470214940 {
1470314941 lightMode = false;
....@@ -14844,23 +15082,21 @@
1484415082 kompactbit = 6;
1484515083 break;
1484615084 case ' ':
14847
- lightMode ^= true;
14848
- Globals.lighttouched = true;
14849
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14850
- targetLookAt.set(manipCamera.lookAt);
15085
+ ObjEditor.theFrame.ToggleFullScreen();
1485115086 repaint();
1485215087 break;
1485315088 //case '`' :
1485415089 case ESC:
1485515090 RENDERPROGRAM += 1;
1485615091 RENDERPROGRAM %= 3;
15092
+
1485715093 repaint();
1485815094 break;
1485915095 case 'Z':
1486015096 //RESIZETEXTURE ^= true;
1486115097 //break;
1486215098 case 'z':
14863
- RENDERSHADOW ^= true;
15099
+ Globals.RENDERSHADOW ^= true;
1486415100 Globals.lighttouched = true;
1486515101 repaint();
1486615102 break;
....@@ -14984,7 +15220,7 @@
1498415220 //mode = ROTATE;
1498515221 if ((MODIFIERS & COMMAND) == 0) // VR??
1498615222 {
14987
- SetMouseMode(modifiers);
15223
+ SetMouseMode(0, modifiers);
1498815224 }
1498915225 }
1499015226
....@@ -15120,7 +15356,7 @@
1512015356 {
1512115357 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512215358 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15123
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15359
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512415360 {
1512515361 mouseMoved(e);
1512615362 } else
....@@ -15145,7 +15381,7 @@
1514515381 }
1514615382 */
1514715383
15148
- object.editWindow.EditSelection();
15384
+ object.editWindow.EditSelection(false);
1514915385 }
1515015386
1515115387 void SelectParent()
....@@ -15339,7 +15575,9 @@
1533915575 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534015576 //Image img = CreateImage(width, height);
1534115577 //System.out.println("width = " + width + "; height = " + height + "\n");
15578
+
1534215579 Graphics gr = g; // img.getGraphics();
15580
+
1534315581 if (!hasMarquee)
1534415582 {
1534515583 if (Xmin < Xmax) // !locked)
....@@ -15437,14 +15675,33 @@
1543715675 if (!isRenderer)
1543815676 {
1543915677 object.drawEditHandles(info, 0);
15678
+
15679
+ if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
15680
+ {
15681
+ switch (object.selection.get(0).hitSomething)
15682
+ {
15683
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15684
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15685
+ break;
15686
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15687
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15688
+ break;
15689
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15690
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15691
+ break;
15692
+ }
15693
+
15694
+ }
1544015695 }
1544115696 }
15697
+
1544215698 if (isRenderer)
1544315699 {
1544415700 //gr.setColor(Color.black);
1544515701 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544615702 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544715703 }
15704
+
1544815705 if (hasMarquee)
1544915706 {
1545015707 gr.setXORMode(Color.white);
....@@ -15557,6 +15814,7 @@
1555715814 public boolean mouseDown(Event evt, int x, int y)
1555815815 {
1555915816 System.out.println("mouseDown: " + evt);
15817
+ System.exit(0);
1556015818 /*
1556115819 locked = true;
1556215820 drag = false;
....@@ -15600,7 +15858,7 @@
1560015858 {
1560115859 keyPressed(0, modifiers);
1560215860 }
15603
- clickStart(x, y, modifiers);
15861
+ // clickStart(x, y, modifiers);
1560415862 return true;
1560515863 }
1560615864
....@@ -15718,7 +15976,7 @@
1571815976 {
1571915977 keyReleased(0, 0);
1572015978 }
15721
- drag(x, y, modifiers);
15979
+ drag(x, y, 0, modifiers);
1572215980 return true;
1572315981 }
1572415982
....@@ -15850,7 +16108,7 @@
1585016108 Object3D object;
1585116109 static Object3D trackedobject;
1585216110 Camera renderCamera; // Light or Eye (or Occlusion)
15853
- /*static*/ Camera manipCamera; // Light or Eye
16111
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585416112 /*static*/ Camera eyeCamera;
1585516113 /*static*/ Camera lightCamera;
1585616114 int cameracount;
....@@ -16135,16 +16393,16 @@
1613516393 cStatic.objectstack[materialdepth++] = checker;
1613616394 //System.out.println("material " + material);
1613716395 //Applet3D.tracein(this, selected);
16138
- vector2buffer = checker.projectedVertices;
16396
+ //vector2buffer = checker.projectedVertices;
1613916397
1614016398 //checker.GetMaterial().Draw(this, false); // true);
16141
- DrawMaterial(checker.GetMaterial(), false); // true);
16399
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614216400
1614316401 materialdepth -= 1;
1614416402 if (materialdepth > 0)
1614516403 {
16146
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16147
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16404
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16405
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614816406 }
1614916407 //checker.GetMaterial().opacity = 1f;
1615016408 ////checker.GetMaterial().ambient = 1f;
....@@ -16368,6 +16626,8 @@
1636816626 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636916627 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
1637016628
16629
+ CreateSelectedPoint();
16630
+
1637116631 // Will fit the mesh !!!
1637216632 selectedpoint.toParent[0][0] = 0.0001;
1637316633 selectedpoint.toParent[1][1] = 0.0001;
....@@ -16416,16 +16676,16 @@
1641616676 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]));
1641716677 }
1641816678
16419
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16679
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642016680 }
1642116681 }
1642216682
1642316683 if (!movingcamera && !PAINTMODE)
1642416684 object.editWindow.ScreenFitPoint(); // fev 2014
1642516685
16426
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16686
+ if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642716687 {
16428
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16688
+ Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642916689
1643016690 Object3D group = new Object3D("inst" + paintcount++);
1643116691
....@@ -16581,7 +16841,7 @@
1658116841 gl.glDisable(gl.GL_CULL_FACE);
1658216842 }
1658316843
16584
- if (!RENDERSHADOW)
16844
+ if (!Globals.RENDERSHADOW)
1658516845 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658616846
1658716847 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16591,7 +16851,7 @@
1659116851 //gl.glColorMask(false, false, false, false);
1659216852
1659316853 //render_scene_from_light_view(gl, drawable, 0, 0);
16594
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
16854
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659516855 {
1659616856 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659716857
....@@ -17007,23 +17267,15 @@
1700717267 int AAbuffersize = 0;
1700817268
1700917269 //double[] selectedpoint = new double[3];
17010
- static Superellipsoid selectedpoint = new Superellipsoid();
17270
+ static Superellipsoid selectedpoint;
1701117271 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();
17272
+ static Sphere debugpointG;
17273
+ static Sphere debugpointP;
17274
+ static Sphere debugpointC;
17275
+ static Sphere debugpointR;
1701617276
1701717277 static Sphere debugpoints[] = new Sphere[8];
1701817278
17019
- static
17020
- {
17021
- for (int i=0; i<8; i++)
17022
- {
17023
- debugpoints[i] = new Sphere();
17024
- }
17025
- }
17026
-
1702717279 static void InitPoints(float radius)
1702817280 {
1702917281 for (int i=0; i<8; i++)