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 {
....@@ -7902,7 +7960,7 @@
79027960 String pigment = Object3D.GetPigment(tex);
79037961 String bump = Object3D.GetBump(tex);
79047962
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
7963
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79067964 {
79077965 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79087966 // System.out.println("; bump = " + bump);
....@@ -7919,6 +7977,64 @@
79197977
79207978 ReleaseTexture(bump, true);
79217979 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);
79228038 }
79238039
79248040 void ReleaseTexture(String tex, boolean bump)
....@@ -8024,7 +8140,55 @@
80248140 }
80258141 }
80268142
8027
- /*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
80288192 {
80298193 if (// DrawMode() != 0 || /*tex == null ||*/
80308194 ambientOcclusion ) // || !textureon)
....@@ -8034,18 +8198,48 @@
80348198
80358199 if (tex == null)
80368200 {
8037
- BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
8201
+ BindTexture(null, null,false,resolution);
80398202 return;
80408203 }
80418204
80428205 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
+
80438238 String bump = Object3D.GetBump(tex);
80448239
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8240
+ usedtextures.add(bump);
80478241
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8242
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498243 {
80508244 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518245 // System.out.println("; bump = " + bump);
....@@ -8055,42 +8249,70 @@
80558249 {
80568250 bump = null;
80578251 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628252
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658253 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8254
+ BindTexture(tex.bumptexture, bump, true, resolution);
80678255 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708256 }
80718257
8072
- 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)
80738261 {
8074
- 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;
80758281
80768282 if (tex != null)
80778283 {
80788284 String texname = tex;
80798285
8080
- String[] split = tex.split("Textures");
8081
- if (split.length > 1)
8082
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8083
- else
8084
- if (!texname.startsWith("/"))
8085
- texname = "/Users/nbriere/Textures/" + texname;
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
+ }
80868298
80878299 if (CACHETEXTURE)
8088
- texture = textures.get(texname); // TEXTURE CACHE
8089
-
8090
- TextureData texturedata = null;
8091
-
8092
- if (texture == null || texture.resolution < resolution)
80938300 {
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
80948316 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80958317 {
80968318 assert(!bump);
....@@ -8102,19 +8324,19 @@
81028324 // }
81038325 // else
81048326 // {
8105
- texture = textures.get(tex);
8106
- if (texture == null)
8327
+ texturecache = textures.get(tex);
8328
+ if (texturecache == null)
81078329 {
8108
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8330
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81098331 }
81108332 // }
81118333 } else
81128334 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81138335 {
81148336 assert(bump);
8115
- texture = textures.get(tex);
8116
- if (texture == null)
8117
- 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);
81188340 } else
81198341 {
81208342 //if (tex.equals("IMMORTAL"))
....@@ -8124,9 +8346,9 @@
81248346 //{
81258347 if (tex.equals("WHITE_NOISE"))
81268348 {
8127
- texture = textures.get(tex);
8128
- if (texture == null)
8129
- 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);
81308352 } else
81318353 {
81328354 if (textureon)
....@@ -8151,7 +8373,7 @@
81518373 }
81528374
81538375 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8376
+ if (!FileExists(cachename))
81558377 cachename = texname;
81568378 else
81578379 processbump = false; // don't process bump map again
....@@ -8173,7 +8395,7 @@
81738395 }
81748396
81758397 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8398
+ if (!FileExists(cachename))
81778399 cachename = texname;
81788400 else
81798401 processbump = false; // don't process bump map again
....@@ -8182,20 +8404,22 @@
81828404 texturedata = GetFileTexture(cachename, processbump, resolution);
81838405
81848406
8185
- if (texturedata != null)
8186
- 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);
81878411 //texture = GetTexture(tex, bump);
81888412 }
81898413 }
81908414 //}
81918415 }
81928416
8193
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8417
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81948418 {
81958419 //return false;
81968420
81978421 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8198
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8422
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81998423 {
82008424 // String ext = "_highres";
82018425 // if (REDUCETEXTURE)
....@@ -8284,8 +8508,8 @@
82848508 textures.remove(texname);
82858509 }
82868510
8287
- texture.texturedata = texturedata;
8288
- textures.put(texname, texture);
8511
+ //texture.texturedata = texturedata;
8512
+ textures.put(texname, texturecache);
82898513
82908514 // newtex = true;
82918515 }
....@@ -8301,12 +8525,12 @@
83018525 }
83028526 }
83038527
8304
- return texture;
8528
+ return texturecache;
83058529 }
83068530
8307
- 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
83088532 {
8309
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8533
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83108534
83118535 if (bump)
83128536 {
....@@ -8322,23 +8546,23 @@
83228546 return texture!=null?texture.texture:null;
83238547 }
83248548
8325
- 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
83268550 {
8327
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8551
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83288552
83298553 return texture!=null?texture.texturedata:null;
83308554 }
83318555
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8556
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83338557 {
83348558 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358559 {
83368560 return false;
83378561 }
83388562
8339
- boolean newtex = false;
8563
+ //boolean newtex = false;
83408564
8341
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8565
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83428566
83438567 if (texture == null)
83448568 return false;
....@@ -8368,7 +8592,7 @@
83688592 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83698593 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83708594
8371
- return newtex;
8595
+ return true; // Warning: not used.
83728596 }
83738597
83748598 ShadowBuffer shadowPBuf;
....@@ -9206,11 +9430,35 @@
92069430 jy8[3] = 0.5f;
92079431 }
92089432
9209
- 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
92109434 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119435 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129436 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139437
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
+
92149462 static int imagecount = 0; // movie generation
92159463
92169464 static int jitter = 0;
....@@ -9306,8 +9554,8 @@
93069554 assert (parentcam != renderCamera);
93079555
93089556 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9557
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9558
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119559
93129560 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139561
....@@ -9322,8 +9570,8 @@
93229570 LA.matCopy(renderCamera.fromScreen, matrix);
93239571
93249572 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279575
93289576 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299577
....@@ -9395,7 +9643,7 @@
93959643 //gl.glFlush();
93969644 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979645
9398
- if (ANIMATION && ABORTED)
9646
+ if (Globals.ANIMATION && ABORTED)
93999647 {
94009648 System.err.println(" ABORTED FRAME");
94019649 break;
....@@ -9425,7 +9673,7 @@
94259673 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269674
94279675 // save image
9428
- if (ANIMATION && !ABORTED)
9676
+ if (Globals.ANIMATION && !ABORTED)
94299677 {
94309678 VPwidth = viewport[2];
94319679 VPheight = viewport[3];
....@@ -9536,11 +9784,11 @@
95369784
95379785 // imagecount++;
95389786
9539
- 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;
95409788
95419789 if (!BOXMODE)
95429790 {
9543
- 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) + ")");
95449792 }
95459793
95469794 if (!BOXMODE)
....@@ -9578,7 +9826,7 @@
95789826 ABORTED = false;
95799827 }
95809828 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9829
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829830
95839831 if (false)
95849832 {
....@@ -10241,11 +10489,11 @@
1024110489
1024210490 public void display(GLAutoDrawable drawable)
1024310491 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10492
+ if (Grafreed.savesound && Grafreed.hassound)
1024510493 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10494
+ Grafreed.wav.save();
10495
+ Grafreed.savesound = false;
10496
+ Grafreed.hassound = false;
1024910497 }
1025010498 // if (DEBUG_SELECTION)
1025110499 // {
....@@ -10321,6 +10569,7 @@
1032110569 ANTIALIAS = 0;
1032210570 //System.out.println("RESTART");
1032310571 AAtimer.restart();
10572
+ Globals.TIMERRUNNING = true;
1032410573 }
1032510574 }
1032610575 }
....@@ -10375,7 +10624,7 @@
1037510624 Object3D theobject = object;
1037610625 Object3D theparent = object.parent;
1037710626 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10627
+ object = (Object3D)Grafreed.clone(object);
1037910628 object.Stripify();
1038010629 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110630 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10637,14 @@
1038810637 ambientOcclusion = false;
1038910638 }
1039010639
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10640
+ if (//Globals.lighttouched &&
10641
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210642 {
1039310643 //if (RENDERSHADOW) // ?
1039410644 if (!IsFrozen())
1039510645 {
1039610646 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10647
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810648 {
1039910649 Globals.framecount++;
1040010650 shadowbuffer.display();
....@@ -10521,8 +10771,8 @@
1052110771
1052210772 // if (parentcam != renderCamera) // not a light
1052310773 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10774
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10775
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610776
1052710777 for (int j = 0; j < 4; j++)
1052810778 {
....@@ -10536,8 +10786,8 @@
1053610786
1053710787 // if (parentcam != renderCamera) // not a light
1053810788 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10789
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10790
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110791
1054210792 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310793
....@@ -10796,7 +11046,16 @@
1079611046 // Bump noise
1079711047 gl.glActiveTexture(GL.GL_TEXTURE6);
1079811048 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080011059
1080111060 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211061 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10819,9 +11078,9 @@
1081911078
1082011079 gl.glMatrixMode(GL.GL_MODELVIEW);
1082111080
10822
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10823
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10824
-//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);
1082511084 } else
1082611085 {
1082711086 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10832,7 +11091,7 @@
1083211091 //System.out.println("BLENDING ON");
1083311092 gl.glEnable(GL.GL_BLEND);
1083411093 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10835
-
11094
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083611095 gl.glMatrixMode(gl.GL_PROJECTION);
1083711096 gl.glLoadIdentity();
1083811097
....@@ -10921,8 +11180,8 @@
1092111180 System.err.println("parentcam != renderCamera");
1092211181
1092311182 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611185 }
1092711186
1092811187 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11202,8 @@
1094311202 if (true) // TODO
1094411203 {
1094511204 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811207 }
1094911208
1095011209 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11519,14 @@
1126011519 {
1126111520 renderpass++;
1126211521 // System.out.println("Draw object... ");
11522
+ STEP = 1;
1126311523 if (FAST) // in case there is no script
11264
- STEP = 16;
11524
+ STEP = 8;
11525
+
11526
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11527
+ {
11528
+ STEP *= 4;
11529
+ }
1126511530
1126611531 //object.FullInvariants();
1126711532
....@@ -11275,23 +11540,44 @@
1127511540 e.printStackTrace();
1127611541 }
1127711542
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11543
+ if (Grafreed.RENDERME > 0)
11544
+ Grafreed.RENDERME--; // mechante magouille
1128011545
1128111546 Globals.ONESTEP = false;
1128211547 }
1128311548
1128411549 static boolean zoomonce = false;
1128511550
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
+
1128611569 void DrawObject(GL gl, boolean draw)
1128711570 {
11571
+ // To clear camera values
11572
+ ResetOptions();
11573
+
1128811574 //System.out.println("DRAW OBJECT " + mouseDown);
1128911575 // DrawMode() = SELECTION;
1129011576 //GL gl = getGL();
1129111577 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211578 {
1129311579 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11580
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511581 pingthread.StepToTarget(true); // true);
1129611582 // zoomonce = false;
1129711583 }
....@@ -11346,7 +11632,14 @@
1134611632
1134711633 usedtextures.clear();
1134811634
11349
- 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
+ }
1135011643 }
1135111644 //System.out.println("--> " + stackdepth);
1135211645 // GrafreeD.traceon();
....@@ -11356,8 +11649,9 @@
1135611649
1135711650 if (DrawMode() == DEFAULT)
1135811651 {
11359
- if (DEBUG)
11652
+ if (Globals.DEBUG)
1136011653 {
11654
+ CreateSelectedPoint();
1136111655 float radius = 0.05f;
1136211656 if (selectedpoint.radius != radius)
1136311657 {
....@@ -11420,7 +11714,7 @@
1142011714 if (tex.equals("WHITE_NOISE"))
1142111715 continue;
1142211716
11423
- if (!usedtextures.containsKey(tex))
11717
+ if (!usedtextures.contains(tex))
1142411718 {
1142511719 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1142611720 textures.get(tex).texture.dispose();
....@@ -11437,7 +11731,14 @@
1143711731 if (checker != null && DrawMode() == DEFAULT)
1143811732 {
1143911733 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111742 // NEAREST
1144211743 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311744 DrawChecker(gl);
....@@ -11519,7 +11820,7 @@
1151911820 return;
1152011821 }
1152111822
11522
- String string = obj.GetToolTip();
11823
+ String string = obj.toString(); //.GetToolTip();
1152311824
1152411825 GL gl = GetGL();
1152511826
....@@ -11836,8 +12137,8 @@
1183612137 //obj.TransformToWorld(light, light);
1183712138 for (int i = tp.size(); --i >= 0;)
1183812139 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112142 }
1184212143
1184312144
....@@ -11854,8 +12155,8 @@
1185412155 parentcam = cameras[0];
1185512156 }
1185612157
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912160
1186012161 LA.xformPos(light, renderCamera.toScreen, light);
1186112162
....@@ -12469,8 +12770,8 @@
1246912770
1247012771 // display shadow only (bump == 0)
1247112772 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12773
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12774
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412775 "SUB temp.y, one.x, temp.z;" +
1247512776 "MUL temp.x, temp.x, temp.y;" +
1247612777 "KIL temp.x;" +
....@@ -12599,8 +12900,10 @@
1259912900 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012901
1260112902 "SUB temp.x, one.x, ndotl.x;" +
12602
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12603
- "ADD temp.y, one.y, options2.y;" + // sursurface
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
1260412907 "MUL temp.x, temp.x, temp.y;" +
1260512908
1260612909 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13051,7 @@
1274813051 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913052 "FLR final.x, final.y;" +
1275013053 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13054
+ "MUL final.x, final.x, c256i;" +
1275213055 "MOV final.z, zero.x;" +
1275313056 "MOV final.a, one.w;":""
1275413057 ) +
....@@ -12756,7 +13059,7 @@
1275613059 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713060 "FLR final.x, final.y;" +
1275813061 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13062
+ "MUL final.x, final.x, c256i;" +
1276013063 "MOV final.z, zero.x;" +
1276113064 "MOV final.a, one.w;":""
1276213065 ) +
....@@ -12799,7 +13102,7 @@
1279913102 //once = true;
1280013103 }
1280113104
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13105
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313106 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413107 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513108
....@@ -12932,12 +13235,16 @@
1293213235
1293313236 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413237 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13238
+
13239
+ // Compare fragment depth in light space with shadowmap.
1293513240 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613241 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13242
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13243
+
13244
+ // Reverse comparison
1293813245 "SUB temp.x, one.x, temp.x;" +
1293913246 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13247
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113248 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213249
1294313250 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13258,10 @@
1295113258 // No shadow for backface
1295213259 "DP3 temp.x, normal, lightd;" +
1295313260 "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;" +
1295413265 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513266 "";
1295613267 }
....@@ -13097,7 +13408,8 @@
1309713408 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813409 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913410 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13411
+
13412
+ //Object3D.cVector2[] vector2buffer;
1310113413
1310213414 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313415 // OUT : diff, spec
....@@ -13113,9 +13425,10 @@
1311313425 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413426 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513427 //"MOV " + dest + ".w," + "normal.z;" +
13116
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13117
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13118
- //"MOV " + dest + ".z," + "params2.w;" +
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
1311913432 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013433 "RCP " + dest + ".w," + dest + ".w;" +
1312113434 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13822,7 @@
1350913822 public void mousePressed(MouseEvent e)
1351013823 {
1351113824 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13825
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313826 }
1351413827
1351513828 static long prevtime = 0;
....@@ -13585,8 +13898,8 @@
1358513898 // mode |= META;
1358613899 //}
1358713900
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13901
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13902
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013903 anchorX = ax;
1359113904 anchorY = ay;
1359213905 prevX = px;
....@@ -13620,6 +13933,7 @@
1362013933 else
1362113934 if (evt.getSource() == AAtimer)
1362213935 {
13936
+ Globals.TIMERRUNNING = false;
1362313937 if (mouseDown)
1362413938 {
1362513939 //new Exception().printStackTrace();
....@@ -13645,6 +13959,10 @@
1364513959 // LIVE = waslive;
1364613960 // wasliveok = true;
1364713961 // waslive = false;
13962
+
13963
+ // May 2019 Forget it:
13964
+ if (true)
13965
+ return;
1364813966
1364913967 // source == timer
1365013968 if (mouseDown)
....@@ -13675,7 +13993,7 @@
1367513993
1367613994 // fev 2014???
1367713995 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
13996
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367913997 pingthread.StepToTarget(true); // true);
1368013998 }
1368113999 // if (!LIVE)
....@@ -13684,12 +14002,13 @@
1368414002
1368514003 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368614004
13687
- void clickStart(int x, int y, int modifiers)
14005
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368814006 {
1368914007 if (!wasliveok)
1369014008 return;
1369114009
1369214010 AAtimer.restart(); //
14011
+ Globals.TIMERRUNNING = true;
1369314012
1369414013 // waslive = LIVE;
1369514014 // LIVE = false;
....@@ -13701,7 +14020,7 @@
1370114020 // touched = true; // main DL
1370214021 if (isRenderer)
1370314022 {
13704
- SetMouseMode(modifiers);
14023
+ SetMouseMode(modifiers, modifiersex);
1370514024 }
1370614025
1370714026 selectX = anchorX = x;
....@@ -13714,7 +14033,7 @@
1371414033 clicked = true;
1371514034 hold = false;
1371614035
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14036
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371814037 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371914038 {
1372014039 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14064,7 @@
1374514064 info.camera = renderCamera;
1374614065 info.x = x;
1374714066 info.y = y;
13748
- info.modifiers = modifiers;
14067
+ info.modifiers = modifiersex;
1374914068 editObj = object.doEditClick(info, 0);
1375014069 if (!editObj)
1375114070 {
....@@ -13762,9 +14081,12 @@
1376214081
1376314082 public void mouseDragged(MouseEvent e)
1376414083 {
14084
+ Globals.MOUSEDRAGGED = true;
14085
+
1376514086 //System.out.println("mouseDragged: " + e);
1376614087 if (isRenderer)
1376714088 movingcamera = true;
14089
+
1376814090 //if (drawing)
1376914091 //return;
1377014092 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14096,7 @@
1377414096 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514097 }
1377614098 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14099
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814100
1377914101 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014102 }
....@@ -14011,7 +14333,7 @@
1401114333 {
1401214334 Globals.lighttouched = true;
1401314335 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14336
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514337 }
1401614338 //else
1401714339 }
....@@ -14025,12 +14347,12 @@
1402514347 void GoDown(int mod)
1402614348 {
1402714349 MODIFIERS |= COMMAND;
14028
- /*
14350
+ /**/
1402914351 if((mod&SHIFT) == SHIFT)
1403014352 manipCamera.RotatePosition(0, -speed);
1403114353 else
14032
- manipCamera.BackForth(0, -speed*delta, getWidth());
14033
- */
14354
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14355
+ /**/
1403414356 if ((mod & SHIFT) == SHIFT)
1403514357 {
1403614358 mouseMode = mouseMode; // VR??
....@@ -14046,12 +14368,12 @@
1404614368 void GoUp(int mod)
1404714369 {
1404814370 MODIFIERS |= COMMAND;
14049
- /*
14371
+ /**/
1405014372 if((mod&SHIFT) == SHIFT)
1405114373 manipCamera.RotatePosition(0, speed);
1405214374 else
14053
- manipCamera.BackForth(0, speed*delta, getWidth());
14054
- */
14375
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14376
+ /**/
1405514377 if ((mod & SHIFT) == SHIFT)
1405614378 {
1405714379 mouseMode = mouseMode;
....@@ -14067,12 +14389,12 @@
1406714389 void GoLeft(int mod)
1406814390 {
1406914391 MODIFIERS |= COMMAND;
14070
- /*
14392
+ /**/
1407114393 if((mod&SHIFT) == SHIFT)
14072
- manipCamera.RotatePosition(speed, 0);
14073
- else
1407414394 manipCamera.Translate(speed*delta, 0, getWidth());
14075
- */
14395
+ else
14396
+ manipCamera.RotatePosition(speed, 0);
14397
+ /**/
1407614398 if ((mod & SHIFT) == SHIFT)
1407714399 {
1407814400 mouseMode = mouseMode;
....@@ -14088,12 +14410,12 @@
1408814410 void GoRight(int mod)
1408914411 {
1409014412 MODIFIERS |= COMMAND;
14091
- /*
14413
+ /**/
1409214414 if((mod&SHIFT) == SHIFT)
14093
- manipCamera.RotatePosition(-speed, 0);
14094
- else
1409514415 manipCamera.Translate(-speed*delta, 0, getWidth());
14096
- */
14416
+ else
14417
+ manipCamera.RotatePosition(-speed, 0);
14418
+ /**/
1409714419 if ((mod & SHIFT) == SHIFT)
1409814420 {
1409914421 mouseMode = mouseMode;
....@@ -14111,7 +14433,7 @@
1411114433 int X, Y;
1411214434 boolean SX, SY;
1411314435
14114
- void drag(int x, int y, int modifiers)
14436
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514437 {
1411614438 if (IsFrozen())
1411714439 {
....@@ -14120,17 +14442,17 @@
1412014442
1412114443 drag = true; // NEW
1412214444
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14445
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414446
1412514447 X = x;
1412614448 Y = y;
1412714449 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14450
+ MODIFIERS = modifiersex;
14451
+ modifiersex &= ~1024;
1413014452 if (false) // modifiers != 0)
1413114453 {
1413214454 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14455
+ System.out.println("mouseDragged: " + modifiersex);
1413414456 System.out.println("SHIFT = " + SHIFT);
1413514457 System.out.println("CONTROL = " + COMMAND);
1413614458 System.out.println("META = " + META);
....@@ -14150,7 +14472,8 @@
1415014472 info.camera = renderCamera;
1415114473 info.x = x;
1415214474 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14475
+ object.GetWindow().copy
14476
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414477 } else
1415514478 {
1415614479 if (x < startX)
....@@ -14314,7 +14637,9 @@
1431414637 ci.camera = renderCamera;
1431514638 if (!isRenderer)
1431614639 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14640
+ //ObjEditor editWindow = object.editWindow;
14641
+ //Object3D copy = editWindow.copy;
14642
+ if (object.doEditClick(ci, 0))
1431814643 {
1431914644 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014645 } else
....@@ -14326,7 +14651,11 @@
1432614651
1432714652 public void mouseReleased(MouseEvent e)
1432814653 {
14654
+ Globals.MOUSEDRAGGED = false;
14655
+
1432914656 movingcamera = false;
14657
+ X = 0; // getBounds().width/2;
14658
+ Y = 0; // getBounds().height/2;
1433014659 //System.out.println("mouseReleased: " + e);
1433114660 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214661 }
....@@ -14349,9 +14678,9 @@
1434914678 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014679 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114680
14352
- if (control || command || IsFrozen())
14681
+// No delay if (control || command || IsFrozen())
1435314682 timeout = true;
14354
- else
14683
+// ?? May 2019 else
1435514684 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614685 mouseDown = false;
1435714686 if (!control && !command) // june 2013
....@@ -14461,7 +14790,7 @@
1446114790 System.out.println("keyReleased: " + e);
1446214791 }
1446314792
14464
- void SetMouseMode(int modifiers)
14793
+ void SetMouseMode(int modifiers, int modifiersex)
1446514794 {
1446614795 //System.out.println("SetMouseMode = " + modifiers);
1446714796 //modifiers &= ~1024;
....@@ -14473,25 +14802,25 @@
1447314802 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414803 // return;
1447514804 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14805
+ if ((modifiersex & WHEEL) == WHEEL)
1447714806 {
1447814807 mouseMode |= ZOOM;
1447914808 }
1448014809
1448114810 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14811
+ if (capsLocked) // || (modifiers & META) == META)
1448314812 {
1448414813 mouseMode |= VR; // BACKFORTH;
1448514814 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14815
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714816 {
1448814817 mouseMode |= SELECT;
1448914818 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14819
+ if ((modifiersex & COMMAND) == COMMAND)
1449114820 {
1449214821 mouseMode |= SELECT;
1449314822 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14823
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514824 {
1449614825 mouseMode &= ~VR;
1449714826 mouseMode |= TRANSLATE;
....@@ -14520,7 +14849,7 @@
1452014849
1452114850 if (isRenderer) //
1452214851 {
14523
- SetMouseMode(modifiers);
14852
+ SetMouseMode(0, modifiers);
1452414853 }
1452514854
1452614855 Globals.theRenderer.keyPressed(key);
....@@ -14667,7 +14996,9 @@
1466714996 case 'E' : COMPACT ^= true;
1466814997 repaint();
1466914998 break;
14670
- case 'W' : DEBUGHSB ^= true;
14999
+ case 'W' : // Wide Window (fullscreen)
15000
+ //DEBUGHSB ^= true;
15001
+ ObjEditor.theFrame.ToggleFullScreen();
1467115002 repaint();
1467215003 break;
1467315004 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14692,8 +15023,8 @@
1469215023 RevertCamera();
1469315024 repaint();
1469415025 break;
14695
- case 'L':
1469615026 case 'l':
15027
+ //case 'L':
1469715028 if (lightMode)
1469815029 {
1469915030 lightMode = false;
....@@ -14836,9 +15167,9 @@
1483615167 case '_':
1483715168 kompactbit = 5;
1483815169 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15170
+// case '+':
15171
+// kompactbit = 6;
15172
+// break;
1484215173 case ' ':
1484315174 lightMode ^= true;
1484415175 Globals.lighttouched = true;
....@@ -14850,13 +15181,14 @@
1485015181 case ESC:
1485115182 RENDERPROGRAM += 1;
1485215183 RENDERPROGRAM %= 3;
15184
+
1485315185 repaint();
1485415186 break;
1485515187 case 'Z':
1485615188 //RESIZETEXTURE ^= true;
1485715189 //break;
1485815190 case 'z':
14859
- RENDERSHADOW ^= true;
15191
+ Globals.RENDERSHADOW ^= true;
1486015192 Globals.lighttouched = true;
1486115193 repaint();
1486215194 break;
....@@ -14889,8 +15221,9 @@
1488915221 case DELETE:
1489015222 ClearSelection();
1489115223 break;
14892
- /*
1489315224 case '+':
15225
+
15226
+ /*
1489415227 //fontsize += 1;
1489515228 bbzoom *= 2;
1489615229 repaint();
....@@ -14907,17 +15240,17 @@
1490715240 case '=':
1490815241 IncDepth();
1490915242 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15243
+ object.GetWindow().refreshContents(true);
1491115244 maskbit = 6;
1491215245 break;
1491315246 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415247 DecDepth();
1491515248 maskbit = 5;
1491615249 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15250
+// if (object.editWindow == null)
15251
+// new Exception().printStackTrace();
15252
+// else
15253
+ object.GetWindow().refreshContents(true);
1492115254 break;
1492215255 case '{':
1492315256 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15313,7 @@
1498015313 //mode = ROTATE;
1498115314 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215315 {
14983
- SetMouseMode(modifiers);
15316
+ SetMouseMode(0, modifiers);
1498415317 }
1498515318 }
1498615319
....@@ -15116,7 +15449,7 @@
1511615449 {
1511715450 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815451 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015453 {
1512115454 mouseMoved(e);
1512215455 } else
....@@ -15141,7 +15474,7 @@
1514115474 }
1514215475 */
1514315476
15144
- object.editWindow.EditSelection();
15477
+ object.GetWindow().EditSelection(false);
1514515478 }
1514615479
1514715480 void SelectParent()
....@@ -15158,10 +15491,10 @@
1515815491 {
1515915492 //selectees.remove(i);
1516015493 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15494
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215495 } else
1516315496 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15497
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515498 }
1516615499
1516715500 first = false;
....@@ -15203,12 +15536,12 @@
1520315536 for (int j = 0; j < group.children.size(); j++)
1520415537 {
1520515538 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15539
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715540 first = false;
1520815541 }
1520915542 } else
1521015543 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15544
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215545 }
1521315546
1521415547 first = false;
....@@ -15219,21 +15552,21 @@
1521915552 {
1522015553 //Composite group = (Composite) object;
1522115554 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15555
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315556 }
1522415557
1522515558 void ResetTransform(int mask)
1522615559 {
1522715560 //Composite group = (Composite) object;
1522815561 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15562
+ group.GetWindow().ResetTransform(mask);
1523015563 }
1523115564
1523215565 void FlipTransform()
1523315566 {
1523415567 //Composite group = (Composite) object;
1523515568 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15569
+ group.GetWindow().FlipTransform();
1523715570 // group.editWindow.ReduceMesh(true);
1523815571 }
1523915572
....@@ -15241,7 +15574,7 @@
1524115574 {
1524215575 //Composite group = (Composite) object;
1524315576 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15577
+ group.GetWindow().PrintMemory();
1524515578 // group.editWindow.ReduceMesh(true);
1524615579 }
1524715580
....@@ -15249,7 +15582,7 @@
1524915582 {
1525015583 //Composite group = (Composite) object;
1525115584 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15585
+ group.GetWindow().ResetCentroid();
1525315586 }
1525415587
1525515588 void IncDepth()
....@@ -15335,7 +15668,9 @@
1533515668 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615669 //Image img = CreateImage(width, height);
1533715670 //System.out.println("width = " + width + "; height = " + height + "\n");
15671
+
1533815672 Graphics gr = g; // img.getGraphics();
15673
+
1533915674 if (!hasMarquee)
1534015675 {
1534115676 if (Xmin < Xmax) // !locked)
....@@ -15423,6 +15758,7 @@
1542315758 info.bounds.y += (height - desired) / 2;
1542415759 }
1542515760 }
15761
+
1542615762 info.g = gr;
1542715763 info.camera = renderCamera;
1542815764 /*
....@@ -15432,15 +15768,55 @@
1543215768 */
1543315769 if (!isRenderer)
1543415770 {
15435
- 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
+ }
1543615810 }
1543715811 }
15812
+
1543815813 if (isRenderer)
1543915814 {
1544015815 //gr.setColor(Color.black);
1544115816 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215817 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315818 }
15819
+
1544415820 if (hasMarquee)
1544515821 {
1544615822 gr.setXORMode(Color.white);
....@@ -15553,6 +15929,7 @@
1555315929 public boolean mouseDown(Event evt, int x, int y)
1555415930 {
1555515931 System.out.println("mouseDown: " + evt);
15932
+ System.exit(0);
1555615933 /*
1555715934 locked = true;
1555815935 drag = false;
....@@ -15596,7 +15973,7 @@
1559615973 {
1559715974 keyPressed(0, modifiers);
1559815975 }
15599
- clickStart(x, y, modifiers);
15976
+ // clickStart(x, y, modifiers);
1560015977 return true;
1560115978 }
1560215979
....@@ -15714,7 +16091,7 @@
1571416091 {
1571516092 keyReleased(0, 0);
1571616093 }
15717
- drag(x, y, modifiers);
16094
+ drag(x, y, 0, modifiers);
1571816095 return true;
1571916096 }
1572016097
....@@ -15846,7 +16223,7 @@
1584616223 Object3D object;
1584716224 static Object3D trackedobject;
1584816225 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16226
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016227 /*static*/ Camera eyeCamera;
1585116228 /*static*/ Camera lightCamera;
1585216229 int cameracount;
....@@ -16131,16 +16508,16 @@
1613116508 cStatic.objectstack[materialdepth++] = checker;
1613216509 //System.out.println("material " + material);
1613316510 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16511
+ //vector2buffer = checker.projectedVertices;
1613516512
1613616513 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16514
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816515
1613916516 materialdepth -= 1;
1614016517 if (materialdepth > 0)
1614116518 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- 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);
1614416521 }
1614516522 //checker.GetMaterial().opacity = 1f;
1614616523 ////checker.GetMaterial().ambient = 1f;
....@@ -16226,6 +16603,14 @@
1622616603 }
1622716604 }
1622816605
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
+
1622916614 class SelectBuffer implements GLEventListener
1623016615 {
1623116616
....@@ -16305,6 +16690,17 @@
1630516690
1630616691 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630716692
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
+
1630816704 //int tmp = selection_view;
1630916705 //selection_view = -1;
1631016706 int temp = DrawMode();
....@@ -16316,6 +16712,17 @@
1631616712 // temp = DEFAULT; // patch for selection debug
1631716713 Globals.drawMode = temp; // WARNING
1631816714
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
+
1631916726 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632016727
1632116728 // trying different ways of getting the depth info over
....@@ -16363,6 +16770,8 @@
1636316770 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1636416771 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516772 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16773
+
16774
+ CreateSelectedPoint();
1636616775
1636716776 // Will fit the mesh !!!
1636816777 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16412,34 +16821,36 @@
1641216821 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]));
1641316822 }
1641416823
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16824
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616825 }
1641716826 }
1641816827
1641916828 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16829
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116830
16422
- 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)
1642316832 {
16424
- 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);
1642516834
16426
- Object3D group = new Object3D("inst" + paintcount++);
16835
+ if (object.GetWindow().copy.selection.Size() > 0)
16836
+ {
16837
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642716838
16428
- group.CreateMaterial(); // use a void leaf to select instances
16429
-
16430
- group.add(paintobj); // link
16431
-
16432
- object.editWindow.SnapObject(group);
16433
-
16434
- Object3D folder = object.editWindow.copy;
16435
-
16436
- if (object.editWindow.copy.selection.Size() > 0)
16437
- folder = object.editWindow.copy.selection.elementAt(0);
16438
-
16439
- folder.add(group);
16440
-
16441
- object.editWindow.ResetModel();
16442
- object.editWindow.refreshContents();
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
+ }
1644316854 }
1644416855 else
1644516856 paintcount = 0;
....@@ -16478,6 +16889,11 @@
1647816889 //System.out.println("objects[color] = " + objects[color]);
1647916890 //objects[color].Select();
1648016891 indexcount = 0;
16892
+ ObjEditor window = object.GetWindow();
16893
+ if (window != null && deselect)
16894
+ {
16895
+ window.Select(null, deselect, true);
16896
+ }
1648116897 object.Select(color, deselect);
1648216898 }
1648316899
....@@ -16577,7 +16993,7 @@
1657716993 gl.glDisable(gl.GL_CULL_FACE);
1657816994 }
1657916995
16580
- if (!RENDERSHADOW)
16996
+ if (!Globals.RENDERSHADOW)
1658116997 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658216998
1658316999 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +17003,7 @@
1658717003 //gl.glColorMask(false, false, false, false);
1658817004
1658917005 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17006
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659117007 {
1659217008 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659317009
....@@ -17003,23 +17419,15 @@
1700317419 int AAbuffersize = 0;
1700417420
1700517421 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17422
+ static Superellipsoid selectedpoint;
1700717423 static Sphere previousselectedpoint = null;
17008
- static Sphere debugpointG = new Sphere();
17009
- static Sphere debugpointP = new Sphere();
17010
- static Sphere debugpointC = new Sphere();
17011
- static Sphere debugpointR = new Sphere();
17424
+ static Sphere debugpointG;
17425
+ static Sphere debugpointP;
17426
+ static Sphere debugpointC;
17427
+ static Sphere debugpointR;
1701217428
1701317429 static Sphere debugpoints[] = new Sphere[8];
1701417430
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317431 static void InitPoints(float radius)
1702417432 {
1702517433 for (int i=0; i<8; i++)