Normand Briere
2019-07-22 c570e1e38f2ff8622a71f81436654bad01cfdd5b
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
....@@ -45,6 +44,39 @@
4544 static boolean ABORTED = false;
4645
4746 static int STEP = 1;
47
+
48
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
49
+ {
50
+ int[] pixels = new int[bytes.length/3];
51
+ for (int i=pixels.length; --i>=0;)
52
+ {
53
+ int i3 = i*3;
54
+ pixels[i] = 0xFF;
55
+ pixels[i] <<= 8;
56
+ pixels[i] |= bytes[i3+2] & 0xFF;
57
+ pixels[i] <<= 8;
58
+ pixels[i] |= bytes[i3+1] & 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3] & 0xFF;
61
+ }
62
+ /*
63
+ int r=0,g=0,b=0,a=0;
64
+ for (int i=0; i<width; i++)
65
+ for (int j=0; j<height; j++)
66
+ {
67
+ int index = j*width+i;
68
+ int p = pixels[index];
69
+ a = ((p>>24) & 0xFF);
70
+ r = ((p>>16) & 0xFF);
71
+ g = ((p>>8) & 0xFF);
72
+ b = (p & 0xFF);
73
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
74
+ }
75
+ /**/
76
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
77
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
78
+ return rendImage;
79
+ }
4880
4981 /*static*/ private boolean CULLFACE = false; // true;
5082 /*static*/ boolean NEAREST = false; // true;
....@@ -56,14 +88,12 @@
5688 static int CURRENTANTIALIAS = 0; // 1;
5789 /*static*/ boolean RENDERSHADOW = true;
5890 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6191
6292 boolean DISPLAYTEXT = false;
6393 //boolean REDUCETEXTURE = true;
6494 boolean CACHETEXTURE = true;
6595 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
96
+ boolean MIPMAP = true; // false; // true;
6797 boolean COMPRESSTEXTURE = false;
6898 boolean KOMPACTTEXTURE = false; // true;
6999 boolean RESIZETEXTURE = false;
....@@ -92,6 +122,8 @@
92122
93123 static int tickcount = 0; // slow pose issue
94124
125
+static boolean BUTTONLESSWHEEL = false;
126
+static boolean ZOOMBOXMODE = false;
95127 static boolean BOXMODE = false;
96128 static boolean IMAGEFLIP = false;
97129 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +138,7 @@
106138 static boolean OEIL = true;
107139 static boolean OEILONCE = false; // do oeilon then oeiloff
108140 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
141
+static boolean SWITCH = true; // false;
110142 static boolean HANDLES = false; // selection doesn't work!!
111143 static boolean PAINTMODE = false;
112144
....@@ -149,6 +181,8 @@
149181 defaultcaps.setAccumBlueBits(16);
150182 defaultcaps.setAccumAlphaBits(16);
151183 }
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152186
153187 void SetAsGLRenderer(boolean b)
154188 {
....@@ -223,6 +257,11 @@
223257 public boolean IsBoxMode()
224258 {
225259 return BOXMODE;
260
+ }
261
+
262
+ public boolean IsZoomBoxMode()
263
+ {
264
+ return ZOOMBOXMODE;
226265 }
227266
228267 public void ClearDepth()
....@@ -320,7 +359,7 @@
320359 cStatic.objectstack[materialdepth++] = obj;
321360 //System.out.println("material " + material);
322361 //Applet3D.tracein(this, selected);
323
- display.vector2buffer = obj.projectedVertices;
362
+ //display.vector2buffer = obj.projectedVertices;
324363 if (obj instanceof Camera)
325364 {
326365 display.options1[0] = material.shift;
....@@ -329,14 +368,28 @@
329368 display.options1[2] = material.shadowbias;
330369 display.options1[3] = material.aniso;
331370 display.options1[4] = material.anisoV;
371
+// System.out.println("display.options1[0] " + display.options1[0]);
372
+// System.out.println("display.options1[1] " + display.options1[1]);
373
+// System.out.println("display.options1[2] " + display.options1[2]);
374
+// System.out.println("display.options1[3] " + display.options1[3]);
375
+// System.out.println("display.options1[4] " + display.options1[4]);
332376 display.options2[0] = material.opacity;
333377 display.options2[1] = material.diffuse;
334378 display.options2[2] = material.factor;
379
+// System.out.println("display.options2[0] " + display.options2[0]);
380
+// System.out.println("display.options2[1] " + display.options2[1]);
381
+// System.out.println("display.options2[2] " + display.options2[2]);
335382
336383 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
384
+// System.out.println("display.options3[0] " + display.options3[0]);
385
+// System.out.println("display.options3[1] " + display.options3[1]);
386
+// System.out.println("display.options3[2] " + display.options3[2]);
337387 display.options4[0] = material.cameralight/0.2f;
338388 display.options4[1] = material.subsurface;
339389 display.options4[2] = material.sheen;
390
+// System.out.println("display.options4[0] " + display.options4[0]);
391
+// System.out.println("display.options4[1] " + display.options4[1]);
392
+// System.out.println("display.options4[2] " + display.options4[2]);
340393
341394 // if (display.CURRENTANTIALIAS > 0)
342395 // display.options3[3] /= 4;
....@@ -352,7 +405,7 @@
352405 /**/
353406 } else
354407 {
355
- DrawMaterial(material, selected);
408
+ DrawMaterial(material, selected, obj.projectedVertices);
356409 }
357410 } else
358411 {
....@@ -376,8 +429,8 @@
376429 cStatic.objectstack[materialdepth++] = obj;
377430 //System.out.println("material " + material);
378431 //Applet3D.tracein("selected ", selected);
379
- display.vector2buffer = obj.projectedVertices;
380
- display.DrawMaterial(material, selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
381434 }
382435 }
383436
....@@ -394,8 +447,8 @@
394447 materialdepth -= 1;
395448 if (materialdepth > 0)
396449 {
397
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
398
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
450
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
451
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
399452 }
400453 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
401454 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -415,8 +468,8 @@
415468 materialdepth -= 1;
416469 if (materialdepth > 0)
417470 {
418
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
419
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
471
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
472
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
420473 }
421474 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
422475 //else
....@@ -457,10 +510,12 @@
457510 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458511 {
459512 //gl.glBegin(gl.GL_TRIANGLES);
460
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
513
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
514
+ // TEST LIVE NORMALS && !obj.dontselect
515
+ ;
461516 if (!hasnorm)
462517 {
463
- // System.out.println("FUCK!!");
518
+ // System.out.println("Mesh normal");
464519 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
465520 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
466521 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1185,10 +1240,12 @@
11851240 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11861241 }
11871242 }
1243
+
11881244 if (flipV)
11891245 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11901246 else
11911247 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
11921249 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11931250 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11941251
....@@ -1208,10 +1265,12 @@
12081265 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12091266 }
12101267 }
1268
+
12111269 if (flipV)
12121270 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12131271 else
12141272 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
12151274 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12161275 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12171276
....@@ -1239,8 +1298,10 @@
12391298 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12401299 else
12411300 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
12421302 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12431303 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
12441305 count2 += 2;
12451306 count3 += 3;
12461307 }
....@@ -1596,7 +1657,7 @@
15961657 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
15971658 }
15981659
1599
- void DrawMaterial(cMaterial material, boolean selected)
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16001661 {
16011662 CameraPane display = this;
16021663 //new Exception().printStackTrace();
....@@ -1612,18 +1673,18 @@
16121673 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131674 if (!material.multiply)
16141675 {
1615
- display.color = color;
1676
+ display.color = material.color;
16161677 display.saturation = material.modulation;
16171678 }
16181679 else
16191680 {
1620
- display.color *= color*2;
1681
+ display.color *= material.color*2;
16211682 display.saturation *= material.modulation*2;
16221683 }
16231684
16241685 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16251686
1626
- float[] colorV = GrafreeD.colorV;
1687
+ float[] colorV = Grafreed.colorV;
16271688
16281689 /**/
16291690 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1631,7 +1692,7 @@
16311692 colorV[0] = display.modelParams0[0] * material.diffuse;
16321693 colorV[1] = display.modelParams0[1] * material.diffuse;
16331694 colorV[2] = display.modelParams0[2] * material.diffuse;
1634
- colorV[3] = material.opacity;
1695
+ colorV[3] = 1; // material.opacity;
16351696
16361697 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16371698 //System.out.println("Opacity = " + opacity);
....@@ -1739,9 +1800,9 @@
17391800 display.modelParams7[2] = 0;
17401801 display.modelParams7[3] = 0;
17411802
1742
- display.modelParams6[0] = 100; // criss de bug de bump
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
17431804
1744
- Object3D.cVector2[] extparams = display.vector2buffer;
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17451806 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17461807 {
17471808 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1883,7 +1944,7 @@
18831944 void PushMatrix(double[][] matrix)
18841945 {
18851946 // GrafreeD.tracein(matrix);
1886
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
18871948 }
18881949
18891950 void PushMatrix()
....@@ -2037,7 +2098,7 @@
20372098 //System.err.println("Oeil on");
20382099 OEIL = true;
20392100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2040
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20412102 //pingthread.StepToTarget(true);
20422103 }
20432104
....@@ -2135,7 +2196,7 @@
21352196 System.err.println("LIVE = " + Globals.isLIVE());
21362197
21372198 if (!Globals.isLIVE()) // save sound
2138
- GrafreeD.savesound = true; // wav.save();
2199
+ Grafreed.savesound = true; // wav.save();
21392200 // else
21402201 repaint(); // start loop // may 2013
21412202 }
....@@ -2168,6 +2229,11 @@
21682229 public void ToggleBoxMode()
21692230 {
21702231 BOXMODE ^= true;
2232
+ }
2233
+
2234
+ public void ToggleZoomBoxMode()
2235
+ {
2236
+ ZOOMBOXMODE ^= true;
21712237 }
21722238
21732239 public void ToggleSmoothFocus()
....@@ -2247,7 +2313,7 @@
22472313
22482314 void ToggleDebug()
22492315 {
2250
- DEBUG ^= true;
2316
+ Globals.DEBUG ^= true;
22512317 }
22522318
22532319 void ToggleLookAt()
....@@ -2255,9 +2321,9 @@
22552321 LOOKAT ^= true;
22562322 }
22572323
2258
- void ToggleRandom()
2324
+ void ToggleSwitch()
22592325 {
2260
- RANDOM ^= true;
2326
+ SWITCH ^= true;
22612327 }
22622328
22632329 void ToggleHandles()
....@@ -2265,10 +2331,17 @@
22652331 HANDLES ^= true;
22662332 }
22672333
2334
+ Object3D paintFolder;
2335
+
22682336 void TogglePaint()
22692337 {
22702338 PAINTMODE ^= true;
22712339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
22722345 }
22732346
22742347 void SwapCamera(int a, int b)
....@@ -2364,7 +2437,22 @@
23642437 {
23652438 return currentGL;
23662439 }
2367
-
2440
+
2441
+ static private BufferedImage CreateBim(TextureData texturedata)
2442
+ {
2443
+ Grafreed.Assert(texturedata != null);
2444
+
2445
+ int width = texturedata.getWidth();
2446
+ int height = texturedata.getHeight();
2447
+
2448
+ Buffer buffer = texturedata.getBuffer();
2449
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2450
+
2451
+ byte[] bytes = bytebuf.array();
2452
+
2453
+ return CreateBim(bytes, width, height);
2454
+ }
2455
+
23682456 /**/
23692457 class CacheTexture
23702458 {
....@@ -2373,28 +2461,31 @@
23732461
23742462 int resolution;
23752463
2376
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23772465 {
2378
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
23792468 resolution = res;
23802469 }
23812470 }
23822471 /**/
23832472
23842473 // 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>();
2474
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2475
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2476
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2477
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2478
+
23882479 int pigmentdepth = 0;
23892480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
23902481 int bumpdepth = 0;
23912482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
23922483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
23932484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2394
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
23952486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
23962487
2397
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
23982489 {
23992490 TextureData texturedata = null;
24002491
....@@ -2413,13 +2504,34 @@
24132504 if (bump)
24142505 texturedata = ConvertBump(texturedata, false);
24152506
2416
- com.sun.opengl.util.texture.Texture texture =
2417
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2507
+// com.sun.opengl.util.texture.Texture texture =
2508
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24182509
2419
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2420
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2510
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2511
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24212512
2422
- return texture;
2513
+ return texturedata;
2514
+ }
2515
+
2516
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2517
+ {
2518
+ TextureData texturedata = null;
2519
+
2520
+ try
2521
+ {
2522
+ texturedata =
2523
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2524
+ bim,
2525
+ true);
2526
+ } catch (Exception e)
2527
+ {
2528
+ throw new javax.media.opengl.GLException(e);
2529
+ }
2530
+
2531
+ if (bump)
2532
+ texturedata = ConvertBump(texturedata, false);
2533
+
2534
+ return texturedata;
24232535 }
24242536
24252537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3492,6 +3604,8 @@
34923604
34933605 System.out.println("LOADING TEXTURE : " + name);
34943606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
34953609 //
34963610 if (false) // compressbit > 0)
34973611 {
....@@ -4196,6 +4310,7 @@
41964310
41974311 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
41984312 {
4313
+ new Exception().printStackTrace();
41994314 System.exit(0);
42004315 com.sun.opengl.util.texture.Texture texture = null;
42014316
....@@ -7889,7 +8004,7 @@
78898004 String pigment = Object3D.GetPigment(tex);
78908005 String bump = Object3D.GetBump(tex);
78918006
7892
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
78938008 {
78948009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
78958010 // System.out.println("; bump = " + bump);
....@@ -7904,11 +8019,69 @@
79048019 pigment = null;
79058020 }
79068021
7907
- ReleaseTexture(bump, true);
7908
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79098024 }
79108025
7911
- void ReleaseTexture(String tex, boolean bump)
8026
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8027
+ {
8028
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8029
+ {
8030
+ return;
8031
+ }
8032
+
8033
+ if (tex == null)
8034
+ {
8035
+ ReleaseTexture(null, false);
8036
+ return;
8037
+ }
8038
+
8039
+ String pigment = Object3D.GetPigment(tex);
8040
+
8041
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ {
8043
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8044
+ // System.out.println("; bump = " + bump);
8045
+ }
8046
+
8047
+ if (pigment.equals(""))
8048
+ {
8049
+ pigment = null;
8050
+ }
8051
+
8052
+ ReleaseTexture(tex, false);
8053
+ }
8054
+
8055
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8056
+ {
8057
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8058
+ {
8059
+ return;
8060
+ }
8061
+
8062
+ if (tex == null)
8063
+ {
8064
+ ReleaseTexture(null, true);
8065
+ return;
8066
+ }
8067
+
8068
+ String bump = Object3D.GetBump(tex);
8069
+
8070
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8071
+ {
8072
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8073
+ // System.out.println("; bump = " + bump);
8074
+ }
8075
+
8076
+ if (bump.equals(""))
8077
+ {
8078
+ bump = null;
8079
+ }
8080
+
8081
+ ReleaseTexture(tex, true);
8082
+ }
8083
+
8084
+ void ReleaseTexture(cTexture tex, boolean bump)
79128085 {
79138086 if (// DrawMode() != 0 || /*tex == null ||*/
79148087 ambientOcclusion ) // || !textureon)
....@@ -7919,7 +8092,7 @@
79198092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79208093
79218094 if (tex != null)
7922
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79238096
79248097 // //assert( texture != null );
79258098 // if (texture == null)
....@@ -8011,7 +8184,55 @@
80118184 }
80128185 }
80138186
8014
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8187
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8188
+ {
8189
+// if (// DrawMode() != 0 || /*tex == null ||*/
8190
+// ambientOcclusion ) // || !textureon)
8191
+// {
8192
+// return; // false;
8193
+// }
8194
+//
8195
+// if (tex == null)
8196
+// {
8197
+// BindTexture(null,false,resolution);
8198
+// BindTexture(null,true,resolution);
8199
+// return;
8200
+// }
8201
+//
8202
+// String pigment = Object3D.GetPigment(tex);
8203
+// String bump = Object3D.GetBump(tex);
8204
+//
8205
+// usedtextures.add(pigment);
8206
+// usedtextures.add(bump);
8207
+//
8208
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8209
+// {
8210
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8211
+// // System.out.println("; bump = " + bump);
8212
+// }
8213
+//
8214
+// if (bump.equals(""))
8215
+// {
8216
+// bump = null;
8217
+// }
8218
+// if (pigment.equals(""))
8219
+// {
8220
+// pigment = null;
8221
+// }
8222
+//
8223
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8224
+// BindTexture(pigment, false, resolution);
8225
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8226
+// BindTexture(bump, true, resolution);
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+//
8229
+// return; // true;
8230
+
8231
+ BindPigmentTexture(tex, resolution);
8232
+ BindBumpTexture(tex, resolution);
8233
+ }
8234
+
8235
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80158236 {
80168237 if (// DrawMode() != 0 || /*tex == null ||*/
80178238 ambientOcclusion ) // || !textureon)
....@@ -8022,17 +8243,47 @@
80228243 if (tex == null)
80238244 {
80248245 BindTexture(null,false,resolution);
8025
- BindTexture(null,true,resolution);
80268246 return;
80278247 }
80288248
80298249 String pigment = Object3D.GetPigment(tex);
8250
+
8251
+ usedtextures.add(tex);
8252
+
8253
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8254
+ {
8255
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8256
+ // System.out.println("; bump = " + bump);
8257
+ }
8258
+
8259
+ if (pigment.equals(""))
8260
+ {
8261
+ pigment = null;
8262
+ }
8263
+
8264
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
+ BindTexture(tex, false, resolution);
8266
+ }
8267
+
8268
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8269
+ {
8270
+ if (// DrawMode() != 0 || /*tex == null ||*/
8271
+ ambientOcclusion ) // || !textureon)
8272
+ {
8273
+ return; // false;
8274
+ }
8275
+
8276
+ if (tex == null)
8277
+ {
8278
+ BindTexture(null,true,resolution);
8279
+ return;
8280
+ }
8281
+
80308282 String bump = Object3D.GetBump(tex);
80318283
8032
- usedtextures.put(pigment, pigment);
8033
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
80348285
8035
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80368287 {
80378288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80388289 // System.out.println("; bump = " + bump);
....@@ -8042,43 +8293,82 @@
80428293 {
80438294 bump = null;
80448295 }
8045
- if (pigment.equals(""))
8046
- {
8047
- pigment = null;
8048
- }
80498296
8050
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8051
- BindTexture(pigment, false, resolution);
80528297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8053
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
80548299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8055
-
8056
- return; // true;
80578300 }
80588301
8059
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8302
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8303
+
8304
+ private boolean FileExists(String tex)
80608305 {
8061
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8306
+ if (missingTextures.contains(tex))
8307
+ {
8308
+ return false;
8309
+ }
8310
+
8311
+ boolean fileExists = new File(tex).exists();
8312
+
8313
+ if (!fileExists)
8314
+ {
8315
+ // If file exists, the "new File()" is not executed sgain
8316
+ missingTextures.add(tex);
8317
+ }
8318
+
8319
+ return fileExists;
8320
+ }
8321
+
8322
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8323
+ {
8324
+ CacheTexture texturecache = null;
80628325
80638326 if (tex != null)
80648327 {
8065
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80668330
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;
8331
+ if (texname.equals("") && texdata == null)
8332
+ {
8333
+ return null;
8334
+ }
8335
+
8336
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8337
+
8338
+// String[] split = tex.split("Textures");
8339
+// if (split.length > 1)
8340
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8341
+// else
8342
+// if (!texname.startsWith("/"))
8343
+// texname = "/Users/nbriere/Textures/" + texname;
8344
+ if (!FileExists(texname))
8345
+ {
8346
+ texname = fallbackTextureName;
8347
+ }
80738348
80748349 if (CACHETEXTURE)
8075
- texture = textures.get(texname); // TEXTURE CACHE
8076
-
8077
- TextureData texturedata = null;
8078
-
8079
- if (texture == null || texture.resolution < resolution)
80808350 {
8081
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8351
+ if (texdata == null)
8352
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8353
+ else
8354
+ texturecache = bimtextures.get(texdata);
8355
+ }
8356
+
8357
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8358
+ {
8359
+ TextureData texturedata = null;
8360
+
8361
+ if (texdata != null)
8362
+ {
8363
+ BufferedImage bim = //new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8364
+
8365
+ CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8366
+
8367
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8368
+ bimtextures.put(texdata, texturecache);
8369
+ }
8370
+ else
8371
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80828372 {
80838373 assert(!bump);
80848374 // if (bump)
....@@ -8089,19 +8379,23 @@
80898379 // }
80908380 // else
80918381 // {
8092
- texture = textures.get(tex);
8093
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
80948384 {
8095
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
80968386 }
8387
+ else
8388
+ new Exception().printStackTrace();
80978389 // }
80988390 } else
8099
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81008392 {
81018393 assert(bump);
8102
- texture = textures.get(tex);
8103
- if (texture == null)
8104
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8394
+ // texturecache = textures.get(texname); // suspicious
8395
+ if (texturecache == null)
8396
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8397
+ else
8398
+ new Exception().printStackTrace();
81058399 } else
81068400 {
81078401 //if (tex.equals("IMMORTAL"))
....@@ -8109,11 +8403,13 @@
81098403 // texture = GetResourceTexture("default.png");
81108404 //} else
81118405 //{
8112
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
81138407 {
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8408
+ // texturecache = textures.get(texname); // suspicious
8409
+ if (texturecache == null)
8410
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8411
+ else
8412
+ new Exception().printStackTrace();
81178413 } else
81188414 {
81198415 if (textureon)
....@@ -8138,7 +8434,7 @@
81388434 }
81398435
81408436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
81428438 cachename = texname;
81438439 else
81448440 processbump = false; // don't process bump map again
....@@ -8160,7 +8456,7 @@
81608456 }
81618457
81628458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
81648460 cachename = texname;
81658461 else
81668462 processbump = false; // don't process bump map again
....@@ -8169,20 +8465,22 @@
81698465 texturedata = GetFileTexture(cachename, processbump, resolution);
81708466
81718467
8172
- if (texturedata != null)
8173
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8468
+ if (texturedata == null)
8469
+ throw new Exception();
8470
+
8471
+ texturecache = new CacheTexture(texturedata,resolution);
81748472 //texture = GetTexture(tex, bump);
81758473 }
81768474 }
81778475 //}
81788476 }
81798477
8180
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81818479 {
81828480 //return false;
81838481
81848482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8185
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81868484 {
81878485 // String ext = "_highres";
81888486 // if (REDUCETEXTURE)
....@@ -8199,52 +8497,17 @@
81998497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82008498 if (!cachefile.exists())
82018499 {
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))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
82118501 {
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);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
82428504 ImageWriter writer = null;
82438505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82448506 if (iter.hasNext()) {
82458507 writer = (ImageWriter)iter.next();
82468508 }
8247
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
82488511 try
82498512 {
82508513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8261,18 +8524,20 @@
82618524 }
82628525 }
82638526 }
8264
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
82658530 //System.out.println("Texture = " + tex);
8266
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
82678532 {
8268
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
82698534 thetex.texture.disable();
82708535 thetex.texture.dispose();
8271
- textures.remove(texname);
8536
+ textures.remove(tex);
82728537 }
82738538
8274
- texture.texturedata = texturedata;
8275
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
82768541
82778542 // newtex = true;
82788543 }
....@@ -8288,10 +8553,41 @@
82888553 }
82898554 }
82908555
8291
- return texture;
8556
+ return texturecache;
82928557 }
82938558
8294
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8559
+ static void EmbedTextures(cTexture tex)
8560
+ {
8561
+ if (tex.pigmentdata == null)
8562
+ {
8563
+ String texname = Object3D.GetPigment(tex);
8564
+
8565
+ CacheTexture texturecache = texturepigment.get(tex);
8566
+
8567
+ if (texturecache != null)
8568
+ {
8569
+ tex.pigmentdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8570
+ tex.pw = texturecache.texturedata.getWidth();
8571
+ tex.ph = texturecache.texturedata.getHeight();
8572
+ }
8573
+ }
8574
+
8575
+ if (tex.bumpdata == null)
8576
+ {
8577
+ String texname = Object3D.GetBump(tex);
8578
+
8579
+ CacheTexture texturecache = texturebump.get(tex);
8580
+
8581
+ if (texturecache != null)
8582
+ {
8583
+ tex.bumpdata = ((ByteBuffer)texturecache.texturedata.getBuffer()).array();
8584
+ tex.bw = texturecache.texturedata.getWidth();
8585
+ tex.bh = texturecache.texturedata.getHeight();
8586
+ }
8587
+ }
8588
+ }
8589
+
8590
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
82958591 {
82968592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
82978593
....@@ -8309,21 +8605,21 @@
83098605 return texture!=null?texture.texture:null;
83108606 }
83118607
8312
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8608
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
83138609 {
83148610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83158611
83168612 return texture!=null?texture.texturedata:null;
83178613 }
83188614
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83208616 {
83218617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228618 {
83238619 return false;
83248620 }
83258621
8326
- boolean newtex = false;
8622
+ //boolean newtex = false;
83278623
83288624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83298625
....@@ -8355,7 +8651,7 @@
83558651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83568652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83578653
8358
- return newtex;
8654
+ return true; // Warning: not used.
83598655 }
83608656
83618657 ShadowBuffer shadowPBuf;
....@@ -9193,11 +9489,35 @@
91939489 jy8[3] = 0.5f;
91949490 }
91959491
9196
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9492
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
91979493 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
91989494 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
91999495 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92009496
9497
+ void ResetOptions()
9498
+ {
9499
+ options1[0] = 100;
9500
+ options1[1] = 0.025f;
9501
+ options1[2] = 0.01f;
9502
+ options1[3] = 0;
9503
+ options1[4] = 0;
9504
+
9505
+ options2[0] = 0;
9506
+ options2[1] = 0.75f;
9507
+ options2[2] = 0;
9508
+ options2[3] = 0;
9509
+
9510
+ options3[0] = 1;
9511
+ options3[1] = 1;
9512
+ options3[2] = 1;
9513
+ options3[3] = 0;
9514
+
9515
+ options4[0] = 1;
9516
+ options4[1] = 0;
9517
+ options4[2] = 1;
9518
+ options4[3] = 0;
9519
+ }
9520
+
92019521 static int imagecount = 0; // movie generation
92029522
92039523 static int jitter = 0;
....@@ -9293,8 +9613,8 @@
92939613 assert (parentcam != renderCamera);
92949614
92959615 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
92989618
92999619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009620
....@@ -9309,8 +9629,8 @@
93099629 LA.matCopy(renderCamera.fromScreen, matrix);
93109630
93119631 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93149634
93159635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169636
....@@ -9382,7 +9702,7 @@
93829702 //gl.glFlush();
93839703 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849704
9385
- if (ANIMATION && ABORTED)
9705
+ if (Globals.ANIMATION && ABORTED)
93869706 {
93879707 System.err.println(" ABORTED FRAME");
93889708 break;
....@@ -9412,7 +9732,7 @@
94129732 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139733
94149734 // save image
9415
- if (ANIMATION && !ABORTED)
9735
+ if (Globals.ANIMATION && !ABORTED)
94169736 {
94179737 VPwidth = viewport[2];
94189738 VPheight = viewport[3];
....@@ -9523,11 +9843,11 @@
95239843
95249844 // imagecount++;
95259845
9526
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9846
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95279847
95289848 if (!BOXMODE)
95299849 {
9530
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9850
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95319851 }
95329852
95339853 if (!BOXMODE)
....@@ -9565,7 +9885,7 @@
95659885 ABORTED = false;
95669886 }
95679887 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9888
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699889
95709890 if (false)
95719891 {
....@@ -10228,11 +10548,11 @@
1022810548
1022910549 public void display(GLAutoDrawable drawable)
1023010550 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10551
+ if (Grafreed.savesound && Grafreed.hassound)
1023210552 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10553
+ Grafreed.wav.save();
10554
+ Grafreed.savesound = false;
10555
+ Grafreed.hassound = false;
1023610556 }
1023710557 // if (DEBUG_SELECTION)
1023810558 // {
....@@ -10308,6 +10628,7 @@
1030810628 ANTIALIAS = 0;
1030910629 //System.out.println("RESTART");
1031010630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
1031110632 }
1031210633 }
1031310634 }
....@@ -10362,7 +10683,7 @@
1036210683 Object3D theobject = object;
1036310684 Object3D theparent = object.parent;
1036410685 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10686
+ object = (Object3D)Grafreed.clone(object);
1036610687 object.Stripify();
1036710688 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810689 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10696,14 @@
1037510696 ambientOcclusion = false;
1037610697 }
1037710698
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910701 {
1038010702 //if (RENDERSHADOW) // ?
1038110703 if (!IsFrozen())
1038210704 {
1038310705 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510707 {
1038610708 Globals.framecount++;
1038710709 shadowbuffer.display();
....@@ -10508,8 +10830,8 @@
1050810830
1050910831 // if (parentcam != renderCamera) // not a light
1051010832 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1051310835
1051410836 for (int j = 0; j < 4; j++)
1051510837 {
....@@ -10523,8 +10845,8 @@
1052310845
1052410846 // if (parentcam != renderCamera) // not a light
1052510847 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1052810850
1052910851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010852
....@@ -10783,7 +11105,16 @@
1078311105 // Bump noise
1078411106 gl.glActiveTexture(GL.GL_TEXTURE6);
1078511107 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- BindTexture(NOISE_TEXTURE, false, 2);
11108
+
11109
+ try
11110
+ {
11111
+ BindTexture(NOISE_TEXTURE, false, 2);
11112
+ }
11113
+ catch (Exception e)
11114
+ {
11115
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11116
+ }
11117
+
1078711118
1078811119 gl.glActiveTexture(GL.GL_TEXTURE0);
1078911120 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10806,9 +11137,9 @@
1080611137
1080711138 gl.glMatrixMode(GL.GL_MODELVIEW);
1080811139
10809
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10810
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10811
-//gl.glEnable(gl.GL_MULTISAMPLE);
11140
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11141
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11142
+gl.glEnable(gl.GL_MULTISAMPLE);
1081211143 } else
1081311144 {
1081411145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10819,7 +11150,7 @@
1081911150 //System.out.println("BLENDING ON");
1082011151 gl.glEnable(GL.GL_BLEND);
1082111152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10822
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1082311154 gl.glMatrixMode(gl.GL_PROJECTION);
1082411155 gl.glLoadIdentity();
1082511156
....@@ -10908,8 +11239,8 @@
1090811239 System.err.println("parentcam != renderCamera");
1090911240
1091011241 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11242
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11243
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1091311244 }
1091411245
1091511246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +11261,8 @@
1093011261 if (true) // TODO
1093111262 {
1093211263 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11264
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11265
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1093511266 }
1093611267
1093711268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11247,8 +11578,14 @@
1124711578 {
1124811579 renderpass++;
1124911580 // System.out.println("Draw object... ");
11581
+ STEP = 1;
1125011582 if (FAST) // in case there is no script
11251
- STEP = 16;
11583
+ STEP = 8;
11584
+
11585
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11586
+ {
11587
+ STEP *= 4;
11588
+ }
1125211589
1125311590 //object.FullInvariants();
1125411591
....@@ -11262,23 +11599,44 @@
1126211599 e.printStackTrace();
1126311600 }
1126411601
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11602
+ if (Grafreed.RENDERME > 0)
11603
+ Grafreed.RENDERME--; // mechante magouille
1126711604
1126811605 Globals.ONESTEP = false;
1126911606 }
1127011607
1127111608 static boolean zoomonce = false;
1127211609
11610
+ static void CreateSelectedPoint()
11611
+ {
11612
+ if (selectedpoint == null)
11613
+ {
11614
+ debugpointG = new Sphere();
11615
+ debugpointP = new Sphere();
11616
+ debugpointC = new Sphere();
11617
+ debugpointR = new Sphere();
11618
+
11619
+ selectedpoint = new Superellipsoid();
11620
+
11621
+ for (int i=0; i<8; i++)
11622
+ {
11623
+ debugpoints[i] = new Sphere();
11624
+ }
11625
+ }
11626
+ }
11627
+
1127311628 void DrawObject(GL gl, boolean draw)
1127411629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
1127511633 //System.out.println("DRAW OBJECT " + mouseDown);
1127611634 // DrawMode() = SELECTION;
1127711635 //GL gl = getGL();
1127811636 if ((TRACK || SHADOWTRACK) || zoomonce)
1127911637 {
1128011638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11281
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1128211640 pingthread.StepToTarget(true); // true);
1128311641 // zoomonce = false;
1128411642 }
....@@ -11333,7 +11691,14 @@
1133311691
1133411692 usedtextures.clear();
1133511693
11336
- BindTextures(DEFAULT_TEXTURES, 2);
11694
+ try
11695
+ {
11696
+ BindTextures(DEFAULT_TEXTURES, 2);
11697
+ }
11698
+ catch (Exception e)
11699
+ {
11700
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11701
+ }
1133711702 }
1133811703 //System.out.println("--> " + stackdepth);
1133911704 // GrafreeD.traceon();
....@@ -11343,8 +11708,9 @@
1134311708
1134411709 if (DrawMode() == DEFAULT)
1134511710 {
11346
- if (DEBUG)
11711
+ if (Globals.DEBUG)
1134711712 {
11713
+ CreateSelectedPoint();
1134811714 float radius = 0.05f;
1134911715 if (selectedpoint.radius != radius)
1135011716 {
....@@ -11398,20 +11764,32 @@
1139811764 ReleaseTextures(DEFAULT_TEXTURES);
1139911765
1140011766 if (CLEANCACHE)
11401
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1140211768 {
11403
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1140411770
1140511771 // System.out.println("Texture --------- " + tex);
1140611772
11407
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1140811774 continue;
1140911775
11410
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1141111777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1141211779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11413
- textures.get(tex).texture.dispose();
11414
- textures.remove(tex);
11780
+ if (gettex != null)
11781
+ {
11782
+ gettex.texture.dispose();
11783
+ texturepigment.remove(tex);
11784
+ }
11785
+
11786
+ gettex = texturebump.get(tex);
11787
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11788
+ if (gettex != null)
11789
+ {
11790
+ gettex.texture.dispose();
11791
+ texturebump.remove(tex);
11792
+ }
1141511793 }
1141611794 }
1141711795 }
....@@ -11424,7 +11802,14 @@
1142411802 if (checker != null && DrawMode() == DEFAULT)
1142511803 {
1142611804 //BindTexture(IMMORTAL_TEXTURE);
11427
- BindTextures(checker.GetTextures(), checker.texres);
11805
+ try
11806
+ {
11807
+ BindTextures(checker.GetTextures(), checker.texres);
11808
+ }
11809
+ catch (Exception e)
11810
+ {
11811
+ System.err.println("FAILED: " + checker.GetTextures());
11812
+ }
1142811813 // NEAREST
1142911814 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011815 DrawChecker(gl);
....@@ -11506,7 +11891,7 @@
1150611891 return;
1150711892 }
1150811893
11509
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
1151011895
1151111896 GL gl = GetGL();
1151211897
....@@ -11823,8 +12208,8 @@
1182312208 //obj.TransformToWorld(light, light);
1182412209 for (int i = tp.size(); --i >= 0;)
1182512210 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- LA.xformPos(light, tp.get(i).toParent, light);
12211
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12212
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1182812213 }
1182912214
1183012215
....@@ -11841,8 +12226,8 @@
1184112226 parentcam = cameras[0];
1184212227 }
1184312228
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12229
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12230
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1184612231
1184712232 LA.xformPos(light, renderCamera.toScreen, light);
1184812233
....@@ -12456,8 +12841,8 @@
1245612841
1245712842 // display shadow only (bump == 0)
1245812843 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12844
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12845
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112846 "SUB temp.y, one.x, temp.z;" +
1246212847 "MUL temp.x, temp.x, temp.y;" +
1246312848 "KIL temp.x;" +
....@@ -12586,8 +12971,10 @@
1258612971 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258712972
1258812973 "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
12974
+ // Tuning for default skin
12975
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
12976
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
12977
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1259112978 "MUL temp.x, temp.x, temp.y;" +
1259212979
1259312980 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +13173,7 @@
1278613173 //once = true;
1278713174 }
1278813175
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
13176
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279013177 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279113178 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279213179
....@@ -12919,12 +13306,16 @@
1291913306
1292013307 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292113308 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13309
+
13310
+ // Compare fragment depth in light space with shadowmap.
1292213311 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292313312 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
13313
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13314
+
13315
+ // Reverse comparison
1292513316 "SUB temp.x, one.x, temp.x;" +
1292613317 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13318
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813319 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913320
1293013321 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13329,10 @@
1293813329 // No shadow for backface
1293913330 "DP3 temp.x, normal, lightd;" +
1294013331 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13332
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13333
+
13334
+ // No shadow when out of frustrum
13335
+ "SGE temp.x, " + depth + ".z, one.z;" +
1294113336 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213337 "";
1294313338 }
....@@ -13084,7 +13479,8 @@
1308413479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1308513480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1308613481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13087
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1308813484
1308913485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1309013486 // OUT : diff, spec
....@@ -13100,9 +13496,10 @@
1310013496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1310113497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1310213498 //"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;" +
13499
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13500
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13501
+
13502
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1310613503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1310713504 "RCP " + dest + ".w," + dest + ".w;" +
1310813505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13496,7 +13893,7 @@
1349613893 public void mousePressed(MouseEvent e)
1349713894 {
1349813895 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13896
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350013897 }
1350113898
1350213899 static long prevtime = 0;
....@@ -13523,6 +13920,7 @@
1352313920
1352413921 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352513922
13923
+ if (BUTTONLESSWHEEL)
1352613924 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352713925 {
1352813926 return;
....@@ -13531,7 +13929,7 @@
1353113929 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353213930
1353313931 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
13932
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353513933 {
1353613934 keepboxmode = BOXMODE;
1353713935 keepsupport = SUPPORT;
....@@ -13571,8 +13969,8 @@
1357113969 // mode |= META;
1357213970 //}
1357313971
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13972
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13973
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357613974 anchorX = ax;
1357713975 anchorY = ay;
1357813976 prevX = px;
....@@ -13606,6 +14004,7 @@
1360614004 else
1360714005 if (evt.getSource() == AAtimer)
1360814006 {
14007
+ Globals.TIMERRUNNING = false;
1360914008 if (mouseDown)
1361014009 {
1361114010 //new Exception().printStackTrace();
....@@ -13631,6 +14030,10 @@
1363114030 // LIVE = waslive;
1363214031 // wasliveok = true;
1363314032 // waslive = false;
14033
+
14034
+ // May 2019 Forget it:
14035
+ if (true)
14036
+ return;
1363414037
1363514038 // source == timer
1363614039 if (mouseDown)
....@@ -13661,7 +14064,7 @@
1366114064
1366214065 // fev 2014???
1366314066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13664
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1366514068 pingthread.StepToTarget(true); // true);
1366614069 }
1366714070 // if (!LIVE)
....@@ -13670,12 +14073,13 @@
1367014073
1367114074 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367214075
13673
- void clickStart(int x, int y, int modifiers)
14076
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367414077 {
1367514078 if (!wasliveok)
1367614079 return;
1367714080
1367814081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1367914083
1368014084 // waslive = LIVE;
1368114085 // LIVE = false;
....@@ -13687,7 +14091,7 @@
1368714091 // touched = true; // main DL
1368814092 if (isRenderer)
1368914093 {
13690
- SetMouseMode(modifiers);
14094
+ SetMouseMode(modifiers, modifiersex);
1369114095 }
1369214096
1369314097 selectX = anchorX = x;
....@@ -13700,7 +14104,7 @@
1370014104 clicked = true;
1370114105 hold = false;
1370214106
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14107
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370414108 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370514109 {
1370614110 // System.out.println("RESTART II " + modifiers);
....@@ -13731,7 +14135,7 @@
1373114135 info.camera = renderCamera;
1373214136 info.x = x;
1373314137 info.y = y;
13734
- info.modifiers = modifiers;
14138
+ info.modifiers = modifiersex;
1373514139 editObj = object.doEditClick(info, 0);
1373614140 if (!editObj)
1373714141 {
....@@ -13748,11 +14152,14 @@
1374814152
1374914153 public void mouseDragged(MouseEvent e)
1375014154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
14157
+ //System.out.println("mouseDragged: " + e);
1375114158 if (isRenderer)
1375214159 movingcamera = true;
14160
+
1375314161 //if (drawing)
1375414162 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375614163 if ((e.getModifiersEx() & CTRL) != 0
1375714164 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375814165 {
....@@ -13760,7 +14167,7 @@
1376014167 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376114168 }
1376214169 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
14170
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376414171
1376514172 //try { Thread.sleep(1); } catch (Exception ex) {}
1376614173 }
....@@ -13933,6 +14340,7 @@
1393314340
1393414341 public void run()
1393514342 {
14343
+ new Exception().printStackTrace();
1393614344 System.exit(0);
1393714345 for (;;)
1393814346 {
....@@ -13996,7 +14404,7 @@
1399614404 {
1399714405 Globals.lighttouched = true;
1399814406 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14407
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014408 }
1400114409 //else
1400214410 }
....@@ -14010,12 +14418,12 @@
1401014418 void GoDown(int mod)
1401114419 {
1401214420 MODIFIERS |= COMMAND;
14013
- /*
14421
+ /**/
1401414422 if((mod&SHIFT) == SHIFT)
1401514423 manipCamera.RotatePosition(0, -speed);
1401614424 else
14017
- manipCamera.BackForth(0, -speed*delta, getWidth());
14018
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1401914427 if ((mod & SHIFT) == SHIFT)
1402014428 {
1402114429 mouseMode = mouseMode; // VR??
....@@ -14031,12 +14439,12 @@
1403114439 void GoUp(int mod)
1403214440 {
1403314441 MODIFIERS |= COMMAND;
14034
- /*
14442
+ /**/
1403514443 if((mod&SHIFT) == SHIFT)
1403614444 manipCamera.RotatePosition(0, speed);
1403714445 else
14038
- manipCamera.BackForth(0, speed*delta, getWidth());
14039
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1404014448 if ((mod & SHIFT) == SHIFT)
1404114449 {
1404214450 mouseMode = mouseMode;
....@@ -14052,12 +14460,12 @@
1405214460 void GoLeft(int mod)
1405314461 {
1405414462 MODIFIERS |= COMMAND;
14055
- /*
14463
+ /**/
1405614464 if((mod&SHIFT) == SHIFT)
14057
- manipCamera.RotatePosition(speed, 0);
14058
- else
1405914465 manipCamera.Translate(speed*delta, 0, getWidth());
14060
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1406114469 if ((mod & SHIFT) == SHIFT)
1406214470 {
1406314471 mouseMode = mouseMode;
....@@ -14073,12 +14481,12 @@
1407314481 void GoRight(int mod)
1407414482 {
1407514483 MODIFIERS |= COMMAND;
14076
- /*
14484
+ /**/
1407714485 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(-speed, 0);
14079
- else
1408014486 manipCamera.Translate(-speed*delta, 0, getWidth());
14081
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1408214490 if ((mod & SHIFT) == SHIFT)
1408314491 {
1408414492 mouseMode = mouseMode;
....@@ -14096,7 +14504,7 @@
1409614504 int X, Y;
1409714505 boolean SX, SY;
1409814506
14099
- void drag(int x, int y, int modifiers)
14507
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014508 {
1410114509 if (IsFrozen())
1410214510 {
....@@ -14105,17 +14513,17 @@
1410514513
1410614514 drag = true; // NEW
1410714515
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14516
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914517
1411014518 X = x;
1411114519 Y = y;
1411214520 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14521
+ MODIFIERS = modifiersex;
14522
+ modifiersex &= ~1024;
1411514523 if (false) // modifiers != 0)
1411614524 {
1411714525 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14526
+ System.out.println("mouseDragged: " + modifiersex);
1411914527 System.out.println("SHIFT = " + SHIFT);
1412014528 System.out.println("CONTROL = " + COMMAND);
1412114529 System.out.println("META = " + META);
....@@ -14135,7 +14543,8 @@
1413514543 info.camera = renderCamera;
1413614544 info.x = x;
1413714545 info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914548 } else
1414014549 {
1414114550 if (x < startX)
....@@ -14287,7 +14696,6 @@
1428714696 public void mouseMoved(MouseEvent e)
1428814697 {
1428914698 //System.out.println("mouseMoved: " + e);
14290
-
1429114699 if (isRenderer)
1429214700 return;
1429314701
....@@ -14300,7 +14708,9 @@
1430014708 ci.camera = renderCamera;
1430114709 if (!isRenderer)
1430214710 {
14303
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1430414714 {
1430514715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1430614716 } else
....@@ -14312,7 +14722,11 @@
1431214722
1431314723 public void mouseReleased(MouseEvent e)
1431414724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1431514727 movingcamera = false;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1431614730 //System.out.println("mouseReleased: " + e);
1431714731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814732 }
....@@ -14335,9 +14749,9 @@
1433514749 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614750 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714751
14338
- if (control || command || IsFrozen())
14752
+// No delay if (control || command || IsFrozen())
1433914753 timeout = true;
14340
- else
14754
+// ?? May 2019 else
1434114755 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214756 mouseDown = false;
1434314757 if (!control && !command) // june 2013
....@@ -14447,7 +14861,7 @@
1444714861 System.out.println("keyReleased: " + e);
1444814862 }
1444914863
14450
- void SetMouseMode(int modifiers)
14864
+ void SetMouseMode(int modifiers, int modifiersex)
1445114865 {
1445214866 //System.out.println("SetMouseMode = " + modifiers);
1445314867 //modifiers &= ~1024;
....@@ -14459,25 +14873,25 @@
1445914873 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446014874 // return;
1446114875 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
14876
+ if ((modifiersex & WHEEL) == WHEEL)
1446314877 {
1446414878 mouseMode |= ZOOM;
1446514879 }
1446614880
1446714881 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
14882
+ if (capsLocked) // || (modifiers & META) == META)
1446914883 {
1447014884 mouseMode |= VR; // BACKFORTH;
1447114885 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14886
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447314887 {
1447414888 mouseMode |= SELECT;
1447514889 }
14476
- if ((modifiers & COMMAND) == COMMAND)
14890
+ if ((modifiersex & COMMAND) == COMMAND)
1447714891 {
1447814892 mouseMode |= SELECT;
1447914893 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14894
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448114895 {
1448214896 mouseMode &= ~VR;
1448314897 mouseMode |= TRANSLATE;
....@@ -14506,7 +14920,7 @@
1450614920
1450714921 if (isRenderer) //
1450814922 {
14509
- SetMouseMode(modifiers);
14923
+ SetMouseMode(0, modifiers);
1451014924 }
1451114925
1451214926 Globals.theRenderer.keyPressed(key);
....@@ -14568,7 +14982,8 @@
1456814982 // break;
1456914983 case 'T':
1457014984 CACHETEXTURE ^= true;
14571
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1457214987 // repaint();
1457314988 break;
1457414989 case 'Y':
....@@ -14653,7 +15068,9 @@
1465315068 case 'E' : COMPACT ^= true;
1465415069 repaint();
1465515070 break;
14656
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1465715074 repaint();
1465815075 break;
1465915076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14678,8 +15095,8 @@
1467815095 RevertCamera();
1467915096 repaint();
1468015097 break;
14681
- case 'L':
1468215098 case 'l':
15099
+ //case 'L':
1468315100 if (lightMode)
1468415101 {
1468515102 lightMode = false;
....@@ -14822,9 +15239,9 @@
1482215239 case '_':
1482315240 kompactbit = 5;
1482415241 break;
14825
- case '+':
14826
- kompactbit = 6;
14827
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1482815245 case ' ':
1482915246 lightMode ^= true;
1483015247 Globals.lighttouched = true;
....@@ -14836,13 +15253,14 @@
1483615253 case ESC:
1483715254 RENDERPROGRAM += 1;
1483815255 RENDERPROGRAM %= 3;
15256
+
1483915257 repaint();
1484015258 break;
1484115259 case 'Z':
1484215260 //RESIZETEXTURE ^= true;
1484315261 //break;
1484415262 case 'z':
14845
- RENDERSHADOW ^= true;
15263
+ Globals.RENDERSHADOW ^= true;
1484615264 Globals.lighttouched = true;
1484715265 repaint();
1484815266 break;
....@@ -14875,8 +15293,9 @@
1487515293 case DELETE:
1487615294 ClearSelection();
1487715295 break;
14878
- /*
1487915296 case '+':
15297
+
15298
+ /*
1488015299 //fontsize += 1;
1488115300 bbzoom *= 2;
1488215301 repaint();
....@@ -14893,17 +15312,17 @@
1489315312 case '=':
1489415313 IncDepth();
1489515314 //fontsize += 1;
14896
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1489715316 maskbit = 6;
1489815317 break;
1489915318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1490015319 DecDepth();
1490115320 maskbit = 5;
1490215321 //if(fontsize > 1) fontsize -= 1;
14903
- if (object.editWindow == null)
14904
- new Exception().printStackTrace();
14905
- else
14906
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1490715326 break;
1490815327 case '{':
1490915328 manipCamera.shaper_fovy /= 1.1;
....@@ -14966,7 +15385,7 @@
1496615385 //mode = ROTATE;
1496715386 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815387 {
14969
- SetMouseMode(modifiers);
15388
+ SetMouseMode(0, modifiers);
1497015389 }
1497115390 }
1497215391
....@@ -15100,8 +15519,9 @@
1510015519
1510115520 protected void processMouseMotionEvent(MouseEvent e)
1510215521 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15522
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15523
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15524
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515525 {
1510615526 mouseMoved(e);
1510715527 } else
....@@ -15126,11 +15546,12 @@
1512615546 }
1512715547 */
1512815548
15129
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1513015550 }
1513115551
1513215552 void SelectParent()
1513315553 {
15554
+ new Exception().printStackTrace();
1513415555 System.exit(0);
1513515556 Composite group = (Composite) object;
1513615557 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15142,10 +15563,10 @@
1514215563 {
1514315564 //selectees.remove(i);
1514415565 System.out.println("select parent of " + elem);
15145
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1514615567 } else
1514715568 {
15148
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1514915570 }
1515015571
1515115572 first = false;
....@@ -15154,6 +15575,7 @@
1515415575
1515515576 void SelectChildren()
1515615577 {
15578
+ new Exception().printStackTrace();
1515715579 System.exit(0);
1515815580 /*
1515915581 Composite group = (Composite) object;
....@@ -15186,12 +15608,12 @@
1518615608 for (int j = 0; j < group.children.size(); j++)
1518715609 {
1518815610 elem = (Object3D) group.children.elementAt(j);
15189
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519015612 first = false;
1519115613 }
1519215614 } else
1519315615 {
15194
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519515617 }
1519615618
1519715619 first = false;
....@@ -15202,21 +15624,21 @@
1520215624 {
1520315625 //Composite group = (Composite) object;
1520415626 Object3D group = object;
15205
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1520615628 }
1520715629
1520815630 void ResetTransform(int mask)
1520915631 {
1521015632 //Composite group = (Composite) object;
1521115633 Object3D group = object;
15212
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1521315635 }
1521415636
1521515637 void FlipTransform()
1521615638 {
1521715639 //Composite group = (Composite) object;
1521815640 Object3D group = object;
15219
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1522015642 // group.editWindow.ReduceMesh(true);
1522115643 }
1522215644
....@@ -15224,7 +15646,7 @@
1522415646 {
1522515647 //Composite group = (Composite) object;
1522615648 Object3D group = object;
15227
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1522815650 // group.editWindow.ReduceMesh(true);
1522915651 }
1523015652
....@@ -15232,7 +15654,7 @@
1523215654 {
1523315655 //Composite group = (Composite) object;
1523415656 Object3D group = object;
15235
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1523615658 }
1523715659
1523815660 void IncDepth()
....@@ -15318,7 +15740,9 @@
1531815740 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915741 //Image img = CreateImage(width, height);
1532015742 //System.out.println("width = " + width + "; height = " + height + "\n");
15743
+
1532115744 Graphics gr = g; // img.getGraphics();
15745
+
1532215746 if (!hasMarquee)
1532315747 {
1532415748 if (Xmin < Xmax) // !locked)
....@@ -15406,6 +15830,7 @@
1540615830 info.bounds.y += (height - desired) / 2;
1540715831 }
1540815832 }
15833
+
1540915834 info.g = gr;
1541015835 info.camera = renderCamera;
1541115836 /*
....@@ -15415,15 +15840,55 @@
1541515840 */
1541615841 if (!isRenderer)
1541715842 {
15418
- object.drawEditHandles(info, 0);
15843
+ Grafreed.Assert(object != null);
15844
+ Grafreed.Assert(object.selection != null);
15845
+ if (object.selection.Size() > 0)
15846
+ {
15847
+ int hitSomething = object.selection.get(0).hitSomething;
15848
+
15849
+ info.DX = 0;
15850
+ info.DY = 0;
15851
+ info.W = 1;
15852
+ if (hitSomething == Object3D.hitCenter)
15853
+ {
15854
+ info.DX = X;
15855
+ if (X != 0)
15856
+ info.DX -= info.bounds.width/2;
15857
+
15858
+ info.DY = Y;
15859
+ if (Y != 0)
15860
+ info.DY -= info.bounds.height/2;
15861
+ }
15862
+
15863
+ object.drawEditHandles(info, 0);
15864
+
15865
+ if (drag && (X != 0 || Y != 0))
15866
+ {
15867
+ switch (hitSomething)
15868
+ {
15869
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15870
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15871
+ break;
15872
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15873
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15874
+ break;
15875
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15876
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15877
+ break;
15878
+ }
15879
+
15880
+ }
15881
+ }
1541915882 }
1542015883 }
15884
+
1542115885 if (isRenderer)
1542215886 {
1542315887 //gr.setColor(Color.black);
1542415888 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542515889 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542615890 }
15891
+
1542715892 if (hasMarquee)
1542815893 {
1542915894 gr.setXORMode(Color.white);
....@@ -15536,6 +16001,7 @@
1553616001 public boolean mouseDown(Event evt, int x, int y)
1553716002 {
1553816003 System.out.println("mouseDown: " + evt);
16004
+ System.exit(0);
1553916005 /*
1554016006 locked = true;
1554116007 drag = false;
....@@ -15579,7 +16045,7 @@
1557916045 {
1558016046 keyPressed(0, modifiers);
1558116047 }
15582
- clickStart(x, y, modifiers);
16048
+ // clickStart(x, y, modifiers);
1558316049 return true;
1558416050 }
1558516051
....@@ -15697,7 +16163,7 @@
1569716163 {
1569816164 keyReleased(0, 0);
1569916165 }
15700
- drag(x, y, modifiers);
16166
+ drag(x, y, 0, modifiers);
1570116167 return true;
1570216168 }
1570316169
....@@ -15829,7 +16295,7 @@
1582916295 Object3D object;
1583016296 static Object3D trackedobject;
1583116297 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583316299 /*static*/ Camera eyeCamera;
1583416300 /*static*/ Camera lightCamera;
1583516301 int cameracount;
....@@ -16114,16 +16580,16 @@
1611416580 cStatic.objectstack[materialdepth++] = checker;
1611516581 //System.out.println("material " + material);
1611616582 //Applet3D.tracein(this, selected);
16117
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1611816584
1611916585 //checker.GetMaterial().Draw(this, false); // true);
16120
- DrawMaterial(checker.GetMaterial(), false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1612116587
1612216588 materialdepth -= 1;
1612316589 if (materialdepth > 0)
1612416590 {
16125
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16126
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16591
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16592
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1612716593 }
1612816594 //checker.GetMaterial().opacity = 1f;
1612916595 ////checker.GetMaterial().ambient = 1f;
....@@ -16209,6 +16675,14 @@
1620916675 }
1621016676 }
1621116677
16678
+ private Object3D GetFolder()
16679
+ {
16680
+ Object3D folder = object.GetWindow().copy;
16681
+ if (object.GetWindow().copy.selection.Size() > 0)
16682
+ folder = object.GetWindow().copy.selection.elementAt(0);
16683
+ return folder;
16684
+ }
16685
+
1621216686 class SelectBuffer implements GLEventListener
1621316687 {
1621416688
....@@ -16267,6 +16741,7 @@
1626716741 {
1626816742 if (!selection)
1626916743 {
16744
+ new Exception().printStackTrace();
1627016745 System.exit(0);
1627116746 return;
1627216747 }
....@@ -16287,6 +16762,17 @@
1628716762
1628816763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1628916764
16765
+ if (PAINTMODE)
16766
+ {
16767
+ if (object.GetWindow().copy.selection.Size() > 0)
16768
+ {
16769
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16770
+
16771
+ // Make what you paint not selectable.
16772
+ paintobj.ResetSelectable();
16773
+ }
16774
+ }
16775
+
1629016776 //int tmp = selection_view;
1629116777 //selection_view = -1;
1629216778 int temp = DrawMode();
....@@ -16298,6 +16784,17 @@
1629816784 // temp = DEFAULT; // patch for selection debug
1629916785 Globals.drawMode = temp; // WARNING
1630016786
16787
+ if (PAINTMODE)
16788
+ {
16789
+ if (object.GetWindow().copy.selection.Size() > 0)
16790
+ {
16791
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16792
+
16793
+ // Revert.
16794
+ paintobj.RestoreSelectable();
16795
+ }
16796
+ }
16797
+
1630116798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1630216799
1630316800 // trying different ways of getting the depth info over
....@@ -16345,6 +16842,8 @@
1634516842 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1634616843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1634716844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16845
+
16846
+ CreateSelectedPoint();
1634816847
1634916848 // Will fit the mesh !!!
1635016849 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16394,34 +16893,36 @@
1639416893 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]));
1639516894 }
1639616895
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16896
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639816897 }
1639916898 }
1640016899
1640116900 if (!movingcamera && !PAINTMODE)
16402
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1640316902
16404
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16903
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1640516904 {
16406
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16905
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1640716906
16408
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1640916910
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();
16911
+ Object3D inst = new Object3D("inst" + paintcount++);
16912
+
16913
+ inst.CreateMaterial(); // use a void leaf to select instances
16914
+
16915
+ inst.add(paintobj); // link
16916
+
16917
+ object.GetWindow().SnapObject(inst);
16918
+
16919
+ Object3D folder = paintFolder; // GetFolder();
16920
+
16921
+ folder.add(inst);
16922
+
16923
+ object.GetWindow().ResetModel();
16924
+ object.GetWindow().refreshContents();
16925
+ }
1642516926 }
1642616927 else
1642716928 paintcount = 0;
....@@ -16460,6 +16961,11 @@
1646016961 //System.out.println("objects[color] = " + objects[color]);
1646116962 //objects[color].Select();
1646216963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1646316969 object.Select(color, deselect);
1646416970 }
1646516971
....@@ -16559,7 +17065,7 @@
1655917065 gl.glDisable(gl.GL_CULL_FACE);
1656017066 }
1656117067
16562
- if (!RENDERSHADOW)
17068
+ if (!Globals.RENDERSHADOW)
1656317069 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656417070
1656517071 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +17075,7 @@
1656917075 //gl.glColorMask(false, false, false, false);
1657017076
1657117077 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17078
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657317079 {
1657417080 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657517081
....@@ -16985,23 +17491,15 @@
1698517491 int AAbuffersize = 0;
1698617492
1698717493 //double[] selectedpoint = new double[3];
16988
- static Superellipsoid selectedpoint = new Superellipsoid();
17494
+ static Superellipsoid selectedpoint;
1698917495 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();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1699417500
1699517501 static Sphere debugpoints[] = new Sphere[8];
1699617502
16997
- static
16998
- {
16999
- for (int i=0; i<8; i++)
17000
- {
17001
- debugpoints[i] = new Sphere();
17002
- }
17003
- }
17004
-
1700517503 static void InitPoints(float radius)
1700617504 {
1700717505 for (int i=0; i<8; i++)