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;
....@@ -92,6 +89,8 @@
9289
9390 static int tickcount = 0; // slow pose issue
9491
92
+static boolean BUTTONLESSWHEEL = false;
93
+static boolean ZOOMBOXMODE = false;
9594 static boolean BOXMODE = false;
9695 static boolean IMAGEFLIP = false;
9796 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +105,7 @@
106105 static boolean OEIL = true;
107106 static boolean OEILONCE = false; // do oeilon then oeiloff
108107 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
108
+static boolean SWITCH = true; // false;
110109 static boolean HANDLES = false; // selection doesn't work!!
111110 static boolean PAINTMODE = false;
112111
....@@ -149,6 +148,8 @@
149148 defaultcaps.setAccumBlueBits(16);
150149 defaultcaps.setAccumAlphaBits(16);
151150 }
151
+
152
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152153
153154 void SetAsGLRenderer(boolean b)
154155 {
....@@ -223,6 +224,11 @@
223224 public boolean IsBoxMode()
224225 {
225226 return BOXMODE;
227
+ }
228
+
229
+ public boolean IsZoomBoxMode()
230
+ {
231
+ return ZOOMBOXMODE;
226232 }
227233
228234 public void ClearDepth()
....@@ -320,7 +326,7 @@
320326 cStatic.objectstack[materialdepth++] = obj;
321327 //System.out.println("material " + material);
322328 //Applet3D.tracein(this, selected);
323
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
324330 if (obj instanceof Camera)
325331 {
326332 display.options1[0] = material.shift;
....@@ -329,14 +335,28 @@
329335 display.options1[2] = material.shadowbias;
330336 display.options1[3] = material.aniso;
331337 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]);
332343 display.options2[0] = material.opacity;
333344 display.options2[1] = material.diffuse;
334345 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]);
335349
336350 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]);
337354 display.options4[0] = material.cameralight/0.2f;
338355 display.options4[1] = material.subsurface;
339356 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]);
340360
341361 // if (display.CURRENTANTIALIAS > 0)
342362 // display.options3[3] /= 4;
....@@ -352,7 +372,7 @@
352372 /**/
353373 } else
354374 {
355
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
356376 }
357377 } else
358378 {
....@@ -376,8 +396,8 @@
376396 cStatic.objectstack[materialdepth++] = obj;
377397 //System.out.println("material " + material);
378398 //Applet3D.tracein("selected ", selected);
379
- display.vector2buffer = obj.projectedVertices;
380
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
381401 }
382402 }
383403
....@@ -394,8 +414,8 @@
394414 materialdepth -= 1;
395415 if (materialdepth > 0)
396416 {
397
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
398
- 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);
399419 }
400420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
401421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -415,8 +435,8 @@
415435 materialdepth -= 1;
416436 if (materialdepth > 0)
417437 {
418
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
419
- 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);
420440 }
421441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
422442 //else
....@@ -457,10 +477,12 @@
457477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458478 {
459479 //gl.glBegin(gl.GL_TRIANGLES);
460
- 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
+ ;
461483 if (!hasnorm)
462484 {
463
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
464486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
465487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
466488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1185,10 +1207,12 @@
11851207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11861208 }
11871209 }
1210
+
11881211 if (flipV)
11891212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11901213 else
11911214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11921216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11931217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11941218
....@@ -1208,10 +1232,12 @@
12081232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12091233 }
12101234 }
1235
+
12111236 if (flipV)
12121237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12131238 else
12141239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12151241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12161242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12171243
....@@ -1239,8 +1265,10 @@
12391265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12401266 else
12411267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12421269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12431270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12441272 count2 += 2;
12451273 count3 += 3;
12461274 }
....@@ -1596,7 +1624,7 @@
15961624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
15971625 }
15981626
1599
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16001628 {
16011629 CameraPane display = this;
16021630 //new Exception().printStackTrace();
....@@ -1612,18 +1640,18 @@
16121640 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131641 if (!material.multiply)
16141642 {
1615
- display.color = color;
1643
+ display.color = material.color;
16161644 display.saturation = material.modulation;
16171645 }
16181646 else
16191647 {
1620
- display.color *= color*2;
1648
+ display.color *= material.color*2;
16211649 display.saturation *= material.modulation*2;
16221650 }
16231651
16241652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16251653
1626
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16271655
16281656 /**/
16291657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1631,7 +1659,7 @@
16311659 colorV[0] = display.modelParams0[0] * material.diffuse;
16321660 colorV[1] = display.modelParams0[1] * material.diffuse;
16331661 colorV[2] = display.modelParams0[2] * material.diffuse;
1634
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16351663
16361664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16371665 //System.out.println("Opacity = " + opacity);
....@@ -1739,9 +1767,9 @@
17391767 display.modelParams7[2] = 0;
17401768 display.modelParams7[3] = 0;
17411769
1742
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17431771
1744
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17451773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17461774 {
17471775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1883,7 +1911,7 @@
18831911 void PushMatrix(double[][] matrix)
18841912 {
18851913 // GrafreeD.tracein(matrix);
1886
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18871915 }
18881916
18891917 void PushMatrix()
....@@ -2037,7 +2065,7 @@
20372065 //System.err.println("Oeil on");
20382066 OEIL = true;
20392067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2040
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20412069 //pingthread.StepToTarget(true);
20422070 }
20432071
....@@ -2135,7 +2163,7 @@
21352163 System.err.println("LIVE = " + Globals.isLIVE());
21362164
21372165 if (!Globals.isLIVE()) // save sound
2138
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21392167 // else
21402168 repaint(); // start loop // may 2013
21412169 }
....@@ -2168,6 +2196,11 @@
21682196 public void ToggleBoxMode()
21692197 {
21702198 BOXMODE ^= true;
2199
+ }
2200
+
2201
+ public void ToggleZoomBoxMode()
2202
+ {
2203
+ ZOOMBOXMODE ^= true;
21712204 }
21722205
21732206 public void ToggleSmoothFocus()
....@@ -2247,7 +2280,7 @@
22472280
22482281 void ToggleDebug()
22492282 {
2250
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22512284 }
22522285
22532286 void ToggleLookAt()
....@@ -2255,9 +2288,9 @@
22552288 LOOKAT ^= true;
22562289 }
22572290
2258
- void ToggleRandom()
2291
+ void ToggleSwitch()
22592292 {
2260
- RANDOM ^= true;
2293
+ SWITCH ^= true;
22612294 }
22622295
22632296 void ToggleHandles()
....@@ -2265,10 +2298,17 @@
22652298 HANDLES ^= true;
22662299 }
22672300
2301
+ Object3D paintFolder;
2302
+
22682303 void TogglePaint()
22692304 {
22702305 PAINTMODE ^= true;
22712306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22722312 }
22732313
22742314 void SwapCamera(int a, int b)
....@@ -2364,7 +2404,46 @@
23642404 {
23652405 return currentGL;
23662406 }
2367
-
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
+
23682447 /**/
23692448 class CacheTexture
23702449 {
....@@ -2382,9 +2461,10 @@
23822461 /**/
23832462
23842463 // TEXTURE static Texture texture;
2385
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2386
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2387
- 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
+
23882468 int pigmentdepth = 0;
23892469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
23902470 int bumpdepth = 0;
....@@ -2406,6 +2486,33 @@
24062486 true,
24072487 com.sun.opengl.util.texture.TextureIO.PNG);
24082488 } 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)
24092516 {
24102517 throw new javax.media.opengl.GLException(e);
24112518 }
....@@ -3492,6 +3599,8 @@
34923599
34933600 System.out.println("LOADING TEXTURE : " + name);
34943601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
34953604 //
34963605 if (false) // compressbit > 0)
34973606 {
....@@ -4196,6 +4305,7 @@
41964305
41974306 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
41984307 {
4308
+ new Exception().printStackTrace();
41994309 System.exit(0);
42004310 com.sun.opengl.util.texture.Texture texture = null;
42014311
....@@ -7889,7 +7999,7 @@
78897999 String pigment = Object3D.GetPigment(tex);
78908000 String bump = Object3D.GetBump(tex);
78918001
7892
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
78938003 {
78948004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
78958005 // System.out.println("; bump = " + bump);
....@@ -7906,6 +8016,64 @@
79068016
79078017 ReleaseTexture(bump, true);
79088018 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);
79098077 }
79108078
79118079 void ReleaseTexture(String tex, boolean bump)
....@@ -8011,7 +8179,55 @@
80118179 }
80128180 }
80138181
8014
- /*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
80158231 {
80168232 if (// DrawMode() != 0 || /*tex == null ||*/
80178233 ambientOcclusion ) // || !textureon)
....@@ -8021,18 +8237,48 @@
80218237
80228238 if (tex == null)
80238239 {
8024
- BindTexture(null,false,resolution);
8025
- BindTexture(null,true,resolution);
8240
+ BindTexture(null, null,false,resolution);
80268241 return;
80278242 }
80288243
80298244 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
+
80308277 String bump = Object3D.GetBump(tex);
80318278
8032
- usedtextures.put(pigment, pigment);
8033
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
80348280
8035
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80368282 {
80378283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80388284 // System.out.println("; bump = " + bump);
....@@ -8042,42 +8288,70 @@
80428288 {
80438289 bump = null;
80448290 }
8045
- if (pigment.equals(""))
8046
- {
8047
- pigment = null;
8048
- }
80498291
8050
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8051
- BindTexture(pigment, false, resolution);
80528292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8053
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
80548294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8055
-
8056
- return; // true;
80578295 }
80588296
8059
- 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)
80608300 {
8061
- 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;
80628320
80638321 if (tex != null)
80648322 {
80658323 String texname = tex;
80668324
8067
- String[] split = tex.split("Textures");
8068
- if (split.length > 1)
8069
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8070
- else
8071
- if (!texname.startsWith("/"))
8072
- 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
+ }
80738337
80748338 if (CACHETEXTURE)
8075
- texture = textures.get(texname); // TEXTURE CACHE
8076
-
8077
- TextureData texturedata = null;
8078
-
8079
- if (texture == null || texture.resolution < resolution)
80808339 {
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
80818355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80828356 {
80838357 assert(!bump);
....@@ -8089,19 +8363,23 @@
80898363 // }
80908364 // else
80918365 // {
8092
- texture = textures.get(tex);
8093
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
80948368 {
8095
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
80968370 }
8371
+ else
8372
+ new Exception().printStackTrace();
80978373 // }
80988374 } else
80998375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81008376 {
81018377 assert(bump);
8102
- texture = textures.get(tex);
8103
- if (texture == null)
8104
- 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();
81058383 } else
81068384 {
81078385 //if (tex.equals("IMMORTAL"))
....@@ -8111,9 +8389,11 @@
81118389 //{
81128390 if (tex.equals("WHITE_NOISE"))
81138391 {
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- 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();
81178397 } else
81188398 {
81198399 if (textureon)
....@@ -8138,7 +8418,7 @@
81388418 }
81398419
81408420 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8421
+ if (!FileExists(cachename))
81428422 cachename = texname;
81438423 else
81448424 processbump = false; // don't process bump map again
....@@ -8160,7 +8440,7 @@
81608440 }
81618441
81628442 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8443
+ if (!FileExists(cachename))
81648444 cachename = texname;
81658445 else
81668446 processbump = false; // don't process bump map again
....@@ -8169,20 +8449,23 @@
81698449 texturedata = GetFileTexture(cachename, processbump, resolution);
81708450
81718451
8172
- if (texturedata != null)
8173
- 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);
81748456 //texture = GetTexture(tex, bump);
81758457 }
81768458 }
81778459 //}
81788460 }
81798461
8180
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81818463 {
81828464 //return false;
8465
+ assert(bim == null);
81838466
81848467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8185
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81868469 {
81878470 // String ext = "_highres";
81888471 // if (REDUCETEXTURE)
....@@ -8199,52 +8482,17 @@
81998482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82008483 if (!cachefile.exists())
82018484 {
8202
- // cache to disk
8203
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8204
- //buffers[0].
8205
-
8206
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8207
- int[] pixels = new int[bytebuf.capacity()/3];
8208
-
8209
- // squared size heuristic...
8210
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
82118486 {
8212
- for (int i=pixels.length; --i>=0;)
8213
- {
8214
- int i3 = i*3;
8215
- pixels[i] = 0xFF;
8216
- pixels[i] <<= 8;
8217
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8218
- pixels[i] <<= 8;
8219
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8220
- pixels[i] <<= 8;
8221
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8222
- }
8223
-
8224
- /*
8225
- int r=0,g=0,b=0,a=0;
8226
- for (int i=0; i<width; i++)
8227
- for (int j=0; j<height; j++)
8228
- {
8229
- int index = j*width+i;
8230
- int p = pixels[index];
8231
- a = ((p>>24) & 0xFF);
8232
- r = ((p>>16) & 0xFF);
8233
- g = ((p>>8) & 0xFF);
8234
- b = (p & 0xFF);
8235
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8236
- }
8237
- /**/
8238
- int width = (int)Math.sqrt(pixels.length); // squared
8239
- int height = width;
8240
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8241
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
82428489 ImageWriter writer = null;
82438490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82448491 if (iter.hasNext()) {
82458492 writer = (ImageWriter)iter.next();
82468493 }
8247
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
82488496 try
82498497 {
82508498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8271,8 +8519,8 @@
82718519 textures.remove(texname);
82728520 }
82738521
8274
- texture.texturedata = texturedata;
8275
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
82768524
82778525 // newtex = true;
82788526 }
....@@ -8288,12 +8536,17 @@
82888536 }
82898537 }
82908538
8291
- return texture;
8539
+ return texturecache;
82928540 }
82938541
8294
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8542
+ static void EmbedTextures(cTexture tex)
82958543 {
8296
- 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);
82978550
82988551 if (bump)
82998552 {
....@@ -8309,23 +8562,23 @@
83098562 return texture!=null?texture.texture:null;
83108563 }
83118564
8312
- 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
83138566 {
8314
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83158568
83168569 return texture!=null?texture.texturedata:null;
83178570 }
83188571
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8572
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83208573 {
83218574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228575 {
83238576 return false;
83248577 }
83258578
8326
- boolean newtex = false;
8579
+ //boolean newtex = false;
83278580
8328
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83298582
83308583 if (texture == null)
83318584 return false;
....@@ -8355,7 +8608,7 @@
83558608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83568609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83578610
8358
- return newtex;
8611
+ return true; // Warning: not used.
83598612 }
83608613
83618614 ShadowBuffer shadowPBuf;
....@@ -9193,11 +9446,35 @@
91939446 jy8[3] = 0.5f;
91949447 }
91959448
9196
- 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
91979450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
91989451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
91999452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92009453
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
+
92019478 static int imagecount = 0; // movie generation
92029479
92039480 static int jitter = 0;
....@@ -9293,8 +9570,8 @@
92939570 assert (parentcam != renderCamera);
92949571
92959572 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
92989575
92999576 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009577
....@@ -9309,8 +9586,8 @@
93099586 LA.matCopy(renderCamera.fromScreen, matrix);
93109587
93119588 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9589
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9590
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93149591
93159592 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169593
....@@ -9382,7 +9659,7 @@
93829659 //gl.glFlush();
93839660 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849661
9385
- if (ANIMATION && ABORTED)
9662
+ if (Globals.ANIMATION && ABORTED)
93869663 {
93879664 System.err.println(" ABORTED FRAME");
93889665 break;
....@@ -9412,7 +9689,7 @@
94129689 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139690
94149691 // save image
9415
- if (ANIMATION && !ABORTED)
9692
+ if (Globals.ANIMATION && !ABORTED)
94169693 {
94179694 VPwidth = viewport[2];
94189695 VPheight = viewport[3];
....@@ -9523,11 +9800,11 @@
95239800
95249801 // imagecount++;
95259802
9526
- 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;
95279804
95289805 if (!BOXMODE)
95299806 {
9530
- 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) + ")");
95319808 }
95329809
95339810 if (!BOXMODE)
....@@ -9565,7 +9842,7 @@
95659842 ABORTED = false;
95669843 }
95679844 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9845
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699846
95709847 if (false)
95719848 {
....@@ -10228,11 +10505,11 @@
1022810505
1022910506 public void display(GLAutoDrawable drawable)
1023010507 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10508
+ if (Grafreed.savesound && Grafreed.hassound)
1023210509 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10510
+ Grafreed.wav.save();
10511
+ Grafreed.savesound = false;
10512
+ Grafreed.hassound = false;
1023610513 }
1023710514 // if (DEBUG_SELECTION)
1023810515 // {
....@@ -10308,6 +10585,7 @@
1030810585 ANTIALIAS = 0;
1030910586 //System.out.println("RESTART");
1031010587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1031110589 }
1031210590 }
1031310591 }
....@@ -10362,7 +10640,7 @@
1036210640 Object3D theobject = object;
1036310641 Object3D theparent = object.parent;
1036410642 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10643
+ object = (Object3D)Grafreed.clone(object);
1036610644 object.Stripify();
1036710645 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810646 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10653,14 @@
1037510653 ambientOcclusion = false;
1037610654 }
1037710655
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910658 {
1038010659 //if (RENDERSHADOW) // ?
1038110660 if (!IsFrozen())
1038210661 {
1038310662 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10663
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510664 {
1038610665 Globals.framecount++;
1038710666 shadowbuffer.display();
....@@ -10508,8 +10787,8 @@
1050810787
1050910788 // if (parentcam != renderCamera) // not a light
1051010789 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10790
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10791
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1051310792
1051410793 for (int j = 0; j < 4; j++)
1051510794 {
....@@ -10523,8 +10802,8 @@
1052310802
1052410803 // if (parentcam != renderCamera) // not a light
1052510804 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10805
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10806
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1052810807
1052910808 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010809
....@@ -10783,7 +11062,16 @@
1078311062 // Bump noise
1078411063 gl.glActiveTexture(GL.GL_TEXTURE6);
1078511064 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- 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
+
1078711075
1078811076 gl.glActiveTexture(GL.GL_TEXTURE0);
1078911077 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10806,9 +11094,9 @@
1080611094
1080711095 gl.glMatrixMode(GL.GL_MODELVIEW);
1080811096
10809
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10810
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10811
-//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);
1081211100 } else
1081311101 {
1081411102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10819,7 +11107,7 @@
1081911107 //System.out.println("BLENDING ON");
1082011108 gl.glEnable(GL.GL_BLEND);
1082111109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10822
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1082311111 gl.glMatrixMode(gl.GL_PROJECTION);
1082411112 gl.glLoadIdentity();
1082511113
....@@ -10908,8 +11196,8 @@
1090811196 System.err.println("parentcam != renderCamera");
1090911197
1091011198 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- 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
1091311201 }
1091411202
1091511203 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +11218,8 @@
1093011218 if (true) // TODO
1093111219 {
1093211220 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- 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
1093511223 }
1093611224
1093711225 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11247,8 +11535,14 @@
1124711535 {
1124811536 renderpass++;
1124911537 // System.out.println("Draw object... ");
11538
+ STEP = 1;
1125011539 if (FAST) // in case there is no script
11251
- STEP = 16;
11540
+ STEP = 8;
11541
+
11542
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11543
+ {
11544
+ STEP *= 4;
11545
+ }
1125211546
1125311547 //object.FullInvariants();
1125411548
....@@ -11262,23 +11556,44 @@
1126211556 e.printStackTrace();
1126311557 }
1126411558
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11559
+ if (Grafreed.RENDERME > 0)
11560
+ Grafreed.RENDERME--; // mechante magouille
1126711561
1126811562 Globals.ONESTEP = false;
1126911563 }
1127011564
1127111565 static boolean zoomonce = false;
1127211566
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
+
1127311585 void DrawObject(GL gl, boolean draw)
1127411586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1127511590 //System.out.println("DRAW OBJECT " + mouseDown);
1127611591 // DrawMode() = SELECTION;
1127711592 //GL gl = getGL();
1127811593 if ((TRACK || SHADOWTRACK) || zoomonce)
1127911594 {
1128011595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11281
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1128211597 pingthread.StepToTarget(true); // true);
1128311598 // zoomonce = false;
1128411599 }
....@@ -11333,7 +11648,14 @@
1133311648
1133411649 usedtextures.clear();
1133511650
11336
- 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
+ }
1133711659 }
1133811660 //System.out.println("--> " + stackdepth);
1133911661 // GrafreeD.traceon();
....@@ -11343,8 +11665,9 @@
1134311665
1134411666 if (DrawMode() == DEFAULT)
1134511667 {
11346
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1134711669 {
11670
+ CreateSelectedPoint();
1134811671 float radius = 0.05f;
1134911672 if (selectedpoint.radius != radius)
1135011673 {
....@@ -11407,7 +11730,7 @@
1140711730 if (tex.equals("WHITE_NOISE"))
1140811731 continue;
1140911732
11410
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1141111734 {
1141211735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1141311736 textures.get(tex).texture.dispose();
....@@ -11424,7 +11747,14 @@
1142411747 if (checker != null && DrawMode() == DEFAULT)
1142511748 {
1142611749 //BindTexture(IMMORTAL_TEXTURE);
11427
- 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
+ }
1142811758 // NEAREST
1142911759 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011760 DrawChecker(gl);
....@@ -11506,7 +11836,7 @@
1150611836 return;
1150711837 }
1150811838
11509
- String string = obj.GetToolTip();
11839
+ String string = obj.toString(); //.GetToolTip();
1151011840
1151111841 GL gl = GetGL();
1151211842
....@@ -11823,8 +12153,8 @@
1182312153 //obj.TransformToWorld(light, light);
1182412154 for (int i = tp.size(); --i >= 0;)
1182512155 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- 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);
1182812158 }
1182912159
1183012160
....@@ -11841,8 +12171,8 @@
1184112171 parentcam = cameras[0];
1184212172 }
1184312173
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- 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
1184612176
1184712177 LA.xformPos(light, renderCamera.toScreen, light);
1184812178
....@@ -12456,8 +12786,8 @@
1245612786
1245712787 // display shadow only (bump == 0)
1245812788 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12789
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12790
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112791 "SUB temp.y, one.x, temp.z;" +
1246212792 "MUL temp.x, temp.x, temp.y;" +
1246312793 "KIL temp.x;" +
....@@ -12586,8 +12916,10 @@
1258612916 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258712917
1258812918 "SUB temp.x, one.x, ndotl.x;" +
12589
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12590
- "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
1259112923 "MUL temp.x, temp.x, temp.y;" +
1259212924
1259312925 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +13118,7 @@
1278613118 //once = true;
1278713119 }
1278813120
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
13121
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279013122 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279113123 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279213124
....@@ -12919,12 +13251,16 @@
1291913251
1292013252 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292113253 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13254
+
13255
+ // Compare fragment depth in light space with shadowmap.
1292213256 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292313257 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
13258
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13259
+
13260
+ // Reverse comparison
1292513261 "SUB temp.x, one.x, temp.x;" +
1292613262 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13263
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813264 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913265
1293013266 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13274,10 @@
1293813274 // No shadow for backface
1293913275 "DP3 temp.x, normal, lightd;" +
1294013276 "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;" +
1294113281 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213282 "";
1294313283 }
....@@ -13084,7 +13424,8 @@
1308413424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1308513425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1308613426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13087
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1308813429
1308913430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1309013431 // OUT : diff, spec
....@@ -13100,9 +13441,10 @@
1310013441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1310113442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1310213443 //"MOV " + dest + ".w," + "normal.z;" +
13103
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13104
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13105
- //"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
1310613448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1310713449 "RCP " + dest + ".w," + dest + ".w;" +
1310813450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13496,7 +13838,7 @@
1349613838 public void mousePressed(MouseEvent e)
1349713839 {
1349813840 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13841
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350013842 }
1350113843
1350213844 static long prevtime = 0;
....@@ -13523,6 +13865,7 @@
1352313865
1352413866 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513867
13868
+ if (BUTTONLESSWHEEL)
1352613869 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713870 {
1352813871 return;
....@@ -13531,7 +13874,7 @@
1353113874 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213875
1353313876 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13877
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513878 {
1353613879 keepboxmode = BOXMODE;
1353713880 keepsupport = SUPPORT;
....@@ -13571,8 +13914,8 @@
1357113914 // mode |= META;
1357213915 //}
1357313916
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13917
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13918
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357613919 anchorX = ax;
1357713920 anchorY = ay;
1357813921 prevX = px;
....@@ -13606,6 +13949,7 @@
1360613949 else
1360713950 if (evt.getSource() == AAtimer)
1360813951 {
13952
+ Globals.TIMERRUNNING = false;
1360913953 if (mouseDown)
1361013954 {
1361113955 //new Exception().printStackTrace();
....@@ -13631,6 +13975,10 @@
1363113975 // LIVE = waslive;
1363213976 // wasliveok = true;
1363313977 // waslive = false;
13978
+
13979
+ // May 2019 Forget it:
13980
+ if (true)
13981
+ return;
1363413982
1363513983 // source == timer
1363613984 if (mouseDown)
....@@ -13661,7 +14009,7 @@
1366114009
1366214010 // fev 2014???
1366314011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13664
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1366514013 pingthread.StepToTarget(true); // true);
1366614014 }
1366714015 // if (!LIVE)
....@@ -13670,12 +14018,13 @@
1367014018
1367114019 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367214020
13673
- void clickStart(int x, int y, int modifiers)
14021
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367414022 {
1367514023 if (!wasliveok)
1367614024 return;
1367714025
1367814026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1367914028
1368014029 // waslive = LIVE;
1368114030 // LIVE = false;
....@@ -13687,7 +14036,7 @@
1368714036 // touched = true; // main DL
1368814037 if (isRenderer)
1368914038 {
13690
- SetMouseMode(modifiers);
14039
+ SetMouseMode(modifiers, modifiersex);
1369114040 }
1369214041
1369314042 selectX = anchorX = x;
....@@ -13700,7 +14049,7 @@
1370014049 clicked = true;
1370114050 hold = false;
1370214051
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14052
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370414053 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370514054 {
1370614055 // System.out.println("RESTART II " + modifiers);
....@@ -13731,7 +14080,7 @@
1373114080 info.camera = renderCamera;
1373214081 info.x = x;
1373314082 info.y = y;
13734
- info.modifiers = modifiers;
14083
+ info.modifiers = modifiersex;
1373514084 editObj = object.doEditClick(info, 0);
1373614085 if (!editObj)
1373714086 {
....@@ -13748,11 +14097,14 @@
1374814097
1374914098 public void mouseDragged(MouseEvent e)
1375014099 {
14100
+ Globals.MOUSEDRAGGED = true;
14101
+
14102
+ //System.out.println("mouseDragged: " + e);
1375114103 if (isRenderer)
1375214104 movingcamera = true;
14105
+
1375314106 //if (drawing)
1375414107 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375614108 if ((e.getModifiersEx() & CTRL) != 0
1375714109 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375814110 {
....@@ -13760,7 +14112,7 @@
1376014112 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376114113 }
1376214114 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
14115
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376414116
1376514117 //try { Thread.sleep(1); } catch (Exception ex) {}
1376614118 }
....@@ -13933,6 +14285,7 @@
1393314285
1393414286 public void run()
1393514287 {
14288
+ new Exception().printStackTrace();
1393614289 System.exit(0);
1393714290 for (;;)
1393814291 {
....@@ -13996,7 +14349,7 @@
1399614349 {
1399714350 Globals.lighttouched = true;
1399814351 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14352
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014353 }
1400114354 //else
1400214355 }
....@@ -14010,12 +14363,12 @@
1401014363 void GoDown(int mod)
1401114364 {
1401214365 MODIFIERS |= COMMAND;
14013
- /*
14366
+ /**/
1401414367 if((mod&SHIFT) == SHIFT)
1401514368 manipCamera.RotatePosition(0, -speed);
1401614369 else
14017
- manipCamera.BackForth(0, -speed*delta, getWidth());
14018
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1401914372 if ((mod & SHIFT) == SHIFT)
1402014373 {
1402114374 mouseMode = mouseMode; // VR??
....@@ -14031,12 +14384,12 @@
1403114384 void GoUp(int mod)
1403214385 {
1403314386 MODIFIERS |= COMMAND;
14034
- /*
14387
+ /**/
1403514388 if((mod&SHIFT) == SHIFT)
1403614389 manipCamera.RotatePosition(0, speed);
1403714390 else
14038
- manipCamera.BackForth(0, speed*delta, getWidth());
14039
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1404014393 if ((mod & SHIFT) == SHIFT)
1404114394 {
1404214395 mouseMode = mouseMode;
....@@ -14052,12 +14405,12 @@
1405214405 void GoLeft(int mod)
1405314406 {
1405414407 MODIFIERS |= COMMAND;
14055
- /*
14408
+ /**/
1405614409 if((mod&SHIFT) == SHIFT)
14057
- manipCamera.RotatePosition(speed, 0);
14058
- else
1405914410 manipCamera.Translate(speed*delta, 0, getWidth());
14060
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1406114414 if ((mod & SHIFT) == SHIFT)
1406214415 {
1406314416 mouseMode = mouseMode;
....@@ -14073,12 +14426,12 @@
1407314426 void GoRight(int mod)
1407414427 {
1407514428 MODIFIERS |= COMMAND;
14076
- /*
14429
+ /**/
1407714430 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(-speed, 0);
14079
- else
1408014431 manipCamera.Translate(-speed*delta, 0, getWidth());
14081
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1408214435 if ((mod & SHIFT) == SHIFT)
1408314436 {
1408414437 mouseMode = mouseMode;
....@@ -14096,7 +14449,7 @@
1409614449 int X, Y;
1409714450 boolean SX, SY;
1409814451
14099
- void drag(int x, int y, int modifiers)
14452
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014453 {
1410114454 if (IsFrozen())
1410214455 {
....@@ -14105,17 +14458,17 @@
1410514458
1410614459 drag = true; // NEW
1410714460
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14461
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914462
1411014463 X = x;
1411114464 Y = y;
1411214465 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14466
+ MODIFIERS = modifiersex;
14467
+ modifiersex &= ~1024;
1411514468 if (false) // modifiers != 0)
1411614469 {
1411714470 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14471
+ System.out.println("mouseDragged: " + modifiersex);
1411914472 System.out.println("SHIFT = " + SHIFT);
1412014473 System.out.println("CONTROL = " + COMMAND);
1412114474 System.out.println("META = " + META);
....@@ -14135,7 +14488,8 @@
1413514488 info.camera = renderCamera;
1413614489 info.x = x;
1413714490 info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914493 } else
1414014494 {
1414114495 if (x < startX)
....@@ -14287,7 +14641,6 @@
1428714641 public void mouseMoved(MouseEvent e)
1428814642 {
1428914643 //System.out.println("mouseMoved: " + e);
14290
-
1429114644 if (isRenderer)
1429214645 return;
1429314646
....@@ -14300,7 +14653,9 @@
1430014653 ci.camera = renderCamera;
1430114654 if (!isRenderer)
1430214655 {
14303
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1430414659 {
1430514660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1430614661 } else
....@@ -14312,7 +14667,11 @@
1431214667
1431314668 public void mouseReleased(MouseEvent e)
1431414669 {
14670
+ Globals.MOUSEDRAGGED = false;
14671
+
1431514672 movingcamera = false;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1431614675 //System.out.println("mouseReleased: " + e);
1431714676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814677 }
....@@ -14335,9 +14694,9 @@
1433514694 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614695 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714696
14338
- if (control || command || IsFrozen())
14697
+// No delay if (control || command || IsFrozen())
1433914698 timeout = true;
14340
- else
14699
+// ?? May 2019 else
1434114700 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214701 mouseDown = false;
1434314702 if (!control && !command) // june 2013
....@@ -14447,7 +14806,7 @@
1444714806 System.out.println("keyReleased: " + e);
1444814807 }
1444914808
14450
- void SetMouseMode(int modifiers)
14809
+ void SetMouseMode(int modifiers, int modifiersex)
1445114810 {
1445214811 //System.out.println("SetMouseMode = " + modifiers);
1445314812 //modifiers &= ~1024;
....@@ -14459,25 +14818,25 @@
1445914818 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446014819 // return;
1446114820 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
14821
+ if ((modifiersex & WHEEL) == WHEEL)
1446314822 {
1446414823 mouseMode |= ZOOM;
1446514824 }
1446614825
1446714826 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
14827
+ if (capsLocked) // || (modifiers & META) == META)
1446914828 {
1447014829 mouseMode |= VR; // BACKFORTH;
1447114830 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14831
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447314832 {
1447414833 mouseMode |= SELECT;
1447514834 }
14476
- if ((modifiers & COMMAND) == COMMAND)
14835
+ if ((modifiersex & COMMAND) == COMMAND)
1447714836 {
1447814837 mouseMode |= SELECT;
1447914838 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14839
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448114840 {
1448214841 mouseMode &= ~VR;
1448314842 mouseMode |= TRANSLATE;
....@@ -14506,7 +14865,7 @@
1450614865
1450714866 if (isRenderer) //
1450814867 {
14509
- SetMouseMode(modifiers);
14868
+ SetMouseMode(0, modifiers);
1451014869 }
1451114870
1451214871 Globals.theRenderer.keyPressed(key);
....@@ -14653,7 +15012,9 @@
1465315012 case 'E' : COMPACT ^= true;
1465415013 repaint();
1465515014 break;
14656
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1465715018 repaint();
1465815019 break;
1465915020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14678,8 +15039,8 @@
1467815039 RevertCamera();
1467915040 repaint();
1468015041 break;
14681
- case 'L':
1468215042 case 'l':
15043
+ //case 'L':
1468315044 if (lightMode)
1468415045 {
1468515046 lightMode = false;
....@@ -14822,9 +15183,9 @@
1482215183 case '_':
1482315184 kompactbit = 5;
1482415185 break;
14825
- case '+':
14826
- kompactbit = 6;
14827
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1482815189 case ' ':
1482915190 lightMode ^= true;
1483015191 Globals.lighttouched = true;
....@@ -14836,13 +15197,14 @@
1483615197 case ESC:
1483715198 RENDERPROGRAM += 1;
1483815199 RENDERPROGRAM %= 3;
15200
+
1483915201 repaint();
1484015202 break;
1484115203 case 'Z':
1484215204 //RESIZETEXTURE ^= true;
1484315205 //break;
1484415206 case 'z':
14845
- RENDERSHADOW ^= true;
15207
+ Globals.RENDERSHADOW ^= true;
1484615208 Globals.lighttouched = true;
1484715209 repaint();
1484815210 break;
....@@ -14875,8 +15237,9 @@
1487515237 case DELETE:
1487615238 ClearSelection();
1487715239 break;
14878
- /*
1487915240 case '+':
15241
+
15242
+ /*
1488015243 //fontsize += 1;
1488115244 bbzoom *= 2;
1488215245 repaint();
....@@ -14893,17 +15256,17 @@
1489315256 case '=':
1489415257 IncDepth();
1489515258 //fontsize += 1;
14896
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1489715260 maskbit = 6;
1489815261 break;
1489915262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1490015263 DecDepth();
1490115264 maskbit = 5;
1490215265 //if(fontsize > 1) fontsize -= 1;
14903
- if (object.editWindow == null)
14904
- new Exception().printStackTrace();
14905
- else
14906
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1490715270 break;
1490815271 case '{':
1490915272 manipCamera.shaper_fovy /= 1.1;
....@@ -14966,7 +15329,7 @@
1496615329 //mode = ROTATE;
1496715330 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815331 {
14969
- SetMouseMode(modifiers);
15332
+ SetMouseMode(0, modifiers);
1497015333 }
1497115334 }
1497215335
....@@ -15100,8 +15463,9 @@
1510015463
1510115464 protected void processMouseMotionEvent(MouseEvent e)
1510215465 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15466
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15467
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15468
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515469 {
1510615470 mouseMoved(e);
1510715471 } else
....@@ -15126,11 +15490,12 @@
1512615490 }
1512715491 */
1512815492
15129
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1513015494 }
1513115495
1513215496 void SelectParent()
1513315497 {
15498
+ new Exception().printStackTrace();
1513415499 System.exit(0);
1513515500 Composite group = (Composite) object;
1513615501 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15142,10 +15507,10 @@
1514215507 {
1514315508 //selectees.remove(i);
1514415509 System.out.println("select parent of " + elem);
15145
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1514615511 } else
1514715512 {
15148
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1514915514 }
1515015515
1515115516 first = false;
....@@ -15154,6 +15519,7 @@
1515415519
1515515520 void SelectChildren()
1515615521 {
15522
+ new Exception().printStackTrace();
1515715523 System.exit(0);
1515815524 /*
1515915525 Composite group = (Composite) object;
....@@ -15186,12 +15552,12 @@
1518615552 for (int j = 0; j < group.children.size(); j++)
1518715553 {
1518815554 elem = (Object3D) group.children.elementAt(j);
15189
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519015556 first = false;
1519115557 }
1519215558 } else
1519315559 {
15194
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519515561 }
1519615562
1519715563 first = false;
....@@ -15202,21 +15568,21 @@
1520215568 {
1520315569 //Composite group = (Composite) object;
1520415570 Object3D group = object;
15205
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1520615572 }
1520715573
1520815574 void ResetTransform(int mask)
1520915575 {
1521015576 //Composite group = (Composite) object;
1521115577 Object3D group = object;
15212
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1521315579 }
1521415580
1521515581 void FlipTransform()
1521615582 {
1521715583 //Composite group = (Composite) object;
1521815584 Object3D group = object;
15219
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1522015586 // group.editWindow.ReduceMesh(true);
1522115587 }
1522215588
....@@ -15224,7 +15590,7 @@
1522415590 {
1522515591 //Composite group = (Composite) object;
1522615592 Object3D group = object;
15227
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1522815594 // group.editWindow.ReduceMesh(true);
1522915595 }
1523015596
....@@ -15232,7 +15598,7 @@
1523215598 {
1523315599 //Composite group = (Composite) object;
1523415600 Object3D group = object;
15235
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1523615602 }
1523715603
1523815604 void IncDepth()
....@@ -15318,7 +15684,9 @@
1531815684 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915685 //Image img = CreateImage(width, height);
1532015686 //System.out.println("width = " + width + "; height = " + height + "\n");
15687
+
1532115688 Graphics gr = g; // img.getGraphics();
15689
+
1532215690 if (!hasMarquee)
1532315691 {
1532415692 if (Xmin < Xmax) // !locked)
....@@ -15406,6 +15774,7 @@
1540615774 info.bounds.y += (height - desired) / 2;
1540715775 }
1540815776 }
15777
+
1540915778 info.g = gr;
1541015779 info.camera = renderCamera;
1541115780 /*
....@@ -15415,15 +15784,55 @@
1541515784 */
1541615785 if (!isRenderer)
1541715786 {
15418
- 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
+ }
1541915826 }
1542015827 }
15828
+
1542115829 if (isRenderer)
1542215830 {
1542315831 //gr.setColor(Color.black);
1542415832 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542515833 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542615834 }
15835
+
1542715836 if (hasMarquee)
1542815837 {
1542915838 gr.setXORMode(Color.white);
....@@ -15536,6 +15945,7 @@
1553615945 public boolean mouseDown(Event evt, int x, int y)
1553715946 {
1553815947 System.out.println("mouseDown: " + evt);
15948
+ System.exit(0);
1553915949 /*
1554015950 locked = true;
1554115951 drag = false;
....@@ -15579,7 +15989,7 @@
1557915989 {
1558015990 keyPressed(0, modifiers);
1558115991 }
15582
- clickStart(x, y, modifiers);
15992
+ // clickStart(x, y, modifiers);
1558315993 return true;
1558415994 }
1558515995
....@@ -15697,7 +16107,7 @@
1569716107 {
1569816108 keyReleased(0, 0);
1569916109 }
15700
- drag(x, y, modifiers);
16110
+ drag(x, y, 0, modifiers);
1570116111 return true;
1570216112 }
1570316113
....@@ -15829,7 +16239,7 @@
1582916239 Object3D object;
1583016240 static Object3D trackedobject;
1583116241 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
16242
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583316243 /*static*/ Camera eyeCamera;
1583416244 /*static*/ Camera lightCamera;
1583516245 int cameracount;
....@@ -16114,16 +16524,16 @@
1611416524 cStatic.objectstack[materialdepth++] = checker;
1611516525 //System.out.println("material " + material);
1611616526 //Applet3D.tracein(this, selected);
16117
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1611816528
1611916529 //checker.GetMaterial().Draw(this, false); // true);
16120
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1612116531
1612216532 materialdepth -= 1;
1612316533 if (materialdepth > 0)
1612416534 {
16125
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16126
- 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);
1612716537 }
1612816538 //checker.GetMaterial().opacity = 1f;
1612916539 ////checker.GetMaterial().ambient = 1f;
....@@ -16209,6 +16619,14 @@
1620916619 }
1621016620 }
1621116621
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
+
1621216630 class SelectBuffer implements GLEventListener
1621316631 {
1621416632
....@@ -16267,6 +16685,7 @@
1626716685 {
1626816686 if (!selection)
1626916687 {
16688
+ new Exception().printStackTrace();
1627016689 System.exit(0);
1627116690 return;
1627216691 }
....@@ -16287,6 +16706,17 @@
1628716706
1628816707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1628916708
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
+
1629016720 //int tmp = selection_view;
1629116721 //selection_view = -1;
1629216722 int temp = DrawMode();
....@@ -16298,6 +16728,17 @@
1629816728 // temp = DEFAULT; // patch for selection debug
1629916729 Globals.drawMode = temp; // WARNING
1630016730
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
+
1630116742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1630216743
1630316744 // trying different ways of getting the depth info over
....@@ -16345,6 +16786,8 @@
1634516786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1634616787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1634716788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1634816791
1634916792 // Will fit the mesh !!!
1635016793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16394,34 +16837,36 @@
1639416837 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]));
1639516838 }
1639616839
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16840
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639816841 }
1639916842 }
1640016843
1640116844 if (!movingcamera && !PAINTMODE)
16402
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1640316846
16404
- 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)
1640516848 {
16406
- 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);
1640716850
16408
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1640916854
16410
- group.CreateMaterial(); // use a void leaf to select instances
16411
-
16412
- group.add(paintobj); // link
16413
-
16414
- object.editWindow.SnapObject(group);
16415
-
16416
- Object3D folder = object.editWindow.copy;
16417
-
16418
- if (object.editWindow.copy.selection.Size() > 0)
16419
- folder = object.editWindow.copy.selection.elementAt(0);
16420
-
16421
- folder.add(group);
16422
-
16423
- object.editWindow.ResetModel();
16424
- 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
+ }
1642516870 }
1642616871 else
1642716872 paintcount = 0;
....@@ -16460,6 +16905,11 @@
1646016905 //System.out.println("objects[color] = " + objects[color]);
1646116906 //objects[color].Select();
1646216907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1646316913 object.Select(color, deselect);
1646416914 }
1646516915
....@@ -16559,7 +17009,7 @@
1655917009 gl.glDisable(gl.GL_CULL_FACE);
1656017010 }
1656117011
16562
- if (!RENDERSHADOW)
17012
+ if (!Globals.RENDERSHADOW)
1656317013 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656417014
1656517015 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +17019,7 @@
1656917019 //gl.glColorMask(false, false, false, false);
1657017020
1657117021 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17022
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657317023 {
1657417024 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657517025
....@@ -16985,23 +17435,15 @@
1698517435 int AAbuffersize = 0;
1698617436
1698717437 //double[] selectedpoint = new double[3];
16988
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1698917439 static Sphere previousselectedpoint = null;
16990
- static Sphere debugpointG = new Sphere();
16991
- static Sphere debugpointP = new Sphere();
16992
- static Sphere debugpointC = new Sphere();
16993
- static Sphere debugpointR = new Sphere();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1699417444
1699517445 static Sphere debugpoints[] = new Sphere[8];
1699617446
16997
- static
16998
- {
16999
- for (int i=0; i<8; i++)
17000
- {
17001
- debugpoints[i] = new Sphere();
17002
- }
17003
- }
17004
-
1700517447 static void InitPoints(float radius)
1700617448 {
1700717449 for (int i=0; i<8; i++)