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
....@@ -61,7 +60,7 @@
6160 //boolean REDUCETEXTURE = true;
6261 boolean CACHETEXTURE = true;
6362 boolean CLEANCACHE = false; // true;
64
- boolean MIPMAP = false; // true;
63
+ boolean MIPMAP = true; // false; // true;
6564 boolean COMPRESSTEXTURE = false;
6665 boolean KOMPACTTEXTURE = false; // true;
6766 boolean RESIZETEXTURE = false;
....@@ -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 {
....@@ -325,7 +326,7 @@
325326 cStatic.objectstack[materialdepth++] = obj;
326327 //System.out.println("material " + material);
327328 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
329
+ //display.vector2buffer = obj.projectedVertices;
329330 if (obj instanceof Camera)
330331 {
331332 display.options1[0] = material.shift;
....@@ -334,14 +335,28 @@
334335 display.options1[2] = material.shadowbias;
335336 display.options1[3] = material.aniso;
336337 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]);
337343 display.options2[0] = material.opacity;
338344 display.options2[1] = material.diffuse;
339345 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]);
340349
341350 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]);
342354 display.options4[0] = material.cameralight/0.2f;
343355 display.options4[1] = material.subsurface;
344356 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]);
345360
346361 // if (display.CURRENTANTIALIAS > 0)
347362 // display.options3[3] /= 4;
....@@ -357,7 +372,7 @@
357372 /**/
358373 } else
359374 {
360
- DrawMaterial(material, selected);
375
+ DrawMaterial(material, selected, obj.projectedVertices);
361376 }
362377 } else
363378 {
....@@ -381,8 +396,8 @@
381396 cStatic.objectstack[materialdepth++] = obj;
382397 //System.out.println("material " + material);
383398 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
399
+ //display.vector2buffer = obj.projectedVertices;
400
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386401 }
387402 }
388403
....@@ -399,8 +414,8 @@
399414 materialdepth -= 1;
400415 if (materialdepth > 0)
401416 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- 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);
404419 }
405420 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406421 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +435,8 @@
420435 materialdepth -= 1;
421436 if (materialdepth > 0)
422437 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- 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);
425440 }
426441 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427442 //else
....@@ -462,10 +477,12 @@
462477 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463478 {
464479 //gl.glBegin(gl.GL_TRIANGLES);
465
- 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
+ ;
466483 if (!hasnorm)
467484 {
468
- // System.out.println("FUCK!!");
485
+ // System.out.println("Mesh normal");
469486 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470487 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471488 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1207,12 @@
11901207 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911208 }
11921209 }
1210
+
11931211 if (flipV)
11941212 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951213 else
11961214 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1215
+
11971216 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981217 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991218
....@@ -1213,10 +1232,12 @@
12131232 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141233 }
12151234 }
1235
+
12161236 if (flipV)
12171237 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181238 else
12191239 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1240
+
12201241 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211242 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221243
....@@ -1244,8 +1265,10 @@
12441265 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451266 else
12461267 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1268
+
12471269 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481270 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1271
+
12491272 count2 += 2;
12501273 count3 += 3;
12511274 }
....@@ -1601,7 +1624,7 @@
16011624 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021625 }
16031626
1604
- void DrawMaterial(cMaterial material, boolean selected)
1627
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051628 {
16061629 CameraPane display = this;
16071630 //new Exception().printStackTrace();
....@@ -1628,7 +1651,7 @@
16281651
16291652 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301653
1631
- float[] colorV = GrafreeD.colorV;
1654
+ float[] colorV = Grafreed.colorV;
16321655
16331656 /**/
16341657 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1659,7 @@
16361659 colorV[0] = display.modelParams0[0] * material.diffuse;
16371660 colorV[1] = display.modelParams0[1] * material.diffuse;
16381661 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1662
+ colorV[3] = 1; // material.opacity;
16401663
16411664 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421665 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1767,9 @@
17441767 display.modelParams7[2] = 0;
17451768 display.modelParams7[3] = 0;
17461769
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1770
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481771
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1772
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501773 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511774 {
17521775 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1911,7 @@
18881911 void PushMatrix(double[][] matrix)
18891912 {
18901913 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1914
+ PushMatrix(matrix, 1);
18921915 }
18931916
18941917 void PushMatrix()
....@@ -2042,7 +2065,7 @@
20422065 //System.err.println("Oeil on");
20432066 OEIL = true;
20442067 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2068
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462069 //pingthread.StepToTarget(true);
20472070 }
20482071
....@@ -2140,7 +2163,7 @@
21402163 System.err.println("LIVE = " + Globals.isLIVE());
21412164
21422165 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2166
+ Grafreed.savesound = true; // wav.save();
21442167 // else
21452168 repaint(); // start loop // may 2013
21462169 }
....@@ -2257,7 +2280,7 @@
22572280
22582281 void ToggleDebug()
22592282 {
2260
- DEBUG ^= true;
2283
+ Globals.DEBUG ^= true;
22612284 }
22622285
22632286 void ToggleLookAt()
....@@ -2265,7 +2288,7 @@
22652288 LOOKAT ^= true;
22662289 }
22672290
2268
- void ToggleRandom()
2291
+ void ToggleSwitch()
22692292 {
22702293 SWITCH ^= true;
22712294 }
....@@ -2275,10 +2298,17 @@
22752298 HANDLES ^= true;
22762299 }
22772300
2301
+ Object3D paintFolder;
2302
+
22782303 void TogglePaint()
22792304 {
22802305 PAINTMODE ^= true;
22812306 paintcount = 0;
2307
+
2308
+ if (PAINTMODE)
2309
+ {
2310
+ paintFolder = GetFolder();
2311
+ }
22822312 }
22832313
22842314 void SwapCamera(int a, int b)
....@@ -2374,7 +2404,46 @@
23742404 {
23752405 return currentGL;
23762406 }
2377
-
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
+
23782447 /**/
23792448 class CacheTexture
23802449 {
....@@ -2392,9 +2461,10 @@
23922461 /**/
23932462
23942463 // TEXTURE static Texture texture;
2395
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2396
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2397
- 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
+
23982468 int pigmentdepth = 0;
23992469 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24002470 int bumpdepth = 0;
....@@ -2416,6 +2486,33 @@
24162486 true,
24172487 com.sun.opengl.util.texture.TextureIO.PNG);
24182488 } 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)
24192516 {
24202517 throw new javax.media.opengl.GLException(e);
24212518 }
....@@ -3502,6 +3599,8 @@
35023599
35033600 System.out.println("LOADING TEXTURE : " + name);
35043601
3602
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3603
+
35053604 //
35063605 if (false) // compressbit > 0)
35073606 {
....@@ -7900,7 +7999,7 @@
79007999 String pigment = Object3D.GetPigment(tex);
79018000 String bump = Object3D.GetBump(tex);
79028001
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8002
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79048003 {
79058004 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79068005 // System.out.println("; bump = " + bump);
....@@ -7917,6 +8016,64 @@
79178016
79188017 ReleaseTexture(bump, true);
79198018 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);
79208077 }
79218078
79228079 void ReleaseTexture(String tex, boolean bump)
....@@ -8022,7 +8179,55 @@
80228179 }
80238180 }
80248181
8025
- /*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
80268231 {
80278232 if (// DrawMode() != 0 || /*tex == null ||*/
80288233 ambientOcclusion ) // || !textureon)
....@@ -8032,18 +8237,48 @@
80328237
80338238 if (tex == null)
80348239 {
8035
- BindTexture(null,false,resolution);
8036
- BindTexture(null,true,resolution);
8240
+ BindTexture(null, null,false,resolution);
80378241 return;
80388242 }
80398243
80408244 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
+
80418277 String bump = Object3D.GetBump(tex);
80428278
8043
- usedtextures.put(pigment, pigment);
8044
- usedtextures.put(bump, bump);
8279
+ usedtextures.add(bump);
80458280
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8281
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478282 {
80488283 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498284 // System.out.println("; bump = " + bump);
....@@ -8053,42 +8288,70 @@
80538288 {
80548289 bump = null;
80558290 }
8056
- if (pigment.equals(""))
8057
- {
8058
- pigment = null;
8059
- }
80608291
8061
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8062
- BindTexture(pigment, false, resolution);
80638292 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8064
- BindTexture(bump, true, resolution);
8293
+ BindTexture(tex.bumptexture, bump, true, resolution);
80658294 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8066
-
8067
- return; // true;
80688295 }
80698296
8070
- 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)
80718300 {
8072
- 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;
80738320
80748321 if (tex != null)
80758322 {
80768323 String texname = tex;
80778324
8078
- String[] split = tex.split("Textures");
8079
- if (split.length > 1)
8080
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8081
- else
8082
- if (!texname.startsWith("/"))
8083
- 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
+ }
80848337
80858338 if (CACHETEXTURE)
8086
- texture = textures.get(texname); // TEXTURE CACHE
8087
-
8088
- TextureData texturedata = null;
8089
-
8090
- if (texture == null || texture.resolution < resolution)
80918339 {
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
80928355 if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80938356 {
80948357 assert(!bump);
....@@ -8100,19 +8363,23 @@
81008363 // }
81018364 // else
81028365 // {
8103
- texture = textures.get(tex);
8104
- if (texture == null)
8366
+ texturecache = textures.get(tex);
8367
+ if (texturecache == null)
81058368 {
8106
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8369
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81078370 }
8371
+ else
8372
+ new Exception().printStackTrace();
81088373 // }
81098374 } else
81108375 if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81118376 {
81128377 assert(bump);
8113
- texture = textures.get(tex);
8114
- if (texture == null)
8115
- 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();
81168383 } else
81178384 {
81188385 //if (tex.equals("IMMORTAL"))
....@@ -8122,9 +8389,11 @@
81228389 //{
81238390 if (tex.equals("WHITE_NOISE"))
81248391 {
8125
- texture = textures.get(tex);
8126
- if (texture == null)
8127
- 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();
81288397 } else
81298398 {
81308399 if (textureon)
....@@ -8149,7 +8418,7 @@
81498418 }
81508419
81518420 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8152
- if (!new File(cachename).exists())
8421
+ if (!FileExists(cachename))
81538422 cachename = texname;
81548423 else
81558424 processbump = false; // don't process bump map again
....@@ -8171,7 +8440,7 @@
81718440 }
81728441
81738442 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8174
- if (!new File(cachename).exists())
8443
+ if (!FileExists(cachename))
81758444 cachename = texname;
81768445 else
81778446 processbump = false; // don't process bump map again
....@@ -8180,20 +8449,23 @@
81808449 texturedata = GetFileTexture(cachename, processbump, resolution);
81818450
81828451
8183
- if (texturedata != null)
8184
- 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);
81858456 //texture = GetTexture(tex, bump);
81868457 }
81878458 }
81888459 //}
81898460 }
81908461
8191
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8462
+ if (/*CACHETEXTURE &&*/ texturecache != null && textureon)
81928463 {
81938464 //return false;
8465
+ assert(bim == null);
81948466
81958467 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8196
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8468
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81978469 {
81988470 // String ext = "_highres";
81998471 // if (REDUCETEXTURE)
....@@ -8210,52 +8482,17 @@
82108482 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82118483 if (!cachefile.exists())
82128484 {
8213
- // cache to disk
8214
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8215
- //buffers[0].
8216
-
8217
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8218
- int[] pixels = new int[bytebuf.capacity()/3];
8219
-
8220
- // squared size heuristic...
8221
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8485
+ //if (texturedata.getWidth() == texturedata.getHeight())
82228486 {
8223
- for (int i=pixels.length; --i>=0;)
8224
- {
8225
- int i3 = i*3;
8226
- pixels[i] = 0xFF;
8227
- pixels[i] <<= 8;
8228
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8229
- pixels[i] <<= 8;
8230
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8231
- pixels[i] <<= 8;
8232
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8233
- }
8234
-
8235
- /*
8236
- int r=0,g=0,b=0,a=0;
8237
- for (int i=0; i<width; i++)
8238
- for (int j=0; j<height; j++)
8239
- {
8240
- int index = j*width+i;
8241
- int p = pixels[index];
8242
- a = ((p>>24) & 0xFF);
8243
- r = ((p>>16) & 0xFF);
8244
- g = ((p>>8) & 0xFF);
8245
- b = (p & 0xFF);
8246
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8247
- }
8248
- /**/
8249
- int width = (int)Math.sqrt(pixels.length); // squared
8250
- int height = width;
8251
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8252
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8487
+ BufferedImage rendImage = CreateBim(texturedata);
8488
+
82538489 ImageWriter writer = null;
82548490 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82558491 if (iter.hasNext()) {
82568492 writer = (ImageWriter)iter.next();
82578493 }
8258
- float compressionQuality = 0.9f;
8494
+
8495
+ float compressionQuality = 0.85f;
82598496 try
82608497 {
82618498 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8282,8 +8519,8 @@
82828519 textures.remove(texname);
82838520 }
82848521
8285
- texture.texturedata = texturedata;
8286
- textures.put(texname, texture);
8522
+ //texture.texturedata = texturedata;
8523
+ textures.put(texname, texturecache);
82878524
82888525 // newtex = true;
82898526 }
....@@ -8299,12 +8536,17 @@
82998536 }
83008537 }
83018538
8302
- return texture;
8539
+ return texturecache;
83038540 }
83048541
8305
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8542
+ static void EmbedTextures(cTexture tex)
83068543 {
8307
- 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);
83088550
83098551 if (bump)
83108552 {
....@@ -8320,23 +8562,23 @@
83208562 return texture!=null?texture.texture:null;
83218563 }
83228564
8323
- 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
83248566 {
8325
- CacheTexture texture = GetCacheTexture(tex, bump, resolution);
8567
+ CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution);
83268568
83278569 return texture!=null?texture.texturedata:null;
83288570 }
83298571
8330
- boolean BindTexture(String tex, boolean bump, int resolution)
8572
+ boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception
83318573 {
83328574 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83338575 {
83348576 return false;
83358577 }
83368578
8337
- boolean newtex = false;
8579
+ //boolean newtex = false;
83388580
8339
- com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
8581
+ com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution);
83408582
83418583 if (texture == null)
83428584 return false;
....@@ -8366,7 +8608,7 @@
83668608 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83678609 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83688610
8369
- return newtex;
8611
+ return true; // Warning: not used.
83708612 }
83718613
83728614 ShadowBuffer shadowPBuf;
....@@ -9204,11 +9446,35 @@
92049446 jy8[3] = 0.5f;
92059447 }
92069448
9207
- 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
92089450 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92099451 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92109452 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92119453
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
+
92129478 static int imagecount = 0; // movie generation
92139479
92149480 static int jitter = 0;
....@@ -9304,8 +9570,8 @@
93049570 assert (parentcam != renderCamera);
93059571
93069572 if (renderCamera != lightCamera)
9307
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9308
- LA.matConcat(matrix, parentcam.toParent, matrix);
9573
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9574
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93099575
93109576 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93119577
....@@ -9320,8 +9586,8 @@
93209586 LA.matCopy(renderCamera.fromScreen, matrix);
93219587
93229588 if (renderCamera != lightCamera)
9323
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9324
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9589
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9590
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93259591
93269592 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93279593
....@@ -9538,7 +9804,7 @@
95389804
95399805 if (!BOXMODE)
95409806 {
9541
- 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) + ")");
95429808 }
95439809
95449810 if (!BOXMODE)
....@@ -9576,7 +9842,7 @@
95769842 ABORTED = false;
95779843 }
95789844 else
9579
- GrafreeD.wav.cursor += 735 * ACSIZE;
9845
+ Grafreed.wav.cursor += 735 * ACSIZE;
95809846
95819847 if (false)
95829848 {
....@@ -10239,11 +10505,11 @@
1023910505
1024010506 public void display(GLAutoDrawable drawable)
1024110507 {
10242
- if (GrafreeD.savesound && GrafreeD.hassound)
10508
+ if (Grafreed.savesound && Grafreed.hassound)
1024310509 {
10244
- GrafreeD.wav.save();
10245
- GrafreeD.savesound = false;
10246
- GrafreeD.hassound = false;
10510
+ Grafreed.wav.save();
10511
+ Grafreed.savesound = false;
10512
+ Grafreed.hassound = false;
1024710513 }
1024810514 // if (DEBUG_SELECTION)
1024910515 // {
....@@ -10319,6 +10585,7 @@
1031910585 ANTIALIAS = 0;
1032010586 //System.out.println("RESTART");
1032110587 AAtimer.restart();
10588
+ Globals.TIMERRUNNING = true;
1032210589 }
1032310590 }
1032410591 }
....@@ -10373,7 +10640,7 @@
1037310640 Object3D theobject = object;
1037410641 Object3D theparent = object.parent;
1037510642 object.parent = null;
10376
- object = (Object3D)GrafreeD.clone(object);
10643
+ object = (Object3D)Grafreed.clone(object);
1037710644 object.Stripify();
1037810645 if (theobject.selection == null || theobject.selection.Size() == 0)
1037910646 theobject.PreprocessOcclusion(this);
....@@ -10386,13 +10653,14 @@
1038610653 ambientOcclusion = false;
1038710654 }
1038810655
10389
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10656
+ if (//Globals.lighttouched &&
10657
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039010658 {
1039110659 //if (RENDERSHADOW) // ?
1039210660 if (!IsFrozen())
1039310661 {
1039410662 // dec 2012
10395
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10663
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039610664 {
1039710665 Globals.framecount++;
1039810666 shadowbuffer.display();
....@@ -10519,8 +10787,8 @@
1051910787
1052010788 // if (parentcam != renderCamera) // not a light
1052110789 if (cam != lightCamera)
10522
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10523
- LA.matConcat(matrix, parentcam.toParent, matrix);
10790
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10791
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052410792
1052510793 for (int j = 0; j < 4; j++)
1052610794 {
....@@ -10534,8 +10802,8 @@
1053410802
1053510803 // if (parentcam != renderCamera) // not a light
1053610804 if (cam != lightCamera)
10537
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10538
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10805
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10806
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1053910807
1054010808 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054110809
....@@ -10794,7 +11062,16 @@
1079411062 // Bump noise
1079511063 gl.glActiveTexture(GL.GL_TEXTURE6);
1079611064 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10797
- 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
+
1079811075
1079911076 gl.glActiveTexture(GL.GL_TEXTURE0);
1080011077 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10817,9 +11094,9 @@
1081711094
1081811095 gl.glMatrixMode(GL.GL_MODELVIEW);
1081911096
10820
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10821
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10822
-//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);
1082311100 } else
1082411101 {
1082511102 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10830,7 +11107,7 @@
1083011107 //System.out.println("BLENDING ON");
1083111108 gl.glEnable(GL.GL_BLEND);
1083211109 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10833
-
11110
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083411111 gl.glMatrixMode(gl.GL_PROJECTION);
1083511112 gl.glLoadIdentity();
1083611113
....@@ -10919,8 +11196,8 @@
1091911196 System.err.println("parentcam != renderCamera");
1092011197
1092111198 // if (cam != lightCamera)
10922
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10923
- 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
1092411201 }
1092511202
1092611203 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10941,8 +11218,8 @@
1094111218 if (true) // TODO
1094211219 {
1094311220 if (cam != lightCamera)
10944
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10945
- 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
1094611223 }
1094711224
1094811225 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11279,23 +11556,44 @@
1127911556 e.printStackTrace();
1128011557 }
1128111558
11282
- if (GrafreeD.RENDERME > 0)
11283
- GrafreeD.RENDERME--; // mechante magouille
11559
+ if (Grafreed.RENDERME > 0)
11560
+ Grafreed.RENDERME--; // mechante magouille
1128411561
1128511562 Globals.ONESTEP = false;
1128611563 }
1128711564
1128811565 static boolean zoomonce = false;
1128911566
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
+
1129011585 void DrawObject(GL gl, boolean draw)
1129111586 {
11587
+ // To clear camera values
11588
+ ResetOptions();
11589
+
1129211590 //System.out.println("DRAW OBJECT " + mouseDown);
1129311591 // DrawMode() = SELECTION;
1129411592 //GL gl = getGL();
1129511593 if ((TRACK || SHADOWTRACK) || zoomonce)
1129611594 {
1129711595 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11298
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11596
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129911597 pingthread.StepToTarget(true); // true);
1130011598 // zoomonce = false;
1130111599 }
....@@ -11350,7 +11648,14 @@
1135011648
1135111649 usedtextures.clear();
1135211650
11353
- 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
+ }
1135411659 }
1135511660 //System.out.println("--> " + stackdepth);
1135611661 // GrafreeD.traceon();
....@@ -11360,8 +11665,9 @@
1136011665
1136111666 if (DrawMode() == DEFAULT)
1136211667 {
11363
- if (DEBUG)
11668
+ if (Globals.DEBUG)
1136411669 {
11670
+ CreateSelectedPoint();
1136511671 float radius = 0.05f;
1136611672 if (selectedpoint.radius != radius)
1136711673 {
....@@ -11424,7 +11730,7 @@
1142411730 if (tex.equals("WHITE_NOISE"))
1142511731 continue;
1142611732
11427
- if (!usedtextures.containsKey(tex))
11733
+ if (!usedtextures.contains(tex))
1142811734 {
1142911735 // System.out.println("DISPOSE +++++++++++++++ " + tex);
1143011736 textures.get(tex).texture.dispose();
....@@ -11441,7 +11747,14 @@
1144111747 if (checker != null && DrawMode() == DEFAULT)
1144211748 {
1144311749 //BindTexture(IMMORTAL_TEXTURE);
11444
- 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
+ }
1144511758 // NEAREST
1144611759 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144711760 DrawChecker(gl);
....@@ -11523,7 +11836,7 @@
1152311836 return;
1152411837 }
1152511838
11526
- String string = obj.GetToolTip();
11839
+ String string = obj.toString(); //.GetToolTip();
1152711840
1152811841 GL gl = GetGL();
1152911842
....@@ -11840,8 +12153,8 @@
1184012153 //obj.TransformToWorld(light, light);
1184112154 for (int i = tp.size(); --i >= 0;)
1184212155 {
11843
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11844
- 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);
1184512158 }
1184612159
1184712160
....@@ -11858,8 +12171,8 @@
1185812171 parentcam = cameras[0];
1185912172 }
1186012173
11861
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11862
- 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
1186312176
1186412177 LA.xformPos(light, renderCamera.toScreen, light);
1186512178
....@@ -12473,8 +12786,8 @@
1247312786
1247412787 // display shadow only (bump == 0)
1247512788 "SUB temp.x, half.x, shadow.x;" +
12476
- "MOV temp.y, -params6.x;" +
12477
- "SLT temp.z, temp.y, zero.x;" +
12789
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12790
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247812791 "SUB temp.y, one.x, temp.z;" +
1247912792 "MUL temp.x, temp.x, temp.y;" +
1248012793 "KIL temp.x;" +
....@@ -12754,7 +13067,7 @@
1275413067 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275513068 "FLR final.x, final.y;" +
1275613069 "SUB final.y, final.y, final.x;" +
12757
- //"MUL final.x, final.x, c256i;" +
13070
+ "MUL final.x, final.x, c256i;" +
1275813071 "MOV final.z, zero.x;" +
1275913072 "MOV final.a, one.w;":""
1276013073 ) +
....@@ -12762,7 +13075,7 @@
1276213075 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276313076 "FLR final.x, final.y;" +
1276413077 "SUB final.y, final.y, final.x;" +
12765
- //"MUL final.x, final.x, c256i;" +
13078
+ "MUL final.x, final.x, c256i;" +
1276613079 "MOV final.z, zero.x;" +
1276713080 "MOV final.a, one.w;":""
1276813081 ) +
....@@ -12805,7 +13118,7 @@
1280513118 //once = true;
1280613119 }
1280713120
12808
- System.out.print("Program #" + mode + "; length = " + program.length());
13121
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280913122 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281013123 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281113124
....@@ -12938,12 +13251,16 @@
1293813251
1293913252 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294013253 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13254
+
13255
+ // Compare fragment depth in light space with shadowmap.
1294113256 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294213257 "SGE temp.y, temp.x, zero.x;" +
12943
- "SUB " + shadow + ".y, one.x, temp.y;" +
13258
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13259
+
13260
+ // Reverse comparison
1294413261 "SUB temp.x, one.x, temp.x;" +
1294513262 "MUL " + shadow + ".x, temp.x, temp.y;" +
12946
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13263
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294713264 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294813265
1294913266 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12957,6 +13274,10 @@
1295713274 // No shadow for backface
1295813275 "DP3 temp.x, normal, lightd;" +
1295913276 "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;" +
1296013281 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296113282 "";
1296213283 }
....@@ -13103,7 +13424,8 @@
1310313424 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310413425 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310513426 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13106
- Object3D.cVector2[] vector2buffer;
13427
+
13428
+ //Object3D.cVector2[] vector2buffer;
1310713429
1310813430 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310913431 // OUT : diff, spec
....@@ -13119,9 +13441,10 @@
1311913441 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312013442 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312113443 //"MOV " + dest + ".w," + "normal.z;" +
13122
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13123
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13124
- //"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
1312513448 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312613449 "RCP " + dest + ".w," + dest + ".w;" +
1312713450 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13515,7 +13838,7 @@
1351513838 public void mousePressed(MouseEvent e)
1351613839 {
1351713840 //System.out.println("mousePressed: " + e);
13518
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13841
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351913842 }
1352013843
1352113844 static long prevtime = 0;
....@@ -13591,8 +13914,8 @@
1359113914 // mode |= META;
1359213915 //}
1359313916
13594
- SetMouseMode(WHEEL | e.getModifiersEx());
13595
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13917
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13918
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359613919 anchorX = ax;
1359713920 anchorY = ay;
1359813921 prevX = px;
....@@ -13626,6 +13949,7 @@
1362613949 else
1362713950 if (evt.getSource() == AAtimer)
1362813951 {
13952
+ Globals.TIMERRUNNING = false;
1362913953 if (mouseDown)
1363013954 {
1363113955 //new Exception().printStackTrace();
....@@ -13651,6 +13975,10 @@
1365113975 // LIVE = waslive;
1365213976 // wasliveok = true;
1365313977 // waslive = false;
13978
+
13979
+ // May 2019 Forget it:
13980
+ if (true)
13981
+ return;
1365413982
1365513983 // source == timer
1365613984 if (mouseDown)
....@@ -13681,7 +14009,7 @@
1368114009
1368214010 // fev 2014???
1368314011 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13684
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14012
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368514013 pingthread.StepToTarget(true); // true);
1368614014 }
1368714015 // if (!LIVE)
....@@ -13690,12 +14018,13 @@
1369014018
1369114019 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369214020
13693
- void clickStart(int x, int y, int modifiers)
14021
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369414022 {
1369514023 if (!wasliveok)
1369614024 return;
1369714025
1369814026 AAtimer.restart(); //
14027
+ Globals.TIMERRUNNING = true;
1369914028
1370014029 // waslive = LIVE;
1370114030 // LIVE = false;
....@@ -13707,7 +14036,7 @@
1370714036 // touched = true; // main DL
1370814037 if (isRenderer)
1370914038 {
13710
- SetMouseMode(modifiers);
14039
+ SetMouseMode(modifiers, modifiersex);
1371114040 }
1371214041
1371314042 selectX = anchorX = x;
....@@ -13720,7 +14049,7 @@
1372014049 clicked = true;
1372114050 hold = false;
1372214051
13723
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14052
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372414053 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372514054 {
1372614055 // System.out.println("RESTART II " + modifiers);
....@@ -13751,7 +14080,7 @@
1375114080 info.camera = renderCamera;
1375214081 info.x = x;
1375314082 info.y = y;
13754
- info.modifiers = modifiers;
14083
+ info.modifiers = modifiersex;
1375514084 editObj = object.doEditClick(info, 0);
1375614085 if (!editObj)
1375714086 {
....@@ -13768,9 +14097,12 @@
1376814097
1376914098 public void mouseDragged(MouseEvent e)
1377014099 {
14100
+ Globals.MOUSEDRAGGED = true;
14101
+
1377114102 //System.out.println("mouseDragged: " + e);
1377214103 if (isRenderer)
1377314104 movingcamera = true;
14105
+
1377414106 //if (drawing)
1377514107 //return;
1377614108 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13780,7 +14112,7 @@
1378014112 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378114113 }
1378214114 else
13783
- drag(e.getX(), e.getY(), e.getModifiersEx());
14115
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378414116
1378514117 //try { Thread.sleep(1); } catch (Exception ex) {}
1378614118 }
....@@ -14017,7 +14349,7 @@
1401714349 {
1401814350 Globals.lighttouched = true;
1401914351 }
14020
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14352
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402114353 }
1402214354 //else
1402314355 }
....@@ -14031,12 +14363,12 @@
1403114363 void GoDown(int mod)
1403214364 {
1403314365 MODIFIERS |= COMMAND;
14034
- /*
14366
+ /**/
1403514367 if((mod&SHIFT) == SHIFT)
1403614368 manipCamera.RotatePosition(0, -speed);
1403714369 else
14038
- manipCamera.BackForth(0, -speed*delta, getWidth());
14039
- */
14370
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14371
+ /**/
1404014372 if ((mod & SHIFT) == SHIFT)
1404114373 {
1404214374 mouseMode = mouseMode; // VR??
....@@ -14052,12 +14384,12 @@
1405214384 void GoUp(int mod)
1405314385 {
1405414386 MODIFIERS |= COMMAND;
14055
- /*
14387
+ /**/
1405614388 if((mod&SHIFT) == SHIFT)
1405714389 manipCamera.RotatePosition(0, speed);
1405814390 else
14059
- manipCamera.BackForth(0, speed*delta, getWidth());
14060
- */
14391
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14392
+ /**/
1406114393 if ((mod & SHIFT) == SHIFT)
1406214394 {
1406314395 mouseMode = mouseMode;
....@@ -14073,12 +14405,12 @@
1407314405 void GoLeft(int mod)
1407414406 {
1407514407 MODIFIERS |= COMMAND;
14076
- /*
14408
+ /**/
1407714409 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(speed, 0);
14079
- else
1408014410 manipCamera.Translate(speed*delta, 0, getWidth());
14081
- */
14411
+ else
14412
+ manipCamera.RotatePosition(speed, 0);
14413
+ /**/
1408214414 if ((mod & SHIFT) == SHIFT)
1408314415 {
1408414416 mouseMode = mouseMode;
....@@ -14094,12 +14426,12 @@
1409414426 void GoRight(int mod)
1409514427 {
1409614428 MODIFIERS |= COMMAND;
14097
- /*
14429
+ /**/
1409814430 if((mod&SHIFT) == SHIFT)
14099
- manipCamera.RotatePosition(-speed, 0);
14100
- else
1410114431 manipCamera.Translate(-speed*delta, 0, getWidth());
14102
- */
14432
+ else
14433
+ manipCamera.RotatePosition(-speed, 0);
14434
+ /**/
1410314435 if ((mod & SHIFT) == SHIFT)
1410414436 {
1410514437 mouseMode = mouseMode;
....@@ -14117,7 +14449,7 @@
1411714449 int X, Y;
1411814450 boolean SX, SY;
1411914451
14120
- void drag(int x, int y, int modifiers)
14452
+ void drag(int x, int y, int modifiers, int modifiersex)
1412114453 {
1412214454 if (IsFrozen())
1412314455 {
....@@ -14126,17 +14458,17 @@
1412614458
1412714459 drag = true; // NEW
1412814460
14129
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14461
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413014462
1413114463 X = x;
1413214464 Y = y;
1413314465 // floating state for animation
14134
- MODIFIERS = modifiers;
14135
- modifiers &= ~1024;
14466
+ MODIFIERS = modifiersex;
14467
+ modifiersex &= ~1024;
1413614468 if (false) // modifiers != 0)
1413714469 {
1413814470 //new Exception().printStackTrace();
14139
- System.out.println("mouseDragged: " + modifiers);
14471
+ System.out.println("mouseDragged: " + modifiersex);
1414014472 System.out.println("SHIFT = " + SHIFT);
1414114473 System.out.println("CONTROL = " + COMMAND);
1414214474 System.out.println("META = " + META);
....@@ -14156,7 +14488,8 @@
1415614488 info.camera = renderCamera;
1415714489 info.x = x;
1415814490 info.y = y;
14159
- object.editWindow.copy.doEditDrag(info);
14491
+ object.GetWindow().copy
14492
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416014493 } else
1416114494 {
1416214495 if (x < startX)
....@@ -14320,7 +14653,9 @@
1432014653 ci.camera = renderCamera;
1432114654 if (!isRenderer)
1432214655 {
14323
- if (object.editWindow.copy.doEditClick(ci, 0))
14656
+ //ObjEditor editWindow = object.editWindow;
14657
+ //Object3D copy = editWindow.copy;
14658
+ if (object.doEditClick(ci, 0))
1432414659 {
1432514660 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432614661 } else
....@@ -14332,7 +14667,11 @@
1433214667
1433314668 public void mouseReleased(MouseEvent e)
1433414669 {
14670
+ Globals.MOUSEDRAGGED = false;
14671
+
1433514672 movingcamera = false;
14673
+ X = 0; // getBounds().width/2;
14674
+ Y = 0; // getBounds().height/2;
1433614675 //System.out.println("mouseReleased: " + e);
1433714676 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433814677 }
....@@ -14355,9 +14694,9 @@
1435514694 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435614695 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435714696
14358
- if (control || command || IsFrozen())
14697
+// No delay if (control || command || IsFrozen())
1435914698 timeout = true;
14360
- else
14699
+// ?? May 2019 else
1436114700 // timer.setDelay((modifiers & 128) != 0?0:350);
1436214701 mouseDown = false;
1436314702 if (!control && !command) // june 2013
....@@ -14467,7 +14806,7 @@
1446714806 System.out.println("keyReleased: " + e);
1446814807 }
1446914808
14470
- void SetMouseMode(int modifiers)
14809
+ void SetMouseMode(int modifiers, int modifiersex)
1447114810 {
1447214811 //System.out.println("SetMouseMode = " + modifiers);
1447314812 //modifiers &= ~1024;
....@@ -14479,25 +14818,25 @@
1447914818 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448014819 // return;
1448114820 //System.out.println("SetMode = " + modifiers);
14482
- if ((modifiers & WHEEL) == WHEEL)
14821
+ if ((modifiersex & WHEEL) == WHEEL)
1448314822 {
1448414823 mouseMode |= ZOOM;
1448514824 }
1448614825
1448714826 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14488
- if (capsLocked || (modifiers & META) == META)
14827
+ if (capsLocked) // || (modifiers & META) == META)
1448914828 {
1449014829 mouseMode |= VR; // BACKFORTH;
1449114830 }
14492
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14831
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449314832 {
1449414833 mouseMode |= SELECT;
1449514834 }
14496
- if ((modifiers & COMMAND) == COMMAND)
14835
+ if ((modifiersex & COMMAND) == COMMAND)
1449714836 {
1449814837 mouseMode |= SELECT;
1449914838 }
14500
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14839
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450114840 {
1450214841 mouseMode &= ~VR;
1450314842 mouseMode |= TRANSLATE;
....@@ -14526,7 +14865,7 @@
1452614865
1452714866 if (isRenderer) //
1452814867 {
14529
- SetMouseMode(modifiers);
14868
+ SetMouseMode(0, modifiers);
1453014869 }
1453114870
1453214871 Globals.theRenderer.keyPressed(key);
....@@ -14673,7 +15012,9 @@
1467315012 case 'E' : COMPACT ^= true;
1467415013 repaint();
1467515014 break;
14676
- case 'W' : DEBUGHSB ^= true;
15015
+ case 'W' : // Wide Window (fullscreen)
15016
+ //DEBUGHSB ^= true;
15017
+ ObjEditor.theFrame.ToggleFullScreen();
1467715018 repaint();
1467815019 break;
1467915020 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14698,8 +15039,8 @@
1469815039 RevertCamera();
1469915040 repaint();
1470015041 break;
14701
- case 'L':
1470215042 case 'l':
15043
+ //case 'L':
1470315044 if (lightMode)
1470415045 {
1470515046 lightMode = false;
....@@ -14842,9 +15183,9 @@
1484215183 case '_':
1484315184 kompactbit = 5;
1484415185 break;
14845
- case '+':
14846
- kompactbit = 6;
14847
- break;
15186
+// case '+':
15187
+// kompactbit = 6;
15188
+// break;
1484815189 case ' ':
1484915190 lightMode ^= true;
1485015191 Globals.lighttouched = true;
....@@ -14856,13 +15197,14 @@
1485615197 case ESC:
1485715198 RENDERPROGRAM += 1;
1485815199 RENDERPROGRAM %= 3;
15200
+
1485915201 repaint();
1486015202 break;
1486115203 case 'Z':
1486215204 //RESIZETEXTURE ^= true;
1486315205 //break;
1486415206 case 'z':
14865
- RENDERSHADOW ^= true;
15207
+ Globals.RENDERSHADOW ^= true;
1486615208 Globals.lighttouched = true;
1486715209 repaint();
1486815210 break;
....@@ -14895,8 +15237,9 @@
1489515237 case DELETE:
1489615238 ClearSelection();
1489715239 break;
14898
- /*
1489915240 case '+':
15241
+
15242
+ /*
1490015243 //fontsize += 1;
1490115244 bbzoom *= 2;
1490215245 repaint();
....@@ -14913,17 +15256,17 @@
1491315256 case '=':
1491415257 IncDepth();
1491515258 //fontsize += 1;
14916
- object.editWindow.refreshContents(true);
15259
+ object.GetWindow().refreshContents(true);
1491715260 maskbit = 6;
1491815261 break;
1491915262 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492015263 DecDepth();
1492115264 maskbit = 5;
1492215265 //if(fontsize > 1) fontsize -= 1;
14923
- if (object.editWindow == null)
14924
- new Exception().printStackTrace();
14925
- else
14926
- object.editWindow.refreshContents(true);
15266
+// if (object.editWindow == null)
15267
+// new Exception().printStackTrace();
15268
+// else
15269
+ object.GetWindow().refreshContents(true);
1492715270 break;
1492815271 case '{':
1492915272 manipCamera.shaper_fovy /= 1.1;
....@@ -14986,7 +15329,7 @@
1498615329 //mode = ROTATE;
1498715330 if ((MODIFIERS & COMMAND) == 0) // VR??
1498815331 {
14989
- SetMouseMode(modifiers);
15332
+ SetMouseMode(0, modifiers);
1499015333 }
1499115334 }
1499215335
....@@ -15122,7 +15465,7 @@
1512215465 {
1512315466 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512415467 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15125
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15468
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512615469 {
1512715470 mouseMoved(e);
1512815471 } else
....@@ -15147,7 +15490,7 @@
1514715490 }
1514815491 */
1514915492
15150
- object.editWindow.EditSelection();
15493
+ object.GetWindow().EditSelection(false);
1515115494 }
1515215495
1515315496 void SelectParent()
....@@ -15164,10 +15507,10 @@
1516415507 {
1516515508 //selectees.remove(i);
1516615509 System.out.println("select parent of " + elem);
15167
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15510
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516815511 } else
1516915512 {
15170
- group.editWindow.Select(elem.GetTreePath(), first, true);
15513
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517115514 }
1517215515
1517315516 first = false;
....@@ -15209,12 +15552,12 @@
1520915552 for (int j = 0; j < group.children.size(); j++)
1521015553 {
1521115554 elem = (Object3D) group.children.elementAt(j);
15212
- object.editWindow.Select(elem.GetTreePath(), first, true);
15555
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521315556 first = false;
1521415557 }
1521515558 } else
1521615559 {
15217
- object.editWindow.Select(elem.GetTreePath(), first, true);
15560
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521815561 }
1521915562
1522015563 first = false;
....@@ -15225,21 +15568,21 @@
1522515568 {
1522615569 //Composite group = (Composite) object;
1522715570 Object3D group = object;
15228
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15571
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522915572 }
1523015573
1523115574 void ResetTransform(int mask)
1523215575 {
1523315576 //Composite group = (Composite) object;
1523415577 Object3D group = object;
15235
- group.editWindow.ResetTransform(mask);
15578
+ group.GetWindow().ResetTransform(mask);
1523615579 }
1523715580
1523815581 void FlipTransform()
1523915582 {
1524015583 //Composite group = (Composite) object;
1524115584 Object3D group = object;
15242
- group.editWindow.FlipTransform();
15585
+ group.GetWindow().FlipTransform();
1524315586 // group.editWindow.ReduceMesh(true);
1524415587 }
1524515588
....@@ -15247,7 +15590,7 @@
1524715590 {
1524815591 //Composite group = (Composite) object;
1524915592 Object3D group = object;
15250
- group.editWindow.PrintMemory();
15593
+ group.GetWindow().PrintMemory();
1525115594 // group.editWindow.ReduceMesh(true);
1525215595 }
1525315596
....@@ -15255,7 +15598,7 @@
1525515598 {
1525615599 //Composite group = (Composite) object;
1525715600 Object3D group = object;
15258
- group.editWindow.ResetCentroid();
15601
+ group.GetWindow().ResetCentroid();
1525915602 }
1526015603
1526115604 void IncDepth()
....@@ -15341,7 +15684,9 @@
1534115684 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534215685 //Image img = CreateImage(width, height);
1534315686 //System.out.println("width = " + width + "; height = " + height + "\n");
15687
+
1534415688 Graphics gr = g; // img.getGraphics();
15689
+
1534515690 if (!hasMarquee)
1534615691 {
1534715692 if (Xmin < Xmax) // !locked)
....@@ -15429,6 +15774,7 @@
1542915774 info.bounds.y += (height - desired) / 2;
1543015775 }
1543115776 }
15777
+
1543215778 info.g = gr;
1543315779 info.camera = renderCamera;
1543415780 /*
....@@ -15438,15 +15784,55 @@
1543815784 */
1543915785 if (!isRenderer)
1544015786 {
15441
- 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
+ }
1544215826 }
1544315827 }
15828
+
1544415829 if (isRenderer)
1544515830 {
1544615831 //gr.setColor(Color.black);
1544715832 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544815833 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544915834 }
15835
+
1545015836 if (hasMarquee)
1545115837 {
1545215838 gr.setXORMode(Color.white);
....@@ -15559,6 +15945,7 @@
1555915945 public boolean mouseDown(Event evt, int x, int y)
1556015946 {
1556115947 System.out.println("mouseDown: " + evt);
15948
+ System.exit(0);
1556215949 /*
1556315950 locked = true;
1556415951 drag = false;
....@@ -15602,7 +15989,7 @@
1560215989 {
1560315990 keyPressed(0, modifiers);
1560415991 }
15605
- clickStart(x, y, modifiers);
15992
+ // clickStart(x, y, modifiers);
1560615993 return true;
1560715994 }
1560815995
....@@ -15720,7 +16107,7 @@
1572016107 {
1572116108 keyReleased(0, 0);
1572216109 }
15723
- drag(x, y, modifiers);
16110
+ drag(x, y, 0, modifiers);
1572416111 return true;
1572516112 }
1572616113
....@@ -15852,7 +16239,7 @@
1585216239 Object3D object;
1585316240 static Object3D trackedobject;
1585416241 Camera renderCamera; // Light or Eye (or Occlusion)
15855
- /*static*/ Camera manipCamera; // Light or Eye
16242
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585616243 /*static*/ Camera eyeCamera;
1585716244 /*static*/ Camera lightCamera;
1585816245 int cameracount;
....@@ -16137,16 +16524,16 @@
1613716524 cStatic.objectstack[materialdepth++] = checker;
1613816525 //System.out.println("material " + material);
1613916526 //Applet3D.tracein(this, selected);
16140
- vector2buffer = checker.projectedVertices;
16527
+ //vector2buffer = checker.projectedVertices;
1614116528
1614216529 //checker.GetMaterial().Draw(this, false); // true);
16143
- DrawMaterial(checker.GetMaterial(), false); // true);
16530
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614416531
1614516532 materialdepth -= 1;
1614616533 if (materialdepth > 0)
1614716534 {
16148
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16149
- 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);
1615016537 }
1615116538 //checker.GetMaterial().opacity = 1f;
1615216539 ////checker.GetMaterial().ambient = 1f;
....@@ -16232,6 +16619,14 @@
1623216619 }
1623316620 }
1623416621
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
+
1623516630 class SelectBuffer implements GLEventListener
1623616631 {
1623716632
....@@ -16311,6 +16706,17 @@
1631116706
1631216707 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1631316708
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
+
1631416720 //int tmp = selection_view;
1631516721 //selection_view = -1;
1631616722 int temp = DrawMode();
....@@ -16322,6 +16728,17 @@
1632216728 // temp = DEFAULT; // patch for selection debug
1632316729 Globals.drawMode = temp; // WARNING
1632416730
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
+
1632516742 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632616743
1632716744 // trying different ways of getting the depth info over
....@@ -16369,6 +16786,8 @@
1636916786 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637016787 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637116788 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16789
+
16790
+ CreateSelectedPoint();
1637216791
1637316792 // Will fit the mesh !!!
1637416793 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16418,34 +16837,36 @@
1641816837 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]));
1641916838 }
1642016839
16421
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16840
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642216841 }
1642316842 }
1642416843
1642516844 if (!movingcamera && !PAINTMODE)
16426
- object.editWindow.ScreenFitPoint(); // fev 2014
16845
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642716846
16428
- 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)
1642916848 {
16430
- 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);
1643116850
16432
- Object3D group = new Object3D("inst" + paintcount++);
16851
+ if (object.GetWindow().copy.selection.Size() > 0)
16852
+ {
16853
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1643316854
16434
- group.CreateMaterial(); // use a void leaf to select instances
16435
-
16436
- group.add(paintobj); // link
16437
-
16438
- object.editWindow.SnapObject(group);
16439
-
16440
- Object3D folder = object.editWindow.copy;
16441
-
16442
- if (object.editWindow.copy.selection.Size() > 0)
16443
- folder = object.editWindow.copy.selection.elementAt(0);
16444
-
16445
- folder.add(group);
16446
-
16447
- object.editWindow.ResetModel();
16448
- 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
+ }
1644916870 }
1645016871 else
1645116872 paintcount = 0;
....@@ -16484,6 +16905,11 @@
1648416905 //System.out.println("objects[color] = " + objects[color]);
1648516906 //objects[color].Select();
1648616907 indexcount = 0;
16908
+ ObjEditor window = object.GetWindow();
16909
+ if (window != null && deselect)
16910
+ {
16911
+ window.Select(null, deselect, true);
16912
+ }
1648716913 object.Select(color, deselect);
1648816914 }
1648916915
....@@ -16583,7 +17009,7 @@
1658317009 gl.glDisable(gl.GL_CULL_FACE);
1658417010 }
1658517011
16586
- if (!RENDERSHADOW)
17012
+ if (!Globals.RENDERSHADOW)
1658717013 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658817014
1658917015 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16593,7 +17019,7 @@
1659317019 //gl.glColorMask(false, false, false, false);
1659417020
1659517021 //render_scene_from_light_view(gl, drawable, 0, 0);
16596
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17022
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659717023 {
1659817024 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659917025
....@@ -17009,23 +17435,15 @@
1700917435 int AAbuffersize = 0;
1701017436
1701117437 //double[] selectedpoint = new double[3];
17012
- static Superellipsoid selectedpoint = new Superellipsoid();
17438
+ static Superellipsoid selectedpoint;
1701317439 static Sphere previousselectedpoint = null;
17014
- static Sphere debugpointG = new Sphere();
17015
- static Sphere debugpointP = new Sphere();
17016
- static Sphere debugpointC = new Sphere();
17017
- static Sphere debugpointR = new Sphere();
17440
+ static Sphere debugpointG;
17441
+ static Sphere debugpointP;
17442
+ static Sphere debugpointC;
17443
+ static Sphere debugpointR;
1701817444
1701917445 static Sphere debugpoints[] = new Sphere[8];
1702017446
17021
- static
17022
- {
17023
- for (int i=0; i<8; i++)
17024
- {
17025
- debugpoints[i] = new Sphere();
17026
- }
17027
- }
17028
-
1702917447 static void InitPoints(float radius)
1703017448 {
1703117449 for (int i=0; i<8; i++)