Normand Briere
2019-07-28 d7fd07756f4095cb87dc25d89fcffcbda092e2cf
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;
....@@ -150,6 +186,20 @@
150186 defaultcaps.setAccumAlphaBits(16);
151187 }
152188
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
191
+ public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException
192
+ {
193
+ try
194
+ {
195
+ cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196
+ } catch (IOException e)
197
+ {
198
+ System.out.println("NAME = " + name);
199
+ e.printStackTrace(); // throw new RuntimeException(e);
200
+ }
201
+ }
202
+
153203 void SetAsGLRenderer(boolean b)
154204 {
155205 isRenderer = b;
....@@ -168,7 +218,8 @@
168218
169219 SetCamera(cam);
170220
171
- SetLight(new Camera(new cVector(10, 10, -20)));
221
+ // Warning: not used.
222
+ SetLight(new Camera(new cVector(15, 10, -20)));
172223
173224 object = o;
174225
....@@ -325,7 +376,7 @@
325376 cStatic.objectstack[materialdepth++] = obj;
326377 //System.out.println("material " + material);
327378 //Applet3D.tracein(this, selected);
328
- display.vector2buffer = obj.projectedVertices;
379
+ //display.vector2buffer = obj.projectedVertices;
329380 if (obj instanceof Camera)
330381 {
331382 display.options1[0] = material.shift;
....@@ -334,14 +385,28 @@
334385 display.options1[2] = material.shadowbias;
335386 display.options1[3] = material.aniso;
336387 display.options1[4] = material.anisoV;
388
+// System.out.println("display.options1[0] " + display.options1[0]);
389
+// System.out.println("display.options1[1] " + display.options1[1]);
390
+// System.out.println("display.options1[2] " + display.options1[2]);
391
+// System.out.println("display.options1[3] " + display.options1[3]);
392
+// System.out.println("display.options1[4] " + display.options1[4]);
337393 display.options2[0] = material.opacity;
338394 display.options2[1] = material.diffuse;
339395 display.options2[2] = material.factor;
396
+// System.out.println("display.options2[0] " + display.options2[0]);
397
+// System.out.println("display.options2[1] " + display.options2[1]);
398
+// System.out.println("display.options2[2] " + display.options2[2]);
340399
341400 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
401
+// System.out.println("display.options3[0] " + display.options3[0]);
402
+// System.out.println("display.options3[1] " + display.options3[1]);
403
+// System.out.println("display.options3[2] " + display.options3[2]);
342404 display.options4[0] = material.cameralight/0.2f;
343405 display.options4[1] = material.subsurface;
344406 display.options4[2] = material.sheen;
407
+// System.out.println("display.options4[0] " + display.options4[0]);
408
+// System.out.println("display.options4[1] " + display.options4[1]);
409
+// System.out.println("display.options4[2] " + display.options4[2]);
345410
346411 // if (display.CURRENTANTIALIAS > 0)
347412 // display.options3[3] /= 4;
....@@ -357,7 +422,7 @@
357422 /**/
358423 } else
359424 {
360
- DrawMaterial(material, selected);
425
+ DrawMaterial(material, selected, obj.projectedVertices);
361426 }
362427 } else
363428 {
....@@ -381,8 +446,8 @@
381446 cStatic.objectstack[materialdepth++] = obj;
382447 //System.out.println("material " + material);
383448 //Applet3D.tracein("selected ", selected);
384
- display.vector2buffer = obj.projectedVertices;
385
- display.DrawMaterial(material, selected);
449
+ //display.vector2buffer = obj.projectedVertices;
450
+ display.DrawMaterial(material, selected, obj.projectedVertices);
386451 }
387452 }
388453
....@@ -399,8 +464,8 @@
399464 materialdepth -= 1;
400465 if (materialdepth > 0)
401466 {
402
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
403
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
467
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
468
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
404469 }
405470 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
406471 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -420,8 +485,8 @@
420485 materialdepth -= 1;
421486 if (materialdepth > 0)
422487 {
423
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
424
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
488
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
489
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
425490 }
426491 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
427492 //else
....@@ -462,10 +527,12 @@
462527 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
463528 {
464529 //gl.glBegin(gl.GL_TRIANGLES);
465
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
530
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
531
+ // TEST LIVE NORMALS && !obj.dontselect
532
+ ;
466533 if (!hasnorm)
467534 {
468
- // System.out.println("FUCK!!");
535
+ // System.out.println("Mesh normal");
469536 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
470537 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
471538 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1190,10 +1257,12 @@
11901257 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11911258 }
11921259 }
1260
+
11931261 if (flipV)
11941262 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11951263 else
11961264 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1265
+
11971266 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11981267 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11991268
....@@ -1213,10 +1282,12 @@
12131282 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12141283 }
12151284 }
1285
+
12161286 if (flipV)
12171287 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12181288 else
12191289 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1290
+
12201291 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12211292 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12221293
....@@ -1244,8 +1315,10 @@
12441315 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12451316 else
12461317 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1318
+
12471319 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12481320 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1321
+
12491322 count2 += 2;
12501323 count3 += 3;
12511324 }
....@@ -1424,6 +1497,8 @@
14241497 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14251498 }
14261499
1500
+ float[] colorV = new float[4];
1501
+
14271502 void SetColor(Object3D obj, Vertex p0)
14281503 {
14291504 CameraPane display = this;
....@@ -1491,8 +1566,6 @@
14911566 {
14921567 return;
14931568 }
1494
-
1495
- float[] colorV = new float[3];
14961569
14971570 if (false) // marked)
14981571 {
....@@ -1601,7 +1674,7 @@
16011674 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
16021675 }
16031676
1604
- void DrawMaterial(cMaterial material, boolean selected)
1677
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16051678 {
16061679 CameraPane display = this;
16071680 //new Exception().printStackTrace();
....@@ -1628,7 +1701,7 @@
16281701
16291702 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16301703
1631
- float[] colorV = GrafreeD.colorV;
1704
+ float[] colorV = Grafreed.colorV;
16321705
16331706 /**/
16341707 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1636,7 +1709,7 @@
16361709 colorV[0] = display.modelParams0[0] * material.diffuse;
16371710 colorV[1] = display.modelParams0[1] * material.diffuse;
16381711 colorV[2] = display.modelParams0[2] * material.diffuse;
1639
- colorV[3] = material.opacity;
1712
+ colorV[3] = 1; // material.opacity;
16401713
16411714 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16421715 //System.out.println("Opacity = " + opacity);
....@@ -1744,9 +1817,9 @@
17441817 display.modelParams7[2] = 0;
17451818 display.modelParams7[3] = 0;
17461819
1747
- display.modelParams6[0] = 100; // criss de bug de bump
1820
+ //display.modelParams6[0] = 100; // criss de bug de bump
17481821
1749
- Object3D.cVector2[] extparams = display.vector2buffer;
1822
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17501823 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17511824 {
17521825 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1888,7 +1961,7 @@
18881961 void PushMatrix(double[][] matrix)
18891962 {
18901963 // GrafreeD.tracein(matrix);
1891
- PushMatrix(matrix,1);
1964
+ PushMatrix(matrix, 1);
18921965 }
18931966
18941967 void PushMatrix()
....@@ -2042,7 +2115,7 @@
20422115 //System.err.println("Oeil on");
20432116 OEIL = true;
20442117 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2045
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2118
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20462119 //pingthread.StepToTarget(true);
20472120 }
20482121
....@@ -2140,7 +2213,7 @@
21402213 System.err.println("LIVE = " + Globals.isLIVE());
21412214
21422215 if (!Globals.isLIVE()) // save sound
2143
- GrafreeD.savesound = true; // wav.save();
2216
+ Grafreed.savesound = true; // wav.save();
21442217 // else
21452218 repaint(); // start loop // may 2013
21462219 }
....@@ -2257,7 +2330,7 @@
22572330
22582331 void ToggleDebug()
22592332 {
2260
- DEBUG ^= true;
2333
+ Globals.DEBUG ^= true;
22612334 }
22622335
22632336 void ToggleLookAt()
....@@ -2265,7 +2338,7 @@
22652338 LOOKAT ^= true;
22662339 }
22672340
2268
- void ToggleRandom()
2341
+ void ToggleSwitch()
22692342 {
22702343 SWITCH ^= true;
22712344 }
....@@ -2275,10 +2348,17 @@
22752348 HANDLES ^= true;
22762349 }
22772350
2351
+ Object3D paintFolder;
2352
+
22782353 void TogglePaint()
22792354 {
22802355 PAINTMODE ^= true;
22812356 paintcount = 0;
2357
+
2358
+ if (PAINTMODE)
2359
+ {
2360
+ paintFolder = GetFolder();
2361
+ }
22822362 }
22832363
22842364 void SwapCamera(int a, int b)
....@@ -2374,7 +2454,22 @@
23742454 {
23752455 return currentGL;
23762456 }
2377
-
2457
+
2458
+ static private BufferedImage CreateBim(TextureData texturedata)
2459
+ {
2460
+ Grafreed.Assert(texturedata != null);
2461
+
2462
+ int width = texturedata.getWidth();
2463
+ int height = texturedata.getHeight();
2464
+
2465
+ Buffer buffer = texturedata.getBuffer();
2466
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2467
+
2468
+ byte[] bytes = bytebuf.array();
2469
+
2470
+ return CreateBim(bytes, width, height);
2471
+ }
2472
+
23782473 /**/
23792474 class CacheTexture
23802475 {
....@@ -2383,28 +2478,31 @@
23832478
23842479 int resolution;
23852480
2386
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2481
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23872482 {
2388
- texture = tex;
2483
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2484
+ texturedata = texdata;
23892485 resolution = res;
23902486 }
23912487 }
23922488 /**/
23932489
23942490 // 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>();
2491
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2492
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2493
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2494
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2495
+
23982496 int pigmentdepth = 0;
23992497 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24002498 int bumpdepth = 0;
24012499 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24022500 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24032501 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2404
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2502
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24052503 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24062504
2407
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2505
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24082506 {
24092507 TextureData texturedata = null;
24102508
....@@ -2423,13 +2521,34 @@
24232521 if (bump)
24242522 texturedata = ConvertBump(texturedata, false);
24252523
2426
- com.sun.opengl.util.texture.Texture texture =
2427
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2524
+// com.sun.opengl.util.texture.Texture texture =
2525
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24282526
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);
2527
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2528
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24312529
2432
- return texture;
2530
+ return texturedata;
2531
+ }
2532
+
2533
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2534
+ {
2535
+ TextureData texturedata = null;
2536
+
2537
+ try
2538
+ {
2539
+ texturedata =
2540
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2541
+ bim,
2542
+ true);
2543
+ } catch (Exception e)
2544
+ {
2545
+ throw new javax.media.opengl.GLException(e);
2546
+ }
2547
+
2548
+ if (bump)
2549
+ texturedata = ConvertBump(texturedata, false);
2550
+
2551
+ return texturedata;
24332552 }
24342553
24352554 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3502,6 +3621,8 @@
35023621
35033622 System.out.println("LOADING TEXTURE : " + name);
35043623
3624
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3625
+
35053626 //
35063627 if (false) // compressbit > 0)
35073628 {
....@@ -7900,7 +8021,7 @@
79008021 String pigment = Object3D.GetPigment(tex);
79018022 String bump = Object3D.GetBump(tex);
79028023
7903
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8024
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79048025 {
79058026 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79068027 // System.out.println("; bump = " + bump);
....@@ -7915,11 +8036,69 @@
79158036 pigment = null;
79168037 }
79178038
7918
- ReleaseTexture(bump, true);
7919
- ReleaseTexture(pigment, false);
8039
+ ReleaseTexture(tex, true);
8040
+ ReleaseTexture(tex, false);
79208041 }
79218042
7922
- void ReleaseTexture(String tex, boolean bump)
8043
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8044
+ {
8045
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8046
+ {
8047
+ return;
8048
+ }
8049
+
8050
+ if (tex == null)
8051
+ {
8052
+ ReleaseTexture(null, false);
8053
+ return;
8054
+ }
8055
+
8056
+ String pigment = Object3D.GetPigment(tex);
8057
+
8058
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8059
+ {
8060
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8061
+ // System.out.println("; bump = " + bump);
8062
+ }
8063
+
8064
+ if (pigment.equals(""))
8065
+ {
8066
+ pigment = null;
8067
+ }
8068
+
8069
+ ReleaseTexture(tex, false);
8070
+ }
8071
+
8072
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8073
+ {
8074
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8075
+ {
8076
+ return;
8077
+ }
8078
+
8079
+ if (tex == null)
8080
+ {
8081
+ ReleaseTexture(null, true);
8082
+ return;
8083
+ }
8084
+
8085
+ String bump = Object3D.GetBump(tex);
8086
+
8087
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8088
+ {
8089
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8090
+ // System.out.println("; bump = " + bump);
8091
+ }
8092
+
8093
+ if (bump.equals(""))
8094
+ {
8095
+ bump = null;
8096
+ }
8097
+
8098
+ ReleaseTexture(tex, true);
8099
+ }
8100
+
8101
+ void ReleaseTexture(cTexture tex, boolean bump)
79238102 {
79248103 if (// DrawMode() != 0 || /*tex == null ||*/
79258104 ambientOcclusion ) // || !textureon)
....@@ -7930,7 +8109,7 @@
79308109 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79318110
79328111 if (tex != null)
7933
- texture = textures.get(tex);
8112
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79348113
79358114 // //assert( texture != null );
79368115 // if (texture == null)
....@@ -8022,7 +8201,55 @@
80228201 }
80238202 }
80248203
8025
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8204
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8205
+ {
8206
+// if (// DrawMode() != 0 || /*tex == null ||*/
8207
+// ambientOcclusion ) // || !textureon)
8208
+// {
8209
+// return; // false;
8210
+// }
8211
+//
8212
+// if (tex == null)
8213
+// {
8214
+// BindTexture(null,false,resolution);
8215
+// BindTexture(null,true,resolution);
8216
+// return;
8217
+// }
8218
+//
8219
+// String pigment = Object3D.GetPigment(tex);
8220
+// String bump = Object3D.GetBump(tex);
8221
+//
8222
+// usedtextures.add(pigment);
8223
+// usedtextures.add(bump);
8224
+//
8225
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8226
+// {
8227
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8228
+// // System.out.println("; bump = " + bump);
8229
+// }
8230
+//
8231
+// if (bump.equals(""))
8232
+// {
8233
+// bump = null;
8234
+// }
8235
+// if (pigment.equals(""))
8236
+// {
8237
+// pigment = null;
8238
+// }
8239
+//
8240
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8241
+// BindTexture(pigment, false, resolution);
8242
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8243
+// BindTexture(bump, true, resolution);
8244
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8245
+//
8246
+// return; // true;
8247
+
8248
+ BindPigmentTexture(tex, resolution);
8249
+ BindBumpTexture(tex, resolution);
8250
+ }
8251
+
8252
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80268253 {
80278254 if (// DrawMode() != 0 || /*tex == null ||*/
80288255 ambientOcclusion ) // || !textureon)
....@@ -8033,17 +8260,47 @@
80338260 if (tex == null)
80348261 {
80358262 BindTexture(null,false,resolution);
8036
- BindTexture(null,true,resolution);
80378263 return;
80388264 }
80398265
80408266 String pigment = Object3D.GetPigment(tex);
8267
+
8268
+ usedtextures.add(tex);
8269
+
8270
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8271
+ {
8272
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8273
+ // System.out.println("; bump = " + bump);
8274
+ }
8275
+
8276
+ if (pigment.equals(""))
8277
+ {
8278
+ pigment = null;
8279
+ }
8280
+
8281
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8282
+ BindTexture(tex, false, resolution);
8283
+ }
8284
+
8285
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8286
+ {
8287
+ if (// DrawMode() != 0 || /*tex == null ||*/
8288
+ ambientOcclusion ) // || !textureon)
8289
+ {
8290
+ return; // false;
8291
+ }
8292
+
8293
+ if (tex == null)
8294
+ {
8295
+ BindTexture(null,true,resolution);
8296
+ return;
8297
+ }
8298
+
80418299 String bump = Object3D.GetBump(tex);
80428300
8043
- usedtextures.put(pigment, pigment);
8044
- usedtextures.put(bump, bump);
8301
+ usedtextures.add(tex);
80458302
8046
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8303
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80478304 {
80488305 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80498306 // System.out.println("; bump = " + bump);
....@@ -8053,47 +8310,94 @@
80538310 {
80548311 bump = null;
80558312 }
8056
- if (pigment.equals(""))
8057
- {
8058
- pigment = null;
8059
- }
80608313
8061
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8062
- BindTexture(pigment, false, resolution);
80638314 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8064
- BindTexture(bump, true, resolution);
8315
+ BindTexture(tex, true, resolution);
80658316 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8066
-
8067
- return; // true;
80688317 }
80698318
8070
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8319
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8320
+
8321
+ private boolean FileExists(String tex)
80718322 {
8072
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8323
+ if (missingTextures.contains(tex))
8324
+ {
8325
+ return false;
8326
+ }
8327
+
8328
+ boolean fileExists = new File(tex).exists();
8329
+
8330
+ if (!fileExists)
8331
+ {
8332
+ // If file exists, the "new File()" is not executed sgain
8333
+ missingTextures.add(tex);
8334
+ }
8335
+
8336
+ return fileExists;
8337
+ }
8338
+
8339
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8340
+ {
8341
+ CacheTexture texturecache = null;
80738342
80748343 if (tex != null)
80758344 {
8076
- String texname = tex;
8345
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8346
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80778347
8348
+ if (texname.equals("") && texdata == null)
8349
+ {
8350
+ return null;
8351
+ }
8352
+
8353
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8354
+
80788355 // String[] split = tex.split("Textures");
80798356 // if (split.length > 1)
80808357 // texname = "/Users/nbriere/Textures" + split[split.length-1];
80818358 // else
80828359 // if (!texname.startsWith("/"))
80838360 // texname = "/Users/nbriere/Textures/" + texname;
8084
- if (!new File(tex).exists())
8361
+ if (!FileExists(texname))
80858362 {
8086
- texname = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory() + "/Textures/" + texname;
8363
+ texname = fallbackTextureName;
80878364 }
80888365
80898366 if (CACHETEXTURE)
8090
- texture = textures.get(texname); // TEXTURE CACHE
8091
-
8092
- TextureData texturedata = null;
8093
-
8094
- if (texture == null || texture.resolution < resolution)
80958367 {
8096
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8368
+ if (texdata == null)
8369
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8370
+ else
8371
+ texturecache = bimtextures.get(texdata);
8372
+ }
8373
+
8374
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8375
+ {
8376
+ TextureData texturedata = null;
8377
+
8378
+ if (texdata != null && textureon)
8379
+ {
8380
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8381
+
8382
+ try
8383
+ {
8384
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8385
+ }
8386
+ catch (Exception e)
8387
+ {
8388
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8389
+ }
8390
+
8391
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8392
+ bimtextures.put(texdata, texturecache);
8393
+
8394
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8395
+
8396
+ //Object bim2 = CreateBim(texturecache.texturedata);
8397
+ //bim2 = bim;
8398
+ }
8399
+ else
8400
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80978401 {
80988402 assert(!bump);
80998403 // if (bump)
....@@ -8104,19 +8408,23 @@
81048408 // }
81058409 // else
81068410 // {
8107
- texture = textures.get(tex);
8108
- if (texture == null)
8411
+ // texturecache = textures.get(texname); // suspicious
8412
+ if (texturecache == null)
81098413 {
8110
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8414
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
81118415 }
8416
+ else
8417
+ new Exception().printStackTrace();
81128418 // }
81138419 } else
8114
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8420
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81158421 {
81168422 assert(bump);
8117
- texture = textures.get(tex);
8118
- if (texture == null)
8119
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8423
+ // texturecache = textures.get(texname); // suspicious
8424
+ if (texturecache == null)
8425
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8426
+ else
8427
+ new Exception().printStackTrace();
81208428 } else
81218429 {
81228430 //if (tex.equals("IMMORTAL"))
....@@ -8124,11 +8432,13 @@
81248432 // texture = GetResourceTexture("default.png");
81258433 //} else
81268434 //{
8127
- if (tex.equals("WHITE_NOISE"))
8435
+ if (texname.endsWith("WHITE_NOISE"))
81288436 {
8129
- texture = textures.get(tex);
8130
- if (texture == null)
8131
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8437
+ // texturecache = textures.get(texname); // suspicious
8438
+ if (texturecache == null)
8439
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8440
+ else
8441
+ new Exception().printStackTrace();
81328442 } else
81338443 {
81348444 if (textureon)
....@@ -8153,7 +8463,7 @@
81538463 }
81548464
81558465 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8156
- if (!new File(cachename).exists())
8466
+ if (!FileExists(cachename))
81578467 cachename = texname;
81588468 else
81598469 processbump = false; // don't process bump map again
....@@ -8175,7 +8485,7 @@
81758485 }
81768486
81778487 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8178
- if (!new File(cachename).exists())
8488
+ if (!FileExists(cachename))
81798489 cachename = texname;
81808490 else
81818491 processbump = false; // don't process bump map again
....@@ -8184,20 +8494,22 @@
81848494 texturedata = GetFileTexture(cachename, processbump, resolution);
81858495
81868496
8187
- if (texturedata != null)
8188
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8497
+ if (texturedata == null)
8498
+ throw new Exception();
8499
+
8500
+ texturecache = new CacheTexture(texturedata,resolution);
81898501 //texture = GetTexture(tex, bump);
81908502 }
81918503 }
81928504 //}
81938505 }
81948506
8195
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8507
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81968508 {
81978509 //return false;
81988510
81998511 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8200
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8512
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
82018513 {
82028514 // String ext = "_highres";
82038515 // if (REDUCETEXTURE)
....@@ -8214,52 +8526,17 @@
82148526 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82158527 if (!cachefile.exists())
82168528 {
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))
8529
+ //if (texturedata.getWidth() == texturedata.getHeight())
82268530 {
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);
8531
+ BufferedImage rendImage = CreateBim(texturedata);
8532
+
82578533 ImageWriter writer = null;
82588534 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82598535 if (iter.hasNext()) {
82608536 writer = (ImageWriter)iter.next();
82618537 }
8262
- float compressionQuality = 0.9f;
8538
+
8539
+ float compressionQuality = 0.85f;
82638540 try
82648541 {
82658542 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8276,18 +8553,20 @@
82768553 }
82778554 }
82788555 }
8279
-
8556
+
8557
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8558
+
82808559 //System.out.println("Texture = " + tex);
8281
- if (textures.containsKey(texname))
8560
+ if (textures.containsKey(tex))
82828561 {
8283
- CacheTexture thetex = textures.get(texname);
8562
+ CacheTexture thetex = textures.get(tex);
82848563 thetex.texture.disable();
82858564 thetex.texture.dispose();
8286
- textures.remove(texname);
8565
+ textures.remove(tex);
82878566 }
82888567
8289
- texture.texturedata = texturedata;
8290
- textures.put(texname, texture);
8568
+ //texture.texturedata = texturedata;
8569
+ textures.put(tex, texturecache);
82918570
82928571 // newtex = true;
82938572 }
....@@ -8303,10 +8582,44 @@
83038582 }
83048583 }
83058584
8306
- return texture;
8585
+ return texturecache;
83078586 }
83088587
8309
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8588
+ static void EmbedTextures(cTexture tex)
8589
+ {
8590
+ if (tex.pigmentdata == null)
8591
+ {
8592
+ //String texname = Object3D.GetPigment(tex);
8593
+
8594
+ CacheTexture texturecache = texturepigment.get(tex);
8595
+
8596
+ if (texturecache != null)
8597
+ {
8598
+ tex.pw = texturecache.texturedata.getWidth();
8599
+ tex.ph = texturecache.texturedata.getHeight();
8600
+ tex.pigmentdata = //CompressJPEG(CreateBim
8601
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8602
+ ;
8603
+ //, tex.pw, tex.ph), 0.5f);
8604
+ }
8605
+ }
8606
+
8607
+ if (tex.bumpdata == null)
8608
+ {
8609
+ //String texname = Object3D.GetBump(tex);
8610
+
8611
+ CacheTexture texturecache = texturebump.get(tex);
8612
+
8613
+ if (texturecache != null)
8614
+ {
8615
+ tex.bw = texturecache.texturedata.getWidth();
8616
+ tex.bh = texturecache.texturedata.getHeight();
8617
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8618
+ }
8619
+ }
8620
+ }
8621
+
8622
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
83108623 {
83118624 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83128625
....@@ -8324,21 +8637,21 @@
83248637 return texture!=null?texture.texture:null;
83258638 }
83268639
8327
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8640
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
83288641 {
83298642 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83308643
83318644 return texture!=null?texture.texturedata:null;
83328645 }
83338646
8334
- boolean BindTexture(String tex, boolean bump, int resolution)
8647
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83358648 {
83368649 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83378650 {
83388651 return false;
83398652 }
83408653
8341
- boolean newtex = false;
8654
+ //boolean newtex = false;
83428655
83438656 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83448657
....@@ -8370,9 +8683,75 @@
83708683 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83718684 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83728685
8373
- return newtex;
8686
+ return true; // Warning: not used.
83748687 }
83758688
8689
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8690
+ {
8691
+ try
8692
+ {
8693
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8694
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8695
+ ImageWriter writer = writers.next();
8696
+
8697
+ ImageWriteParam param = writer.getDefaultWriteParam();
8698
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8699
+ param.setCompressionQuality(quality);
8700
+
8701
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8702
+ writer.setOutput(ios);
8703
+ writer.write(null, new IIOImage(image, null, null), param);
8704
+
8705
+ byte[] data = baos.toByteArray();
8706
+ writer.dispose();
8707
+ return data;
8708
+ }
8709
+ catch (Exception e)
8710
+ {
8711
+ e.printStackTrace();
8712
+ return null;
8713
+ }
8714
+ }
8715
+
8716
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8717
+ {
8718
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8719
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8720
+ ImageReader reader = writers.next();
8721
+
8722
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8723
+
8724
+ ImageReadParam param = reader.getDefaultReadParam();
8725
+ param.setDestination(bim);
8726
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8727
+
8728
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8729
+ reader.setInput(ios);
8730
+ BufferedImage bim2 = reader.read(0, param);
8731
+ reader.dispose();
8732
+
8733
+// WritableRaster raster = bim2.getRaster();
8734
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8735
+// byte[] bytes = data.getData();
8736
+//
8737
+// int[] pixels = new int[bytes.length/3];
8738
+// for (int i=pixels.length; --i>=0;)
8739
+// {
8740
+// int i3 = i*3;
8741
+// pixels[i] = 0xFF;
8742
+// pixels[i] <<= 8;
8743
+// pixels[i] |= bytes[i3+2] & 0xFF;
8744
+// pixels[i] <<= 8;
8745
+// pixels[i] |= bytes[i3+1] & 0xFF;
8746
+// pixels[i] <<= 8;
8747
+// pixels[i] |= bytes[i3] & 0xFF;
8748
+// }
8749
+//
8750
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8751
+
8752
+ return bim;
8753
+ }
8754
+
83768755 ShadowBuffer shadowPBuf;
83778756 AntialiasBuffer antialiasPBuf;
83788757 int MAXSTACK;
....@@ -8565,7 +8944,7 @@
85658944
85668945 if (cubemap == null)
85678946 {
8568
- LoadEnvy(5);
8947
+ //LoadEnvy(1);
85698948 }
85708949
85718950 //cubemap.enable();
....@@ -8852,37 +9231,58 @@
88529231 cubemap = null;
88539232 return;
88549233 case 1:
8855
- name = "cubemaps/box_";
8856
- ext = "png";
9234
+ name = "cubemaps/rgb/";
9235
+ ext = "jpg";
88579236 reverseUP = false;
88589237 break;
88599238 case 2:
8860
- name = "cubemaps/uffizi_";
8861
- ext = "png";
8862
- break; // reverseUP = true; break;
9239
+ name = "cubemaps/uffizi/";
9240
+ ext = "jpg";
9241
+ reverseUP = false;
9242
+ break;
88639243 case 3:
8864
- name = "cubemaps/CloudyHills_";
8865
- ext = "tga";
9244
+ name = "cubemaps/CloudyHills/";
9245
+ ext = "jpg";
88669246 reverseUP = false;
88679247 break;
88689248 case 4:
8869
- name = "cubemaps/cornell_";
9249
+ name = "cubemaps/cornell/";
88709250 ext = "png";
88719251 reverseUP = false;
88729252 break;
9253
+ case 5:
9254
+ name = "cubemaps/skycube/";
9255
+ ext = "jpg";
9256
+ reverseUP = false;
9257
+ break;
9258
+ case 6:
9259
+ name = "cubemaps/SaintLazarusChurch3/";
9260
+ ext = "jpg";
9261
+ reverseUP = false;
9262
+ break;
9263
+ case 7:
9264
+ name = "cubemaps/Sodermalmsallen/";
9265
+ ext = "jpg";
9266
+ reverseUP = false;
9267
+ break;
9268
+ case 8:
9269
+ name = "cubemaps/Sodermalmsallen2/";
9270
+ ext = "jpg";
9271
+ reverseUP = false;
9272
+ break;
9273
+ case 9:
9274
+ name = "cubemaps/UnionSquare/";
9275
+ ext = "jpg";
9276
+ reverseUP = false;
9277
+ break;
88739278 default:
8874
- name = "cubemaps/rgb_";
8875
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9279
+ name = "cubemaps/box/";
9280
+ ext = "png"; /*mipmap = true;*/
9281
+ reverseUP = false;
88769282 break;
88779283 }
8878
-
8879
- try
8880
- {
8881
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
8882
- } catch (IOException e)
8883
- {
8884
- throw new RuntimeException(e);
8885
- }
9284
+
9285
+ LoadSkybox(name, ext, mipmap);
88869286 }
88879287
88889288 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -8914,8 +9314,13 @@
89149314 static double[] model = new double[16];
89159315 double[] camera2light = new double[16];
89169316 double[] light2camera = new double[16];
8917
- int newenvy = -1;
9317
+
9318
+ //int newenvy = -1;
89189319 boolean envyoff = true; // false;
9320
+ String skyboxname = "";
9321
+ String skyboxext;
9322
+ String loadedskyboxname = "";
9323
+
89199324 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
89209325 //float[] light0 = { 0,0,0 };
89219326 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9208,11 +9613,35 @@
92089613 jy8[3] = 0.5f;
92099614 }
92109615
9211
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9616
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
92129617 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
92139618 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
92149619 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92159620
9621
+ void ResetOptions()
9622
+ {
9623
+ options1[0] = 100;
9624
+ options1[1] = 0.025f;
9625
+ options1[2] = 0.01f;
9626
+ options1[3] = 0;
9627
+ options1[4] = 0;
9628
+
9629
+ options2[0] = 0;
9630
+ options2[1] = 0.75f;
9631
+ options2[2] = 0;
9632
+ options2[3] = 0;
9633
+
9634
+ options3[0] = 1;
9635
+ options3[1] = 1;
9636
+ options3[2] = 1;
9637
+ options3[3] = 0;
9638
+
9639
+ options4[0] = 1;
9640
+ options4[1] = 0;
9641
+ options4[2] = 1;
9642
+ options4[3] = 0;
9643
+ }
9644
+
92169645 static int imagecount = 0; // movie generation
92179646
92189647 static int jitter = 0;
....@@ -9308,8 +9737,8 @@
93089737 assert (parentcam != renderCamera);
93099738
93109739 if (renderCamera != lightCamera)
9311
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9312
- LA.matConcat(matrix, parentcam.toParent, matrix);
9740
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9741
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
93139742
93149743 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93159744
....@@ -9324,8 +9753,8 @@
93249753 LA.matCopy(renderCamera.fromScreen, matrix);
93259754
93269755 if (renderCamera != lightCamera)
9327
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9328
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9756
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9757
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
93299758
93309759 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93319760
....@@ -9371,10 +9800,12 @@
93719800 rati = 1 / rati;
93729801 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
93739802 }
9374
- assert (newenvy == -1);
9803
+
9804
+ //assert (newenvy == -1);
9805
+
93759806 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
93769807 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9377
- DrawSkyBox(gl);
9808
+ DrawSkyBox(gl, (float)rati);
93789809 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
93799810 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
93809811 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -9542,7 +9973,7 @@
95429973
95439974 if (!BOXMODE)
95449975 {
9545
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9976
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95469977 }
95479978
95489979 if (!BOXMODE)
....@@ -9580,7 +10011,7 @@
958010011 ABORTED = false;
958110012 }
958210013 else
9583
- GrafreeD.wav.cursor += 735 * ACSIZE;
10014
+ Grafreed.wav.cursor += 735 * ACSIZE;
958410015
958510016 if (false)
958610017 {
....@@ -10243,11 +10674,11 @@
1024310674
1024410675 public void display(GLAutoDrawable drawable)
1024510676 {
10246
- if (GrafreeD.savesound && GrafreeD.hassound)
10677
+ if (Grafreed.savesound && Grafreed.hassound)
1024710678 {
10248
- GrafreeD.wav.save();
10249
- GrafreeD.savesound = false;
10250
- GrafreeD.hassound = false;
10679
+ Grafreed.wav.save();
10680
+ Grafreed.savesound = false;
10681
+ Grafreed.hassound = false;
1025110682 }
1025210683 // if (DEBUG_SELECTION)
1025310684 // {
....@@ -10323,6 +10754,7 @@
1032310754 ANTIALIAS = 0;
1032410755 //System.out.println("RESTART");
1032510756 AAtimer.restart();
10757
+ Globals.TIMERRUNNING = true;
1032610758 }
1032710759 }
1032810760 }
....@@ -10377,7 +10809,7 @@
1037710809 Object3D theobject = object;
1037810810 Object3D theparent = object.parent;
1037910811 object.parent = null;
10380
- object = (Object3D)GrafreeD.clone(object);
10812
+ object = (Object3D)Grafreed.clone(object);
1038110813 object.Stripify();
1038210814 if (theobject.selection == null || theobject.selection.Size() == 0)
1038310815 theobject.PreprocessOcclusion(this);
....@@ -10390,13 +10822,14 @@
1039010822 ambientOcclusion = false;
1039110823 }
1039210824
10393
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10825
+ if (//Globals.lighttouched &&
10826
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1039410827 {
1039510828 //if (RENDERSHADOW) // ?
1039610829 if (!IsFrozen())
1039710830 {
1039810831 // dec 2012
10399
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10832
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1040010833 {
1040110834 Globals.framecount++;
1040210835 shadowbuffer.display();
....@@ -10523,8 +10956,8 @@
1052310956
1052410957 // if (parentcam != renderCamera) // not a light
1052510958 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(matrix, parentcam.toParent, matrix);
10959
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10960
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1052810961
1052910962 for (int j = 0; j < 4; j++)
1053010963 {
....@@ -10538,8 +10971,8 @@
1053810971
1053910972 // if (parentcam != renderCamera) // not a light
1054010973 if (cam != lightCamera)
10541
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10542
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10974
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10975
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1054310976
1054410977 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1054510978
....@@ -10625,13 +11058,19 @@
1062511058 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1062611059 }
1062711060
10628
- if (newenvy > -1)
11061
+// if (newenvy > -1)
11062
+// {
11063
+// LoadEnvy(newenvy);
11064
+// }
11065
+//
11066
+// newenvy = -1;
11067
+
11068
+ if (!skyboxname.equals(this.loadedskyboxname))
1062911069 {
10630
- LoadEnvy(newenvy);
11070
+ LoadSkybox(skyboxname + "/", skyboxext, false);
11071
+ loadedskyboxname = skyboxname;
1063111072 }
10632
-
10633
- newenvy = -1;
10634
-
11073
+
1063511074 ratio = ((double) getWidth()) / getHeight();
1063611075 //System.out.println("ratio = " + ratio);
1063711076
....@@ -10647,7 +11086,7 @@
1064711086
1064811087 if (!IsFrozen() && !ambientOcclusion)
1064911088 {
10650
- DrawSkyBox(gl);
11089
+ DrawSkyBox(gl, (float)ratio);
1065111090 }
1065211091
1065311092 //if (selection_view == -1)
....@@ -10798,7 +11237,16 @@
1079811237 // Bump noise
1079911238 gl.glActiveTexture(GL.GL_TEXTURE6);
1080011239 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10801
- BindTexture(NOISE_TEXTURE, false, 2);
11240
+
11241
+ try
11242
+ {
11243
+ BindTexture(NOISE_TEXTURE, false, 2);
11244
+ }
11245
+ catch (Exception e)
11246
+ {
11247
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11248
+ }
11249
+
1080211250
1080311251 gl.glActiveTexture(GL.GL_TEXTURE0);
1080411252 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10821,9 +11269,9 @@
1082111269
1082211270 gl.glMatrixMode(GL.GL_MODELVIEW);
1082311271
10824
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10825
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10826
-//gl.glEnable(gl.GL_MULTISAMPLE);
11272
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11273
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11274
+gl.glEnable(gl.GL_MULTISAMPLE);
1082711275 } else
1082811276 {
1082911277 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10834,7 +11282,7 @@
1083411282 //System.out.println("BLENDING ON");
1083511283 gl.glEnable(GL.GL_BLEND);
1083611284 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10837
-
11285
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1083811286 gl.glMatrixMode(gl.GL_PROJECTION);
1083911287 gl.glLoadIdentity();
1084011288
....@@ -10923,8 +11371,8 @@
1092311371 System.err.println("parentcam != renderCamera");
1092411372
1092511373 // if (cam != lightCamera)
10926
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10927
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11374
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11375
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1092811376 }
1092911377
1093011378 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10945,8 +11393,8 @@
1094511393 if (true) // TODO
1094611394 {
1094711395 if (cam != lightCamera)
10948
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10949
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11396
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11397
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1095011398 }
1095111399
1095211400 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11083,7 +11531,7 @@
1108311531 }
1108411532 }
1108511533
11086
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11534
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1108711535 {
1108811536 //gl.glDepthFunc(GL.GL_LEQUAL);
1108911537 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11091,24 +11539,21 @@
1109111539
1109211540 boolean texon = textureon;
1109311541
11094
- if (RENDERPROGRAM > 0)
11095
- {
11096
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11097
- textureon = false;
11098
- }
11542
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11543
+ textureon = false;
11544
+
1109911545 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1110011546 //System.out.println("ALLO");
1110111547 gl.glColorMask(false, false, false, false);
1110211548 DrawObject(gl);
11103
- if (RENDERPROGRAM > 0)
11104
- {
11105
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11106
- textureon = texon;
11107
- }
11549
+
11550
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11551
+ textureon = texon;
11552
+
1110811553 gl.glColorMask(true, true, true, true);
1110911554
1111011555 gl.glDepthFunc(GL.GL_EQUAL);
11111
- //gl.glDepthMask(false);
11556
+ gl.glDepthMask(false);
1111211557 }
1111311558
1111411559 if (false) // DrawMode() == SHADOW)
....@@ -11283,23 +11728,44 @@
1128311728 e.printStackTrace();
1128411729 }
1128511730
11286
- if (GrafreeD.RENDERME > 0)
11287
- GrafreeD.RENDERME--; // mechante magouille
11731
+ if (Grafreed.RENDERME > 0)
11732
+ Grafreed.RENDERME--; // mechante magouille
1128811733
1128911734 Globals.ONESTEP = false;
1129011735 }
1129111736
1129211737 static boolean zoomonce = false;
1129311738
11739
+ static void CreateSelectedPoint()
11740
+ {
11741
+ if (selectedpoint == null)
11742
+ {
11743
+ debugpointG = new Sphere();
11744
+ debugpointP = new Sphere();
11745
+ debugpointC = new Sphere();
11746
+ debugpointR = new Sphere();
11747
+
11748
+ selectedpoint = new Superellipsoid();
11749
+
11750
+ for (int i=0; i<8; i++)
11751
+ {
11752
+ debugpoints[i] = new Sphere();
11753
+ }
11754
+ }
11755
+ }
11756
+
1129411757 void DrawObject(GL gl, boolean draw)
1129511758 {
11759
+ // To clear camera values
11760
+ ResetOptions();
11761
+
1129611762 //System.out.println("DRAW OBJECT " + mouseDown);
1129711763 // DrawMode() = SELECTION;
1129811764 //GL gl = getGL();
1129911765 if ((TRACK || SHADOWTRACK) || zoomonce)
1130011766 {
1130111767 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11302
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11768
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1130311769 pingthread.StepToTarget(true); // true);
1130411770 // zoomonce = false;
1130511771 }
....@@ -11354,7 +11820,14 @@
1135411820
1135511821 usedtextures.clear();
1135611822
11357
- BindTextures(DEFAULT_TEXTURES, 2);
11823
+ try
11824
+ {
11825
+ BindTextures(DEFAULT_TEXTURES, 2);
11826
+ }
11827
+ catch (Exception e)
11828
+ {
11829
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11830
+ }
1135811831 }
1135911832 //System.out.println("--> " + stackdepth);
1136011833 // GrafreeD.traceon();
....@@ -11364,8 +11837,9 @@
1136411837
1136511838 if (DrawMode() == DEFAULT)
1136611839 {
11367
- if (DEBUG)
11840
+ if (Globals.DEBUG)
1136811841 {
11842
+ CreateSelectedPoint();
1136911843 float radius = 0.05f;
1137011844 if (selectedpoint.radius != radius)
1137111845 {
....@@ -11419,20 +11893,32 @@
1141911893 ReleaseTextures(DEFAULT_TEXTURES);
1142011894
1142111895 if (CLEANCACHE)
11422
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11896
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1142311897 {
11424
- String tex = e.nextElement();
11898
+ cTexture tex = e.nextElement();
1142511899
1142611900 // System.out.println("Texture --------- " + tex);
1142711901
11428
- if (tex.equals("WHITE_NOISE"))
11902
+ if (tex.equals("WHITE_NOISE:"))
1142911903 continue;
1143011904
11431
- if (!usedtextures.containsKey(tex))
11905
+ if (!usedtextures.contains(tex))
1143211906 {
11907
+ CacheTexture gettex = texturepigment.get(tex);
1143311908 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11434
- textures.get(tex).texture.dispose();
11435
- textures.remove(tex);
11909
+ if (gettex != null)
11910
+ {
11911
+ gettex.texture.dispose();
11912
+ texturepigment.remove(tex);
11913
+ }
11914
+
11915
+ gettex = texturebump.get(tex);
11916
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11917
+ if (gettex != null)
11918
+ {
11919
+ gettex.texture.dispose();
11920
+ texturebump.remove(tex);
11921
+ }
1143611922 }
1143711923 }
1143811924 }
....@@ -11445,7 +11931,14 @@
1144511931 if (checker != null && DrawMode() == DEFAULT)
1144611932 {
1144711933 //BindTexture(IMMORTAL_TEXTURE);
11448
- BindTextures(checker.GetTextures(), checker.texres);
11934
+ try
11935
+ {
11936
+ BindTextures(checker.GetTextures(), checker.texres);
11937
+ }
11938
+ catch (Exception e)
11939
+ {
11940
+ System.err.println("FAILED: " + checker.GetTextures());
11941
+ }
1144911942 // NEAREST
1145011943 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1145111944 DrawChecker(gl);
....@@ -11527,7 +12020,7 @@
1152712020 return;
1152812021 }
1152912022
11530
- String string = obj.GetToolTip();
12023
+ String string = obj.toString(); //.GetToolTip();
1153112024
1153212025 GL gl = GetGL();
1153312026
....@@ -11844,8 +12337,8 @@
1184412337 //obj.TransformToWorld(light, light);
1184512338 for (int i = tp.size(); --i >= 0;)
1184612339 {
11847
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11848
- LA.xformPos(light, tp.get(i).toParent, light);
12340
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12341
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1184912342 }
1185012343
1185112344
....@@ -11862,8 +12355,8 @@
1186212355 parentcam = cameras[0];
1186312356 }
1186412357
11865
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11866
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12358
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12359
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1186712360
1186812361 LA.xformPos(light, renderCamera.toScreen, light);
1186912362
....@@ -11953,8 +12446,76 @@
1195312446
1195412447 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1195512448
12449
+ String program0 =
12450
+ // Min shader
12451
+ "!!ARBfp1.0\n" +
12452
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12453
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12454
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12455
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12456
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12457
+ "PARAM light2cam0 = program.env[10];" +
12458
+ "PARAM light2cam1 = program.env[11];" +
12459
+ "PARAM light2cam2 = program.env[12];" +
12460
+ "TEMP temp;" +
12461
+ "TEMP light;" +
12462
+ "TEMP ndotl;" +
12463
+ "TEMP normal;" +
12464
+ "TEMP depth;" +
12465
+ "TEMP eye;" +
12466
+ "TEMP pos;" +
12467
+
12468
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12469
+ Normalize("normal") +
12470
+ "MOV light, state.light[0].position;" +
12471
+ "DP3 ndotl.x, light, normal;" +
12472
+
12473
+ // shadow
12474
+ "MOV pos, fragment.texcoord[1];" +
12475
+ "MOV temp, pos;" +
12476
+ ShadowTextureFetch("depth", "temp", "1") +
12477
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12478
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12479
+
12480
+ // No shadow when out of frustum
12481
+ //"SGE temp.y, depth.z, zero123.y;" +
12482
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12483
+
12484
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12485
+
12486
+ // Backlit
12487
+ "MOV pos.w, zero123.y;" +
12488
+ "DP4 eye.x, pos, light2cam0;" +
12489
+ "DP4 eye.y, pos, light2cam1;" +
12490
+ "DP4 eye.z, pos, light2cam2;" +
12491
+ Normalize("eye") +
12492
+
12493
+ "DP3 ndotl.y, -eye, normal;" +
12494
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12495
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12496
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12497
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12498
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12499
+
12500
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12501
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12502
+
12503
+ // Pigment
12504
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12505
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12506
+ "MUL temp, temp, ndotl.x;" +
12507
+
12508
+ "MUL temp, temp, zero123.z;" +
12509
+
12510
+ //"MUL temp, temp, ndotl.y;" +
12511
+
12512
+ "MOV temp.w, zero123.y;" + // reset alpha
12513
+ "MOV result.color, temp;" +
12514
+ "END";
12515
+
1195612516 String program =
1195712517 "!!ARBfp1.0\n" +
12518
+
1195812519 //"OPTION ARB_fragment_program_shadow;" +
1195912520 "PARAM light2cam0 = program.env[10];" +
1196012521 "PARAM light2cam1 = program.env[11];" +
....@@ -12069,8 +12630,7 @@
1206912630 "TEMP shininess;" +
1207012631 "\n" +
1207112632 "MOV texSamp, one;" +
12072
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12073
-
12633
+
1207412634 "MOV mapgrid.x, one2048th.x;" +
1207512635 "MOV temp, fragment.texcoord[1];" +
1207612636 /*
....@@ -12091,20 +12651,20 @@
1209112651 "MUL temp, floor, mapgrid.x;" +
1209212652 //"TEX depth0, temp, texture[1], 2D;" +
1209312653 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12094
- TextureFetch("depth0", "temp", "1") +
12654
+ ShadowTextureFetch("depth0", "temp", "1") +
1209512655 "") +
1209612656 "ADD temp.x, temp.x, mapgrid.x;" +
1209712657 //"TEX depth1, temp, texture[1], 2D;" +
1209812658 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12099
- TextureFetch("depth1", "temp", "1") +
12659
+ ShadowTextureFetch("depth1", "temp", "1") +
1210012660 "") +
1210112661 "ADD temp.y, temp.y, mapgrid.x;" +
1210212662 //"TEX depth2, temp, texture[1], 2D;" +
12103
- TextureFetch("depth2", "temp", "1") +
12663
+ ShadowTextureFetch("depth2", "temp", "1") +
1210412664 "SUB temp.x, temp.x, mapgrid.x;" +
1210512665 //"TEX depth3, temp, texture[1], 2D;" +
1210612666 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12107
- TextureFetch("depth3", "temp", "1") +
12667
+ ShadowTextureFetch("depth3", "temp", "1") +
1210812668 "") +
1210912669 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1211012670 //"MOV params, material;" +
....@@ -12475,10 +13035,10 @@
1247513035 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1247613036 "") +
1247713037
12478
- // display shadow only (bump == 0)
13038
+ // display shadow only (fakedepth == 0)
1247913039 "SUB temp.x, half.x, shadow.x;" +
12480
- "MOV temp.y, -params6.x;" +
12481
- "SLT temp.z, temp.y, zero.x;" +
13040
+ "MOV temp.y, -params5.z;" + // params6.x;" +
13041
+ "SLT temp.z, temp.y, -c256i.x;" +
1248213042 "SUB temp.y, one.x, temp.z;" +
1248313043 "MUL temp.x, temp.x, temp.y;" +
1248413044 "KIL temp.x;" +
....@@ -12809,7 +13369,7 @@
1280913369 //once = true;
1281013370 }
1281113371
12812
- System.out.print("Program #" + mode + "; length = " + program.length());
13372
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1281313373 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1281413374 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1281513375
....@@ -12902,25 +13462,26 @@
1290213462 return out;
1290313463 }
1290413464
12905
- String TextureFetch(String dest, String src, String unit)
13465
+ // Also does frustum culling
13466
+ String ShadowTextureFetch(String dest, String src, String unit)
1290613467 {
1290713468 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1290813469 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1290913470 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13471
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13472
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1291013473 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12911
- "SLT " + src + ".z, " + src + ".x, one.x;" +
12912
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12913
- "SLT " + src + ".z, " + src + ".y, one.x;" +
12914
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13474
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13475
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1291513476 //"SWZ buffer, temp, w,w,w,w;";
12916
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13477
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1291713478 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1291813479 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1291913480 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12920
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13481
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1292113482
12922
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12923
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13483
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13484
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1292413485 }
1292513486
1292613487 String Shadow(String depth, String shadow)
....@@ -12942,12 +13503,16 @@
1294213503
1294313504 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1294413505 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13506
+
13507
+ // Compare fragment depth in light space with shadowmap.
1294513508 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1294613509 "SGE temp.y, temp.x, zero.x;" +
12947
- "SUB " + shadow + ".y, one.x, temp.y;" +
13510
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13511
+
13512
+ // Reverse comparison
1294813513 "SUB temp.x, one.x, temp.x;" +
1294913514 "MUL " + shadow + ".x, temp.x, temp.y;" +
12950
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13515
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1295113516 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1295213517
1295313518 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12961,6 +13526,10 @@
1296113526 // No shadow for backface
1296213527 "DP3 temp.x, normal, lightd;" +
1296313528 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13529
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13530
+
13531
+ // No shadow when out of frustum
13532
+ "SGE temp.x, " + depth + ".z, one.z;" +
1296413533 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1296513534 "";
1296613535 }
....@@ -13107,7 +13676,8 @@
1310713676 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1310813677 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1310913678 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13110
- Object3D.cVector2[] vector2buffer;
13679
+
13680
+ //Object3D.cVector2[] vector2buffer;
1311113681
1311213682 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1311313683 // OUT : diff, spec
....@@ -13123,9 +13693,10 @@
1312313693 "DP3 " + dest + ".z," + "normals," + "eye;" +
1312413694 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1312513695 //"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;" +
13696
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13697
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13698
+
13699
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1312913700 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1313013701 "RCP " + dest + ".w," + dest + ".w;" +
1313113702 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13519,7 +14090,7 @@
1351914090 public void mousePressed(MouseEvent e)
1352014091 {
1352114092 //System.out.println("mousePressed: " + e);
13522
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14093
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1352314094 }
1352414095
1352514096 static long prevtime = 0;
....@@ -13595,8 +14166,8 @@
1359514166 // mode |= META;
1359614167 //}
1359714168
13598
- SetMouseMode(WHEEL | e.getModifiersEx());
13599
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14169
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14170
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1360014171 anchorX = ax;
1360114172 anchorY = ay;
1360214173 prevX = px;
....@@ -13630,6 +14201,7 @@
1363014201 else
1363114202 if (evt.getSource() == AAtimer)
1363214203 {
14204
+ Globals.TIMERRUNNING = false;
1363314205 if (mouseDown)
1363414206 {
1363514207 //new Exception().printStackTrace();
....@@ -13655,6 +14227,10 @@
1365514227 // LIVE = waslive;
1365614228 // wasliveok = true;
1365714229 // waslive = false;
14230
+
14231
+ // May 2019 Forget it:
14232
+ if (true)
14233
+ return;
1365814234
1365914235 // source == timer
1366014236 if (mouseDown)
....@@ -13685,7 +14261,7 @@
1368514261
1368614262 // fev 2014???
1368714263 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13688
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14264
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1368914265 pingthread.StepToTarget(true); // true);
1369014266 }
1369114267 // if (!LIVE)
....@@ -13694,12 +14270,13 @@
1369414270
1369514271 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1369614272
13697
- void clickStart(int x, int y, int modifiers)
14273
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1369814274 {
1369914275 if (!wasliveok)
1370014276 return;
1370114277
1370214278 AAtimer.restart(); //
14279
+ Globals.TIMERRUNNING = true;
1370314280
1370414281 // waslive = LIVE;
1370514282 // LIVE = false;
....@@ -13711,7 +14288,7 @@
1371114288 // touched = true; // main DL
1371214289 if (isRenderer)
1371314290 {
13714
- SetMouseMode(modifiers);
14291
+ SetMouseMode(modifiers, modifiersex);
1371514292 }
1371614293
1371714294 selectX = anchorX = x;
....@@ -13724,7 +14301,7 @@
1372414301 clicked = true;
1372514302 hold = false;
1372614303
13727
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14304
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1372814305 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1372914306 {
1373014307 // System.out.println("RESTART II " + modifiers);
....@@ -13749,14 +14326,15 @@
1374914326 drag = false;
1375014327 //System.out.println("Mouse DOWN");
1375114328 editObj = false;
13752
- ClickInfo info = new ClickInfo();
13753
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13754
- info.pane = this;
13755
- info.camera = renderCamera;
13756
- info.x = x;
13757
- info.y = y;
13758
- info.modifiers = modifiers;
13759
- editObj = object.doEditClick(info, 0);
14329
+ //ClickInfo info = new ClickInfo();
14330
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14331
+ object.clickInfo.pane = this;
14332
+ object.clickInfo.camera = renderCamera;
14333
+ object.clickInfo.x = x;
14334
+ object.clickInfo.y = y;
14335
+ object.clickInfo.modifiers = modifiersex;
14336
+ editObj = object.doEditClick(//info,
14337
+ 0);
1376014338 if (!editObj)
1376114339 {
1376214340 hasMarquee = true;
....@@ -13772,9 +14350,12 @@
1377214350
1377314351 public void mouseDragged(MouseEvent e)
1377414352 {
14353
+ Globals.MOUSEDRAGGED = true;
14354
+
1377514355 //System.out.println("mouseDragged: " + e);
1377614356 if (isRenderer)
1377714357 movingcamera = true;
14358
+
1377814359 //if (drawing)
1377914360 //return;
1378014361 if ((e.getModifiersEx() & CTRL) != 0
....@@ -13784,7 +14365,7 @@
1378414365 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1378514366 }
1378614367 else
13787
- drag(e.getX(), e.getY(), e.getModifiersEx());
14368
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1378814369
1378914370 //try { Thread.sleep(1); } catch (Exception ex) {}
1379014371 }
....@@ -14021,7 +14602,7 @@
1402114602 {
1402214603 Globals.lighttouched = true;
1402314604 }
14024
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14605
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1402514606 }
1402614607 //else
1402714608 }
....@@ -14035,12 +14616,12 @@
1403514616 void GoDown(int mod)
1403614617 {
1403714618 MODIFIERS |= COMMAND;
14038
- /*
14619
+ /**/
1403914620 if((mod&SHIFT) == SHIFT)
1404014621 manipCamera.RotatePosition(0, -speed);
1404114622 else
14042
- manipCamera.BackForth(0, -speed*delta, getWidth());
14043
- */
14623
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14624
+ /**/
1404414625 if ((mod & SHIFT) == SHIFT)
1404514626 {
1404614627 mouseMode = mouseMode; // VR??
....@@ -14056,12 +14637,12 @@
1405614637 void GoUp(int mod)
1405714638 {
1405814639 MODIFIERS |= COMMAND;
14059
- /*
14640
+ /**/
1406014641 if((mod&SHIFT) == SHIFT)
1406114642 manipCamera.RotatePosition(0, speed);
1406214643 else
14063
- manipCamera.BackForth(0, speed*delta, getWidth());
14064
- */
14644
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14645
+ /**/
1406514646 if ((mod & SHIFT) == SHIFT)
1406614647 {
1406714648 mouseMode = mouseMode;
....@@ -14077,12 +14658,12 @@
1407714658 void GoLeft(int mod)
1407814659 {
1407914660 MODIFIERS |= COMMAND;
14080
- /*
14661
+ /**/
1408114662 if((mod&SHIFT) == SHIFT)
14082
- manipCamera.RotatePosition(speed, 0);
14083
- else
1408414663 manipCamera.Translate(speed*delta, 0, getWidth());
14085
- */
14664
+ else
14665
+ manipCamera.RotatePosition(speed, 0);
14666
+ /**/
1408614667 if ((mod & SHIFT) == SHIFT)
1408714668 {
1408814669 mouseMode = mouseMode;
....@@ -14098,12 +14679,12 @@
1409814679 void GoRight(int mod)
1409914680 {
1410014681 MODIFIERS |= COMMAND;
14101
- /*
14682
+ /**/
1410214683 if((mod&SHIFT) == SHIFT)
14103
- manipCamera.RotatePosition(-speed, 0);
14104
- else
1410514684 manipCamera.Translate(-speed*delta, 0, getWidth());
14106
- */
14685
+ else
14686
+ manipCamera.RotatePosition(-speed, 0);
14687
+ /**/
1410714688 if ((mod & SHIFT) == SHIFT)
1410814689 {
1410914690 mouseMode = mouseMode;
....@@ -14121,7 +14702,7 @@
1412114702 int X, Y;
1412214703 boolean SX, SY;
1412314704
14124
- void drag(int x, int y, int modifiers)
14705
+ void drag(int x, int y, int modifiers, int modifiersex)
1412514706 {
1412614707 if (IsFrozen())
1412714708 {
....@@ -14130,17 +14711,17 @@
1413014711
1413114712 drag = true; // NEW
1413214713
14133
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14714
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1413414715
1413514716 X = x;
1413614717 Y = y;
1413714718 // floating state for animation
14138
- MODIFIERS = modifiers;
14139
- modifiers &= ~1024;
14719
+ MODIFIERS = modifiersex;
14720
+ modifiersex &= ~1024;
1414014721 if (false) // modifiers != 0)
1414114722 {
1414214723 //new Exception().printStackTrace();
14143
- System.out.println("mouseDragged: " + modifiers);
14724
+ System.out.println("mouseDragged: " + modifiersex);
1414414725 System.out.println("SHIFT = " + SHIFT);
1414514726 System.out.println("CONTROL = " + COMMAND);
1414614727 System.out.println("META = " + META);
....@@ -14153,14 +14734,16 @@
1415314734 if (editObj)
1415414735 {
1415514736 drag = true;
14156
- ClickInfo info = new ClickInfo();
14157
- info.bounds.setBounds(0, 0,
14737
+ //ClickInfo info = new ClickInfo();
14738
+ object.clickInfo.bounds.setBounds(0, 0,
1415814739 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14159
- info.pane = this;
14160
- info.camera = renderCamera;
14161
- info.x = x;
14162
- info.y = y;
14163
- object.editWindow.copy.doEditDrag(info);
14740
+ object.clickInfo.pane = this;
14741
+ object.clickInfo.camera = renderCamera;
14742
+ object.clickInfo.x = x;
14743
+ object.clickInfo.y = y;
14744
+ object //.GetWindow().copy
14745
+ .doEditDrag(//info,
14746
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1416414747 } else
1416514748 {
1416614749 if (x < startX)
....@@ -14309,22 +14892,27 @@
1430914892 }
1431014893 }
1431114894
14895
+// ClickInfo clickInfo = new ClickInfo();
14896
+
1431214897 public void mouseMoved(MouseEvent e)
1431314898 {
1431414899 //System.out.println("mouseMoved: " + e);
1431514900 if (isRenderer)
1431614901 return;
1431714902
14318
- ClickInfo ci = new ClickInfo();
14319
- ci.x = e.getX();
14320
- ci.y = e.getY();
14321
- ci.modifiers = e.getModifiersEx();
14322
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14323
- ci.pane = this;
14324
- ci.camera = renderCamera;
14903
+ // Mouse cursor feedback
14904
+ object.clickInfo.x = e.getX();
14905
+ object.clickInfo.y = e.getY();
14906
+ object.clickInfo.modifiers = e.getModifiersEx();
14907
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14908
+ object.clickInfo.pane = this;
14909
+ object.clickInfo.camera = renderCamera;
1432514910 if (!isRenderer)
1432614911 {
14327
- if (object.editWindow.copy.doEditClick(ci, 0))
14912
+ //ObjEditor editWindow = object.editWindow;
14913
+ //Object3D copy = editWindow.copy;
14914
+ if (object.doEditClick(//clickInfo,
14915
+ 0))
1432814916 {
1432914917 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1433014918 } else
....@@ -14336,7 +14924,11 @@
1433614924
1433714925 public void mouseReleased(MouseEvent e)
1433814926 {
14927
+ Globals.MOUSEDRAGGED = false;
14928
+
1433914929 movingcamera = false;
14930
+ X = 0; // getBounds().width/2;
14931
+ Y = 0; // getBounds().height/2;
1434014932 //System.out.println("mouseReleased: " + e);
1434114933 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1434214934 }
....@@ -14359,9 +14951,9 @@
1435914951 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1436014952 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1436114953
14362
- if (control || command || IsFrozen())
14954
+// No delay if (control || command || IsFrozen())
1436314955 timeout = true;
14364
- else
14956
+// ?? May 2019 else
1436514957 // timer.setDelay((modifiers & 128) != 0?0:350);
1436614958 mouseDown = false;
1436714959 if (!control && !command) // june 2013
....@@ -14471,7 +15063,7 @@
1447115063 System.out.println("keyReleased: " + e);
1447215064 }
1447315065
14474
- void SetMouseMode(int modifiers)
15066
+ void SetMouseMode(int modifiers, int modifiersex)
1447515067 {
1447615068 //System.out.println("SetMouseMode = " + modifiers);
1447715069 //modifiers &= ~1024;
....@@ -14483,7 +15075,7 @@
1448315075 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1448415076 // return;
1448515077 //System.out.println("SetMode = " + modifiers);
14486
- if ((modifiers & WHEEL) == WHEEL)
15078
+ if ((modifiersex & WHEEL) == WHEEL)
1448715079 {
1448815080 mouseMode |= ZOOM;
1448915081 }
....@@ -14493,15 +15085,15 @@
1449315085 {
1449415086 mouseMode |= VR; // BACKFORTH;
1449515087 }
14496
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15088
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1449715089 {
1449815090 mouseMode |= SELECT;
1449915091 }
14500
- if ((modifiers & COMMAND) == COMMAND)
15092
+ if ((modifiersex & COMMAND) == COMMAND)
1450115093 {
1450215094 mouseMode |= SELECT;
1450315095 }
14504
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15096
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1450515097 {
1450615098 mouseMode &= ~VR;
1450715099 mouseMode |= TRANSLATE;
....@@ -14530,7 +15122,7 @@
1453015122
1453115123 if (isRenderer) //
1453215124 {
14533
- SetMouseMode(modifiers);
15125
+ SetMouseMode(0, modifiers);
1453415126 }
1453515127
1453615128 Globals.theRenderer.keyPressed(key);
....@@ -14592,7 +15184,8 @@
1459215184 // break;
1459315185 case 'T':
1459415186 CACHETEXTURE ^= true;
14595
- textures.clear();
15187
+ texturepigment.clear();
15188
+ texturebump.clear();
1459615189 // repaint();
1459715190 break;
1459815191 case 'Y':
....@@ -14677,7 +15270,9 @@
1467715270 case 'E' : COMPACT ^= true;
1467815271 repaint();
1467915272 break;
14680
- case 'W' : DEBUGHSB ^= true;
15273
+ case 'W' : // Wide Window (fullscreen)
15274
+ //DEBUGHSB ^= true;
15275
+ ObjEditor.theFrame.ToggleFullScreen();
1468115276 repaint();
1468215277 break;
1468315278 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14702,8 +15297,8 @@
1470215297 RevertCamera();
1470315298 repaint();
1470415299 break;
14705
- case 'L':
1470615300 case 'l':
15301
+ //case 'L':
1470715302 if (lightMode)
1470815303 {
1470915304 lightMode = false;
....@@ -14773,14 +15368,18 @@
1477315368 case '3':
1477415369 case '4':
1477515370 case '5':
14776
- newenvy = Character.getNumericValue(key);
14777
- repaint();
14778
- break;
1477915371 case '6':
1478015372 case '7':
1478115373 case '8':
1478215374 case '9':
14783
- BGcolor = (key - '6')/3.f;
15375
+ if (envyoff)
15376
+ {
15377
+ BGcolor = (key - '1')/8.f;
15378
+ }
15379
+ else
15380
+ {
15381
+ //newenvy = Character.getNumericValue(key);
15382
+ }
1478415383 repaint();
1478515384 break;
1478615385 case '!':
....@@ -14846,9 +15445,9 @@
1484615445 case '_':
1484715446 kompactbit = 5;
1484815447 break;
14849
- case '+':
14850
- kompactbit = 6;
14851
- break;
15448
+// case '+':
15449
+// kompactbit = 6;
15450
+// break;
1485215451 case ' ':
1485315452 lightMode ^= true;
1485415453 Globals.lighttouched = true;
....@@ -14860,13 +15459,14 @@
1486015459 case ESC:
1486115460 RENDERPROGRAM += 1;
1486215461 RENDERPROGRAM %= 3;
15462
+
1486315463 repaint();
1486415464 break;
1486515465 case 'Z':
1486615466 //RESIZETEXTURE ^= true;
1486715467 //break;
1486815468 case 'z':
14869
- RENDERSHADOW ^= true;
15469
+ Globals.RENDERSHADOW ^= true;
1487015470 Globals.lighttouched = true;
1487115471 repaint();
1487215472 break;
....@@ -14899,8 +15499,9 @@
1489915499 case DELETE:
1490015500 ClearSelection();
1490115501 break;
14902
- /*
1490315502 case '+':
15503
+
15504
+ /*
1490415505 //fontsize += 1;
1490515506 bbzoom *= 2;
1490615507 repaint();
....@@ -14917,17 +15518,17 @@
1491715518 case '=':
1491815519 IncDepth();
1491915520 //fontsize += 1;
14920
- object.editWindow.refreshContents(true);
15521
+ object.GetWindow().refreshContents(true);
1492115522 maskbit = 6;
1492215523 break;
1492315524 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1492415525 DecDepth();
1492515526 maskbit = 5;
1492615527 //if(fontsize > 1) fontsize -= 1;
14927
- if (object.editWindow == null)
14928
- new Exception().printStackTrace();
14929
- else
14930
- object.editWindow.refreshContents(true);
15528
+// if (object.editWindow == null)
15529
+// new Exception().printStackTrace();
15530
+// else
15531
+ object.GetWindow().refreshContents(true);
1493115532 break;
1493215533 case '{':
1493315534 manipCamera.shaper_fovy /= 1.1;
....@@ -14990,7 +15591,7 @@
1499015591 //mode = ROTATE;
1499115592 if ((MODIFIERS & COMMAND) == 0) // VR??
1499215593 {
14993
- SetMouseMode(modifiers);
15594
+ SetMouseMode(0, modifiers);
1499415595 }
1499515596 }
1499615597
....@@ -15151,7 +15752,7 @@
1515115752 }
1515215753 */
1515315754
15154
- object.editWindow.EditSelection();
15755
+ object.GetWindow().EditSelection(false);
1515515756 }
1515615757
1515715758 void SelectParent()
....@@ -15168,10 +15769,10 @@
1516815769 {
1516915770 //selectees.remove(i);
1517015771 System.out.println("select parent of " + elem);
15171
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15772
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1517215773 } else
1517315774 {
15174
- group.editWindow.Select(elem.GetTreePath(), first, true);
15775
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1517515776 }
1517615777
1517715778 first = false;
....@@ -15213,12 +15814,12 @@
1521315814 for (int j = 0; j < group.children.size(); j++)
1521415815 {
1521515816 elem = (Object3D) group.children.elementAt(j);
15216
- object.editWindow.Select(elem.GetTreePath(), first, true);
15817
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1521715818 first = false;
1521815819 }
1521915820 } else
1522015821 {
15221
- object.editWindow.Select(elem.GetTreePath(), first, true);
15822
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1522215823 }
1522315824
1522415825 first = false;
....@@ -15229,21 +15830,21 @@
1522915830 {
1523015831 //Composite group = (Composite) object;
1523115832 Object3D group = object;
15232
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15833
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1523315834 }
1523415835
1523515836 void ResetTransform(int mask)
1523615837 {
1523715838 //Composite group = (Composite) object;
1523815839 Object3D group = object;
15239
- group.editWindow.ResetTransform(mask);
15840
+ group.GetWindow().ResetTransform(mask);
1524015841 }
1524115842
1524215843 void FlipTransform()
1524315844 {
1524415845 //Composite group = (Composite) object;
1524515846 Object3D group = object;
15246
- group.editWindow.FlipTransform();
15847
+ group.GetWindow().FlipTransform();
1524715848 // group.editWindow.ReduceMesh(true);
1524815849 }
1524915850
....@@ -15251,7 +15852,7 @@
1525115852 {
1525215853 //Composite group = (Composite) object;
1525315854 Object3D group = object;
15254
- group.editWindow.PrintMemory();
15855
+ group.GetWindow().PrintMemory();
1525515856 // group.editWindow.ReduceMesh(true);
1525615857 }
1525715858
....@@ -15259,7 +15860,7 @@
1525915860 {
1526015861 //Composite group = (Composite) object;
1526115862 Object3D group = object;
15262
- group.editWindow.ResetCentroid();
15863
+ group.GetWindow().ResetCentroid();
1526315864 }
1526415865
1526515866 void IncDepth()
....@@ -15341,11 +15942,11 @@
1534115942
1534215943 int width = getBounds().width;
1534315944 int height = getBounds().height;
15344
- ClickInfo info = new ClickInfo();
15345
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1534615945 //Image img = CreateImage(width, height);
1534715946 //System.out.println("width = " + width + "; height = " + height + "\n");
15947
+
1534815948 Graphics gr = g; // img.getGraphics();
15949
+
1534915950 if (!hasMarquee)
1535015951 {
1535115952 if (Xmin < Xmax) // !locked)
....@@ -15417,40 +16018,88 @@
1541716018 }
1541816019 if (object != null && !hasMarquee)
1541916020 {
16021
+ if (object.clickInfo == null)
16022
+ object.clickInfo = new ClickInfo();
16023
+ ClickInfo info = object.clickInfo;
16024
+ //ClickInfo info = new ClickInfo();
16025
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16026
+
1542016027 if (isRenderer)
1542116028 {
15422
- info.flags++;
16029
+ object.clickInfo.flags++;
1542316030 double frameAspect = (double) width / (double) height;
1542416031 if (frameAspect > renderCamera.aspect)
1542516032 {
1542616033 int desired = (int) ((double) height * renderCamera.aspect);
15427
- info.bounds.width -= width - desired;
15428
- info.bounds.x += (width - desired) / 2;
16034
+ object.clickInfo.bounds.width -= width - desired;
16035
+ object.clickInfo.bounds.x += (width - desired) / 2;
1542916036 } else
1543016037 {
1543116038 int desired = (int) ((double) width / renderCamera.aspect);
15432
- info.bounds.height -= height - desired;
15433
- info.bounds.y += (height - desired) / 2;
16039
+ object.clickInfo.bounds.height -= height - desired;
16040
+ object.clickInfo.bounds.y += (height - desired) / 2;
1543416041 }
1543516042 }
15436
- info.g = gr;
15437
- info.camera = renderCamera;
16043
+
16044
+ object.clickInfo.g = gr;
16045
+ object.clickInfo.camera = renderCamera;
1543816046 /*
1543916047 // Memory intensive (brep.verticescopy)
1544016048 if (!(object instanceof Composite))
1544116049 object.draw(info, 0, false); // SLOW :
1544216050 */
15443
- if (!isRenderer)
16051
+ if (!isRenderer) // && drag)
1544416052 {
15445
- object.drawEditHandles(info, 0);
16053
+ Grafreed.Assert(object != null);
16054
+ Grafreed.Assert(object.selection != null);
16055
+ if (object.selection.Size() > 0)
16056
+ {
16057
+ int hitSomething = object.selection.get(0).hitSomething;
16058
+
16059
+ object.clickInfo.DX = 0;
16060
+ object.clickInfo.DY = 0;
16061
+ object.clickInfo.W = 1;
16062
+ if (hitSomething == Object3D.hitCenter)
16063
+ {
16064
+ info.DX = X;
16065
+ if (X != 0)
16066
+ info.DX -= info.bounds.width/2;
16067
+
16068
+ info.DY = Y;
16069
+ if (Y != 0)
16070
+ info.DY -= info.bounds.height/2;
16071
+ }
16072
+
16073
+ object.drawEditHandles(//info,
16074
+ 0);
16075
+
16076
+ if (drag && (X != 0 || Y != 0))
16077
+ {
16078
+ switch (hitSomething)
16079
+ {
16080
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16081
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16082
+ break;
16083
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16084
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16085
+ break;
16086
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16087
+ gr.drawLine(X, Y, 0, 0);
16088
+ break;
16089
+ }
16090
+
16091
+ }
16092
+ }
1544616093 }
1544716094 }
16095
+
1544816096 if (isRenderer)
1544916097 {
1545016098 //gr.setColor(Color.black);
1545116099 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1545216100 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1545316101 }
16102
+
1545416103 if (hasMarquee)
1545516104 {
1545616105 gr.setXORMode(Color.white);
....@@ -15563,6 +16212,7 @@
1556316212 public boolean mouseDown(Event evt, int x, int y)
1556416213 {
1556516214 System.out.println("mouseDown: " + evt);
16215
+ System.exit(0);
1556616216 /*
1556716217 locked = true;
1556816218 drag = false;
....@@ -15606,7 +16256,7 @@
1560616256 {
1560716257 keyPressed(0, modifiers);
1560816258 }
15609
- clickStart(x, y, modifiers);
16259
+ // clickStart(x, y, modifiers);
1561016260 return true;
1561116261 }
1561216262
....@@ -15724,7 +16374,7 @@
1572416374 {
1572516375 keyReleased(0, 0);
1572616376 }
15727
- drag(x, y, modifiers);
16377
+ drag(x, y, 0, modifiers);
1572816378 return true;
1572916379 }
1573016380
....@@ -15856,7 +16506,7 @@
1585616506 Object3D object;
1585716507 static Object3D trackedobject;
1585816508 Camera renderCamera; // Light or Eye (or Occlusion)
15859
- /*static*/ Camera manipCamera; // Light or Eye
16509
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1586016510 /*static*/ Camera eyeCamera;
1586116511 /*static*/ Camera lightCamera;
1586216512 int cameracount;
....@@ -15952,7 +16602,9 @@
1595216602
1595316603 float BGcolor = 0.5f;
1595416604
15955
- private void DrawSkyBox(GL gl)
16605
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16606
+
16607
+ private void DrawSkyBox(GL gl, float ratio)
1595616608 {
1595716609 if (envyoff || cubemap == null)
1595816610 {
....@@ -15969,7 +16621,17 @@
1596916621 // Compensates for ExaminerViewer's modification of modelview matrix
1597016622 gl.glMatrixMode(GL.GL_MODELVIEW);
1597116623 gl.glLoadIdentity();
16624
+ gl.glScalef(1,ratio,1);
1597216625
16626
+ colorV[0] = 2;
16627
+ colorV[1] = 2;
16628
+ colorV[2] = 2;
16629
+ colorV[3] = 1;
16630
+ gl.glDisable(gl.GL_COLOR_MATERIAL);
16631
+ gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16632
+
16633
+ gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16634
+
1597316635 //gl.glActiveTexture(GL.GL_TEXTURE1);
1597416636 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1597516637
....@@ -15982,7 +16644,7 @@
1598216644 // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting
1598316645 // causes the normals to be sent down. Thanks to Ken Dyke.
1598416646 //gl.glEnable(GL.GL_LIGHTING);
15985
- gl.glDisable(GL.GL_LIGHTING);
16647
+ gl.glEnable(GL.GL_LIGHTING);
1598616648
1598716649 gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
1598816650 gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP);
....@@ -16141,16 +16803,16 @@
1614116803 cStatic.objectstack[materialdepth++] = checker;
1614216804 //System.out.println("material " + material);
1614316805 //Applet3D.tracein(this, selected);
16144
- vector2buffer = checker.projectedVertices;
16806
+ //vector2buffer = checker.projectedVertices;
1614516807
1614616808 //checker.GetMaterial().Draw(this, false); // true);
16147
- DrawMaterial(checker.GetMaterial(), false); // true);
16809
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1614816810
1614916811 materialdepth -= 1;
1615016812 if (materialdepth > 0)
1615116813 {
16152
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16153
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16814
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16815
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1615416816 }
1615516817 //checker.GetMaterial().opacity = 1f;
1615616818 ////checker.GetMaterial().ambient = 1f;
....@@ -16236,6 +16898,14 @@
1623616898 }
1623716899 }
1623816900
16901
+ private Object3D GetFolder()
16902
+ {
16903
+ Object3D folder = object.GetWindow().copy;
16904
+ if (object.GetWindow().copy.selection.Size() > 0)
16905
+ folder = object.GetWindow().copy.selection.elementAt(0);
16906
+ return folder;
16907
+ }
16908
+
1623916909 class SelectBuffer implements GLEventListener
1624016910 {
1624116911
....@@ -16251,7 +16921,7 @@
1625116921 //new Exception().printStackTrace();
1625216922 System.out.println("select buffer init");
1625316923 // Use debug pipeline
16254
- drawable.setGL(new DebugGL(drawable.getGL()));
16924
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1625516925
1625616926 GL gl = drawable.getGL();
1625716927
....@@ -16315,6 +16985,17 @@
1631516985
1631616986 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1631716987
16988
+ if (PAINTMODE)
16989
+ {
16990
+ if (object.GetWindow().copy.selection.Size() > 0)
16991
+ {
16992
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16993
+
16994
+ // Make what you paint not selectable.
16995
+ paintobj.ResetSelectable();
16996
+ }
16997
+ }
16998
+
1631816999 //int tmp = selection_view;
1631917000 //selection_view = -1;
1632017001 int temp = DrawMode();
....@@ -16326,6 +17007,17 @@
1632617007 // temp = DEFAULT; // patch for selection debug
1632717008 Globals.drawMode = temp; // WARNING
1632817009
17010
+ if (PAINTMODE)
17011
+ {
17012
+ if (object.GetWindow().copy.selection.Size() > 0)
17013
+ {
17014
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17015
+
17016
+ // Revert.
17017
+ paintobj.RestoreSelectable();
17018
+ }
17019
+ }
17020
+
1632917021 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1633017022
1633117023 // trying different ways of getting the depth info over
....@@ -16373,6 +17065,8 @@
1637317065 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1637417066 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1637517067 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17068
+
17069
+ CreateSelectedPoint();
1637617070
1637717071 // Will fit the mesh !!!
1637817072 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16422,34 +17116,36 @@
1642217116 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]));
1642317117 }
1642417118
16425
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17119
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1642617120 }
1642717121 }
1642817122
1642917123 if (!movingcamera && !PAINTMODE)
16430
- object.editWindow.ScreenFitPoint(); // fev 2014
17124
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1643117125
16432
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17126
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1643317127 {
16434
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17128
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1643517129
16436
- Object3D group = new Object3D("inst" + paintcount++);
17130
+ if (object.GetWindow().copy.selection.Size() > 0)
17131
+ {
17132
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1643717133
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();
17134
+ Object3D inst = new Object3D("inst" + paintcount++);
17135
+
17136
+ inst.CreateMaterial(); // use a void leaf to select instances
17137
+
17138
+ inst.add(paintobj); // link
17139
+
17140
+ object.GetWindow().SnapObject(inst);
17141
+
17142
+ Object3D folder = paintFolder; // GetFolder();
17143
+
17144
+ folder.add(inst);
17145
+
17146
+ object.GetWindow().ResetModel();
17147
+ object.GetWindow().refreshContents();
17148
+ }
1645317149 }
1645417150 else
1645517151 paintcount = 0;
....@@ -16488,6 +17184,11 @@
1648817184 //System.out.println("objects[color] = " + objects[color]);
1648917185 //objects[color].Select();
1649017186 indexcount = 0;
17187
+ ObjEditor window = object.GetWindow();
17188
+ if (window != null && deselect)
17189
+ {
17190
+ window.Select(null, deselect, true);
17191
+ }
1649117192 object.Select(color, deselect);
1649217193 }
1649317194
....@@ -16587,7 +17288,7 @@
1658717288 gl.glDisable(gl.GL_CULL_FACE);
1658817289 }
1658917290
16590
- if (!RENDERSHADOW)
17291
+ if (!Globals.RENDERSHADOW)
1659117292 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1659217293
1659317294 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16597,7 +17298,7 @@
1659717298 //gl.glColorMask(false, false, false, false);
1659817299
1659917300 //render_scene_from_light_view(gl, drawable, 0, 0);
16600
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17301
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1660117302 {
1660217303 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1660317304
....@@ -17013,23 +17714,15 @@
1701317714 int AAbuffersize = 0;
1701417715
1701517716 //double[] selectedpoint = new double[3];
17016
- static Superellipsoid selectedpoint = new Superellipsoid();
17717
+ static Superellipsoid selectedpoint;
1701717718 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();
17719
+ static Sphere debugpointG;
17720
+ static Sphere debugpointP;
17721
+ static Sphere debugpointC;
17722
+ static Sphere debugpointR;
1702217723
1702317724 static Sphere debugpoints[] = new Sphere[8];
1702417725
17025
- static
17026
- {
17027
- for (int i=0; i<8; i++)
17028
- {
17029
- debugpoints[i] = new Sphere();
17030
- }
17031
- }
17032
-
1703317726 static void InitPoints(float radius)
1703417727 {
1703517728 for (int i=0; i<8; i++)