Normand Briere
2019-07-21 40f408aaee14abd85d391008b4d22977dc586b50
CameraPane.java
....@@ -37,7 +37,6 @@
3737 static boolean[] selectedstack = new boolean[65536];
3838 static int materialdepth = 0;
3939
40
- static boolean DEBUG = false;
4140 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4241
4342 // camera change fix
....@@ -56,14 +55,12 @@
5655 static int CURRENTANTIALIAS = 0; // 1;
5756 /*static*/ boolean RENDERSHADOW = true;
5857 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6158
6259 boolean DISPLAYTEXT = false;
6360 //boolean REDUCETEXTURE = true;
6461 boolean CACHETEXTURE = true;
6562 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6764 boolean COMPRESSTEXTURE = false;
6865 boolean KOMPACTTEXTURE = false; // true;
6966 boolean RESIZETEXTURE = false;
....@@ -86,7 +83,7 @@
8683 static boolean FULLSCREEN = false;
8784 static boolean SUPPORT = true;
8885 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
86
+static boolean FAST = false;
9087 static boolean SLOWPOSE = false;
9188 static boolean FOOTCONTACT = true;
9289
....@@ -108,7 +105,7 @@
108105 static boolean OEIL = true;
109106 static boolean OEILONCE = false; // do oeilon then oeiloff
110107 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
112109 static boolean HANDLES = false; // selection doesn't work!!
113110 static boolean PAINTMODE = false;
114111
....@@ -151,6 +148,8 @@
151148 defaultcaps.setAccumBlueBits(16);
152149 defaultcaps.setAccumAlphaBits(16);
153150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154153
155154 void SetAsGLRenderer(boolean b)
156155 {
....@@ -327,7 +326,7 @@
327326 cStatic.objectstack[materialdepth++] = obj;
328327 //System.out.println("material " + material);
329328 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
331330 if (obj instanceof Camera)
332331 {
333332 display.options1[0] = material.shift;
....@@ -336,14 +335,28 @@
336335 display.options1[2] = material.shadowbias;
337336 display.options1[3] = material.aniso;
338337 display.options1[4] = material.anisoV;
338
+// System.out.println("display.options1[0] " + display.options1[0]);
339
+// System.out.println("display.options1[1] " + display.options1[1]);
340
+// System.out.println("display.options1[2] " + display.options1[2]);
341
+// System.out.println("display.options1[3] " + display.options1[3]);
342
+// System.out.println("display.options1[4] " + display.options1[4]);
339343 display.options2[0] = material.opacity;
340344 display.options2[1] = material.diffuse;
341345 display.options2[2] = material.factor;
346
+// System.out.println("display.options2[0] " + display.options2[0]);
347
+// System.out.println("display.options2[1] " + display.options2[1]);
348
+// System.out.println("display.options2[2] " + display.options2[2]);
342349
343350 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
351
+// System.out.println("display.options3[0] " + display.options3[0]);
352
+// System.out.println("display.options3[1] " + display.options3[1]);
353
+// System.out.println("display.options3[2] " + display.options3[2]);
344354 display.options4[0] = material.cameralight/0.2f;
345355 display.options4[1] = material.subsurface;
346356 display.options4[2] = material.sheen;
357
+// System.out.println("display.options4[0] " + display.options4[0]);
358
+// System.out.println("display.options4[1] " + display.options4[1]);
359
+// System.out.println("display.options4[2] " + display.options4[2]);
347360
348361 // if (display.CURRENTANTIALIAS > 0)
349362 // display.options3[3] /= 4;
....@@ -359,7 +372,7 @@
359372 /**/
360373 } else
361374 {
362
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
363376 }
364377 } else
365378 {
....@@ -383,8 +396,8 @@
383396 cStatic.objectstack[materialdepth++] = obj;
384397 //System.out.println("material " + material);
385398 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388401 }
389402 }
390403
....@@ -401,8 +414,8 @@
401414 materialdepth -= 1;
402415 if (materialdepth > 0)
403416 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
417
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
418
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
406419 }
407420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +435,8 @@
422435 materialdepth -= 1;
423436 if (materialdepth > 0)
424437 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
438
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
439
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
427440 }
428441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429442 //else
....@@ -464,10 +477,12 @@
464477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465478 {
466479 //gl.glBegin(gl.GL_TRIANGLES);
467
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
480
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
481
+ // TEST LIVE NORMALS && !obj.dontselect
482
+ ;
468483 if (!hasnorm)
469484 {
470
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
471486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1207,12 @@
11921207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931208 }
11941209 }
1210
+
11951211 if (flipV)
11961212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971213 else
11981214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11991216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011218
....@@ -1215,10 +1232,12 @@
12151232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161233 }
12171234 }
1235
+
12181236 if (flipV)
12191237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201238 else
12211239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12221241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241243
....@@ -1246,8 +1265,10 @@
12461265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471266 else
12481267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12491269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12511272 count2 += 2;
12521273 count3 += 3;
12531274 }
....@@ -1603,7 +1624,7 @@
16031624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041625 }
16051626
1606
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071628 {
16081629 CameraPane display = this;
16091630 //new Exception().printStackTrace();
....@@ -1630,7 +1651,7 @@
16301651
16311652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321653
1633
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16341655
16351656 /**/
16361657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1659,7 @@
16381659 colorV[0] = display.modelParams0[0] * material.diffuse;
16391660 colorV[1] = display.modelParams0[1] * material.diffuse;
16401661 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16421663
16431664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441665 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1767,9 @@
17461767 display.modelParams7[2] = 0;
17471768 display.modelParams7[3] = 0;
17481769
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501771
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531774 {
17541775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1911,7 @@
18901911 void PushMatrix(double[][] matrix)
18911912 {
18921913 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18941915 }
18951916
18961917 void PushMatrix()
....@@ -2044,7 +2065,7 @@
20442065 //System.err.println("Oeil on");
20452066 OEIL = true;
20462067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482069 //pingthread.StepToTarget(true);
20492070 }
20502071
....@@ -2142,7 +2163,7 @@
21422163 System.err.println("LIVE = " + Globals.isLIVE());
21432164
21442165 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21462167 // else
21472168 repaint(); // start loop // may 2013
21482169 }
....@@ -2259,7 +2280,7 @@
22592280
22602281 void ToggleDebug()
22612282 {
2262
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22632284 }
22642285
22652286 void ToggleLookAt()
....@@ -2267,9 +2288,9 @@
22672288 LOOKAT ^= true;
22682289 }
22692290
2270
- void ToggleRandom()
2291
+ void ToggleSwitch()
22712292 {
2272
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22732294 }
22742295
22752296 void ToggleHandles()
....@@ -2277,10 +2298,17 @@
22772298 HANDLES ^= true;
22782299 }
22792300
2301
+ Object3D paintFolder;
2302
+
22802303 void TogglePaint()
22812304 {
22822305 PAINTMODE ^= true;
22832306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22842312 }
22852313
22862314 void SwapCamera(int a, int b)
....@@ -2376,7 +2404,7 @@
23762404 {
23772405 return currentGL;
23782406 }
2379
-
2407
+
23802408 /**/
23812409 class CacheTexture
23822410 {
....@@ -2394,9 +2422,10 @@
23942422 /**/
23952423
23962424 // TEXTURE static Texture texture;
2397
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2398
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2399
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2425
+ static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2426
+ static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2427
+ static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2428
+
24002429 int pigmentdepth = 0;
24012430 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022431 int bumpdepth = 0;
....@@ -2418,6 +2447,33 @@
24182447 true,
24192448 com.sun.opengl.util.texture.TextureIO.PNG);
24202449 } catch (java.io.IOException e)
2450
+ {
2451
+ throw new javax.media.opengl.GLException(e);
2452
+ }
2453
+
2454
+ if (bump)
2455
+ texturedata = ConvertBump(texturedata, false);
2456
+
2457
+ com.sun.opengl.util.texture.Texture texture =
2458
+ com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2459
+
2460
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2461
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2462
+
2463
+ return texture;
2464
+ }
2465
+
2466
+ com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2467
+ {
2468
+ TextureData texturedata = null;
2469
+
2470
+ try
2471
+ {
2472
+ texturedata =
2473
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2474
+ name,
2475
+ true);
2476
+ } catch (Exception e)
24212477 {
24222478 throw new javax.media.opengl.GLException(e);
24232479 }
....@@ -3504,6 +3560,8 @@
35043560
35053561 System.out.println("LOADING TEXTURE : " + name);
35063562
3563
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3564
+
35073565 //
35083566 if (false) // compressbit > 0)
35093567 {
....@@ -4208,6 +4266,7 @@
42084266
42094267 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
42104268 {
4269
+ new Exception().printStackTrace();
42114270 System.exit(0);
42124271 com.sun.opengl.util.texture.Texture texture = null;
42134272
....@@ -7901,7 +7960,7 @@
79017960 String pigment = Object3D.GetPigment(tex);
79027961 String bump = Object3D.GetBump(tex);
79037962
7904
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7963
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79057964 {
79067965 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79077966 // System.out.println("; bump = " + bump);
....@@ -7918,6 +7977,64 @@
79187977
79197978 ReleaseTexture(bump, true);
79207979 ReleaseTexture(pigment, false);
7980
+ }
7981
+
7982
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
7983
+ {
7984
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
7985
+ {
7986
+ return;
7987
+ }
7988
+
7989
+ if (tex == null)
7990
+ {
7991
+ ReleaseTexture(null, false);
7992
+ return;
7993
+ }
7994
+
7995
+ String pigment = Object3D.GetPigment(tex);
7996
+
7997
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7998
+ {
7999
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8000
+ // System.out.println("; bump = " + bump);
8001
+ }
8002
+
8003
+ if (pigment.equals(""))
8004
+ {
8005
+ pigment = null;
8006
+ }
8007
+
8008
+ ReleaseTexture(pigment, false);
8009
+ }
8010
+
8011
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8012
+ {
8013
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8014
+ {
8015
+ return;
8016
+ }
8017
+
8018
+ if (tex == null)
8019
+ {
8020
+ ReleaseTexture(null, true);
8021
+ return;
8022
+ }
8023
+
8024
+ String bump = Object3D.GetBump(tex);
8025
+
8026
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8027
+ {
8028
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8029
+ // System.out.println("; bump = " + bump);
8030
+ }
8031
+
8032
+ if (bump.equals(""))
8033
+ {
8034
+ bump = null;
8035
+ }
8036
+
8037
+ ReleaseTexture(bump, true);
79218038 }
79228039
79238040 void ReleaseTexture(String tex, boolean bump)
....@@ -8023,7 +8140,55 @@
80238140 }
80248141 }
80258142
8026
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8143
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8144
+ {
8145
+// if (// DrawMode() != 0 || /*tex == null ||*/
8146
+// ambientOcclusion ) // || !textureon)
8147
+// {
8148
+// return; // false;
8149
+// }
8150
+//
8151
+// if (tex == null)
8152
+// {
8153
+// BindTexture(null,false,resolution);
8154
+// BindTexture(null,true,resolution);
8155
+// return;
8156
+// }
8157
+//
8158
+// String pigment = Object3D.GetPigment(tex);
8159
+// String bump = Object3D.GetBump(tex);
8160
+//
8161
+// usedtextures.add(pigment);
8162
+// usedtextures.add(bump);
8163
+//
8164
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8165
+// {
8166
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8167
+// // System.out.println("; bump = " + bump);
8168
+// }
8169
+//
8170
+// if (bump.equals(""))
8171
+// {
8172
+// bump = null;
8173
+// }
8174
+// if (pigment.equals(""))
8175
+// {
8176
+// pigment = null;
8177
+// }
8178
+//
8179
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8180
+// BindTexture(pigment, false, resolution);
8181
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8182
+// BindTexture(bump, true, resolution);
8183
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8184
+//
8185
+// return; // true;
8186
+
8187
+ BindPigmentTexture(tex, resolution);
8188
+ BindBumpTexture(tex, resolution);
8189
+ }
8190
+
8191
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80278192 {
80288193 if (// DrawMode() != 0 || /*tex == null ||*/
80298194 ambientOcclusion ) // || !textureon)
....@@ -8033,18 +8198,48 @@
80338198
80348199 if (tex == null)
80358200 {
8036
- BindTexture(null,false,resolution);
8037
- BindTexture(null,true,resolution);
8201
+ BindTexture(null, null,false,resolution);
80388202 return;
80398203 }
80408204
80418205 String pigment = Object3D.GetPigment(tex);
8206
+
8207
+ usedtextures.add(pigment);
8208
+
8209
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8210
+ {
8211
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8212
+ // System.out.println("; bump = " + bump);
8213
+ }
8214
+
8215
+ if (pigment.equals(""))
8216
+ {
8217
+ pigment = null;
8218
+ }
8219
+
8220
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8221
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
8222
+ }
8223
+
8224
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8225
+ {
8226
+ if (// DrawMode() != 0 || /*tex == null ||*/
8227
+ ambientOcclusion ) // || !textureon)
8228
+ {
8229
+ return; // false;
8230
+ }
8231
+
8232
+ if (tex == null)
8233
+ {
8234
+ BindTexture(null, null,true,resolution);
8235
+ return;
8236
+ }
8237
+
80428238 String bump = Object3D.GetBump(tex);
80438239
8044
- usedtextures.put(pigment, pigment);
8045
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
80468241
8047
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80488243 {
80498244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80508245 // System.out.println("; bump = " + bump);
....@@ -8054,42 +8249,70 @@
80548249 {
80558250 bump = null;
80568251 }
8057
- if (pigment.equals(""))
8058
- {
8059
- pigment = null;
8060
- }
80618252
8062
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8063
- BindTexture(pigment, false, resolution);
80648253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8065
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
80668255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8067
-
8068
- return; // true;
80698256 }
80708257
8071
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8258
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8259
+
8260
+ private boolean FileExists(String tex)
80728261 {
8073
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8262
+ if (missingTextures.contains(tex))
8263
+ {
8264
+ return false;
8265
+ }
8266
+
8267
+ boolean fileExists = new File(tex).exists();
8268
+
8269
+ if (!fileExists)
8270
+ {
8271
+ // If file exists, the "new File()" is not executed sgain
8272
+ missingTextures.add(tex);
8273
+ }
8274
+
8275
+ return fileExists;
8276
+ }
8277
+
8278
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8279
+ {
8280
+ CacheTexture texturecache = null;
80748281
80758282 if (tex != null)
80768283 {
80778284 String texname = tex;
80788285
8079
- String[] split = tex.split("Textures");
8080
- if (split.length > 1)
8081
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8082
- else
8083
- if (!texname.startsWith("/"))
8084
- texname = "/Users/nbriere/Textures/" + texname;
8286
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8287
+
8288
+// String[] split = tex.split("Textures");
8289
+// if (split.length > 1)
8290
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8291
+// else
8292
+// if (!texname.startsWith("/"))
8293
+// texname = "/Users/nbriere/Textures/" + texname;
8294
+ if (!FileExists(tex))
8295
+ {
8296
+ texname = fallbackTextureName;
8297
+ }
80858298
80868299 if (CACHETEXTURE)
8087
- texture = textures.get(texname); // TEXTURE CACHE
8088
-
8089
- TextureData texturedata = null;
8090
-
8091
- if (texture == null || texture.resolution < resolution)
80928300 {
8301
+ if (bim == null)
8302
+ texturecache = textures.get(texname); // TEXTURE CACHE
8303
+ else
8304
+ texturecache = bimtextures.get(bim); // TEXTURE CACHE
8305
+ }
8306
+
8307
+ if (texturecache == null || texturecache.resolution < resolution)
8308
+ {
8309
+ TextureData texturedata = null;
8310
+
8311
+ if (bim == null)
8312
+ {
8313
+
8314
+ }
8315
+ else
80938316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80948317 {
80958318 assert(!bump);
....@@ -8101,19 +8324,19 @@
81018324 // }
81028325 // else
81038326 // {
8104
- texture = textures.get(tex);
8105
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
81068329 {
8107
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81088331 }
81098332 // }
81108333 } else
81118334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81128335 {
81138336 assert(bump);
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8337
+ texturecache = textures.get(tex);
8338
+ if (texturecache == null)
8339
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81178340 } else
81188341 {
81198342 //if (tex.equals("IMMORTAL"))
....@@ -8123,9 +8346,9 @@
81238346 //{
81248347 if (tex.equals("WHITE_NOISE"))
81258348 {
8126
- texture = textures.get(tex);
8127
- if (texture == null)
8128
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8349
+ texturecache = textures.get(tex);
8350
+ if (texturecache == null)
8351
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
81298352 } else
81308353 {
81318354 if (textureon)
....@@ -8150,7 +8373,7 @@
81508373 }
81518374
81528375 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8153
- if (!new File(cachename).exists())
8376
+ if (!FileExists(cachename))
81548377 cachename = texname;
81558378 else
81568379 processbump = false; // don't process bump map again
....@@ -8172,7 +8395,7 @@
81728395 }
81738396
81748397 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8175
- if (!new File(cachename).exists())
8398
+ if (!FileExists(cachename))
81768399 cachename = texname;
81778400 else
81788401 processbump = false; // don't process bump map again
....@@ -8181,20 +8404,22 @@
81818404 texturedata = GetFileTexture(cachename, processbump, resolution);
81828405
81838406
8184
- if (texturedata != null)
8185
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8407
+ if (texturedata == null)
8408
+ throw new Exception();
8409
+
8410
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81868411 //texture = GetTexture(tex, bump);
81878412 }
81888413 }
81898414 //}
81908415 }
81918416
8192
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81938418 {
81948419 //return false;
81958420
81968421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8197
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81988423 {
81998424 // String ext = "_highres";
82008425 // if (REDUCETEXTURE)
....@@ -8283,8 +8508,8 @@
82838508 textures.remove(texname);
82848509 }
82858510
8286
- texture.texturedata = texturedata;
8287
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
82888513
82898514 // newtex = true;
82908515 }
....@@ -8300,12 +8525,12 @@
83008525 }
83018526 }
83028527
8303
- return texture;
8528
+ return texturecache;
83048529 }
83058530
8306
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8531
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83078532 {
8308
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83098534
83108535 if (bump)
83118536 {
....@@ -8321,23 +8546,23 @@
83218546 return texture!=null?texture.texture:null;
83228547 }
83238548
8324
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8549
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83258550 {
8326
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83278552
83288553 return texture!=null?texture.texturedata:null;
83298554 }
83308555
8331
- boolean BindTexture(String tex, boolean bump, int resolution)
8556
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83328557 {
83338558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83348559 {
83358560 return false;
83368561 }
83378562
8338
- boolean newtex = false;
8563
+ //boolean newtex = false;
83398564
8340
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83418566
83428567 if (texture == null)
83438568 return false;
....@@ -8367,7 +8592,7 @@
83678592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83688593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83698594
8370
- return newtex;
8595
+ return true; // Warning: not used.
83718596 }
83728597
83738598 ShadowBuffer shadowPBuf;
....@@ -9205,11 +9430,35 @@
92059430 jy8[3] = 0.5f;
92069431 }
92079432
9208
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9433
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92099434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92109435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92119436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92129437
9438
+ void ResetOptions()
9439
+ {
9440
+ options1[0] = 100;
9441
+ options1[1] = 0.025f;
9442
+ options1[2] = 0.01f;
9443
+ options1[3] = 0;
9444
+ options1[4] = 0;
9445
+
9446
+ options2[0] = 0;
9447
+ options2[1] = 0.75f;
9448
+ options2[2] = 0;
9449
+ options2[3] = 0;
9450
+
9451
+ options3[0] = 1;
9452
+ options3[1] = 1;
9453
+ options3[2] = 1;
9454
+ options3[3] = 0;
9455
+
9456
+ options4[0] = 1;
9457
+ options4[1] = 0;
9458
+ options4[2] = 1;
9459
+ options4[3] = 0;
9460
+ }
9461
+
92139462 static int imagecount = 0; // movie generation
92149463
92159464 static int jitter = 0;
....@@ -9305,8 +9554,8 @@
93059554 assert (parentcam != renderCamera);
93069555
93079556 if (renderCamera != lightCamera)
9308
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9309
- LA.matConcat(matrix, parentcam.toParent, matrix);
9557
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93109559
93119560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93129561
....@@ -9321,8 +9570,8 @@
93219570 LA.matCopy(renderCamera.fromScreen, matrix);
93229571
93239572 if (renderCamera != lightCamera)
9324
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9325
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93269575
93279576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93289577
....@@ -9394,7 +9643,7 @@
93949643 //gl.glFlush();
93959644 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93969645
9397
- if (ANIMATION && ABORTED)
9646
+ if (Globals.ANIMATION && ABORTED)
93989647 {
93999648 System.err.println(" ABORTED FRAME");
94009649 break;
....@@ -9424,7 +9673,7 @@
94249673 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94259674
94269675 // save image
9427
- if (ANIMATION && !ABORTED)
9676
+ if (Globals.ANIMATION && !ABORTED)
94289677 {
94299678 VPwidth = viewport[2];
94309679 VPheight = viewport[3];
....@@ -9535,11 +9784,11 @@
95359784
95369785 // imagecount++;
95379786
9538
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9787
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95399788
95409789 if (!BOXMODE)
95419790 {
9542
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9791
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95439792 }
95449793
95459794 if (!BOXMODE)
....@@ -9577,7 +9826,7 @@
95779826 ABORTED = false;
95789827 }
95799828 else
9580
- GrafreeD.wav.cursor += 735 * ACSIZE;
9829
+ Grafreed.wav.cursor += 735 * ACSIZE;
95819830
95829831 if (false)
95839832 {
....@@ -10240,11 +10489,11 @@
1024010489
1024110490 public void display(GLAutoDrawable drawable)
1024210491 {
10243
- if (GrafreeD.savesound && GrafreeD.hassound)
10492
+ if (Grafreed.savesound && Grafreed.hassound)
1024410493 {
10245
- GrafreeD.wav.save();
10246
- GrafreeD.savesound = false;
10247
- GrafreeD.hassound = false;
10494
+ Grafreed.wav.save();
10495
+ Grafreed.savesound = false;
10496
+ Grafreed.hassound = false;
1024810497 }
1024910498 // if (DEBUG_SELECTION)
1025010499 // {
....@@ -10320,6 +10569,7 @@
1032010569 ANTIALIAS = 0;
1032110570 //System.out.println("RESTART");
1032210571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1032310573 }
1032410574 }
1032510575 }
....@@ -10374,7 +10624,7 @@
1037410624 Object3D theobject = object;
1037510625 Object3D theparent = object.parent;
1037610626 object.parent = null;
10377
- object = (Object3D)GrafreeD.clone(object);
10627
+ object = (Object3D)Grafreed.clone(object);
1037810628 object.Stripify();
1037910629 if (theobject.selection == null || theobject.selection.Size() == 0)
1038010630 theobject.PreprocessOcclusion(this);
....@@ -10387,13 +10637,14 @@
1038710637 ambientOcclusion = false;
1038810638 }
1038910639
10390
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039110642 {
1039210643 //if (RENDERSHADOW) // ?
1039310644 if (!IsFrozen())
1039410645 {
1039510646 // dec 2012
10396
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10647
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039710648 {
1039810649 Globals.framecount++;
1039910650 shadowbuffer.display();
....@@ -10520,8 +10771,8 @@
1052010771
1052110772 // if (parentcam != renderCamera) // not a light
1052210773 if (cam != lightCamera)
10523
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10524
- LA.matConcat(matrix, parentcam.toParent, matrix);
10774
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052510776
1052610777 for (int j = 0; j < 4; j++)
1052710778 {
....@@ -10535,8 +10786,8 @@
1053510786
1053610787 // if (parentcam != renderCamera) // not a light
1053710788 if (cam != lightCamera)
10538
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10539
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10789
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054010791
1054110792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054210793
....@@ -10795,7 +11046,16 @@
1079511046 // Bump noise
1079611047 gl.glActiveTexture(GL.GL_TEXTURE6);
1079711048 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10798
- BindTexture(NOISE_TEXTURE, false, 2);
11049
+
11050
+ try
11051
+ {
11052
+ BindTexture(null, NOISE_TEXTURE, false, 2);
11053
+ }
11054
+ catch (Exception e)
11055
+ {
11056
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11057
+ }
11058
+
1079911059
1080011060 gl.glActiveTexture(GL.GL_TEXTURE0);
1080111061 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10818,9 +11078,9 @@
1081811078
1081911079 gl.glMatrixMode(GL.GL_MODELVIEW);
1082011080
10821
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10822
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10823
-//gl.glEnable(gl.GL_MULTISAMPLE);
11081
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11082
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11083
+gl.glEnable(gl.GL_MULTISAMPLE);
1082411084 } else
1082511085 {
1082611086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10831,7 +11091,7 @@
1083111091 //System.out.println("BLENDING ON");
1083211092 gl.glEnable(GL.GL_BLEND);
1083311093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10834
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083511095 gl.glMatrixMode(gl.GL_PROJECTION);
1083611096 gl.glLoadIdentity();
1083711097
....@@ -10920,8 +11180,8 @@
1092011180 System.err.println("parentcam != renderCamera");
1092111181
1092211182 // if (cam != lightCamera)
10923
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10924
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11183
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11184
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092511185 }
1092611186
1092711187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10942,8 +11202,8 @@
1094211202 if (true) // TODO
1094311203 {
1094411204 if (cam != lightCamera)
10945
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10946
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11205
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11206
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094711207 }
1094811208
1094911209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11259,8 +11519,14 @@
1125911519 {
1126011520 renderpass++;
1126111521 // System.out.println("Draw object... ");
11522
+ STEP = 1;
1126211523 if (FAST) // in case there is no script
11263
- STEP = 16;
11524
+ STEP = 8;
11525
+
11526
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11527
+ {
11528
+ STEP *= 4;
11529
+ }
1126411530
1126511531 //object.FullInvariants();
1126611532
....@@ -11274,23 +11540,44 @@
1127411540 e.printStackTrace();
1127511541 }
1127611542
11277
- if (GrafreeD.RENDERME > 0)
11278
- GrafreeD.RENDERME--; // mechante magouille
11543
+ if (Grafreed.RENDERME > 0)
11544
+ Grafreed.RENDERME--; // mechante magouille
1127911545
1128011546 Globals.ONESTEP = false;
1128111547 }
1128211548
1128311549 static boolean zoomonce = false;
1128411550
11551
+ static void CreateSelectedPoint()
11552
+ {
11553
+ if (selectedpoint == null)
11554
+ {
11555
+ debugpointG = new Sphere();
11556
+ debugpointP = new Sphere();
11557
+ debugpointC = new Sphere();
11558
+ debugpointR = new Sphere();
11559
+
11560
+ selectedpoint = new Superellipsoid();
11561
+
11562
+ for (int i=0; i<8; i++)
11563
+ {
11564
+ debugpoints[i] = new Sphere();
11565
+ }
11566
+ }
11567
+ }
11568
+
1128511569 void DrawObject(GL gl, boolean draw)
1128611570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1128711574 //System.out.println("DRAW OBJECT " + mouseDown);
1128811575 // DrawMode() = SELECTION;
1128911576 //GL gl = getGL();
1129011577 if ((TRACK || SHADOWTRACK) || zoomonce)
1129111578 {
1129211579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11293
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129411581 pingthread.StepToTarget(true); // true);
1129511582 // zoomonce = false;
1129611583 }
....@@ -11345,7 +11632,14 @@
1134511632
1134611633 usedtextures.clear();
1134711634
11348
- BindTextures(DEFAULT_TEXTURES, 2);
11635
+ try
11636
+ {
11637
+ BindTextures(DEFAULT_TEXTURES, 2);
11638
+ }
11639
+ catch (Exception e)
11640
+ {
11641
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11642
+ }
1134911643 }
1135011644 //System.out.println("--> " + stackdepth);
1135111645 // GrafreeD.traceon();
....@@ -11355,8 +11649,9 @@
1135511649
1135611650 if (DrawMode() == DEFAULT)
1135711651 {
11358
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1135911653 {
11654
+ CreateSelectedPoint();
1136011655 float radius = 0.05f;
1136111656 if (selectedpoint.radius != radius)
1136211657 {
....@@ -11419,7 +11714,7 @@
1141911714 if (tex.equals("WHITE_NOISE"))
1142011715 continue;
1142111716
11422
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1142311718 {
1142411719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1142511720 textures.get(tex).texture.dispose();
....@@ -11436,7 +11731,14 @@
1143611731 if (checker != null && DrawMode() == DEFAULT)
1143711732 {
1143811733 //BindTexture(IMMORTAL_TEXTURE);
11439
- BindTextures(checker.GetTextures(), checker.texres);
11734
+ try
11735
+ {
11736
+ BindTextures(checker.GetTextures(), checker.texres);
11737
+ }
11738
+ catch (Exception e)
11739
+ {
11740
+ System.err.println("FAILED: " + checker.GetTextures());
11741
+ }
1144011742 // NEAREST
1144111743 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144211744 DrawChecker(gl);
....@@ -11518,7 +11820,7 @@
1151811820 return;
1151911821 }
1152011822
11521
- String string = obj.GetToolTip();
11823
+ String string = obj.toString(); //.GetToolTip();
1152211824
1152311825 GL gl = GetGL();
1152411826
....@@ -11835,8 +12137,8 @@
1183512137 //obj.TransformToWorld(light, light);
1183612138 for (int i = tp.size(); --i >= 0;)
1183712139 {
11838
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11839
- LA.xformPos(light, tp.get(i).toParent, light);
12140
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12141
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184012142 }
1184112143
1184212144
....@@ -11853,8 +12155,8 @@
1185312155 parentcam = cameras[0];
1185412156 }
1185512157
11856
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11857
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12158
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12159
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185812160
1185912161 LA.xformPos(light, renderCamera.toScreen, light);
1186012162
....@@ -12468,8 +12770,8 @@
1246812770
1246912771 // display shadow only (bump == 0)
1247012772 "SUB temp.x, half.x, shadow.x;" +
12471
- "MOV temp.y, -params6.x;" +
12472
- "SLT temp.z, temp.y, zero.x;" +
12773
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12774
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247312775 "SUB temp.y, one.x, temp.z;" +
1247412776 "MUL temp.x, temp.x, temp.y;" +
1247512777 "KIL temp.x;" +
....@@ -12598,8 +12900,10 @@
1259812900 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1259912901
1260012902 "SUB temp.x, one.x, ndotl.x;" +
12601
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12602
- "ADD temp.y, one.y, options2.y;" + // sursurface
12903
+ // Tuning for default skin
12904
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12905
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12906
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260312907 "MUL temp.x, temp.x, temp.y;" +
1260412908
1260512909 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12747,7 +13051,7 @@
1274713051 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274813052 "FLR final.x, final.y;" +
1274913053 "SUB final.y, final.y, final.x;" +
12750
- //"MUL final.x, final.x, c256i;" +
13054
+ "MUL final.x, final.x, c256i;" +
1275113055 "MOV final.z, zero.x;" +
1275213056 "MOV final.a, one.w;":""
1275313057 ) +
....@@ -12755,7 +13059,7 @@
1275513059 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275613060 "FLR final.x, final.y;" +
1275713061 "SUB final.y, final.y, final.x;" +
12758
- //"MUL final.x, final.x, c256i;" +
13062
+ "MUL final.x, final.x, c256i;" +
1275913063 "MOV final.z, zero.x;" +
1276013064 "MOV final.a, one.w;":""
1276113065 ) +
....@@ -12798,7 +13102,7 @@
1279813102 //once = true;
1279913103 }
1280013104
12801
- System.out.print("Program #" + mode + "; length = " + program.length());
13105
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280213106 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280313107 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280413108
....@@ -12931,12 +13235,16 @@
1293113235
1293213236 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293313237 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13238
+
13239
+ // Compare fragment depth in light space with shadowmap.
1293413240 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293513241 "SGE temp.y, temp.x, zero.x;" +
12936
- "SUB " + shadow + ".y, one.x, temp.y;" +
13242
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13243
+
13244
+ // Reverse comparison
1293713245 "SUB temp.x, one.x, temp.x;" +
1293813246 "MUL " + shadow + ".x, temp.x, temp.y;" +
12939
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13247
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294013248 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294113249
1294213250 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12950,6 +13258,10 @@
1295013258 // No shadow for backface
1295113259 "DP3 temp.x, normal, lightd;" +
1295213260 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13261
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13262
+
13263
+ // No shadow when out of frustrum
13264
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295313265 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295413266 "";
1295513267 }
....@@ -13096,7 +13408,8 @@
1309613408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309713409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309813410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13099
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1310013413
1310113414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310213415 // OUT : diff, spec
....@@ -13112,9 +13425,10 @@
1311213425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311313426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311413427 //"MOV " + dest + ".w," + "normal.z;" +
13115
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13116
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13117
- //"MOV " + dest + ".z," + "params2.w;" +
13428
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13429
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13430
+
13431
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1311813432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1311913433 "RCP " + dest + ".w," + dest + ".w;" +
1312013434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13508,7 +13822,7 @@
1350813822 public void mousePressed(MouseEvent e)
1350913823 {
1351013824 //System.out.println("mousePressed: " + e);
13511
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13825
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351213826 }
1351313827
1351413828 static long prevtime = 0;
....@@ -13584,8 +13898,8 @@
1358413898 // mode |= META;
1358513899 //}
1358613900
13587
- SetMouseMode(WHEEL | e.getModifiersEx());
13588
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13901
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13902
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1358913903 anchorX = ax;
1359013904 anchorY = ay;
1359113905 prevX = px;
....@@ -13619,6 +13933,7 @@
1361913933 else
1362013934 if (evt.getSource() == AAtimer)
1362113935 {
13936
+ Globals.TIMERRUNNING = false;
1362213937 if (mouseDown)
1362313938 {
1362413939 //new Exception().printStackTrace();
....@@ -13644,6 +13959,10 @@
1364413959 // LIVE = waslive;
1364513960 // wasliveok = true;
1364613961 // waslive = false;
13962
+
13963
+ // May 2019 Forget it:
13964
+ if (true)
13965
+ return;
1364713966
1364813967 // source == timer
1364913968 if (mouseDown)
....@@ -13674,7 +13993,7 @@
1367413993
1367513994 // fev 2014???
1367613995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13677
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367813997 pingthread.StepToTarget(true); // true);
1367913998 }
1368013999 // if (!LIVE)
....@@ -13683,12 +14002,13 @@
1368314002
1368414003 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368514004
13686
- void clickStart(int x, int y, int modifiers)
14005
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368714006 {
1368814007 if (!wasliveok)
1368914008 return;
1369014009
1369114010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1369214012
1369314013 // waslive = LIVE;
1369414014 // LIVE = false;
....@@ -13700,7 +14020,7 @@
1370014020 // touched = true; // main DL
1370114021 if (isRenderer)
1370214022 {
13703
- SetMouseMode(modifiers);
14023
+ SetMouseMode(modifiers, modifiersex);
1370414024 }
1370514025
1370614026 selectX = anchorX = x;
....@@ -13713,7 +14033,7 @@
1371314033 clicked = true;
1371414034 hold = false;
1371514035
13716
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14036
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371714037 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371814038 {
1371914039 // System.out.println("RESTART II " + modifiers);
....@@ -13744,7 +14064,7 @@
1374414064 info.camera = renderCamera;
1374514065 info.x = x;
1374614066 info.y = y;
13747
- info.modifiers = modifiers;
14067
+ info.modifiers = modifiersex;
1374814068 editObj = object.doEditClick(info, 0);
1374914069 if (!editObj)
1375014070 {
....@@ -13761,9 +14081,12 @@
1376114081
1376214082 public void mouseDragged(MouseEvent e)
1376314083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
1376414086 //System.out.println("mouseDragged: " + e);
1376514087 if (isRenderer)
1376614088 movingcamera = true;
14089
+
1376714090 //if (drawing)
1376814091 //return;
1376914092 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13773,7 +14096,7 @@
1377314096 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377414097 }
1377514098 else
13776
- drag(e.getX(), e.getY(), e.getModifiersEx());
14099
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377714100
1377814101 //try { Thread.sleep(1); } catch (Exception ex) {}
1377914102 }
....@@ -13946,6 +14269,7 @@
1394614269
1394714270 public void run()
1394814271 {
14272
+ new Exception().printStackTrace();
1394914273 System.exit(0);
1395014274 for (;;)
1395114275 {
....@@ -14009,7 +14333,7 @@
1400914333 {
1401014334 Globals.lighttouched = true;
1401114335 }
14012
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14336
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401314337 }
1401414338 //else
1401514339 }
....@@ -14023,12 +14347,12 @@
1402314347 void GoDown(int mod)
1402414348 {
1402514349 MODIFIERS |= COMMAND;
14026
- /*
14350
+ /**/
1402714351 if((mod&SHIFT) == SHIFT)
1402814352 manipCamera.RotatePosition(0, -speed);
1402914353 else
14030
- manipCamera.BackForth(0, -speed*delta, getWidth());
14031
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1403214356 if ((mod & SHIFT) == SHIFT)
1403314357 {
1403414358 mouseMode = mouseMode; // VR??
....@@ -14044,12 +14368,12 @@
1404414368 void GoUp(int mod)
1404514369 {
1404614370 MODIFIERS |= COMMAND;
14047
- /*
14371
+ /**/
1404814372 if((mod&SHIFT) == SHIFT)
1404914373 manipCamera.RotatePosition(0, speed);
1405014374 else
14051
- manipCamera.BackForth(0, speed*delta, getWidth());
14052
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1405314377 if ((mod & SHIFT) == SHIFT)
1405414378 {
1405514379 mouseMode = mouseMode;
....@@ -14065,12 +14389,12 @@
1406514389 void GoLeft(int mod)
1406614390 {
1406714391 MODIFIERS |= COMMAND;
14068
- /*
14392
+ /**/
1406914393 if((mod&SHIFT) == SHIFT)
14070
- manipCamera.RotatePosition(speed, 0);
14071
- else
1407214394 manipCamera.Translate(speed*delta, 0, getWidth());
14073
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1407414398 if ((mod & SHIFT) == SHIFT)
1407514399 {
1407614400 mouseMode = mouseMode;
....@@ -14086,12 +14410,12 @@
1408614410 void GoRight(int mod)
1408714411 {
1408814412 MODIFIERS |= COMMAND;
14089
- /*
14413
+ /**/
1409014414 if((mod&SHIFT) == SHIFT)
14091
- manipCamera.RotatePosition(-speed, 0);
14092
- else
1409314415 manipCamera.Translate(-speed*delta, 0, getWidth());
14094
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1409514419 if ((mod & SHIFT) == SHIFT)
1409614420 {
1409714421 mouseMode = mouseMode;
....@@ -14109,7 +14433,7 @@
1410914433 int X, Y;
1411014434 boolean SX, SY;
1411114435
14112
- void drag(int x, int y, int modifiers)
14436
+ void drag(int x, int y, int modifiers, int modifiersex)
1411314437 {
1411414438 if (IsFrozen())
1411514439 {
....@@ -14118,17 +14442,17 @@
1411814442
1411914443 drag = true; // NEW
1412014444
14121
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14445
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412214446
1412314447 X = x;
1412414448 Y = y;
1412514449 // floating state for animation
14126
- MODIFIERS = modifiers;
14127
- modifiers &= ~1024;
14450
+ MODIFIERS = modifiersex;
14451
+ modifiersex &= ~1024;
1412814452 if (false) // modifiers != 0)
1412914453 {
1413014454 //new Exception().printStackTrace();
14131
- System.out.println("mouseDragged: " + modifiers);
14455
+ System.out.println("mouseDragged: " + modifiersex);
1413214456 System.out.println("SHIFT = " + SHIFT);
1413314457 System.out.println("CONTROL = " + COMMAND);
1413414458 System.out.println("META = " + META);
....@@ -14148,7 +14472,8 @@
1414814472 info.camera = renderCamera;
1414914473 info.x = x;
1415014474 info.y = y;
14151
- object.editWindow.copy.doEditDrag(info);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415214477 } else
1415314478 {
1415414479 if (x < startX)
....@@ -14312,7 +14637,9 @@
1431214637 ci.camera = renderCamera;
1431314638 if (!isRenderer)
1431414639 {
14315
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1431614643 {
1431714644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1431814645 } else
....@@ -14324,7 +14651,11 @@
1432414651
1432514652 public void mouseReleased(MouseEvent e)
1432614653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1432714656 movingcamera = false;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1432814659 //System.out.println("mouseReleased: " + e);
1432914660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433014661 }
....@@ -14347,9 +14678,9 @@
1434714678 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1434814679 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1434914680
14350
- if (control || command || IsFrozen())
14681
+// No delay if (control || command || IsFrozen())
1435114682 timeout = true;
14352
- else
14683
+// ?? May 2019 else
1435314684 // timer.setDelay((modifiers & 128) != 0?0:350);
1435414685 mouseDown = false;
1435514686 if (!control && !command) // june 2013
....@@ -14459,7 +14790,7 @@
1445914790 System.out.println("keyReleased: " + e);
1446014791 }
1446114792
14462
- void SetMouseMode(int modifiers)
14793
+ void SetMouseMode(int modifiers, int modifiersex)
1446314794 {
1446414795 //System.out.println("SetMouseMode = " + modifiers);
1446514796 //modifiers &= ~1024;
....@@ -14471,25 +14802,25 @@
1447114802 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447214803 // return;
1447314804 //System.out.println("SetMode = " + modifiers);
14474
- if ((modifiers & WHEEL) == WHEEL)
14805
+ if ((modifiersex & WHEEL) == WHEEL)
1447514806 {
1447614807 mouseMode |= ZOOM;
1447714808 }
1447814809
1447914810 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14480
- if (capsLocked || (modifiers & META) == META)
14811
+ if (capsLocked) // || (modifiers & META) == META)
1448114812 {
1448214813 mouseMode |= VR; // BACKFORTH;
1448314814 }
14484
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14815
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448514816 {
1448614817 mouseMode |= SELECT;
1448714818 }
14488
- if ((modifiers & COMMAND) == COMMAND)
14819
+ if ((modifiersex & COMMAND) == COMMAND)
1448914820 {
1449014821 mouseMode |= SELECT;
1449114822 }
14492
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14823
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449314824 {
1449414825 mouseMode &= ~VR;
1449514826 mouseMode |= TRANSLATE;
....@@ -14518,7 +14849,7 @@
1451814849
1451914850 if (isRenderer) //
1452014851 {
14521
- SetMouseMode(modifiers);
14852
+ SetMouseMode(0, modifiers);
1452214853 }
1452314854
1452414855 Globals.theRenderer.keyPressed(key);
....@@ -14665,7 +14996,9 @@
1466514996 case 'E' : COMPACT ^= true;
1466614997 repaint();
1466714998 break;
14668
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1466915002 repaint();
1467015003 break;
1467115004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14690,8 +15023,8 @@
1469015023 RevertCamera();
1469115024 repaint();
1469215025 break;
14693
- case 'L':
1469415026 case 'l':
15027
+ //case 'L':
1469515028 if (lightMode)
1469615029 {
1469715030 lightMode = false;
....@@ -14834,9 +15167,9 @@
1483415167 case '_':
1483515168 kompactbit = 5;
1483615169 break;
14837
- case '+':
14838
- kompactbit = 6;
14839
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1484015173 case ' ':
1484115174 lightMode ^= true;
1484215175 Globals.lighttouched = true;
....@@ -14848,13 +15181,14 @@
1484815181 case ESC:
1484915182 RENDERPROGRAM += 1;
1485015183 RENDERPROGRAM %= 3;
15184
+
1485115185 repaint();
1485215186 break;
1485315187 case 'Z':
1485415188 //RESIZETEXTURE ^= true;
1485515189 //break;
1485615190 case 'z':
14857
- RENDERSHADOW ^= true;
15191
+ Globals.RENDERSHADOW ^= true;
1485815192 Globals.lighttouched = true;
1485915193 repaint();
1486015194 break;
....@@ -14887,8 +15221,9 @@
1488715221 case DELETE:
1488815222 ClearSelection();
1488915223 break;
14890
- /*
1489115224 case '+':
15225
+
15226
+ /*
1489215227 //fontsize += 1;
1489315228 bbzoom *= 2;
1489415229 repaint();
....@@ -14905,17 +15240,17 @@
1490515240 case '=':
1490615241 IncDepth();
1490715242 //fontsize += 1;
14908
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1490915244 maskbit = 6;
1491015245 break;
1491115246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491215247 DecDepth();
1491315248 maskbit = 5;
1491415249 //if(fontsize > 1) fontsize -= 1;
14915
- if (object.editWindow == null)
14916
- new Exception().printStackTrace();
14917
- else
14918
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1491915254 break;
1492015255 case '{':
1492115256 manipCamera.shaper_fovy /= 1.1;
....@@ -14978,7 +15313,7 @@
1497815313 //mode = ROTATE;
1497915314 if ((MODIFIERS & COMMAND) == 0) // VR??
1498015315 {
14981
- SetMouseMode(modifiers);
15316
+ SetMouseMode(0, modifiers);
1498215317 }
1498315318 }
1498415319
....@@ -15114,7 +15449,7 @@
1511415449 {
1511515450 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511615451 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15117
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15452
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1511815453 {
1511915454 mouseMoved(e);
1512015455 } else
....@@ -15139,11 +15474,12 @@
1513915474 }
1514015475 */
1514115476
15142
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1514315478 }
1514415479
1514515480 void SelectParent()
1514615481 {
15482
+ new Exception().printStackTrace();
1514715483 System.exit(0);
1514815484 Composite group = (Composite) object;
1514915485 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15155,10 +15491,10 @@
1515515491 {
1515615492 //selectees.remove(i);
1515715493 System.out.println("select parent of " + elem);
15158
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1515915495 } else
1516015496 {
15161
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516215498 }
1516315499
1516415500 first = false;
....@@ -15167,6 +15503,7 @@
1516715503
1516815504 void SelectChildren()
1516915505 {
15506
+ new Exception().printStackTrace();
1517015507 System.exit(0);
1517115508 /*
1517215509 Composite group = (Composite) object;
....@@ -15199,12 +15536,12 @@
1519915536 for (int j = 0; j < group.children.size(); j++)
1520015537 {
1520115538 elem = (Object3D) group.children.elementAt(j);
15202
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520315540 first = false;
1520415541 }
1520515542 } else
1520615543 {
15207
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520815545 }
1520915546
1521015547 first = false;
....@@ -15215,21 +15552,21 @@
1521515552 {
1521615553 //Composite group = (Composite) object;
1521715554 Object3D group = object;
15218
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1521915556 }
1522015557
1522115558 void ResetTransform(int mask)
1522215559 {
1522315560 //Composite group = (Composite) object;
1522415561 Object3D group = object;
15225
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1522615563 }
1522715564
1522815565 void FlipTransform()
1522915566 {
1523015567 //Composite group = (Composite) object;
1523115568 Object3D group = object;
15232
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1523315570 // group.editWindow.ReduceMesh(true);
1523415571 }
1523515572
....@@ -15237,7 +15574,7 @@
1523715574 {
1523815575 //Composite group = (Composite) object;
1523915576 Object3D group = object;
15240
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1524115578 // group.editWindow.ReduceMesh(true);
1524215579 }
1524315580
....@@ -15245,7 +15582,7 @@
1524515582 {
1524615583 //Composite group = (Composite) object;
1524715584 Object3D group = object;
15248
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1524915586 }
1525015587
1525115588 void IncDepth()
....@@ -15331,7 +15668,9 @@
1533115668 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533215669 //Image img = CreateImage(width, height);
1533315670 //System.out.println("width = " + width + "; height = " + height + "\n");
15671
+
1533415672 Graphics gr = g; // img.getGraphics();
15673
+
1533515674 if (!hasMarquee)
1533615675 {
1533715676 if (Xmin < Xmax) // !locked)
....@@ -15419,6 +15758,7 @@
1541915758 info.bounds.y += (height - desired) / 2;
1542015759 }
1542115760 }
15761
+
1542215762 info.g = gr;
1542315763 info.camera = renderCamera;
1542415764 /*
....@@ -15428,15 +15768,55 @@
1542815768 */
1542915769 if (!isRenderer)
1543015770 {
15431
- object.drawEditHandles(info, 0);
15771
+ Grafreed.Assert(object != null);
15772
+ Grafreed.Assert(object.selection != null);
15773
+ if (object.selection.Size() > 0)
15774
+ {
15775
+ int hitSomething = object.selection.get(0).hitSomething;
15776
+
15777
+ info.DX = 0;
15778
+ info.DY = 0;
15779
+ info.W = 1;
15780
+ if (hitSomething == Object3D.hitCenter)
15781
+ {
15782
+ info.DX = X;
15783
+ if (X != 0)
15784
+ info.DX -= info.bounds.width/2;
15785
+
15786
+ info.DY = Y;
15787
+ if (Y != 0)
15788
+ info.DY -= info.bounds.height/2;
15789
+ }
15790
+
15791
+ object.drawEditHandles(info, 0);
15792
+
15793
+ if (drag && (X != 0 || Y != 0))
15794
+ {
15795
+ switch (hitSomething)
15796
+ {
15797
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15798
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15799
+ break;
15800
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15801
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15802
+ break;
15803
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15804
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15805
+ break;
15806
+ }
15807
+
15808
+ }
15809
+ }
1543215810 }
1543315811 }
15812
+
1543415813 if (isRenderer)
1543515814 {
1543615815 //gr.setColor(Color.black);
1543715816 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1543815817 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1543915818 }
15819
+
1544015820 if (hasMarquee)
1544115821 {
1544215822 gr.setXORMode(Color.white);
....@@ -15549,6 +15929,7 @@
1554915929 public boolean mouseDown(Event evt, int x, int y)
1555015930 {
1555115931 System.out.println("mouseDown: " + evt);
15932
+ System.exit(0);
1555215933 /*
1555315934 locked = true;
1555415935 drag = false;
....@@ -15592,7 +15973,7 @@
1559215973 {
1559315974 keyPressed(0, modifiers);
1559415975 }
15595
- clickStart(x, y, modifiers);
15976
+ // clickStart(x, y, modifiers);
1559615977 return true;
1559715978 }
1559815979
....@@ -15710,7 +16091,7 @@
1571016091 {
1571116092 keyReleased(0, 0);
1571216093 }
15713
- drag(x, y, modifiers);
16094
+ drag(x, y, 0, modifiers);
1571416095 return true;
1571516096 }
1571616097
....@@ -15842,7 +16223,7 @@
1584216223 Object3D object;
1584316224 static Object3D trackedobject;
1584416225 Camera renderCamera; // Light or Eye (or Occlusion)
15845
- /*static*/ Camera manipCamera; // Light or Eye
16226
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1584616227 /*static*/ Camera eyeCamera;
1584716228 /*static*/ Camera lightCamera;
1584816229 int cameracount;
....@@ -16127,16 +16508,16 @@
1612716508 cStatic.objectstack[materialdepth++] = checker;
1612816509 //System.out.println("material " + material);
1612916510 //Applet3D.tracein(this, selected);
16130
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1613116512
1613216513 //checker.GetMaterial().Draw(this, false); // true);
16133
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613416515
1613516516 materialdepth -= 1;
1613616517 if (materialdepth > 0)
1613716518 {
16138
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16139
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16519
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16520
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614016521 }
1614116522 //checker.GetMaterial().opacity = 1f;
1614216523 ////checker.GetMaterial().ambient = 1f;
....@@ -16222,6 +16603,14 @@
1622216603 }
1622316604 }
1622416605
16606
+ private Object3D GetFolder()
16607
+ {
16608
+ Object3D folder = object.GetWindow().copy;
16609
+ if (object.GetWindow().copy.selection.Size() > 0)
16610
+ folder = object.GetWindow().copy.selection.elementAt(0);
16611
+ return folder;
16612
+ }
16613
+
1622516614 class SelectBuffer implements GLEventListener
1622616615 {
1622716616
....@@ -16280,6 +16669,7 @@
1628016669 {
1628116670 if (!selection)
1628216671 {
16672
+ new Exception().printStackTrace();
1628316673 System.exit(0);
1628416674 return;
1628516675 }
....@@ -16300,6 +16690,17 @@
1630016690
1630116691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630216692
16693
+ if (PAINTMODE)
16694
+ {
16695
+ if (object.GetWindow().copy.selection.Size() > 0)
16696
+ {
16697
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16698
+
16699
+ // Make what you paint not selectable.
16700
+ paintobj.ResetSelectable();
16701
+ }
16702
+ }
16703
+
1630316704 //int tmp = selection_view;
1630416705 //selection_view = -1;
1630516706 int temp = DrawMode();
....@@ -16311,6 +16712,17 @@
1631116712 // temp = DEFAULT; // patch for selection debug
1631216713 Globals.drawMode = temp; // WARNING
1631316714
16715
+ if (PAINTMODE)
16716
+ {
16717
+ if (object.GetWindow().copy.selection.Size() > 0)
16718
+ {
16719
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16720
+
16721
+ // Revert.
16722
+ paintobj.RestoreSelectable();
16723
+ }
16724
+ }
16725
+
1631416726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1631516727
1631616728 // trying different ways of getting the depth info over
....@@ -16358,6 +16770,8 @@
1635816770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1635916771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636016772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1636116775
1636216776 // Will fit the mesh !!!
1636316777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16407,34 +16821,36 @@
1640716821 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]));
1640816822 }
1640916823
16410
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16824
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641116825 }
1641216826 }
1641316827
1641416828 if (!movingcamera && !PAINTMODE)
16415
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1641616830
16417
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16831
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1641816832 {
16419
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16833
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642016834
16421
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642216838
16423
- group.CreateMaterial(); // use a void leaf to select instances
16424
-
16425
- group.add(paintobj); // link
16426
-
16427
- object.editWindow.SnapObject(group);
16428
-
16429
- Object3D folder = object.editWindow.copy;
16430
-
16431
- if (object.editWindow.copy.selection.Size() > 0)
16432
- folder = object.editWindow.copy.selection.elementAt(0);
16433
-
16434
- folder.add(group);
16435
-
16436
- object.editWindow.ResetModel();
16437
- object.editWindow.refreshContents();
16839
+ Object3D inst = new Object3D("inst" + paintcount++);
16840
+
16841
+ inst.CreateMaterial(); // use a void leaf to select instances
16842
+
16843
+ inst.add(paintobj); // link
16844
+
16845
+ object.GetWindow().SnapObject(inst);
16846
+
16847
+ Object3D folder = paintFolder; // GetFolder();
16848
+
16849
+ folder.add(inst);
16850
+
16851
+ object.GetWindow().ResetModel();
16852
+ object.GetWindow().refreshContents();
16853
+ }
1643816854 }
1643916855 else
1644016856 paintcount = 0;
....@@ -16473,6 +16889,11 @@
1647316889 //System.out.println("objects[color] = " + objects[color]);
1647416890 //objects[color].Select();
1647516891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1647616897 object.Select(color, deselect);
1647716898 }
1647816899
....@@ -16572,7 +16993,7 @@
1657216993 gl.glDisable(gl.GL_CULL_FACE);
1657316994 }
1657416995
16575
- if (!RENDERSHADOW)
16996
+ if (!Globals.RENDERSHADOW)
1657616997 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657716998
1657816999 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16582,7 +17003,7 @@
1658217003 //gl.glColorMask(false, false, false, false);
1658317004
1658417005 //render_scene_from_light_view(gl, drawable, 0, 0);
16585
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17006
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1658617007 {
1658717008 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658817009
....@@ -16998,23 +17419,15 @@
1699817419 int AAbuffersize = 0;
1699917420
1700017421 //double[] selectedpoint = new double[3];
17001
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1700217423 static Sphere previousselectedpoint = null;
17003
- static Sphere debugpointG = new Sphere();
17004
- static Sphere debugpointP = new Sphere();
17005
- static Sphere debugpointC = new Sphere();
17006
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1700717428
1700817429 static Sphere debugpoints[] = new Sphere[8];
1700917430
17010
- static
17011
- {
17012
- for (int i=0; i<8; i++)
17013
- {
17014
- debugpoints[i] = new Sphere();
17015
- }
17016
- }
17017
-
1701817431 static void InitPoints(float radius)
1701917432 {
1702017433 for (int i=0; i<8; i++)