Normand Briere
2019-08-21 7ac1b01c591ed65743676b1181d60eb17c5cb69d
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 {
....@@ -44,6 +48,39 @@
4448 static boolean ABORTED = false;
4549
4650 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
+ }
4784
4885 /*static*/ private boolean CULLFACE = false; // true;
4986 /*static*/ boolean NEAREST = false; // true;
....@@ -60,7 +97,7 @@
6097 //boolean REDUCETEXTURE = true;
6198 boolean CACHETEXTURE = true;
6299 boolean CLEANCACHE = false; // true;
63
- boolean MIPMAP = false; // true;
100
+ boolean MIPMAP = false; // true; // never works...
64101 boolean COMPRESSTEXTURE = false;
65102 boolean KOMPACTTEXTURE = false; // true;
66103 boolean RESIZETEXTURE = false;
....@@ -73,7 +110,11 @@
73110 //private Mat4f spotlightTransform = new Mat4f();
74111 //private Mat4f spotlightInverseTransform = new Mat4f();
75112 static GLContext glcontext = null;
76
- /*static*/ com.sun.opengl.util.texture.Texture cubemap;
113
+ /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb
114
+ /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom;
115
+ /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb;
116
+ boolean transformMode;
117
+
77118 boolean reverseUP = false;
78119 static boolean frozen = false;
79120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -127,7 +168,7 @@
127168
128169
129170 // OPTIONS
130
- boolean Skinshader = true;
171
+ boolean Skinshader = false; // true;
131172 boolean cameraLight = false;
132173 boolean UVdebug = false;
133174 boolean Udebug = false;
....@@ -136,7 +177,7 @@
136177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
137178 boolean anisotropy = true;
138179 boolean softshadow = true; // slower but better false;
139
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
140181
141182 boolean macromode = false;
142183
....@@ -150,6 +191,19 @@
150191 }
151192
152193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
194
+
195
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
196
+ {
197
+ try
198
+ {
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
200
+ } catch (IOException e)
201
+ {
202
+ System.out.println("NAME = " + name);
203
+ e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
205
+ }
206
+ }
153207
154208 void SetAsGLRenderer(boolean b)
155209 {
....@@ -169,7 +223,8 @@
169223
170224 SetCamera(cam);
171225
172
- SetLight(new Camera(new cVector(10, 10, -20)));
226
+ // Warning: not used.
227
+ SetLight(new Camera(new cVector(15, 10, -20)));
173228
174229 object = o;
175230
....@@ -335,14 +390,28 @@
335390 display.options1[2] = material.shadowbias;
336391 display.options1[3] = material.aniso;
337392 display.options1[4] = material.anisoV;
393
+// System.out.println("display.options1[0] " + display.options1[0]);
394
+// System.out.println("display.options1[1] " + display.options1[1]);
395
+// System.out.println("display.options1[2] " + display.options1[2]);
396
+// System.out.println("display.options1[3] " + display.options1[3]);
397
+// System.out.println("display.options1[4] " + display.options1[4]);
338398 display.options2[0] = material.opacity;
339399 display.options2[1] = material.diffuse;
340400 display.options2[2] = material.factor;
401
+// System.out.println("display.options2[0] " + display.options2[0]);
402
+// System.out.println("display.options2[1] " + display.options2[1]);
403
+// System.out.println("display.options2[2] " + display.options2[2]);
341404
342405 cColor.HSBtoRGB(material.color, material.modulation, 1, display.options3);
406
+// System.out.println("display.options3[0] " + display.options3[0]);
407
+// System.out.println("display.options3[1] " + display.options3[1]);
408
+// System.out.println("display.options3[2] " + display.options3[2]);
343409 display.options4[0] = material.cameralight/0.2f;
344410 display.options4[1] = material.subsurface;
345411 display.options4[2] = material.sheen;
412
+// System.out.println("display.options4[0] " + display.options4[0]);
413
+// System.out.println("display.options4[1] " + display.options4[1]);
414
+// System.out.println("display.options4[2] " + display.options4[2]);
346415
347416 // if (display.CURRENTANTIALIAS > 0)
348417 // display.options3[3] /= 4;
....@@ -473,7 +542,8 @@
473542 LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1);
474543 LA.vecCross(obj.v0, obj.v1, obj.v2);
475544 LA.vecNormalize(obj.v2);
476
- gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
545
+
546
+ SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z);
477547 }
478548
479549 // P
....@@ -495,7 +565,7 @@
495565 y += ny * obj.NORMALPUSH;
496566 z += nz * obj.NORMALPUSH;
497567
498
- gl.glNormal3f(nx, ny, nz);
568
+ SetGLNormal(gl, nx, ny, nz);
499569 }
500570 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
501571 SetColor(obj, pv);
....@@ -527,7 +597,7 @@
527597 y += ny * obj.NORMALPUSH;
528598 z += nz * obj.NORMALPUSH;
529599
530
- gl.glNormal3f(nx, ny, nz);
600
+ SetGLNormal(gl, nx, ny, nz);
531601 }
532602 //System.out.println("vertexq = " + qv.s + ", " + qv.t);
533603 // boolean locked = false;
....@@ -575,7 +645,7 @@
575645 y += ny * obj.NORMALPUSH;
576646 z += nz * obj.NORMALPUSH;
577647
578
- gl.glNormal3f(nx, ny, nz);
648
+ SetGLNormal(gl, nx, ny, nz);
579649 }
580650
581651 // if ((dot&4) == 0)
....@@ -1181,10 +1251,10 @@
11811251 {
11821252 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
11831253 {
1184
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1254
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
11851255 } else
11861256 {
1187
- gl.glNormal3f(0, 0, 1);
1257
+ SetGLNormal(gl, 0, 0, 1);
11881258 }
11891259
11901260 if (c != null)
....@@ -1208,10 +1278,10 @@
12081278 {
12091279 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12101280 {
1211
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1281
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12121282 } else
12131283 {
1214
- gl.glNormal3f(0, 0, 1);
1284
+ SetGLNormal(gl, 0, 0, 1);
12151285 }
12161286 if (c != null)
12171287 {
....@@ -1236,10 +1306,10 @@
12361306 {
12371307 if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0)
12381308 {
1239
- gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]);
1309
+ SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]);
12401310 } else
12411311 {
1242
- gl.glNormal3f(0, 0, 1);
1312
+ SetGLNormal(gl, 0, 0, 1);
12431313 }
12441314 if (c != null)
12451315 {
....@@ -1421,7 +1491,7 @@
14211491 {
14221492 if (!selectmode)
14231493 {
1424
- gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
1494
+ SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z);
14251495 gl.glColor4f(pv.AO, pv.AO, pv.AO, 1);
14261496
14271497 if (flipV)
....@@ -1433,6 +1503,8 @@
14331503 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14341504 }
14351505
1506
+ float[] colorV = new float[4];
1507
+
14361508 void SetColor(Object3D obj, Vertex p0)
14371509 {
14381510 CameraPane display = this;
....@@ -1500,8 +1572,6 @@
15001572 {
15011573 return;
15021574 }
1503
-
1504
- float[] colorV = new float[3];
15051575
15061576 if (false) // marked)
15071577 {
....@@ -1750,7 +1820,7 @@
17501820
17511821 display.modelParams7[0] = 0;
17521822 display.modelParams7[1] = 1000;
1753
- display.modelParams7[2] = 0;
1823
+ display.modelParams7[2] = material.parallax;
17541824 display.modelParams7[3] = 0;
17551825
17561826 //display.modelParams6[0] = 100; // criss de bug de bump
....@@ -1983,9 +2053,9 @@
19832053 switch(viewcode)
19842054 {
19852055 case 0: return "main";
1986
- case 1: return "one";
1987
- case 2: return "two";
1988
- case 3: return "three";
2056
+ case 1: return "Red";
2057
+ case 2: return "Green";
2058
+ case 3: return "Blue";
19892059 case 4: return "light";
19902060 }
19912061
....@@ -2051,7 +2121,7 @@
20512121 //System.err.println("Oeil on");
20522122 OEIL = true;
20532123 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2054
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2124
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20552125 //pingthread.StepToTarget(true);
20562126 }
20572127
....@@ -2284,10 +2354,17 @@
22842354 HANDLES ^= true;
22852355 }
22862356
2357
+ Object3D paintFolder;
2358
+
22872359 void TogglePaint()
22882360 {
22892361 PAINTMODE ^= true;
22902362 paintcount = 0;
2363
+
2364
+ if (PAINTMODE)
2365
+ {
2366
+ paintFolder = GetFolder();
2367
+ }
22912368 }
22922369
22932370 void SwapCamera(int a, int b)
....@@ -2384,6 +2461,33 @@
23842461 return currentGL;
23852462 }
23862463
2464
+ static private BufferedImage CreateBim(TextureData texturedata)
2465
+ {
2466
+ Grafreed.Assert(texturedata != null);
2467
+
2468
+ int width = texturedata.getWidth();
2469
+ int height = texturedata.getHeight();
2470
+
2471
+ Buffer buffer = texturedata.getBuffer();
2472
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2473
+
2474
+ byte[] bytes = bytebuf.array();
2475
+
2476
+ return CreateBim(bytes, width, height);
2477
+ }
2478
+
2479
+ private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz)
2480
+ {
2481
+ gl.glNormal3f(nx, ny, nz);
2482
+
2483
+ if (ny > 0.9 || ny < -0.9)
2484
+ // Ground or ceiling
2485
+ gl.glVertexAttrib3f(4, 1, 0, 0);
2486
+ else
2487
+ // Walls
2488
+ gl.glVertexAttrib3f(4, 0, 1, 0);
2489
+ }
2490
+
23872491 /**/
23882492 class CacheTexture
23892493 {
....@@ -2392,28 +2496,31 @@
23922496
23932497 int resolution;
23942498
2395
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2499
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
23962500 {
2397
- texture = tex;
2501
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2502
+ texturedata = texdata;
23982503 resolution = res;
23992504 }
24002505 }
24012506 /**/
24022507
24032508 // TEXTURE static Texture texture;
2404
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2405
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2406
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2509
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2510
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2511
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2512
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2513
+
24072514 int pigmentdepth = 0;
24082515 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
24092516 int bumpdepth = 0;
24102517 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
24112518 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
24122519 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2413
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2520
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
24142521 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
24152522
2416
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2523
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
24172524 {
24182525 TextureData texturedata = null;
24192526
....@@ -2423,7 +2530,7 @@
24232530 com.sun.opengl.util.texture.TextureIO.newTextureData(
24242531 getClass().getClassLoader().getResourceAsStream(name),
24252532 true,
2426
- com.sun.opengl.util.texture.TextureIO.PNG);
2533
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
24272534 } catch (java.io.IOException e)
24282535 {
24292536 throw new javax.media.opengl.GLException(e);
....@@ -2432,13 +2539,34 @@
24322539 if (bump)
24332540 texturedata = ConvertBump(texturedata, false);
24342541
2435
- com.sun.opengl.util.texture.Texture texture =
2436
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2542
+// com.sun.opengl.util.texture.Texture texture =
2543
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
24372544
2438
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2439
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2545
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2546
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
24402547
2441
- return texture;
2548
+ return texturedata;
2549
+ }
2550
+
2551
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2552
+ {
2553
+ TextureData texturedata = null;
2554
+
2555
+ try
2556
+ {
2557
+ texturedata =
2558
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2559
+ bim,
2560
+ true);
2561
+ } catch (Exception e)
2562
+ {
2563
+ throw new javax.media.opengl.GLException(e);
2564
+ }
2565
+
2566
+ if (bump)
2567
+ texturedata = ConvertBump(texturedata, false);
2568
+
2569
+ return texturedata;
24422570 }
24432571
24442572 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3511,6 +3639,8 @@
35113639
35123640 System.out.println("LOADING TEXTURE : " + name);
35133641
3642
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3643
+
35143644 //
35153645 if (false) // compressbit > 0)
35163646 {
....@@ -7909,7 +8039,7 @@
79098039 String pigment = Object3D.GetPigment(tex);
79108040 String bump = Object3D.GetBump(tex);
79118041
7912
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8042
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79138043 {
79148044 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79158045 // System.out.println("; bump = " + bump);
....@@ -7924,8 +8054,8 @@
79248054 pigment = null;
79258055 }
79268056
7927
- ReleaseTexture(bump, true);
7928
- ReleaseTexture(pigment, false);
8057
+ ReleaseTexture(tex, true);
8058
+ ReleaseTexture(tex, false);
79298059 }
79308060
79318061 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -7943,7 +8073,7 @@
79438073
79448074 String pigment = Object3D.GetPigment(tex);
79458075
7946
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8076
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79478077 {
79488078 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79498079 // System.out.println("; bump = " + bump);
....@@ -7954,7 +8084,7 @@
79548084 pigment = null;
79558085 }
79568086
7957
- ReleaseTexture(pigment, false);
8087
+ ReleaseTexture(tex, false);
79588088 }
79598089
79608090 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -7972,7 +8102,7 @@
79728102
79738103 String bump = Object3D.GetBump(tex);
79748104
7975
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8105
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
79768106 {
79778107 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
79788108 // System.out.println("; bump = " + bump);
....@@ -7983,10 +8113,10 @@
79838113 bump = null;
79848114 }
79858115
7986
- ReleaseTexture(bump, true);
8116
+ ReleaseTexture(tex, true);
79878117 }
79888118
7989
- void ReleaseTexture(String tex, boolean bump)
8119
+ void ReleaseTexture(cTexture tex, boolean bump)
79908120 {
79918121 if (// DrawMode() != 0 || /*tex == null ||*/
79928122 ambientOcclusion ) // || !textureon)
....@@ -7997,7 +8127,7 @@
79978127 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
79988128
79998129 if (tex != null)
8000
- texture = textures.get(tex);
8130
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
80018131
80028132 // //assert( texture != null );
80038133 // if (texture == null)
....@@ -8091,47 +8221,50 @@
80918221
80928222 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
80938223 {
8094
- if (// DrawMode() != 0 || /*tex == null ||*/
8095
- ambientOcclusion ) // || !textureon)
8096
- {
8097
- return; // false;
8098
- }
8099
-
8100
- if (tex == null)
8101
- {
8102
- BindTexture(null,false,resolution);
8103
- BindTexture(null,true,resolution);
8104
- return;
8105
- }
8224
+// if (// DrawMode() != 0 || /*tex == null ||*/
8225
+// ambientOcclusion ) // || !textureon)
8226
+// {
8227
+// return; // false;
8228
+// }
8229
+//
8230
+// if (tex == null)
8231
+// {
8232
+// BindTexture(null,false,resolution);
8233
+// BindTexture(null,true,resolution);
8234
+// return;
8235
+// }
8236
+//
8237
+// String pigment = Object3D.GetPigment(tex);
8238
+// String bump = Object3D.GetBump(tex);
8239
+//
8240
+// usedtextures.add(pigment);
8241
+// usedtextures.add(bump);
8242
+//
8243
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8244
+// {
8245
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8246
+// // System.out.println("; bump = " + bump);
8247
+// }
8248
+//
8249
+// if (bump.equals(""))
8250
+// {
8251
+// bump = null;
8252
+// }
8253
+// if (pigment.equals(""))
8254
+// {
8255
+// pigment = null;
8256
+// }
8257
+//
8258
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8259
+// BindTexture(pigment, false, resolution);
8260
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8261
+// BindTexture(bump, true, resolution);
8262
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8263
+//
8264
+// return; // true;
81068265
8107
- String pigment = Object3D.GetPigment(tex);
8108
- String bump = Object3D.GetBump(tex);
8109
-
8110
- usedtextures.put(pigment, pigment);
8111
- usedtextures.put(bump, bump);
8112
-
8113
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8114
- {
8115
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8116
- // System.out.println("; bump = " + bump);
8117
- }
8118
-
8119
- if (bump.equals(""))
8120
- {
8121
- bump = null;
8122
- }
8123
- if (pigment.equals(""))
8124
- {
8125
- pigment = null;
8126
- }
8127
-
8128
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8129
- BindTexture(pigment, false, resolution);
8130
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8131
- BindTexture(bump, true, resolution);
8132
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8133
-
8134
- return; // true;
8266
+ BindPigmentTexture(tex, resolution);
8267
+ BindBumpTexture(tex, resolution);
81358268 }
81368269
81378270 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8150,9 +8283,9 @@
81508283
81518284 String pigment = Object3D.GetPigment(tex);
81528285
8153
- usedtextures.put(pigment, pigment);
8286
+ usedtextures.add(tex);
81548287
8155
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8288
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81568289 {
81578290 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81588291 // System.out.println("; bump = " + bump);
....@@ -8164,7 +8297,7 @@
81648297 }
81658298
81668299 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8167
- BindTexture(pigment, false, resolution);
8300
+ BindTexture(tex, false, resolution);
81688301 }
81698302
81708303 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8183,9 +8316,9 @@
81838316
81848317 String bump = Object3D.GetBump(tex);
81858318
8186
- usedtextures.put(bump, bump);
8319
+ usedtextures.add(tex);
81878320
8188
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8321
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81898322 {
81908323 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
81918324 // System.out.println("; bump = " + bump);
....@@ -8197,7 +8330,7 @@
81978330 }
81988331
81998332 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8200
- BindTexture(bump, true, resolution);
8333
+ BindTexture(tex, true, resolution);
82018334 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
82028335 }
82038336
....@@ -8221,13 +8354,19 @@
82218354 return fileExists;
82228355 }
82238356
8224
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8357
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
82258358 {
8226
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8359
+ CacheTexture texturecache = null;
82278360
82288361 if (tex != null)
82298362 {
8230
- String texname = tex;
8363
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8364
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8365
+
8366
+ if (texname.equals("") && texdata == null)
8367
+ {
8368
+ return null;
8369
+ }
82318370
82328371 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
82338372
....@@ -8237,19 +8376,46 @@
82378376 // else
82388377 // if (!texname.startsWith("/"))
82398378 // texname = "/Users/nbriere/Textures/" + texname;
8240
- if (!FileExists(tex))
8379
+ if (!FileExists(texname) && !texname.startsWith("@"))
82418380 {
82428381 texname = fallbackTextureName;
82438382 }
82448383
82458384 if (CACHETEXTURE)
8246
- texture = textures.get(texname); // TEXTURE CACHE
8247
-
8248
- TextureData texturedata = null;
8249
-
8250
- if (texture == null || texture.resolution < resolution)
82518385 {
8252
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8386
+ if (texdata == null)
8387
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8388
+ else
8389
+ texturecache = bimtextures.get(texdata);
8390
+ }
8391
+
8392
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8393
+ {
8394
+ TextureData texturedata = null;
8395
+
8396
+ if (texdata != null && textureon)
8397
+ {
8398
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8399
+
8400
+ try
8401
+ {
8402
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8403
+ }
8404
+ catch (Exception e)
8405
+ {
8406
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8407
+ }
8408
+
8409
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8410
+ bimtextures.put(texdata, texturecache);
8411
+
8412
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8413
+
8414
+ //Object bim2 = CreateBim(texturecache.texturedata);
8415
+ //bim2 = bim;
8416
+ }
8417
+ else
8418
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
82538419 {
82548420 assert(!bump);
82558421 // if (bump)
....@@ -8260,19 +8426,23 @@
82608426 // }
82618427 // else
82628428 // {
8263
- texture = textures.get(tex);
8264
- if (texture == null)
8429
+ // texturecache = textures.get(texname); // suspicious
8430
+ if (texturecache == null)
82658431 {
8266
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8432
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
82678433 }
8434
+ else
8435
+ new Exception().printStackTrace();
82688436 // }
82698437 } else
8270
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8438
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
82718439 {
82728440 assert(bump);
8273
- texture = textures.get(tex);
8274
- if (texture == null)
8275
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8441
+ // texturecache = textures.get(texname); // suspicious
8442
+ if (texturecache == null)
8443
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8444
+ else
8445
+ new Exception().printStackTrace();
82768446 } else
82778447 {
82788448 //if (tex.equals("IMMORTAL"))
....@@ -8280,11 +8450,22 @@
82808450 // texture = GetResourceTexture("default.png");
82818451 //} else
82828452 //{
8283
- if (tex.equals("WHITE_NOISE"))
8453
+ if (texname.endsWith("WHITE_NOISE"))
82848454 {
8285
- texture = textures.get(tex);
8286
- if (texture == null)
8287
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8455
+ // texturecache = textures.get(texname); // suspicious
8456
+ if (texturecache == null)
8457
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8458
+ else
8459
+ new Exception().printStackTrace();
8460
+ } else
8461
+ {
8462
+ if (texname.startsWith("@"))
8463
+ {
8464
+ // texturecache = textures.get(texname); // suspicious
8465
+ if (texturecache == null)
8466
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8467
+ else
8468
+ new Exception().printStackTrace();
82888469 } else
82898470 {
82908471 if (textureon)
....@@ -8343,19 +8524,20 @@
83438524 if (texturedata == null)
83448525 throw new Exception();
83458526
8346
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8527
+ texturecache = new CacheTexture(texturedata,resolution);
83478528 //texture = GetTexture(tex, bump);
83488529 }
8530
+ }
83498531 }
83508532 //}
83518533 }
83528534
8353
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8535
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
83548536 {
83558537 //return false;
83568538
83578539 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8358
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8540
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
83598541 {
83608542 // String ext = "_highres";
83618543 // if (REDUCETEXTURE)
....@@ -8372,52 +8554,17 @@
83728554 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
83738555 if (!cachefile.exists())
83748556 {
8375
- // cache to disk
8376
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8377
- //buffers[0].
8378
-
8379
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8380
- int[] pixels = new int[bytebuf.capacity()/3];
8381
-
8382
- // squared size heuristic...
8383
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8557
+ //if (texturedata.getWidth() == texturedata.getHeight())
83848558 {
8385
- for (int i=pixels.length; --i>=0;)
8386
- {
8387
- int i3 = i*3;
8388
- pixels[i] = 0xFF;
8389
- pixels[i] <<= 8;
8390
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8391
- pixels[i] <<= 8;
8392
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8393
- pixels[i] <<= 8;
8394
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8395
- }
8396
-
8397
- /*
8398
- int r=0,g=0,b=0,a=0;
8399
- for (int i=0; i<width; i++)
8400
- for (int j=0; j<height; j++)
8401
- {
8402
- int index = j*width+i;
8403
- int p = pixels[index];
8404
- a = ((p>>24) & 0xFF);
8405
- r = ((p>>16) & 0xFF);
8406
- g = ((p>>8) & 0xFF);
8407
- b = (p & 0xFF);
8408
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8409
- }
8410
- /**/
8411
- int width = (int)Math.sqrt(pixels.length); // squared
8412
- int height = width;
8413
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8414
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8559
+ BufferedImage rendImage = CreateBim(texturedata);
8560
+
84158561 ImageWriter writer = null;
84168562 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
84178563 if (iter.hasNext()) {
84188564 writer = (ImageWriter)iter.next();
84198565 }
8420
- float compressionQuality = 0.9f;
8566
+
8567
+ float compressionQuality = 0.85f;
84218568 try
84228569 {
84238570 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8434,18 +8581,20 @@
84348581 }
84358582 }
84368583 }
8437
-
8584
+
8585
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8586
+
84388587 //System.out.println("Texture = " + tex);
8439
- if (textures.containsKey(texname))
8588
+ if (textures.containsKey(tex))
84408589 {
8441
- CacheTexture thetex = textures.get(texname);
8590
+ CacheTexture thetex = textures.get(tex);
84428591 thetex.texture.disable();
84438592 thetex.texture.dispose();
8444
- textures.remove(texname);
8593
+ textures.remove(tex);
84458594 }
84468595
8447
- texture.texturedata = texturedata;
8448
- textures.put(texname, texture);
8596
+ //texture.texturedata = texturedata;
8597
+ textures.put(tex, texturecache);
84498598
84508599 // newtex = true;
84518600 }
....@@ -8461,10 +8610,44 @@
84618610 }
84628611 }
84638612
8464
- return texture;
8613
+ return texturecache;
84658614 }
84668615
8467
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8616
+ static void EmbedTextures(cTexture tex)
8617
+ {
8618
+ if (tex.pigmentdata == null)
8619
+ {
8620
+ //String texname = Object3D.GetPigment(tex);
8621
+
8622
+ CacheTexture texturecache = texturepigment.get(tex);
8623
+
8624
+ if (texturecache != null)
8625
+ {
8626
+ tex.pw = texturecache.texturedata.getWidth();
8627
+ tex.ph = texturecache.texturedata.getHeight();
8628
+ tex.pigmentdata = //CompressJPEG(CreateBim
8629
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8630
+ ;
8631
+ //, tex.pw, tex.ph), 0.5f);
8632
+ }
8633
+ }
8634
+
8635
+ if (tex.bumpdata == null)
8636
+ {
8637
+ //String texname = Object3D.GetBump(tex);
8638
+
8639
+ CacheTexture texturecache = texturebump.get(tex);
8640
+
8641
+ if (texturecache != null)
8642
+ {
8643
+ tex.bw = texturecache.texturedata.getWidth();
8644
+ tex.bh = texturecache.texturedata.getHeight();
8645
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8646
+ }
8647
+ }
8648
+ }
8649
+
8650
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
84688651 {
84698652 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84708653
....@@ -8482,21 +8665,21 @@
84828665 return texture!=null?texture.texture:null;
84838666 }
84848667
8485
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8668
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
84868669 {
84878670 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
84888671
84898672 return texture!=null?texture.texturedata:null;
84908673 }
84918674
8492
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8675
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
84938676 {
84948677 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
84958678 {
84968679 return false;
84978680 }
84988681
8499
- boolean newtex = false;
8682
+ //boolean newtex = false;
85008683
85018684 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
85028685
....@@ -8528,9 +8711,75 @@
85288711 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
85298712 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
85308713
8531
- return newtex;
8714
+ return true; // Warning: not used.
85328715 }
85338716
8717
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8718
+ {
8719
+ try
8720
+ {
8721
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8722
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8723
+ ImageWriter writer = writers.next();
8724
+
8725
+ ImageWriteParam param = writer.getDefaultWriteParam();
8726
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8727
+ param.setCompressionQuality(quality);
8728
+
8729
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8730
+ writer.setOutput(ios);
8731
+ writer.write(null, new IIOImage(image, null, null), param);
8732
+
8733
+ byte[] data = baos.toByteArray();
8734
+ writer.dispose();
8735
+ return data;
8736
+ }
8737
+ catch (Exception e)
8738
+ {
8739
+ e.printStackTrace();
8740
+ return null;
8741
+ }
8742
+ }
8743
+
8744
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8745
+ {
8746
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8747
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8748
+ ImageReader reader = writers.next();
8749
+
8750
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8751
+
8752
+ ImageReadParam param = reader.getDefaultReadParam();
8753
+ param.setDestination(bim);
8754
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8755
+
8756
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8757
+ reader.setInput(ios);
8758
+ BufferedImage bim2 = reader.read(0, param);
8759
+ reader.dispose();
8760
+
8761
+// WritableRaster raster = bim2.getRaster();
8762
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8763
+// byte[] bytes = data.getData();
8764
+//
8765
+// int[] pixels = new int[bytes.length/3];
8766
+// for (int i=pixels.length; --i>=0;)
8767
+// {
8768
+// int i3 = i*3;
8769
+// pixels[i] = 0xFF;
8770
+// pixels[i] <<= 8;
8771
+// pixels[i] |= bytes[i3+2] & 0xFF;
8772
+// pixels[i] <<= 8;
8773
+// pixels[i] |= bytes[i3+1] & 0xFF;
8774
+// pixels[i] <<= 8;
8775
+// pixels[i] |= bytes[i3] & 0xFF;
8776
+// }
8777
+//
8778
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8779
+
8780
+ return bim;
8781
+ }
8782
+
85348783 ShadowBuffer shadowPBuf;
85358784 AntialiasBuffer antialiasPBuf;
85368785 int MAXSTACK;
....@@ -8547,10 +8796,12 @@
85478796
85488797 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
85498798 MAXSTACK = temp[0];
8550
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
85518801 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
85528802 MAXSTACK = temp[0];
8553
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8803
+ if (Globals.DEBUG)
8804
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
85548805
85558806 // Use debug pipeline
85568807 //drawable.setGL(new DebugGL(gl)); //
....@@ -8558,7 +8809,8 @@
85588809 gl = drawable.getGL(); //
85598810
85608811 GL gl3 = getGL();
8561
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8812
+ if (Globals.DEBUG)
8813
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
85628814
85638815
85648816 //float pos[] = { 100, 100, 100, 0 };
....@@ -8723,7 +8975,7 @@
87238975
87248976 if (cubemap == null)
87258977 {
8726
- LoadEnvy(5);
8978
+ //LoadEnvy(1);
87278979 }
87288980
87298981 //cubemap.enable();
....@@ -8999,6 +9251,8 @@
89999251
90009252 void LoadEnvy(int which)
90019253 {
9254
+ assert(false);
9255
+
90029256 String name;
90039257 String ext;
90049258
....@@ -9010,37 +9264,58 @@
90109264 cubemap = null;
90119265 return;
90129266 case 1:
9013
- name = "cubemaps/box_";
9014
- ext = "png";
9267
+ name = "cubemaps/rgb/";
9268
+ ext = "jpg";
90159269 reverseUP = false;
90169270 break;
90179271 case 2:
9018
- name = "cubemaps/uffizi_";
9019
- ext = "png";
9020
- break; // reverseUP = true; break;
9272
+ name = "cubemaps/uffizi/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
90219276 case 3:
9022
- name = "cubemaps/CloudyHills_";
9023
- ext = "tga";
9277
+ name = "cubemaps/CloudyHills/";
9278
+ ext = "jpg";
90249279 reverseUP = false;
90259280 break;
90269281 case 4:
9027
- name = "cubemaps/cornell_";
9282
+ name = "cubemaps/cornell/";
90289283 ext = "png";
90299284 reverseUP = false;
90309285 break;
9286
+ case 5:
9287
+ name = "cubemaps/skycube/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 6:
9292
+ name = "cubemaps/SaintLazarusChurch3/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
9296
+ case 7:
9297
+ name = "cubemaps/Sodermalmsallen/";
9298
+ ext = "jpg";
9299
+ reverseUP = false;
9300
+ break;
9301
+ case 8:
9302
+ name = "cubemaps/Sodermalmsallen2/";
9303
+ ext = "jpg";
9304
+ reverseUP = false;
9305
+ break;
9306
+ case 9:
9307
+ name = "cubemaps/UnionSquare/";
9308
+ ext = "jpg";
9309
+ reverseUP = false;
9310
+ break;
90319311 default:
9032
- name = "cubemaps/rgb_";
9033
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9312
+ name = "cubemaps/box/";
9313
+ ext = "png"; /*mipmap = true;*/
9314
+ reverseUP = false;
90349315 break;
90359316 }
9036
-
9037
- try
9038
- {
9039
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9040
- } catch (IOException e)
9041
- {
9042
- throw new RuntimeException(e);
9043
- }
9317
+
9318
+ LoadSkybox(name, ext, mipmap);
90449319 }
90459320
90469321 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9072,8 +9347,12 @@
90729347 static double[] model = new double[16];
90739348 double[] camera2light = new double[16];
90749349 double[] light2camera = new double[16];
9075
- int newenvy = -1;
9076
- boolean envyoff = true; // false;
9350
+
9351
+ //int newenvy = -1;
9352
+ //boolean envyoff = false;
9353
+
9354
+ String loadedskyboxname;
9355
+
90779356 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
90789357 //float[] light0 = { 0,0,0 };
90799358 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9366,11 +9645,35 @@
93669645 jy8[3] = 0.5f;
93679646 }
93689647
9369
- float[] options1 = new float[]{1000, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
9648
+ float[] options1 = new float[]{100, 0.00001f, 20, 0, 0}; // focus, aperture, Shadow blur, aniso, anisoV
93709649 float[] options2 = new float[]{0, 1, 0, 0}; // fog density, intensity, elevation
93719650 float[] options3 = new float[]{1, 1, 1, 0}; // fog color
93729651 float[] options4 = new float[]{1, 0, 1, 0}; // image intensity, subsurface, lightsheen
93739652
9653
+ void ResetOptions()
9654
+ {
9655
+ options1[0] = 100;
9656
+ options1[1] = 0.025f;
9657
+ options1[2] = 0.01f;
9658
+ options1[3] = 0;
9659
+ options1[4] = 0;
9660
+
9661
+ options2[0] = 0;
9662
+ options2[1] = 0.75f;
9663
+ options2[2] = 0;
9664
+ options2[3] = 0;
9665
+
9666
+ options3[0] = 1;
9667
+ options3[1] = 1;
9668
+ options3[2] = 1;
9669
+ options3[3] = 0;
9670
+
9671
+ options4[0] = 1;
9672
+ options4[1] = 0;
9673
+ options4[2] = 1;
9674
+ options4[3] = 0;
9675
+ }
9676
+
93749677 static int imagecount = 0; // movie generation
93759678
93769679 static int jitter = 0;
....@@ -9467,7 +9770,7 @@
94679770
94689771 if (renderCamera != lightCamera)
94699772 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9470
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9773
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
94719774
94729775 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
94739776
....@@ -9483,7 +9786,7 @@
94839786
94849787 if (renderCamera != lightCamera)
94859788 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9486
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9789
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
94879790
94889791 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
94899792
....@@ -9529,10 +9832,12 @@
95299832 rati = 1 / rati;
95309833 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
95319834 }
9532
- assert (newenvy == -1);
9835
+
9836
+ //assert (newenvy == -1);
9837
+
95339838 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
95349839 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9535
- DrawSkyBox(gl);
9840
+ DrawSkyBox(gl, (float)rati);
95369841 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
95379842 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
95389843 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10398,9 +10703,18 @@
1039810703 static boolean init = false;
1039910704
1040010705 double[][] matrix = LA.newMatrix();
10706
+
10707
+ // This is to refresh the UI of the material panel.
10708
+ ObjEditor patchMaterial;
1040110709
1040210710 public void display(GLAutoDrawable drawable)
1040310711 {
10712
+ if (patchMaterial.patchMaterial)
10713
+ {
10714
+ patchMaterial.patchMaterial = false;
10715
+ patchMaterial.objectPanel.setSelectedIndex(1);
10716
+ }
10717
+
1040410718 if (Grafreed.savesound && Grafreed.hassound)
1040510719 {
1040610720 Grafreed.wav.save();
....@@ -10481,6 +10795,7 @@
1048110795 ANTIALIAS = 0;
1048210796 //System.out.println("RESTART");
1048310797 AAtimer.restart();
10798
+ Globals.TIMERRUNNING = true;
1048410799 }
1048510800 }
1048610801 }
....@@ -10568,7 +10883,7 @@
1056810883
1056910884 if (wait)
1057010885 {
10571
- Sleep(500);
10886
+ Sleep(200); // blocks everything
1057210887
1057310888 wait = false;
1057410889 }
....@@ -10683,7 +10998,7 @@
1068310998 // if (parentcam != renderCamera) // not a light
1068410999 if (cam != lightCamera)
1068511000 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10686
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
11001
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1068711002
1068811003 for (int j = 0; j < 4; j++)
1068911004 {
....@@ -10698,7 +11013,7 @@
1069811013 // if (parentcam != renderCamera) // not a light
1069911014 if (cam != lightCamera)
1070011015 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10701
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
11016
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1070211017
1070311018 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1070411019
....@@ -10784,13 +11099,43 @@
1078411099 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1078511100 }
1078611101
10787
- if (newenvy > -1)
11102
+// if (newenvy > -1)
11103
+// {
11104
+// LoadEnvy(newenvy);
11105
+// }
11106
+//
11107
+// newenvy = -1;
11108
+
11109
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1078811110 {
10789
- LoadEnvy(newenvy);
11111
+ if (cubemaprgb == null)
11112
+ {
11113
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false);
11114
+ }
11115
+
11116
+ cubemap = cubemaprgb;
1079011117 }
10791
-
10792
- newenvy = -1;
10793
-
11118
+ else
11119
+ {
11120
+ if (object.skyboxname != null)
11121
+ {
11122
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11123
+ {
11124
+ if (cubemap != null && cubemap != cubemaprgb)
11125
+ cubemap.dispose();
11126
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11127
+ loadedskyboxname = object.skyboxname;
11128
+ }
11129
+ }
11130
+ else
11131
+ {
11132
+ cubemapcustom = null;
11133
+ loadedskyboxname = null;
11134
+ }
11135
+
11136
+ cubemap = cubemapcustom;
11137
+ }
11138
+
1079411139 ratio = ((double) getWidth()) / getHeight();
1079511140 //System.out.println("ratio = " + ratio);
1079611141
....@@ -10806,7 +11151,7 @@
1080611151
1080711152 if (!IsFrozen() && !ambientOcclusion)
1080811153 {
10809
- DrawSkyBox(gl);
11154
+ DrawSkyBox(gl, (float)ratio);
1081011155 }
1081111156
1081211157 //if (selection_view == -1)
....@@ -10989,9 +11334,9 @@
1098911334
1099011335 gl.glMatrixMode(GL.GL_MODELVIEW);
1099111336
10992
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
10993
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
10994
-//gl.glEnable(gl.GL_MULTISAMPLE);
11337
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11338
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11339
+gl.glEnable(gl.GL_MULTISAMPLE);
1099511340 } else
1099611341 {
1099711342 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11002,7 +11347,7 @@
1100211347 //System.out.println("BLENDING ON");
1100311348 gl.glEnable(GL.GL_BLEND);
1100411349 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11005
-
11350
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1100611351 gl.glMatrixMode(gl.GL_PROJECTION);
1100711352 gl.glLoadIdentity();
1100811353
....@@ -11092,7 +11437,7 @@
1109211437
1109311438 // if (cam != lightCamera)
1109411439 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11095
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11440
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1109611441 }
1109711442
1109811443 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -11251,7 +11596,7 @@
1125111596 }
1125211597 }
1125311598
11254
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11599
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1125511600 {
1125611601 //gl.glDepthFunc(GL.GL_LEQUAL);
1125711602 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11259,24 +11604,21 @@
1125911604
1126011605 boolean texon = textureon;
1126111606
11262
- if (RENDERPROGRAM > 0)
11263
- {
11264
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11265
- textureon = false;
11266
- }
11607
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11608
+ textureon = false;
11609
+
1126711610 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1126811611 //System.out.println("ALLO");
1126911612 gl.glColorMask(false, false, false, false);
1127011613 DrawObject(gl);
11271
- if (RENDERPROGRAM > 0)
11272
- {
11273
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11274
- textureon = texon;
11275
- }
11614
+
11615
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11616
+ textureon = texon;
11617
+
1127611618 gl.glColorMask(true, true, true, true);
1127711619
1127811620 gl.glDepthFunc(GL.GL_EQUAL);
11279
- //gl.glDepthMask(false);
11621
+ gl.glDepthMask(false);
1128011622 }
1128111623
1128211624 if (false) // DrawMode() == SHADOW)
....@@ -11459,7 +11801,7 @@
1145911801
1146011802 static boolean zoomonce = false;
1146111803
11462
- void CreateSelectedPoint()
11804
+ static void CreateSelectedPoint()
1146311805 {
1146411806 if (selectedpoint == null)
1146511807 {
....@@ -11479,13 +11821,16 @@
1147911821
1148011822 void DrawObject(GL gl, boolean draw)
1148111823 {
11824
+ // To clear camera values
11825
+ ResetOptions();
11826
+
1148211827 //System.out.println("DRAW OBJECT " + mouseDown);
1148311828 // DrawMode() = SELECTION;
1148411829 //GL gl = getGL();
1148511830 if ((TRACK || SHADOWTRACK) || zoomonce)
1148611831 {
1148711832 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11488
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11833
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1148911834 pingthread.StepToTarget(true); // true);
1149011835 // zoomonce = false;
1149111836 }
....@@ -11613,20 +11958,32 @@
1161311958 ReleaseTextures(DEFAULT_TEXTURES);
1161411959
1161511960 if (CLEANCACHE)
11616
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11961
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1161711962 {
11618
- String tex = e.nextElement();
11963
+ cTexture tex = e.nextElement();
1161911964
1162011965 // System.out.println("Texture --------- " + tex);
1162111966
11622
- if (tex.equals("WHITE_NOISE"))
11967
+ if (tex.equals("WHITE_NOISE:"))
1162311968 continue;
1162411969
11625
- if (!usedtextures.containsKey(tex))
11970
+ if (!usedtextures.contains(tex))
1162611971 {
11972
+ CacheTexture gettex = texturepigment.get(tex);
1162711973 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11628
- textures.get(tex).texture.dispose();
11629
- textures.remove(tex);
11974
+ if (gettex != null)
11975
+ {
11976
+ gettex.texture.dispose();
11977
+ texturepigment.remove(tex);
11978
+ }
11979
+
11980
+ gettex = texturebump.get(tex);
11981
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11982
+ if (gettex != null)
11983
+ {
11984
+ gettex.texture.dispose();
11985
+ texturebump.remove(tex);
11986
+ }
1163011987 }
1163111988 }
1163211989 }
....@@ -12046,7 +12403,7 @@
1204612403 for (int i = tp.size(); --i >= 0;)
1204712404 {
1204812405 //for (int count = tp.get(i).GetTransformCount(); --count>=0;)
12049
- LA.xformPos(light, tp.get(i).GlobalTransform(), light);
12406
+ LA.xformPos(light, tp.get(i).GlobalTransformInv(), light);
1205012407 }
1205112408
1205212409
....@@ -12154,8 +12511,76 @@
1215412511
1215512512 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1215612513
12157
- String program =
12514
+ String programmin =
12515
+ // Min shader
1215812516 "!!ARBfp1.0\n" +
12517
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12518
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12519
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12520
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12521
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12522
+ "PARAM light2cam0 = program.env[10];" +
12523
+ "PARAM light2cam1 = program.env[11];" +
12524
+ "PARAM light2cam2 = program.env[12];" +
12525
+ "TEMP temp;" +
12526
+ "TEMP light;" +
12527
+ "TEMP ndotl;" +
12528
+ "TEMP normal;" +
12529
+ "TEMP depth;" +
12530
+ "TEMP eye;" +
12531
+ "TEMP pos;" +
12532
+
12533
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12534
+ Normalize("normal") +
12535
+ "MOV light, state.light[0].position;" +
12536
+ "DP3 ndotl.x, light, normal;" +
12537
+
12538
+ // shadow
12539
+ "MOV pos, fragment.texcoord[1];" +
12540
+ "MOV temp, pos;" +
12541
+ ShadowTextureFetch("depth", "temp", "1") +
12542
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12543
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12544
+
12545
+ // No shadow when out of frustum
12546
+ //"SGE temp.y, depth.z, zero123.y;" +
12547
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12548
+
12549
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12550
+
12551
+ // Backlit
12552
+ "MOV pos.w, zero123.y;" +
12553
+ "DP4 eye.x, pos, light2cam0;" +
12554
+ "DP4 eye.y, pos, light2cam1;" +
12555
+ "DP4 eye.z, pos, light2cam2;" +
12556
+ Normalize("eye") +
12557
+
12558
+ "DP3 ndotl.y, -eye, normal;" +
12559
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12560
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12561
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12562
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12563
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12564
+
12565
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12566
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12567
+
12568
+ // Pigment
12569
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12570
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12571
+ "MUL temp, temp, ndotl.x;" +
12572
+
12573
+ "MUL temp, temp, zero123.z;" +
12574
+
12575
+ //"MUL temp, temp, ndotl.y;" +
12576
+
12577
+ "MOV temp.w, zero123.y;" + // reset alpha
12578
+ "MOV result.color, temp;" +
12579
+ "END";
12580
+
12581
+ String programmax =
12582
+ "!!ARBfp1.0\n" +
12583
+
1215912584 //"OPTION ARB_fragment_program_shadow;" +
1216012585 "PARAM light2cam0 = program.env[10];" +
1216112586 "PARAM light2cam1 = program.env[11];" +
....@@ -12181,7 +12606,7 @@
1218112606 "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow
1218212607 "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias
1218312608 "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough
12184
- "PARAM params7 = program.env[7];" + // noise power, opacity power
12609
+ "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax
1218512610 "PARAM options0 = program.env[63];" + // fog density, intensity, elevation
1218612611 "PARAM options1 = program.env[62];" + // fog rgb color
1218712612 "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen
....@@ -12270,8 +12695,7 @@
1227012695 "TEMP shininess;" +
1227112696 "\n" +
1227212697 "MOV texSamp, one;" +
12273
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12274
-
12698
+
1227512699 "MOV mapgrid.x, one2048th.x;" +
1227612700 "MOV temp, fragment.texcoord[1];" +
1227712701 /*
....@@ -12292,20 +12716,20 @@
1229212716 "MUL temp, floor, mapgrid.x;" +
1229312717 //"TEX depth0, temp, texture[1], 2D;" +
1229412718 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12295
- TextureFetch("depth0", "temp", "1") +
12719
+ ShadowTextureFetch("depth0", "temp", "1") +
1229612720 "") +
1229712721 "ADD temp.x, temp.x, mapgrid.x;" +
1229812722 //"TEX depth1, temp, texture[1], 2D;" +
1229912723 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12300
- TextureFetch("depth1", "temp", "1") +
12724
+ ShadowTextureFetch("depth1", "temp", "1") +
1230112725 "") +
1230212726 "ADD temp.y, temp.y, mapgrid.x;" +
1230312727 //"TEX depth2, temp, texture[1], 2D;" +
12304
- TextureFetch("depth2", "temp", "1") +
12728
+ ShadowTextureFetch("depth2", "temp", "1") +
1230512729 "SUB temp.x, temp.x, mapgrid.x;" +
1230612730 //"TEX depth3, temp, texture[1], 2D;" +
1230712731 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12308
- TextureFetch("depth3", "temp", "1") +
12732
+ ShadowTextureFetch("depth3", "temp", "1") +
1230912733 "") +
1231012734 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1231112735 //"MOV params, material;" +
....@@ -12427,7 +12851,7 @@
1242712851 "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut
1242812852 // mar 2013 ??? "KIL alpha.a;" +
1242912853 "MOV alpha, texSamp.aaaa;" + // y;" +
12430
- "KIL alpha.a;" +
12854
+ "KIL alpha.a;" + // not sure with parallax mapping
1243112855 /*
1243212856 "MUL temp.xy, temp, two;" +
1243312857 "TXB bump, temp, texture[0], 2D;" +
....@@ -12513,11 +12937,6 @@
1251312937 "SUB bump0, bump0, half;" +
1251412938 "ADD bump, bump, bump0;" +
1251512939
12516
- "MOV temp.x, texSamp.a;" +
12517
- "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
12518
- //"LRP texSamp0, params5.x, texSamp0, one;" +
12519
- "MOV texSamp.a, temp.x;" +
12520
-
1252112940 // double-sided
1252212941 /**/
1252312942 (doublesided?"DP3 temp.z, normal, eye;" +
....@@ -12534,19 +12953,62 @@
1253412953 "MOV normald, normal;" +
1253512954 "MOV normals, normal;" +
1253612955
12956
+ "MOV temp, fragment.texcoord[4];" +
12957
+
1253712958 // UV base
1253812959 //"DP3 UP.x,state.matrix.modelview.row[0],Y;" +
1253912960 //"DP3 UP.y,state.matrix.modelview.row[1],Y;" +
1254012961 //"DP3 UP.z,state.matrix.modelview.row[2],Y;" +
12541
- "DP3 UP.x,state.matrix.texture[7].row[0],Y;" +
12542
- "DP3 UP.y,state.matrix.texture[7].row[1],Y;" +
12543
- "DP3 UP.z,state.matrix.texture[7].row[2],Y;" +
12962
+ "DP3 UP.x,state.matrix.texture[7].row[0],temp;" +
12963
+ "DP3 UP.y,state.matrix.texture[7].row[1],temp;" +
12964
+ "DP3 UP.z,state.matrix.texture[7].row[2],temp;" +
12965
+ Normalize("UP") +
12966
+
1254412967 "XPD V, normal, UP;" +
1254512968 Normalize("V") +
1254612969 "XPD U, V, normal;" +
1254712970 Normalize("U") +
1254812971
1254912972 // parallax mapping
12973
+
12974
+ "DP3 temp2.x, V, eye;" +
12975
+ "DP3 temp2.y, U, eye;" +
12976
+ "DP3 temp2.z, normal, eye;" +
12977
+ "RCP temp2.z, temp2.z;" +
12978
+
12979
+ "DP3 temp2.w, texSamp, texSamp;" + // Height
12980
+ "RSQ temp2.w, temp2.w;" +
12981
+ "RCP temp2.w, temp2.w;" +
12982
+
12983
+ "SUB temp2.w, temp2.w, half;" +
12984
+// "SGE temp.x, temp2.w, eps.x;" +
12985
+// "MUL temp2.w, temp2.w, temp.x;" +
12986
+
12987
+ //"MOV texSamp, U;" +
12988
+
12989
+ "MUL temp2.z, temp2.z, temp2.w;" +
12990
+ "MUL temp2.z, temp2.z, params7.z;" + // parallax
12991
+
12992
+ "MUL temp2, temp2, temp2.z;" +
12993
+
12994
+ "MOV temp, fragment.texcoord[0];" +
12995
+
12996
+ "SUB temp, temp, temp2;" +
12997
+
12998
+ "TEX temp, temp, texture[0], 2D;" +
12999
+ "POW temp.a, temp.a, params6.w;" + // punch through
13000
+
13001
+ "ADD texSamp, temp, texSamp;" +
13002
+ "MUL temp.xyz, half, texSamp;" +
13003
+
13004
+ "MOV alpha, texSamp.aaaa;" +
13005
+
13006
+// parallax mapping
13007
+
13008
+ "MOV temp.x, texSamp.a;" +
13009
+ "LRP texSamp, params5.x, texSamp, one;" + // texture proportion
13010
+ //"LRP texSamp0, params5.x, texSamp0, one;" +
13011
+ "MOV texSamp.a, temp.x;" +
1255013012
1255113013 //"MOV temp, fragment.texcoord[0];" +
1255213014 //
....@@ -12676,10 +13138,10 @@
1267613138 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1267713139 "") +
1267813140
12679
- // display shadow only (bump == 0)
13141
+ // display shadow only (fakedepth == 0)
1268013142 "SUB temp.x, half.x, shadow.x;" +
1268113143 "MOV temp.y, -params5.z;" + // params6.x;" +
12682
- "SLT temp.z, temp.y, -one2048th.x;" +
13144
+ "SLT temp.z, temp.y, -c256i.x;" +
1268313145 "SUB temp.y, one.x, temp.z;" +
1268413146 "MUL temp.x, temp.x, temp.y;" +
1268513147 "KIL temp.x;" +
....@@ -13010,8 +13472,19 @@
1301013472 //once = true;
1301113473 }
1301213474
13013
- System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13014
- System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13475
+ String program = programmax;
13476
+
13477
+ if (Globals.MINSHADER)
13478
+ {
13479
+ program = programmin;
13480
+ }
13481
+
13482
+ if (Globals.DEBUG)
13483
+ {
13484
+ System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
13485
+ System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
13486
+ }
13487
+
1301513488 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1301613489
1301713490 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13058,7 +13531,8 @@
1305813531 "\n" +
1305913532 "END\n";
1306013533
13061
- System.out.println("Program shadow #" + 0 + "; length = " + program.length());
13534
+ if (Globals.DEBUG)
13535
+ System.out.println("Program shadow #" + 0 + "; length = " + program.length());
1306213536 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
1306313537
1306413538 //gl.glNewList(displayListID, GL.GL_COMPILE);
....@@ -13103,25 +13577,26 @@
1310313577 return out;
1310413578 }
1310513579
13106
- String TextureFetch(String dest, String src, String unit)
13580
+ // Also does frustum culling
13581
+ String ShadowTextureFetch(String dest, String src, String unit)
1310713582 {
1310813583 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1310913584 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1311013585 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13586
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13587
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1311113588 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13112
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13113
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13114
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13115
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13589
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13590
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1311613591 //"SWZ buffer, temp, w,w,w,w;";
13117
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13592
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1311813593 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1311913594 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1312013595 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13121
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13596
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1312213597
13123
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13124
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13598
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13599
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1312513600 }
1312613601
1312713602 String Shadow(String depth, String shadow)
....@@ -13168,7 +13643,7 @@
1316813643 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1316913644 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1317013645
13171
- // No shadow when out of frustrum
13646
+ // No shadow when out of frustum
1317213647 "SGE temp.x, " + depth + ".z, one.z;" +
1317313648 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1317413649 "";
....@@ -13315,7 +13790,7 @@
1331513790 /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow
1331613791 /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias
1331713792 /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough
13318
- /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power
13793
+ /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax
1331913794
1332013795 //Object3D.cVector2[] vector2buffer;
1332113796
....@@ -13333,9 +13808,10 @@
1333313808 "DP3 " + dest + ".z," + "normals," + "eye;" +
1333413809 "MAX " + dest + ".w," + dest + ".z," + "eps.x;" +
1333513810 //"MOV " + dest + ".w," + "normal.z;" +
13336
- "MUL " + dest + ".z," + "params2.w," + dest + ".x;" +
13337
- "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13338
- //"MOV " + dest + ".z," + "params2.w;" +
13811
+// "MUL " + dest + ".z," + "params2.w," + dest + ".x;" + // PRETTY HEURISTIC FOR VELVET
13812
+// "MUL " + dest + ".z," + dest + ".z," + dest + ".x;" +
13813
+
13814
+ "MOV " + dest + ".z," + "params2.w;" + // EXACT
1333913815 "POW " + dest + ".w," + dest + ".w," + dest + ".z;" +
1334013816 "RCP " + dest + ".w," + dest + ".w;" +
1334113817 //"RSQ " + dest + ".w," + dest + ".w;" +
....@@ -13481,7 +13957,7 @@
1348113957 "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" +
1348213958 "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" +
1348313959 "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" +
13484
- "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" +
13960
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
1348513961 "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" +
1348613962 "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" +
1348713963 //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" +
....@@ -13542,7 +14018,7 @@
1354214018 "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" +
1354314019 "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" +
1354414020 "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" +
13545
- //"MOV result.texcoord, vertex.texcoord;" +
14021
+ //"MOV result.texcoord, vertex.fogcoord;" +
1354614022 "MOV result.texcoord, temp;" +
1354714023 // border fade
1354814024 "MOV result.texcoord[3], vertex.texcoord;" +
....@@ -13589,7 +14065,9 @@
1358914065
1359014066 //"ADD temp.z, temp.z, one;" +
1359114067
13592
- "MOV result.color, temp;"
14068
+ "MOV result.texcoord[4], vertex.attrib[4];" + // U dir
14069
+
14070
+ "MOV result.color, temp;" // Normal
1359314071 : "MOV result.color, vertex.color;") +
1359414072 ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;"
1359514073 : "") +
....@@ -13840,6 +14318,7 @@
1384014318 else
1384114319 if (evt.getSource() == AAtimer)
1384214320 {
14321
+ Globals.TIMERRUNNING = false;
1384314322 if (mouseDown)
1384414323 {
1384514324 //new Exception().printStackTrace();
....@@ -13899,7 +14378,7 @@
1389914378
1390014379 // fev 2014???
1390114380 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
13902
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14381
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1390314382 pingthread.StepToTarget(true); // true);
1390414383 }
1390514384 // if (!LIVE)
....@@ -13914,6 +14393,7 @@
1391414393 return;
1391514394
1391614395 AAtimer.restart(); //
14396
+ Globals.TIMERRUNNING = true;
1391714397
1391814398 // waslive = LIVE;
1391914399 // LIVE = false;
....@@ -13963,14 +14443,15 @@
1396314443 drag = false;
1396414444 //System.out.println("Mouse DOWN");
1396514445 editObj = false;
13966
- ClickInfo info = new ClickInfo();
13967
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
13968
- info.pane = this;
13969
- info.camera = renderCamera;
13970
- info.x = x;
13971
- info.y = y;
13972
- info.modifiers = modifiersex;
13973
- editObj = object.doEditClick(info, 0);
14446
+ //ClickInfo info = new ClickInfo();
14447
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14448
+ object.clickInfo.pane = this;
14449
+ object.clickInfo.camera = renderCamera;
14450
+ object.clickInfo.x = x;
14451
+ object.clickInfo.y = y;
14452
+ object.clickInfo.modifiers = modifiersex;
14453
+ editObj = object.doEditClick(//info,
14454
+ 0);
1397414455 if (!editObj)
1397514456 {
1397614457 hasMarquee = true;
....@@ -14252,12 +14733,18 @@
1425214733 void GoDown(int mod)
1425314734 {
1425414735 MODIFIERS |= COMMAND;
14255
- /*
14736
+ boolean isVR = (mouseMode&VR)!=0;
14737
+ /**/
1425614738 if((mod&SHIFT) == SHIFT)
14257
- manipCamera.RotatePosition(0, -speed);
14739
+ {
14740
+ if (isVR)
14741
+ manipCamera.RotateInterest(0, -speed);
14742
+ else
14743
+ manipCamera.RotatePosition(0, -speed);
14744
+ }
1425814745 else
14259
- manipCamera.BackForth(0, -speed*delta, getWidth());
14260
- */
14746
+ manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth());
14747
+ /**/
1426114748 if ((mod & SHIFT) == SHIFT)
1426214749 {
1426314750 mouseMode = mouseMode; // VR??
....@@ -14266,6 +14753,8 @@
1426614753 mouseMode |= BACKFORTH;
1426714754 }
1426814755
14756
+ targetLookAt.set(manipCamera.lookAt);
14757
+
1426914758 //prevX = X = anchorX;
1427014759 prevY = Y = anchorY - (int) (renderCamera.Distance());
1427114760 }
....@@ -14273,12 +14762,19 @@
1427314762 void GoUp(int mod)
1427414763 {
1427514764 MODIFIERS |= COMMAND;
14276
- /*
14765
+ /**/
14766
+ boolean isVR = (mouseMode&VR)!=0;
14767
+
1427714768 if((mod&SHIFT) == SHIFT)
14278
- manipCamera.RotatePosition(0, speed);
14769
+ {
14770
+ if (isVR)
14771
+ manipCamera.RotateInterest(0, speed);
14772
+ else
14773
+ manipCamera.RotatePosition(0, speed);
14774
+ }
1427914775 else
14280
- manipCamera.BackForth(0, speed*delta, getWidth());
14281
- */
14776
+ manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth());
14777
+ /**/
1428214778 if ((mod & SHIFT) == SHIFT)
1428314779 {
1428414780 mouseMode = mouseMode;
....@@ -14287,6 +14783,8 @@
1428714783 mouseMode |= BACKFORTH;
1428814784 }
1428914785
14786
+ targetLookAt.set(manipCamera.lookAt);
14787
+
1429014788 //prevX = X = anchorX;
1429114789 prevY = Y = anchorY + (int) (renderCamera.Distance());
1429214790 }
....@@ -14294,12 +14792,17 @@
1429414792 void GoLeft(int mod)
1429514793 {
1429614794 MODIFIERS |= COMMAND;
14297
- /*
14795
+ /**/
1429814796 if((mod&SHIFT) == SHIFT)
14299
- manipCamera.RotatePosition(speed, 0);
14797
+ manipCamera.Translate(speed*delta, 0, getWidth());
1430014798 else
14301
- manipCamera.Translate(speed*delta, 0, getWidth());
14302
- */
14799
+ {
14800
+ if ((mouseMode&VR)!=0)
14801
+ manipCamera.RotateInterest(-speed, 0);
14802
+ else
14803
+ manipCamera.RotatePosition(speed, 0);
14804
+ }
14805
+ /**/
1430314806 if ((mod & SHIFT) == SHIFT)
1430414807 {
1430514808 mouseMode = mouseMode;
....@@ -14308,6 +14811,8 @@
1430814811 mouseMode |= ROTATE;
1430914812 } // TRANSLATE;
1431014813
14814
+ targetLookAt.set(manipCamera.lookAt);
14815
+
1431114816 prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance());
1431214817 prevY = Y = anchorY;
1431314818 }
....@@ -14315,12 +14820,18 @@
1431514820 void GoRight(int mod)
1431614821 {
1431714822 MODIFIERS |= COMMAND;
14318
- /*
14823
+ /**/
1431914824 if((mod&SHIFT) == SHIFT)
14320
- manipCamera.RotatePosition(-speed, 0);
14825
+ manipCamera.Translate(-speed*delta, 0, getWidth());
1432114826 else
14322
- manipCamera.Translate(-speed*delta, 0, getWidth());
14323
- */
14827
+ {
14828
+ if ((mouseMode&VR)!=0)
14829
+ manipCamera.RotateInterest(speed, 0);
14830
+ else
14831
+ manipCamera.RotatePosition(-speed, 0);
14832
+ }
14833
+
14834
+ /**/
1432414835 if ((mod & SHIFT) == SHIFT)
1432514836 {
1432614837 mouseMode = mouseMode;
....@@ -14329,6 +14840,8 @@
1432914840 mouseMode |= ROTATE;
1433014841 } // TRANSLATE;
1433114842
14843
+ targetLookAt.set(manipCamera.lookAt);
14844
+
1433214845 prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance());
1433314846 prevY = Y = anchorY;
1433414847 }
....@@ -14370,14 +14883,16 @@
1437014883 if (editObj)
1437114884 {
1437214885 drag = true;
14373
- ClickInfo info = new ClickInfo();
14374
- info.bounds.setBounds(0, 0,
14886
+ //ClickInfo info = new ClickInfo();
14887
+ object.clickInfo.bounds.setBounds(0, 0,
1437514888 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14376
- info.pane = this;
14377
- info.camera = renderCamera;
14378
- info.x = x;
14379
- info.y = y;
14380
- object.editWindow.copy.doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14889
+ object.clickInfo.pane = this;
14890
+ object.clickInfo.camera = renderCamera;
14891
+ object.clickInfo.x = x;
14892
+ object.clickInfo.y = y;
14893
+ object //.GetWindow().copy
14894
+ .doEditDrag(//info,
14895
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1438114896 } else
1438214897 {
1438314898 if (x < startX)
....@@ -14526,24 +15041,27 @@
1452615041 }
1452715042 }
1452815043
15044
+// ClickInfo clickInfo = new ClickInfo();
15045
+
1452915046 public void mouseMoved(MouseEvent e)
1453015047 {
1453115048 //System.out.println("mouseMoved: " + e);
1453215049 if (isRenderer)
1453315050 return;
1453415051
14535
- ClickInfo ci = new ClickInfo();
14536
- ci.x = e.getX();
14537
- ci.y = e.getY();
14538
- ci.modifiers = e.getModifiersEx();
14539
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14540
- ci.pane = this;
14541
- ci.camera = renderCamera;
15052
+ // Mouse cursor feedback
15053
+ object.clickInfo.x = e.getX();
15054
+ object.clickInfo.y = e.getY();
15055
+ object.clickInfo.modifiers = e.getModifiersEx();
15056
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
15057
+ object.clickInfo.pane = this;
15058
+ object.clickInfo.camera = renderCamera;
1454215059 if (!isRenderer)
1454315060 {
14544
- ObjEditor editWindow = object.editWindow;
14545
- Object3D copy = editWindow.copy;
14546
- if (copy.doEditClick(ci, 0))
15061
+ //ObjEditor editWindow = object.editWindow;
15062
+ //Object3D copy = editWindow.copy;
15063
+ if (object.doEditClick(//clickInfo,
15064
+ 0))
1454715065 {
1454815066 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1454915067 } else
....@@ -14558,7 +15076,8 @@
1455815076 Globals.MOUSEDRAGGED = false;
1455915077
1456015078 movingcamera = false;
14561
- X = Y = 0;
15079
+ X = 0; // getBounds().width/2;
15080
+ Y = 0; // getBounds().height/2;
1456215081 //System.out.println("mouseReleased: " + e);
1456315082 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1456415083 }
....@@ -14814,7 +15333,8 @@
1481415333 // break;
1481515334 case 'T':
1481615335 CACHETEXTURE ^= true;
14817
- textures.clear();
15336
+ texturepigment.clear();
15337
+ texturebump.clear();
1481815338 // repaint();
1481915339 break;
1482015340 case 'Y':
....@@ -14824,8 +15344,8 @@
1482415344 case 'K':
1482515345 KOMPACTTEXTURE ^= true;
1482615346 //textures.clear();
14827
- break;
14828
- case 'P': // Texture Projection macros
15347
+ // break;
15348
+ //case 'P': // Texture Projection macros
1482915349 // SAVETEXTURE ^= true;
1483015350 macromode = true;
1483115351 Udebug = Vdebug = NORMALdebug = false; programInitialized = false;
....@@ -14899,7 +15419,9 @@
1489915419 case 'E' : COMPACT ^= true;
1490015420 repaint();
1490115421 break;
14902
- case 'W' : DEBUGHSB ^= true;
15422
+ case 'W' : // Wide Window (fullscreen)
15423
+ //DEBUGHSB ^= true;
15424
+ ObjEditor.theFrame.ToggleFullScreen();
1490315425 repaint();
1490415426 break;
1490515427 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -14925,13 +15447,7 @@
1492515447 repaint();
1492615448 break;
1492715449 case 'l':
14928
- lightMode ^= true;
14929
- Globals.lighttouched = true;
14930
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
14931
- targetLookAt.set(manipCamera.lookAt);
14932
- repaint();
14933
- break;
14934
- case 'L':
15450
+ //case 'L':
1493515451 if (lightMode)
1493615452 {
1493715453 lightMode = false;
....@@ -14950,7 +15466,7 @@
1495015466 targetLookAt.set(manipCamera.lookAt);
1495115467 repaint();
1495215468 break;
14953
- case 'p':
15469
+ case 'P': // p':
1495415470 // c'est quoi ca au juste? spherical ^= true;
1495515471 Skinshader ^= true; programInitialized = false;
1495615472 repaint();
....@@ -14995,20 +15511,24 @@
1499515511 OCCLUSION_CULLING ^= true;
1499615512 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1499715513 break;
14998
- case '0': envyoff ^= true; repaint(); break;
15514
+ //case '0': envyoff ^= true; repaint(); break;
1499915515 case '1':
1500015516 case '2':
1500115517 case '3':
1500215518 case '4':
1500315519 case '5':
15004
- newenvy = Character.getNumericValue(key);
15005
- repaint();
15006
- break;
1500715520 case '6':
1500815521 case '7':
1500915522 case '8':
1501015523 case '9':
15011
- BGcolor = (key - '6')/3.f;
15524
+ if (true) // envyoff)
15525
+ {
15526
+ BGcolor = (key - '1')/8.f;
15527
+ }
15528
+ else
15529
+ {
15530
+ //newenvy = Character.getNumericValue(key);
15531
+ }
1501215532 repaint();
1501315533 break;
1501415534 case '!':
....@@ -15074,11 +15594,14 @@
1507415594 case '_':
1507515595 kompactbit = 5;
1507615596 break;
15077
- case '+':
15078
- kompactbit = 6;
15079
- break;
15597
+// case '+':
15598
+// kompactbit = 6;
15599
+// break;
1508015600 case ' ':
15081
- ObjEditor.theFrame.ToggleFullScreen();
15601
+ lightMode ^= true;
15602
+ Globals.lighttouched = true;
15603
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15604
+ targetLookAt.set(manipCamera.lookAt);
1508215605 repaint();
1508315606 break;
1508415607 //case '`' :
....@@ -15125,8 +15648,9 @@
1512515648 case DELETE:
1512615649 ClearSelection();
1512715650 break;
15128
- /*
1512915651 case '+':
15652
+
15653
+ /*
1513015654 //fontsize += 1;
1513115655 bbzoom *= 2;
1513215656 repaint();
....@@ -15143,17 +15667,17 @@
1514315667 case '=':
1514415668 IncDepth();
1514515669 //fontsize += 1;
15146
- object.editWindow.refreshContents(true);
15670
+ object.GetWindow().refreshContents(true);
1514715671 maskbit = 6;
1514815672 break;
1514915673 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1515015674 DecDepth();
1515115675 maskbit = 5;
1515215676 //if(fontsize > 1) fontsize -= 1;
15153
- if (object.editWindow == null)
15154
- new Exception().printStackTrace();
15155
- else
15156
- object.editWindow.refreshContents(true);
15677
+// if (object.editWindow == null)
15678
+// new Exception().printStackTrace();
15679
+// else
15680
+ object.GetWindow().refreshContents(true);
1515715681 break;
1515815682 case '{':
1515915683 manipCamera.shaper_fovy /= 1.1;
....@@ -15377,7 +15901,7 @@
1537715901 }
1537815902 */
1537915903
15380
- object.editWindow.EditSelection();
15904
+ object.GetWindow().EditSelection(false);
1538115905 }
1538215906
1538315907 void SelectParent()
....@@ -15394,10 +15918,10 @@
1539415918 {
1539515919 //selectees.remove(i);
1539615920 System.out.println("select parent of " + elem);
15397
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15921
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1539815922 } else
1539915923 {
15400
- group.editWindow.Select(elem.GetTreePath(), first, true);
15924
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1540115925 }
1540215926
1540315927 first = false;
....@@ -15439,12 +15963,12 @@
1543915963 for (int j = 0; j < group.children.size(); j++)
1544015964 {
1544115965 elem = (Object3D) group.children.elementAt(j);
15442
- object.editWindow.Select(elem.GetTreePath(), first, true);
15966
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1544315967 first = false;
1544415968 }
1544515969 } else
1544615970 {
15447
- object.editWindow.Select(elem.GetTreePath(), first, true);
15971
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1544815972 }
1544915973
1545015974 first = false;
....@@ -15455,21 +15979,21 @@
1545515979 {
1545615980 //Composite group = (Composite) object;
1545715981 Object3D group = object;
15458
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15982
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1545915983 }
1546015984
1546115985 void ResetTransform(int mask)
1546215986 {
1546315987 //Composite group = (Composite) object;
1546415988 Object3D group = object;
15465
- group.editWindow.ResetTransform(mask);
15989
+ group.GetWindow().ResetTransform(mask);
1546615990 }
1546715991
1546815992 void FlipTransform()
1546915993 {
1547015994 //Composite group = (Composite) object;
1547115995 Object3D group = object;
15472
- group.editWindow.FlipTransform();
15996
+ group.GetWindow().FlipTransform();
1547315997 // group.editWindow.ReduceMesh(true);
1547415998 }
1547515999
....@@ -15477,7 +16001,7 @@
1547716001 {
1547816002 //Composite group = (Composite) object;
1547916003 Object3D group = object;
15480
- group.editWindow.PrintMemory();
16004
+ group.GetWindow().PrintMemory();
1548116005 // group.editWindow.ReduceMesh(true);
1548216006 }
1548316007
....@@ -15485,7 +16009,7 @@
1548516009 {
1548616010 //Composite group = (Composite) object;
1548716011 Object3D group = object;
15488
- group.editWindow.ResetCentroid();
16012
+ group.GetWindow().ResetCentroid();
1548916013 }
1549016014
1549116015 void IncDepth()
....@@ -15567,8 +16091,6 @@
1556716091
1556816092 int width = getBounds().width;
1556916093 int height = getBounds().height;
15570
- ClickInfo info = new ClickInfo();
15571
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1557216094 //Image img = CreateImage(width, height);
1557316095 //System.out.println("width = " + width + "; height = " + height + "\n");
1557416096
....@@ -15645,48 +16167,77 @@
1564516167 }
1564616168 if (object != null && !hasMarquee)
1564716169 {
16170
+ if (object.clickInfo == null)
16171
+ object.clickInfo = new ClickInfo();
16172
+ ClickInfo info = object.clickInfo;
16173
+ //ClickInfo info = new ClickInfo();
16174
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16175
+
1564816176 if (isRenderer)
1564916177 {
15650
- info.flags++;
16178
+ object.clickInfo.flags++;
1565116179 double frameAspect = (double) width / (double) height;
1565216180 if (frameAspect > renderCamera.aspect)
1565316181 {
1565416182 int desired = (int) ((double) height * renderCamera.aspect);
15655
- info.bounds.width -= width - desired;
15656
- info.bounds.x += (width - desired) / 2;
16183
+ object.clickInfo.bounds.width -= width - desired;
16184
+ object.clickInfo.bounds.x += (width - desired) / 2;
1565716185 } else
1565816186 {
1565916187 int desired = (int) ((double) width / renderCamera.aspect);
15660
- info.bounds.height -= height - desired;
15661
- info.bounds.y += (height - desired) / 2;
16188
+ object.clickInfo.bounds.height -= height - desired;
16189
+ object.clickInfo.bounds.y += (height - desired) / 2;
1566216190 }
1566316191 }
15664
- info.g = gr;
15665
- info.camera = renderCamera;
16192
+
16193
+ object.clickInfo.g = gr;
16194
+ object.clickInfo.camera = renderCamera;
1566616195 /*
1566716196 // Memory intensive (brep.verticescopy)
1566816197 if (!(object instanceof Composite))
1566916198 object.draw(info, 0, false); // SLOW :
1567016199 */
15671
- if (!isRenderer)
16200
+ if (!isRenderer) // && drag)
1567216201 {
15673
- object.drawEditHandles(info, 0);
15674
-
15675
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
16202
+ Grafreed.Assert(object != null);
16203
+ Grafreed.Assert(object.selection != null);
16204
+ if (object.selection.Size() > 0)
1567616205 {
15677
- switch (object.selection.get(0).hitSomething)
16206
+ int hitSomething = object.selection.get(0).hitSomething;
16207
+
16208
+ object.clickInfo.DX = 0;
16209
+ object.clickInfo.DY = 0;
16210
+ object.clickInfo.W = 1;
16211
+ if (hitSomething == Object3D.hitCenter)
1567816212 {
15679
- case Object3D.hitCenter: gr.setColor(Color.pink);
15680
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15681
- break;
15682
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15683
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15684
- break;
15685
- case Object3D.hitScale: gr.setColor(Color.cyan);
15686
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15687
- break;
16213
+ info.DX = X;
16214
+ if (X != 0)
16215
+ info.DX -= info.bounds.width/2;
16216
+
16217
+ info.DY = Y;
16218
+ if (Y != 0)
16219
+ info.DY -= info.bounds.height/2;
1568816220 }
15689
-
16221
+
16222
+ object.drawEditHandles(//info,
16223
+ 0);
16224
+
16225
+ if (drag && (X != 0 || Y != 0))
16226
+ {
16227
+ switch (hitSomething)
16228
+ {
16229
+ case Object3D.hitCenter: gr.setColor(Color.white);
16230
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16231
+ break;
16232
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16233
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16234
+ break;
16235
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16236
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16237
+ break;
16238
+ }
16239
+
16240
+ }
1569016241 }
1569116242 }
1569216243 }
....@@ -15701,7 +16252,7 @@
1570116252 if (hasMarquee)
1570216253 {
1570316254 gr.setXORMode(Color.white);
15704
- gr.setColor(Color.red);
16255
+ gr.setColor(Color.white);
1570516256 if (!firstime)
1570616257 {
1570716258 gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH);
....@@ -16168,6 +16719,8 @@
1616816719 private /*static*/ boolean firstime;
1616916720 private /*static*/ cVector newView = new cVector();
1617016721 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16722
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16723
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1617116724 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1617216725 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1617316726 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16180,29 +16733,67 @@
1618016733 {
1618116734 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1618216735
16736
+ int usedsuf = 0;
16737
+
1618316738 for (int i = 0; i < suffixes.length; i++)
1618416739 {
16185
- String resourceName = basename + suffixes[i] + "." + suffix;
16186
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16187
- mipmapped,
16188
- FileUtil.getFileSuffix(resourceName));
16189
- if (data == null)
16740
+ String[] suffixe = suffixes;
16741
+ String[] fallback = suffixes2;
16742
+ String[] fallfallback = suffixes3;
16743
+
16744
+ for (int c=usedsuf; --c>=0;)
1619016745 {
16191
- throw new IOException("Unable to load texture " + resourceName);
16746
+// String[] temp = suffixe;
16747
+// suffixe = fallback;
16748
+// fallback = fallfallback;
16749
+// fallfallback = temp;
1619216750 }
16751
+
16752
+ String resourceName = basename + suffixe[i] + "." + suffix;
16753
+ TextureData data;
16754
+
16755
+ try
16756
+ {
16757
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16758
+ mipmapped,
16759
+ FileUtil.getFileSuffix(resourceName));
16760
+ }
16761
+ catch (Exception e)
16762
+ {
16763
+ try
16764
+ {
16765
+ resourceName = basename + fallback[i] + "." + suffix;
16766
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16767
+ mipmapped,
16768
+ FileUtil.getFileSuffix(resourceName));
16769
+ }
16770
+ catch (Exception e2)
16771
+ {
16772
+ resourceName = basename + fallfallback[i] + "." + suffix;
16773
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16774
+ mipmapped,
16775
+ FileUtil.getFileSuffix(resourceName));
16776
+ }
16777
+ }
16778
+
1619316779 //System.out.println("Target = " + targets[i]);
1619416780 cubemap.updateImage(data, targets[i]);
1619516781 }
1619616782
1619716783 return cubemap;
1619816784 }
16785
+
1619916786 int bigsphere = -1;
1620016787
1620116788 float BGcolor = 0.5f;
1620216789
16203
- private void DrawSkyBox(GL gl)
16790
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16791
+
16792
+ private void DrawSkyBox(GL gl, float ratio)
1620416793 {
16205
- if (envyoff || cubemap == null)
16794
+ if (//envyoff ||
16795
+ WIREFRAME ||
16796
+ cubemap == null)
1620616797 {
1620716798 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1620816799 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16217,7 +16808,17 @@
1621716808 // Compensates for ExaminerViewer's modification of modelview matrix
1621816809 gl.glMatrixMode(GL.GL_MODELVIEW);
1621916810 gl.glLoadIdentity();
16811
+ gl.glScalef(1,ratio,1);
1622016812
16813
+// colorV[0] = 2;
16814
+// colorV[1] = 2;
16815
+// colorV[2] = 2;
16816
+// colorV[3] = 1;
16817
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16818
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16819
+//
16820
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16821
+
1622116822 //gl.glActiveTexture(GL.GL_TEXTURE1);
1622216823 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1622316824
....@@ -16249,6 +16850,7 @@
1624916850 {
1625016851 gl.glScalef(1.0f, -1.0f, 1.0f);
1625116852 }
16853
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1625216854 gl.glMultMatrixd(viewrot_1, 0);
1625316855 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1625416856 //viewer.updateInverseRotation(gl);
....@@ -16289,7 +16891,8 @@
1628916891 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1629016892
1629116893 cubemap.disable();
16292
- ////cubemap.unbind();
16894
+ //cubemap.dispose();
16895
+
1629316896 if (CULLFACE)
1629416897 {
1629516898 gl.glEnable(gl.GL_CULL_FACE);
....@@ -16345,7 +16948,7 @@
1634516948 gl.glScalef(1.0f, -1.0f, 1.0f);
1634616949 }
1634716950
16348
- gl.glNormal3f(0.0f, 0.0f, 1.0f);
16951
+ SetGLNormal(gl, 0.0f, 0.0f, 1.0f);
1634916952
1635016953 float step = 2; // 0.1666f; //0.25f;
1635116954 float stepv = 2; // step * 1652 / 998;
....@@ -16484,6 +17087,14 @@
1648417087 }
1648517088 }
1648617089
17090
+ private Object3D GetFolder()
17091
+ {
17092
+ Object3D folder = object.GetWindow().copy;
17093
+ if (object.GetWindow().copy.selection.Size() > 0)
17094
+ folder = object.GetWindow().copy.selection.elementAt(0);
17095
+ return folder;
17096
+ }
17097
+
1648717098 class SelectBuffer implements GLEventListener
1648817099 {
1648917100
....@@ -16499,7 +17110,7 @@
1649917110 //new Exception().printStackTrace();
1650017111 System.out.println("select buffer init");
1650117112 // Use debug pipeline
16502
- drawable.setGL(new DebugGL(drawable.getGL()));
17113
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1650317114
1650417115 GL gl = drawable.getGL();
1650517116
....@@ -16563,6 +17174,17 @@
1656317174
1656417175 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1656517176
17177
+ if (PAINTMODE)
17178
+ {
17179
+ if (object.GetWindow().copy.selection.Size() > 0)
17180
+ {
17181
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17182
+
17183
+ // Make what you paint not selectable.
17184
+ paintobj.ResetSelectable();
17185
+ }
17186
+ }
17187
+
1656617188 //int tmp = selection_view;
1656717189 //selection_view = -1;
1656817190 int temp = DrawMode();
....@@ -16574,6 +17196,17 @@
1657417196 // temp = DEFAULT; // patch for selection debug
1657517197 Globals.drawMode = temp; // WARNING
1657617198
17199
+ if (PAINTMODE)
17200
+ {
17201
+ if (object.GetWindow().copy.selection.Size() > 0)
17202
+ {
17203
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17204
+
17205
+ // Revert.
17206
+ paintobj.RestoreSelectable();
17207
+ }
17208
+ }
17209
+
1657717210 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1657817211
1657917212 // trying different ways of getting the depth info over
....@@ -16621,6 +17254,8 @@
1662117254 // System.err.println("view = " + view[4] + " " + view[5] + " " + view[6] + " " + view[7]);
1662217255 // System.err.println("view = " + view[8] + " " + view[9] + " " + view[10] + " " + view[11]);
1662317256 // System.err.println("view = " + view[12] + " " + view[13] + " " + view[14] + " " + view[15]);
17257
+
17258
+ CreateSelectedPoint();
1662417259
1662517260 // Will fit the mesh !!!
1662617261 selectedpoint.toParent[0][0] = 0.0001;
....@@ -16675,29 +17310,31 @@
1667517310 }
1667617311
1667717312 if (!movingcamera && !PAINTMODE)
16678
- object.editWindow.ScreenFitPoint(); // fev 2014
17313
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1667917314
16680
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17315
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1668117316 {
16682
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17317
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1668317318
16684
- Object3D group = new Object3D("inst" + paintcount++);
17319
+ if (object.GetWindow().copy.selection.Size() > 0)
17320
+ {
17321
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1668517322
16686
- group.CreateMaterial(); // use a void leaf to select instances
16687
-
16688
- group.add(paintobj); // link
16689
-
16690
- object.editWindow.SnapObject(group);
16691
-
16692
- Object3D folder = object.editWindow.copy;
16693
-
16694
- if (object.editWindow.copy.selection.Size() > 0)
16695
- folder = object.editWindow.copy.selection.elementAt(0);
16696
-
16697
- folder.add(group);
16698
-
16699
- object.editWindow.ResetModel();
16700
- object.editWindow.refreshContents();
17323
+ Object3D inst = new Object3D("inst" + paintcount++);
17324
+
17325
+ inst.CreateMaterial(); // use a void leaf to select instances
17326
+
17327
+ inst.add(paintobj); // link
17328
+
17329
+ object.GetWindow().SnapObject(inst);
17330
+
17331
+ Object3D folder = paintFolder; // GetFolder();
17332
+
17333
+ folder.add(inst);
17334
+
17335
+ object.GetWindow().ResetModel();
17336
+ object.GetWindow().refreshContents();
17337
+ }
1670117338 }
1670217339 else
1670317340 paintcount = 0;
....@@ -16736,6 +17373,11 @@
1673617373 //System.out.println("objects[color] = " + objects[color]);
1673717374 //objects[color].Select();
1673817375 indexcount = 0;
17376
+ ObjEditor window = object.GetWindow();
17377
+ if (window != null && deselect)
17378
+ {
17379
+ window.Select(null, deselect, true);
17380
+ }
1673917381 object.Select(color, deselect);
1674017382 }
1674117383
....@@ -16786,6 +17428,7 @@
1678617428
1678717429 public void init(GLAutoDrawable drawable)
1678817430 {
17431
+ if (Globals.DEBUG)
1678917432 System.out.println("shadow buffer init");
1679017433
1679117434 GL gl = drawable.getGL();
....@@ -17014,10 +17657,14 @@
1701417657 gl.glFlush();
1701517658
1701617659 /**/
17017
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17660
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1701817661
17019
- float[] pixels = occlusionsizebuffer.array();
17662
+ float[] depths = occlusiondepthbuffer.array();
1702017663
17664
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17665
+
17666
+ int[] pixels = selectsizebuffer.array();
17667
+
1702117668 double r = 0, g = 0, b = 0;
1702217669
1702317670 double count = 0;
....@@ -17028,7 +17675,7 @@
1702817675
1702917676 double FACTOR = 1;
1703017677
17031
- for (int i = 0; i < pixels.length; i++)
17678
+ for (int i = 0; i < depths.length; i++)
1703217679 {
1703317680 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1703417681 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17111,7 +17758,7 @@
1711117758
1711217759 double scale = ray.z; // 1; // cos
1711317760
17114
- float depth = pixels[newindex];
17761
+ float depth = depths[newindex];
1711517762
1711617763 /*
1711717764 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17308,11 +17955,14 @@
1730817955 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1730917956 static IntBuffer bigAAbuffer;
1731017957 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17311
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17958
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1731217959 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1731317960 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1731417961 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17315
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17962
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17963
+
17964
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17965
+
1731617966 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1731717967 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1731817968 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();