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;
....@@ -56,14 +92,12 @@
5692 static int CURRENTANTIALIAS = 0; // 1;
5793 /*static*/ boolean RENDERSHADOW = true;
5894 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6195
6296 boolean DISPLAYTEXT = false;
6397 //boolean REDUCETEXTURE = true;
6498 boolean CACHETEXTURE = true;
6599 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
67101 boolean COMPRESSTEXTURE = false;
68102 boolean KOMPACTTEXTURE = false; // true;
69103 boolean RESIZETEXTURE = false;
....@@ -86,7 +120,7 @@
86120 static boolean FULLSCREEN = false;
87121 static boolean SUPPORT = true;
88122 static boolean INERTIA = true;
89
-static boolean FAST = true; // false;
123
+static boolean FAST = false;
90124 static boolean SLOWPOSE = false;
91125 static boolean FOOTCONTACT = true;
92126
....@@ -108,7 +142,7 @@
108142 static boolean OEIL = true;
109143 static boolean OEILONCE = false; // do oeilon then oeiloff
110144 static boolean LOOKAT = true;
111
-static boolean RANDOM = true; // false;
145
+static boolean SWITCH = true; // false;
112146 static boolean HANDLES = false; // selection doesn't work!!
113147 static boolean PAINTMODE = false;
114148
....@@ -151,6 +185,8 @@
151185 defaultcaps.setAccumBlueBits(16);
152186 defaultcaps.setAccumAlphaBits(16);
153187 }
188
+
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
154190
155191 void SetAsGLRenderer(boolean b)
156192 {
....@@ -327,7 +363,7 @@
327363 cStatic.objectstack[materialdepth++] = obj;
328364 //System.out.println("material " + material);
329365 //Applet3D.tracein(this, selected);
330
- display.vector2buffer = obj.projectedVertices;
366
+ //display.vector2buffer = obj.projectedVertices;
331367 if (obj instanceof Camera)
332368 {
333369 display.options1[0] = material.shift;
....@@ -336,14 +372,28 @@
336372 display.options1[2] = material.shadowbias;
337373 display.options1[3] = material.aniso;
338374 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]);
339380 display.options2[0] = material.opacity;
340381 display.options2[1] = material.diffuse;
341382 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]);
342386
343387 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]);
344391 display.options4[0] = material.cameralight/0.2f;
345392 display.options4[1] = material.subsurface;
346393 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]);
347397
348398 // if (display.CURRENTANTIALIAS > 0)
349399 // display.options3[3] /= 4;
....@@ -359,7 +409,7 @@
359409 /**/
360410 } else
361411 {
362
- DrawMaterial(material, selected);
412
+ DrawMaterial(material, selected, obj.projectedVertices);
363413 }
364414 } else
365415 {
....@@ -383,8 +433,8 @@
383433 cStatic.objectstack[materialdepth++] = obj;
384434 //System.out.println("material " + material);
385435 //Applet3D.tracein("selected ", selected);
386
- display.vector2buffer = obj.projectedVertices;
387
- display.DrawMaterial(material, selected);
436
+ //display.vector2buffer = obj.projectedVertices;
437
+ display.DrawMaterial(material, selected, obj.projectedVertices);
388438 }
389439 }
390440
....@@ -401,8 +451,8 @@
401451 materialdepth -= 1;
402452 if (materialdepth > 0)
403453 {
404
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
405
- 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);
406456 }
407457 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
408458 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -422,8 +472,8 @@
422472 materialdepth -= 1;
423473 if (materialdepth > 0)
424474 {
425
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
426
- 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);
427477 }
428478 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
429479 //else
....@@ -464,10 +514,12 @@
464514 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
465515 {
466516 //gl.glBegin(gl.GL_TRIANGLES);
467
- 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
+ ;
468520 if (!hasnorm)
469521 {
470
- // System.out.println("FUCK!!");
522
+ // System.out.println("Mesh normal");
471523 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
472524 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
473525 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1192,10 +1244,12 @@
11921244 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11931245 }
11941246 }
1247
+
11951248 if (flipV)
11961249 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11971250 else
11981251 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1252
+
11991253 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12001254 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12011255
....@@ -1215,10 +1269,12 @@
12151269 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12161270 }
12171271 }
1272
+
12181273 if (flipV)
12191274 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12201275 else
12211276 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1277
+
12221278 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12231279 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12241280
....@@ -1246,8 +1302,10 @@
12461302 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12471303 else
12481304 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1305
+
12491306 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12501307 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1308
+
12511309 count2 += 2;
12521310 count3 += 3;
12531311 }
....@@ -1603,7 +1661,7 @@
16031661 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16041662 }
16051663
1606
- void DrawMaterial(cMaterial material, boolean selected)
1664
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16071665 {
16081666 CameraPane display = this;
16091667 //new Exception().printStackTrace();
....@@ -1630,7 +1688,7 @@
16301688
16311689 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16321690
1633
- float[] colorV = GrafreeD.colorV;
1691
+ float[] colorV = Grafreed.colorV;
16341692
16351693 /**/
16361694 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1638,7 +1696,7 @@
16381696 colorV[0] = display.modelParams0[0] * material.diffuse;
16391697 colorV[1] = display.modelParams0[1] * material.diffuse;
16401698 colorV[2] = display.modelParams0[2] * material.diffuse;
1641
- colorV[3] = material.opacity;
1699
+ colorV[3] = 1; // material.opacity;
16421700
16431701 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16441702 //System.out.println("Opacity = " + opacity);
....@@ -1746,9 +1804,9 @@
17461804 display.modelParams7[2] = 0;
17471805 display.modelParams7[3] = 0;
17481806
1749
- display.modelParams6[0] = 100; // criss de bug de bump
1807
+ //display.modelParams6[0] = 100; // criss de bug de bump
17501808
1751
- Object3D.cVector2[] extparams = display.vector2buffer;
1809
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17521810 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17531811 {
17541812 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1890,7 +1948,7 @@
18901948 void PushMatrix(double[][] matrix)
18911949 {
18921950 // GrafreeD.tracein(matrix);
1893
- PushMatrix(matrix,1);
1951
+ PushMatrix(matrix, 1);
18941952 }
18951953
18961954 void PushMatrix()
....@@ -2044,7 +2102,7 @@
20442102 //System.err.println("Oeil on");
20452103 OEIL = true;
20462104 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2047
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2105
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20482106 //pingthread.StepToTarget(true);
20492107 }
20502108
....@@ -2142,7 +2200,7 @@
21422200 System.err.println("LIVE = " + Globals.isLIVE());
21432201
21442202 if (!Globals.isLIVE()) // save sound
2145
- GrafreeD.savesound = true; // wav.save();
2203
+ Grafreed.savesound = true; // wav.save();
21462204 // else
21472205 repaint(); // start loop // may 2013
21482206 }
....@@ -2259,7 +2317,7 @@
22592317
22602318 void ToggleDebug()
22612319 {
2262
- DEBUG ^= true;
2320
+ Globals.DEBUG ^= true;
22632321 }
22642322
22652323 void ToggleLookAt()
....@@ -2267,9 +2325,9 @@
22672325 LOOKAT ^= true;
22682326 }
22692327
2270
- void ToggleRandom()
2328
+ void ToggleSwitch()
22712329 {
2272
- RANDOM ^= true;
2330
+ SWITCH ^= true;
22732331 }
22742332
22752333 void ToggleHandles()
....@@ -2277,10 +2335,17 @@
22772335 HANDLES ^= true;
22782336 }
22792337
2338
+ Object3D paintFolder;
2339
+
22802340 void TogglePaint()
22812341 {
22822342 PAINTMODE ^= true;
22832343 paintcount = 0;
2344
+
2345
+ if (PAINTMODE)
2346
+ {
2347
+ paintFolder = GetFolder();
2348
+ }
22842349 }
22852350
22862351 void SwapCamera(int a, int b)
....@@ -2376,7 +2441,22 @@
23762441 {
23772442 return currentGL;
23782443 }
2379
-
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
+
23802460 /**/
23812461 class CacheTexture
23822462 {
....@@ -2385,28 +2465,31 @@
23852465
23862466 int resolution;
23872467
2388
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2468
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23892469 {
2390
- texture = tex;
2470
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2471
+ texturedata = texdata;
23912472 resolution = res;
23922473 }
23932474 }
23942475 /**/
23952476
23962477 // 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>();
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
+
24002483 int pigmentdepth = 0;
24012484 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24022485 int bumpdepth = 0;
24032486 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24042487 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24052488 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2406
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2489
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24072490 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24082491
2409
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2492
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24102493 {
24112494 TextureData texturedata = null;
24122495
....@@ -2425,13 +2508,34 @@
24252508 if (bump)
24262509 texturedata = ConvertBump(texturedata, false);
24272510
2428
- com.sun.opengl.util.texture.Texture texture =
2429
- 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);
24302513
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);
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);
24332516
2434
- 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;
24352539 }
24362540
24372541 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3504,6 +3608,8 @@
35043608
35053609 System.out.println("LOADING TEXTURE : " + name);
35063610
3611
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3612
+
35073613 //
35083614 if (false) // compressbit > 0)
35093615 {
....@@ -7902,7 +8008,7 @@
79028008 String pigment = Object3D.GetPigment(tex);
79038009 String bump = Object3D.GetBump(tex);
79048010
7905
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8011
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79068012 {
79078013 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79088014 // System.out.println("; bump = " + bump);
....@@ -7917,11 +8023,69 @@
79178023 pigment = null;
79188024 }
79198025
7920
- ReleaseTexture(bump, true);
7921
- ReleaseTexture(pigment, false);
8026
+ ReleaseTexture(tex, true);
8027
+ ReleaseTexture(tex, false);
79228028 }
79238029
7924
- 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)
79258089 {
79268090 if (// DrawMode() != 0 || /*tex == null ||*/
79278091 ambientOcclusion ) // || !textureon)
....@@ -7932,7 +8096,7 @@
79328096 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79338097
79348098 if (tex != null)
7935
- texture = textures.get(tex);
8099
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79368100
79378101 // //assert( texture != null );
79388102 // if (texture == null)
....@@ -8024,7 +8188,55 @@
80248188 }
80258189 }
80268190
8027
- /*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
80288240 {
80298241 if (// DrawMode() != 0 || /*tex == null ||*/
80308242 ambientOcclusion ) // || !textureon)
....@@ -8035,17 +8247,47 @@
80358247 if (tex == null)
80368248 {
80378249 BindTexture(null,false,resolution);
8038
- BindTexture(null,true,resolution);
80398250 return;
80408251 }
80418252
80428253 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
+
80438286 String bump = Object3D.GetBump(tex);
80448287
8045
- usedtextures.put(pigment, pigment);
8046
- usedtextures.put(bump, bump);
8288
+ usedtextures.add(tex);
80478289
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8290
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498291 {
80508292 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80518293 // System.out.println("; bump = " + bump);
....@@ -8055,43 +8297,94 @@
80558297 {
80568298 bump = null;
80578299 }
8058
- if (pigment.equals(""))
8059
- {
8060
- pigment = null;
8061
- }
80628300
8063
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8064
- BindTexture(pigment, false, resolution);
80658301 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8066
- BindTexture(bump, true, resolution);
8302
+ BindTexture(tex, true, resolution);
80678303 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8068
-
8069
- return; // true;
80708304 }
80718305
8072
- 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)
80738309 {
8074
- 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;
80758329
80768330 if (tex != null)
80778331 {
8078
- String texname = tex;
8332
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8333
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80798334
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;
8335
+ if (texname.equals("") && texdata == null)
8336
+ {
8337
+ return null;
8338
+ }
8339
+
8340
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8341
+
8342
+// String[] split = tex.split("Textures");
8343
+// if (split.length > 1)
8344
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8345
+// else
8346
+// if (!texname.startsWith("/"))
8347
+// texname = "/Users/nbriere/Textures/" + texname;
8348
+ if (!FileExists(texname))
8349
+ {
8350
+ texname = fallbackTextureName;
8351
+ }
80868352
80878353 if (CACHETEXTURE)
8088
- texture = textures.get(texname); // TEXTURE CACHE
8089
-
8090
- TextureData texturedata = null;
8091
-
8092
- if (texture == null || texture.resolution < resolution)
80938354 {
8094
- 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(""))
80958388 {
80968389 assert(!bump);
80978390 // if (bump)
....@@ -8102,19 +8395,23 @@
81028395 // }
81038396 // else
81048397 // {
8105
- texture = textures.get(tex);
8106
- if (texture == null)
8398
+ // texturecache = textures.get(texname); // suspicious
8399
+ if (texturecache == null)
81078400 {
8108
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8401
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81098402 }
8403
+ else
8404
+ new Exception().printStackTrace();
81108405 // }
81118406 } else
8112
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8407
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81138408 {
81148409 assert(bump);
8115
- texture = textures.get(tex);
8116
- if (texture == null)
8117
- 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();
81188415 } else
81198416 {
81208417 //if (tex.equals("IMMORTAL"))
....@@ -8122,11 +8419,13 @@
81228419 // texture = GetResourceTexture("default.png");
81238420 //} else
81248421 //{
8125
- if (tex.equals("WHITE_NOISE"))
8422
+ if (texname.endsWith("WHITE_NOISE"))
81268423 {
8127
- texture = textures.get(tex);
8128
- if (texture == null)
8129
- 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();
81308429 } else
81318430 {
81328431 if (textureon)
....@@ -8151,7 +8450,7 @@
81518450 }
81528451
81538452 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8154
- if (!new File(cachename).exists())
8453
+ if (!FileExists(cachename))
81558454 cachename = texname;
81568455 else
81578456 processbump = false; // don't process bump map again
....@@ -8173,7 +8472,7 @@
81738472 }
81748473
81758474 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8176
- if (!new File(cachename).exists())
8475
+ if (!FileExists(cachename))
81778476 cachename = texname;
81788477 else
81798478 processbump = false; // don't process bump map again
....@@ -8182,20 +8481,22 @@
81828481 texturedata = GetFileTexture(cachename, processbump, resolution);
81838482
81848483
8185
- if (texturedata != null)
8186
- 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);
81878488 //texture = GetTexture(tex, bump);
81888489 }
81898490 }
81908491 //}
81918492 }
81928493
8193
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8494
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81948495 {
81958496 //return false;
81968497
81978498 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8198
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8499
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81998500 {
82008501 // String ext = "_highres";
82018502 // if (REDUCETEXTURE)
....@@ -8212,52 +8513,17 @@
82128513 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82138514 if (!cachefile.exists())
82148515 {
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))
8516
+ //if (texturedata.getWidth() == texturedata.getHeight())
82248517 {
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);
8518
+ BufferedImage rendImage = CreateBim(texturedata);
8519
+
82558520 ImageWriter writer = null;
82568521 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82578522 if (iter.hasNext()) {
82588523 writer = (ImageWriter)iter.next();
82598524 }
8260
- float compressionQuality = 0.9f;
8525
+
8526
+ float compressionQuality = 0.85f;
82618527 try
82628528 {
82638529 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8274,18 +8540,20 @@
82748540 }
82758541 }
82768542 }
8277
-
8543
+
8544
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8545
+
82788546 //System.out.println("Texture = " + tex);
8279
- if (textures.containsKey(texname))
8547
+ if (textures.containsKey(tex))
82808548 {
8281
- CacheTexture thetex = textures.get(texname);
8549
+ CacheTexture thetex = textures.get(tex);
82828550 thetex.texture.disable();
82838551 thetex.texture.dispose();
8284
- textures.remove(texname);
8552
+ textures.remove(tex);
82858553 }
82868554
8287
- texture.texturedata = texturedata;
8288
- textures.put(texname, texture);
8555
+ //texture.texturedata = texturedata;
8556
+ textures.put(tex, texturecache);
82898557
82908558 // newtex = true;
82918559 }
....@@ -8301,10 +8569,44 @@
83018569 }
83028570 }
83038571
8304
- return texture;
8572
+ return texturecache;
83058573 }
83068574
8307
- 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
83088610 {
83098611 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83108612
....@@ -8322,21 +8624,21 @@
83228624 return texture!=null?texture.texture:null;
83238625 }
83248626
8325
- 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
83268628 {
83278629 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83288630
83298631 return texture!=null?texture.texturedata:null;
83308632 }
83318633
8332
- boolean BindTexture(String tex, boolean bump, int resolution)
8634
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83338635 {
83348636 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83358637 {
83368638 return false;
83378639 }
83388640
8339
- boolean newtex = false;
8641
+ //boolean newtex = false;
83408642
83418643 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83428644
....@@ -8368,9 +8670,75 @@
83688670 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83698671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83708672
8371
- return newtex;
8673
+ return true; // Warning: not used.
83728674 }
83738675
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
+
83748742 ShadowBuffer shadowPBuf;
83758743 AntialiasBuffer antialiasPBuf;
83768744 int MAXSTACK;
....@@ -9206,11 +9574,35 @@
92069574 jy8[3] = 0.5f;
92079575 }
92089576
9209
- 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
92109578 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92119579 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92129580 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92139581
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
+
92149606 static int imagecount = 0; // movie generation
92159607
92169608 static int jitter = 0;
....@@ -9306,8 +9698,8 @@
93069698 assert (parentcam != renderCamera);
93079699
93089700 if (renderCamera != lightCamera)
9309
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9310
- LA.matConcat(matrix, parentcam.toParent, matrix);
9701
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9702
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
93119703
93129704 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93139705
....@@ -9322,8 +9714,8 @@
93229714 LA.matCopy(renderCamera.fromScreen, matrix);
93239715
93249716 if (renderCamera != lightCamera)
9325
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9326
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9717
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9718
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
93279719
93289720 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93299721
....@@ -9395,7 +9787,7 @@
93959787 //gl.glFlush();
93969788 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93979789
9398
- if (ANIMATION && ABORTED)
9790
+ if (Globals.ANIMATION && ABORTED)
93999791 {
94009792 System.err.println(" ABORTED FRAME");
94019793 break;
....@@ -9425,7 +9817,7 @@
94259817 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94269818
94279819 // save image
9428
- if (ANIMATION && !ABORTED)
9820
+ if (Globals.ANIMATION && !ABORTED)
94299821 {
94309822 VPwidth = viewport[2];
94319823 VPheight = viewport[3];
....@@ -9536,11 +9928,11 @@
95369928
95379929 // imagecount++;
95389930
9539
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9931
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95409932
95419933 if (!BOXMODE)
95429934 {
9543
- 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) + ")");
95449936 }
95459937
95469938 if (!BOXMODE)
....@@ -9578,7 +9970,7 @@
95789970 ABORTED = false;
95799971 }
95809972 else
9581
- GrafreeD.wav.cursor += 735 * ACSIZE;
9973
+ Grafreed.wav.cursor += 735 * ACSIZE;
95829974
95839975 if (false)
95849976 {
....@@ -10241,11 +10633,11 @@
1024110633
1024210634 public void display(GLAutoDrawable drawable)
1024310635 {
10244
- if (GrafreeD.savesound && GrafreeD.hassound)
10636
+ if (Grafreed.savesound && Grafreed.hassound)
1024510637 {
10246
- GrafreeD.wav.save();
10247
- GrafreeD.savesound = false;
10248
- GrafreeD.hassound = false;
10638
+ Grafreed.wav.save();
10639
+ Grafreed.savesound = false;
10640
+ Grafreed.hassound = false;
1024910641 }
1025010642 // if (DEBUG_SELECTION)
1025110643 // {
....@@ -10321,6 +10713,7 @@
1032110713 ANTIALIAS = 0;
1032210714 //System.out.println("RESTART");
1032310715 AAtimer.restart();
10716
+ Globals.TIMERRUNNING = true;
1032410717 }
1032510718 }
1032610719 }
....@@ -10375,7 +10768,7 @@
1037510768 Object3D theobject = object;
1037610769 Object3D theparent = object.parent;
1037710770 object.parent = null;
10378
- object = (Object3D)GrafreeD.clone(object);
10771
+ object = (Object3D)Grafreed.clone(object);
1037910772 object.Stripify();
1038010773 if (theobject.selection == null || theobject.selection.Size() == 0)
1038110774 theobject.PreprocessOcclusion(this);
....@@ -10388,13 +10781,14 @@
1038810781 ambientOcclusion = false;
1038910782 }
1039010783
10391
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10784
+ if (//Globals.lighttouched &&
10785
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039210786 {
1039310787 //if (RENDERSHADOW) // ?
1039410788 if (!IsFrozen())
1039510789 {
1039610790 // dec 2012
10397
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10791
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1039810792 {
1039910793 Globals.framecount++;
1040010794 shadowbuffer.display();
....@@ -10521,8 +10915,8 @@
1052110915
1052210916 // if (parentcam != renderCamera) // not a light
1052310917 if (cam != lightCamera)
10524
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10525
- LA.matConcat(matrix, parentcam.toParent, matrix);
10918
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10919
+ LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
1052610920
1052710921 for (int j = 0; j < 4; j++)
1052810922 {
....@@ -10536,8 +10930,8 @@
1053610930
1053710931 // if (parentcam != renderCamera) // not a light
1053810932 if (cam != lightCamera)
10539
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10540
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10933
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
+ LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
1054110935
1054210936 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054310937
....@@ -10796,7 +11190,16 @@
1079611190 // Bump noise
1079711191 gl.glActiveTexture(GL.GL_TEXTURE6);
1079811192 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10799
- 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
+
1080011203
1080111204 gl.glActiveTexture(GL.GL_TEXTURE0);
1080211205 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10819,9 +11222,9 @@
1081911222
1082011223 gl.glMatrixMode(GL.GL_MODELVIEW);
1082111224
10822
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10823
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10824
-//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);
1082511228 } else
1082611229 {
1082711230 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10832,7 +11235,7 @@
1083211235 //System.out.println("BLENDING ON");
1083311236 gl.glEnable(GL.GL_BLEND);
1083411237 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10835
-
11238
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083611239 gl.glMatrixMode(gl.GL_PROJECTION);
1083711240 gl.glLoadIdentity();
1083811241
....@@ -10921,8 +11324,8 @@
1092111324 System.err.println("parentcam != renderCamera");
1092211325
1092311326 // if (cam != lightCamera)
10924
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10925
- 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
1092611329 }
1092711330
1092811331 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10943,8 +11346,8 @@
1094311346 if (true) // TODO
1094411347 {
1094511348 if (cam != lightCamera)
10946
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10947
- 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
1094811351 }
1094911352
1095011353 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11081,7 +11484,7 @@
1108111484 }
1108211485 }
1108311486
11084
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11487
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1108511488 {
1108611489 //gl.glDepthFunc(GL.GL_LEQUAL);
1108711490 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11089,24 +11492,21 @@
1108911492
1109011493 boolean texon = textureon;
1109111494
11092
- if (RENDERPROGRAM > 0)
11093
- {
11094
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11095
- textureon = false;
11096
- }
11495
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11496
+ textureon = false;
11497
+
1109711498 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1109811499 //System.out.println("ALLO");
1109911500 gl.glColorMask(false, false, false, false);
1110011501 DrawObject(gl);
11101
- if (RENDERPROGRAM > 0)
11102
- {
11103
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11104
- textureon = texon;
11105
- }
11502
+
11503
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11504
+ textureon = texon;
11505
+
1110611506 gl.glColorMask(true, true, true, true);
1110711507
1110811508 gl.glDepthFunc(GL.GL_EQUAL);
11109
- //gl.glDepthMask(false);
11509
+ gl.glDepthMask(false);
1111011510 }
1111111511
1111211512 if (false) // DrawMode() == SHADOW)
....@@ -11260,8 +11660,14 @@
1126011660 {
1126111661 renderpass++;
1126211662 // System.out.println("Draw object... ");
11663
+ STEP = 1;
1126311664 if (FAST) // in case there is no script
11264
- STEP = 16;
11665
+ STEP = 8;
11666
+
11667
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11668
+ {
11669
+ STEP *= 4;
11670
+ }
1126511671
1126611672 //object.FullInvariants();
1126711673
....@@ -11275,23 +11681,44 @@
1127511681 e.printStackTrace();
1127611682 }
1127711683
11278
- if (GrafreeD.RENDERME > 0)
11279
- GrafreeD.RENDERME--; // mechante magouille
11684
+ if (Grafreed.RENDERME > 0)
11685
+ Grafreed.RENDERME--; // mechante magouille
1128011686
1128111687 Globals.ONESTEP = false;
1128211688 }
1128311689
1128411690 static boolean zoomonce = false;
1128511691
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
+
1128611710 void DrawObject(GL gl, boolean draw)
1128711711 {
11712
+ // To clear camera values
11713
+ ResetOptions();
11714
+
1128811715 //System.out.println("DRAW OBJECT " + mouseDown);
1128911716 // DrawMode() = SELECTION;
1129011717 //GL gl = getGL();
1129111718 if ((TRACK || SHADOWTRACK) || zoomonce)
1129211719 {
1129311720 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11294
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11721
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1129511722 pingthread.StepToTarget(true); // true);
1129611723 // zoomonce = false;
1129711724 }
....@@ -11346,7 +11773,14 @@
1134611773
1134711774 usedtextures.clear();
1134811775
11349
- 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
+ }
1135011784 }
1135111785 //System.out.println("--> " + stackdepth);
1135211786 // GrafreeD.traceon();
....@@ -11356,8 +11790,9 @@
1135611790
1135711791 if (DrawMode() == DEFAULT)
1135811792 {
11359
- if (DEBUG)
11793
+ if (Globals.DEBUG)
1136011794 {
11795
+ CreateSelectedPoint();
1136111796 float radius = 0.05f;
1136211797 if (selectedpoint.radius != radius)
1136311798 {
....@@ -11411,20 +11846,32 @@
1141111846 ReleaseTextures(DEFAULT_TEXTURES);
1141211847
1141311848 if (CLEANCACHE)
11414
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11849
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1141511850 {
11416
- String tex = e.nextElement();
11851
+ cTexture tex = e.nextElement();
1141711852
1141811853 // System.out.println("Texture --------- " + tex);
1141911854
11420
- if (tex.equals("WHITE_NOISE"))
11855
+ if (tex.equals("WHITE_NOISE:"))
1142111856 continue;
1142211857
11423
- if (!usedtextures.containsKey(tex))
11858
+ if (!usedtextures.contains(tex))
1142411859 {
11860
+ CacheTexture gettex = texturepigment.get(tex);
1142511861 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11426
- textures.get(tex).texture.dispose();
11427
- 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
+ }
1142811875 }
1142911876 }
1143011877 }
....@@ -11437,7 +11884,14 @@
1143711884 if (checker != null && DrawMode() == DEFAULT)
1143811885 {
1143911886 //BindTexture(IMMORTAL_TEXTURE);
11440
- 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
+ }
1144111895 // NEAREST
1144211896 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1144311897 DrawChecker(gl);
....@@ -11519,7 +11973,7 @@
1151911973 return;
1152011974 }
1152111975
11522
- String string = obj.GetToolTip();
11976
+ String string = obj.toString(); //.GetToolTip();
1152311977
1152411978 GL gl = GetGL();
1152511979
....@@ -11836,8 +12290,8 @@
1183612290 //obj.TransformToWorld(light, light);
1183712291 for (int i = tp.size(); --i >= 0;)
1183812292 {
11839
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11840
- 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);
1184112295 }
1184212296
1184312297
....@@ -11854,8 +12308,8 @@
1185412308 parentcam = cameras[0];
1185512309 }
1185612310
11857
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11858
- 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
1185912313
1186012314 LA.xformPos(light, renderCamera.toScreen, light);
1186112315
....@@ -12469,8 +12923,8 @@
1246912923
1247012924 // display shadow only (bump == 0)
1247112925 "SUB temp.x, half.x, shadow.x;" +
12472
- "MOV temp.y, -params6.x;" +
12473
- "SLT temp.z, temp.y, zero.x;" +
12926
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12927
+ "SLT temp.z, temp.y, -one2048th.x;" +
1247412928 "SUB temp.y, one.x, temp.z;" +
1247512929 "MUL temp.x, temp.x, temp.y;" +
1247612930 "KIL temp.x;" +
....@@ -12599,8 +13053,10 @@
1259913053 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1260013054
1260113055 "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
13056
+ // Tuning for default skin
13057
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13058
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13059
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1260413060 "MUL temp.x, temp.x, temp.y;" +
1260513061
1260613062 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12748,7 +13204,7 @@
1274813204 "MUL final.y, fragment.texcoord[0].x, c256;" +
1274913205 "FLR final.x, final.y;" +
1275013206 "SUB final.y, final.y, final.x;" +
12751
- //"MUL final.x, final.x, c256i;" +
13207
+ "MUL final.x, final.x, c256i;" +
1275213208 "MOV final.z, zero.x;" +
1275313209 "MOV final.a, one.w;":""
1275413210 ) +
....@@ -12756,7 +13212,7 @@
1275613212 "MUL final.y, fragment.texcoord[0].y, c256;" +
1275713213 "FLR final.x, final.y;" +
1275813214 "SUB final.y, final.y, final.x;" +
12759
- //"MUL final.x, final.x, c256i;" +
13215
+ "MUL final.x, final.x, c256i;" +
1276013216 "MOV final.z, zero.x;" +
1276113217 "MOV final.a, one.w;":""
1276213218 ) +
....@@ -12799,7 +13255,7 @@
1279913255 //once = true;
1280013256 }
1280113257
12802
- System.out.print("Program #" + mode + "; length = " + program.length());
13258
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1280313259 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1280413260 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1280513261
....@@ -12932,12 +13388,16 @@
1293213388
1293313389 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1293413390 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13391
+
13392
+ // Compare fragment depth in light space with shadowmap.
1293513393 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1293613394 "SGE temp.y, temp.x, zero.x;" +
12937
- "SUB " + shadow + ".y, one.x, temp.y;" +
13395
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13396
+
13397
+ // Reverse comparison
1293813398 "SUB temp.x, one.x, temp.x;" +
1293913399 "MUL " + shadow + ".x, temp.x, temp.y;" +
12940
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13400
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1294113401 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1294213402
1294313403 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12951,6 +13411,10 @@
1295113411 // No shadow for backface
1295213412 "DP3 temp.x, normal, lightd;" +
1295313413 "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;" +
1295413418 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1295513419 "";
1295613420 }
....@@ -13097,7 +13561,8 @@
1309713561 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1309813562 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1309913563 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13100
- Object3D.cVector2[] vector2buffer;
13564
+
13565
+ //Object3D.cVector2[] vector2buffer;
1310113566
1310213567 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1310313568 // OUT : diff, spec
....@@ -13113,9 +13578,10 @@
1311313578 "DP3 " + dest + ".z," + "normals," + "eye;" +
1311413579 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1311513580 //"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;" +
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
1311913585 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1312013586 "RCP " + dest + ".w," + dest + ".w;" +
1312113587 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13509,7 +13975,7 @@
1350913975 public void mousePressed(MouseEvent e)
1351013976 {
1351113977 //System.out.println("mousePressed: " + e);
13512
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
13978
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1351313979 }
1351413980
1351513981 static long prevtime = 0;
....@@ -13585,8 +14051,8 @@
1358514051 // mode |= META;
1358614052 //}
1358714053
13588
- SetMouseMode(WHEEL | e.getModifiersEx());
13589
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14054
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14055
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1359014056 anchorX = ax;
1359114057 anchorY = ay;
1359214058 prevX = px;
....@@ -13620,6 +14086,7 @@
1362014086 else
1362114087 if (evt.getSource() == AAtimer)
1362214088 {
14089
+ Globals.TIMERRUNNING = false;
1362314090 if (mouseDown)
1362414091 {
1362514092 //new Exception().printStackTrace();
....@@ -13645,6 +14112,10 @@
1364514112 // LIVE = waslive;
1364614113 // wasliveok = true;
1364714114 // waslive = false;
14115
+
14116
+ // May 2019 Forget it:
14117
+ if (true)
14118
+ return;
1364814119
1364914120 // source == timer
1365014121 if (mouseDown)
....@@ -13675,7 +14146,7 @@
1367514146
1367614147 // fev 2014???
1367714148 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13678
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14149
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1367914150 pingthread.StepToTarget(true); // true);
1368014151 }
1368114152 // if (!LIVE)
....@@ -13684,12 +14155,13 @@
1368414155
1368514156 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1368614157
13687
- void clickStart(int x, int y, int modifiers)
14158
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1368814159 {
1368914160 if (!wasliveok)
1369014161 return;
1369114162
1369214163 AAtimer.restart(); //
14164
+ Globals.TIMERRUNNING = true;
1369314165
1369414166 // waslive = LIVE;
1369514167 // LIVE = false;
....@@ -13701,7 +14173,7 @@
1370114173 // touched = true; // main DL
1370214174 if (isRenderer)
1370314175 {
13704
- SetMouseMode(modifiers);
14176
+ SetMouseMode(modifiers, modifiersex);
1370514177 }
1370614178
1370714179 selectX = anchorX = x;
....@@ -13714,7 +14186,7 @@
1371414186 clicked = true;
1371514187 hold = false;
1371614188
13717
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14189
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1371814190 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1371914191 {
1372014192 // System.out.println("RESTART II " + modifiers);
....@@ -13745,7 +14217,7 @@
1374514217 info.camera = renderCamera;
1374614218 info.x = x;
1374714219 info.y = y;
13748
- info.modifiers = modifiers;
14220
+ info.modifiers = modifiersex;
1374914221 editObj = object.doEditClick(info, 0);
1375014222 if (!editObj)
1375114223 {
....@@ -13762,9 +14234,12 @@
1376214234
1376314235 public void mouseDragged(MouseEvent e)
1376414236 {
14237
+ Globals.MOUSEDRAGGED = true;
14238
+
1376514239 //System.out.println("mouseDragged: " + e);
1376614240 if (isRenderer)
1376714241 movingcamera = true;
14242
+
1376814243 //if (drawing)
1376914244 //return;
1377014245 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13774,7 +14249,7 @@
1377414249 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1377514250 }
1377614251 else
13777
- drag(e.getX(), e.getY(), e.getModifiersEx());
14252
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1377814253
1377914254 //try { Thread.sleep(1); } catch (Exception ex) {}
1378014255 }
....@@ -14011,7 +14486,7 @@
1401114486 {
1401214487 Globals.lighttouched = true;
1401314488 }
14014
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14489
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1401514490 }
1401614491 //else
1401714492 }
....@@ -14025,12 +14500,12 @@
1402514500 void GoDown(int mod)
1402614501 {
1402714502 MODIFIERS |= COMMAND;
14028
- /*
14503
+ /**/
1402914504 if((mod&SHIFT) == SHIFT)
1403014505 manipCamera.RotatePosition(0, -speed);
1403114506 else
14032
- manipCamera.BackForth(0, -speed*delta, getWidth());
14033
- */
14507
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14508
+ /**/
1403414509 if ((mod & SHIFT) == SHIFT)
1403514510 {
1403614511 mouseMode = mouseMode; // VR??
....@@ -14046,12 +14521,12 @@
1404614521 void GoUp(int mod)
1404714522 {
1404814523 MODIFIERS |= COMMAND;
14049
- /*
14524
+ /**/
1405014525 if((mod&SHIFT) == SHIFT)
1405114526 manipCamera.RotatePosition(0, speed);
1405214527 else
14053
- manipCamera.BackForth(0, speed*delta, getWidth());
14054
- */
14528
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14529
+ /**/
1405514530 if ((mod & SHIFT) == SHIFT)
1405614531 {
1405714532 mouseMode = mouseMode;
....@@ -14067,12 +14542,12 @@
1406714542 void GoLeft(int mod)
1406814543 {
1406914544 MODIFIERS |= COMMAND;
14070
- /*
14545
+ /**/
1407114546 if((mod&SHIFT) == SHIFT)
14072
- manipCamera.RotatePosition(speed, 0);
14073
- else
1407414547 manipCamera.Translate(speed*delta, 0, getWidth());
14075
- */
14548
+ else
14549
+ manipCamera.RotatePosition(speed, 0);
14550
+ /**/
1407614551 if ((mod & SHIFT) == SHIFT)
1407714552 {
1407814553 mouseMode = mouseMode;
....@@ -14088,12 +14563,12 @@
1408814563 void GoRight(int mod)
1408914564 {
1409014565 MODIFIERS |= COMMAND;
14091
- /*
14566
+ /**/
1409214567 if((mod&SHIFT) == SHIFT)
14093
- manipCamera.RotatePosition(-speed, 0);
14094
- else
1409514568 manipCamera.Translate(-speed*delta, 0, getWidth());
14096
- */
14569
+ else
14570
+ manipCamera.RotatePosition(-speed, 0);
14571
+ /**/
1409714572 if ((mod & SHIFT) == SHIFT)
1409814573 {
1409914574 mouseMode = mouseMode;
....@@ -14111,7 +14586,7 @@
1411114586 int X, Y;
1411214587 boolean SX, SY;
1411314588
14114
- void drag(int x, int y, int modifiers)
14589
+ void drag(int x, int y, int modifiers, int modifiersex)
1411514590 {
1411614591 if (IsFrozen())
1411714592 {
....@@ -14120,17 +14595,17 @@
1412014595
1412114596 drag = true; // NEW
1412214597
14123
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14598
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1412414599
1412514600 X = x;
1412614601 Y = y;
1412714602 // floating state for animation
14128
- MODIFIERS = modifiers;
14129
- modifiers &= ~1024;
14603
+ MODIFIERS = modifiersex;
14604
+ modifiersex &= ~1024;
1413014605 if (false) // modifiers != 0)
1413114606 {
1413214607 //new Exception().printStackTrace();
14133
- System.out.println("mouseDragged: " + modifiers);
14608
+ System.out.println("mouseDragged: " + modifiersex);
1413414609 System.out.println("SHIFT = " + SHIFT);
1413514610 System.out.println("CONTROL = " + COMMAND);
1413614611 System.out.println("META = " + META);
....@@ -14150,7 +14625,8 @@
1415014625 info.camera = renderCamera;
1415114626 info.x = x;
1415214627 info.y = y;
14153
- object.editWindow.copy.doEditDrag(info);
14628
+ object.GetWindow().copy
14629
+ .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1415414630 } else
1415514631 {
1415614632 if (x < startX)
....@@ -14314,7 +14790,9 @@
1431414790 ci.camera = renderCamera;
1431514791 if (!isRenderer)
1431614792 {
14317
- if (object.editWindow.copy.doEditClick(ci, 0))
14793
+ //ObjEditor editWindow = object.editWindow;
14794
+ //Object3D copy = editWindow.copy;
14795
+ if (object.doEditClick(ci, 0))
1431814796 {
1431914797 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1432014798 } else
....@@ -14326,7 +14804,11 @@
1432614804
1432714805 public void mouseReleased(MouseEvent e)
1432814806 {
14807
+ Globals.MOUSEDRAGGED = false;
14808
+
1432914809 movingcamera = false;
14810
+ X = 0; // getBounds().width/2;
14811
+ Y = 0; // getBounds().height/2;
1433014812 //System.out.println("mouseReleased: " + e);
1433114813 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1433214814 }
....@@ -14349,9 +14831,9 @@
1434914831 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1435014832 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1435114833
14352
- if (control || command || IsFrozen())
14834
+// No delay if (control || command || IsFrozen())
1435314835 timeout = true;
14354
- else
14836
+// ?? May 2019 else
1435514837 // timer.setDelay((modifiers & 128) != 0?0:350);
1435614838 mouseDown = false;
1435714839 if (!control && !command) // june 2013
....@@ -14461,7 +14943,7 @@
1446114943 System.out.println("keyReleased: " + e);
1446214944 }
1446314945
14464
- void SetMouseMode(int modifiers)
14946
+ void SetMouseMode(int modifiers, int modifiersex)
1446514947 {
1446614948 //System.out.println("SetMouseMode = " + modifiers);
1446714949 //modifiers &= ~1024;
....@@ -14473,25 +14955,25 @@
1447314955 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1447414956 // return;
1447514957 //System.out.println("SetMode = " + modifiers);
14476
- if ((modifiers & WHEEL) == WHEEL)
14958
+ if ((modifiersex & WHEEL) == WHEEL)
1447714959 {
1447814960 mouseMode |= ZOOM;
1447914961 }
1448014962
1448114963 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14482
- if (capsLocked || (modifiers & META) == META)
14964
+ if (capsLocked) // || (modifiers & META) == META)
1448314965 {
1448414966 mouseMode |= VR; // BACKFORTH;
1448514967 }
14486
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
14968
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1448714969 {
1448814970 mouseMode |= SELECT;
1448914971 }
14490
- if ((modifiers & COMMAND) == COMMAND)
14972
+ if ((modifiersex & COMMAND) == COMMAND)
1449114973 {
1449214974 mouseMode |= SELECT;
1449314975 }
14494
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
14976
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1449514977 {
1449614978 mouseMode &= ~VR;
1449714979 mouseMode |= TRANSLATE;
....@@ -14520,7 +15002,7 @@
1452015002
1452115003 if (isRenderer) //
1452215004 {
14523
- SetMouseMode(modifiers);
15005
+ SetMouseMode(0, modifiers);
1452415006 }
1452515007
1452615008 Globals.theRenderer.keyPressed(key);
....@@ -14582,7 +15064,8 @@
1458215064 // break;
1458315065 case 'T':
1458415066 CACHETEXTURE ^= true;
14585
- textures.clear();
15067
+ texturepigment.clear();
15068
+ texturebump.clear();
1458615069 // repaint();
1458715070 break;
1458815071 case 'Y':
....@@ -14667,7 +15150,9 @@
1466715150 case 'E' : COMPACT ^= true;
1466815151 repaint();
1466915152 break;
14670
- case 'W' : DEBUGHSB ^= true;
15153
+ case 'W' : // Wide Window (fullscreen)
15154
+ //DEBUGHSB ^= true;
15155
+ ObjEditor.theFrame.ToggleFullScreen();
1467115156 repaint();
1467215157 break;
1467315158 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14692,8 +15177,8 @@
1469215177 RevertCamera();
1469315178 repaint();
1469415179 break;
14695
- case 'L':
1469615180 case 'l':
15181
+ //case 'L':
1469715182 if (lightMode)
1469815183 {
1469915184 lightMode = false;
....@@ -14836,9 +15321,9 @@
1483615321 case '_':
1483715322 kompactbit = 5;
1483815323 break;
14839
- case '+':
14840
- kompactbit = 6;
14841
- break;
15324
+// case '+':
15325
+// kompactbit = 6;
15326
+// break;
1484215327 case ' ':
1484315328 lightMode ^= true;
1484415329 Globals.lighttouched = true;
....@@ -14850,13 +15335,14 @@
1485015335 case ESC:
1485115336 RENDERPROGRAM += 1;
1485215337 RENDERPROGRAM %= 3;
15338
+
1485315339 repaint();
1485415340 break;
1485515341 case 'Z':
1485615342 //RESIZETEXTURE ^= true;
1485715343 //break;
1485815344 case 'z':
14859
- RENDERSHADOW ^= true;
15345
+ Globals.RENDERSHADOW ^= true;
1486015346 Globals.lighttouched = true;
1486115347 repaint();
1486215348 break;
....@@ -14889,8 +15375,9 @@
1488915375 case DELETE:
1489015376 ClearSelection();
1489115377 break;
14892
- /*
1489315378 case '+':
15379
+
15380
+ /*
1489415381 //fontsize += 1;
1489515382 bbzoom *= 2;
1489615383 repaint();
....@@ -14907,17 +15394,17 @@
1490715394 case '=':
1490815395 IncDepth();
1490915396 //fontsize += 1;
14910
- object.editWindow.refreshContents(true);
15397
+ object.GetWindow().refreshContents(true);
1491115398 maskbit = 6;
1491215399 break;
1491315400 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1491415401 DecDepth();
1491515402 maskbit = 5;
1491615403 //if(fontsize > 1) fontsize -= 1;
14917
- if (object.editWindow == null)
14918
- new Exception().printStackTrace();
14919
- else
14920
- object.editWindow.refreshContents(true);
15404
+// if (object.editWindow == null)
15405
+// new Exception().printStackTrace();
15406
+// else
15407
+ object.GetWindow().refreshContents(true);
1492115408 break;
1492215409 case '{':
1492315410 manipCamera.shaper_fovy /= 1.1;
....@@ -14980,7 +15467,7 @@
1498015467 //mode = ROTATE;
1498115468 if ((MODIFIERS & COMMAND) == 0) // VR??
1498215469 {
14983
- SetMouseMode(modifiers);
15470
+ SetMouseMode(0, modifiers);
1498415471 }
1498515472 }
1498615473
....@@ -15116,7 +15603,7 @@
1511615603 {
1511715604 //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
1511815605 //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15119
- 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)
1512015607 {
1512115608 mouseMoved(e);
1512215609 } else
....@@ -15141,7 +15628,7 @@
1514115628 }
1514215629 */
1514315630
15144
- object.editWindow.EditSelection();
15631
+ object.GetWindow().EditSelection(false);
1514515632 }
1514615633
1514715634 void SelectParent()
....@@ -15158,10 +15645,10 @@
1515815645 {
1515915646 //selectees.remove(i);
1516015647 System.out.println("select parent of " + elem);
15161
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15648
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1516215649 } else
1516315650 {
15164
- group.editWindow.Select(elem.GetTreePath(), first, true);
15651
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1516515652 }
1516615653
1516715654 first = false;
....@@ -15203,12 +15690,12 @@
1520315690 for (int j = 0; j < group.children.size(); j++)
1520415691 {
1520515692 elem = (Object3D) group.children.elementAt(j);
15206
- object.editWindow.Select(elem.GetTreePath(), first, true);
15693
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1520715694 first = false;
1520815695 }
1520915696 } else
1521015697 {
15211
- object.editWindow.Select(elem.GetTreePath(), first, true);
15698
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521215699 }
1521315700
1521415701 first = false;
....@@ -15219,21 +15706,21 @@
1521915706 {
1522015707 //Composite group = (Composite) object;
1522115708 Object3D group = object;
15222
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15709
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1522315710 }
1522415711
1522515712 void ResetTransform(int mask)
1522615713 {
1522715714 //Composite group = (Composite) object;
1522815715 Object3D group = object;
15229
- group.editWindow.ResetTransform(mask);
15716
+ group.GetWindow().ResetTransform(mask);
1523015717 }
1523115718
1523215719 void FlipTransform()
1523315720 {
1523415721 //Composite group = (Composite) object;
1523515722 Object3D group = object;
15236
- group.editWindow.FlipTransform();
15723
+ group.GetWindow().FlipTransform();
1523715724 // group.editWindow.ReduceMesh(true);
1523815725 }
1523915726
....@@ -15241,7 +15728,7 @@
1524115728 {
1524215729 //Composite group = (Composite) object;
1524315730 Object3D group = object;
15244
- group.editWindow.PrintMemory();
15731
+ group.GetWindow().PrintMemory();
1524515732 // group.editWindow.ReduceMesh(true);
1524615733 }
1524715734
....@@ -15249,7 +15736,7 @@
1524915736 {
1525015737 //Composite group = (Composite) object;
1525115738 Object3D group = object;
15252
- group.editWindow.ResetCentroid();
15739
+ group.GetWindow().ResetCentroid();
1525315740 }
1525415741
1525515742 void IncDepth()
....@@ -15335,7 +15822,9 @@
1533515822 info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1533615823 //Image img = CreateImage(width, height);
1533715824 //System.out.println("width = " + width + "; height = " + height + "\n");
15825
+
1533815826 Graphics gr = g; // img.getGraphics();
15827
+
1533915828 if (!hasMarquee)
1534015829 {
1534115830 if (Xmin < Xmax) // !locked)
....@@ -15423,6 +15912,7 @@
1542315912 info.bounds.y += (height - desired) / 2;
1542415913 }
1542515914 }
15915
+
1542615916 info.g = gr;
1542715917 info.camera = renderCamera;
1542815918 /*
....@@ -15432,15 +15922,55 @@
1543215922 */
1543315923 if (!isRenderer)
1543415924 {
15435
- 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
+ }
1543615964 }
1543715965 }
15966
+
1543815967 if (isRenderer)
1543915968 {
1544015969 //gr.setColor(Color.black);
1544115970 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1544215971 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1544315972 }
15973
+
1544415974 if (hasMarquee)
1544515975 {
1544615976 gr.setXORMode(Color.white);
....@@ -15553,6 +16083,7 @@
1555316083 public boolean mouseDown(Event evt, int x, int y)
1555416084 {
1555516085 System.out.println("mouseDown: " + evt);
16086
+ System.exit(0);
1555616087 /*
1555716088 locked = true;
1555816089 drag = false;
....@@ -15596,7 +16127,7 @@
1559616127 {
1559716128 keyPressed(0, modifiers);
1559816129 }
15599
- clickStart(x, y, modifiers);
16130
+ // clickStart(x, y, modifiers);
1560016131 return true;
1560116132 }
1560216133
....@@ -15714,7 +16245,7 @@
1571416245 {
1571516246 keyReleased(0, 0);
1571616247 }
15717
- drag(x, y, modifiers);
16248
+ drag(x, y, 0, modifiers);
1571816249 return true;
1571916250 }
1572016251
....@@ -15846,7 +16377,7 @@
1584616377 Object3D object;
1584716378 static Object3D trackedobject;
1584816379 Camera renderCamera; // Light or Eye (or Occlusion)
15849
- /*static*/ Camera manipCamera; // Light or Eye
16380
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1585016381 /*static*/ Camera eyeCamera;
1585116382 /*static*/ Camera lightCamera;
1585216383 int cameracount;
....@@ -16131,16 +16662,16 @@
1613116662 cStatic.objectstack[materialdepth++] = checker;
1613216663 //System.out.println("material " + material);
1613316664 //Applet3D.tracein(this, selected);
16134
- vector2buffer = checker.projectedVertices;
16665
+ //vector2buffer = checker.projectedVertices;
1613516666
1613616667 //checker.GetMaterial().Draw(this, false); // true);
16137
- DrawMaterial(checker.GetMaterial(), false); // true);
16668
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1613816669
1613916670 materialdepth -= 1;
1614016671 if (materialdepth > 0)
1614116672 {
16142
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16143
- 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);
1614416675 }
1614516676 //checker.GetMaterial().opacity = 1f;
1614616677 ////checker.GetMaterial().ambient = 1f;
....@@ -16226,6 +16757,14 @@
1622616757 }
1622716758 }
1622816759
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
+
1622916768 class SelectBuffer implements GLEventListener
1623016769 {
1623116770
....@@ -16305,6 +16844,17 @@
1630516844
1630616845 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1630716846
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
+
1630816858 //int tmp = selection_view;
1630916859 //selection_view = -1;
1631016860 int temp = DrawMode();
....@@ -16316,6 +16866,17 @@
1631616866 // temp = DEFAULT; // patch for selection debug
1631716867 Globals.drawMode = temp; // WARNING
1631816868
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
+
1631916880 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1632016881
1632116882 // trying different ways of getting the depth info over
....@@ -16363,6 +16924,8 @@
1636316924 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1636416925 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1636516926 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
16927
+
16928
+ CreateSelectedPoint();
1636616929
1636716930 // Will fit the mesh !!!
1636816931 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16412,34 +16975,36 @@
1641216975 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]));
1641316976 }
1641416977
16415
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
16978
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1641616979 }
1641716980 }
1641816981
1641916982 if (!movingcamera && !PAINTMODE)
16420
- object.editWindow.ScreenFitPoint(); // fev 2014
16983
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1642116984
16422
- 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)
1642316986 {
16424
- 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);
1642516988
16426
- Object3D group = new Object3D("inst" + paintcount++);
16989
+ if (object.GetWindow().copy.selection.Size() > 0)
16990
+ {
16991
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1642716992
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();
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
+ }
1644317008 }
1644417009 else
1644517010 paintcount = 0;
....@@ -16478,6 +17043,11 @@
1647817043 //System.out.println("objects[color] = " + objects[color]);
1647917044 //objects[color].Select();
1648017045 indexcount = 0;
17046
+ ObjEditor window = object.GetWindow();
17047
+ if (window != null && deselect)
17048
+ {
17049
+ window.Select(null, deselect, true);
17050
+ }
1648117051 object.Select(color, deselect);
1648217052 }
1648317053
....@@ -16577,7 +17147,7 @@
1657717147 gl.glDisable(gl.GL_CULL_FACE);
1657817148 }
1657917149
16580
- if (!RENDERSHADOW)
17150
+ if (!Globals.RENDERSHADOW)
1658117151 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1658217152
1658317153 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16587,7 +17157,7 @@
1658717157 //gl.glColorMask(false, false, false, false);
1658817158
1658917159 //render_scene_from_light_view(gl, drawable, 0, 0);
16590
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17160
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1659117161 {
1659217162 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659317163
....@@ -17003,23 +17573,15 @@
1700317573 int AAbuffersize = 0;
1700417574
1700517575 //double[] selectedpoint = new double[3];
17006
- static Superellipsoid selectedpoint = new Superellipsoid();
17576
+ static Superellipsoid selectedpoint;
1700717577 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();
17578
+ static Sphere debugpointG;
17579
+ static Sphere debugpointP;
17580
+ static Sphere debugpointC;
17581
+ static Sphere debugpointR;
1701217582
1701317583 static Sphere debugpoints[] = new Sphere[8];
1701417584
17015
- static
17016
- {
17017
- for (int i=0; i<8; i++)
17018
- {
17019
- debugpoints[i] = new Sphere();
17020
- }
17021
- }
17022
-
1702317585 static void InitPoints(float radius)
1702417586 {
1702517587 for (int i=0; i<8; i++)