Normand Briere
2019-07-23 cf7cfa1c792eebba606a48aa648893f6e4873263
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -37,7 +41,6 @@
3741 static boolean[] selectedstack = new boolean[65536];
3842 static int materialdepth = 0;
3943
40
- static boolean DEBUG = false;
4144 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4245
4346 // camera change fix
....@@ -45,6 +48,39 @@
4548 static boolean ABORTED = false;
4649
4750 static int STEP = 1;
51
+
52
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
53
+ {
54
+ int[] pixels = new int[bytes.length/3];
55
+ for (int i=pixels.length; --i>=0;)
56
+ {
57
+ int i3 = i*3;
58
+ pixels[i] = 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3+2] & 0xFF;
61
+ pixels[i] <<= 8;
62
+ pixels[i] |= bytes[i3+1] & 0xFF;
63
+ pixels[i] <<= 8;
64
+ pixels[i] |= bytes[i3] & 0xFF;
65
+ }
66
+ /*
67
+ int r=0,g=0,b=0,a=0;
68
+ for (int i=0; i<width; i++)
69
+ for (int j=0; j<height; j++)
70
+ {
71
+ int index = j*width+i;
72
+ int p = pixels[index];
73
+ a = ((p>>24) & 0xFF);
74
+ r = ((p>>16) & 0xFF);
75
+ g = ((p>>8) & 0xFF);
76
+ b = (p & 0xFF);
77
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
78
+ }
79
+ /**/
80
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
81
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
82
+ return rendImage;
83
+ }
4884
4985 /*static*/ private boolean CULLFACE = false; // true;
5086 /*static*/ boolean NEAREST = false; // true;
....@@ -61,7 +97,7 @@
6197 //boolean REDUCETEXTURE = true;
6298 boolean CACHETEXTURE = true;
6399 boolean CLEANCACHE = false; // true;
64
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
65101 boolean COMPRESSTEXTURE = false;
66102 boolean KOMPACTTEXTURE = false; // true;
67103 boolean RESIZETEXTURE = false;
....@@ -149,6 +185,8 @@
149185 defaultcaps.setAccumBlueBits(16);
150186 defaultcaps.setAccumAlphaBits(16);
151187 }
188
+
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
152190
153191 void SetAsGLRenderer(boolean b)
154192 {
....@@ -325,7 +363,7 @@
325363 cStatic.objectstack[materialdepth++] = obj;
326364 //System.out.println("material " + material);
327365 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
366
+ //display.vector2buffer = obj.projectedVertices;
329367 if (obj instanceof Camera)
330368 {
331369 display.options1[0] = material.shift;
....@@ -334,14 +372,28 @@
334372 display.options1[2] = material.shadowbias;
335373 display.options1[3] = material.aniso;
336374 display.options1[4] = material.anisoV;
375
+// System.out.println("display.options1[0] " + display.options1[0]);
376
+// System.out.println("display.options1[1] " + display.options1[1]);
377
+// System.out.println("display.options1[2] " + display.options1[2]);
378
+// System.out.println("display.options1[3] " + display.options1[3]);
379
+// System.out.println("display.options1[4] " + display.options1[4]);
337380 display.options2[0] = material.opacity;
338381 display.options2[1] = material.diffuse;
339382 display.options2[2] = material.factor;
383
+// System.out.println("display.options2[0] " + display.options2[0]);
384
+// System.out.println("display.options2[1] " + display.options2[1]);
385
+// System.out.println("display.options2[2] " + display.options2[2]);
340386
341387 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
388
+// System.out.println("display.options3[0] " + display.options3[0]);
389
+// System.out.println("display.options3[1] " + display.options3[1]);
390
+// System.out.println("display.options3[2] " + display.options3[2]);
342391 display.options4[0] = material.cameralight/0.2f;
343392 display.options4[1] = material.subsurface;
344393 display.options4[2] = material.sheen;
394
+// System.out.println("display.options4[0] " + display.options4[0]);
395
+// System.out.println("display.options4[1] " + display.options4[1]);
396
+// System.out.println("display.options4[2] " + display.options4[2]);
345397
346398 // if (display.CURRENTANTIALIAS > 0)
347399 // display.options3[3] /= 4;
....@@ -357,7 +409,7 @@
357409 /**/
358410 } else
359411 {
360
- DrawMaterial(material, selected);
412
+ DrawMaterial(material, selected, obj.projectedVertices);
361413 }
362414 } else
363415 {
....@@ -381,8 +433,8 @@
381433 cStatic.objectstack[materialdepth++] = obj;
382434 //System.out.println("material " + material);
383435 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
436
+ //display.vector2buffer = obj.projectedVertices;
437
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386438 }
387439 }
388440
....@@ -399,8 +451,8 @@
399451 materialdepth -= 1;
400452 if (materialdepth > 0)
401453 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
454
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
455
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
404456 }
405457 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406458 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +472,8 @@
420472 materialdepth -= 1;
421473 if (materialdepth > 0)
422474 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
475
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
476
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
425477 }
426478 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427479 //else
....@@ -462,10 +514,12 @@
462514 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463515 {
464516 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
517
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
518
+ // TEST LIVE NORMALS && !obj.dontselect
519
+ ;
466520 if (!hasnorm)
467521 {
468
- // System.out.println("FUCK!!");
522
+ // System.out.println("Mesh normal");
469523 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470524 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471525 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1244,12 @@
11901244 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911245 }
11921246 }
1247
+
11931248 if (flipV)
11941249 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951250 else
11961251 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1252
+
11971253 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981254 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991255
....@@ -1213,10 +1269,12 @@
12131269 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141270 }
12151271 }
1272
+
12161273 if (flipV)
12171274 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181275 else
12191276 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1277
+
12201278 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211279 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221280
....@@ -1244,8 +1302,10 @@
12441302 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451303 else
12461304 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1305
+
12471306 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481307 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1308
+
12491309 count2 += 2;
12501310 count3 += 3;
12511311 }
....@@ -1601,7 +1661,7 @@
16011661 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021662 }
16031663
1604
- void DrawMaterial(cMaterial material, boolean selected)
1664
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051665 {
16061666 CameraPane display = this;
16071667 //new Exception().printStackTrace();
....@@ -1628,7 +1688,7 @@
16281688
16291689 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301690
1631
- float[] colorV = GrafreeD.colorV;
1691
+ float[] colorV = Grafreed.colorV;
16321692
16331693 /**/
16341694 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1696,7 @@
16361696 colorV[0] = display.modelParams0[0] * material.diffuse;
16371697 colorV[1] = display.modelParams0[1] * material.diffuse;
16381698 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1699
+ colorV[3] = 1; // material.opacity;
16401700
16411701 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421702 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1804,9 @@
17441804 display.modelParams7[2] = 0;
17451805 display.modelParams7[3] = 0;
17461806
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1807
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481808
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1809
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501810 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511811 {
17521812 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1948,7 @@
18881948 void PushMatrix(double[][] matrix)
18891949 {
18901950 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1951
+ PushMatrix(matrix, 1);
18921952 }
18931953
18941954 void PushMatrix()
....@@ -2042,7 +2102,7 @@
20422102 //System.err.println("Oeil on");
20432103 OEIL = true;
20442104 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2105
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462106 //pingthread.StepToTarget(true);
20472107 }
20482108
....@@ -2140,7 +2200,7 @@
21402200 System.err.println("LIVE = " + Globals.isLIVE());
21412201
21422202 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2203
+ Grafreed.savesound = true; // wav.save();
21442204 // else
21452205 repaint(); // start loop // may 2013
21462206 }
....@@ -2257,7 +2317,7 @@
22572317
22582318 void ToggleDebug()
22592319 {
2260
- DEBUG ^= true;
2320
+ Globals.DEBUG ^= true;
22612321 }
22622322
22632323 void ToggleLookAt()
....@@ -2265,7 +2325,7 @@
22652325 LOOKAT ^= true;
22662326 }
22672327
2268
- void ToggleRandom()
2328
+ void ToggleSwitch()
22692329 {
22702330 SWITCH ^= true;
22712331 }
....@@ -2275,10 +2335,17 @@
22752335 HANDLES ^= true;
22762336 }
22772337
2338
+ Object3D paintFolder;
2339
+
22782340 void TogglePaint()
22792341 {
22802342 PAINTMODE ^= true;
22812343 paintcount = 0;
2344
+
2345
+ if (PAINTMODE)
2346
+ {
2347
+ paintFolder = GetFolder();
2348
+ }
22822349 }
22832350
22842351 void SwapCamera(int a, int b)
....@@ -2374,7 +2441,22 @@
23742441 {
23752442 return currentGL;
23762443 }
2377
-
2444
+
2445
+ static private BufferedImage CreateBim(TextureData texturedata)
2446
+ {
2447
+ Grafreed.Assert(texturedata != null);
2448
+
2449
+ int width = texturedata.getWidth();
2450
+ int height = texturedata.getHeight();
2451
+
2452
+ Buffer buffer = texturedata.getBuffer();
2453
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2454
+
2455
+ byte[] bytes = bytebuf.array();
2456
+
2457
+ return CreateBim(bytes, width, height);
2458
+ }
2459
+
23782460 /**/
23792461 class CacheTexture
23802462 {
....@@ -2383,28 +2465,31 @@
23832465
23842466 int resolution;
23852467
2386
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2468
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23872469 {
2388
- texture = tex;
2470
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2471
+ texturedata = texdata;
23892472 resolution = res;
23902473 }
23912474 }
23922475 /**/
23932476
23942477 // 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>();
2478
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2481
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2482
+
23982483 int pigmentdepth = 0;
23992484 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24002485 int bumpdepth = 0;
24012486 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24022487 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24032488 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2404
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2489
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24052490 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24062491
2407
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2492
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24082493 {
24092494 TextureData texturedata = null;
24102495
....@@ -2423,13 +2508,34 @@
24232508 if (bump)
24242509 texturedata = ConvertBump(texturedata, false);
24252510
2426
- com.sun.opengl.util.texture.Texture texture =
2427
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2511
+// com.sun.opengl.util.texture.Texture texture =
2512
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24282513
2429
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2430
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2514
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24312516
2432
- return texture;
2517
+ return texturedata;
2518
+ }
2519
+
2520
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2521
+ {
2522
+ TextureData texturedata = null;
2523
+
2524
+ try
2525
+ {
2526
+ texturedata =
2527
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2528
+ bim,
2529
+ true);
2530
+ } catch (Exception e)
2531
+ {
2532
+ throw new javax.media.opengl.GLException(e);
2533
+ }
2534
+
2535
+ if (bump)
2536
+ texturedata = ConvertBump(texturedata, false);
2537
+
2538
+ return texturedata;
24332539 }
24342540
24352541 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3502,6 +3608,8 @@
35023608
35033609 System.out.println("LOADING TEXTURE : " + name);
35043610
3611
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3612
+
35053613 //
35063614 if (false) // compressbit > 0)
35073615 {
....@@ -7900,7 +8008,7 @@
79008008 String pigment = Object3D.GetPigment(tex);
79018009 String bump = Object3D.GetBump(tex);
79028010
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8011
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79048012 {
79058013 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79068014 // System.out.println("; bump = " + bump);
....@@ -7915,11 +8023,69 @@
79158023 pigment = null;
79168024 }
79178025
7918
- ReleaseTexture(bump, true);
7919
- ReleaseTexture(pigment, false);
8026
+ ReleaseTexture(tex, true);
8027
+ ReleaseTexture(tex, false);
79208028 }
79218029
7922
- void ReleaseTexture(String tex, boolean bump)
8030
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8031
+ {
8032
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8033
+ {
8034
+ return;
8035
+ }
8036
+
8037
+ if (tex == null)
8038
+ {
8039
+ ReleaseTexture(null, false);
8040
+ return;
8041
+ }
8042
+
8043
+ String pigment = Object3D.GetPigment(tex);
8044
+
8045
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8046
+ {
8047
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8048
+ // System.out.println("; bump = " + bump);
8049
+ }
8050
+
8051
+ if (pigment.equals(""))
8052
+ {
8053
+ pigment = null;
8054
+ }
8055
+
8056
+ ReleaseTexture(tex, false);
8057
+ }
8058
+
8059
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8060
+ {
8061
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8062
+ {
8063
+ return;
8064
+ }
8065
+
8066
+ if (tex == null)
8067
+ {
8068
+ ReleaseTexture(null, true);
8069
+ return;
8070
+ }
8071
+
8072
+ String bump = Object3D.GetBump(tex);
8073
+
8074
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8075
+ {
8076
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8077
+ // System.out.println("; bump = " + bump);
8078
+ }
8079
+
8080
+ if (bump.equals(""))
8081
+ {
8082
+ bump = null;
8083
+ }
8084
+
8085
+ ReleaseTexture(tex, true);
8086
+ }
8087
+
8088
+ void ReleaseTexture(cTexture tex, boolean bump)
79238089 {
79248090 if (// DrawMode() != 0 || /*tex == null ||*/
79258091 ambientOcclusion ) // || !textureon)
....@@ -7930,7 +8096,7 @@
79308096 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79318097
79328098 if (tex != null)
7933
- texture = textures.get(tex);
8099
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79348100
79358101 // //assert( texture != null );
79368102 // if (texture == null)
....@@ -8022,7 +8188,55 @@
80228188 }
80238189 }
80248190
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8191
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8192
+ {
8193
+// if (// DrawMode() != 0 || /*tex == null ||*/
8194
+// ambientOcclusion ) // || !textureon)
8195
+// {
8196
+// return; // false;
8197
+// }
8198
+//
8199
+// if (tex == null)
8200
+// {
8201
+// BindTexture(null,false,resolution);
8202
+// BindTexture(null,true,resolution);
8203
+// return;
8204
+// }
8205
+//
8206
+// String pigment = Object3D.GetPigment(tex);
8207
+// String bump = Object3D.GetBump(tex);
8208
+//
8209
+// usedtextures.add(pigment);
8210
+// usedtextures.add(bump);
8211
+//
8212
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8213
+// {
8214
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8215
+// // System.out.println("; bump = " + bump);
8216
+// }
8217
+//
8218
+// if (bump.equals(""))
8219
+// {
8220
+// bump = null;
8221
+// }
8222
+// if (pigment.equals(""))
8223
+// {
8224
+// pigment = null;
8225
+// }
8226
+//
8227
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8228
+// BindTexture(pigment, false, resolution);
8229
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8230
+// BindTexture(bump, true, resolution);
8231
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8232
+//
8233
+// return; // true;
8234
+
8235
+ BindPigmentTexture(tex, resolution);
8236
+ BindBumpTexture(tex, resolution);
8237
+ }
8238
+
8239
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80268240 {
80278241 if (// DrawMode() != 0 || /*tex == null ||*/
80288242 ambientOcclusion ) // || !textureon)
....@@ -8033,17 +8247,47 @@
80338247 if (tex == null)
80348248 {
80358249 BindTexture(null,false,resolution);
8036
- BindTexture(null,true,resolution);
80378250 return;
80388251 }
80398252
80408253 String pigment = Object3D.GetPigment(tex);
8254
+
8255
+ usedtextures.add(tex);
8256
+
8257
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8258
+ {
8259
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8260
+ // System.out.println("; bump = " + bump);
8261
+ }
8262
+
8263
+ if (pigment.equals(""))
8264
+ {
8265
+ pigment = null;
8266
+ }
8267
+
8268
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8269
+ BindTexture(tex, false, resolution);
8270
+ }
8271
+
8272
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8273
+ {
8274
+ if (// DrawMode() != 0 || /*tex == null ||*/
8275
+ ambientOcclusion ) // || !textureon)
8276
+ {
8277
+ return; // false;
8278
+ }
8279
+
8280
+ if (tex == null)
8281
+ {
8282
+ BindTexture(null,true,resolution);
8283
+ return;
8284
+ }
8285
+
80418286 String bump = Object3D.GetBump(tex);
80428287
8043
- usedtextures.put(pigment, pigment);
8044
- usedtextures.put(bump, bump);
8288
+ usedtextures.add(tex);
80458289
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8290
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478291 {
80488292 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498293 // System.out.println("; bump = " + bump);
....@@ -8053,47 +8297,94 @@
80538297 {
80548298 bump = null;
80558299 }
8056
- if (pigment.equals(""))
8057
- {
8058
- pigment = null;
8059
- }
80608300
8061
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8062
- BindTexture(pigment, false, resolution);
80638301 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8064
- BindTexture(bump, true, resolution);
8302
+ BindTexture(tex, true, resolution);
80658303 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8066
-
8067
- return; // true;
80688304 }
80698305
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8306
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8307
+
8308
+ private boolean FileExists(String tex)
80718309 {
8072
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8310
+ if (missingTextures.contains(tex))
8311
+ {
8312
+ return false;
8313
+ }
8314
+
8315
+ boolean fileExists = new File(tex).exists();
8316
+
8317
+ if (!fileExists)
8318
+ {
8319
+ // If file exists, the "new File()" is not executed sgain
8320
+ missingTextures.add(tex);
8321
+ }
8322
+
8323
+ return fileExists;
8324
+ }
8325
+
8326
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8327
+ {
8328
+ CacheTexture texturecache = null;
80738329
80748330 if (tex != null)
80758331 {
8076
- String texname = tex;
8332
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8333
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80778334
8335
+ if (texname.equals("") && texdata == null)
8336
+ {
8337
+ return null;
8338
+ }
8339
+
8340
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8341
+
80788342 // String[] split = tex.split("Textures");
80798343 // if (split.length > 1)
80808344 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818345 // else
80828346 // if (!texname.startsWith("/"))
80838347 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8348
+ if (!FileExists(texname))
80858349 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8350
+ texname = fallbackTextureName;
80878351 }
80888352
80898353 if (CACHETEXTURE)
8090
- texture = textures.get(texname); // TEXTURE CACHE
8091
-
8092
- TextureData texturedata = null;
8093
-
8094
- if (texture == null || texture.resolution < resolution)
80958354 {
8096
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8355
+ if (texdata == null)
8356
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8357
+ else
8358
+ texturecache = bimtextures.get(texdata);
8359
+ }
8360
+
8361
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8362
+ {
8363
+ TextureData texturedata = null;
8364
+
8365
+ if (texdata != null && textureon)
8366
+ {
8367
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8368
+
8369
+ try
8370
+ {
8371
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8372
+ }
8373
+ catch (Exception e)
8374
+ {
8375
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8376
+ }
8377
+
8378
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8379
+ bimtextures.put(texdata, texturecache);
8380
+
8381
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8382
+
8383
+ //Object bim2 = CreateBim(texturecache.texturedata);
8384
+ //bim2 = bim;
8385
+ }
8386
+ else
8387
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80978388 {
80988389 assert(!bump);
80998390 // if (bump)
....@@ -8104,19 +8395,23 @@
81048395 // }
81058396 // else
81068397 // {
8107
- texture = textures.get(tex);
8108
- if (texture == null)
8398
+ // texturecache = textures.get(texname); // suspicious
8399
+ if (texturecache == null)
81098400 {
8110
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8401
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81118402 }
8403
+ else
8404
+ new Exception().printStackTrace();
81128405 // }
81138406 } else
8114
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8407
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81158408 {
81168409 assert(bump);
8117
- texture = textures.get(tex);
8118
- if (texture == null)
8119
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8410
+ // texturecache = textures.get(texname); // suspicious
8411
+ if (texturecache == null)
8412
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8413
+ else
8414
+ new Exception().printStackTrace();
81208415 } else
81218416 {
81228417 //if (tex.equals("IMMORTAL"))
....@@ -8124,11 +8419,13 @@
81248419 // texture = GetResourceTexture("default.png");
81258420 //} else
81268421 //{
8127
- if (tex.equals("WHITE_NOISE"))
8422
+ if (texname.endsWith("WHITE_NOISE"))
81288423 {
8129
- texture = textures.get(tex);
8130
- if (texture == null)
8131
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8424
+ // texturecache = textures.get(texname); // suspicious
8425
+ if (texturecache == null)
8426
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8427
+ else
8428
+ new Exception().printStackTrace();
81328429 } else
81338430 {
81348431 if (textureon)
....@@ -8153,7 +8450,7 @@
81538450 }
81548451
81558452 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8453
+ if (!FileExists(cachename))
81578454 cachename = texname;
81588455 else
81598456 processbump = false; // don't process bump map again
....@@ -8175,7 +8472,7 @@
81758472 }
81768473
81778474 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8475
+ if (!FileExists(cachename))
81798476 cachename = texname;
81808477 else
81818478 processbump = false; // don't process bump map again
....@@ -8184,20 +8481,22 @@
81848481 texturedata = GetFileTexture(cachename, processbump, resolution);
81858482
81868483
8187
- if (texturedata != null)
8188
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8484
+ if (texturedata == null)
8485
+ throw new Exception();
8486
+
8487
+ texturecache = new CacheTexture(texturedata,resolution);
81898488 //texture = GetTexture(tex, bump);
81908489 }
81918490 }
81928491 //}
81938492 }
81948493
8195
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8494
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81968495 {
81978496 //return false;
81988497
81998498 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8200
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8499
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82018500 {
82028501 // String ext = "_highres";
82038502 // if (REDUCETEXTURE)
....@@ -8214,52 +8513,17 @@
82148513 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82158514 if (!cachefile.exists())
82168515 {
8217
- // cache to disk
8218
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8219
- //buffers[0].
8220
-
8221
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8222
- int[] pixels = new int[bytebuf.capacity()/3];
8223
-
8224
- // squared size heuristic...
8225
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8516
+ //if (texturedata.getWidth() == texturedata.getHeight())
82268517 {
8227
- for (int i=pixels.length; --i>=0;)
8228
- {
8229
- int i3 = i*3;
8230
- pixels[i] = 0xFF;
8231
- pixels[i] <<= 8;
8232
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8233
- pixels[i] <<= 8;
8234
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8235
- pixels[i] <<= 8;
8236
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8237
- }
8238
-
8239
- /*
8240
- int r=0,g=0,b=0,a=0;
8241
- for (int i=0; i<width; i++)
8242
- for (int j=0; j<height; j++)
8243
- {
8244
- int index = j*width+i;
8245
- int p = pixels[index];
8246
- a = ((p>>24) & 0xFF);
8247
- r = ((p>>16) & 0xFF);
8248
- g = ((p>>8) & 0xFF);
8249
- b = (p & 0xFF);
8250
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8251
- }
8252
- /**/
8253
- int width = (int)Math.sqrt(pixels.length); // squared
8254
- int height = width;
8255
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8256
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8518
+ BufferedImage rendImage = CreateBim(texturedata);
8519
+
82578520 ImageWriter writer = null;
82588521 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82598522 if (iter.hasNext()) {
82608523 writer = (ImageWriter)iter.next();
82618524 }
8262
- float compressionQuality = 0.9f;
8525
+
8526
+ float compressionQuality = 0.85f;
82638527 try
82648528 {
82658529 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8276,18 +8540,20 @@
82768540 }
82778541 }
82788542 }
8279
-
8543
+
8544
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8545
+
82808546 //System.out.println("Texture = " + tex);
8281
- if (textures.containsKey(texname))
8547
+ if (textures.containsKey(tex))
82828548 {
8283
- CacheTexture thetex = textures.get(texname);
8549
+ CacheTexture thetex = textures.get(tex);
82848550 thetex.texture.disable();
82858551 thetex.texture.dispose();
8286
- textures.remove(texname);
8552
+ textures.remove(tex);
82878553 }
82888554
8289
- texture.texturedata = texturedata;
8290
- textures.put(texname, texture);
8555
+ //texture.texturedata = texturedata;
8556
+ textures.put(tex, texturecache);
82918557
82928558 // newtex = true;
82938559 }
....@@ -8303,10 +8569,44 @@
83038569 }
83048570 }
83058571
8306
- return texture;
8572
+ return texturecache;
83078573 }
83088574
8309
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8575
+ static void EmbedTextures(cTexture tex)
8576
+ {
8577
+ if (tex.pigmentdata == null)
8578
+ {
8579
+ //String texname = Object3D.GetPigment(tex);
8580
+
8581
+ CacheTexture texturecache = texturepigment.get(tex);
8582
+
8583
+ if (texturecache != null)
8584
+ {
8585
+ tex.pw = texturecache.texturedata.getWidth();
8586
+ tex.ph = texturecache.texturedata.getHeight();
8587
+ tex.pigmentdata = //CompressJPEG(CreateBim
8588
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8589
+ ;
8590
+ //, tex.pw, tex.ph), 0.5f);
8591
+ }
8592
+ }
8593
+
8594
+ if (tex.bumpdata == null)
8595
+ {
8596
+ //String texname = Object3D.GetBump(tex);
8597
+
8598
+ CacheTexture texturecache = texturebump.get(tex);
8599
+
8600
+ if (texturecache != null)
8601
+ {
8602
+ tex.bw = texturecache.texturedata.getWidth();
8603
+ tex.bh = texturecache.texturedata.getHeight();
8604
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8605
+ }
8606
+ }
8607
+ }
8608
+
8609
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
83108610 {
83118611 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128612
....@@ -8324,21 +8624,21 @@
83248624 return texture!=null?texture.texture:null;
83258625 }
83268626
8327
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8627
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
83288628 {
83298629 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308630
83318631 return texture!=null?texture.texturedata:null;
83328632 }
83338633
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8634
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83358635 {
83368636 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378637 {
83388638 return false;
83398639 }
83408640
8341
- boolean newtex = false;
8641
+ //boolean newtex = false;
83428642
83438643 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83448644
....@@ -8370,9 +8670,75 @@
83708670 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83718671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83728672
8373
- return newtex;
8673
+ return true; // Warning: not used.
83748674 }
83758675
8676
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8677
+ {
8678
+ try
8679
+ {
8680
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8681
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8682
+ ImageWriter writer = writers.next();
8683
+
8684
+ ImageWriteParam param = writer.getDefaultWriteParam();
8685
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8686
+ param.setCompressionQuality(quality);
8687
+
8688
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8689
+ writer.setOutput(ios);
8690
+ writer.write(null, new IIOImage(image, null, null), param);
8691
+
8692
+ byte[] data = baos.toByteArray();
8693
+ writer.dispose();
8694
+ return data;
8695
+ }
8696
+ catch (Exception e)
8697
+ {
8698
+ e.printStackTrace();
8699
+ return null;
8700
+ }
8701
+ }
8702
+
8703
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8704
+ {
8705
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8706
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8707
+ ImageReader reader = writers.next();
8708
+
8709
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8710
+
8711
+ ImageReadParam param = reader.getDefaultReadParam();
8712
+ param.setDestination(bim);
8713
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8714
+
8715
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8716
+ reader.setInput(ios);
8717
+ BufferedImage bim2 = reader.read(0, param);
8718
+ reader.dispose();
8719
+
8720
+// WritableRaster raster = bim2.getRaster();
8721
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8722
+// byte[] bytes = data.getData();
8723
+//
8724
+// int[] pixels = new int[bytes.length/3];
8725
+// for (int i=pixels.length; --i>=0;)
8726
+// {
8727
+// int i3 = i*3;
8728
+// pixels[i] = 0xFF;
8729
+// pixels[i] <<= 8;
8730
+// pixels[i] |= bytes[i3+2] & 0xFF;
8731
+// pixels[i] <<= 8;
8732
+// pixels[i] |= bytes[i3+1] & 0xFF;
8733
+// pixels[i] <<= 8;
8734
+// pixels[i] |= bytes[i3] & 0xFF;
8735
+// }
8736
+//
8737
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8738
+
8739
+ return bim;
8740
+ }
8741
+
83768742 ShadowBuffer shadowPBuf;
83778743 AntialiasBuffer antialiasPBuf;
83788744 int MAXSTACK;
....@@ -9208,11 +9574,35 @@
92089574 jy8[3] = 0.5f;
92099575 }
92109576
9211
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9577
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92129578 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92139579 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92149580 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92159581
9582
+ void ResetOptions()
9583
+ {
9584
+ options1[0] = 100;
9585
+ options1[1] = 0.025f;
9586
+ options1[2] = 0.01f;
9587
+ options1[3] = 0;
9588
+ options1[4] = 0;
9589
+
9590
+ options2[0] = 0;
9591
+ options2[1] = 0.75f;
9592
+ options2[2] = 0;
9593
+ options2[3] = 0;
9594
+
9595
+ options3[0] = 1;
9596
+ options3[1] = 1;
9597
+ options3[2] = 1;
9598
+ options3[3] = 0;
9599
+
9600
+ options4[0] = 1;
9601
+ options4[1] = 0;
9602
+ options4[2] = 1;
9603
+ options4[3] = 0;
9604
+ }
9605
+
92169606 static int imagecount = 0; // movie generation
92179607
92189608 static int jitter = 0;
....@@ -9308,8 +9698,8 @@
93089698 assert (parentcam != renderCamera);
93099699
93109700 if (renderCamera != lightCamera)
9311
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9312
- LA.matConcat(matrix, parentcam.toParent, matrix);
9701
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93139703
93149704 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93159705
....@@ -9324,8 +9714,8 @@
93249714 LA.matCopy(renderCamera.fromScreen, matrix);
93259715
93269716 if (renderCamera != lightCamera)
9327
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9328
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9717
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93299719
93309720 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93319721
....@@ -9542,7 +9932,7 @@
95429932
95439933 if (!BOXMODE)
95449934 {
9545
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9935
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95469936 }
95479937
95489938 if (!BOXMODE)
....@@ -9580,7 +9970,7 @@
95809970 ABORTED = false;
95819971 }
95829972 else
9583
- GrafreeD.wav.cursor += 735 * ACSIZE;
9973
+ Grafreed.wav.cursor += 735 * ACSIZE;
95849974
95859975 if (false)
95869976 {
....@@ -10243,11 +10633,11 @@
1024310633
1024410634 public void display(GLAutoDrawable drawable)
1024510635 {
10246
- if (GrafreeD.savesound && GrafreeD.hassound)
10636
+ if (Grafreed.savesound && Grafreed.hassound)
1024710637 {
10248
- GrafreeD.wav.save();
10249
- GrafreeD.savesound = false;
10250
- GrafreeD.hassound = false;
10638
+ Grafreed.wav.save();
10639
+ Grafreed.savesound = false;
10640
+ Grafreed.hassound = false;
1025110641 }
1025210642 // if (DEBUG_SELECTION)
1025310643 // {
....@@ -10323,6 +10713,7 @@
1032310713 ANTIALIAS = 0;
1032410714 //System.out.println("RESTART");
1032510715 AAtimer.restart();
10716
+ Globals.TIMERRUNNING = true;
1032610717 }
1032710718 }
1032810719 }
....@@ -10377,7 +10768,7 @@
1037710768 Object3D theobject = object;
1037810769 Object3D theparent = object.parent;
1037910770 object.parent = null;
10380
- object = (Object3D)GrafreeD.clone(object);
10771
+ object = (Object3D)Grafreed.clone(object);
1038110772 object.Stripify();
1038210773 if (theobject.selection == null || theobject.selection.Size() == 0)
1038310774 theobject.PreprocessOcclusion(this);
....@@ -10390,13 +10781,14 @@
1039010781 ambientOcclusion = false;
1039110782 }
1039210783
10393
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10784
+ if (//Globals.lighttouched &&
10785
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039410786 {
1039510787 //if (RENDERSHADOW) // ?
1039610788 if (!IsFrozen())
1039710789 {
1039810790 // dec 2012
10399
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10791
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040010792 {
1040110793 Globals.framecount++;
1040210794 shadowbuffer.display();
....@@ -10523,8 +10915,8 @@
1052310915
1052410916 // if (parentcam != renderCamera) // not a light
1052510917 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(matrix, parentcam.toParent, matrix);
10918
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052810920
1052910921 for (int j = 0; j < 4; j++)
1053010922 {
....@@ -10538,8 +10930,8 @@
1053810930
1053910931 // if (parentcam != renderCamera) // not a light
1054010932 if (cam != lightCamera)
10541
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10542
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10933
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054310935
1054410936 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054510937
....@@ -10798,7 +11190,16 @@
1079811190 // Bump noise
1079911191 gl.glActiveTexture(GL.GL_TEXTURE6);
1080011192 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- BindTexture(NOISE_TEXTURE, false, 2);
11193
+
11194
+ try
11195
+ {
11196
+ BindTexture(NOISE_TEXTURE, false, 2);
11197
+ }
11198
+ catch (Exception e)
11199
+ {
11200
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11201
+ }
11202
+
1080211203
1080311204 gl.glActiveTexture(GL.GL_TEXTURE0);
1080411205 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10821,9 +11222,9 @@
1082111222
1082211223 gl.glMatrixMode(GL.GL_MODELVIEW);
1082311224
10824
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10825
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10826
-//gl.glEnable(gl.GL_MULTISAMPLE);
11225
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11226
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11227
+gl.glEnable(gl.GL_MULTISAMPLE);
1082711228 } else
1082811229 {
1082911230 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10834,7 +11235,7 @@
1083411235 //System.out.println("BLENDING ON");
1083511236 gl.glEnable(GL.GL_BLEND);
1083611237 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10837
-
11238
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083811239 gl.glMatrixMode(gl.GL_PROJECTION);
1083911240 gl.glLoadIdentity();
1084011241
....@@ -10923,8 +11324,8 @@
1092311324 System.err.println("parentcam != renderCamera");
1092411325
1092511326 // if (cam != lightCamera)
10926
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10927
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11327
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11328
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092811329 }
1092911330
1093011331 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10945,8 +11346,8 @@
1094511346 if (true) // TODO
1094611347 {
1094711348 if (cam != lightCamera)
10948
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10949
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11349
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11350
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1095011351 }
1095111352
1095211353 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11083,7 +11484,7 @@
1108311484 }
1108411485 }
1108511486
11086
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11487
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1108711488 {
1108811489 //gl.glDepthFunc(GL.GL_LEQUAL);
1108911490 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11091,24 +11492,21 @@
1109111492
1109211493 boolean texon = textureon;
1109311494
11094
- if (RENDERPROGRAM > 0)
11095
- {
11096
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11097
- textureon = false;
11098
- }
11495
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11496
+ textureon = false;
11497
+
1109911498 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1110011499 //System.out.println("ALLO");
1110111500 gl.glColorMask(false, false, false, false);
1110211501 DrawObject(gl);
11103
- if (RENDERPROGRAM > 0)
11104
- {
11105
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11106
- textureon = texon;
11107
- }
11502
+
11503
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11504
+ textureon = texon;
11505
+
1110811506 gl.glColorMask(true, true, true, true);
1110911507
1111011508 gl.glDepthFunc(GL.GL_EQUAL);
11111
- //gl.glDepthMask(false);
11509
+ gl.glDepthMask(false);
1111211510 }
1111311511
1111411512 if (false) // DrawMode() == SHADOW)
....@@ -11283,23 +11681,44 @@
1128311681 e.printStackTrace();
1128411682 }
1128511683
11286
- if (GrafreeD.RENDERME > 0)
11287
- GrafreeD.RENDERME--; // mechante magouille
11684
+ if (Grafreed.RENDERME > 0)
11685
+ Grafreed.RENDERME--; // mechante magouille
1128811686
1128911687 Globals.ONESTEP = false;
1129011688 }
1129111689
1129211690 static boolean zoomonce = false;
1129311691
11692
+ static void CreateSelectedPoint()
11693
+ {
11694
+ if (selectedpoint == null)
11695
+ {
11696
+ debugpointG = new Sphere();
11697
+ debugpointP = new Sphere();
11698
+ debugpointC = new Sphere();
11699
+ debugpointR = new Sphere();
11700
+
11701
+ selectedpoint = new Superellipsoid();
11702
+
11703
+ for (int i=0; i<8; i++)
11704
+ {
11705
+ debugpoints[i] = new Sphere();
11706
+ }
11707
+ }
11708
+ }
11709
+
1129411710 void DrawObject(GL gl, boolean draw)
1129511711 {
11712
+ // To clear camera values
11713
+ ResetOptions();
11714
+
1129611715 //System.out.println("DRAW OBJECT " + mouseDown);
1129711716 // DrawMode() = SELECTION;
1129811717 //GL gl = getGL();
1129911718 if ((TRACK || SHADOWTRACK) || zoomonce)
1130011719 {
1130111720 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11302
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11721
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1130311722 pingthread.StepToTarget(true); // true);
1130411723 // zoomonce = false;
1130511724 }
....@@ -11354,7 +11773,14 @@
1135411773
1135511774 usedtextures.clear();
1135611775
11357
- BindTextures(DEFAULT_TEXTURES, 2);
11776
+ try
11777
+ {
11778
+ BindTextures(DEFAULT_TEXTURES, 2);
11779
+ }
11780
+ catch (Exception e)
11781
+ {
11782
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11783
+ }
1135811784 }
1135911785 //System.out.println("--> " + stackdepth);
1136011786 // GrafreeD.traceon();
....@@ -11364,8 +11790,9 @@
1136411790
1136511791 if (DrawMode() == DEFAULT)
1136611792 {
11367
- if (DEBUG)
11793
+ if (Globals.DEBUG)
1136811794 {
11795
+ CreateSelectedPoint();
1136911796 float radius = 0.05f;
1137011797 if (selectedpoint.radius != radius)
1137111798 {
....@@ -11419,20 +11846,32 @@
1141911846 ReleaseTextures(DEFAULT_TEXTURES);
1142011847
1142111848 if (CLEANCACHE)
11422
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11849
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1142311850 {
11424
- String tex = e.nextElement();
11851
+ cTexture tex = e.nextElement();
1142511852
1142611853 // System.out.println("Texture --------- " + tex);
1142711854
11428
- if (tex.equals("WHITE_NOISE"))
11855
+ if (tex.equals("WHITE_NOISE:"))
1142911856 continue;
1143011857
11431
- if (!usedtextures.containsKey(tex))
11858
+ if (!usedtextures.contains(tex))
1143211859 {
11860
+ CacheTexture gettex = texturepigment.get(tex);
1143311861 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11434
- textures.get(tex).texture.dispose();
11435
- textures.remove(tex);
11862
+ if (gettex != null)
11863
+ {
11864
+ gettex.texture.dispose();
11865
+ texturepigment.remove(tex);
11866
+ }
11867
+
11868
+ gettex = texturebump.get(tex);
11869
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11870
+ if (gettex != null)
11871
+ {
11872
+ gettex.texture.dispose();
11873
+ texturebump.remove(tex);
11874
+ }
1143611875 }
1143711876 }
1143811877 }
....@@ -11445,7 +11884,14 @@
1144511884 if (checker != null && DrawMode() == DEFAULT)
1144611885 {
1144711886 //BindTexture(IMMORTAL_TEXTURE);
11448
- BindTextures(checker.GetTextures(), checker.texres);
11887
+ try
11888
+ {
11889
+ BindTextures(checker.GetTextures(), checker.texres);
11890
+ }
11891
+ catch (Exception e)
11892
+ {
11893
+ System.err.println("FAILED: " + checker.GetTextures());
11894
+ }
1144911895 // NEAREST
1145011896 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111897 DrawChecker(gl);
....@@ -11527,7 +11973,7 @@
1152711973 return;
1152811974 }
1152911975
11530
- String string = obj.GetToolTip();
11976
+ String string = obj.toString(); //.GetToolTip();
1153111977
1153211978 GL gl = GetGL();
1153311979
....@@ -11844,8 +12290,8 @@
1184412290 //obj.TransformToWorld(light, light);
1184512291 for (int i = tp.size(); --i >= 0;)
1184612292 {
11847
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11848
- LA.xformPos(light, tp.get(i).toParent, light);
12293
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12294
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184912295 }
1185012296
1185112297
....@@ -11862,8 +12308,8 @@
1186212308 parentcam = cameras[0];
1186312309 }
1186412310
11865
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11866
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12311
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12312
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186712313
1186812314 LA.xformPos(light, renderCamera.toScreen, light);
1186912315
....@@ -12477,8 +12923,8 @@
1247712923
1247812924 // display shadow only (bump == 0)
1247912925 "SUB temp.x, half.x, shadow.x;" +
12480
- "MOV temp.y, -params6.x;" +
12481
- "SLT temp.z, temp.y, zero.x;" +
12926
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12927
+ "SLT temp.z, temp.y, -one2048th.x;" +
1248212928 "SUB temp.y, one.x, temp.z;" +
1248312929 "MUL temp.x, temp.x, temp.y;" +
1248412930 "KIL temp.x;" +
....@@ -12758,7 +13204,7 @@
1275813204 "MUL final.y, fragment.texcoord[0].x, c256;" +
1275913205 "FLR final.x, final.y;" +
1276013206 "SUB final.y, final.y, final.x;" +
12761
- //"MUL final.x, final.x, c256i;" +
13207
+ "MUL final.x, final.x, c256i;" +
1276213208 "MOV final.z, zero.x;" +
1276313209 "MOV final.a, one.w;":""
1276413210 ) +
....@@ -12766,7 +13212,7 @@
1276613212 "MUL final.y, fragment.texcoord[0].y, c256;" +
1276713213 "FLR final.x, final.y;" +
1276813214 "SUB final.y, final.y, final.x;" +
12769
- //"MUL final.x, final.x, c256i;" +
13215
+ "MUL final.x, final.x, c256i;" +
1277013216 "MOV final.z, zero.x;" +
1277113217 "MOV final.a, one.w;":""
1277213218 ) +
....@@ -12809,7 +13255,7 @@
1280913255 //once = true;
1281013256 }
1281113257
12812
- System.out.print("Program #" + mode + "; length = " + program.length());
13258
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1281313259 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281413260 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281513261
....@@ -12942,12 +13388,16 @@
1294213388
1294313389 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294413390 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13391
+
13392
+ // Compare fragment depth in light space with shadowmap.
1294513393 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294613394 "SGE temp.y, temp.x, zero.x;" +
12947
- "SUB " + shadow + ".y, one.x, temp.y;" +
13395
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13396
+
13397
+ // Reverse comparison
1294813398 "SUB temp.x, one.x, temp.x;" +
1294913399 "MUL " + shadow + ".x, temp.x, temp.y;" +
12950
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13400
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1295113401 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1295213402
1295313403 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12961,6 +13411,10 @@
1296113411 // No shadow for backface
1296213412 "DP3 temp.x, normal, lightd;" +
1296313413 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13414
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13415
+
13416
+ // No shadow when out of frustrum
13417
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296413418 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296513419 "";
1296613420 }
....@@ -13107,7 +13561,8 @@
1310713561 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310813562 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310913563 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13110
- Object3D.cVector2[] vector2buffer;
13564
+
13565
+ //Object3D.cVector2[] vector2buffer;
1311113566
1311213567 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1311313568 // OUT : diff, spec
....@@ -13123,9 +13578,10 @@
1312313578 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312413579 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312513580 //"MOV " + dest + ".w," + "normal.z;" +
13126
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13127
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13128
- //"MOV " + dest + ".z," + "params2.w;" +
13581
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13582
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13583
+
13584
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1312913585 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1313013586 "RCP " + dest + ".w," + dest + ".w;" +
1313113587 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13519,7 +13975,7 @@
1351913975 public void mousePressed(MouseEvent e)
1352013976 {
1352113977 //System.out.println("mousePressed: " + e);
13522
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13978
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1352313979 }
1352413980
1352513981 static long prevtime = 0;
....@@ -13595,8 +14051,8 @@
1359514051 // mode |= META;
1359614052 //}
1359714053
13598
- SetMouseMode(WHEEL | e.getModifiersEx());
13599
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14054
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14055
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1360014056 anchorX = ax;
1360114057 anchorY = ay;
1360214058 prevX = px;
....@@ -13630,6 +14086,7 @@
1363014086 else
1363114087 if (evt.getSource() == AAtimer)
1363214088 {
14089
+ Globals.TIMERRUNNING = false;
1363314090 if (mouseDown)
1363414091 {
1363514092 //new Exception().printStackTrace();
....@@ -13655,6 +14112,10 @@
1365514112 // LIVE = waslive;
1365614113 // wasliveok = true;
1365714114 // waslive = false;
14115
+
14116
+ // May 2019 Forget it:
14117
+ if (true)
14118
+ return;
1365814119
1365914120 // source == timer
1366014121 if (mouseDown)
....@@ -13685,7 +14146,7 @@
1368514146
1368614147 // fev 2014???
1368714148 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13688
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14149
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368914150 pingthread.StepToTarget(true); // true);
1369014151 }
1369114152 // if (!LIVE)
....@@ -13694,12 +14155,13 @@
1369414155
1369514156 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369614157
13697
- void clickStart(int x, int y, int modifiers)
14158
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369814159 {
1369914160 if (!wasliveok)
1370014161 return;
1370114162
1370214163 AAtimer.restart(); //
14164
+ Globals.TIMERRUNNING = true;
1370314165
1370414166 // waslive = LIVE;
1370514167 // LIVE = false;
....@@ -13711,7 +14173,7 @@
1371114173 // touched = true; // main DL
1371214174 if (isRenderer)
1371314175 {
13714
- SetMouseMode(modifiers);
14176
+ SetMouseMode(modifiers, modifiersex);
1371514177 }
1371614178
1371714179 selectX = anchorX = x;
....@@ -13724,7 +14186,7 @@
1372414186 clicked = true;
1372514187 hold = false;
1372614188
13727
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14189
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372814190 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372914191 {
1373014192 // System.out.println("RESTART II " + modifiers);
....@@ -13755,7 +14217,7 @@
1375514217 info.camera = renderCamera;
1375614218 info.x = x;
1375714219 info.y = y;
13758
- info.modifiers = modifiers;
14220
+ info.modifiers = modifiersex;
1375914221 editObj = object.doEditClick(info, 0);
1376014222 if (!editObj)
1376114223 {
....@@ -13772,9 +14234,12 @@
1377214234
1377314235 public void mouseDragged(MouseEvent e)
1377414236 {
14237
+ Globals.MOUSEDRAGGED = true;
14238
+
1377514239 //System.out.println("mouseDragged: " + e);
1377614240 if (isRenderer)
1377714241 movingcamera = true;
14242
+
1377814243 //if (drawing)
1377914244 //return;
1378014245 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13784,7 +14249,7 @@
1378414249 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378514250 }
1378614251 else
13787
- drag(e.getX(), e.getY(), e.getModifiersEx());
14252
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378814253
1378914254 //try { Thread.sleep(1); } catch (Exception ex) {}
1379014255 }
....@@ -14021,7 +14486,7 @@
1402114486 {
1402214487 Globals.lighttouched = true;
1402314488 }
14024
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14489
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402514490 }
1402614491 //else
1402714492 }
....@@ -14035,12 +14500,12 @@
1403514500 void GoDown(int mod)
1403614501 {
1403714502 MODIFIERS |= COMMAND;
14038
- /*
14503
+ /**/
1403914504 if((mod&SHIFT) == SHIFT)
1404014505 manipCamera.RotatePosition(0, -speed);
1404114506 else
14042
- manipCamera.BackForth(0, -speed*delta, getWidth());
14043
- */
14507
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14508
+ /**/
1404414509 if ((mod & SHIFT) == SHIFT)
1404514510 {
1404614511 mouseMode = mouseMode; // VR??
....@@ -14056,12 +14521,12 @@
1405614521 void GoUp(int mod)
1405714522 {
1405814523 MODIFIERS |= COMMAND;
14059
- /*
14524
+ /**/
1406014525 if((mod&SHIFT) == SHIFT)
1406114526 manipCamera.RotatePosition(0, speed);
1406214527 else
14063
- manipCamera.BackForth(0, speed*delta, getWidth());
14064
- */
14528
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14529
+ /**/
1406514530 if ((mod & SHIFT) == SHIFT)
1406614531 {
1406714532 mouseMode = mouseMode;
....@@ -14077,12 +14542,12 @@
1407714542 void GoLeft(int mod)
1407814543 {
1407914544 MODIFIERS |= COMMAND;
14080
- /*
14545
+ /**/
1408114546 if((mod&SHIFT) == SHIFT)
14082
- manipCamera.RotatePosition(speed, 0);
14083
- else
1408414547 manipCamera.Translate(speed*delta, 0, getWidth());
14085
- */
14548
+ else
14549
+ manipCamera.RotatePosition(speed, 0);
14550
+ /**/
1408614551 if ((mod & SHIFT) == SHIFT)
1408714552 {
1408814553 mouseMode = mouseMode;
....@@ -14098,12 +14563,12 @@
1409814563 void GoRight(int mod)
1409914564 {
1410014565 MODIFIERS |= COMMAND;
14101
- /*
14566
+ /**/
1410214567 if((mod&SHIFT) == SHIFT)
14103
- manipCamera.RotatePosition(-speed, 0);
14104
- else
1410514568 manipCamera.Translate(-speed*delta, 0, getWidth());
14106
- */
14569
+ else
14570
+ manipCamera.RotatePosition(-speed, 0);
14571
+ /**/
1410714572 if ((mod & SHIFT) == SHIFT)
1410814573 {
1410914574 mouseMode = mouseMode;
....@@ -14121,7 +14586,7 @@
1412114586 int X, Y;
1412214587 boolean SX, SY;
1412314588
14124
- void drag(int x, int y, int modifiers)
14589
+ void drag(int x, int y, int modifiers, int modifiersex)
1412514590 {
1412614591 if (IsFrozen())
1412714592 {
....@@ -14130,17 +14595,17 @@
1413014595
1413114596 drag = true; // NEW
1413214597
14133
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14598
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413414599
1413514600 X = x;
1413614601 Y = y;
1413714602 // floating state for animation
14138
- MODIFIERS = modifiers;
14139
- modifiers &= ~1024;
14603
+ MODIFIERS = modifiersex;
14604
+ modifiersex &= ~1024;
1414014605 if (false) // modifiers != 0)
1414114606 {
1414214607 //new Exception().printStackTrace();
14143
- System.out.println("mouseDragged: " + modifiers);
14608
+ System.out.println("mouseDragged: " + modifiersex);
1414414609 System.out.println("SHIFT = " + SHIFT);
1414514610 System.out.println("CONTROL = " + COMMAND);
1414614611 System.out.println("META = " + META);
....@@ -14160,7 +14625,8 @@
1416014625 info.camera = renderCamera;
1416114626 info.x = x;
1416214627 info.y = y;
14163
- object.editWindow.copy.doEditDrag(info);
14628
+ object.GetWindow().copy
14629
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416414630 } else
1416514631 {
1416614632 if (x < startX)
....@@ -14324,7 +14790,9 @@
1432414790 ci.camera = renderCamera;
1432514791 if (!isRenderer)
1432614792 {
14327
- if (object.editWindow.copy.doEditClick(ci, 0))
14793
+ //ObjEditor editWindow = object.editWindow;
14794
+ //Object3D copy = editWindow.copy;
14795
+ if (object.doEditClick(ci, 0))
1432814796 {
1432914797 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1433014798 } else
....@@ -14336,7 +14804,11 @@
1433614804
1433714805 public void mouseReleased(MouseEvent e)
1433814806 {
14807
+ Globals.MOUSEDRAGGED = false;
14808
+
1433914809 movingcamera = false;
14810
+ X = 0; // getBounds().width/2;
14811
+ Y = 0; // getBounds().height/2;
1434014812 //System.out.println("mouseReleased: " + e);
1434114813 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1434214814 }
....@@ -14359,9 +14831,9 @@
1435914831 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1436014832 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1436114833
14362
- if (control || command || IsFrozen())
14834
+// No delay if (control || command || IsFrozen())
1436314835 timeout = true;
14364
- else
14836
+// ?? May 2019 else
1436514837 // timer.setDelay((modifiers & 128) != 0?0:350);
1436614838 mouseDown = false;
1436714839 if (!control && !command) // june 2013
....@@ -14471,7 +14943,7 @@
1447114943 System.out.println("keyReleased: " + e);
1447214944 }
1447314945
14474
- void SetMouseMode(int modifiers)
14946
+ void SetMouseMode(int modifiers, int modifiersex)
1447514947 {
1447614948 //System.out.println("SetMouseMode = " + modifiers);
1447714949 //modifiers &= ~1024;
....@@ -14483,25 +14955,25 @@
1448314955 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448414956 // return;
1448514957 //System.out.println("SetMode = " + modifiers);
14486
- if ((modifiers & WHEEL) == WHEEL)
14958
+ if ((modifiersex & WHEEL) == WHEEL)
1448714959 {
1448814960 mouseMode |= ZOOM;
1448914961 }
1449014962
1449114963 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14492
- if (capsLocked || (modifiers & META) == META)
14964
+ if (capsLocked) // || (modifiers & META) == META)
1449314965 {
1449414966 mouseMode |= VR; // BACKFORTH;
1449514967 }
14496
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14968
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449714969 {
1449814970 mouseMode |= SELECT;
1449914971 }
14500
- if ((modifiers & COMMAND) == COMMAND)
14972
+ if ((modifiersex & COMMAND) == COMMAND)
1450114973 {
1450214974 mouseMode |= SELECT;
1450314975 }
14504
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14976
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450514977 {
1450614978 mouseMode &= ~VR;
1450714979 mouseMode |= TRANSLATE;
....@@ -14530,7 +15002,7 @@
1453015002
1453115003 if (isRenderer) //
1453215004 {
14533
- SetMouseMode(modifiers);
15005
+ SetMouseMode(0, modifiers);
1453415006 }
1453515007
1453615008 Globals.theRenderer.keyPressed(key);
....@@ -14592,7 +15064,8 @@
1459215064 // break;
1459315065 case 'T':
1459415066 CACHETEXTURE ^= true;
14595
- textures.clear();
15067
+ texturepigment.clear();
15068
+ texturebump.clear();
1459615069 // repaint();
1459715070 break;
1459815071 case 'Y':
....@@ -14677,7 +15150,9 @@
1467715150 case 'E' : COMPACT ^= true;
1467815151 repaint();
1467915152 break;
14680
- case 'W' : DEBUGHSB ^= true;
15153
+ case 'W' : // Wide Window (fullscreen)
15154
+ //DEBUGHSB ^= true;
15155
+ ObjEditor.theFrame.ToggleFullScreen();
1468115156 repaint();
1468215157 break;
1468315158 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14702,8 +15177,8 @@
1470215177 RevertCamera();
1470315178 repaint();
1470415179 break;
14705
- case 'L':
1470615180 case 'l':
15181
+ //case 'L':
1470715182 if (lightMode)
1470815183 {
1470915184 lightMode = false;
....@@ -14846,9 +15321,9 @@
1484615321 case '_':
1484715322 kompactbit = 5;
1484815323 break;
14849
- case '+':
14850
- kompactbit = 6;
14851
- break;
15324
+// case '+':
15325
+// kompactbit = 6;
15326
+// break;
1485215327 case ' ':
1485315328 lightMode ^= true;
1485415329 Globals.lighttouched = true;
....@@ -14860,13 +15335,14 @@
1486015335 case ESC:
1486115336 RENDERPROGRAM += 1;
1486215337 RENDERPROGRAM %= 3;
15338
+
1486315339 repaint();
1486415340 break;
1486515341 case 'Z':
1486615342 //RESIZETEXTURE ^= true;
1486715343 //break;
1486815344 case 'z':
14869
- RENDERSHADOW ^= true;
15345
+ Globals.RENDERSHADOW ^= true;
1487015346 Globals.lighttouched = true;
1487115347 repaint();
1487215348 break;
....@@ -14899,8 +15375,9 @@
1489915375 case DELETE:
1490015376 ClearSelection();
1490115377 break;
14902
- /*
1490315378 case '+':
15379
+
15380
+ /*
1490415381 //fontsize += 1;
1490515382 bbzoom *= 2;
1490615383 repaint();
....@@ -14917,17 +15394,17 @@
1491715394 case '=':
1491815395 IncDepth();
1491915396 //fontsize += 1;
14920
- object.editWindow.refreshContents(true);
15397
+ object.GetWindow().refreshContents(true);
1492115398 maskbit = 6;
1492215399 break;
1492315400 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492415401 DecDepth();
1492515402 maskbit = 5;
1492615403 //if(fontsize > 1) fontsize -= 1;
14927
- if (object.editWindow == null)
14928
- new Exception().printStackTrace();
14929
- else
14930
- object.editWindow.refreshContents(true);
15404
+// if (object.editWindow == null)
15405
+// new Exception().printStackTrace();
15406
+// else
15407
+ object.GetWindow().refreshContents(true);
1493115408 break;
1493215409 case '{':
1493315410 manipCamera.shaper_fovy /= 1.1;
....@@ -14990,7 +15467,7 @@
1499015467 //mode = ROTATE;
1499115468 if ((MODIFIERS & COMMAND) == 0) // VR??
1499215469 {
14993
- SetMouseMode(modifiers);
15470
+ SetMouseMode(0, modifiers);
1499415471 }
1499515472 }
1499615473
....@@ -15126,7 +15603,7 @@
1512615603 {
1512715604 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1512815605 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15129
- if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (mouseMode & SELECT) == 0)
15606
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1513015607 {
1513115608 mouseMoved(e);
1513215609 } else
....@@ -15151,7 +15628,7 @@
1515115628 }
1515215629 */
1515315630
15154
- object.editWindow.EditSelection();
15631
+ object.GetWindow().EditSelection(false);
1515515632 }
1515615633
1515715634 void SelectParent()
....@@ -15168,10 +15645,10 @@
1516815645 {
1516915646 //selectees.remove(i);
1517015647 System.out.println("select parent of " + elem);
15171
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15648
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1517215649 } else
1517315650 {
15174
- group.editWindow.Select(elem.GetTreePath(), first, true);
15651
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517515652 }
1517615653
1517715654 first = false;
....@@ -15213,12 +15690,12 @@
1521315690 for (int j = 0; j < group.children.size(); j++)
1521415691 {
1521515692 elem = (Object3D) group.children.elementAt(j);
15216
- object.editWindow.Select(elem.GetTreePath(), first, true);
15693
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521715694 first = false;
1521815695 }
1521915696 } else
1522015697 {
15221
- object.editWindow.Select(elem.GetTreePath(), first, true);
15698
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522215699 }
1522315700
1522415701 first = false;
....@@ -15229,21 +15706,21 @@
1522915706 {
1523015707 //Composite group = (Composite) object;
1523115708 Object3D group = object;
15232
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15709
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1523315710 }
1523415711
1523515712 void ResetTransform(int mask)
1523615713 {
1523715714 //Composite group = (Composite) object;
1523815715 Object3D group = object;
15239
- group.editWindow.ResetTransform(mask);
15716
+ group.GetWindow().ResetTransform(mask);
1524015717 }
1524115718
1524215719 void FlipTransform()
1524315720 {
1524415721 //Composite group = (Composite) object;
1524515722 Object3D group = object;
15246
- group.editWindow.FlipTransform();
15723
+ group.GetWindow().FlipTransform();
1524715724 // group.editWindow.ReduceMesh(true);
1524815725 }
1524915726
....@@ -15251,7 +15728,7 @@
1525115728 {
1525215729 //Composite group = (Composite) object;
1525315730 Object3D group = object;
15254
- group.editWindow.PrintMemory();
15731
+ group.GetWindow().PrintMemory();
1525515732 // group.editWindow.ReduceMesh(true);
1525615733 }
1525715734
....@@ -15259,7 +15736,7 @@
1525915736 {
1526015737 //Composite group = (Composite) object;
1526115738 Object3D group = object;
15262
- group.editWindow.ResetCentroid();
15739
+ group.GetWindow().ResetCentroid();
1526315740 }
1526415741
1526515742 void IncDepth()
....@@ -15345,7 +15822,9 @@
1534515822 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534615823 //Image img = CreateImage(width, height);
1534715824 //System.out.println("width = " + width + "; height = " + height + "\n");
15825
+
1534815826 Graphics gr = g; // img.getGraphics();
15827
+
1534915828 if (!hasMarquee)
1535015829 {
1535115830 if (Xmin < Xmax) // !locked)
....@@ -15433,6 +15912,7 @@
1543315912 info.bounds.y += (height - desired) / 2;
1543415913 }
1543515914 }
15915
+
1543615916 info.g = gr;
1543715917 info.camera = renderCamera;
1543815918 /*
....@@ -15442,15 +15922,55 @@
1544215922 */
1544315923 if (!isRenderer)
1544415924 {
15445
- object.drawEditHandles(info, 0);
15925
+ Grafreed.Assert(object != null);
15926
+ Grafreed.Assert(object.selection != null);
15927
+ if (object.selection.Size() > 0)
15928
+ {
15929
+ int hitSomething = object.selection.get(0).hitSomething;
15930
+
15931
+ info.DX = 0;
15932
+ info.DY = 0;
15933
+ info.W = 1;
15934
+ if (hitSomething == Object3D.hitCenter)
15935
+ {
15936
+ info.DX = X;
15937
+ if (X != 0)
15938
+ info.DX -= info.bounds.width/2;
15939
+
15940
+ info.DY = Y;
15941
+ if (Y != 0)
15942
+ info.DY -= info.bounds.height/2;
15943
+ }
15944
+
15945
+ object.drawEditHandles(info, 0);
15946
+
15947
+ if (drag && (X != 0 || Y != 0))
15948
+ {
15949
+ switch (hitSomething)
15950
+ {
15951
+ case Object3D.hitCenter: gr.setColor(Color.pink);
15952
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15953
+ break;
15954
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
15955
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15956
+ break;
15957
+ case Object3D.hitScale: gr.setColor(Color.cyan);
15958
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15959
+ break;
15960
+ }
15961
+
15962
+ }
15963
+ }
1544615964 }
1544715965 }
15966
+
1544815967 if (isRenderer)
1544915968 {
1545015969 //gr.setColor(Color.black);
1545115970 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1545215971 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1545315972 }
15973
+
1545415974 if (hasMarquee)
1545515975 {
1545615976 gr.setXORMode(Color.white);
....@@ -15563,6 +16083,7 @@
1556316083 public boolean mouseDown(Event evt, int x, int y)
1556416084 {
1556516085 System.out.println("mouseDown: " + evt);
16086
+ System.exit(0);
1556616087 /*
1556716088 locked = true;
1556816089 drag = false;
....@@ -15606,7 +16127,7 @@
1560616127 {
1560716128 keyPressed(0, modifiers);
1560816129 }
15609
- clickStart(x, y, modifiers);
16130
+ // clickStart(x, y, modifiers);
1561016131 return true;
1561116132 }
1561216133
....@@ -15724,7 +16245,7 @@
1572416245 {
1572516246 keyReleased(0, 0);
1572616247 }
15727
- drag(x, y, modifiers);
16248
+ drag(x, y, 0, modifiers);
1572816249 return true;
1572916250 }
1573016251
....@@ -15856,7 +16377,7 @@
1585616377 Object3D object;
1585716378 static Object3D trackedobject;
1585816379 Camera renderCamera; // Light or Eye (or Occlusion)
15859
- /*static*/ Camera manipCamera; // Light or Eye
16380
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1586016381 /*static*/ Camera eyeCamera;
1586116382 /*static*/ Camera lightCamera;
1586216383 int cameracount;
....@@ -16141,16 +16662,16 @@
1614116662 cStatic.objectstack[materialdepth++] = checker;
1614216663 //System.out.println("material " + material);
1614316664 //Applet3D.tracein(this, selected);
16144
- vector2buffer = checker.projectedVertices;
16665
+ //vector2buffer = checker.projectedVertices;
1614516666
1614616667 //checker.GetMaterial().Draw(this, false); // true);
16147
- DrawMaterial(checker.GetMaterial(), false); // true);
16668
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614816669
1614916670 materialdepth -= 1;
1615016671 if (materialdepth > 0)
1615116672 {
16152
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16153
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16673
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16674
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1615416675 }
1615516676 //checker.GetMaterial().opacity = 1f;
1615616677 ////checker.GetMaterial().ambient = 1f;
....@@ -16236,6 +16757,14 @@
1623616757 }
1623716758 }
1623816759
16760
+ private Object3D GetFolder()
16761
+ {
16762
+ Object3D folder = object.GetWindow().copy;
16763
+ if (object.GetWindow().copy.selection.Size() > 0)
16764
+ folder = object.GetWindow().copy.selection.elementAt(0);
16765
+ return folder;
16766
+ }
16767
+
1623916768 class SelectBuffer implements GLEventListener
1624016769 {
1624116770
....@@ -16315,6 +16844,17 @@
1631516844
1631616845 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1631716846
16847
+ if (PAINTMODE)
16848
+ {
16849
+ if (object.GetWindow().copy.selection.Size() > 0)
16850
+ {
16851
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16852
+
16853
+ // Make what you paint not selectable.
16854
+ paintobj.ResetSelectable();
16855
+ }
16856
+ }
16857
+
1631816858 //int tmp = selection_view;
1631916859 //selection_view = -1;
1632016860 int temp = DrawMode();
....@@ -16326,6 +16866,17 @@
1632616866 // temp = DEFAULT; // patch for selection debug
1632716867 Globals.drawMode = temp; // WARNING
1632816868
16869
+ if (PAINTMODE)
16870
+ {
16871
+ if (object.GetWindow().copy.selection.Size() > 0)
16872
+ {
16873
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16874
+
16875
+ // Revert.
16876
+ paintobj.RestoreSelectable();
16877
+ }
16878
+ }
16879
+
1632916880 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1633016881
1633116882 // trying different ways of getting the depth info over
....@@ -16373,6 +16924,8 @@
1637316924 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637416925 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637516926 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16927
+
16928
+ CreateSelectedPoint();
1637616929
1637716930 // Will fit the mesh !!!
1637816931 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16422,34 +16975,36 @@
1642216975 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]));
1642316976 }
1642416977
16425
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16978
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642616979 }
1642716980 }
1642816981
1642916982 if (!movingcamera && !PAINTMODE)
16430
- object.editWindow.ScreenFitPoint(); // fev 2014
16983
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1643116984
16432
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
16985
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1643316986 {
16434
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
16987
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643516988
16436
- Object3D group = new Object3D("inst" + paintcount++);
16989
+ if (object.GetWindow().copy.selection.Size() > 0)
16990
+ {
16991
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1643716992
16438
- group.CreateMaterial(); // use a void leaf to select instances
16439
-
16440
- group.add(paintobj); // link
16441
-
16442
- object.editWindow.SnapObject(group);
16443
-
16444
- Object3D folder = object.editWindow.copy;
16445
-
16446
- if (object.editWindow.copy.selection.Size() > 0)
16447
- folder = object.editWindow.copy.selection.elementAt(0);
16448
-
16449
- folder.add(group);
16450
-
16451
- object.editWindow.ResetModel();
16452
- object.editWindow.refreshContents();
16993
+ Object3D inst = new Object3D("inst" + paintcount++);
16994
+
16995
+ inst.CreateMaterial(); // use a void leaf to select instances
16996
+
16997
+ inst.add(paintobj); // link
16998
+
16999
+ object.GetWindow().SnapObject(inst);
17000
+
17001
+ Object3D folder = paintFolder; // GetFolder();
17002
+
17003
+ folder.add(inst);
17004
+
17005
+ object.GetWindow().ResetModel();
17006
+ object.GetWindow().refreshContents();
17007
+ }
1645317008 }
1645417009 else
1645517010 paintcount = 0;
....@@ -16488,6 +17043,11 @@
1648817043 //System.out.println("objects[color] = " + objects[color]);
1648917044 //objects[color].Select();
1649017045 indexcount = 0;
17046
+ ObjEditor window = object.GetWindow();
17047
+ if (window != null && deselect)
17048
+ {
17049
+ window.Select(null, deselect, true);
17050
+ }
1649117051 object.Select(color, deselect);
1649217052 }
1649317053
....@@ -16587,7 +17147,7 @@
1658717147 gl.glDisable(gl.GL_CULL_FACE);
1658817148 }
1658917149
16590
- if (!RENDERSHADOW)
17150
+ if (!Globals.RENDERSHADOW)
1659117151 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659217152
1659317153 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16597,7 +17157,7 @@
1659717157 //gl.glColorMask(false, false, false, false);
1659817158
1659917159 //render_scene_from_light_view(gl, drawable, 0, 0);
16600
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17160
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660117161 {
1660217162 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660317163
....@@ -17013,23 +17573,15 @@
1701317573 int AAbuffersize = 0;
1701417574
1701517575 //double[] selectedpoint = new double[3];
17016
- static Superellipsoid selectedpoint = new Superellipsoid();
17576
+ static Superellipsoid selectedpoint;
1701717577 static Sphere previousselectedpoint = null;
17018
- static Sphere debugpointG = new Sphere();
17019
- static Sphere debugpointP = new Sphere();
17020
- static Sphere debugpointC = new Sphere();
17021
- static Sphere debugpointR = new Sphere();
17578
+ static Sphere debugpointG;
17579
+ static Sphere debugpointP;
17580
+ static Sphere debugpointC;
17581
+ static Sphere debugpointR;
1702217582
1702317583 static Sphere debugpoints[] = new Sphere[8];
1702417584
17025
- static
17026
- {
17027
- for (int i=0; i<8; i++)
17028
- {
17029
- debugpoints[i] = new Sphere();
17030
- }
17031
- }
17032
-
1703317585 static void InitPoints(float radius)
1703417586 {
1703517587 for (int i=0; i<8; i++)