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;
....@@ -86,7 +116,7 @@
86116 static boolean FULLSCREEN = false;
87117 static boolean SUPPORT = true;
88118 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
119
+static boolean FAST = false;
90120 static boolean SLOWPOSE = false;
91121 static boolean FOOTCONTACT = true;
92122
....@@ -108,7 +138,7 @@
108138 static boolean OEIL = true;
109139 static boolean OEILONCE = false; // do oeilon then oeiloff
110140 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
141
+static boolean SWITCH = true; // false;
112142 static boolean HANDLES = false; // selection doesn't work!!
113143 static boolean PAINTMODE = false;
114144
....@@ -151,6 +181,8 @@
151181 defaultcaps.setAccumBlueBits(16);
152182 defaultcaps.setAccumAlphaBits(16);
153183 }
184
+
185
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154186
155187 void SetAsGLRenderer(boolean b)
156188 {
....@@ -327,7 +359,7 @@
327359 cStatic.objectstack[materialdepth++] = obj;
328360 //System.out.println("material " + material);
329361 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
362
+ //display.vector2buffer = obj.projectedVertices;
331363 if (obj instanceof Camera)
332364 {
333365 display.options1[0] = material.shift;
....@@ -336,14 +368,28 @@
336368 display.options1[2] = material.shadowbias;
337369 display.options1[3] = material.aniso;
338370 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]);
339376 display.options2[0] = material.opacity;
340377 display.options2[1] = material.diffuse;
341378 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]);
342382
343383 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]);
344387 display.options4[0] = material.cameralight/0.2f;
345388 display.options4[1] = material.subsurface;
346389 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]);
347393
348394 // if (display.CURRENTANTIALIAS > 0)
349395 // display.options3[3] /= 4;
....@@ -359,7 +405,7 @@
359405 /**/
360406 } else
361407 {
362
- DrawMaterial(material, selected);
408
+ DrawMaterial(material, selected, obj.projectedVertices);
363409 }
364410 } else
365411 {
....@@ -383,8 +429,8 @@
383429 cStatic.objectstack[materialdepth++] = obj;
384430 //System.out.println("material " + material);
385431 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
432
+ //display.vector2buffer = obj.projectedVertices;
433
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388434 }
389435 }
390436
....@@ -401,8 +447,8 @@
401447 materialdepth -= 1;
402448 if (materialdepth > 0)
403449 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- 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);
406452 }
407453 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408454 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +468,8 @@
422468 materialdepth -= 1;
423469 if (materialdepth > 0)
424470 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- 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);
427473 }
428474 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429475 //else
....@@ -464,10 +510,12 @@
464510 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465511 {
466512 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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
+ ;
468516 if (!hasnorm)
469517 {
470
- // System.out.println("FUCK!!");
518
+ // System.out.println("Mesh normal");
471519 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472520 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473521 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1240,12 @@
11921240 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931241 }
11941242 }
1243
+
11951244 if (flipV)
11961245 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971246 else
11981247 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1248
+
11991249 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001250 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011251
....@@ -1215,10 +1265,12 @@
12151265 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161266 }
12171267 }
1268
+
12181269 if (flipV)
12191270 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201271 else
12211272 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1273
+
12221274 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231275 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241276
....@@ -1246,8 +1298,10 @@
12461298 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471299 else
12481300 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1301
+
12491302 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501303 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1304
+
12511305 count2 += 2;
12521306 count3 += 3;
12531307 }
....@@ -1603,7 +1657,7 @@
16031657 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041658 }
16051659
1606
- void DrawMaterial(cMaterial material, boolean selected)
1660
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071661 {
16081662 CameraPane display = this;
16091663 //new Exception().printStackTrace();
....@@ -1630,7 +1684,7 @@
16301684
16311685 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321686
1633
- float[] colorV = GrafreeD.colorV;
1687
+ float[] colorV = Grafreed.colorV;
16341688
16351689 /**/
16361690 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1692,7 @@
16381692 colorV[0] = display.modelParams0[0] * material.diffuse;
16391693 colorV[1] = display.modelParams0[1] * material.diffuse;
16401694 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1695
+ colorV[3] = 1; // material.opacity;
16421696
16431697 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441698 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1800,9 @@
17461800 display.modelParams7[2] = 0;
17471801 display.modelParams7[3] = 0;
17481802
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1803
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501804
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1805
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521806 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531807 {
17541808 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1944,7 @@
18901944 void PushMatrix(double[][] matrix)
18911945 {
18921946 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1947
+ PushMatrix(matrix, 1);
18941948 }
18951949
18961950 void PushMatrix()
....@@ -2044,7 +2098,7 @@
20442098 //System.err.println("Oeil on");
20452099 OEIL = true;
20462100 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2101
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482102 //pingthread.StepToTarget(true);
20492103 }
20502104
....@@ -2142,7 +2196,7 @@
21422196 System.err.println("LIVE = " + Globals.isLIVE());
21432197
21442198 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2199
+ Grafreed.savesound = true; // wav.save();
21462200 // else
21472201 repaint(); // start loop // may 2013
21482202 }
....@@ -2259,7 +2313,7 @@
22592313
22602314 void ToggleDebug()
22612315 {
2262
- DEBUG ^= true;
2316
+ Globals.DEBUG ^= true;
22632317 }
22642318
22652319 void ToggleLookAt()
....@@ -2267,9 +2321,9 @@
22672321 LOOKAT ^= true;
22682322 }
22692323
2270
- void ToggleRandom()
2324
+ void ToggleSwitch()
22712325 {
2272
- RANDOM ^= true;
2326
+ SWITCH ^= true;
22732327 }
22742328
22752329 void ToggleHandles()
....@@ -2277,10 +2331,17 @@
22772331 HANDLES ^= true;
22782332 }
22792333
2334
+ Object3D paintFolder;
2335
+
22802336 void TogglePaint()
22812337 {
22822338 PAINTMODE ^= true;
22832339 paintcount = 0;
2340
+
2341
+ if (PAINTMODE)
2342
+ {
2343
+ paintFolder = GetFolder();
2344
+ }
22842345 }
22852346
22862347 void SwapCamera(int a, int b)
....@@ -2376,7 +2437,22 @@
23762437 {
23772438 return currentGL;
23782439 }
2379
-
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
+
23802456 /**/
23812457 class CacheTexture
23822458 {
....@@ -2385,28 +2461,31 @@
23852461
23862462 int resolution;
23872463
2388
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2464
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23892465 {
2390
- texture = tex;
2466
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2467
+ texturedata = texdata;
23912468 resolution = res;
23922469 }
23932470 }
23942471 /**/
23952472
23962473 // TEXTURE static Texture texture;
2397
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2398
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2399
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
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
+
24002479 int pigmentdepth = 0;
24012480 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022481 int bumpdepth = 0;
24032482 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24042483 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24052484 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2406
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2485
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24072486 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24082487
2409
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2488
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24102489 {
24112490 TextureData texturedata = null;
24122491
....@@ -2425,13 +2504,34 @@
24252504 if (bump)
24262505 texturedata = ConvertBump(texturedata, false);
24272506
2428
- com.sun.opengl.util.texture.Texture texture =
2429
- 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);
24302509
2431
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2432
- 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);
24332512
2434
- 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;
24352535 }
24362536
24372537 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3504,6 +3604,8 @@
35043604
35053605 System.out.println("LOADING TEXTURE : " + name);
35063606
3607
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3608
+
35073609 //
35083610 if (false) // compressbit > 0)
35093611 {
....@@ -7902,7 +8004,7 @@
79028004 String pigment = Object3D.GetPigment(tex);
79038005 String bump = Object3D.GetBump(tex);
79048006
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8007
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79068008 {
79078009 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79088010 // System.out.println("; bump = " + bump);
....@@ -7917,11 +8019,69 @@
79178019 pigment = null;
79188020 }
79198021
7920
- ReleaseTexture(bump, true);
7921
- ReleaseTexture(pigment, false);
8022
+ ReleaseTexture(tex, true);
8023
+ ReleaseTexture(tex, false);
79228024 }
79238025
7924
- 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)
79258085 {
79268086 if (// DrawMode() != 0 || /*tex == null ||*/
79278087 ambientOcclusion ) // || !textureon)
....@@ -7932,7 +8092,7 @@
79328092 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79338093
79348094 if (tex != null)
7935
- texture = textures.get(tex);
8095
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79368096
79378097 // //assert( texture != null );
79388098 // if (texture == null)
....@@ -8024,7 +8184,55 @@
80248184 }
80258185 }
80268186
8027
- /*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
80288236 {
80298237 if (// DrawMode() != 0 || /*tex == null ||*/
80308238 ambientOcclusion ) // || !textureon)
....@@ -8035,17 +8243,47 @@
80358243 if (tex == null)
80368244 {
80378245 BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
80398246 return;
80408247 }
80418248
80428249 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
+
80438282 String bump = Object3D.GetBump(tex);
80448283
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8284
+ usedtextures.add(tex);
80478285
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8286
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498287 {
80508288 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518289 // System.out.println("; bump = " + bump);
....@@ -8055,43 +8293,82 @@
80558293 {
80568294 bump = null;
80578295 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628296
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658297 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8298
+ BindTexture(tex, true, resolution);
80678299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708300 }
80718301
8072
- 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)
80738305 {
8074
- 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;
80758325
80768326 if (tex != null)
80778327 {
8078
- String texname = tex;
8328
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8329
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80798330
8080
- String[] split = tex.split("Textures");
8081
- if (split.length > 1)
8082
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8083
- else
8084
- if (!texname.startsWith("/"))
8085
- texname = "/Users/nbriere/Textures/" + texname;
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
+ }
80868348
80878349 if (CACHETEXTURE)
8088
- texture = textures.get(texname); // TEXTURE CACHE
8089
-
8090
- TextureData texturedata = null;
8091
-
8092
- if (texture == null || texture.resolution < resolution)
80938350 {
8094
- 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(""))
80958372 {
80968373 assert(!bump);
80978374 // if (bump)
....@@ -8102,19 +8379,23 @@
81028379 // }
81038380 // else
81048381 // {
8105
- texture = textures.get(tex);
8106
- if (texture == null)
8382
+ // texturecache = textures.get(texname); // suspicious
8383
+ if (texturecache == null)
81078384 {
8108
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8385
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81098386 }
8387
+ else
8388
+ new Exception().printStackTrace();
81108389 // }
81118390 } else
8112
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8391
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81138392 {
81148393 assert(bump);
8115
- texture = textures.get(tex);
8116
- if (texture == null)
8117
- 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();
81188399 } else
81198400 {
81208401 //if (tex.equals("IMMORTAL"))
....@@ -8122,11 +8403,13 @@
81228403 // texture = GetResourceTexture("default.png");
81238404 //} else
81248405 //{
8125
- if (tex.equals("WHITE_NOISE"))
8406
+ if (texname.endsWith("WHITE_NOISE"))
81268407 {
8127
- texture = textures.get(tex);
8128
- if (texture == null)
8129
- 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();
81308413 } else
81318414 {
81328415 if (textureon)
....@@ -8151,7 +8434,7 @@
81518434 }
81528435
81538436 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8437
+ if (!FileExists(cachename))
81558438 cachename = texname;
81568439 else
81578440 processbump = false; // don't process bump map again
....@@ -8173,7 +8456,7 @@
81738456 }
81748457
81758458 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8459
+ if (!FileExists(cachename))
81778460 cachename = texname;
81788461 else
81798462 processbump = false; // don't process bump map again
....@@ -8182,20 +8465,22 @@
81828465 texturedata = GetFileTexture(cachename, processbump, resolution);
81838466
81848467
8185
- if (texturedata != null)
8186
- 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);
81878472 //texture = GetTexture(tex, bump);
81888473 }
81898474 }
81908475 //}
81918476 }
81928477
8193
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8478
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81948479 {
81958480 //return false;
81968481
81978482 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8198
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8483
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81998484 {
82008485 // String ext = "_highres";
82018486 // if (REDUCETEXTURE)
....@@ -8212,52 +8497,17 @@
82128497 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82138498 if (!cachefile.exists())
82148499 {
8215
- // cache to disk
8216
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8217
- //buffers[0].
8218
-
8219
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8220
- int[] pixels = new int[bytebuf.capacity()/3];
8221
-
8222
- // squared size heuristic...
8223
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8500
+ //if (texturedata.getWidth() == texturedata.getHeight())
82248501 {
8225
- for (int i=pixels.length; --i>=0;)
8226
- {
8227
- int i3 = i*3;
8228
- pixels[i] = 0xFF;
8229
- pixels[i] <<= 8;
8230
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8231
- pixels[i] <<= 8;
8232
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8233
- pixels[i] <<= 8;
8234
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8235
- }
8236
-
8237
- /*
8238
- int r=0,g=0,b=0,a=0;
8239
- for (int i=0; i<width; i++)
8240
- for (int j=0; j<height; j++)
8241
- {
8242
- int index = j*width+i;
8243
- int p = pixels[index];
8244
- a = ((p>>24) & 0xFF);
8245
- r = ((p>>16) & 0xFF);
8246
- g = ((p>>8) & 0xFF);
8247
- b = (p & 0xFF);
8248
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8249
- }
8250
- /**/
8251
- int width = (int)Math.sqrt(pixels.length); // squared
8252
- int height = width;
8253
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8254
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8502
+ BufferedImage rendImage = CreateBim(texturedata);
8503
+
82558504 ImageWriter writer = null;
82568505 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82578506 if (iter.hasNext()) {
82588507 writer = (ImageWriter)iter.next();
82598508 }
8260
- float compressionQuality = 0.9f;
8509
+
8510
+ float compressionQuality = 0.85f;
82618511 try
82628512 {
82638513 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8274,18 +8524,20 @@
82748524 }
82758525 }
82768526 }
8277
-
8527
+
8528
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8529
+
82788530 //System.out.println("Texture = " + tex);
8279
- if (textures.containsKey(texname))
8531
+ if (textures.containsKey(tex))
82808532 {
8281
- CacheTexture thetex = textures.get(texname);
8533
+ CacheTexture thetex = textures.get(tex);
82828534 thetex.texture.disable();
82838535 thetex.texture.dispose();
8284
- textures.remove(texname);
8536
+ textures.remove(tex);
82858537 }
82868538
8287
- texture.texturedata = texturedata;
8288
- textures.put(texname, texture);
8539
+ //texture.texturedata = texturedata;
8540
+ textures.put(tex, texturecache);
82898541
82908542 // newtex = true;
82918543 }
....@@ -8301,10 +8553,41 @@
83018553 }
83028554 }
83038555
8304
- return texture;
8556
+ return texturecache;
83058557 }
83068558
8307
- 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
83088591 {
83098592 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108593
....@@ -8322,21 +8605,21 @@
83228605 return texture!=null?texture.texture:null;
83238606 }
83248607
8325
- 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
83268609 {
83278610 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288611
83298612 return texture!=null?texture.texturedata:null;
83308613 }
83318614
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8615
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83338616 {
83348617 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358618 {
83368619 return false;
83378620 }
83388621
8339
- boolean newtex = false;
8622
+ //boolean newtex = false;
83408623
83418624 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83428625
....@@ -8368,7 +8651,7 @@
83688651 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83698652 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83708653
8371
- return newtex;
8654
+ return true; // Warning: not used.
83728655 }
83738656
83748657 ShadowBuffer shadowPBuf;
....@@ -9206,11 +9489,35 @@
92069489 jy8[3] = 0.5f;
92079490 }
92089491
9209
- 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
92109493 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119494 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129495 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139496
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
+
92149521 static int imagecount = 0; // movie generation
92159522
92169523 static int jitter = 0;
....@@ -9306,8 +9613,8 @@
93069613 assert (parentcam != renderCamera);
93079614
93089615 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9616
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9617
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119618
93129619 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139620
....@@ -9322,8 +9629,8 @@
93229629 LA.matCopy(renderCamera.fromScreen, matrix);
93239630
93249631 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9632
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9633
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279634
93289635 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299636
....@@ -9395,7 +9702,7 @@
93959702 //gl.glFlush();
93969703 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979704
9398
- if (ANIMATION && ABORTED)
9705
+ if (Globals.ANIMATION && ABORTED)
93999706 {
94009707 System.err.println(" ABORTED FRAME");
94019708 break;
....@@ -9425,7 +9732,7 @@
94259732 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269733
94279734 // save image
9428
- if (ANIMATION && !ABORTED)
9735
+ if (Globals.ANIMATION && !ABORTED)
94299736 {
94309737 VPwidth = viewport[2];
94319738 VPheight = viewport[3];
....@@ -9536,11 +9843,11 @@
95369843
95379844 // imagecount++;
95389845
9539
- 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;
95409847
95419848 if (!BOXMODE)
95429849 {
9543
- 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) + ")");
95449851 }
95459852
95469853 if (!BOXMODE)
....@@ -9578,7 +9885,7 @@
95789885 ABORTED = false;
95799886 }
95809887 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9888
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829889
95839890 if (false)
95849891 {
....@@ -10241,11 +10548,11 @@
1024110548
1024210549 public void display(GLAutoDrawable drawable)
1024310550 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10551
+ if (Grafreed.savesound && Grafreed.hassound)
1024510552 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10553
+ Grafreed.wav.save();
10554
+ Grafreed.savesound = false;
10555
+ Grafreed.hassound = false;
1024910556 }
1025010557 // if (DEBUG_SELECTION)
1025110558 // {
....@@ -10321,6 +10628,7 @@
1032110628 ANTIALIAS = 0;
1032210629 //System.out.println("RESTART");
1032310630 AAtimer.restart();
10631
+ Globals.TIMERRUNNING = true;
1032410632 }
1032510633 }
1032610634 }
....@@ -10375,7 +10683,7 @@
1037510683 Object3D theobject = object;
1037610684 Object3D theparent = object.parent;
1037710685 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10686
+ object = (Object3D)Grafreed.clone(object);
1037910687 object.Stripify();
1038010688 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110689 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10696,14 @@
1038810696 ambientOcclusion = false;
1038910697 }
1039010698
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10699
+ if (//Globals.lighttouched &&
10700
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210701 {
1039310702 //if (RENDERSHADOW) // ?
1039410703 if (!IsFrozen())
1039510704 {
1039610705 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10706
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810707 {
1039910708 Globals.framecount++;
1040010709 shadowbuffer.display();
....@@ -10521,8 +10830,8 @@
1052110830
1052210831 // if (parentcam != renderCamera) // not a light
1052310832 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10833
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10834
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610835
1052710836 for (int j = 0; j < 4; j++)
1052810837 {
....@@ -10536,8 +10845,8 @@
1053610845
1053710846 // if (parentcam != renderCamera) // not a light
1053810847 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10848
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10849
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110850
1054210851 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310852
....@@ -10796,7 +11105,16 @@
1079611105 // Bump noise
1079711106 gl.glActiveTexture(GL.GL_TEXTURE6);
1079811107 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080011118
1080111119 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211120 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10819,9 +11137,9 @@
1081911137
1082011138 gl.glMatrixMode(GL.GL_MODELVIEW);
1082111139
10822
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10823
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10824
-//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);
1082511143 } else
1082611144 {
1082711145 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10832,7 +11150,7 @@
1083211150 //System.out.println("BLENDING ON");
1083311151 gl.glEnable(GL.GL_BLEND);
1083411152 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10835
-
11153
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083611154 gl.glMatrixMode(gl.GL_PROJECTION);
1083711155 gl.glLoadIdentity();
1083811156
....@@ -10921,8 +11239,8 @@
1092111239 System.err.println("parentcam != renderCamera");
1092211240
1092311241 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611244 }
1092711245
1092811246 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11261,8 @@
1094311261 if (true) // TODO
1094411262 {
1094511263 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811266 }
1094911267
1095011268 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11260,8 +11578,14 @@
1126011578 {
1126111579 renderpass++;
1126211580 // System.out.println("Draw object... ");
11581
+ STEP = 1;
1126311582 if (FAST) // in case there is no script
11264
- STEP = 16;
11583
+ STEP = 8;
11584
+
11585
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11586
+ {
11587
+ STEP *= 4;
11588
+ }
1126511589
1126611590 //object.FullInvariants();
1126711591
....@@ -11275,23 +11599,44 @@
1127511599 e.printStackTrace();
1127611600 }
1127711601
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11602
+ if (Grafreed.RENDERME > 0)
11603
+ Grafreed.RENDERME--; // mechante magouille
1128011604
1128111605 Globals.ONESTEP = false;
1128211606 }
1128311607
1128411608 static boolean zoomonce = false;
1128511609
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
+
1128611628 void DrawObject(GL gl, boolean draw)
1128711629 {
11630
+ // To clear camera values
11631
+ ResetOptions();
11632
+
1128811633 //System.out.println("DRAW OBJECT " + mouseDown);
1128911634 // DrawMode() = SELECTION;
1129011635 //GL gl = getGL();
1129111636 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211637 {
1129311638 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11639
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511640 pingthread.StepToTarget(true); // true);
1129611641 // zoomonce = false;
1129711642 }
....@@ -11346,7 +11691,14 @@
1134611691
1134711692 usedtextures.clear();
1134811693
11349
- 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
+ }
1135011702 }
1135111703 //System.out.println("--> " + stackdepth);
1135211704 // GrafreeD.traceon();
....@@ -11356,8 +11708,9 @@
1135611708
1135711709 if (DrawMode() == DEFAULT)
1135811710 {
11359
- if (DEBUG)
11711
+ if (Globals.DEBUG)
1136011712 {
11713
+ CreateSelectedPoint();
1136111714 float radius = 0.05f;
1136211715 if (selectedpoint.radius != radius)
1136311716 {
....@@ -11411,20 +11764,32 @@
1141111764 ReleaseTextures(DEFAULT_TEXTURES);
1141211765
1141311766 if (CLEANCACHE)
11414
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11767
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1141511768 {
11416
- String tex = e.nextElement();
11769
+ cTexture tex = e.nextElement();
1141711770
1141811771 // System.out.println("Texture --------- " + tex);
1141911772
11420
- if (tex.equals("WHITE_NOISE"))
11773
+ if (tex.equals("WHITE_NOISE:"))
1142111774 continue;
1142211775
11423
- if (!usedtextures.containsKey(tex))
11776
+ if (!usedtextures.contains(tex))
1142411777 {
11778
+ CacheTexture gettex = texturepigment.get(tex);
1142511779 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11426
- textures.get(tex).texture.dispose();
11427
- 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
+ }
1142811793 }
1142911794 }
1143011795 }
....@@ -11437,7 +11802,14 @@
1143711802 if (checker != null && DrawMode() == DEFAULT)
1143811803 {
1143911804 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111813 // NEAREST
1144211814 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311815 DrawChecker(gl);
....@@ -11519,7 +11891,7 @@
1151911891 return;
1152011892 }
1152111893
11522
- String string = obj.GetToolTip();
11894
+ String string = obj.toString(); //.GetToolTip();
1152311895
1152411896 GL gl = GetGL();
1152511897
....@@ -11836,8 +12208,8 @@
1183612208 //obj.TransformToWorld(light, light);
1183712209 for (int i = tp.size(); --i >= 0;)
1183812210 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112213 }
1184212214
1184312215
....@@ -11854,8 +12226,8 @@
1185412226 parentcam = cameras[0];
1185512227 }
1185612228
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912231
1186012232 LA.xformPos(light, renderCamera.toScreen, light);
1186112233
....@@ -12469,8 +12841,8 @@
1246912841
1247012842 // display shadow only (bump == 0)
1247112843 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12844
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12845
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412846 "SUB temp.y, one.x, temp.z;" +
1247512847 "MUL temp.x, temp.x, temp.y;" +
1247612848 "KIL temp.x;" +
....@@ -12599,8 +12971,10 @@
1259912971 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260012972
1260112973 "SUB temp.x, one.x, ndotl.x;" +
12602
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12603
- "ADD temp.y, one.y, options2.y;" + // sursurface
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
1260412978 "MUL temp.x, temp.x, temp.y;" +
1260512979
1260612980 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13122,7 @@
1274813122 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913123 "FLR final.x, final.y;" +
1275013124 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13125
+ "MUL final.x, final.x, c256i;" +
1275213126 "MOV final.z, zero.x;" +
1275313127 "MOV final.a, one.w;":""
1275413128 ) +
....@@ -12756,7 +13130,7 @@
1275613130 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713131 "FLR final.x, final.y;" +
1275813132 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13133
+ "MUL final.x, final.x, c256i;" +
1276013134 "MOV final.z, zero.x;" +
1276113135 "MOV final.a, one.w;":""
1276213136 ) +
....@@ -12799,7 +13173,7 @@
1279913173 //once = true;
1280013174 }
1280113175
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13176
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313177 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413178 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513179
....@@ -12932,12 +13306,16 @@
1293213306
1293313307 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413308 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13309
+
13310
+ // Compare fragment depth in light space with shadowmap.
1293513311 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613312 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13313
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13314
+
13315
+ // Reverse comparison
1293813316 "SUB temp.x, one.x, temp.x;" +
1293913317 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13318
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113319 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213320
1294313321 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13329,10 @@
1295113329 // No shadow for backface
1295213330 "DP3 temp.x, normal, lightd;" +
1295313331 "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;" +
1295413336 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513337 "";
1295613338 }
....@@ -13097,7 +13479,8 @@
1309713479 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813480 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913481 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13482
+
13483
+ //Object3D.cVector2[] vector2buffer;
1310113484
1310213485 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313486 // OUT : diff, spec
....@@ -13113,9 +13496,10 @@
1311313496 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413497 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513498 //"MOV " + dest + ".w," + "normal.z;" +
13116
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13117
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13118
- //"MOV " + dest + ".z," + "params2.w;" +
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
1311913503 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013504 "RCP " + dest + ".w," + dest + ".w;" +
1312113505 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13893,7 @@
1350913893 public void mousePressed(MouseEvent e)
1351013894 {
1351113895 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13896
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313897 }
1351413898
1351513899 static long prevtime = 0;
....@@ -13585,8 +13969,8 @@
1358513969 // mode |= META;
1358613970 //}
1358713971
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
13972
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
13973
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359013974 anchorX = ax;
1359113975 anchorY = ay;
1359213976 prevX = px;
....@@ -13620,6 +14004,7 @@
1362014004 else
1362114005 if (evt.getSource() == AAtimer)
1362214006 {
14007
+ Globals.TIMERRUNNING = false;
1362314008 if (mouseDown)
1362414009 {
1362514010 //new Exception().printStackTrace();
....@@ -13645,6 +14030,10 @@
1364514030 // LIVE = waslive;
1364614031 // wasliveok = true;
1364714032 // waslive = false;
14033
+
14034
+ // May 2019 Forget it:
14035
+ if (true)
14036
+ return;
1364814037
1364914038 // source == timer
1365014039 if (mouseDown)
....@@ -13675,7 +14064,7 @@
1367514064
1367614065 // fev 2014???
1367714066 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14067
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367914068 pingthread.StepToTarget(true); // true);
1368014069 }
1368114070 // if (!LIVE)
....@@ -13684,12 +14073,13 @@
1368414073
1368514074 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368614075
13687
- void clickStart(int x, int y, int modifiers)
14076
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368814077 {
1368914078 if (!wasliveok)
1369014079 return;
1369114080
1369214081 AAtimer.restart(); //
14082
+ Globals.TIMERRUNNING = true;
1369314083
1369414084 // waslive = LIVE;
1369514085 // LIVE = false;
....@@ -13701,7 +14091,7 @@
1370114091 // touched = true; // main DL
1370214092 if (isRenderer)
1370314093 {
13704
- SetMouseMode(modifiers);
14094
+ SetMouseMode(modifiers, modifiersex);
1370514095 }
1370614096
1370714097 selectX = anchorX = x;
....@@ -13714,7 +14104,7 @@
1371414104 clicked = true;
1371514105 hold = false;
1371614106
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14107
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371814108 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371914109 {
1372014110 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14135,7 @@
1374514135 info.camera = renderCamera;
1374614136 info.x = x;
1374714137 info.y = y;
13748
- info.modifiers = modifiers;
14138
+ info.modifiers = modifiersex;
1374914139 editObj = object.doEditClick(info, 0);
1375014140 if (!editObj)
1375114141 {
....@@ -13762,9 +14152,12 @@
1376214152
1376314153 public void mouseDragged(MouseEvent e)
1376414154 {
14155
+ Globals.MOUSEDRAGGED = true;
14156
+
1376514157 //System.out.println("mouseDragged: " + e);
1376614158 if (isRenderer)
1376714159 movingcamera = true;
14160
+
1376814161 //if (drawing)
1376914162 //return;
1377014163 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14167,7 @@
1377414167 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514168 }
1377614169 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14170
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814171
1377914172 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014173 }
....@@ -14011,7 +14404,7 @@
1401114404 {
1401214405 Globals.lighttouched = true;
1401314406 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14407
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514408 }
1401614409 //else
1401714410 }
....@@ -14025,12 +14418,12 @@
1402514418 void GoDown(int mod)
1402614419 {
1402714420 MODIFIERS |= COMMAND;
14028
- /*
14421
+ /**/
1402914422 if((mod&SHIFT) == SHIFT)
1403014423 manipCamera.RotatePosition(0, -speed);
1403114424 else
14032
- manipCamera.BackForth(0, -speed*delta, getWidth());
14033
- */
14425
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14426
+ /**/
1403414427 if ((mod & SHIFT) == SHIFT)
1403514428 {
1403614429 mouseMode = mouseMode; // VR??
....@@ -14046,12 +14439,12 @@
1404614439 void GoUp(int mod)
1404714440 {
1404814441 MODIFIERS |= COMMAND;
14049
- /*
14442
+ /**/
1405014443 if((mod&SHIFT) == SHIFT)
1405114444 manipCamera.RotatePosition(0, speed);
1405214445 else
14053
- manipCamera.BackForth(0, speed*delta, getWidth());
14054
- */
14446
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14447
+ /**/
1405514448 if ((mod & SHIFT) == SHIFT)
1405614449 {
1405714450 mouseMode = mouseMode;
....@@ -14067,12 +14460,12 @@
1406714460 void GoLeft(int mod)
1406814461 {
1406914462 MODIFIERS |= COMMAND;
14070
- /*
14463
+ /**/
1407114464 if((mod&SHIFT) == SHIFT)
14072
- manipCamera.RotatePosition(speed, 0);
14073
- else
1407414465 manipCamera.Translate(speed*delta, 0, getWidth());
14075
- */
14466
+ else
14467
+ manipCamera.RotatePosition(speed, 0);
14468
+ /**/
1407614469 if ((mod & SHIFT) == SHIFT)
1407714470 {
1407814471 mouseMode = mouseMode;
....@@ -14088,12 +14481,12 @@
1408814481 void GoRight(int mod)
1408914482 {
1409014483 MODIFIERS |= COMMAND;
14091
- /*
14484
+ /**/
1409214485 if((mod&SHIFT) == SHIFT)
14093
- manipCamera.RotatePosition(-speed, 0);
14094
- else
1409514486 manipCamera.Translate(-speed*delta, 0, getWidth());
14096
- */
14487
+ else
14488
+ manipCamera.RotatePosition(-speed, 0);
14489
+ /**/
1409714490 if ((mod & SHIFT) == SHIFT)
1409814491 {
1409914492 mouseMode = mouseMode;
....@@ -14111,7 +14504,7 @@
1411114504 int X, Y;
1411214505 boolean SX, SY;
1411314506
14114
- void drag(int x, int y, int modifiers)
14507
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514508 {
1411614509 if (IsFrozen())
1411714510 {
....@@ -14120,17 +14513,17 @@
1412014513
1412114514 drag = true; // NEW
1412214515
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14516
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414517
1412514518 X = x;
1412614519 Y = y;
1412714520 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14521
+ MODIFIERS = modifiersex;
14522
+ modifiersex &= ~1024;
1413014523 if (false) // modifiers != 0)
1413114524 {
1413214525 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14526
+ System.out.println("mouseDragged: " + modifiersex);
1413414527 System.out.println("SHIFT = " + SHIFT);
1413514528 System.out.println("CONTROL = " + COMMAND);
1413614529 System.out.println("META = " + META);
....@@ -14150,7 +14543,8 @@
1415014543 info.camera = renderCamera;
1415114544 info.x = x;
1415214545 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14546
+ object.GetWindow().copy
14547
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414548 } else
1415514549 {
1415614550 if (x < startX)
....@@ -14314,7 +14708,9 @@
1431414708 ci.camera = renderCamera;
1431514709 if (!isRenderer)
1431614710 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14711
+ //ObjEditor editWindow = object.editWindow;
14712
+ //Object3D copy = editWindow.copy;
14713
+ if (object.doEditClick(ci, 0))
1431814714 {
1431914715 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014716 } else
....@@ -14326,7 +14722,11 @@
1432614722
1432714723 public void mouseReleased(MouseEvent e)
1432814724 {
14725
+ Globals.MOUSEDRAGGED = false;
14726
+
1432914727 movingcamera = false;
14728
+ X = 0; // getBounds().width/2;
14729
+ Y = 0; // getBounds().height/2;
1433014730 //System.out.println("mouseReleased: " + e);
1433114731 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214732 }
....@@ -14349,9 +14749,9 @@
1434914749 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014750 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114751
14352
- if (control || command || IsFrozen())
14752
+// No delay if (control || command || IsFrozen())
1435314753 timeout = true;
14354
- else
14754
+// ?? May 2019 else
1435514755 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614756 mouseDown = false;
1435714757 if (!control && !command) // june 2013
....@@ -14461,7 +14861,7 @@
1446114861 System.out.println("keyReleased: " + e);
1446214862 }
1446314863
14464
- void SetMouseMode(int modifiers)
14864
+ void SetMouseMode(int modifiers, int modifiersex)
1446514865 {
1446614866 //System.out.println("SetMouseMode = " + modifiers);
1446714867 //modifiers &= ~1024;
....@@ -14473,25 +14873,25 @@
1447314873 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414874 // return;
1447514875 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14876
+ if ((modifiersex & WHEEL) == WHEEL)
1447714877 {
1447814878 mouseMode |= ZOOM;
1447914879 }
1448014880
1448114881 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14882
+ if (capsLocked) // || (modifiers & META) == META)
1448314883 {
1448414884 mouseMode |= VR; // BACKFORTH;
1448514885 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14886
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714887 {
1448814888 mouseMode |= SELECT;
1448914889 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14890
+ if ((modifiersex & COMMAND) == COMMAND)
1449114891 {
1449214892 mouseMode |= SELECT;
1449314893 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14894
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514895 {
1449614896 mouseMode &= ~VR;
1449714897 mouseMode |= TRANSLATE;
....@@ -14520,7 +14920,7 @@
1452014920
1452114921 if (isRenderer) //
1452214922 {
14523
- SetMouseMode(modifiers);
14923
+ SetMouseMode(0, modifiers);
1452414924 }
1452514925
1452614926 Globals.theRenderer.keyPressed(key);
....@@ -14582,7 +14982,8 @@
1458214982 // break;
1458314983 case 'T':
1458414984 CACHETEXTURE ^= true;
14585
- textures.clear();
14985
+ texturepigment.clear();
14986
+ texturebump.clear();
1458614987 // repaint();
1458714988 break;
1458814989 case 'Y':
....@@ -14667,7 +15068,9 @@
1466715068 case 'E' : COMPACT ^= true;
1466815069 repaint();
1466915070 break;
14670
- case 'W' : DEBUGHSB ^= true;
15071
+ case 'W' : // Wide Window (fullscreen)
15072
+ //DEBUGHSB ^= true;
15073
+ ObjEditor.theFrame.ToggleFullScreen();
1467115074 repaint();
1467215075 break;
1467315076 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14692,8 +15095,8 @@
1469215095 RevertCamera();
1469315096 repaint();
1469415097 break;
14695
- case 'L':
1469615098 case 'l':
15099
+ //case 'L':
1469715100 if (lightMode)
1469815101 {
1469915102 lightMode = false;
....@@ -14836,9 +15239,9 @@
1483615239 case '_':
1483715240 kompactbit = 5;
1483815241 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15242
+// case '+':
15243
+// kompactbit = 6;
15244
+// break;
1484215245 case ' ':
1484315246 lightMode ^= true;
1484415247 Globals.lighttouched = true;
....@@ -14850,13 +15253,14 @@
1485015253 case ESC:
1485115254 RENDERPROGRAM += 1;
1485215255 RENDERPROGRAM %= 3;
15256
+
1485315257 repaint();
1485415258 break;
1485515259 case 'Z':
1485615260 //RESIZETEXTURE ^= true;
1485715261 //break;
1485815262 case 'z':
14859
- RENDERSHADOW ^= true;
15263
+ Globals.RENDERSHADOW ^= true;
1486015264 Globals.lighttouched = true;
1486115265 repaint();
1486215266 break;
....@@ -14889,8 +15293,9 @@
1488915293 case DELETE:
1489015294 ClearSelection();
1489115295 break;
14892
- /*
1489315296 case '+':
15297
+
15298
+ /*
1489415299 //fontsize += 1;
1489515300 bbzoom *= 2;
1489615301 repaint();
....@@ -14907,17 +15312,17 @@
1490715312 case '=':
1490815313 IncDepth();
1490915314 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15315
+ object.GetWindow().refreshContents(true);
1491115316 maskbit = 6;
1491215317 break;
1491315318 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415319 DecDepth();
1491515320 maskbit = 5;
1491615321 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15322
+// if (object.editWindow == null)
15323
+// new Exception().printStackTrace();
15324
+// else
15325
+ object.GetWindow().refreshContents(true);
1492115326 break;
1492215327 case '{':
1492315328 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15385,7 @@
1498015385 //mode = ROTATE;
1498115386 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215387 {
14983
- SetMouseMode(modifiers);
15388
+ SetMouseMode(0, modifiers);
1498415389 }
1498515390 }
1498615391
....@@ -15116,7 +15521,7 @@
1511615521 {
1511715522 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815523 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15524
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1512015525 {
1512115526 mouseMoved(e);
1512215527 } else
....@@ -15141,7 +15546,7 @@
1514115546 }
1514215547 */
1514315548
15144
- object.editWindow.EditSelection();
15549
+ object.GetWindow().EditSelection(false);
1514515550 }
1514615551
1514715552 void SelectParent()
....@@ -15158,10 +15563,10 @@
1515815563 {
1515915564 //selectees.remove(i);
1516015565 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15566
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215567 } else
1516315568 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15569
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515570 }
1516615571
1516715572 first = false;
....@@ -15203,12 +15608,12 @@
1520315608 for (int j = 0; j < group.children.size(); j++)
1520415609 {
1520515610 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15611
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715612 first = false;
1520815613 }
1520915614 } else
1521015615 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15616
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215617 }
1521315618
1521415619 first = false;
....@@ -15219,21 +15624,21 @@
1521915624 {
1522015625 //Composite group = (Composite) object;
1522115626 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15627
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315628 }
1522415629
1522515630 void ResetTransform(int mask)
1522615631 {
1522715632 //Composite group = (Composite) object;
1522815633 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15634
+ group.GetWindow().ResetTransform(mask);
1523015635 }
1523115636
1523215637 void FlipTransform()
1523315638 {
1523415639 //Composite group = (Composite) object;
1523515640 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15641
+ group.GetWindow().FlipTransform();
1523715642 // group.editWindow.ReduceMesh(true);
1523815643 }
1523915644
....@@ -15241,7 +15646,7 @@
1524115646 {
1524215647 //Composite group = (Composite) object;
1524315648 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15649
+ group.GetWindow().PrintMemory();
1524515650 // group.editWindow.ReduceMesh(true);
1524615651 }
1524715652
....@@ -15249,7 +15654,7 @@
1524915654 {
1525015655 //Composite group = (Composite) object;
1525115656 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15657
+ group.GetWindow().ResetCentroid();
1525315658 }
1525415659
1525515660 void IncDepth()
....@@ -15335,7 +15740,9 @@
1533515740 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615741 //Image img = CreateImage(width, height);
1533715742 //System.out.println("width = " + width + "; height = " + height + "\n");
15743
+
1533815744 Graphics gr = g; // img.getGraphics();
15745
+
1533915746 if (!hasMarquee)
1534015747 {
1534115748 if (Xmin < Xmax) // !locked)
....@@ -15423,6 +15830,7 @@
1542315830 info.bounds.y += (height - desired) / 2;
1542415831 }
1542515832 }
15833
+
1542615834 info.g = gr;
1542715835 info.camera = renderCamera;
1542815836 /*
....@@ -15432,15 +15840,55 @@
1543215840 */
1543315841 if (!isRenderer)
1543415842 {
15435
- 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
+ }
1543615882 }
1543715883 }
15884
+
1543815885 if (isRenderer)
1543915886 {
1544015887 //gr.setColor(Color.black);
1544115888 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215889 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315890 }
15891
+
1544415892 if (hasMarquee)
1544515893 {
1544615894 gr.setXORMode(Color.white);
....@@ -15553,6 +16001,7 @@
1555316001 public boolean mouseDown(Event evt, int x, int y)
1555416002 {
1555516003 System.out.println("mouseDown: " + evt);
16004
+ System.exit(0);
1555616005 /*
1555716006 locked = true;
1555816007 drag = false;
....@@ -15596,7 +16045,7 @@
1559616045 {
1559716046 keyPressed(0, modifiers);
1559816047 }
15599
- clickStart(x, y, modifiers);
16048
+ // clickStart(x, y, modifiers);
1560016049 return true;
1560116050 }
1560216051
....@@ -15714,7 +16163,7 @@
1571416163 {
1571516164 keyReleased(0, 0);
1571616165 }
15717
- drag(x, y, modifiers);
16166
+ drag(x, y, 0, modifiers);
1571816167 return true;
1571916168 }
1572016169
....@@ -15846,7 +16295,7 @@
1584616295 Object3D object;
1584716296 static Object3D trackedobject;
1584816297 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16298
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016299 /*static*/ Camera eyeCamera;
1585116300 /*static*/ Camera lightCamera;
1585216301 int cameracount;
....@@ -16131,16 +16580,16 @@
1613116580 cStatic.objectstack[materialdepth++] = checker;
1613216581 //System.out.println("material " + material);
1613316582 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16583
+ //vector2buffer = checker.projectedVertices;
1613516584
1613616585 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16586
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816587
1613916588 materialdepth -= 1;
1614016589 if (materialdepth > 0)
1614116590 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- 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);
1614416593 }
1614516594 //checker.GetMaterial().opacity = 1f;
1614616595 ////checker.GetMaterial().ambient = 1f;
....@@ -16226,6 +16675,14 @@
1622616675 }
1622716676 }
1622816677
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
+
1622916686 class SelectBuffer implements GLEventListener
1623016687 {
1623116688
....@@ -16305,6 +16762,17 @@
1630516762
1630616763 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630716764
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
+
1630816776 //int tmp = selection_view;
1630916777 //selection_view = -1;
1631016778 int temp = DrawMode();
....@@ -16316,6 +16784,17 @@
1631616784 // temp = DEFAULT; // patch for selection debug
1631716785 Globals.drawMode = temp; // WARNING
1631816786
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
+
1631916798 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632016799
1632116800 // trying different ways of getting the depth info over
....@@ -16363,6 +16842,8 @@
1636316842 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1636416843 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516844 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16845
+
16846
+ CreateSelectedPoint();
1636616847
1636716848 // Will fit the mesh !!!
1636816849 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16412,34 +16893,36 @@
1641216893 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]));
1641316894 }
1641416895
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16896
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616897 }
1641716898 }
1641816899
1641916900 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16901
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116902
16422
- 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)
1642316904 {
16424
- 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);
1642516906
16426
- Object3D group = new Object3D("inst" + paintcount++);
16907
+ if (object.GetWindow().copy.selection.Size() > 0)
16908
+ {
16909
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642716910
16428
- group.CreateMaterial(); // use a void leaf to select instances
16429
-
16430
- group.add(paintobj); // link
16431
-
16432
- object.editWindow.SnapObject(group);
16433
-
16434
- Object3D folder = object.editWindow.copy;
16435
-
16436
- if (object.editWindow.copy.selection.Size() > 0)
16437
- folder = object.editWindow.copy.selection.elementAt(0);
16438
-
16439
- folder.add(group);
16440
-
16441
- object.editWindow.ResetModel();
16442
- object.editWindow.refreshContents();
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
+ }
1644316926 }
1644416927 else
1644516928 paintcount = 0;
....@@ -16478,6 +16961,11 @@
1647816961 //System.out.println("objects[color] = " + objects[color]);
1647916962 //objects[color].Select();
1648016963 indexcount = 0;
16964
+ ObjEditor window = object.GetWindow();
16965
+ if (window != null && deselect)
16966
+ {
16967
+ window.Select(null, deselect, true);
16968
+ }
1648116969 object.Select(color, deselect);
1648216970 }
1648316971
....@@ -16577,7 +17065,7 @@
1657717065 gl.glDisable(gl.GL_CULL_FACE);
1657817066 }
1657917067
16580
- if (!RENDERSHADOW)
17068
+ if (!Globals.RENDERSHADOW)
1658117069 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658217070
1658317071 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +17075,7 @@
1658717075 //gl.glColorMask(false, false, false, false);
1658817076
1658917077 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17078
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659117079 {
1659217080 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659317081
....@@ -17003,23 +17491,15 @@
1700317491 int AAbuffersize = 0;
1700417492
1700517493 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17494
+ static Superellipsoid selectedpoint;
1700717495 static Sphere previousselectedpoint = null;
17008
- static Sphere debugpointG = new Sphere();
17009
- static Sphere debugpointP = new Sphere();
17010
- static Sphere debugpointC = new Sphere();
17011
- static Sphere debugpointR = new Sphere();
17496
+ static Sphere debugpointG;
17497
+ static Sphere debugpointP;
17498
+ static Sphere debugpointC;
17499
+ static Sphere debugpointR;
1701217500
1701317501 static Sphere debugpoints[] = new Sphere[8];
1701417502
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317503 static void InitPoints(float radius)
1702417504 {
1702517505 for (int i=0; i<8; i++)