Normand Briere
2019-07-25 7058eef32e524cae08a7373d8bc1061e373b223c
CameraPane.java
....@@ -18,7 +18,10 @@
1818 import javax.imageio.ImageIO;
1919 import javax.imageio.ImageWriteParam;
2020 import javax.imageio.ImageWriter;
21
+import javax.imageio.ImageReadParam;
22
+import javax.imageio.ImageReader;
2123 import javax.imageio.plugins.jpeg.JPEGImageWriteParam;
24
+import javax.imageio.stream.ImageInputStream;
2225 import javax.imageio.stream.ImageOutputStream;
2326 import javax.imageio.ImageWriteParam;
2427
....@@ -30,6 +33,7 @@
3033 import java.nio.*;
3134
3235 import gleem.linalg.Mat4f;
36
+import javax.imageio.ImageTypeSpecifier;
3337
3438 class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener
3539 {
....@@ -37,7 +41,6 @@
3741 static boolean[] selectedstack = new boolean[65536];
3842 static int materialdepth = 0;
3943
40
- static boolean DEBUG = false;
4144 static boolean FRUSTUM = false; // still bogus true; // frustum culling
4245
4346 // camera change fix
....@@ -45,6 +48,39 @@
4548 static boolean ABORTED = false;
4649
4750 static int STEP = 1;
51
+
52
+ private static BufferedImage CreateBim(byte[] bytes, int width, int height)
53
+ {
54
+ int[] pixels = new int[bytes.length/3];
55
+ for (int i=pixels.length; --i>=0;)
56
+ {
57
+ int i3 = i*3;
58
+ pixels[i] = 0xFF;
59
+ pixels[i] <<= 8;
60
+ pixels[i] |= bytes[i3+2] & 0xFF;
61
+ pixels[i] <<= 8;
62
+ pixels[i] |= bytes[i3+1] & 0xFF;
63
+ pixels[i] <<= 8;
64
+ pixels[i] |= bytes[i3] & 0xFF;
65
+ }
66
+ /*
67
+ int r=0,g=0,b=0,a=0;
68
+ for (int i=0; i<width; i++)
69
+ for (int j=0; j<height; j++)
70
+ {
71
+ int index = j*width+i;
72
+ int p = pixels[index];
73
+ a = ((p>>24) & 0xFF);
74
+ r = ((p>>16) & 0xFF);
75
+ g = ((p>>8) & 0xFF);
76
+ b = (p & 0xFF);
77
+ pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
78
+ }
79
+ /**/
80
+ BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
81
+ rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
82
+ return rendImage;
83
+ }
4884
4985 /*static*/ private boolean CULLFACE = false; // true;
5086 /*static*/ boolean NEAREST = false; // true;
....@@ -56,14 +92,12 @@
5692 static int CURRENTANTIALIAS = 0; // 1;
5793 /*static*/ boolean RENDERSHADOW = true;
5894 /*static*/ int RENDERPROGRAM = 2; // 0 == none, 1 == fast, 2 == normal
59
- static boolean ANIMATION = false;
60
- static String filename;
6195
6296 boolean DISPLAYTEXT = false;
6397 //boolean REDUCETEXTURE = true;
6498 boolean CACHETEXTURE = true;
6599 boolean CLEANCACHE = false; // true;
66
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
67101 boolean COMPRESSTEXTURE = false;
68102 boolean KOMPACTTEXTURE = false; // true;
69103 boolean RESIZETEXTURE = false;
....@@ -92,6 +126,8 @@
92126
93127 static int tickcount = 0; // slow pose issue
94128
129
+static boolean BUTTONLESSWHEEL = false;
130
+static boolean ZOOMBOXMODE = false;
95131 static boolean BOXMODE = false;
96132 static boolean IMAGEFLIP = false;
97133 static boolean SMOOTHFOCUS = false;
....@@ -106,7 +142,7 @@
106142 static boolean OEIL = true;
107143 static boolean OEILONCE = false; // do oeilon then oeiloff
108144 static boolean LOOKAT = true;
109
-static boolean RANDOM = true; // false;
145
+static boolean SWITCH = true; // false;
110146 static boolean HANDLES = false; // selection doesn't work!!
111147 static boolean PAINTMODE = false;
112148
....@@ -150,6 +186,8 @@
150186 defaultcaps.setAccumAlphaBits(16);
151187 }
152188
189
+ private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190
+
153191 void SetAsGLRenderer(boolean b)
154192 {
155193 isRenderer = b;
....@@ -168,7 +206,8 @@
168206
169207 SetCamera(cam);
170208
171
- SetLight(new Camera(new cVector(10, 10, -20)));
209
+ // Warning: not used.
210
+ SetLight(new Camera(new cVector(15, 10, -20)));
172211
173212 object = o;
174213
....@@ -223,6 +262,11 @@
223262 public boolean IsBoxMode()
224263 {
225264 return BOXMODE;
265
+ }
266
+
267
+ public boolean IsZoomBoxMode()
268
+ {
269
+ return ZOOMBOXMODE;
226270 }
227271
228272 public void ClearDepth()
....@@ -320,7 +364,7 @@
320364 cStatic.objectstack[materialdepth++] = obj;
321365 //System.out.println("material " + material);
322366 //Applet3D.tracein(this, selected);
323
- display.vector2buffer = obj.projectedVertices;
367
+ //display.vector2buffer = obj.projectedVertices;
324368 if (obj instanceof Camera)
325369 {
326370 display.options1[0] = material.shift;
....@@ -329,14 +373,28 @@
329373 display.options1[2] = material.shadowbias;
330374 display.options1[3] = material.aniso;
331375 display.options1[4] = material.anisoV;
376
+// System.out.println("display.options1[0] " + display.options1[0]);
377
+// System.out.println("display.options1[1] " + display.options1[1]);
378
+// System.out.println("display.options1[2] " + display.options1[2]);
379
+// System.out.println("display.options1[3] " + display.options1[3]);
380
+// System.out.println("display.options1[4] " + display.options1[4]);
332381 display.options2[0] = material.opacity;
333382 display.options2[1] = material.diffuse;
334383 display.options2[2] = material.factor;
384
+// System.out.println("display.options2[0] " + display.options2[0]);
385
+// System.out.println("display.options2[1] " + display.options2[1]);
386
+// System.out.println("display.options2[2] " + display.options2[2]);
335387
336388 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
389
+// System.out.println("display.options3[0] " + display.options3[0]);
390
+// System.out.println("display.options3[1] " + display.options3[1]);
391
+// System.out.println("display.options3[2] " + display.options3[2]);
337392 display.options4[0] = material.cameralight/0.2f;
338393 display.options4[1] = material.subsurface;
339394 display.options4[2] = material.sheen;
395
+// System.out.println("display.options4[0] " + display.options4[0]);
396
+// System.out.println("display.options4[1] " + display.options4[1]);
397
+// System.out.println("display.options4[2] " + display.options4[2]);
340398
341399 // if (display.CURRENTANTIALIAS > 0)
342400 // display.options3[3] /= 4;
....@@ -352,7 +410,7 @@
352410 /**/
353411 } else
354412 {
355
- DrawMaterial(material, selected);
413
+ DrawMaterial(material, selected, obj.projectedVertices);
356414 }
357415 } else
358416 {
....@@ -376,8 +434,8 @@
376434 cStatic.objectstack[materialdepth++] = obj;
377435 //System.out.println("material " + material);
378436 //Applet3D.tracein("selected ", selected);
379
- display.vector2buffer = obj.projectedVertices;
380
- display.DrawMaterial(material, selected);
437
+ //display.vector2buffer = obj.projectedVertices;
438
+ display.DrawMaterial(material, selected, obj.projectedVertices);
381439 }
382440 }
383441
....@@ -394,8 +452,8 @@
394452 materialdepth -= 1;
395453 if (materialdepth > 0)
396454 {
397
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
398
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
455
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
456
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
399457 }
400458 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
401459 } else if (selected && CameraPane.flash && obj.GetMaterial() != null)
....@@ -415,8 +473,8 @@
415473 materialdepth -= 1;
416474 if (materialdepth > 0)
417475 {
418
- display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
419
- display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
476
+ //display.vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
477
+ display.DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
420478 }
421479 //Applet3D.traceout("selected ", (stackdepth>0)?selectedstack[stackdepth-1]:"???");
422480 //else
....@@ -457,10 +515,12 @@
457515 if (!selectmode) // display.drawMode != display.SELECTION) // && display.drawMode != display.SHADOW) // (attributes & FILL) != 0)
458516 {
459517 //gl.glBegin(gl.GL_TRIANGLES);
460
- boolean hasnorm = pv.norm != null; // && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0);
518
+ boolean hasnorm = pv.norm != null && (pv.norm.x != 0 || pv.norm.y != 0 || pv.norm.z != 0)
519
+ // TEST LIVE NORMALS && !obj.dontselect
520
+ ;
461521 if (!hasnorm)
462522 {
463
- // System.out.println("FUCK!!");
523
+ // System.out.println("Mesh normal");
464524 LA.vecSub(pv/*.pos*/, qv/*.pos*/, obj.v0);
465525 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
466526 LA.vecCross(obj.v0, obj.v1, obj.v2);
....@@ -1185,10 +1245,12 @@
11851245 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
11861246 }
11871247 }
1248
+
11881249 if (flipV)
11891250 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
11901251 else
11911252 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1253
+
11921254 //System.out.println("vertex1 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
11931255 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
11941256
....@@ -1208,10 +1270,12 @@
12081270 gl.glColor4f(c[count3/3], c[count3/3 /* + 1*/], c[count3/3 /* + 2*/], 1);
12091271 }
12101272 }
1273
+
12111274 if (flipV)
12121275 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12131276 else
12141277 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1278
+
12151279 //System.out.println("vertex2 = " + v[count3] + ", " + v[count3+1] + ", " + v[count3+2]);
12161280 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
12171281
....@@ -1239,8 +1303,10 @@
12391303 gl.glTexCoord2f(uv[count2], 1-uv[count2 + 1]);
12401304 else
12411305 gl.glTexCoord2f(uv[count2], uv[count2 + 1]);
1306
+
12421307 //System.out.println("coord3 = " + uv[count2] + ", " + uv[count2+1]);
12431308 gl.glVertex3f(v[count3], v[count3 + 1], v[count3 + 2]);
1309
+
12441310 count2 += 2;
12451311 count3 += 3;
12461312 }
....@@ -1596,7 +1662,7 @@
15961662 // gl.glMaterialfv(gl.GL_BACK, gl.GL_DIFFUSE, colorV, 0);
15971663 }
15981664
1599
- void DrawMaterial(cMaterial material, boolean selected)
1665
+ void DrawMaterial(cMaterial material, boolean selected, Object3D.cVector2[] others)
16001666 {
16011667 CameraPane display = this;
16021668 //new Exception().printStackTrace();
....@@ -1612,18 +1678,18 @@
16121678 //col.getColorComponents(ColorSpace.getInstance(ColorSpace.CS_LINEAR_RGB), CameraPane.modelParams0);
16131679 if (!material.multiply)
16141680 {
1615
- display.color = color;
1681
+ display.color = material.color;
16161682 display.saturation = material.modulation;
16171683 }
16181684 else
16191685 {
1620
- display.color *= color*2;
1686
+ display.color *= material.color*2;
16211687 display.saturation *= material.modulation*2;
16221688 }
16231689
16241690 cColor.HSBtoRGB(display.color, display.saturation, 1, display.modelParams0);
16251691
1626
- float[] colorV = GrafreeD.colorV;
1692
+ float[] colorV = Grafreed.colorV;
16271693
16281694 /**/
16291695 if (display.DrawMode() == display.DEFAULT) // && display.RENDERPROGRAM == 0)
....@@ -1631,7 +1697,7 @@
16311697 colorV[0] = display.modelParams0[0] * material.diffuse;
16321698 colorV[1] = display.modelParams0[1] * material.diffuse;
16331699 colorV[2] = display.modelParams0[2] * material.diffuse;
1634
- colorV[3] = material.opacity;
1700
+ colorV[3] = 1; // material.opacity;
16351701
16361702 gl.glColor4f(colorV[0], colorV[1], colorV[2], material.opacity);
16371703 //System.out.println("Opacity = " + opacity);
....@@ -1739,9 +1805,9 @@
17391805 display.modelParams7[2] = 0;
17401806 display.modelParams7[3] = 0;
17411807
1742
- display.modelParams6[0] = 100; // criss de bug de bump
1808
+ //display.modelParams6[0] = 100; // criss de bug de bump
17431809
1744
- Object3D.cVector2[] extparams = display.vector2buffer;
1810
+ Object3D.cVector2[] extparams = others; // display.vector2buffer;
17451811 if (extparams != null && extparams.length > 0 && extparams[0] != null)
17461812 {
17471813 display.modelParams6[0] = extparams[0].x / 1000.0f; // bump
....@@ -1883,7 +1949,7 @@
18831949 void PushMatrix(double[][] matrix)
18841950 {
18851951 // GrafreeD.tracein(matrix);
1886
- PushMatrix(matrix,1);
1952
+ PushMatrix(matrix, 1);
18871953 }
18881954
18891955 void PushMatrix()
....@@ -2037,7 +2103,7 @@
20372103 //System.err.println("Oeil on");
20382104 OEIL = true;
20392105 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2040
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2106
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20412107 //pingthread.StepToTarget(true);
20422108 }
20432109
....@@ -2135,7 +2201,7 @@
21352201 System.err.println("LIVE = " + Globals.isLIVE());
21362202
21372203 if (!Globals.isLIVE()) // save sound
2138
- GrafreeD.savesound = true; // wav.save();
2204
+ Grafreed.savesound = true; // wav.save();
21392205 // else
21402206 repaint(); // start loop // may 2013
21412207 }
....@@ -2168,6 +2234,11 @@
21682234 public void ToggleBoxMode()
21692235 {
21702236 BOXMODE ^= true;
2237
+ }
2238
+
2239
+ public void ToggleZoomBoxMode()
2240
+ {
2241
+ ZOOMBOXMODE ^= true;
21712242 }
21722243
21732244 public void ToggleSmoothFocus()
....@@ -2247,7 +2318,7 @@
22472318
22482319 void ToggleDebug()
22492320 {
2250
- DEBUG ^= true;
2321
+ Globals.DEBUG ^= true;
22512322 }
22522323
22532324 void ToggleLookAt()
....@@ -2255,9 +2326,9 @@
22552326 LOOKAT ^= true;
22562327 }
22572328
2258
- void ToggleRandom()
2329
+ void ToggleSwitch()
22592330 {
2260
- RANDOM ^= true;
2331
+ SWITCH ^= true;
22612332 }
22622333
22632334 void ToggleHandles()
....@@ -2265,10 +2336,17 @@
22652336 HANDLES ^= true;
22662337 }
22672338
2339
+ Object3D paintFolder;
2340
+
22682341 void TogglePaint()
22692342 {
22702343 PAINTMODE ^= true;
22712344 paintcount = 0;
2345
+
2346
+ if (PAINTMODE)
2347
+ {
2348
+ paintFolder = GetFolder();
2349
+ }
22722350 }
22732351
22742352 void SwapCamera(int a, int b)
....@@ -2364,7 +2442,22 @@
23642442 {
23652443 return currentGL;
23662444 }
2367
-
2445
+
2446
+ static private BufferedImage CreateBim(TextureData texturedata)
2447
+ {
2448
+ Grafreed.Assert(texturedata != null);
2449
+
2450
+ int width = texturedata.getWidth();
2451
+ int height = texturedata.getHeight();
2452
+
2453
+ Buffer buffer = texturedata.getBuffer();
2454
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2455
+
2456
+ byte[] bytes = bytebuf.array();
2457
+
2458
+ return CreateBim(bytes, width, height);
2459
+ }
2460
+
23682461 /**/
23692462 class CacheTexture
23702463 {
....@@ -2373,28 +2466,31 @@
23732466
23742467 int resolution;
23752468
2376
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2469
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23772470 {
2378
- texture = tex;
2471
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2472
+ texturedata = texdata;
23792473 resolution = res;
23802474 }
23812475 }
23822476 /**/
23832477
23842478 // TEXTURE static Texture texture;
2385
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2386
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2387
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2479
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2480
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2481
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2482
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2483
+
23882484 int pigmentdepth = 0;
23892485 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
23902486 int bumpdepth = 0;
23912487 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
23922488 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
23932489 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2394
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2490
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
23952491 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
23962492
2397
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2493
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
23982494 {
23992495 TextureData texturedata = null;
24002496
....@@ -2413,13 +2509,34 @@
24132509 if (bump)
24142510 texturedata = ConvertBump(texturedata, false);
24152511
2416
- com.sun.opengl.util.texture.Texture texture =
2417
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2512
+// com.sun.opengl.util.texture.Texture texture =
2513
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24182514
2419
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2420
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2515
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2516
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24212517
2422
- return texture;
2518
+ return texturedata;
2519
+ }
2520
+
2521
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2522
+ {
2523
+ TextureData texturedata = null;
2524
+
2525
+ try
2526
+ {
2527
+ texturedata =
2528
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2529
+ bim,
2530
+ true);
2531
+ } catch (Exception e)
2532
+ {
2533
+ throw new javax.media.opengl.GLException(e);
2534
+ }
2535
+
2536
+ if (bump)
2537
+ texturedata = ConvertBump(texturedata, false);
2538
+
2539
+ return texturedata;
24232540 }
24242541
24252542 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3492,6 +3609,8 @@
34923609
34933610 System.out.println("LOADING TEXTURE : " + name);
34943611
3612
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3613
+
34953614 //
34963615 if (false) // compressbit > 0)
34973616 {
....@@ -4196,6 +4315,7 @@
41964315
41974316 com.sun.opengl.util.texture.Texture CompressTexture2(String name)
41984317 {
4318
+ new Exception().printStackTrace();
41994319 System.exit(0);
42004320 com.sun.opengl.util.texture.Texture texture = null;
42014321
....@@ -7889,7 +8009,7 @@
78898009 String pigment = Object3D.GetPigment(tex);
78908010 String bump = Object3D.GetBump(tex);
78918011
7892
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8012
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
78938013 {
78948014 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
78958015 // System.out.println("; bump = " + bump);
....@@ -7904,11 +8024,69 @@
79048024 pigment = null;
79058025 }
79068026
7907
- ReleaseTexture(bump, true);
7908
- ReleaseTexture(pigment, false);
8027
+ ReleaseTexture(tex, true);
8028
+ ReleaseTexture(tex, false);
79098029 }
79108030
7911
- void ReleaseTexture(String tex, boolean bump)
8031
+ public void ReleasePigmentTexture(cTexture tex) // INTERFACE
8032
+ {
8033
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8034
+ {
8035
+ return;
8036
+ }
8037
+
8038
+ if (tex == null)
8039
+ {
8040
+ ReleaseTexture(null, false);
8041
+ return;
8042
+ }
8043
+
8044
+ String pigment = Object3D.GetPigment(tex);
8045
+
8046
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8047
+ {
8048
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8049
+ // System.out.println("; bump = " + bump);
8050
+ }
8051
+
8052
+ if (pigment.equals(""))
8053
+ {
8054
+ pigment = null;
8055
+ }
8056
+
8057
+ ReleaseTexture(tex, false);
8058
+ }
8059
+
8060
+ public void ReleaseBumpTexture(cTexture tex) // INTERFACE
8061
+ {
8062
+ if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
8063
+ {
8064
+ return;
8065
+ }
8066
+
8067
+ if (tex == null)
8068
+ {
8069
+ ReleaseTexture(null, true);
8070
+ return;
8071
+ }
8072
+
8073
+ String bump = Object3D.GetBump(tex);
8074
+
8075
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8076
+ {
8077
+ // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
8078
+ // System.out.println("; bump = " + bump);
8079
+ }
8080
+
8081
+ if (bump.equals(""))
8082
+ {
8083
+ bump = null;
8084
+ }
8085
+
8086
+ ReleaseTexture(tex, true);
8087
+ }
8088
+
8089
+ void ReleaseTexture(cTexture tex, boolean bump)
79128090 {
79138091 if (// DrawMode() != 0 || /*tex == null ||*/
79148092 ambientOcclusion ) // || !textureon)
....@@ -7919,7 +8097,7 @@
79198097 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79208098
79218099 if (tex != null)
7922
- texture = textures.get(tex);
8100
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
79238101
79248102 // //assert( texture != null );
79258103 // if (texture == null)
....@@ -8011,7 +8189,55 @@
80118189 }
80128190 }
80138191
8014
- /*boolean*/ public void BindTextures(cTexture tex, int resolution) // INTERFACE
8192
+ /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
8193
+ {
8194
+// if (// DrawMode() != 0 || /*tex == null ||*/
8195
+// ambientOcclusion ) // || !textureon)
8196
+// {
8197
+// return; // false;
8198
+// }
8199
+//
8200
+// if (tex == null)
8201
+// {
8202
+// BindTexture(null,false,resolution);
8203
+// BindTexture(null,true,resolution);
8204
+// return;
8205
+// }
8206
+//
8207
+// String pigment = Object3D.GetPigment(tex);
8208
+// String bump = Object3D.GetBump(tex);
8209
+//
8210
+// usedtextures.add(pigment);
8211
+// usedtextures.add(bump);
8212
+//
8213
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8214
+// {
8215
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8216
+// // System.out.println("; bump = " + bump);
8217
+// }
8218
+//
8219
+// if (bump.equals(""))
8220
+// {
8221
+// bump = null;
8222
+// }
8223
+// if (pigment.equals(""))
8224
+// {
8225
+// pigment = null;
8226
+// }
8227
+//
8228
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8229
+// BindTexture(pigment, false, resolution);
8230
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8231
+// BindTexture(bump, true, resolution);
8232
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8233
+//
8234
+// return; // true;
8235
+
8236
+ BindPigmentTexture(tex, resolution);
8237
+ BindBumpTexture(tex, resolution);
8238
+ }
8239
+
8240
+ /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
80158241 {
80168242 if (// DrawMode() != 0 || /*tex == null ||*/
80178243 ambientOcclusion ) // || !textureon)
....@@ -8022,17 +8248,47 @@
80228248 if (tex == null)
80238249 {
80248250 BindTexture(null,false,resolution);
8025
- BindTexture(null,true,resolution);
80268251 return;
80278252 }
80288253
80298254 String pigment = Object3D.GetPigment(tex);
8255
+
8256
+ usedtextures.add(tex);
8257
+
8258
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8259
+ {
8260
+ // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8261
+ // System.out.println("; bump = " + bump);
8262
+ }
8263
+
8264
+ if (pigment.equals(""))
8265
+ {
8266
+ pigment = null;
8267
+ }
8268
+
8269
+ GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8270
+ BindTexture(tex, false, resolution);
8271
+ }
8272
+
8273
+ /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
8274
+ {
8275
+ if (// DrawMode() != 0 || /*tex == null ||*/
8276
+ ambientOcclusion ) // || !textureon)
8277
+ {
8278
+ return; // false;
8279
+ }
8280
+
8281
+ if (tex == null)
8282
+ {
8283
+ BindTexture(null,true,resolution);
8284
+ return;
8285
+ }
8286
+
80308287 String bump = Object3D.GetBump(tex);
80318288
8032
- usedtextures.put(pigment, pigment);
8033
- usedtextures.put(bump, bump);
8289
+ usedtextures.add(tex);
80348290
8035
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8291
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80368292 {
80378293 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
80388294 // System.out.println("; bump = " + bump);
....@@ -8042,43 +8298,94 @@
80428298 {
80438299 bump = null;
80448300 }
8045
- if (pigment.equals(""))
8046
- {
8047
- pigment = null;
8048
- }
80498301
8050
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8051
- BindTexture(pigment, false, resolution);
80528302 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8053
- BindTexture(bump, true, resolution);
8303
+ BindTexture(tex, true, resolution);
80548304 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8055
-
8056
- return; // true;
80578305 }
80588306
8059
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution)
8307
+ java.util.HashSet<String> missingTextures = new java.util.HashSet<String>();
8308
+
8309
+ private boolean FileExists(String tex)
80608310 {
8061
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8311
+ if (missingTextures.contains(tex))
8312
+ {
8313
+ return false;
8314
+ }
8315
+
8316
+ boolean fileExists = new File(tex).exists();
8317
+
8318
+ if (!fileExists)
8319
+ {
8320
+ // If file exists, the "new File()" is not executed sgain
8321
+ missingTextures.add(tex);
8322
+ }
8323
+
8324
+ return fileExists;
8325
+ }
8326
+
8327
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
8328
+ {
8329
+ CacheTexture texturecache = null;
80628330
80638331 if (tex != null)
80648332 {
8065
- String texname = tex;
8333
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8334
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
80668335
8067
- String[] split = tex.split("Textures");
8068
- if (split.length > 1)
8069
- texname = "/Users/nbriere/Textures" + split[split.length-1];
8070
- else
8071
- if (!texname.startsWith("/"))
8072
- texname = "/Users/nbriere/Textures/" + texname;
8336
+ if (texname.equals("") && texdata == null)
8337
+ {
8338
+ return null;
8339
+ }
8340
+
8341
+ String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
8342
+
8343
+// String[] split = tex.split("Textures");
8344
+// if (split.length > 1)
8345
+// texname = "/Users/nbriere/Textures" + split[split.length-1];
8346
+// else
8347
+// if (!texname.startsWith("/"))
8348
+// texname = "/Users/nbriere/Textures/" + texname;
8349
+ if (!FileExists(texname))
8350
+ {
8351
+ texname = fallbackTextureName;
8352
+ }
80738353
80748354 if (CACHETEXTURE)
8075
- texture = textures.get(texname); // TEXTURE CACHE
8076
-
8077
- TextureData texturedata = null;
8078
-
8079
- if (texture == null || texture.resolution < resolution)
80808355 {
8081
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8356
+ if (texdata == null)
8357
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8358
+ else
8359
+ texturecache = bimtextures.get(texdata);
8360
+ }
8361
+
8362
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8363
+ {
8364
+ TextureData texturedata = null;
8365
+
8366
+ if (texdata != null && textureon)
8367
+ {
8368
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8369
+
8370
+ try
8371
+ {
8372
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8373
+ }
8374
+ catch (Exception e)
8375
+ {
8376
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8377
+ }
8378
+
8379
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8380
+ bimtextures.put(texdata, texturecache);
8381
+
8382
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8383
+
8384
+ //Object bim2 = CreateBim(texturecache.texturedata);
8385
+ //bim2 = bim;
8386
+ }
8387
+ else
8388
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
80828389 {
80838390 assert(!bump);
80848391 // if (bump)
....@@ -8089,19 +8396,23 @@
80898396 // }
80908397 // else
80918398 // {
8092
- texture = textures.get(tex);
8093
- if (texture == null)
8399
+ // texturecache = textures.get(texname); // suspicious
8400
+ if (texturecache == null)
80948401 {
8095
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8402
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
80968403 }
8404
+ else
8405
+ new Exception().printStackTrace();
80978406 // }
80988407 } else
8099
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8408
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
81008409 {
81018410 assert(bump);
8102
- texture = textures.get(tex);
8103
- if (texture == null)
8104
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8411
+ // texturecache = textures.get(texname); // suspicious
8412
+ if (texturecache == null)
8413
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8414
+ else
8415
+ new Exception().printStackTrace();
81058416 } else
81068417 {
81078418 //if (tex.equals("IMMORTAL"))
....@@ -8109,11 +8420,13 @@
81098420 // texture = GetResourceTexture("default.png");
81108421 //} else
81118422 //{
8112
- if (tex.equals("WHITE_NOISE"))
8423
+ if (texname.endsWith("WHITE_NOISE"))
81138424 {
8114
- texture = textures.get(tex);
8115
- if (texture == null)
8116
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8425
+ // texturecache = textures.get(texname); // suspicious
8426
+ if (texturecache == null)
8427
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8428
+ else
8429
+ new Exception().printStackTrace();
81178430 } else
81188431 {
81198432 if (textureon)
....@@ -8138,7 +8451,7 @@
81388451 }
81398452
81408453 cachename = texname.substring(0, texname.length()-4)+ext+".jpg";
8141
- if (!new File(cachename).exists())
8454
+ if (!FileExists(cachename))
81428455 cachename = texname;
81438456 else
81448457 processbump = false; // don't process bump map again
....@@ -8160,7 +8473,7 @@
81608473 }
81618474
81628475 cachename = texname.substring(0, texname.length()-4)+ext+".png";
8163
- if (!new File(cachename).exists())
8476
+ if (!FileExists(cachename))
81648477 cachename = texname;
81658478 else
81668479 processbump = false; // don't process bump map again
....@@ -8169,20 +8482,22 @@
81698482 texturedata = GetFileTexture(cachename, processbump, resolution);
81708483
81718484
8172
- if (texturedata != null)
8173
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8485
+ if (texturedata == null)
8486
+ throw new Exception();
8487
+
8488
+ texturecache = new CacheTexture(texturedata,resolution);
81748489 //texture = GetTexture(tex, bump);
81758490 }
81768491 }
81778492 //}
81788493 }
81798494
8180
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8495
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
81818496 {
81828497 //return false;
81838498
81848499 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8185
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8500
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
81868501 {
81878502 // String ext = "_highres";
81888503 // if (REDUCETEXTURE)
....@@ -8199,52 +8514,17 @@
81998514 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
82008515 if (!cachefile.exists())
82018516 {
8202
- // cache to disk
8203
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8204
- //buffers[0].
8205
-
8206
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8207
- int[] pixels = new int[bytebuf.capacity()/3];
8208
-
8209
- // squared size heuristic...
8210
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8517
+ //if (texturedata.getWidth() == texturedata.getHeight())
82118518 {
8212
- for (int i=pixels.length; --i>=0;)
8213
- {
8214
- int i3 = i*3;
8215
- pixels[i] = 0xFF;
8216
- pixels[i] <<= 8;
8217
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8218
- pixels[i] <<= 8;
8219
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8220
- pixels[i] <<= 8;
8221
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8222
- }
8223
-
8224
- /*
8225
- int r=0,g=0,b=0,a=0;
8226
- for (int i=0; i<width; i++)
8227
- for (int j=0; j<height; j++)
8228
- {
8229
- int index = j*width+i;
8230
- int p = pixels[index];
8231
- a = ((p>>24) & 0xFF);
8232
- r = ((p>>16) & 0xFF);
8233
- g = ((p>>8) & 0xFF);
8234
- b = (p & 0xFF);
8235
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8236
- }
8237
- /**/
8238
- int width = (int)Math.sqrt(pixels.length); // squared
8239
- int height = width;
8240
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8241
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8519
+ BufferedImage rendImage = CreateBim(texturedata);
8520
+
82428521 ImageWriter writer = null;
82438522 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
82448523 if (iter.hasNext()) {
82458524 writer = (ImageWriter)iter.next();
82468525 }
8247
- float compressionQuality = 0.9f;
8526
+
8527
+ float compressionQuality = 0.85f;
82488528 try
82498529 {
82508530 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8261,18 +8541,20 @@
82618541 }
82628542 }
82638543 }
8264
-
8544
+
8545
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8546
+
82658547 //System.out.println("Texture = " + tex);
8266
- if (textures.containsKey(texname))
8548
+ if (textures.containsKey(tex))
82678549 {
8268
- CacheTexture thetex = textures.get(texname);
8550
+ CacheTexture thetex = textures.get(tex);
82698551 thetex.texture.disable();
82708552 thetex.texture.dispose();
8271
- textures.remove(texname);
8553
+ textures.remove(tex);
82728554 }
82738555
8274
- texture.texturedata = texturedata;
8275
- textures.put(texname, texture);
8556
+ //texture.texturedata = texturedata;
8557
+ textures.put(tex, texturecache);
82768558
82778559 // newtex = true;
82788560 }
....@@ -8288,10 +8570,44 @@
82888570 }
82898571 }
82908572
8291
- return texture;
8573
+ return texturecache;
82928574 }
82938575
8294
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution)
8576
+ static void EmbedTextures(cTexture tex)
8577
+ {
8578
+ if (tex.pigmentdata == null)
8579
+ {
8580
+ //String texname = Object3D.GetPigment(tex);
8581
+
8582
+ CacheTexture texturecache = texturepigment.get(tex);
8583
+
8584
+ if (texturecache != null)
8585
+ {
8586
+ tex.pw = texturecache.texturedata.getWidth();
8587
+ tex.ph = texturecache.texturedata.getHeight();
8588
+ tex.pigmentdata = //CompressJPEG(CreateBim
8589
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8590
+ ;
8591
+ //, tex.pw, tex.ph), 0.5f);
8592
+ }
8593
+ }
8594
+
8595
+ if (tex.bumpdata == null)
8596
+ {
8597
+ //String texname = Object3D.GetBump(tex);
8598
+
8599
+ CacheTexture texturecache = texturebump.get(tex);
8600
+
8601
+ if (texturecache != null)
8602
+ {
8603
+ tex.bw = texturecache.texturedata.getWidth();
8604
+ tex.bh = texturecache.texturedata.getHeight();
8605
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8606
+ }
8607
+ }
8608
+ }
8609
+
8610
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
82958611 {
82968612 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
82978613
....@@ -8309,21 +8625,21 @@
83098625 return texture!=null?texture.texture:null;
83108626 }
83118627
8312
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution)
8628
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
83138629 {
83148630 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
83158631
83168632 return texture!=null?texture.texturedata:null;
83178633 }
83188634
8319
- boolean BindTexture(String tex, boolean bump, int resolution)
8635
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
83208636 {
83218637 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
83228638 {
83238639 return false;
83248640 }
83258641
8326
- boolean newtex = false;
8642
+ //boolean newtex = false;
83278643
83288644 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
83298645
....@@ -8355,9 +8671,75 @@
83558671 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
83568672 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
83578673
8358
- return newtex;
8674
+ return true; // Warning: not used.
83598675 }
83608676
8677
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8678
+ {
8679
+ try
8680
+ {
8681
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8682
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8683
+ ImageWriter writer = writers.next();
8684
+
8685
+ ImageWriteParam param = writer.getDefaultWriteParam();
8686
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8687
+ param.setCompressionQuality(quality);
8688
+
8689
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8690
+ writer.setOutput(ios);
8691
+ writer.write(null, new IIOImage(image, null, null), param);
8692
+
8693
+ byte[] data = baos.toByteArray();
8694
+ writer.dispose();
8695
+ return data;
8696
+ }
8697
+ catch (Exception e)
8698
+ {
8699
+ e.printStackTrace();
8700
+ return null;
8701
+ }
8702
+ }
8703
+
8704
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8705
+ {
8706
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8707
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8708
+ ImageReader reader = writers.next();
8709
+
8710
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8711
+
8712
+ ImageReadParam param = reader.getDefaultReadParam();
8713
+ param.setDestination(bim);
8714
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8715
+
8716
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8717
+ reader.setInput(ios);
8718
+ BufferedImage bim2 = reader.read(0, param);
8719
+ reader.dispose();
8720
+
8721
+// WritableRaster raster = bim2.getRaster();
8722
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8723
+// byte[] bytes = data.getData();
8724
+//
8725
+// int[] pixels = new int[bytes.length/3];
8726
+// for (int i=pixels.length; --i>=0;)
8727
+// {
8728
+// int i3 = i*3;
8729
+// pixels[i] = 0xFF;
8730
+// pixels[i] <<= 8;
8731
+// pixels[i] |= bytes[i3+2] & 0xFF;
8732
+// pixels[i] <<= 8;
8733
+// pixels[i] |= bytes[i3+1] & 0xFF;
8734
+// pixels[i] <<= 8;
8735
+// pixels[i] |= bytes[i3] & 0xFF;
8736
+// }
8737
+//
8738
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8739
+
8740
+ return bim;
8741
+ }
8742
+
83618743 ShadowBuffer shadowPBuf;
83628744 AntialiasBuffer antialiasPBuf;
83638745 int MAXSTACK;
....@@ -9193,11 +9575,35 @@
91939575 jy8[3] = 0.5f;
91949576 }
91959577
9196
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9578
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
91979579 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
91989580 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
91999581 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
92009582
9583
+ void ResetOptions()
9584
+ {
9585
+ options1[0] = 100;
9586
+ options1[1] = 0.025f;
9587
+ options1[2] = 0.01f;
9588
+ options1[3] = 0;
9589
+ options1[4] = 0;
9590
+
9591
+ options2[0] = 0;
9592
+ options2[1] = 0.75f;
9593
+ options2[2] = 0;
9594
+ options2[3] = 0;
9595
+
9596
+ options3[0] = 1;
9597
+ options3[1] = 1;
9598
+ options3[2] = 1;
9599
+ options3[3] = 0;
9600
+
9601
+ options4[0] = 1;
9602
+ options4[1] = 0;
9603
+ options4[2] = 1;
9604
+ options4[3] = 0;
9605
+ }
9606
+
92019607 static int imagecount = 0; // movie generation
92029608
92039609 static int jitter = 0;
....@@ -9293,8 +9699,8 @@
92939699 assert (parentcam != renderCamera);
92949700
92959701 if (renderCamera != lightCamera)
9296
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9297
- LA.matConcat(matrix, parentcam.toParent, matrix);
9702
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9703
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
92989704
92999705 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
93009706
....@@ -9309,8 +9715,8 @@
93099715 LA.matCopy(renderCamera.fromScreen, matrix);
93109716
93119717 if (renderCamera != lightCamera)
9312
- for (int count = parentcam.GetTransformCount(); --count>=0;)
9313
- LA.matConcat(parentcam.fromParent, matrix, matrix);
9718
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
9719
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
93149720
93159721 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
93169722
....@@ -9382,7 +9788,7 @@
93829788 //gl.glFlush();
93839789 gl.glAccum(gl.GL_ACCUM, 1.0f / ACSIZE);
93849790
9385
- if (ANIMATION && ABORTED)
9791
+ if (Globals.ANIMATION && ABORTED)
93869792 {
93879793 System.err.println(" ABORTED FRAME");
93889794 break;
....@@ -9412,7 +9818,7 @@
94129818 setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
94139819
94149820 // save image
9415
- if (ANIMATION && !ABORTED)
9821
+ if (Globals.ANIMATION && !ABORTED)
94169822 {
94179823 VPwidth = viewport[2];
94189824 VPheight = viewport[3];
....@@ -9523,11 +9929,11 @@
95239929
95249930 // imagecount++;
95259931
9526
- String fullname = filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
9932
+ String fullname = Globals.filename + (i%100000)/10000 + "" + (i%10000)/1000 + "" + (i%1000)/100 + "" + (i%100)/10 + "" + (i%10) + "." + ext;
95279933
95289934 if (!BOXMODE)
95299935 {
9530
- System.out.println("image: " + fullname + " (wav cursor=" + (GrafreeD.wav.cursor / 735 / 4) + ")");
9936
+ System.out.println("image: " + fullname + " (wav cursor=" + (Grafreed.wav.cursor / 735 / 4) + ")");
95319937 }
95329938
95339939 if (!BOXMODE)
....@@ -9565,7 +9971,7 @@
95659971 ABORTED = false;
95669972 }
95679973 else
9568
- GrafreeD.wav.cursor += 735 * ACSIZE;
9974
+ Grafreed.wav.cursor += 735 * ACSIZE;
95699975
95709976 if (false)
95719977 {
....@@ -10228,11 +10634,11 @@
1022810634
1022910635 public void display(GLAutoDrawable drawable)
1023010636 {
10231
- if (GrafreeD.savesound && GrafreeD.hassound)
10637
+ if (Grafreed.savesound && Grafreed.hassound)
1023210638 {
10233
- GrafreeD.wav.save();
10234
- GrafreeD.savesound = false;
10235
- GrafreeD.hassound = false;
10639
+ Grafreed.wav.save();
10640
+ Grafreed.savesound = false;
10641
+ Grafreed.hassound = false;
1023610642 }
1023710643 // if (DEBUG_SELECTION)
1023810644 // {
....@@ -10308,6 +10714,7 @@
1030810714 ANTIALIAS = 0;
1030910715 //System.out.println("RESTART");
1031010716 AAtimer.restart();
10717
+ Globals.TIMERRUNNING = true;
1031110718 }
1031210719 }
1031310720 }
....@@ -10362,7 +10769,7 @@
1036210769 Object3D theobject = object;
1036310770 Object3D theparent = object.parent;
1036410771 object.parent = null;
10365
- object = (Object3D)GrafreeD.clone(object);
10772
+ object = (Object3D)Grafreed.clone(object);
1036610773 object.Stripify();
1036710774 if (theobject.selection == null || theobject.selection.Size() == 0)
1036810775 theobject.PreprocessOcclusion(this);
....@@ -10375,13 +10782,14 @@
1037510782 ambientOcclusion = false;
1037610783 }
1037710784
10378
- if (Globals.lighttouched && DrawMode() == DEFAULT && !lightMode) // && !FROZEN)
10785
+ if (//Globals.lighttouched &&
10786
+ DrawMode() == DEFAULT) // && !lightMode) // && !FROZEN)
1037910787 {
1038010788 //if (RENDERSHADOW) // ?
1038110789 if (!IsFrozen())
1038210790 {
1038310791 // dec 2012
10384
- if (!ambientOcclusion && !(!flash && !lightMode && DrawMode() == DEFAULT && ANTIALIAS > 0))
10792
+ if (!ambientOcclusion && !(!flash && DrawMode() == DEFAULT && ANTIALIAS > 0))
1038510793 {
1038610794 Globals.framecount++;
1038710795 shadowbuffer.display();
....@@ -10508,8 +10916,8 @@
1050810916
1050910917 // if (parentcam != renderCamera) // not a light
1051010918 if (cam != lightCamera)
10511
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10512
- LA.matConcat(matrix, parentcam.toParent, matrix);
10919
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10920
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1051310921
1051410922 for (int j = 0; j < 4; j++)
1051510923 {
....@@ -10523,8 +10931,8 @@
1052310931
1052410932 // if (parentcam != renderCamera) // not a light
1052510933 if (cam != lightCamera)
10526
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10527
- LA.matConcat(parentcam.fromParent, matrix, matrix);
10934
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
10935
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1052810936
1052910937 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1053010938
....@@ -10783,7 +11191,16 @@
1078311191 // Bump noise
1078411192 gl.glActiveTexture(GL.GL_TEXTURE6);
1078511193 //gl.glBindTexture(GL.GL_TEXTURE_2D, bump_noise);
10786
- BindTexture(NOISE_TEXTURE, false, 2);
11194
+
11195
+ try
11196
+ {
11197
+ BindTexture(NOISE_TEXTURE, false, 2);
11198
+ }
11199
+ catch (Exception e)
11200
+ {
11201
+ System.err.println("FAILED: " + NOISE_TEXTURE);
11202
+ }
11203
+
1078711204
1078811205 gl.glActiveTexture(GL.GL_TEXTURE0);
1078911206 gl.glEnable(GL.GL_TEXTURE_2D);
....@@ -10806,9 +11223,9 @@
1080611223
1080711224 gl.glMatrixMode(GL.GL_MODELVIEW);
1080811225
10809
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10810
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10811
-//gl.glEnable(gl.GL_MULTISAMPLE);
11226
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11227
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11228
+gl.glEnable(gl.GL_MULTISAMPLE);
1081211229 } else
1081311230 {
1081411231 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -10819,7 +11236,7 @@
1081911236 //System.out.println("BLENDING ON");
1082011237 gl.glEnable(GL.GL_BLEND);
1082111238 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
10822
-
11239
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1082311240 gl.glMatrixMode(gl.GL_PROJECTION);
1082411241 gl.glLoadIdentity();
1082511242
....@@ -10908,8 +11325,8 @@
1090811325 System.err.println("parentcam != renderCamera");
1090911326
1091011327 // if (cam != lightCamera)
10911
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10912
- LA.xformDir(lightposition, parentcam.toParent, lightposition); // may 2013
11328
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11329
+ LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
1091311330 }
1091411331
1091511332 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -10930,8 +11347,8 @@
1093011347 if (true) // TODO
1093111348 {
1093211349 if (cam != lightCamera)
10933
- for (int count = parentcam.GetTransformCount(); --count>=0;)
10934
- LA.xformDir(light0, parentcam.toParent, light0); // may 2013
11350
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
11351
+ LA.xformDir(light0, parentcam.GlobalTransform(), light0); // may 2013
1093511352 }
1093611353
1093711354 LA.xformPos(light0, cam.toScreen, light0);
....@@ -11068,7 +11485,7 @@
1106811485 }
1106911486 }
1107011487
11071
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11488
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1107211489 {
1107311490 //gl.glDepthFunc(GL.GL_LEQUAL);
1107411491 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11076,24 +11493,21 @@
1107611493
1107711494 boolean texon = textureon;
1107811495
11079
- if (RENDERPROGRAM > 0)
11080
- {
11081
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11082
- textureon = false;
11083
- }
11496
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11497
+ textureon = false;
11498
+
1108411499 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1108511500 //System.out.println("ALLO");
1108611501 gl.glColorMask(false, false, false, false);
1108711502 DrawObject(gl);
11088
- if (RENDERPROGRAM > 0)
11089
- {
11090
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11091
- textureon = texon;
11092
- }
11503
+
11504
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11505
+ textureon = texon;
11506
+
1109311507 gl.glColorMask(true, true, true, true);
1109411508
1109511509 gl.glDepthFunc(GL.GL_EQUAL);
11096
- //gl.glDepthMask(false);
11510
+ gl.glDepthMask(false);
1109711511 }
1109811512
1109911513 if (false) // DrawMode() == SHADOW)
....@@ -11247,8 +11661,14 @@
1124711661 {
1124811662 renderpass++;
1124911663 // System.out.println("Draw object... ");
11664
+ STEP = 1;
1125011665 if (FAST) // in case there is no script
11251
- STEP = 16;
11666
+ STEP = 8;
11667
+
11668
+ if (CURRENTANTIALIAS == 0 || ACSIZE == 1)
11669
+ {
11670
+ STEP *= 4;
11671
+ }
1125211672
1125311673 //object.FullInvariants();
1125411674
....@@ -11262,23 +11682,44 @@
1126211682 e.printStackTrace();
1126311683 }
1126411684
11265
- if (GrafreeD.RENDERME > 0)
11266
- GrafreeD.RENDERME--; // mechante magouille
11685
+ if (Grafreed.RENDERME > 0)
11686
+ Grafreed.RENDERME--; // mechante magouille
1126711687
1126811688 Globals.ONESTEP = false;
1126911689 }
1127011690
1127111691 static boolean zoomonce = false;
1127211692
11693
+ static void CreateSelectedPoint()
11694
+ {
11695
+ if (selectedpoint == null)
11696
+ {
11697
+ debugpointG = new Sphere();
11698
+ debugpointP = new Sphere();
11699
+ debugpointC = new Sphere();
11700
+ debugpointR = new Sphere();
11701
+
11702
+ selectedpoint = new Superellipsoid();
11703
+
11704
+ for (int i=0; i<8; i++)
11705
+ {
11706
+ debugpoints[i] = new Sphere();
11707
+ }
11708
+ }
11709
+ }
11710
+
1127311711 void DrawObject(GL gl, boolean draw)
1127411712 {
11713
+ // To clear camera values
11714
+ ResetOptions();
11715
+
1127511716 //System.out.println("DRAW OBJECT " + mouseDown);
1127611717 // DrawMode() = SELECTION;
1127711718 //GL gl = getGL();
1127811719 if ((TRACK || SHADOWTRACK) || zoomonce)
1127911720 {
1128011721 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11281
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11722
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1128211723 pingthread.StepToTarget(true); // true);
1128311724 // zoomonce = false;
1128411725 }
....@@ -11333,7 +11774,14 @@
1133311774
1133411775 usedtextures.clear();
1133511776
11336
- BindTextures(DEFAULT_TEXTURES, 2);
11777
+ try
11778
+ {
11779
+ BindTextures(DEFAULT_TEXTURES, 2);
11780
+ }
11781
+ catch (Exception e)
11782
+ {
11783
+ System.err.println("FAILED: " + DEFAULT_TEXTURES);
11784
+ }
1133711785 }
1133811786 //System.out.println("--> " + stackdepth);
1133911787 // GrafreeD.traceon();
....@@ -11343,8 +11791,9 @@
1134311791
1134411792 if (DrawMode() == DEFAULT)
1134511793 {
11346
- if (DEBUG)
11794
+ if (Globals.DEBUG)
1134711795 {
11796
+ CreateSelectedPoint();
1134811797 float radius = 0.05f;
1134911798 if (selectedpoint.radius != radius)
1135011799 {
....@@ -11398,20 +11847,32 @@
1139811847 ReleaseTextures(DEFAULT_TEXTURES);
1139911848
1140011849 if (CLEANCACHE)
11401
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11850
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1140211851 {
11403
- String tex = e.nextElement();
11852
+ cTexture tex = e.nextElement();
1140411853
1140511854 // System.out.println("Texture --------- " + tex);
1140611855
11407
- if (tex.equals("WHITE_NOISE"))
11856
+ if (tex.equals("WHITE_NOISE:"))
1140811857 continue;
1140911858
11410
- if (!usedtextures.containsKey(tex))
11859
+ if (!usedtextures.contains(tex))
1141111860 {
11861
+ CacheTexture gettex = texturepigment.get(tex);
1141211862 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11413
- textures.get(tex).texture.dispose();
11414
- textures.remove(tex);
11863
+ if (gettex != null)
11864
+ {
11865
+ gettex.texture.dispose();
11866
+ texturepigment.remove(tex);
11867
+ }
11868
+
11869
+ gettex = texturebump.get(tex);
11870
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11871
+ if (gettex != null)
11872
+ {
11873
+ gettex.texture.dispose();
11874
+ texturebump.remove(tex);
11875
+ }
1141511876 }
1141611877 }
1141711878 }
....@@ -11424,7 +11885,14 @@
1142411885 if (checker != null && DrawMode() == DEFAULT)
1142511886 {
1142611887 //BindTexture(IMMORTAL_TEXTURE);
11427
- BindTextures(checker.GetTextures(), checker.texres);
11888
+ try
11889
+ {
11890
+ BindTextures(checker.GetTextures(), checker.texres);
11891
+ }
11892
+ catch (Exception e)
11893
+ {
11894
+ System.err.println("FAILED: " + checker.GetTextures());
11895
+ }
1142811896 // NEAREST
1142911897 GetGL().glTexParameteri(GL.GL_TEXTURE_2D, GL.GL_TEXTURE_MAG_FILTER, GL.GL_NEAREST); // GL.GL_LINEAR);
1143011898 DrawChecker(gl);
....@@ -11506,7 +11974,7 @@
1150611974 return;
1150711975 }
1150811976
11509
- String string = obj.GetToolTip();
11977
+ String string = obj.toString(); //.GetToolTip();
1151011978
1151111979 GL gl = GetGL();
1151211980
....@@ -11823,8 +12291,8 @@
1182312291 //obj.TransformToWorld(light, light);
1182412292 for (int i = tp.size(); --i >= 0;)
1182512293 {
11826
- for (int count = tp.get(i).GetTransformCount(); --count>=0;)
11827
- LA.xformPos(light, tp.get(i).toParent, light);
12294
+ //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12295
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1182812296 }
1182912297
1183012298
....@@ -11841,8 +12309,8 @@
1184112309 parentcam = cameras[0];
1184212310 }
1184312311
11844
- for (int count = parentcam.GetTransformCount(); --count>=0;)
11845
- LA.xformPos(light, parentcam.toParent, light); // may 2013
12312
+ //for (int count = parentcam.GetTransformCount(); --count>=0;)
12313
+ LA.xformPos(light, parentcam.GlobalTransform(), light); // may 2013
1184612314
1184712315 LA.xformPos(light, renderCamera.toScreen, light);
1184812316
....@@ -11933,7 +12401,74 @@
1193312401 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1193412402
1193512403 String program =
12404
+ // Min shader
1193612405 "!!ARBfp1.0\n" +
12406
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12407
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12408
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12409
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12410
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12411
+ "PARAM light2cam0 = program.env[10];" +
12412
+ "PARAM light2cam1 = program.env[11];" +
12413
+ "PARAM light2cam2 = program.env[12];" +
12414
+ "TEMP temp;" +
12415
+ "TEMP light;" +
12416
+ "TEMP ndotl;" +
12417
+ "TEMP normal;" +
12418
+ "TEMP depth;" +
12419
+ "TEMP eye;" +
12420
+ "TEMP pos;" +
12421
+
12422
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12423
+ Normalize("normal") +
12424
+ "MOV light, state.light[0].position;" +
12425
+ "DP3 ndotl.x, light, normal;" +
12426
+
12427
+ // shadow
12428
+ "MOV pos, fragment.texcoord[1];" +
12429
+ "MOV temp, pos;" +
12430
+ ShadowTextureFetch("depth", "temp", "1") +
12431
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12432
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12433
+
12434
+ // No shadow when out of frustum
12435
+ //"SGE temp.y, depth.z, zero123.y;" +
12436
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12437
+
12438
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12439
+
12440
+ // Backlit
12441
+ "MOV pos.w, zero123.y;" +
12442
+ "DP4 eye.x, pos, light2cam0;" +
12443
+ "DP4 eye.y, pos, light2cam1;" +
12444
+ "DP4 eye.z, pos, light2cam2;" +
12445
+ Normalize("eye") +
12446
+
12447
+ "DP3 ndotl.y, -eye, normal;" +
12448
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12449
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12450
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12451
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12452
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12453
+
12454
+ "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12455
+
12456
+ // Pigment
12457
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12458
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12459
+ "MUL temp, temp, ndotl.x;" +
12460
+
12461
+ "MUL temp, temp, zero123.z;" +
12462
+
12463
+ //"MUL temp, temp, ndotl.y;" +
12464
+
12465
+ "MOV temp.w, zero123.y;" + // reset alpha
12466
+ "MOV result.color, temp;" +
12467
+ "END";
12468
+
12469
+ String program2 =
12470
+ "!!ARBfp1.0\n" +
12471
+
1193712472 //"OPTION ARB_fragment_program_shadow;" +
1193812473 "PARAM light2cam0 = program.env[10];" +
1193912474 "PARAM light2cam1 = program.env[11];" +
....@@ -12048,8 +12583,7 @@
1204812583 "TEMP shininess;" +
1204912584 "\n" +
1205012585 "MOV texSamp, one;" +
12051
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12052
-
12586
+
1205312587 "MOV mapgrid.x, one2048th.x;" +
1205412588 "MOV temp, fragment.texcoord[1];" +
1205512589 /*
....@@ -12070,20 +12604,20 @@
1207012604 "MUL temp, floor, mapgrid.x;" +
1207112605 //"TEX depth0, temp, texture[1], 2D;" +
1207212606 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12073
- TextureFetch("depth0", "temp", "1") +
12607
+ ShadowTextureFetch("depth0", "temp", "1") +
1207412608 "") +
1207512609 "ADD temp.x, temp.x, mapgrid.x;" +
1207612610 //"TEX depth1, temp, texture[1], 2D;" +
1207712611 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12078
- TextureFetch("depth1", "temp", "1") +
12612
+ ShadowTextureFetch("depth1", "temp", "1") +
1207912613 "") +
1208012614 "ADD temp.y, temp.y, mapgrid.x;" +
1208112615 //"TEX depth2, temp, texture[1], 2D;" +
12082
- TextureFetch("depth2", "temp", "1") +
12616
+ ShadowTextureFetch("depth2", "temp", "1") +
1208312617 "SUB temp.x, temp.x, mapgrid.x;" +
1208412618 //"TEX depth3, temp, texture[1], 2D;" +
1208512619 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12086
- TextureFetch("depth3", "temp", "1") +
12620
+ ShadowTextureFetch("depth3", "temp", "1") +
1208712621 "") +
1208812622 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1208912623 //"MOV params, material;" +
....@@ -12454,10 +12988,10 @@
1245412988 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1245512989 "") +
1245612990
12457
- // display shadow only (bump == 0)
12991
+ // display shadow only (fakedepth == 0)
1245812992 "SUB temp.x, half.x, shadow.x;" +
12459
- "MOV temp.y, -params6.x;" +
12460
- "SLT temp.z, temp.y, zero.x;" +
12993
+ "MOV temp.y, -params5.z;" + // params6.x;" +
12994
+ "SLT temp.z, temp.y, -one2048th.x;" +
1246112995 "SUB temp.y, one.x, temp.z;" +
1246212996 "MUL temp.x, temp.x, temp.y;" +
1246312997 "KIL temp.x;" +
....@@ -12586,8 +13120,10 @@
1258613120 "MAX ndotl.x, ndotl.x, -ndotl.x;" +
1258713121
1258813122 "SUB temp.x, one.x, ndotl.x;" +
12589
- "ADD temp.x, temp.x, options2.z;" + // lightsheen
12590
- "ADD temp.y, one.y, options2.y;" + // sursurface
13123
+ // Tuning for default skin
13124
+ //"ADD temp.x, temp.x, options2.z;" + // lightsheen
13125
+ "MAD temp.x, options2.z, half.y, temp.x;" + // lightsheen
13126
+ "ADD temp.y, one.y, options2.y;" + // subsurface
1259113127 "MUL temp.x, temp.x, temp.y;" +
1259213128
1259313129 "MUL saturation, saturation, temp.xxxx;" +
....@@ -12786,7 +13322,7 @@
1278613322 //once = true;
1278713323 }
1278813324
12789
- System.out.print("Program #" + mode + "; length = " + program.length());
13325
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1279013326 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1279113327 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1279213328
....@@ -12879,25 +13415,26 @@
1287913415 return out;
1288013416 }
1288113417
12882
- String TextureFetch(String dest, String src, String unit)
13418
+ // Also does frustum culling
13419
+ String ShadowTextureFetch(String dest, String src, String unit)
1288313420 {
1288413421 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1288513422 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1288613423 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13424
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13425
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1288713426 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12888
- "SLT " + src + ".z, " + src + ".x, one.x;" +
12889
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
12890
- "SLT " + src + ".z, " + src + ".y, one.x;" +
12891
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13427
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13428
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1289213429 //"SWZ buffer, temp, w,w,w,w;";
12893
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13430
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1289413431 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1289513432 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1289613433 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
12897
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13434
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1289813435
12899
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
12900
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13436
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13437
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1290113438 }
1290213439
1290313440 String Shadow(String depth, String shadow)
....@@ -12919,12 +13456,16 @@
1291913456
1292013457 "ADD " + depth + ".z, " + depth + ".z, temp.x;" +
1292113458 //"SUB " + depth + ".z, " + depth + ".z, temp.x;" + // back face shadowing!
13459
+
13460
+ // Compare fragment depth in light space with shadowmap.
1292213461 "SUB temp.x, fragment.texcoord[1].z, " + depth + ".z;" +
1292313462 "SGE temp.y, temp.x, zero.x;" +
12924
- "SUB " + shadow + ".y, one.x, temp.y;" +
13463
+ "SUB " + shadow + ".y, one.x, temp.y;" + // Specular is fully occluded
13464
+
13465
+ // Reverse comparison
1292513466 "SUB temp.x, one.x, temp.x;" +
1292613467 "MUL " + shadow + ".x, temp.x, temp.y;" +
12927
- "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // specular is fully occluded
13468
+ "SUB " + shadow + ".x, one.x, " + shadow + ".x;" + // diffuse
1292813469 "POW " + shadow + ".x, " + shadow + ".x, params5.z;" + // fake depth
1292913470
1293013471 "SLT " + shadow + ".z, fragment.texcoord[1].z, " + depth + ".z;" +
....@@ -12938,6 +13479,10 @@
1293813479 // No shadow for backface
1293913480 "DP3 temp.x, normal, lightd;" +
1294013481 "SLT temp.x, temp.x, zero.x;" + // shadoweps
13482
+ "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
13483
+
13484
+ // No shadow when out of frustum
13485
+ "SGE temp.x, " + depth + ".z, one.z;" +
1294113486 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1294213487 "";
1294313488 }
....@@ -13084,7 +13629,8 @@
1308413629 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1308513630 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
1308613631 /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13087
- Object3D.cVector2[] vector2buffer;
13632
+
13633
+ //Object3D.cVector2[] vector2buffer;
1308813634
1308913635 // IN : ndotl, ndoth, xxx, NdotL //, snininess, lightarea
1309013636 // OUT : diff, spec
....@@ -13100,9 +13646,10 @@
1310013646 "DP3 " + dest + ".z," + "normals," + "eye;" +
1310113647 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1310213648 //"MOV " + dest + ".w," + "normal.z;" +
13103
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13104
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13105
- //"MOV " + dest + ".z," + "params2.w;" +
13649
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13650
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13651
+
13652
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1310613653 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1310713654 "RCP " + dest + ".w," + dest + ".w;" +
1310813655 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13496,7 +14043,7 @@
1349614043 public void mousePressed(MouseEvent e)
1349714044 {
1349814045 //System.out.println("mousePressed: " + e);
13499
- clickStart(e.getX(), e.getY(), e.getModifiersEx());
14046
+ clickStart(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1350014047 }
1350114048
1350214049 static long prevtime = 0;
....@@ -13523,6 +14070,7 @@
1352314070
1352414071 //System.err.println("Dtime = " + Dtime + "; units = " + e.getUnitsToScroll() + "; ratio (units/ms) = " + ratio);
1352514072
14073
+ if (BUTTONLESSWHEEL)
1352614074 if (Math.abs(ratio) < 0.1 || Math.abs(Dtime) == 0) // < 30)
1352714075 {
1352814076 return;
....@@ -13531,7 +14079,7 @@
1353114079 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
1353214080
1353314081 // TIMER
13534
- if (!wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
14082
+ if (ZOOMBOXMODE && !wheeltimer.isRunning() && e.getModifiersEx() == 0 && !capsLocked) // VR
1353514083 {
1353614084 keepboxmode = BOXMODE;
1353714085 keepsupport = SUPPORT;
....@@ -13571,8 +14119,8 @@
1357114119 // mode |= META;
1357214120 //}
1357314121
13574
- SetMouseMode(WHEEL | e.getModifiersEx());
13575
- drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0);
14122
+ SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx());
14123
+ drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0);
1357614124 anchorX = ax;
1357714125 anchorY = ay;
1357814126 prevX = px;
....@@ -13606,6 +14154,7 @@
1360614154 else
1360714155 if (evt.getSource() == AAtimer)
1360814156 {
14157
+ Globals.TIMERRUNNING = false;
1360914158 if (mouseDown)
1361014159 {
1361114160 //new Exception().printStackTrace();
....@@ -13631,6 +14180,10 @@
1363114180 // LIVE = waslive;
1363214181 // wasliveok = true;
1363314182 // waslive = false;
14183
+
14184
+ // May 2019 Forget it:
14185
+ if (true)
14186
+ return;
1363414187
1363514188 // source == timer
1363614189 if (mouseDown)
....@@ -13661,7 +14214,7 @@
1366114214
1366214215 // fev 2014???
1366314216 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13664
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14217
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1366514218 pingthread.StepToTarget(true); // true);
1366614219 }
1366714220 // if (!LIVE)
....@@ -13670,12 +14223,13 @@
1367014223
1367114224 javax.swing.Timer timer = new javax.swing.Timer(350, this);
1367214225
13673
- void clickStart(int x, int y, int modifiers)
14226
+ void clickStart(int x, int y, int modifiers, int modifiersex)
1367414227 {
1367514228 if (!wasliveok)
1367614229 return;
1367714230
1367814231 AAtimer.restart(); //
14232
+ Globals.TIMERRUNNING = true;
1367914233
1368014234 // waslive = LIVE;
1368114235 // LIVE = false;
....@@ -13687,7 +14241,7 @@
1368714241 // touched = true; // main DL
1368814242 if (isRenderer)
1368914243 {
13690
- SetMouseMode(modifiers);
14244
+ SetMouseMode(modifiers, modifiersex);
1369114245 }
1369214246
1369314247 selectX = anchorX = x;
....@@ -13700,7 +14254,7 @@
1370014254 clicked = true;
1370114255 hold = false;
1370214256
13703
- if (((modifiers & ~1024) & ~0) == 0) // Single or multiple selection
14257
+ if (((modifiersex & ~1024) & ~0) == 0) // Single or multiple selection
1370414258 // june 2013 means CTRL_CLICK: if (((modifiers & ~1024) & ~128) == 0) // Single or multiple selection
1370514259 {
1370614260 // System.out.println("RESTART II " + modifiers);
....@@ -13725,14 +14279,15 @@
1372514279 drag = false;
1372614280 //System.out.println("Mouse DOWN");
1372714281 editObj = false;
13728
- ClickInfo info = new ClickInfo();
13729
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13730
- info.pane = this;
13731
- info.camera = renderCamera;
13732
- info.x = x;
13733
- info.y = y;
13734
- info.modifiers = modifiers;
13735
- editObj = object.doEditClick(info, 0);
14282
+ //ClickInfo info = new ClickInfo();
14283
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14284
+ object.clickInfo.pane = this;
14285
+ object.clickInfo.camera = renderCamera;
14286
+ object.clickInfo.x = x;
14287
+ object.clickInfo.y = y;
14288
+ object.clickInfo.modifiers = modifiersex;
14289
+ editObj = object.doEditClick(//info,
14290
+ 0);
1373614291 if (!editObj)
1373714292 {
1373814293 hasMarquee = true;
....@@ -13748,11 +14303,14 @@
1374814303
1374914304 public void mouseDragged(MouseEvent e)
1375014305 {
14306
+ Globals.MOUSEDRAGGED = true;
14307
+
14308
+ //System.out.println("mouseDragged: " + e);
1375114309 if (isRenderer)
1375214310 movingcamera = true;
14311
+
1375314312 //if (drawing)
1375414313 //return;
13755
- //System.out.println("mouseDragged: " + e);
1375614314 if ((e.getModifiersEx() & CTRL) != 0
1375714315 || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen())
1375814316 {
....@@ -13760,7 +14318,7 @@
1376014318 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1376114319 }
1376214320 else
13763
- drag(e.getX(), e.getY(), e.getModifiersEx());
14321
+ drag(e.getX(), e.getY(), e.getModifiers(), e.getModifiersEx());
1376414322
1376514323 //try { Thread.sleep(1); } catch (Exception ex) {}
1376614324 }
....@@ -13933,6 +14491,7 @@
1393314491
1393414492 public void run()
1393514493 {
14494
+ new Exception().printStackTrace();
1393614495 System.exit(0);
1393714496 for (;;)
1393814497 {
....@@ -13996,7 +14555,7 @@
1399614555 {
1399714556 Globals.lighttouched = true;
1399814557 }
13999
- drag(X, (mouseMode != 0) ? Y : anchorY, MODIFIERS);
14558
+ drag(X, (mouseMode != 0) ? Y : anchorY, 0, MODIFIERS);
1400014559 }
1400114560 //else
1400214561 }
....@@ -14010,12 +14569,12 @@
1401014569 void GoDown(int mod)
1401114570 {
1401214571 MODIFIERS |= COMMAND;
14013
- /*
14572
+ /**/
1401414573 if((mod&SHIFT) == SHIFT)
1401514574 manipCamera.RotatePosition(0, -speed);
1401614575 else
14017
- manipCamera.BackForth(0, -speed*delta, getWidth());
14018
- */
14576
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
14577
+ /**/
1401914578 if ((mod & SHIFT) == SHIFT)
1402014579 {
1402114580 mouseMode = mouseMode; // VR??
....@@ -14031,12 +14590,12 @@
1403114590 void GoUp(int mod)
1403214591 {
1403314592 MODIFIERS |= COMMAND;
14034
- /*
14593
+ /**/
1403514594 if((mod&SHIFT) == SHIFT)
1403614595 manipCamera.RotatePosition(0, speed);
1403714596 else
14038
- manipCamera.BackForth(0, speed*delta, getWidth());
14039
- */
14597
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
14598
+ /**/
1404014599 if ((mod & SHIFT) == SHIFT)
1404114600 {
1404214601 mouseMode = mouseMode;
....@@ -14052,12 +14611,12 @@
1405214611 void GoLeft(int mod)
1405314612 {
1405414613 MODIFIERS |= COMMAND;
14055
- /*
14614
+ /**/
1405614615 if((mod&SHIFT) == SHIFT)
14057
- manipCamera.RotatePosition(speed, 0);
14058
- else
1405914616 manipCamera.Translate(speed*delta, 0, getWidth());
14060
- */
14617
+ else
14618
+ manipCamera.RotatePosition(speed, 0);
14619
+ /**/
1406114620 if ((mod & SHIFT) == SHIFT)
1406214621 {
1406314622 mouseMode = mouseMode;
....@@ -14073,12 +14632,12 @@
1407314632 void GoRight(int mod)
1407414633 {
1407514634 MODIFIERS |= COMMAND;
14076
- /*
14635
+ /**/
1407714636 if((mod&SHIFT) == SHIFT)
14078
- manipCamera.RotatePosition(-speed, 0);
14079
- else
1408014637 manipCamera.Translate(-speed*delta, 0, getWidth());
14081
- */
14638
+ else
14639
+ manipCamera.RotatePosition(-speed, 0);
14640
+ /**/
1408214641 if ((mod & SHIFT) == SHIFT)
1408314642 {
1408414643 mouseMode = mouseMode;
....@@ -14096,7 +14655,7 @@
1409614655 int X, Y;
1409714656 boolean SX, SY;
1409814657
14099
- void drag(int x, int y, int modifiers)
14658
+ void drag(int x, int y, int modifiers, int modifiersex)
1410014659 {
1410114660 if (IsFrozen())
1410214661 {
....@@ -14105,17 +14664,17 @@
1410514664
1410614665 drag = true; // NEW
1410714666
14108
- boolean continuous = (modifiers & COMMAND) == COMMAND;
14667
+ boolean continuous = (modifiersex & COMMAND) == COMMAND;
1410914668
1411014669 X = x;
1411114670 Y = y;
1411214671 // floating state for animation
14113
- MODIFIERS = modifiers;
14114
- modifiers &= ~1024;
14672
+ MODIFIERS = modifiersex;
14673
+ modifiersex &= ~1024;
1411514674 if (false) // modifiers != 0)
1411614675 {
1411714676 //new Exception().printStackTrace();
14118
- System.out.println("mouseDragged: " + modifiers);
14677
+ System.out.println("mouseDragged: " + modifiersex);
1411914678 System.out.println("SHIFT = " + SHIFT);
1412014679 System.out.println("CONTROL = " + COMMAND);
1412114680 System.out.println("META = " + META);
....@@ -14128,14 +14687,16 @@
1412814687 if (editObj)
1412914688 {
1413014689 drag = true;
14131
- ClickInfo info = new ClickInfo();
14132
- info.bounds.setBounds(0, 0,
14690
+ //ClickInfo info = new ClickInfo();
14691
+ object.clickInfo.bounds.setBounds(0, 0,
1413314692 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14134
- info.pane = this;
14135
- info.camera = renderCamera;
14136
- info.x = x;
14137
- info.y = y;
14138
- object.editWindow.copy.doEditDrag(info);
14693
+ object.clickInfo.pane = this;
14694
+ object.clickInfo.camera = renderCamera;
14695
+ object.clickInfo.x = x;
14696
+ object.clickInfo.y = y;
14697
+ object //.GetWindow().copy
14698
+ .doEditDrag(//info,
14699
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1413914700 } else
1414014701 {
1414114702 if (x < startX)
....@@ -14284,23 +14845,27 @@
1428414845 }
1428514846 }
1428614847
14848
+// ClickInfo clickInfo = new ClickInfo();
14849
+
1428714850 public void mouseMoved(MouseEvent e)
1428814851 {
1428914852 //System.out.println("mouseMoved: " + e);
14290
-
1429114853 if (isRenderer)
1429214854 return;
1429314855
14294
- ClickInfo ci = new ClickInfo();
14295
- ci.x = e.getX();
14296
- ci.y = e.getY();
14297
- ci.modifiers = e.getModifiersEx();
14298
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14299
- ci.pane = this;
14300
- ci.camera = renderCamera;
14856
+ // Mouse cursor feedback
14857
+ object.clickInfo.x = e.getX();
14858
+ object.clickInfo.y = e.getY();
14859
+ object.clickInfo.modifiers = e.getModifiersEx();
14860
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14861
+ object.clickInfo.pane = this;
14862
+ object.clickInfo.camera = renderCamera;
1430114863 if (!isRenderer)
1430214864 {
14303
- if (object.editWindow.copy.doEditClick(ci, 0))
14865
+ //ObjEditor editWindow = object.editWindow;
14866
+ //Object3D copy = editWindow.copy;
14867
+ if (object.doEditClick(//clickInfo,
14868
+ 0))
1430414869 {
1430514870 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1430614871 } else
....@@ -14312,7 +14877,11 @@
1431214877
1431314878 public void mouseReleased(MouseEvent e)
1431414879 {
14880
+ Globals.MOUSEDRAGGED = false;
14881
+
1431514882 movingcamera = false;
14883
+ X = 0; // getBounds().width/2;
14884
+ Y = 0; // getBounds().height/2;
1431614885 //System.out.println("mouseReleased: " + e);
1431714886 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1431814887 }
....@@ -14335,9 +14904,9 @@
1433514904 boolean control = ((modifiers & CTRL) != 0); // june 2013: for point selection
1433614905 boolean command = ((modifiers & COMMAND) != 0); // june 2013: for multiple selection
1433714906
14338
- if (control || command || IsFrozen())
14907
+// No delay if (control || command || IsFrozen())
1433914908 timeout = true;
14340
- else
14909
+// ?? May 2019 else
1434114910 // timer.setDelay((modifiers & 128) != 0?0:350);
1434214911 mouseDown = false;
1434314912 if (!control && !command) // june 2013
....@@ -14447,7 +15016,7 @@
1444715016 System.out.println("keyReleased: " + e);
1444815017 }
1444915018
14450
- void SetMouseMode(int modifiers)
15019
+ void SetMouseMode(int modifiers, int modifiersex)
1445115020 {
1445215021 //System.out.println("SetMouseMode = " + modifiers);
1445315022 //modifiers &= ~1024;
....@@ -14459,25 +15028,25 @@
1445915028 //if (modifiers == 0) // || (modifiers == (1024 | CONTROL)))
1446015029 // return;
1446115030 //System.out.println("SetMode = " + modifiers);
14462
- if ((modifiers & WHEEL) == WHEEL)
15031
+ if ((modifiersex & WHEEL) == WHEEL)
1446315032 {
1446415033 mouseMode |= ZOOM;
1446515034 }
1446615035
1446715036 boolean capsLocked = Toolkit.getDefaultToolkit().getLockingKeyState(KeyEvent.VK_CAPS_LOCK);
14468
- if (capsLocked || (modifiers & META) == META)
15037
+ if (capsLocked) // || (modifiers & META) == META)
1446915038 {
1447015039 mouseMode |= VR; // BACKFORTH;
1447115040 }
14472
- if ((modifiers & CTRLCLICK) == CTRLCLICK)
15041
+ if ((modifiersex & CTRLCLICK) == CTRLCLICK)
1447315042 {
1447415043 mouseMode |= SELECT;
1447515044 }
14476
- if ((modifiers & COMMAND) == COMMAND)
15045
+ if ((modifiersex & COMMAND) == COMMAND)
1447715046 {
1447815047 mouseMode |= SELECT;
1447915048 }
14480
- if ((modifiers & SHIFT) == SHIFT || forcetranslate)
15049
+ if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0)
1448115050 {
1448215051 mouseMode &= ~VR;
1448315052 mouseMode |= TRANSLATE;
....@@ -14506,7 +15075,7 @@
1450615075
1450715076 if (isRenderer) //
1450815077 {
14509
- SetMouseMode(modifiers);
15078
+ SetMouseMode(0, modifiers);
1451015079 }
1451115080
1451215081 Globals.theRenderer.keyPressed(key);
....@@ -14568,7 +15137,8 @@
1456815137 // break;
1456915138 case 'T':
1457015139 CACHETEXTURE ^= true;
14571
- textures.clear();
15140
+ texturepigment.clear();
15141
+ texturebump.clear();
1457215142 // repaint();
1457315143 break;
1457415144 case 'Y':
....@@ -14653,7 +15223,9 @@
1465315223 case 'E' : COMPACT ^= true;
1465415224 repaint();
1465515225 break;
14656
- case 'W' : DEBUGHSB ^= true;
15226
+ case 'W' : // Wide Window (fullscreen)
15227
+ //DEBUGHSB ^= true;
15228
+ ObjEditor.theFrame.ToggleFullScreen();
1465715229 repaint();
1465815230 break;
1465915231 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14678,8 +15250,8 @@
1467815250 RevertCamera();
1467915251 repaint();
1468015252 break;
14681
- case 'L':
1468215253 case 'l':
15254
+ //case 'L':
1468315255 if (lightMode)
1468415256 {
1468515257 lightMode = false;
....@@ -14822,9 +15394,9 @@
1482215394 case '_':
1482315395 kompactbit = 5;
1482415396 break;
14825
- case '+':
14826
- kompactbit = 6;
14827
- break;
15397
+// case '+':
15398
+// kompactbit = 6;
15399
+// break;
1482815400 case ' ':
1482915401 lightMode ^= true;
1483015402 Globals.lighttouched = true;
....@@ -14836,13 +15408,14 @@
1483615408 case ESC:
1483715409 RENDERPROGRAM += 1;
1483815410 RENDERPROGRAM %= 3;
15411
+
1483915412 repaint();
1484015413 break;
1484115414 case 'Z':
1484215415 //RESIZETEXTURE ^= true;
1484315416 //break;
1484415417 case 'z':
14845
- RENDERSHADOW ^= true;
15418
+ Globals.RENDERSHADOW ^= true;
1484615419 Globals.lighttouched = true;
1484715420 repaint();
1484815421 break;
....@@ -14875,8 +15448,9 @@
1487515448 case DELETE:
1487615449 ClearSelection();
1487715450 break;
14878
- /*
1487915451 case '+':
15452
+
15453
+ /*
1488015454 //fontsize += 1;
1488115455 bbzoom *= 2;
1488215456 repaint();
....@@ -14893,17 +15467,17 @@
1489315467 case '=':
1489415468 IncDepth();
1489515469 //fontsize += 1;
14896
- object.editWindow.refreshContents(true);
15470
+ object.GetWindow().refreshContents(true);
1489715471 maskbit = 6;
1489815472 break;
1489915473 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1490015474 DecDepth();
1490115475 maskbit = 5;
1490215476 //if(fontsize > 1) fontsize -= 1;
14903
- if (object.editWindow == null)
14904
- new Exception().printStackTrace();
14905
- else
14906
- object.editWindow.refreshContents(true);
15477
+// if (object.editWindow == null)
15478
+// new Exception().printStackTrace();
15479
+// else
15480
+ object.GetWindow().refreshContents(true);
1490715481 break;
1490815482 case '{':
1490915483 manipCamera.shaper_fovy /= 1.1;
....@@ -14966,7 +15540,7 @@
1496615540 //mode = ROTATE;
1496715541 if ((MODIFIERS & COMMAND) == 0) // VR??
1496815542 {
14969
- SetMouseMode(modifiers);
15543
+ SetMouseMode(0, modifiers);
1497015544 }
1497115545 }
1497215546
....@@ -15100,8 +15674,9 @@
1510015674
1510115675 protected void processMouseMotionEvent(MouseEvent e)
1510215676 {
15103
- //System.out.println("processMouseMotionEvent: " + mouseMode);
15104
- if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15677
+ //System.out.println("processMouseMotionEvent: " + mouseMode + " " + e.getModifiers() + " " + e.getModifiersEx() + " " + e.getButton());
15678
+ //if (e.getButton() == MouseEvent.NOBUTTON && (mouseMode & SELECT) == 0)
15679
+ if ((e.getModifiers() & MouseEvent.BUTTON1_MASK) == 0 && (e.getModifiers() & MouseEvent.BUTTON3_MASK) == 0 && (mouseMode & SELECT) == 0)
1510515680 {
1510615681 mouseMoved(e);
1510715682 } else
....@@ -15126,11 +15701,12 @@
1512615701 }
1512715702 */
1512815703
15129
- object.editWindow.EditSelection();
15704
+ object.GetWindow().EditSelection(false);
1513015705 }
1513115706
1513215707 void SelectParent()
1513315708 {
15709
+ new Exception().printStackTrace();
1513415710 System.exit(0);
1513515711 Composite group = (Composite) object;
1513615712 java.util.Vector selectees = new java.util.Vector(group.selection);
....@@ -15142,10 +15718,10 @@
1514215718 {
1514315719 //selectees.remove(i);
1514415720 System.out.println("select parent of " + elem);
15145
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15721
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1514615722 } else
1514715723 {
15148
- group.editWindow.Select(elem.GetTreePath(), first, true);
15724
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1514915725 }
1515015726
1515115727 first = false;
....@@ -15154,6 +15730,7 @@
1515415730
1515515731 void SelectChildren()
1515615732 {
15733
+ new Exception().printStackTrace();
1515715734 System.exit(0);
1515815735 /*
1515915736 Composite group = (Composite) object;
....@@ -15186,12 +15763,12 @@
1518615763 for (int j = 0; j < group.children.size(); j++)
1518715764 {
1518815765 elem = (Object3D) group.children.elementAt(j);
15189
- object.editWindow.Select(elem.GetTreePath(), first, true);
15766
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519015767 first = false;
1519115768 }
1519215769 } else
1519315770 {
15194
- object.editWindow.Select(elem.GetTreePath(), first, true);
15771
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1519515772 }
1519615773
1519715774 first = false;
....@@ -15202,21 +15779,21 @@
1520215779 {
1520315780 //Composite group = (Composite) object;
1520415781 Object3D group = object;
15205
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15782
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1520615783 }
1520715784
1520815785 void ResetTransform(int mask)
1520915786 {
1521015787 //Composite group = (Composite) object;
1521115788 Object3D group = object;
15212
- group.editWindow.ResetTransform(mask);
15789
+ group.GetWindow().ResetTransform(mask);
1521315790 }
1521415791
1521515792 void FlipTransform()
1521615793 {
1521715794 //Composite group = (Composite) object;
1521815795 Object3D group = object;
15219
- group.editWindow.FlipTransform();
15796
+ group.GetWindow().FlipTransform();
1522015797 // group.editWindow.ReduceMesh(true);
1522115798 }
1522215799
....@@ -15224,7 +15801,7 @@
1522415801 {
1522515802 //Composite group = (Composite) object;
1522615803 Object3D group = object;
15227
- group.editWindow.PrintMemory();
15804
+ group.GetWindow().PrintMemory();
1522815805 // group.editWindow.ReduceMesh(true);
1522915806 }
1523015807
....@@ -15232,7 +15809,7 @@
1523215809 {
1523315810 //Composite group = (Composite) object;
1523415811 Object3D group = object;
15235
- group.editWindow.ResetCentroid();
15812
+ group.GetWindow().ResetCentroid();
1523615813 }
1523715814
1523815815 void IncDepth()
....@@ -15314,11 +15891,11 @@
1531415891
1531515892 int width = getBounds().width;
1531615893 int height = getBounds().height;
15317
- ClickInfo info = new ClickInfo();
15318
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1531915894 //Image img = CreateImage(width, height);
1532015895 //System.out.println("width = " + width + "; height = " + height + "\n");
15896
+
1532115897 Graphics gr = g; // img.getGraphics();
15898
+
1532215899 if (!hasMarquee)
1532315900 {
1532415901 if (Xmin < Xmax) // !locked)
....@@ -15390,40 +15967,88 @@
1539015967 }
1539115968 if (object != null && !hasMarquee)
1539215969 {
15970
+ if (object.clickInfo == null)
15971
+ object.clickInfo = new ClickInfo();
15972
+ ClickInfo info = object.clickInfo;
15973
+ //ClickInfo info = new ClickInfo();
15974
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
15975
+
1539315976 if (isRenderer)
1539415977 {
15395
- info.flags++;
15978
+ object.clickInfo.flags++;
1539615979 double frameAspect = (double) width / (double) height;
1539715980 if (frameAspect > renderCamera.aspect)
1539815981 {
1539915982 int desired = (int) ((double) height * renderCamera.aspect);
15400
- info.bounds.width -= width - desired;
15401
- info.bounds.x += (width - desired) / 2;
15983
+ object.clickInfo.bounds.width -= width - desired;
15984
+ object.clickInfo.bounds.x += (width - desired) / 2;
1540215985 } else
1540315986 {
1540415987 int desired = (int) ((double) width / renderCamera.aspect);
15405
- info.bounds.height -= height - desired;
15406
- info.bounds.y += (height - desired) / 2;
15988
+ object.clickInfo.bounds.height -= height - desired;
15989
+ object.clickInfo.bounds.y += (height - desired) / 2;
1540715990 }
1540815991 }
15409
- info.g = gr;
15410
- info.camera = renderCamera;
15992
+
15993
+ object.clickInfo.g = gr;
15994
+ object.clickInfo.camera = renderCamera;
1541115995 /*
1541215996 // Memory intensive (brep.verticescopy)
1541315997 if (!(object instanceof Composite))
1541415998 object.draw(info, 0, false); // SLOW :
1541515999 */
15416
- if (!isRenderer)
16000
+ if (!isRenderer) // && drag)
1541716001 {
15418
- object.drawEditHandles(info, 0);
16002
+ Grafreed.Assert(object != null);
16003
+ Grafreed.Assert(object.selection != null);
16004
+ if (object.selection.Size() > 0)
16005
+ {
16006
+ int hitSomething = object.selection.get(0).hitSomething;
16007
+
16008
+ object.clickInfo.DX = 0;
16009
+ object.clickInfo.DY = 0;
16010
+ object.clickInfo.W = 1;
16011
+ if (hitSomething == Object3D.hitCenter)
16012
+ {
16013
+ info.DX = X;
16014
+ if (X != 0)
16015
+ info.DX -= info.bounds.width/2;
16016
+
16017
+ info.DY = Y;
16018
+ if (Y != 0)
16019
+ info.DY -= info.bounds.height/2;
16020
+ }
16021
+
16022
+ object.drawEditHandles(//info,
16023
+ 0);
16024
+
16025
+ if (drag && (X != 0 || Y != 0))
16026
+ {
16027
+ switch (hitSomething)
16028
+ {
16029
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16030
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16031
+ break;
16032
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16033
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16034
+ break;
16035
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16036
+ gr.drawLine(X, Y, 0, 0);
16037
+ break;
16038
+ }
16039
+
16040
+ }
16041
+ }
1541916042 }
1542016043 }
16044
+
1542116045 if (isRenderer)
1542216046 {
1542316047 //gr.setColor(Color.black);
1542416048 //gr.drawRect(info.bounds.x - 1, info.bounds.y - 1, info.bounds.width + 1, info.bounds.height + 1);
1542516049 //gr.drawRect(info.bounds.x - 2, info.bounds.y - 2, info.bounds.width + 3, info.bounds.height + 3);
1542616050 }
16051
+
1542716052 if (hasMarquee)
1542816053 {
1542916054 gr.setXORMode(Color.white);
....@@ -15536,6 +16161,7 @@
1553616161 public boolean mouseDown(Event evt, int x, int y)
1553716162 {
1553816163 System.out.println("mouseDown: " + evt);
16164
+ System.exit(0);
1553916165 /*
1554016166 locked = true;
1554116167 drag = false;
....@@ -15579,7 +16205,7 @@
1557916205 {
1558016206 keyPressed(0, modifiers);
1558116207 }
15582
- clickStart(x, y, modifiers);
16208
+ // clickStart(x, y, modifiers);
1558316209 return true;
1558416210 }
1558516211
....@@ -15697,7 +16323,7 @@
1569716323 {
1569816324 keyReleased(0, 0);
1569916325 }
15700
- drag(x, y, modifiers);
16326
+ drag(x, y, 0, modifiers);
1570116327 return true;
1570216328 }
1570316329
....@@ -15829,7 +16455,7 @@
1582916455 Object3D object;
1583016456 static Object3D trackedobject;
1583116457 Camera renderCamera; // Light or Eye (or Occlusion)
15832
- /*static*/ Camera manipCamera; // Light or Eye
16458
+ /*static*/ Camera manipCamera; // Light or Eye. Can be Light when Eye, not Eye when Light
1583316459 /*static*/ Camera eyeCamera;
1583416460 /*static*/ Camera lightCamera;
1583516461 int cameracount;
....@@ -16114,16 +16740,16 @@
1611416740 cStatic.objectstack[materialdepth++] = checker;
1611516741 //System.out.println("material " + material);
1611616742 //Applet3D.tracein(this, selected);
16117
- vector2buffer = checker.projectedVertices;
16743
+ //vector2buffer = checker.projectedVertices;
1611816744
1611916745 //checker.GetMaterial().Draw(this, false); // true);
16120
- DrawMaterial(checker.GetMaterial(), false); // true);
16746
+ DrawMaterial(checker.GetMaterial(), false, checker.projectedVertices); // true);
1612116747
1612216748 materialdepth -= 1;
1612316749 if (materialdepth > 0)
1612416750 {
16125
- vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16126
- DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1]);
16751
+ //vector2buffer = cStatic.objectstack[materialdepth - 1].projectedVertices;
16752
+ DrawMaterial(materialstack[materialdepth - 1], selectedstack[materialdepth - 1], cStatic.objectstack[materialdepth - 1].projectedVertices);
1612716753 }
1612816754 //checker.GetMaterial().opacity = 1f;
1612916755 ////checker.GetMaterial().ambient = 1f;
....@@ -16209,6 +16835,14 @@
1620916835 }
1621016836 }
1621116837
16838
+ private Object3D GetFolder()
16839
+ {
16840
+ Object3D folder = object.GetWindow().copy;
16841
+ if (object.GetWindow().copy.selection.Size() > 0)
16842
+ folder = object.GetWindow().copy.selection.elementAt(0);
16843
+ return folder;
16844
+ }
16845
+
1621216846 class SelectBuffer implements GLEventListener
1621316847 {
1621416848
....@@ -16267,6 +16901,7 @@
1626716901 {
1626816902 if (!selection)
1626916903 {
16904
+ new Exception().printStackTrace();
1627016905 System.exit(0);
1627116906 return;
1627216907 }
....@@ -16287,6 +16922,17 @@
1628716922
1628816923 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1628916924
16925
+ if (PAINTMODE)
16926
+ {
16927
+ if (object.GetWindow().copy.selection.Size() > 0)
16928
+ {
16929
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16930
+
16931
+ // Make what you paint not selectable.
16932
+ paintobj.ResetSelectable();
16933
+ }
16934
+ }
16935
+
1629016936 //int tmp = selection_view;
1629116937 //selection_view = -1;
1629216938 int temp = DrawMode();
....@@ -16298,6 +16944,17 @@
1629816944 // temp = DEFAULT; // patch for selection debug
1629916945 Globals.drawMode = temp; // WARNING
1630016946
16947
+ if (PAINTMODE)
16948
+ {
16949
+ if (object.GetWindow().copy.selection.Size() > 0)
16950
+ {
16951
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
16952
+
16953
+ // Revert.
16954
+ paintobj.RestoreSelectable();
16955
+ }
16956
+ }
16957
+
1630116958 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1630216959
1630316960 // trying different ways of getting the depth info over
....@@ -16345,6 +17002,8 @@
1634517002 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1634617003 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1634717004 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17005
+
17006
+ CreateSelectedPoint();
1634817007
1634917008 // Will fit the mesh !!!
1635017009 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16394,34 +17053,36 @@
1639417053 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]));
1639517054 }
1639617055
16397
- previousselectedpoint = (Sphere) GrafreeD.clone(selectedpoint);
17056
+ previousselectedpoint = (Sphere) Grafreed.clone(selectedpoint);
1639817057 }
1639917058 }
1640017059
1640117060 if (!movingcamera && !PAINTMODE)
16402
- object.editWindow.ScreenFitPoint(); // fev 2014
17061
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1640317062
16404
- if (PAINTMODE && GrafreeD.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17063
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1640517064 {
16406
- Object3D paintobj = GrafreeD.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17065
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1640717066
16408
- Object3D group = new Object3D("inst" + paintcount++);
17067
+ if (object.GetWindow().copy.selection.Size() > 0)
17068
+ {
17069
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1640917070
16410
- group.CreateMaterial(); // use a void leaf to select instances
16411
-
16412
- group.add(paintobj); // link
16413
-
16414
- object.editWindow.SnapObject(group);
16415
-
16416
- Object3D folder = object.editWindow.copy;
16417
-
16418
- if (object.editWindow.copy.selection.Size() > 0)
16419
- folder = object.editWindow.copy.selection.elementAt(0);
16420
-
16421
- folder.add(group);
16422
-
16423
- object.editWindow.ResetModel();
16424
- object.editWindow.refreshContents();
17071
+ Object3D inst = new Object3D("inst" + paintcount++);
17072
+
17073
+ inst.CreateMaterial(); // use a void leaf to select instances
17074
+
17075
+ inst.add(paintobj); // link
17076
+
17077
+ object.GetWindow().SnapObject(inst);
17078
+
17079
+ Object3D folder = paintFolder; // GetFolder();
17080
+
17081
+ folder.add(inst);
17082
+
17083
+ object.GetWindow().ResetModel();
17084
+ object.GetWindow().refreshContents();
17085
+ }
1642517086 }
1642617087 else
1642717088 paintcount = 0;
....@@ -16460,6 +17121,11 @@
1646017121 //System.out.println("objects[color] = " + objects[color]);
1646117122 //objects[color].Select();
1646217123 indexcount = 0;
17124
+ ObjEditor window = object.GetWindow();
17125
+ if (window != null && deselect)
17126
+ {
17127
+ window.Select(null, deselect, true);
17128
+ }
1646317129 object.Select(color, deselect);
1646417130 }
1646517131
....@@ -16559,7 +17225,7 @@
1655917225 gl.glDisable(gl.GL_CULL_FACE);
1656017226 }
1656117227
16562
- if (!RENDERSHADOW)
17228
+ if (!Globals.RENDERSHADOW)
1656317229 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1656417230
1656517231 // SB gl.glPolygonOffset(2.5f, 10);
....@@ -16569,7 +17235,7 @@
1656917235 //gl.glColorMask(false, false, false, false);
1657017236
1657117237 //render_scene_from_light_view(gl, drawable, 0, 0);
16572
- if (RENDERSHADOW && Globals.lighttouched && !movingcamera) // && !parent.IsFreezed())
17238
+ if (Globals.RENDERSHADOW && Globals.lighttouched && (!movingcamera || !Globals.FREEZEONMOVE)) // && !parent.IsFreezed())
1657317239 {
1657417240 gl.glClear(GL.GL_COLOR_BUFFER_BIT | GL.GL_DEPTH_BUFFER_BIT);
1657517241
....@@ -16985,23 +17651,15 @@
1698517651 int AAbuffersize = 0;
1698617652
1698717653 //double[] selectedpoint = new double[3];
16988
- static Superellipsoid selectedpoint = new Superellipsoid();
17654
+ static Superellipsoid selectedpoint;
1698917655 static Sphere previousselectedpoint = null;
16990
- static Sphere debugpointG = new Sphere();
16991
- static Sphere debugpointP = new Sphere();
16992
- static Sphere debugpointC = new Sphere();
16993
- static Sphere debugpointR = new Sphere();
17656
+ static Sphere debugpointG;
17657
+ static Sphere debugpointP;
17658
+ static Sphere debugpointC;
17659
+ static Sphere debugpointR;
1699417660
1699517661 static Sphere debugpoints[] = new Sphere[8];
1699617662
16997
- static
16998
- {
16999
- for (int i=0; i<8; i++)
17000
- {
17001
- debugpoints[i] = new Sphere();
17002
- }
17003
- }
17004
-
1700517663 static void InitPoints(float radius)
1700617664 {
1700717665 for (int i=0; i<8; i++)