Normand Briere
2019-07-21 d32f24f147068e6cbecb31c7f98047f68bc8b58a
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,46 @@
23762404 {
23772405 return currentGL;
23782406 }
2379
-
2407
+
2408
+ private BufferedImage CreateBim(TextureData texturedata)
2409
+ {
2410
+ // cache to disk
2411
+ Buffer buffer = texturedata.getBuffer(); // getMipmapData();
2412
+ //buffers[0].
2413
+ ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
2414
+ int[] pixels = new int[bytebuf.capacity()/3];
2415
+ int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared
2416
+ int height = width;
2417
+ for (int i=pixels.length; --i>=0;)
2418
+ {
2419
+ int i3 = i*3;
2420
+ pixels[i] = 0xFF;
2421
+ pixels[i] <<= 8;
2422
+ pixels[i] |= bytebuf.get(i3+2) & 0xFF;
2423
+ pixels[i] <<= 8;
2424
+ pixels[i] |= bytebuf.get(i3+1) & 0xFF;
2425
+ pixels[i] <<= 8;
2426
+ pixels[i] |= bytebuf.get(i3) & 0xFF;
2427
+ }
2428
+ /*
2429
+ int r=0,g=0,b=0,a=0;
2430
+ for (int i=0; i<width; i++)
2431
+ for (int j=0; j<height; j++)
2432
+ {
2433
+ int index = j*width+i;
2434
+ int p = pixels[index];
2435
+ a = ((p>>24) & 0xFF);
2436
+ r = ((p>>16) & 0xFF);
2437
+ g = ((p>>8) & 0xFF);
2438
+ b = (p & 0xFF);
2439
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
2440
+ }
2441
+ /**/
2442
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
2443
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
2444
+ return rendImage;
2445
+ }
2446
+
23802447 /**/
23812448 class CacheTexture
23822449 {
....@@ -2394,9 +2461,10 @@
23942461 /**/
23952462
23962463 // 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>();
2464
+ static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>();
2465
+ static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>();
2466
+ static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>();
2467
+
24002468 int pigmentdepth = 0;
24012469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022470 int bumpdepth = 0;
....@@ -2418,6 +2486,33 @@
24182486 true,
24192487 com.sun.opengl.util.texture.TextureIO.PNG);
24202488 } catch (java.io.IOException e)
2489
+ {
2490
+ throw new javax.media.opengl.GLException(e);
2491
+ }
2492
+
2493
+ if (bump)
2494
+ texturedata = ConvertBump(texturedata, false);
2495
+
2496
+ com.sun.opengl.util.texture.Texture texture =
2497
+ com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2498
+
2499
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2500
+ texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2501
+
2502
+ return texture;
2503
+ }
2504
+
2505
+ com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump)
2506
+ {
2507
+ TextureData texturedata = null;
2508
+
2509
+ try
2510
+ {
2511
+ texturedata =
2512
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2513
+ name,
2514
+ true);
2515
+ } catch (Exception e)
24212516 {
24222517 throw new javax.media.opengl.GLException(e);
24232518 }
....@@ -3504,6 +3599,8 @@
35043599
35053600 System.out.println("LOADING TEXTURE : " + name);
35063601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35073604 //
35083605 if (false) // compressbit > 0)
35093606 {
....@@ -7902,7 +7999,7 @@
79027999 String pigment = Object3D.GetPigment(tex);
79038000 String bump = Object3D.GetBump(tex);
79048001
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79068003 {
79078004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79088005 // System.out.println("; bump = " + bump);
....@@ -7919,6 +8016,64 @@
79198016
79208017 ReleaseTexture(bump, true);
79218018 ReleaseTexture(pigment, false);
8019
+ }
8020
+
8021
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8022
+ {
8023
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8024
+ {
8025
+ return;
8026
+ }
8027
+
8028
+ if (tex == null)
8029
+ {
8030
+ ReleaseTexture(null, false);
8031
+ return;
8032
+ }
8033
+
8034
+ String pigment = Object3D.GetPigment(tex);
8035
+
8036
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8037
+ {
8038
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8039
+ // System.out.println("; bump = " + bump);
8040
+ }
8041
+
8042
+ if (pigment.equals(""))
8043
+ {
8044
+ pigment = null;
8045
+ }
8046
+
8047
+ ReleaseTexture(pigment, false);
8048
+ }
8049
+
8050
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8051
+ {
8052
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8053
+ {
8054
+ return;
8055
+ }
8056
+
8057
+ if (tex == null)
8058
+ {
8059
+ ReleaseTexture(null, true);
8060
+ return;
8061
+ }
8062
+
8063
+ String bump = Object3D.GetBump(tex);
8064
+
8065
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8066
+ {
8067
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8068
+ // System.out.println("; bump = " + bump);
8069
+ }
8070
+
8071
+ if (bump.equals(""))
8072
+ {
8073
+ bump = null;
8074
+ }
8075
+
8076
+ ReleaseTexture(bump, true);
79228077 }
79238078
79248079 void ReleaseTexture(String tex, boolean bump)
....@@ -8024,7 +8179,55 @@
80248179 }
80258180 }
80268181
8027
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8182
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8183
+ {
8184
+// if (// DrawMode() != 0 || /*tex == null ||*/
8185
+// ambientOcclusion ) // || !textureon)
8186
+// {
8187
+// return; // false;
8188
+// }
8189
+//
8190
+// if (tex == null)
8191
+// {
8192
+// BindTexture(null,false,resolution);
8193
+// BindTexture(null,true,resolution);
8194
+// return;
8195
+// }
8196
+//
8197
+// String pigment = Object3D.GetPigment(tex);
8198
+// String bump = Object3D.GetBump(tex);
8199
+//
8200
+// usedtextures.add(pigment);
8201
+// usedtextures.add(bump);
8202
+//
8203
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8204
+// {
8205
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8206
+// // System.out.println("; bump = " + bump);
8207
+// }
8208
+//
8209
+// if (bump.equals(""))
8210
+// {
8211
+// bump = null;
8212
+// }
8213
+// if (pigment.equals(""))
8214
+// {
8215
+// pigment = null;
8216
+// }
8217
+//
8218
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8219
+// BindTexture(pigment, false, resolution);
8220
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8221
+// BindTexture(bump, true, resolution);
8222
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8223
+//
8224
+// return; // true;
8225
+
8226
+ BindPigmentTexture(tex, resolution);
8227
+ BindBumpTexture(tex, resolution);
8228
+ }
8229
+
8230
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80288231 {
80298232 if (// DrawMode() != 0 || /*tex == null ||*/
80308233 ambientOcclusion ) // || !textureon)
....@@ -8034,18 +8237,48 @@
80348237
80358238 if (tex == null)
80368239 {
8037
- BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
8240
+ BindTexture(null, null,false,resolution);
80398241 return;
80408242 }
80418243
80428244 String pigment = Object3D.GetPigment(tex);
8245
+
8246
+ usedtextures.add(pigment);
8247
+
8248
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8249
+ {
8250
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8251
+ // System.out.println("; bump = " + bump);
8252
+ }
8253
+
8254
+ if (pigment.equals(""))
8255
+ {
8256
+ pigment = null;
8257
+ }
8258
+
8259
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8260
+ BindTexture(tex.pigmenttexture, pigment, false, resolution);
8261
+ }
8262
+
8263
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8264
+ {
8265
+ if (// DrawMode() != 0 || /*tex == null ||*/
8266
+ ambientOcclusion ) // || !textureon)
8267
+ {
8268
+ return; // false;
8269
+ }
8270
+
8271
+ if (tex == null)
8272
+ {
8273
+ BindTexture(null, null,true,resolution);
8274
+ return;
8275
+ }
8276
+
80438277 String bump = Object3D.GetBump(tex);
80448278
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
80478280
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498282 {
80508283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518284 // System.out.println("; bump = " + bump);
....@@ -8055,42 +8288,70 @@
80558288 {
80568289 bump = null;
80578290 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628291
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
80678294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708295 }
80718296
8072
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8297
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8298
+
8299
+ private boolean FileExists(String tex)
80738300 {
8074
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8301
+ if (missingTextures.contains(tex))
8302
+ {
8303
+ return false;
8304
+ }
8305
+
8306
+ boolean fileExists = new File(tex).exists();
8307
+
8308
+ if (!fileExists)
8309
+ {
8310
+ // If file exists, the "new File()" is not executed sgain
8311
+ missingTextures.add(tex);
8312
+ }
8313
+
8314
+ return fileExists;
8315
+ }
8316
+
8317
+ CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception
8318
+ {
8319
+ CacheTexture texturecache = null;
80758320
80768321 if (tex != null)
80778322 {
80788323 String texname = tex;
80798324
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;
8325
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8326
+
8327
+// String[] split = tex.split("Textures");
8328
+// if (split.length > 1)
8329
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8330
+// else
8331
+// if (!texname.startsWith("/"))
8332
+// texname = "/Users/nbriere/Textures/" + texname;
8333
+ if (!FileExists(tex))
8334
+ {
8335
+ texname = fallbackTextureName;
8336
+ }
80868337
80878338 if (CACHETEXTURE)
8088
- texture = textures.get(texname); // TEXTURE CACHE
8089
-
8090
- TextureData texturedata = null;
8091
-
8092
- if (texture == null || texture.resolution < resolution)
80938339 {
8340
+ if (bim == null)
8341
+ texturecache = textures.get(texname); // TEXTURE CACHE
8342
+ else
8343
+ texturecache = bimtextures.get(bim); // TEXTURE CACHE
8344
+ }
8345
+
8346
+ if (texturecache == null || texturecache.resolution < resolution)
8347
+ {
8348
+ TextureData texturedata = null;
8349
+
8350
+ if (bim != null)
8351
+ {
8352
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8353
+ }
8354
+ else
80948355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80958356 {
80968357 assert(!bump);
....@@ -8102,19 +8363,23 @@
81028363 // }
81038364 // else
81048365 // {
8105
- texture = textures.get(tex);
8106
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
81078368 {
8108
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81098370 }
8371
+ else
8372
+ new Exception().printStackTrace();
81108373 // }
81118374 } else
81128375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81138376 {
81148377 assert(bump);
8115
- texture = textures.get(tex);
8116
- if (texture == null)
8117
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8378
+ texturecache = textures.get(tex);
8379
+ if (texturecache == null)
8380
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8381
+ else
8382
+ new Exception().printStackTrace();
81188383 } else
81198384 {
81208385 //if (tex.equals("IMMORTAL"))
....@@ -8124,9 +8389,11 @@
81248389 //{
81258390 if (tex.equals("WHITE_NOISE"))
81268391 {
8127
- texture = textures.get(tex);
8128
- if (texture == null)
8129
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8392
+ texturecache = textures.get(tex);
8393
+ if (texturecache == null)
8394
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8395
+ else
8396
+ new Exception().printStackTrace();
81308397 } else
81318398 {
81328399 if (textureon)
....@@ -8151,7 +8418,7 @@
81518418 }
81528419
81538420 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8421
+ if (!FileExists(cachename))
81558422 cachename = texname;
81568423 else
81578424 processbump = false; // don't process bump map again
....@@ -8173,7 +8440,7 @@
81738440 }
81748441
81758442 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8443
+ if (!FileExists(cachename))
81778444 cachename = texname;
81788445 else
81798446 processbump = false; // don't process bump map again
....@@ -8182,20 +8449,23 @@
81828449 texturedata = GetFileTexture(cachename, processbump, resolution);
81838450
81848451
8185
- if (texturedata != null)
8186
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8452
+ if (texturedata == null)
8453
+ throw new Exception();
8454
+
8455
+ texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
81878456 //texture = GetTexture(tex, bump);
81888457 }
81898458 }
81908459 //}
81918460 }
81928461
8193
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81948463 {
81958464 //return false;
8465
+ assert(bim == null);
81968466
81978467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8198
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81998469 {
82008470 // String ext = "_highres";
82018471 // if (REDUCETEXTURE)
....@@ -8212,52 +8482,17 @@
82128482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82138483 if (!cachefile.exists())
82148484 {
8215
- // cache to disk
8216
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8217
- //buffers[0].
8218
-
8219
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8220
- int[] pixels = new int[bytebuf.capacity()/3];
8221
-
8222
- // squared size heuristic...
8223
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
82248486 {
8225
- for (int i=pixels.length; --i>=0;)
8226
- {
8227
- int i3 = i*3;
8228
- pixels[i] = 0xFF;
8229
- pixels[i] <<= 8;
8230
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8231
- pixels[i] <<= 8;
8232
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8233
- pixels[i] <<= 8;
8234
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8235
- }
8236
-
8237
- /*
8238
- int r=0,g=0,b=0,a=0;
8239
- for (int i=0; i<width; i++)
8240
- for (int j=0; j<height; j++)
8241
- {
8242
- int index = j*width+i;
8243
- int p = pixels[index];
8244
- a = ((p>>24) & 0xFF);
8245
- r = ((p>>16) & 0xFF);
8246
- g = ((p>>8) & 0xFF);
8247
- b = (p & 0xFF);
8248
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8249
- }
8250
- /**/
8251
- int width = (int)Math.sqrt(pixels.length); // squared
8252
- int height = width;
8253
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8254
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
82558489 ImageWriter writer = null;
82568490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82578491 if (iter.hasNext()) {
82588492 writer = (ImageWriter)iter.next();
82598493 }
8260
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
82618496 try
82628497 {
82638498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8284,8 +8519,8 @@
82848519 textures.remove(texname);
82858520 }
82868521
8287
- texture.texturedata = texturedata;
8288
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
82898524
82908525 // newtex = true;
82918526 }
....@@ -8301,12 +8536,17 @@
83018536 }
83028537 }
83038538
8304
- return texture;
8539
+ return texturecache;
83058540 }
83068541
8307
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8542
+ static void EmbedTextures(cTexture tex)
83088543 {
8309
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8544
+
8545
+ }
8546
+
8547
+ com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
8548
+ {
8549
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83108550
83118551 if (bump)
83128552 {
....@@ -8322,23 +8562,23 @@
83228562 return texture!=null?texture.texture:null;
83238563 }
83248564
8325
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8565
+ public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83268566 {
8327
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83288568
83298569 return texture!=null?texture.texturedata:null;
83308570 }
83318571
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8572
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83338573 {
83348574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358575 {
83368576 return false;
83378577 }
83388578
8339
- boolean newtex = false;
8579
+ //boolean newtex = false;
83408580
8341
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83428582
83438583 if (texture == null)
83448584 return false;
....@@ -8368,7 +8608,7 @@
83688608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83698609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83708610
8371
- return newtex;
8611
+ return true; // Warning: not used.
83728612 }
83738613
83748614 ShadowBuffer shadowPBuf;
....@@ -9206,11 +9446,35 @@
92069446 jy8[3] = 0.5f;
92079447 }
92089448
9209
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9449
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92109450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139453
9454
+ void ResetOptions()
9455
+ {
9456
+ options1[0] = 100;
9457
+ options1[1] = 0.025f;
9458
+ options1[2] = 0.01f;
9459
+ options1[3] = 0;
9460
+ options1[4] = 0;
9461
+
9462
+ options2[0] = 0;
9463
+ options2[1] = 0.75f;
9464
+ options2[2] = 0;
9465
+ options2[3] = 0;
9466
+
9467
+ options3[0] = 1;
9468
+ options3[1] = 1;
9469
+ options3[2] = 1;
9470
+ options3[3] = 0;
9471
+
9472
+ options4[0] = 1;
9473
+ options4[1] = 0;
9474
+ options4[2] = 1;
9475
+ options4[3] = 0;
9476
+ }
9477
+
92149478 static int imagecount = 0; // movie generation
92159479
92169480 static int jitter = 0;
....@@ -9306,8 +9570,8 @@
93069570 assert (parentcam != renderCamera);
93079571
93089572 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119575
93129576 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139577
....@@ -9322,8 +9586,8 @@
93229586 LA.matCopy(renderCamera.fromScreen, matrix);
93239587
93249588 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9589
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9590
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279591
93289592 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299593
....@@ -9395,7 +9659,7 @@
93959659 //gl.glFlush();
93969660 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979661
9398
- if (ANIMATION && ABORTED)
9662
+ if (Globals.ANIMATION && ABORTED)
93999663 {
94009664 System.err.println(" ABORTED FRAME");
94019665 break;
....@@ -9425,7 +9689,7 @@
94259689 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269690
94279691 // save image
9428
- if (ANIMATION && !ABORTED)
9692
+ if (Globals.ANIMATION && !ABORTED)
94299693 {
94309694 VPwidth = viewport[2];
94319695 VPheight = viewport[3];
....@@ -9536,11 +9800,11 @@
95369800
95379801 // imagecount++;
95389802
9539
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9803
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95409804
95419805 if (!BOXMODE)
95429806 {
9543
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9807
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95449808 }
95459809
95469810 if (!BOXMODE)
....@@ -9578,7 +9842,7 @@
95789842 ABORTED = false;
95799843 }
95809844 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9845
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829846
95839847 if (false)
95849848 {
....@@ -10241,11 +10505,11 @@
1024110505
1024210506 public void display(GLAutoDrawable drawable)
1024310507 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10508
+ if (Grafreed.savesound && Grafreed.hassound)
1024510509 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10510
+ Grafreed.wav.save();
10511
+ Grafreed.savesound = false;
10512
+ Grafreed.hassound = false;
1024910513 }
1025010514 // if (DEBUG_SELECTION)
1025110515 // {
....@@ -10321,6 +10585,7 @@
1032110585 ANTIALIAS = 0;
1032210586 //System.out.println("RESTART");
1032310587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1032410589 }
1032510590 }
1032610591 }
....@@ -10375,7 +10640,7 @@
1037510640 Object3D theobject = object;
1037610641 Object3D theparent = object.parent;
1037710642 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10643
+ object = (Object3D)Grafreed.clone(object);
1037910644 object.Stripify();
1038010645 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110646 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10653,14 @@
1038810653 ambientOcclusion = false;
1038910654 }
1039010655
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210658 {
1039310659 //if (RENDERSHADOW) // ?
1039410660 if (!IsFrozen())
1039510661 {
1039610662 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10663
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810664 {
1039910665 Globals.framecount++;
1040010666 shadowbuffer.display();
....@@ -10521,8 +10787,8 @@
1052110787
1052210788 // if (parentcam != renderCamera) // not a light
1052310789 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10790
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10791
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610792
1052710793 for (int j = 0; j < 4; j++)
1052810794 {
....@@ -10536,8 +10802,8 @@
1053610802
1053710803 // if (parentcam != renderCamera) // not a light
1053810804 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10805
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10806
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110807
1054210808 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310809
....@@ -10796,7 +11062,16 @@
1079611062 // Bump noise
1079711063 gl.glActiveTexture(GL.GL_TEXTURE6);
1079811064 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- BindTexture(NOISE_TEXTURE, false, 2);
11065
+
11066
+ try
11067
+ {
11068
+ BindTexture(null, NOISE_TEXTURE, false, 2);
11069
+ }
11070
+ catch (Exception e)
11071
+ {
11072
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11073
+ }
11074
+
1080011075
1080111076 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211077 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10819,9 +11094,9 @@
1081911094
1082011095 gl.glMatrixMode(GL.GL_MODELVIEW);
1082111096
10822
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10823
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10824
-//gl.glEnable(gl.GL_MULTISAMPLE);
11097
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11098
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11099
+gl.glEnable(gl.GL_MULTISAMPLE);
1082511100 } else
1082611101 {
1082711102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10832,7 +11107,7 @@
1083211107 //System.out.println("BLENDING ON");
1083311108 gl.glEnable(GL.GL_BLEND);
1083411109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10835
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083611111 gl.glMatrixMode(gl.GL_PROJECTION);
1083711112 gl.glLoadIdentity();
1083811113
....@@ -10921,8 +11196,8 @@
1092111196 System.err.println("parentcam != renderCamera");
1092211197
1092311198 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11199
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11200
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092611201 }
1092711202
1092811203 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11218,8 @@
1094311218 if (true) // TODO
1094411219 {
1094511220 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11221
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11222
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1094811223 }
1094911224
1095011225 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11535,14 @@
1126011535 {
1126111536 renderpass++;
1126211537 // System.out.println("Draw object... ");
11538
+ STEP = 1;
1126311539 if (FAST) // in case there is no script
11264
- STEP = 16;
11540
+ STEP = 8;
11541
+
11542
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11543
+ {
11544
+ STEP *= 4;
11545
+ }
1126511546
1126611547 //object.FullInvariants();
1126711548
....@@ -11275,23 +11556,44 @@
1127511556 e.printStackTrace();
1127611557 }
1127711558
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11559
+ if (Grafreed.RENDERME > 0)
11560
+ Grafreed.RENDERME--; // mechante magouille
1128011561
1128111562 Globals.ONESTEP = false;
1128211563 }
1128311564
1128411565 static boolean zoomonce = false;
1128511566
11567
+ static void CreateSelectedPoint()
11568
+ {
11569
+ if (selectedpoint == null)
11570
+ {
11571
+ debugpointG = new Sphere();
11572
+ debugpointP = new Sphere();
11573
+ debugpointC = new Sphere();
11574
+ debugpointR = new Sphere();
11575
+
11576
+ selectedpoint = new Superellipsoid();
11577
+
11578
+ for (int i=0; i<8; i++)
11579
+ {
11580
+ debugpoints[i] = new Sphere();
11581
+ }
11582
+ }
11583
+ }
11584
+
1128611585 void DrawObject(GL gl, boolean draw)
1128711586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1128811590 //System.out.println("DRAW OBJECT " + mouseDown);
1128911591 // DrawMode() = SELECTION;
1129011592 //GL gl = getGL();
1129111593 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211594 {
1129311595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511597 pingthread.StepToTarget(true); // true);
1129611598 // zoomonce = false;
1129711599 }
....@@ -11346,7 +11648,14 @@
1134611648
1134711649 usedtextures.clear();
1134811650
11349
- BindTextures(DEFAULT_TEXTURES, 2);
11651
+ try
11652
+ {
11653
+ BindTextures(DEFAULT_TEXTURES, 2);
11654
+ }
11655
+ catch (Exception e)
11656
+ {
11657
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11658
+ }
1135011659 }
1135111660 //System.out.println("--> " + stackdepth);
1135211661 // GrafreeD.traceon();
....@@ -11356,8 +11665,9 @@
1135611665
1135711666 if (DrawMode() == DEFAULT)
1135811667 {
11359
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1136011669 {
11670
+ CreateSelectedPoint();
1136111671 float radius = 0.05f;
1136211672 if (selectedpoint.radius != radius)
1136311673 {
....@@ -11420,7 +11730,7 @@
1142011730 if (tex.equals("WHITE_NOISE"))
1142111731 continue;
1142211732
11423
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1142411734 {
1142511735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1142611736 textures.get(tex).texture.dispose();
....@@ -11437,7 +11747,14 @@
1143711747 if (checker != null && DrawMode() == DEFAULT)
1143811748 {
1143911749 //BindTexture(IMMORTAL_TEXTURE);
11440
- BindTextures(checker.GetTextures(), checker.texres);
11750
+ try
11751
+ {
11752
+ BindTextures(checker.GetTextures(), checker.texres);
11753
+ }
11754
+ catch (Exception e)
11755
+ {
11756
+ System.err.println("FAILED: " + checker.GetTextures());
11757
+ }
1144111758 // NEAREST
1144211759 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311760 DrawChecker(gl);
....@@ -11519,7 +11836,7 @@
1151911836 return;
1152011837 }
1152111838
11522
- String string = obj.GetToolTip();
11839
+ String string = obj.toString(); //.GetToolTip();
1152311840
1152411841 GL gl = GetGL();
1152511842
....@@ -11836,8 +12153,8 @@
1183612153 //obj.TransformToWorld(light, light);
1183712154 for (int i = tp.size(); --i >= 0;)
1183812155 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- LA.xformPos(light, tp.get(i).toParent, light);
12156
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12157
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184112158 }
1184212159
1184312160
....@@ -11854,8 +12171,8 @@
1185412171 parentcam = cameras[0];
1185512172 }
1185612173
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12174
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12175
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1185912176
1186012177 LA.xformPos(light, renderCamera.toScreen, light);
1186112178
....@@ -12469,8 +12786,8 @@
1246912786
1247012787 // display shadow only (bump == 0)
1247112788 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12789
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12790
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412791 "SUB temp.y, one.x, temp.z;" +
1247512792 "MUL temp.x, temp.x, temp.y;" +
1247612793 "KIL temp.x;" +
....@@ -12599,8 +12916,10 @@
1259912916 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012917
1260112918 "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
12919
+ // Tuning for default skin
12920
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12921
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12922
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260412923 "MUL temp.x, temp.x, temp.y;" +
1260512924
1260612925 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13067,7 @@
1274813067 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913068 "FLR final.x, final.y;" +
1275013069 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13070
+ "MUL final.x, final.x, c256i;" +
1275213071 "MOV final.z, zero.x;" +
1275313072 "MOV final.a, one.w;":""
1275413073 ) +
....@@ -12756,7 +13075,7 @@
1275613075 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713076 "FLR final.x, final.y;" +
1275813077 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13078
+ "MUL final.x, final.x, c256i;" +
1276013079 "MOV final.z, zero.x;" +
1276113080 "MOV final.a, one.w;":""
1276213081 ) +
....@@ -12799,7 +13118,7 @@
1279913118 //once = true;
1280013119 }
1280113120
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13121
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313122 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413123 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513124
....@@ -12932,12 +13251,16 @@
1293213251
1293313252 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413253 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13254
+
13255
+ // Compare fragment depth in light space with shadowmap.
1293513256 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613257 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13258
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13259
+
13260
+ // Reverse comparison
1293813261 "SUB temp.x, one.x, temp.x;" +
1293913262 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13263
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113264 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213265
1294313266 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13274,10 @@
1295113274 // No shadow for backface
1295213275 "DP3 temp.x, normal, lightd;" +
1295313276 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13277
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13278
+
13279
+ // No shadow when out of frustrum
13280
+ "SGE temp.x, " + depth + ".z, one.z;" +
1295413281 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513282 "";
1295613283 }
....@@ -13097,7 +13424,8 @@
1309713424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1310113429
1310213430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313431 // OUT : diff, spec
....@@ -13113,9 +13441,10 @@
1311313441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513443 //"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;" +
13444
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13445
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13446
+
13447
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1311913448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013449 "RCP " + dest + ".w," + dest + ".w;" +
1312113450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13838,7 @@
1350913838 public void mousePressed(MouseEvent e)
1351013839 {
1351113840 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13841
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313842 }
1351413843
1351513844 static long prevtime = 0;
....@@ -13585,8 +13914,8 @@
1358513914 // mode |= META;
1358613915 //}
1358713916
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13917
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13918
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013919 anchorX = ax;
1359113920 anchorY = ay;
1359213921 prevX = px;
....@@ -13620,6 +13949,7 @@
1362013949 else
1362113950 if (evt.getSource() == AAtimer)
1362213951 {
13952
+ Globals.TIMERRUNNING = false;
1362313953 if (mouseDown)
1362413954 {
1362513955 //new Exception().printStackTrace();
....@@ -13645,6 +13975,10 @@
1364513975 // LIVE = waslive;
1364613976 // wasliveok = true;
1364713977 // waslive = false;
13978
+
13979
+ // May 2019 Forget it:
13980
+ if (true)
13981
+ return;
1364813982
1364913983 // source == timer
1365013984 if (mouseDown)
....@@ -13675,7 +14009,7 @@
1367514009
1367614010 // fev 2014???
1367714011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367914013 pingthread.StepToTarget(true); // true);
1368014014 }
1368114015 // if (!LIVE)
....@@ -13684,12 +14018,13 @@
1368414018
1368514019 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368614020
13687
- void clickStart(int x, int y, int modifiers)
14021
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368814022 {
1368914023 if (!wasliveok)
1369014024 return;
1369114025
1369214026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1369314028
1369414029 // waslive = LIVE;
1369514030 // LIVE = false;
....@@ -13701,7 +14036,7 @@
1370114036 // touched = true; // main DL
1370214037 if (isRenderer)
1370314038 {
13704
- SetMouseMode(modifiers);
14039
+ SetMouseMode(modifiers, modifiersex);
1370514040 }
1370614041
1370714042 selectX = anchorX = x;
....@@ -13714,7 +14049,7 @@
1371414049 clicked = true;
1371514050 hold = false;
1371614051
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14052
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371814053 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371914054 {
1372014055 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14080,7 @@
1374514080 info.camera = renderCamera;
1374614081 info.x = x;
1374714082 info.y = y;
13748
- info.modifiers = modifiers;
14083
+ info.modifiers = modifiersex;
1374914084 editObj = object.doEditClick(info, 0);
1375014085 if (!editObj)
1375114086 {
....@@ -13762,9 +14097,12 @@
1376214097
1376314098 public void mouseDragged(MouseEvent e)
1376414099 {
14100
+ Globals.MOUSEDRAGGED = true;
14101
+
1376514102 //System.out.println("mouseDragged: " + e);
1376614103 if (isRenderer)
1376714104 movingcamera = true;
14105
+
1376814106 //if (drawing)
1376914107 //return;
1377014108 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14112,7 @@
1377414112 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514113 }
1377614114 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14115
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814116
1377914117 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014118 }
....@@ -14011,7 +14349,7 @@
1401114349 {
1401214350 Globals.lighttouched = true;
1401314351 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14352
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514353 }
1401614354 //else
1401714355 }
....@@ -14025,12 +14363,12 @@
1402514363 void GoDown(int mod)
1402614364 {
1402714365 MODIFIERS |= COMMAND;
14028
- /*
14366
+ /**/
1402914367 if((mod&SHIFT) == SHIFT)
1403014368 manipCamera.RotatePosition(0, -speed);
1403114369 else
14032
- manipCamera.BackForth(0, -speed*delta, getWidth());
14033
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1403414372 if ((mod & SHIFT) == SHIFT)
1403514373 {
1403614374 mouseMode = mouseMode; // VR??
....@@ -14046,12 +14384,12 @@
1404614384 void GoUp(int mod)
1404714385 {
1404814386 MODIFIERS |= COMMAND;
14049
- /*
14387
+ /**/
1405014388 if((mod&SHIFT) == SHIFT)
1405114389 manipCamera.RotatePosition(0, speed);
1405214390 else
14053
- manipCamera.BackForth(0, speed*delta, getWidth());
14054
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1405514393 if ((mod & SHIFT) == SHIFT)
1405614394 {
1405714395 mouseMode = mouseMode;
....@@ -14067,12 +14405,12 @@
1406714405 void GoLeft(int mod)
1406814406 {
1406914407 MODIFIERS |= COMMAND;
14070
- /*
14408
+ /**/
1407114409 if((mod&SHIFT) == SHIFT)
14072
- manipCamera.RotatePosition(speed, 0);
14073
- else
1407414410 manipCamera.Translate(speed*delta, 0, getWidth());
14075
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1407614414 if ((mod & SHIFT) == SHIFT)
1407714415 {
1407814416 mouseMode = mouseMode;
....@@ -14088,12 +14426,12 @@
1408814426 void GoRight(int mod)
1408914427 {
1409014428 MODIFIERS |= COMMAND;
14091
- /*
14429
+ /**/
1409214430 if((mod&SHIFT) == SHIFT)
14093
- manipCamera.RotatePosition(-speed, 0);
14094
- else
1409514431 manipCamera.Translate(-speed*delta, 0, getWidth());
14096
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1409714435 if ((mod & SHIFT) == SHIFT)
1409814436 {
1409914437 mouseMode = mouseMode;
....@@ -14111,7 +14449,7 @@
1411114449 int X, Y;
1411214450 boolean SX, SY;
1411314451
14114
- void drag(int x, int y, int modifiers)
14452
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514453 {
1411614454 if (IsFrozen())
1411714455 {
....@@ -14120,17 +14458,17 @@
1412014458
1412114459 drag = true; // NEW
1412214460
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14461
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414462
1412514463 X = x;
1412614464 Y = y;
1412714465 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14466
+ MODIFIERS = modifiersex;
14467
+ modifiersex &= ~1024;
1413014468 if (false) // modifiers != 0)
1413114469 {
1413214470 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14471
+ System.out.println("mouseDragged: " + modifiersex);
1413414472 System.out.println("SHIFT = " + SHIFT);
1413514473 System.out.println("CONTROL = " + COMMAND);
1413614474 System.out.println("META = " + META);
....@@ -14150,7 +14488,8 @@
1415014488 info.camera = renderCamera;
1415114489 info.x = x;
1415214490 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414493 } else
1415514494 {
1415614495 if (x < startX)
....@@ -14314,7 +14653,9 @@
1431414653 ci.camera = renderCamera;
1431514654 if (!isRenderer)
1431614655 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1431814659 {
1431914660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014661 } else
....@@ -14326,7 +14667,11 @@
1432614667
1432714668 public void mouseReleased(MouseEvent e)
1432814669 {
14670
+ Globals.MOUSEDRAGGED = false;
14671
+
1432914672 movingcamera = false;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1433014675 //System.out.println("mouseReleased: " + e);
1433114676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214677 }
....@@ -14349,9 +14694,9 @@
1434914694 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014695 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114696
14352
- if (control || command || IsFrozen())
14697
+// No delay if (control || command || IsFrozen())
1435314698 timeout = true;
14354
- else
14699
+// ?? May 2019 else
1435514700 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614701 mouseDown = false;
1435714702 if (!control && !command) // june 2013
....@@ -14461,7 +14806,7 @@
1446114806 System.out.println("keyReleased: " + e);
1446214807 }
1446314808
14464
- void SetMouseMode(int modifiers)
14809
+ void SetMouseMode(int modifiers, int modifiersex)
1446514810 {
1446614811 //System.out.println("SetMouseMode = " + modifiers);
1446714812 //modifiers &= ~1024;
....@@ -14473,25 +14818,25 @@
1447314818 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414819 // return;
1447514820 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14821
+ if ((modifiersex & WHEEL) == WHEEL)
1447714822 {
1447814823 mouseMode |= ZOOM;
1447914824 }
1448014825
1448114826 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14827
+ if (capsLocked) // || (modifiers & META) == META)
1448314828 {
1448414829 mouseMode |= VR; // BACKFORTH;
1448514830 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14831
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714832 {
1448814833 mouseMode |= SELECT;
1448914834 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14835
+ if ((modifiersex & COMMAND) == COMMAND)
1449114836 {
1449214837 mouseMode |= SELECT;
1449314838 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14839
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514840 {
1449614841 mouseMode &= ~VR;
1449714842 mouseMode |= TRANSLATE;
....@@ -14520,7 +14865,7 @@
1452014865
1452114866 if (isRenderer) //
1452214867 {
14523
- SetMouseMode(modifiers);
14868
+ SetMouseMode(0, modifiers);
1452414869 }
1452514870
1452614871 Globals.theRenderer.keyPressed(key);
....@@ -14667,7 +15012,9 @@
1466715012 case 'E' : COMPACT ^= true;
1466815013 repaint();
1466915014 break;
14670
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1467115018 repaint();
1467215019 break;
1467315020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14692,8 +15039,8 @@
1469215039 RevertCamera();
1469315040 repaint();
1469415041 break;
14695
- case 'L':
1469615042 case 'l':
15043
+ //case 'L':
1469715044 if (lightMode)
1469815045 {
1469915046 lightMode = false;
....@@ -14836,9 +15183,9 @@
1483615183 case '_':
1483715184 kompactbit = 5;
1483815185 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1484215189 case ' ':
1484315190 lightMode ^= true;
1484415191 Globals.lighttouched = true;
....@@ -14850,13 +15197,14 @@
1485015197 case ESC:
1485115198 RENDERPROGRAM += 1;
1485215199 RENDERPROGRAM %= 3;
15200
+
1485315201 repaint();
1485415202 break;
1485515203 case 'Z':
1485615204 //RESIZETEXTURE ^= true;
1485715205 //break;
1485815206 case 'z':
14859
- RENDERSHADOW ^= true;
15207
+ Globals.RENDERSHADOW ^= true;
1486015208 Globals.lighttouched = true;
1486115209 repaint();
1486215210 break;
....@@ -14889,8 +15237,9 @@
1488915237 case DELETE:
1489015238 ClearSelection();
1489115239 break;
14892
- /*
1489315240 case '+':
15241
+
15242
+ /*
1489415243 //fontsize += 1;
1489515244 bbzoom *= 2;
1489615245 repaint();
....@@ -14907,17 +15256,17 @@
1490715256 case '=':
1490815257 IncDepth();
1490915258 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1491115260 maskbit = 6;
1491215261 break;
1491315262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415263 DecDepth();
1491515264 maskbit = 5;
1491615265 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1492115270 break;
1492215271 case '{':
1492315272 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15329,7 @@
1498015329 //mode = ROTATE;
1498115330 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215331 {
14983
- SetMouseMode(modifiers);
15332
+ SetMouseMode(0, modifiers);
1498415333 }
1498515334 }
1498615335
....@@ -15116,7 +15465,7 @@
1511615465 {
1511715466 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815467 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15468
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512015469 {
1512115470 mouseMoved(e);
1512215471 } else
....@@ -15141,7 +15490,7 @@
1514115490 }
1514215491 */
1514315492
15144
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1514515494 }
1514615495
1514715496 void SelectParent()
....@@ -15158,10 +15507,10 @@
1515815507 {
1515915508 //selectees.remove(i);
1516015509 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215511 } else
1516315512 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515514 }
1516615515
1516715516 first = false;
....@@ -15203,12 +15552,12 @@
1520315552 for (int j = 0; j < group.children.size(); j++)
1520415553 {
1520515554 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715556 first = false;
1520815557 }
1520915558 } else
1521015559 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215561 }
1521315562
1521415563 first = false;
....@@ -15219,21 +15568,21 @@
1521915568 {
1522015569 //Composite group = (Composite) object;
1522115570 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315572 }
1522415573
1522515574 void ResetTransform(int mask)
1522615575 {
1522715576 //Composite group = (Composite) object;
1522815577 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1523015579 }
1523115580
1523215581 void FlipTransform()
1523315582 {
1523415583 //Composite group = (Composite) object;
1523515584 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1523715586 // group.editWindow.ReduceMesh(true);
1523815587 }
1523915588
....@@ -15241,7 +15590,7 @@
1524115590 {
1524215591 //Composite group = (Composite) object;
1524315592 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1524515594 // group.editWindow.ReduceMesh(true);
1524615595 }
1524715596
....@@ -15249,7 +15598,7 @@
1524915598 {
1525015599 //Composite group = (Composite) object;
1525115600 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1525315602 }
1525415603
1525515604 void IncDepth()
....@@ -15335,7 +15684,9 @@
1533515684 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615685 //Image img = CreateImage(width, height);
1533715686 //System.out.println("width = " + width + "; height = " + height + "\n");
15687
+
1533815688 Graphics gr = g; // img.getGraphics();
15689
+
1533915690 if (!hasMarquee)
1534015691 {
1534115692 if (Xmin < Xmax) // !locked)
....@@ -15423,6 +15774,7 @@
1542315774 info.bounds.y += (height - desired) / 2;
1542415775 }
1542515776 }
15777
+
1542615778 info.g = gr;
1542715779 info.camera = renderCamera;
1542815780 /*
....@@ -15432,15 +15784,55 @@
1543215784 */
1543315785 if (!isRenderer)
1543415786 {
15435
- object.drawEditHandles(info, 0);
15787
+ Grafreed.Assert(object != null);
15788
+ Grafreed.Assert(object.selection != null);
15789
+ if (object.selection.Size() > 0)
15790
+ {
15791
+ int hitSomething = object.selection.get(0).hitSomething;
15792
+
15793
+ info.DX = 0;
15794
+ info.DY = 0;
15795
+ info.W = 1;
15796
+ if (hitSomething == Object3D.hitCenter)
15797
+ {
15798
+ info.DX = X;
15799
+ if (X != 0)
15800
+ info.DX -= info.bounds.width/2;
15801
+
15802
+ info.DY = Y;
15803
+ if (Y != 0)
15804
+ info.DY -= info.bounds.height/2;
15805
+ }
15806
+
15807
+ object.drawEditHandles(info, 0);
15808
+
15809
+ if (drag && (X != 0 || Y != 0))
15810
+ {
15811
+ switch (hitSomething)
15812
+ {
15813
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15814
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15815
+ break;
15816
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15817
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15818
+ break;
15819
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15820
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15821
+ break;
15822
+ }
15823
+
15824
+ }
15825
+ }
1543615826 }
1543715827 }
15828
+
1543815829 if (isRenderer)
1543915830 {
1544015831 //gr.setColor(Color.black);
1544115832 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215833 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315834 }
15835
+
1544415836 if (hasMarquee)
1544515837 {
1544615838 gr.setXORMode(Color.white);
....@@ -15553,6 +15945,7 @@
1555315945 public boolean mouseDown(Event evt, int x, int y)
1555415946 {
1555515947 System.out.println("mouseDown: " + evt);
15948
+ System.exit(0);
1555615949 /*
1555715950 locked = true;
1555815951 drag = false;
....@@ -15596,7 +15989,7 @@
1559615989 {
1559715990 keyPressed(0, modifiers);
1559815991 }
15599
- clickStart(x, y, modifiers);
15992
+ // clickStart(x, y, modifiers);
1560015993 return true;
1560115994 }
1560215995
....@@ -15714,7 +16107,7 @@
1571416107 {
1571516108 keyReleased(0, 0);
1571616109 }
15717
- drag(x, y, modifiers);
16110
+ drag(x, y, 0, modifiers);
1571816111 return true;
1571916112 }
1572016113
....@@ -15846,7 +16239,7 @@
1584616239 Object3D object;
1584716240 static Object3D trackedobject;
1584816241 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16242
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016243 /*static*/ Camera eyeCamera;
1585116244 /*static*/ Camera lightCamera;
1585216245 int cameracount;
....@@ -16131,16 +16524,16 @@
1613116524 cStatic.objectstack[materialdepth++] = checker;
1613216525 //System.out.println("material " + material);
1613316526 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1613516528
1613616529 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816531
1613916532 materialdepth -= 1;
1614016533 if (materialdepth > 0)
1614116534 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16535
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16536
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1614416537 }
1614516538 //checker.GetMaterial().opacity = 1f;
1614616539 ////checker.GetMaterial().ambient = 1f;
....@@ -16226,6 +16619,14 @@
1622616619 }
1622716620 }
1622816621
16622
+ private Object3D GetFolder()
16623
+ {
16624
+ Object3D folder = object.GetWindow().copy;
16625
+ if (object.GetWindow().copy.selection.Size() > 0)
16626
+ folder = object.GetWindow().copy.selection.elementAt(0);
16627
+ return folder;
16628
+ }
16629
+
1622916630 class SelectBuffer implements GLEventListener
1623016631 {
1623116632
....@@ -16305,6 +16706,17 @@
1630516706
1630616707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630716708
16709
+ if (PAINTMODE)
16710
+ {
16711
+ if (object.GetWindow().copy.selection.Size() > 0)
16712
+ {
16713
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16714
+
16715
+ // Make what you paint not selectable.
16716
+ paintobj.ResetSelectable();
16717
+ }
16718
+ }
16719
+
1630816720 //int tmp = selection_view;
1630916721 //selection_view = -1;
1631016722 int temp = DrawMode();
....@@ -16316,6 +16728,17 @@
1631616728 // temp = DEFAULT; // patch for selection debug
1631716729 Globals.drawMode = temp; // WARNING
1631816730
16731
+ if (PAINTMODE)
16732
+ {
16733
+ if (object.GetWindow().copy.selection.Size() > 0)
16734
+ {
16735
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16736
+
16737
+ // Revert.
16738
+ paintobj.RestoreSelectable();
16739
+ }
16740
+ }
16741
+
1631916742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632016743
1632116744 // trying different ways of getting the depth info over
....@@ -16363,6 +16786,8 @@
1636316786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1636416787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1636616791
1636716792 // Will fit the mesh !!!
1636816793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16412,34 +16837,36 @@
1641216837 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]));
1641316838 }
1641416839
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16840
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616841 }
1641716842 }
1641816843
1641916844 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116846
16422
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16847
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1642316848 {
16424
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16849
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1642516850
16426
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642716854
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();
16855
+ Object3D inst = new Object3D("inst" + paintcount++);
16856
+
16857
+ inst.CreateMaterial(); // use a void leaf to select instances
16858
+
16859
+ inst.add(paintobj); // link
16860
+
16861
+ object.GetWindow().SnapObject(inst);
16862
+
16863
+ Object3D folder = paintFolder; // GetFolder();
16864
+
16865
+ folder.add(inst);
16866
+
16867
+ object.GetWindow().ResetModel();
16868
+ object.GetWindow().refreshContents();
16869
+ }
1644316870 }
1644416871 else
1644516872 paintcount = 0;
....@@ -16478,6 +16905,11 @@
1647816905 //System.out.println("objects[color] = " + objects[color]);
1647916906 //objects[color].Select();
1648016907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1648116913 object.Select(color, deselect);
1648216914 }
1648316915
....@@ -16577,7 +17009,7 @@
1657717009 gl.glDisable(gl.GL_CULL_FACE);
1657817010 }
1657917011
16580
- if (!RENDERSHADOW)
17012
+ if (!Globals.RENDERSHADOW)
1658117013 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658217014
1658317015 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +17019,7 @@
1658717019 //gl.glColorMask(false, false, false, false);
1658817020
1658917021 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17022
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659117023 {
1659217024 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659317025
....@@ -17003,23 +17435,15 @@
1700317435 int AAbuffersize = 0;
1700417436
1700517437 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1700717439 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();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1701217444
1701317445 static Sphere debugpoints[] = new Sphere[8];
1701417446
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317447 static void InitPoints(float radius)
1702417448 {
1702517449 for (int i=0; i<8; i++)