Normand Briere
2019-08-13 c67de8aca04d988179191ccb52461af00125920e
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,9 @@
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;
77116 boolean reverseUP = false;
78117 static boolean frozen = false;
79118 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -136,7 +175,7 @@
136175 static boolean doublesided = false; // true; // reversed normals are awful for conformance
137176 boolean anisotropy = true;
138177 boolean softshadow = true; // slower but better false;
139
- boolean opacityhalo = false;
178
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
140179
141180 boolean macromode = false;
142181
....@@ -150,6 +189,19 @@
150189 }
151190
152191 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
192
+
193
+ public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException
194
+ {
195
+ try
196
+ {
197
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
198
+ } catch (IOException e)
199
+ {
200
+ System.out.println("NAME = " + name);
201
+ e.printStackTrace(); // throw new RuntimeException(e);
202
+ return null;
203
+ }
204
+ }
153205
154206 void SetAsGLRenderer(boolean b)
155207 {
....@@ -169,7 +221,8 @@
169221
170222 SetCamera(cam);
171223
172
- SetLight(new Camera(new cVector(10, 10, -20)));
224
+ // Warning: not used.
225
+ SetLight(new Camera(new cVector(15, 10, -20)));
173226
174227 object = o;
175228
....@@ -1447,6 +1500,8 @@
14471500 gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z);
14481501 }
14491502
1503
+ float[] colorV = new float[4];
1504
+
14501505 void SetColor(Object3D obj, Vertex p0)
14511506 {
14521507 CameraPane display = this;
....@@ -1514,8 +1569,6 @@
15141569 {
15151570 return;
15161571 }
1517
-
1518
- float[] colorV = new float[3];
15191572
15201573 if (false) // marked)
15211574 {
....@@ -2065,7 +2118,7 @@
20652118 //System.err.println("Oeil on");
20662119 OEIL = true;
20672120 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
2068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
2121
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
20692122 //pingthread.StepToTarget(true);
20702123 }
20712124
....@@ -2298,10 +2351,17 @@
22982351 HANDLES ^= true;
22992352 }
23002353
2354
+ Object3D paintFolder;
2355
+
23012356 void TogglePaint()
23022357 {
23032358 PAINTMODE ^= true;
23042359 paintcount = 0;
2360
+
2361
+ if (PAINTMODE)
2362
+ {
2363
+ paintFolder = GetFolder();
2364
+ }
23052365 }
23062366
23072367 void SwapCamera(int a, int b)
....@@ -2398,126 +2458,19 @@
23982458 return currentGL;
23992459 }
24002460
2401
- private void GetRemoteZip(String url, String name, boolean unzip, boolean save)
2461
+ static private BufferedImage CreateBim(TextureData texturedata)
24022462 {
2403
- java.net.URL u;
2404
- InputStream is = null;
2405
- DataInputStream dis;
2406
- java.util.zip.ZipInputStream zis;
2407
- //String s;
2408
-
2409
- System.out.println("GetRemoteZip " + name);
2410
-
2411
- int total = 0; // dis.available();
2412
-
2413
- byte[] bytes = new byte[16384];
2414
-
2415
- try
2416
- {
2417
- u = new java.net.URL(url + name);
2418
- is = u.openStream();
2419
-
2420
- System.out.println(url + name);
2421
-
2422
- if (unzip)
2423
- {
2424
- //dis = new DataInputStream(new BufferedInputStream(is));
2425
- zis = new java.util.zip.ZipInputStream(new BufferedInputStream(is));
2426
- //while ((s = dis.readLine()) != null)
2427
-
2428
- if (save)
2429
- new java.io.File(name).mkdirs();
2430
-
2431
- // FileOutputStream stream = new FileOutputStream("test.zip");
2432
- //
2433
- // int count;
2434
- //
2435
- // while ((count = dis.read(bytes)) != -1)
2436
- // {
2437
- // //System.out.println(s);
2438
- // System.out.println(count);
2439
- // total += count;
2440
- // stream.write(bytes);
2441
- // }
2442
- //
2443
- // stream.close();
2444
-
2445
- // now iterate through each item in the stream. The get next
2446
- // entry call will return a ZipEntry for each file in the
2447
- // stream
2448
- java.util.zip.ZipEntry entry;
2449
- while((entry = zis.getNextEntry())!=null)
2450
- {
2451
- if (entry.getName().endsWith(".gsm"))
2452
- {
2453
- continue;
2454
- }
2455
-
2456
- String s = String.format("Entry: %s len %d added %TD",
2457
- entry.getName(), entry.getSize(),
2458
- new java.util.Date(entry.getTime()));
2459
- System.out.println(s);
2460
-
2461
- if (save)
2462
- {
2463
- // Once we get the entry from the stream, the stream is
2464
- // positioned read to read the raw data, and we keep
2465
- // reading until read returns 0 or less.
2466
- String outpath = name + "/" + entry.getName();
2467
- FileOutputStream output = null;
2468
- try
2469
- {
2470
- output = new FileOutputStream(outpath);
2471
- int len = 0;
2472
- while ((len = zis.read(bytes)) > 0)
2473
- {
2474
- output.write(bytes, 0, len);
2475
- }
2476
- }
2477
- finally
2478
- {
2479
- // we must always close the output file
2480
- if(output!=null) output.close();
2481
- }
2482
- }
2483
- }
2484
- }
2485
- }
2486
- catch (java.net.MalformedURLException mue)
2487
- {
2488
- System.err.println("Ouch - a MalformedURLException happened.");
2489
- mue.printStackTrace();
2490
- //System.exit(2);
2491
- }
2492
- catch (IOException ioe)
2493
- {
2494
- //System.err.println("Oops - an IOException happened.");
2495
- //ioe.printStackTrace();
2496
- //System.exit(3);
2497
- }
2498
- finally
2499
- {
2500
- try
2501
- {
2502
- if (is != null)
2503
- is.close();
2504
- }
2505
- catch (IOException ioe)
2506
- {
2507
- }
2508
- }
2509
-
2510
- // System.out.println("length = " + total);
2511
-
2512
-// try
2513
-// {
2514
-// Runtime.getRuntime().exec("/usr/local/bin/wget https://archive3d.net/?a=download&do=get&id=7caca905");
2515
-// }
2516
-// catch (Exception e)
2517
-// {
2518
-// e.printStackTrace();
2519
-// }
2520
-
2463
+ Grafreed.Assert(texturedata != null);
2464
+
2465
+ int width = texturedata.getWidth();
2466
+ int height = texturedata.getHeight();
2467
+
2468
+ Buffer buffer = texturedata.getBuffer();
2469
+ ByteBuffer bytebuf = (ByteBuffer)buffer;
2470
+
2471
+ byte[] bytes = bytebuf.array();
2472
+
2473
+ return CreateBim(bytes, width, height);
25212474 }
25222475
25232476 /**/
....@@ -2528,28 +2481,31 @@
25282481
25292482 int resolution;
25302483
2531
- CacheTexture(com.sun.opengl.util.texture.Texture tex, int res)
2484
+ CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res)
25322485 {
2533
- texture = tex;
2486
+ texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata);
2487
+ texturedata = texdata;
25342488 resolution = res;
25352489 }
25362490 }
25372491 /**/
25382492
25392493 // TEXTURE static Texture texture;
2540
- static public java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/> textures
2541
- = new java.util.Hashtable<String, CacheTexture/*com.sun.opengl.util.texture.Texture*/>();
2542
- static public java.util.Hashtable<String, String> usedtextures = new java.util.Hashtable<String, String>();
2494
+ static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>();
2495
+ static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>();
2496
+ static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>();
2497
+ static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>();
2498
+
25432499 int pigmentdepth = 0;
25442500 public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536];
25452501 int bumpdepth = 0;
25462502 public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536];
25472503 //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE";
25482504 public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP");
2549
- public static String NOISE_TEXTURE = "WHITE_NOISE";
2505
+ public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:");
25502506 // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL");
25512507
2552
- com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump)
2508
+ com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump)
25532509 {
25542510 TextureData texturedata = null;
25552511
....@@ -2568,13 +2524,34 @@
25682524 if (bump)
25692525 texturedata = ConvertBump(texturedata, false);
25702526
2571
- com.sun.opengl.util.texture.Texture texture =
2572
- com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
2527
+// com.sun.opengl.util.texture.Texture texture =
2528
+// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata);
25732529
2574
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2575
- texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
2530
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT);
2531
+ //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT);
25762532
2577
- return texture;
2533
+ return texturedata;
2534
+ }
2535
+
2536
+ com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump)
2537
+ {
2538
+ TextureData texturedata = null;
2539
+
2540
+ try
2541
+ {
2542
+ texturedata =
2543
+ com.sun.opengl.util.texture.TextureIO.newTextureData(
2544
+ bim,
2545
+ true);
2546
+ } catch (Exception e)
2547
+ {
2548
+ throw new javax.media.opengl.GLException(e);
2549
+ }
2550
+
2551
+ if (bump)
2552
+ texturedata = ConvertBump(texturedata, false);
2553
+
2554
+ return texturedata;
25782555 }
25792556
25802557 boolean HUESMOOTH = true; // wrap around bug... true;
....@@ -3647,6 +3624,8 @@
36473624
36483625 System.out.println("LOADING TEXTURE : " + name);
36493626
3627
+ Object x = texturedata.getMipmapData(); // .getBuffer();
3628
+
36503629 //
36513630 if (false) // compressbit > 0)
36523631 {
....@@ -8045,7 +8024,7 @@
80458024 String pigment = Object3D.GetPigment(tex);
80468025 String bump = Object3D.GetBump(tex);
80478026
8048
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8027
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80498028 {
80508029 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80518030 // System.out.println("; bump = " + bump);
....@@ -8060,8 +8039,8 @@
80608039 pigment = null;
80618040 }
80628041
8063
- ReleaseTexture(bump, true);
8064
- ReleaseTexture(pigment, false);
8042
+ ReleaseTexture(tex, true);
8043
+ ReleaseTexture(tex, false);
80658044 }
80668045
80678046 public void ReleasePigmentTexture(cTexture tex) // INTERFACE
....@@ -8079,7 +8058,7 @@
80798058
80808059 String pigment = Object3D.GetPigment(tex);
80818060
8082
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8061
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
80838062 {
80848063 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
80858064 // System.out.println("; bump = " + bump);
....@@ -8090,7 +8069,7 @@
80908069 pigment = null;
80918070 }
80928071
8093
- ReleaseTexture(pigment, false);
8072
+ ReleaseTexture(tex, false);
80948073 }
80958074
80968075 public void ReleaseBumpTexture(cTexture tex) // INTERFACE
....@@ -8108,7 +8087,7 @@
81088087
81098088 String bump = Object3D.GetBump(tex);
81108089
8111
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8090
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
81128091 {
81138092 // System.out.print("RELEASE +++++++++++++++ pigment = " + pigment);
81148093 // System.out.println("; bump = " + bump);
....@@ -8119,10 +8098,10 @@
81198098 bump = null;
81208099 }
81218100
8122
- ReleaseTexture(bump, true);
8101
+ ReleaseTexture(tex, true);
81238102 }
81248103
8125
- void ReleaseTexture(String tex, boolean bump)
8104
+ void ReleaseTexture(cTexture tex, boolean bump)
81268105 {
81278106 if (// DrawMode() != 0 || /*tex == null ||*/
81288107 ambientOcclusion ) // || !textureon)
....@@ -8133,7 +8112,7 @@
81338112 CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
81348113
81358114 if (tex != null)
8136
- texture = textures.get(tex);
8115
+ texture = bump ? texturebump.get(tex) : texturepigment.get(tex);
81378116
81388117 // //assert( texture != null );
81398118 // if (texture == null)
....@@ -8227,47 +8206,50 @@
82278206
82288207 /*boolean*/ public void BindTextures(cTexture tex, int resolution) throws Exception // INTERFACE
82298208 {
8230
- if (// DrawMode() != 0 || /*tex == null ||*/
8231
- ambientOcclusion ) // || !textureon)
8232
- {
8233
- return; // false;
8234
- }
8235
-
8236
- if (tex == null)
8237
- {
8238
- BindTexture(null,false,resolution);
8239
- BindTexture(null,true,resolution);
8240
- return;
8241
- }
8209
+// if (// DrawMode() != 0 || /*tex == null ||*/
8210
+// ambientOcclusion ) // || !textureon)
8211
+// {
8212
+// return; // false;
8213
+// }
8214
+//
8215
+// if (tex == null)
8216
+// {
8217
+// BindTexture(null,false,resolution);
8218
+// BindTexture(null,true,resolution);
8219
+// return;
8220
+// }
8221
+//
8222
+// String pigment = Object3D.GetPigment(tex);
8223
+// String bump = Object3D.GetBump(tex);
8224
+//
8225
+// usedtextures.add(pigment);
8226
+// usedtextures.add(bump);
8227
+//
8228
+// //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8229
+// {
8230
+// // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8231
+// // System.out.println("; bump = " + bump);
8232
+// }
8233
+//
8234
+// if (bump.equals(""))
8235
+// {
8236
+// bump = null;
8237
+// }
8238
+// if (pigment.equals(""))
8239
+// {
8240
+// pigment = null;
8241
+// }
8242
+//
8243
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8244
+// BindTexture(pigment, false, resolution);
8245
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8246
+// BindTexture(bump, true, resolution);
8247
+// GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8248
+//
8249
+// return; // true;
82428250
8243
- String pigment = Object3D.GetPigment(tex);
8244
- String bump = Object3D.GetBump(tex);
8245
-
8246
- usedtextures.put(pigment, pigment);
8247
- usedtextures.put(bump, bump);
8248
-
8249
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8250
- {
8251
- // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
8252
- // System.out.println("; bump = " + bump);
8253
- }
8254
-
8255
- if (bump.equals(""))
8256
- {
8257
- bump = null;
8258
- }
8259
- if (pigment.equals(""))
8260
- {
8261
- pigment = null;
8262
- }
8263
-
8264
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8265
- BindTexture(pigment, false, resolution);
8266
- GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8267
- BindTexture(bump, true, resolution);
8268
- GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8269
-
8270
- return; // true;
8251
+ BindPigmentTexture(tex, resolution);
8252
+ BindBumpTexture(tex, resolution);
82718253 }
82728254
82738255 /*boolean*/ public void BindPigmentTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8286,9 +8268,9 @@
82868268
82878269 String pigment = Object3D.GetPigment(tex);
82888270
8289
- usedtextures.put(pigment, pigment);
8271
+ usedtextures.add(tex);
82908272
8291
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8273
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
82928274 {
82938275 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
82948276 // System.out.println("; bump = " + bump);
....@@ -8300,7 +8282,7 @@
83008282 }
83018283
83028284 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
8303
- BindTexture(pigment, false, resolution);
8285
+ BindTexture(tex, false, resolution);
83048286 }
83058287
83068288 /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE
....@@ -8319,9 +8301,9 @@
83198301
83208302 String bump = Object3D.GetBump(tex);
83218303
8322
- usedtextures.put(bump, bump);
8304
+ usedtextures.add(tex);
83238305
8324
- if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
8306
+ //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES))
83258307 {
83268308 // System.out.print("BIND +++++++++++++++ pigment = " + pigment);
83278309 // System.out.println("; bump = " + bump);
....@@ -8333,7 +8315,7 @@
83338315 }
83348316
83358317 GetGL().glActiveTexture(GetGL().GL_TEXTURE2);
8336
- BindTexture(bump, true, resolution);
8318
+ BindTexture(tex, true, resolution);
83378319 GetGL().glActiveTexture(GetGL().GL_TEXTURE0);
83388320 }
83398321
....@@ -8357,13 +8339,19 @@
83578339 return fileExists;
83588340 }
83598341
8360
- CacheTexture GetCacheTexture(String tex, boolean bump, int resolution) throws Exception
8342
+ CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception
83618343 {
8362
- CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null;
8344
+ CacheTexture texturecache = null;
83638345
83648346 if (tex != null)
83658347 {
8366
- String texname = tex;
8348
+ String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex);
8349
+ byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata;
8350
+
8351
+ if (texname.equals("") && texdata == null)
8352
+ {
8353
+ return null;
8354
+ }
83678355
83688356 String fallbackTextureName = defaultDirectory + "/Textures/" + texname;
83698357
....@@ -8373,19 +8361,46 @@
83738361 // else
83748362 // if (!texname.startsWith("/"))
83758363 // texname = "/Users/nbriere/Textures/" + texname;
8376
- if (!FileExists(tex))
8364
+ if (!FileExists(texname) && !texname.startsWith("@"))
83778365 {
83788366 texname = fallbackTextureName;
83798367 }
83808368
83818369 if (CACHETEXTURE)
8382
- texture = textures.get(texname); // TEXTURE CACHE
8383
-
8384
- TextureData texturedata = null;
8385
-
8386
- if (texture == null || texture.resolution < resolution)
83878370 {
8388
- if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
8371
+ if (texdata == null)
8372
+ texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex);
8373
+ else
8374
+ texturecache = bimtextures.get(texdata);
8375
+ }
8376
+
8377
+ if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution)
8378
+ {
8379
+ TextureData texturedata = null;
8380
+
8381
+ if (texdata != null && textureon)
8382
+ {
8383
+ BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8384
+
8385
+ try
8386
+ {
8387
+ bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8388
+ }
8389
+ catch (Exception e)
8390
+ {
8391
+ bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph);
8392
+ }
8393
+
8394
+ texturecache = new CacheTexture(GetBimTexture(bim, bump), -1);
8395
+ bimtextures.put(texdata, texturecache);
8396
+
8397
+ //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB);
8398
+
8399
+ //Object bim2 = CreateBim(texturecache.texturedata);
8400
+ //bim2 = bim;
8401
+ }
8402
+ else
8403
+ if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals(""))
83898404 {
83908405 assert(!bump);
83918406 // if (bump)
....@@ -8396,19 +8411,23 @@
83968411 // }
83978412 // else
83988413 // {
8399
- texture = textures.get(tex);
8400
- if (texture == null)
8414
+ // texturecache = textures.get(texname); // suspicious
8415
+ if (texturecache == null)
84018416 {
8402
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8417
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
84038418 }
8419
+ else
8420
+ new Exception().printStackTrace();
84048421 // }
84058422 } else
8406
- if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
8423
+ if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals(""))
84078424 {
84088425 assert(bump);
8409
- texture = textures.get(tex);
8410
- if (texture == null)
8411
- texture = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8426
+ // texturecache = textures.get(texname); // suspicious
8427
+ if (texturecache == null)
8428
+ texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution);
8429
+ else
8430
+ new Exception().printStackTrace();
84128431 } else
84138432 {
84148433 //if (tex.equals("IMMORTAL"))
....@@ -8416,11 +8435,22 @@
84168435 // texture = GetResourceTexture("default.png");
84178436 //} else
84188437 //{
8419
- if (tex.equals("WHITE_NOISE"))
8438
+ if (texname.endsWith("WHITE_NOISE"))
84208439 {
8421
- texture = textures.get(tex);
8422
- if (texture == null)
8423
- texture = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8440
+ // texturecache = textures.get(texname); // suspicious
8441
+ if (texturecache == null)
8442
+ texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution);
8443
+ else
8444
+ new Exception().printStackTrace();
8445
+ } else
8446
+ {
8447
+ if (texname.startsWith("@"))
8448
+ {
8449
+ // texturecache = textures.get(texname); // suspicious
8450
+ if (texturecache == null)
8451
+ texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution);
8452
+ else
8453
+ new Exception().printStackTrace();
84248454 } else
84258455 {
84268456 if (textureon)
....@@ -8479,19 +8509,20 @@
84798509 if (texturedata == null)
84808510 throw new Exception();
84818511
8482
- texture = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution);
8512
+ texturecache = new CacheTexture(texturedata,resolution);
84838513 //texture = GetTexture(tex, bump);
84848514 }
8515
+ }
84858516 }
84868517 //}
84878518 }
84888519
8489
- if (/*CACHETEXTURE &&*/ texture != null && textureon)
8520
+ if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon)
84908521 {
84918522 //return false;
84928523
84938524 // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")");
8494
- if (texturedata != null && (texname.endsWith(".jpg") || texname.endsWith(".JPG")))
8525
+ if (texturedata != null && texname.toLowerCase().endsWith(".jpg"))
84958526 {
84968527 // String ext = "_highres";
84978528 // if (REDUCETEXTURE)
....@@ -8508,52 +8539,17 @@
85088539 File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg");
85098540 if (!cachefile.exists())
85108541 {
8511
- // cache to disk
8512
- Buffer buffer = texturedata.getBuffer(); // getMipmapData();
8513
- //buffers[0].
8514
-
8515
- ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer();
8516
- int[] pixels = new int[bytebuf.capacity()/3];
8517
-
8518
- // squared size heuristic...
8519
- if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length))
8542
+ //if (texturedata.getWidth() == texturedata.getHeight())
85208543 {
8521
- for (int i=pixels.length; --i>=0;)
8522
- {
8523
- int i3 = i*3;
8524
- pixels[i] = 0xFF;
8525
- pixels[i] <<= 8;
8526
- pixels[i] |= bytebuf.get(i3+2) & 0xFF;
8527
- pixels[i] <<= 8;
8528
- pixels[i] |= bytebuf.get(i3+1) & 0xFF;
8529
- pixels[i] <<= 8;
8530
- pixels[i] |= bytebuf.get(i3) & 0xFF;
8531
- }
8532
-
8533
- /*
8534
- int r=0,g=0,b=0,a=0;
8535
- for (int i=0; i<width; i++)
8536
- for (int j=0; j<height; j++)
8537
- {
8538
- int index = j*width+i;
8539
- int p = pixels[index];
8540
- a = ((p>>24) & 0xFF);
8541
- r = ((p>>16) & 0xFF);
8542
- g = ((p>>8) & 0xFF);
8543
- b = (p & 0xFF);
8544
- pixels[index] = (a<<24) | (b<<16) | (g<<8) | r;
8545
- }
8546
- /**/
8547
- int width = (int)Math.sqrt(pixels.length); // squared
8548
- int height = width;
8549
- BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile);
8550
- rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width);
8544
+ BufferedImage rendImage = CreateBim(texturedata);
8545
+
85518546 ImageWriter writer = null;
85528547 Iterator iter = ImageIO.getImageWritersByFormatName("jpg");
85538548 if (iter.hasNext()) {
85548549 writer = (ImageWriter)iter.next();
85558550 }
8556
- float compressionQuality = 0.9f;
8551
+
8552
+ float compressionQuality = 0.85f;
85578553 try
85588554 {
85598555 ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile);
....@@ -8570,18 +8566,20 @@
85708566 }
85718567 }
85728568 }
8573
-
8569
+
8570
+ Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment;
8571
+
85748572 //System.out.println("Texture = " + tex);
8575
- if (textures.containsKey(texname))
8573
+ if (textures.containsKey(tex))
85768574 {
8577
- CacheTexture thetex = textures.get(texname);
8575
+ CacheTexture thetex = textures.get(tex);
85788576 thetex.texture.disable();
85798577 thetex.texture.dispose();
8580
- textures.remove(texname);
8578
+ textures.remove(tex);
85818579 }
85828580
8583
- texture.texturedata = texturedata;
8584
- textures.put(texname, texture);
8581
+ //texture.texturedata = texturedata;
8582
+ textures.put(tex, texturecache);
85858583
85868584 // newtex = true;
85878585 }
....@@ -8597,10 +8595,44 @@
85978595 }
85988596 }
85998597
8600
- return texture;
8598
+ return texturecache;
86018599 }
86028600
8603
- com.sun.opengl.util.texture.Texture GetTexture(String tex, boolean bump, int resolution) throws Exception
8601
+ static void EmbedTextures(cTexture tex)
8602
+ {
8603
+ if (tex.pigmentdata == null)
8604
+ {
8605
+ //String texname = Object3D.GetPigment(tex);
8606
+
8607
+ CacheTexture texturecache = texturepigment.get(tex);
8608
+
8609
+ if (texturecache != null)
8610
+ {
8611
+ tex.pw = texturecache.texturedata.getWidth();
8612
+ tex.ph = texturecache.texturedata.getHeight();
8613
+ tex.pigmentdata = //CompressJPEG(CreateBim
8614
+ ((ByteBuffer)texturecache.texturedata.getBuffer()).array()
8615
+ ;
8616
+ //, tex.pw, tex.ph), 0.5f);
8617
+ }
8618
+ }
8619
+
8620
+ if (tex.bumpdata == null)
8621
+ {
8622
+ //String texname = Object3D.GetBump(tex);
8623
+
8624
+ CacheTexture texturecache = texturebump.get(tex);
8625
+
8626
+ if (texturecache != null)
8627
+ {
8628
+ tex.bw = texturecache.texturedata.getWidth();
8629
+ tex.bh = texturecache.texturedata.getHeight();
8630
+ tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f);
8631
+ }
8632
+ }
8633
+ }
8634
+
8635
+ com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception
86048636 {
86058637 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86068638
....@@ -8618,21 +8650,21 @@
86188650 return texture!=null?texture.texture:null;
86198651 }
86208652
8621
- public com.sun.opengl.util.texture.TextureData GetTextureData(String tex, boolean bump, int resolution) throws Exception
8653
+ public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception
86228654 {
86238655 CacheTexture texture = GetCacheTexture(tex, bump, resolution);
86248656
86258657 return texture!=null?texture.texturedata:null;
86268658 }
86278659
8628
- boolean BindTexture(String tex, boolean bump, int resolution) throws Exception
8660
+ boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception
86298661 {
86308662 if (/*tex == null ||*/ ambientOcclusion ) // || !textureon)
86318663 {
86328664 return false;
86338665 }
86348666
8635
- boolean newtex = false;
8667
+ //boolean newtex = false;
86368668
86378669 com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution);
86388670
....@@ -8664,9 +8696,75 @@
86648696 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_S, GetGL().GL_REPEAT);
86658697 texture.setTexParameteri(GetGL().GL_TEXTURE_WRAP_T, GetGL().GL_REPEAT);
86668698
8667
- return newtex;
8699
+ return true; // Warning: not used.
86688700 }
86698701
8702
+ public static byte[] CompressJPEG(BufferedImage image, float quality)
8703
+ {
8704
+ try
8705
+ {
8706
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();
8707
+ Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg");
8708
+ ImageWriter writer = writers.next();
8709
+
8710
+ ImageWriteParam param = writer.getDefaultWriteParam();
8711
+ param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT);
8712
+ param.setCompressionQuality(quality);
8713
+
8714
+ ImageOutputStream ios = ImageIO.createImageOutputStream(baos);
8715
+ writer.setOutput(ios);
8716
+ writer.write(null, new IIOImage(image, null, null), param);
8717
+
8718
+ byte[] data = baos.toByteArray();
8719
+ writer.dispose();
8720
+ return data;
8721
+ }
8722
+ catch (Exception e)
8723
+ {
8724
+ e.printStackTrace();
8725
+ return null;
8726
+ }
8727
+ }
8728
+
8729
+ public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException
8730
+ {
8731
+ ByteArrayInputStream baos = new ByteArrayInputStream(image);
8732
+ Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg");
8733
+ ImageReader reader = writers.next();
8734
+
8735
+ BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB);
8736
+
8737
+ ImageReadParam param = reader.getDefaultReadParam();
8738
+ param.setDestination(bim);
8739
+ //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB));
8740
+
8741
+ ImageInputStream ios = ImageIO.createImageInputStream(baos);
8742
+ reader.setInput(ios);
8743
+ BufferedImage bim2 = reader.read(0, param);
8744
+ reader.dispose();
8745
+
8746
+// WritableRaster raster = bim2.getRaster();
8747
+// DataBufferByte data = (DataBufferByte) raster.getDataBuffer();
8748
+// byte[] bytes = data.getData();
8749
+//
8750
+// int[] pixels = new int[bytes.length/3];
8751
+// for (int i=pixels.length; --i>=0;)
8752
+// {
8753
+// int i3 = i*3;
8754
+// pixels[i] = 0xFF;
8755
+// pixels[i] <<= 8;
8756
+// pixels[i] |= bytes[i3+2] & 0xFF;
8757
+// pixels[i] <<= 8;
8758
+// pixels[i] |= bytes[i3+1] & 0xFF;
8759
+// pixels[i] <<= 8;
8760
+// pixels[i] |= bytes[i3] & 0xFF;
8761
+// }
8762
+//
8763
+// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w);
8764
+
8765
+ return bim;
8766
+ }
8767
+
86708768 ShadowBuffer shadowPBuf;
86718769 AntialiasBuffer antialiasPBuf;
86728770 int MAXSTACK;
....@@ -8683,10 +8781,12 @@
86838781
86848782 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
86858783 MAXSTACK = temp[0];
8686
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8784
+ if (Globals.DEBUG)
8785
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
86878786 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
86888787 MAXSTACK = temp[0];
8689
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8788
+ if (Globals.DEBUG)
8789
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
86908790
86918791 // Use debug pipeline
86928792 //drawable.setGL(new DebugGL(gl)); //
....@@ -8694,7 +8794,8 @@
86948794 gl = drawable.getGL(); //
86958795
86968796 GL gl3 = getGL();
8697
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8797
+ if (Globals.DEBUG)
8798
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
86988799
86998800
87008801 //float pos[] = { 100, 100, 100, 0 };
....@@ -8859,7 +8960,7 @@
88598960
88608961 if (cubemap == null)
88618962 {
8862
- LoadEnvy(5);
8963
+ //LoadEnvy(1);
88638964 }
88648965
88658966 //cubemap.enable();
....@@ -9135,6 +9236,8 @@
91359236
91369237 void LoadEnvy(int which)
91379238 {
9239
+ assert(false);
9240
+
91389241 String name;
91399242 String ext;
91409243
....@@ -9146,37 +9249,58 @@
91469249 cubemap = null;
91479250 return;
91489251 case 1:
9149
- name = "cubemaps/box_";
9150
- ext = "png";
9252
+ name = "cubemaps/rgb/";
9253
+ ext = "jpg";
91519254 reverseUP = false;
91529255 break;
91539256 case 2:
9154
- name = "cubemaps/uffizi_";
9155
- ext = "png";
9156
- break; // reverseUP = true; break;
9257
+ name = "cubemaps/uffizi/";
9258
+ ext = "jpg";
9259
+ reverseUP = false;
9260
+ break;
91579261 case 3:
9158
- name = "cubemaps/CloudyHills_";
9159
- ext = "tga";
9262
+ name = "cubemaps/CloudyHills/";
9263
+ ext = "jpg";
91609264 reverseUP = false;
91619265 break;
91629266 case 4:
9163
- name = "cubemaps/cornell_";
9267
+ name = "cubemaps/cornell/";
91649268 ext = "png";
91659269 reverseUP = false;
91669270 break;
9271
+ case 5:
9272
+ name = "cubemaps/skycube/";
9273
+ ext = "jpg";
9274
+ reverseUP = false;
9275
+ break;
9276
+ case 6:
9277
+ name = "cubemaps/SaintLazarusChurch3/";
9278
+ ext = "jpg";
9279
+ reverseUP = false;
9280
+ break;
9281
+ case 7:
9282
+ name = "cubemaps/Sodermalmsallen/";
9283
+ ext = "jpg";
9284
+ reverseUP = false;
9285
+ break;
9286
+ case 8:
9287
+ name = "cubemaps/Sodermalmsallen2/";
9288
+ ext = "jpg";
9289
+ reverseUP = false;
9290
+ break;
9291
+ case 9:
9292
+ name = "cubemaps/UnionSquare/";
9293
+ ext = "jpg";
9294
+ reverseUP = false;
9295
+ break;
91679296 default:
9168
- name = "cubemaps/rgb_";
9169
- ext = "png"; /*mipmap = true;*/ reverseUP = false;
9297
+ name = "cubemaps/box/";
9298
+ ext = "png"; /*mipmap = true;*/
9299
+ reverseUP = false;
91709300 break;
91719301 }
9172
-
9173
- try
9174
- {
9175
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
9176
- } catch (IOException e)
9177
- {
9178
- throw new RuntimeException(e);
9179
- }
9302
+
9303
+ LoadSkybox(name, ext, mipmap);
91809304 }
91819305
91829306 public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height)
....@@ -9208,8 +9332,12 @@
92089332 static double[] model = new double[16];
92099333 double[] camera2light = new double[16];
92109334 double[] light2camera = new double[16];
9211
- int newenvy = -1;
9212
- boolean envyoff = true; // false;
9335
+
9336
+ //int newenvy = -1;
9337
+ //boolean envyoff = false;
9338
+
9339
+ String loadedskyboxname;
9340
+
92139341 cVector light0 = new cVector(0, 0, 0); // 1,3,2);
92149342 //float[] light0 = { 0,0,0 };
92159343 cVector dirlight = new cVector(0, 0, 1); // 1,3,2);
....@@ -9627,7 +9755,7 @@
96279755
96289756 if (renderCamera != lightCamera)
96299757 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9630
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
9758
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
96319759
96329760 // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix);
96339761
....@@ -9643,7 +9771,7 @@
96439771
96449772 if (renderCamera != lightCamera)
96459773 //for (int count = parentcam.GetTransformCount(); --count>=0;)
9646
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
9774
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
96479775
96489776 // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix);
96499777
....@@ -9689,10 +9817,12 @@
96899817 rati = 1 / rati;
96909818 gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000);
96919819 }
9692
- assert (newenvy == -1);
9820
+
9821
+ //assert (newenvy == -1);
9822
+
96939823 gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
96949824 gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
9695
- DrawSkyBox(gl);
9825
+ DrawSkyBox(gl, (float)rati);
96969826 gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
96979827 gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB);
96989828 accPerspective(gl, renderCamera.shaper_fovy / ratio,
....@@ -10729,7 +10859,7 @@
1072910859
1073010860 if (wait)
1073110861 {
10732
- Sleep(500);
10862
+ Sleep(200); // blocks everything
1073310863
1073410864 wait = false;
1073510865 }
....@@ -10844,7 +10974,7 @@
1084410974 // if (parentcam != renderCamera) // not a light
1084510975 if (cam != lightCamera)
1084610976 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10847
- LA.matConcat(matrix, parentcam.GlobalTransform(), matrix);
10977
+ LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix);
1084810978
1084910979 for (int j = 0; j < 4; j++)
1085010980 {
....@@ -10859,7 +10989,7 @@
1085910989 // if (parentcam != renderCamera) // not a light
1086010990 if (cam != lightCamera)
1086110991 //for (int count = parentcam.GetTransformCount(); --count>=0;)
10862
- LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix);
10992
+ LA.matConcat(parentcam.GlobalTransform(), matrix, matrix);
1086310993
1086410994 //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix);
1086510995
....@@ -10945,13 +11075,41 @@
1094511075 gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000);
1094611076 }
1094711077
10948
- if (newenvy > -1)
11078
+// if (newenvy > -1)
11079
+// {
11080
+// LoadEnvy(newenvy);
11081
+// }
11082
+//
11083
+// newenvy = -1;
11084
+
11085
+ if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1094911086 {
10950
- LoadEnvy(newenvy);
11087
+ if (cubemaprgb == null)
11088
+ {
11089
+ cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11090
+ }
11091
+
11092
+ cubemap = cubemaprgb;
1095111093 }
10952
-
10953
- newenvy = -1;
10954
-
11094
+ else
11095
+ {
11096
+ if (object.skyboxname != null)
11097
+ {
11098
+ if (!object.skyboxname.equals(this.loadedskyboxname))
11099
+ {
11100
+ cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11101
+ loadedskyboxname = object.skyboxname;
11102
+ }
11103
+ }
11104
+ else
11105
+ {
11106
+ cubemapcustom = null;
11107
+ loadedskyboxname = null;
11108
+ }
11109
+
11110
+ cubemap = cubemapcustom;
11111
+ }
11112
+
1095511113 ratio = ((double) getWidth()) / getHeight();
1095611114 //System.out.println("ratio = " + ratio);
1095711115
....@@ -10967,7 +11125,7 @@
1096711125
1096811126 if (!IsFrozen() && !ambientOcclusion)
1096911127 {
10970
- DrawSkyBox(gl);
11128
+ DrawSkyBox(gl, (float)ratio);
1097111129 }
1097211130
1097311131 //if (selection_view == -1)
....@@ -11150,9 +11308,9 @@
1115011308
1115111309 gl.glMatrixMode(GL.GL_MODELVIEW);
1115211310
11153
-//gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11154
-//gl.glEnable(gl.GL_POLYGON_SMOOTH);
11155
-//gl.glEnable(gl.GL_MULTISAMPLE);
11311
+gl.glEnable(gl.GL_POLYGON_SMOOTH);
11312
+gl.glHint(gl.GL_POLYGON_SMOOTH_HINT, gl.GL_NICEST);
11313
+gl.glEnable(gl.GL_MULTISAMPLE);
1115611314 } else
1115711315 {
1115811316 //gl.glDisable(GL.GL_TEXTURE_2D);
....@@ -11163,7 +11321,7 @@
1116311321 //System.out.println("BLENDING ON");
1116411322 gl.glEnable(GL.GL_BLEND);
1116511323 gl.glBlendFunc(GL.GL_SRC_ALPHA, GL.GL_ONE_MINUS_SRC_ALPHA);
11166
-
11324
+// gl.glBlendFunc(GL.GL_SRC_ALPHA_SATURATE, GL.GL_ONE);
1116711325 gl.glMatrixMode(gl.GL_PROJECTION);
1116811326 gl.glLoadIdentity();
1116911327
....@@ -11253,7 +11411,7 @@
1125311411
1125411412 // if (cam != lightCamera)
1125511413 //for (int count = parentcam.GetTransformCount(); --count>=0;)
11256
- LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013
11414
+ LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013
1125711415 }
1125811416
1125911417 LA.xformDir(lightposition, cam.toScreen, lightposition);
....@@ -11412,7 +11570,7 @@
1141211570 }
1141311571 }
1141411572
11415
- if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
11573
+ if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion)
1141611574 {
1141711575 //gl.glDepthFunc(GL.GL_LEQUAL);
1141811576 //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT);
....@@ -11420,24 +11578,21 @@
1142011578
1142111579 boolean texon = textureon;
1142211580
11423
- if (RENDERPROGRAM > 0)
11424
- {
11425
- gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11426
- textureon = false;
11427
- }
11581
+ gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB);
11582
+ textureon = false;
11583
+
1142811584 //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB);
1142911585 //System.out.println("ALLO");
1143011586 gl.glColorMask(false, false, false, false);
1143111587 DrawObject(gl);
11432
- if (RENDERPROGRAM > 0)
11433
- {
11434
- gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11435
- textureon = texon;
11436
- }
11588
+
11589
+ gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB);
11590
+ textureon = texon;
11591
+
1143711592 gl.glColorMask(true, true, true, true);
1143811593
1143911594 gl.glDepthFunc(GL.GL_EQUAL);
11440
- //gl.glDepthMask(false);
11595
+ gl.glDepthMask(false);
1144111596 }
1144211597
1144311598 if (false) // DrawMode() == SHADOW)
....@@ -11649,7 +11804,7 @@
1164911804 if ((TRACK || SHADOWTRACK) || zoomonce)
1165011805 {
1165111806 if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode)
11652
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
11807
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1165311808 pingthread.StepToTarget(true); // true);
1165411809 // zoomonce = false;
1165511810 }
....@@ -11777,20 +11932,32 @@
1177711932 ReleaseTextures(DEFAULT_TEXTURES);
1177811933
1177911934 if (CLEANCACHE)
11780
- for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();)
11935
+ for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();)
1178111936 {
11782
- String tex = e.nextElement();
11937
+ cTexture tex = e.nextElement();
1178311938
1178411939 // System.out.println("Texture --------- " + tex);
1178511940
11786
- if (tex.equals("WHITE_NOISE"))
11941
+ if (tex.equals("WHITE_NOISE:"))
1178711942 continue;
1178811943
11789
- if (!usedtextures.containsKey(tex))
11944
+ if (!usedtextures.contains(tex))
1179011945 {
11946
+ CacheTexture gettex = texturepigment.get(tex);
1179111947 // System.out.println("DISPOSE +++++++++++++++ " + tex);
11792
- textures.get(tex).texture.dispose();
11793
- textures.remove(tex);
11948
+ if (gettex != null)
11949
+ {
11950
+ gettex.texture.dispose();
11951
+ texturepigment.remove(tex);
11952
+ }
11953
+
11954
+ gettex = texturebump.get(tex);
11955
+ // System.out.println("DISPOSE +++++++++++++++ " + tex);
11956
+ if (gettex != null)
11957
+ {
11958
+ gettex.texture.dispose();
11959
+ texturebump.remove(tex);
11960
+ }
1179411961 }
1179511962 }
1179611963 }
....@@ -12318,8 +12485,76 @@
1231812485
1231912486 //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0);
1232012487
12321
- String program =
12488
+ String programmin =
12489
+ // Min shader
1232212490 "!!ARBfp1.0\n" +
12491
+ "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" +
12492
+ "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" +
12493
+ "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" +
12494
+ "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" +
12495
+ "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" +
12496
+ "PARAM light2cam0 = program.env[10];" +
12497
+ "PARAM light2cam1 = program.env[11];" +
12498
+ "PARAM light2cam2 = program.env[12];" +
12499
+ "TEMP temp;" +
12500
+ "TEMP light;" +
12501
+ "TEMP ndotl;" +
12502
+ "TEMP normal;" +
12503
+ "TEMP depth;" +
12504
+ "TEMP eye;" +
12505
+ "TEMP pos;" +
12506
+
12507
+ "MAD normal, fragment.color, zero123.z, -zero123.y;" +
12508
+ Normalize("normal") +
12509
+ "MOV light, state.light[0].position;" +
12510
+ "DP3 ndotl.x, light, normal;" +
12511
+
12512
+ // shadow
12513
+ "MOV pos, fragment.texcoord[1];" +
12514
+ "MOV temp, pos;" +
12515
+ ShadowTextureFetch("depth", "temp", "1") +
12516
+ //"TEX depth, fragment.texcoord[1], texture[1], 2D;" +
12517
+ "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" +
12518
+
12519
+ // No shadow when out of frustum
12520
+ //"SGE temp.y, depth.z, zero123.y;" +
12521
+ //"LRP temp.x, temp.y, zero123.y, temp.x;" +
12522
+
12523
+ "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow
12524
+
12525
+ // Backlit
12526
+ "MOV pos.w, zero123.y;" +
12527
+ "DP4 eye.x, pos, light2cam0;" +
12528
+ "DP4 eye.y, pos, light2cam1;" +
12529
+ "DP4 eye.z, pos, light2cam2;" +
12530
+ Normalize("eye") +
12531
+
12532
+ "DP3 ndotl.y, -eye, normal;" +
12533
+ //"MUL ndotl.y, ndotl.y, pow2.x;" +
12534
+ "POW ndotl.y, ndotl.y, pow2.z;" + // backlit
12535
+ "SUB ndotl.y, zero123.y, ndotl.y;" +
12536
+ //"SUB ndotl.y, zero123.y, ndotl.y;" +
12537
+ //"MUL ndotl.y, ndotl.y, pow2.z;" +
12538
+
12539
+ //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient
12540
+ //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient
12541
+
12542
+ // Pigment
12543
+ "TEX temp, fragment.texcoord[0], texture[0], 2D;" +
12544
+ "LRP temp, zero123.w, temp, one;" + // texture proportion
12545
+ "MUL temp, temp, ndotl.x;" +
12546
+
12547
+ "MUL temp, temp, zero123.z;" +
12548
+
12549
+ //"MUL temp, temp, ndotl.y;" +
12550
+
12551
+ "MOV temp.w, zero123.y;" + // reset alpha
12552
+ "MOV result.color, temp;" +
12553
+ "END";
12554
+
12555
+ String programmax =
12556
+ "!!ARBfp1.0\n" +
12557
+
1232312558 //"OPTION ARB_fragment_program_shadow;" +
1232412559 "PARAM light2cam0 = program.env[10];" +
1232512560 "PARAM light2cam1 = program.env[11];" +
....@@ -12434,8 +12669,7 @@
1243412669 "TEMP shininess;" +
1243512670 "\n" +
1243612671 "MOV texSamp, one;" +
12437
- //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" +
12438
-
12672
+
1243912673 "MOV mapgrid.x, one2048th.x;" +
1244012674 "MOV temp, fragment.texcoord[1];" +
1244112675 /*
....@@ -12456,20 +12690,20 @@
1245612690 "MUL temp, floor, mapgrid.x;" +
1245712691 //"TEX depth0, temp, texture[1], 2D;" +
1245812692 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12459
- TextureFetch("depth0", "temp", "1") +
12693
+ ShadowTextureFetch("depth0", "temp", "1") +
1246012694 "") +
1246112695 "ADD temp.x, temp.x, mapgrid.x;" +
1246212696 //"TEX depth1, temp, texture[1], 2D;" +
1246312697 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12464
- TextureFetch("depth1", "temp", "1") +
12698
+ ShadowTextureFetch("depth1", "temp", "1") +
1246512699 "") +
1246612700 "ADD temp.y, temp.y, mapgrid.x;" +
1246712701 //"TEX depth2, temp, texture[1], 2D;" +
12468
- TextureFetch("depth2", "temp", "1") +
12702
+ ShadowTextureFetch("depth2", "temp", "1") +
1246912703 "SUB temp.x, temp.x, mapgrid.x;" +
1247012704 //"TEX depth3, temp, texture[1], 2D;" +
1247112705 (((mode & FP_SOFTSHADOW) == 0) ? "" :
12472
- TextureFetch("depth3", "temp", "1") +
12706
+ ShadowTextureFetch("depth3", "temp", "1") +
1247312707 "") +
1247412708 //"MUL texSamp0, texSamp0, state.material.front.diffuse;" +
1247512709 //"MOV params, material;" +
....@@ -12840,10 +13074,10 @@
1284013074 "MAD shadow.x, buffer.x, frac.y, shadow.x;" +
1284113075 "") +
1284213076
12843
- // display shadow only (bump == 0)
13077
+ // display shadow only (fakedepth == 0)
1284413078 "SUB temp.x, half.x, shadow.x;" +
1284513079 "MOV temp.y, -params5.z;" + // params6.x;" +
12846
- "SLT temp.z, temp.y, -one2048th.x;" +
13080
+ "SLT temp.z, temp.y, -c256i.x;" +
1284713081 "SUB temp.y, one.x, temp.z;" +
1284813082 "MUL temp.x, temp.x, temp.y;" +
1284913083 "KIL temp.x;" +
....@@ -13174,6 +13408,13 @@
1317413408 //once = true;
1317513409 }
1317613410
13411
+ String program = programmax;
13412
+
13413
+ if (Globals.MINSHADER)
13414
+ {
13415
+ program = programmin;
13416
+ }
13417
+
1317713418 System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length());
1317813419 System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : ""));
1317913420 loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program);
....@@ -13267,25 +13508,26 @@
1326713508 return out;
1326813509 }
1326913510
13270
- String TextureFetch(String dest, String src, String unit)
13511
+ // Also does frustum culling
13512
+ String ShadowTextureFetch(String dest, String src, String unit)
1327113513 {
1327213514 return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" +
1327313515 "SGE " + src + ".w, " + src + ".x, eps.x;" +
1327413516 "SGE " + src + ".z, " + src + ".y, eps.x;" +
13517
+ "SLT " + dest + ".x, " + src + ".x, one.x;" +
13518
+ "SLT " + dest + ".y, " + src + ".y, one.x;" +
1327513519 "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13276
- "SLT " + src + ".z, " + src + ".x, one.x;" +
13277
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13278
- "SLT " + src + ".z, " + src + ".y, one.x;" +
13279
- "MUL " + src + ".w, " + src + ".z, " + src + ".w;" +
13520
+ "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" +
13521
+ "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" +
1328013522 //"SWZ buffer, temp, w,w,w,w;";
13281
- "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
13523
+ //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" +
1328213524 "SUB " + src + ".z, " + "one.x, " + src + ".w;" +
1328313525 //"MUL " + src + ".z, " + src + ".z, infinity.x;" +
1328413526 //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;";
13285
- "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
13527
+ //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1328613528
13287
- //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13288
- //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;";
13529
+ //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;";
13530
+ "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;";
1328913531 }
1329013532
1329113533 String Shadow(String depth, String shadow)
....@@ -13332,7 +13574,7 @@
1333213574 "SLT temp.x, temp.x, zero.x;" + // shadoweps
1333313575 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333413576
13335
- // No shadow when out of frustrum
13577
+ // No shadow when out of frustum
1333613578 "SGE temp.x, " + depth + ".z, one.z;" +
1333713579 "LRP " + shadow + ", temp.x, one, " + shadow + ";" +
1333813580 "";
....@@ -14065,7 +14307,7 @@
1406514307
1406614308 // fev 2014???
1406714309 if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode)
14068
- object.editWindow.ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
14310
+ object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK);
1406914311 pingthread.StepToTarget(true); // true);
1407014312 }
1407114313 // if (!LIVE)
....@@ -14130,14 +14372,15 @@
1413014372 drag = false;
1413114373 //System.out.println("Mouse DOWN");
1413214374 editObj = false;
14133
- ClickInfo info = new ClickInfo();
14134
- info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14135
- info.pane = this;
14136
- info.camera = renderCamera;
14137
- info.x = x;
14138
- info.y = y;
14139
- info.modifiers = modifiersex;
14140
- editObj = object.doEditClick(info, 0);
14375
+ //ClickInfo info = new ClickInfo();
14376
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14377
+ object.clickInfo.pane = this;
14378
+ object.clickInfo.camera = renderCamera;
14379
+ object.clickInfo.x = x;
14380
+ object.clickInfo.y = y;
14381
+ object.clickInfo.modifiers = modifiersex;
14382
+ editObj = object.doEditClick(//info,
14383
+ 0);
1414114384 if (!editObj)
1414214385 {
1414314386 hasMarquee = true;
....@@ -14419,12 +14662,12 @@
1441914662 void GoDown(int mod)
1442014663 {
1442114664 MODIFIERS |= COMMAND;
14422
- /*
14665
+ /**/
1442314666 if((mod&SHIFT) == SHIFT)
14424
- manipCamera.RotatePosition(0, -speed);
14667
+ manipCamera.BackForth(0, -speed*delta, 0); // getWidth());
1442514668 else
14426
- manipCamera.BackForth(0, -speed*delta, getWidth());
14427
- */
14669
+ manipCamera.RotatePosition(0, -speed);
14670
+ /**/
1442814671 if ((mod & SHIFT) == SHIFT)
1442914672 {
1443014673 mouseMode = mouseMode; // VR??
....@@ -14440,12 +14683,12 @@
1444014683 void GoUp(int mod)
1444114684 {
1444214685 MODIFIERS |= COMMAND;
14443
- /*
14686
+ /**/
1444414687 if((mod&SHIFT) == SHIFT)
14445
- manipCamera.RotatePosition(0, speed);
14688
+ manipCamera.BackForth(0, speed*delta, 0); // getWidth());
1444614689 else
14447
- manipCamera.BackForth(0, speed*delta, getWidth());
14448
- */
14690
+ manipCamera.RotatePosition(0, speed);
14691
+ /**/
1444914692 if ((mod & SHIFT) == SHIFT)
1445014693 {
1445114694 mouseMode = mouseMode;
....@@ -14461,12 +14704,12 @@
1446114704 void GoLeft(int mod)
1446214705 {
1446314706 MODIFIERS |= COMMAND;
14464
- /*
14707
+ /**/
1446514708 if((mod&SHIFT) == SHIFT)
14466
- manipCamera.RotatePosition(speed, 0);
14467
- else
1446814709 manipCamera.Translate(speed*delta, 0, getWidth());
14469
- */
14710
+ else
14711
+ manipCamera.RotatePosition(speed, 0);
14712
+ /**/
1447014713 if ((mod & SHIFT) == SHIFT)
1447114714 {
1447214715 mouseMode = mouseMode;
....@@ -14482,12 +14725,12 @@
1448214725 void GoRight(int mod)
1448314726 {
1448414727 MODIFIERS |= COMMAND;
14485
- /*
14728
+ /**/
1448614729 if((mod&SHIFT) == SHIFT)
14487
- manipCamera.RotatePosition(-speed, 0);
14488
- else
1448914730 manipCamera.Translate(-speed*delta, 0, getWidth());
14490
- */
14731
+ else
14732
+ manipCamera.RotatePosition(-speed, 0);
14733
+ /**/
1449114734 if ((mod & SHIFT) == SHIFT)
1449214735 {
1449314736 mouseMode = mouseMode;
....@@ -14537,15 +14780,16 @@
1453714780 if (editObj)
1453814781 {
1453914782 drag = true;
14540
- ClickInfo info = new ClickInfo();
14541
- info.bounds.setBounds(0, 0,
14783
+ //ClickInfo info = new ClickInfo();
14784
+ object.clickInfo.bounds.setBounds(0, 0,
1454214785 (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14543
- info.pane = this;
14544
- info.camera = renderCamera;
14545
- info.x = x;
14546
- info.y = y;
14547
- object.GetWindow().copy
14548
- .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0);
14786
+ object.clickInfo.pane = this;
14787
+ object.clickInfo.camera = renderCamera;
14788
+ object.clickInfo.x = x;
14789
+ object.clickInfo.y = y;
14790
+ object //.GetWindow().copy
14791
+ .doEditDrag(//info,
14792
+ (modifiers & MouseEvent.BUTTON3_MASK) != 0);
1454914793 } else
1455014794 {
1455114795 if (x < startX)
....@@ -14694,24 +14938,27 @@
1469414938 }
1469514939 }
1469614940
14941
+// ClickInfo clickInfo = new ClickInfo();
14942
+
1469714943 public void mouseMoved(MouseEvent e)
1469814944 {
1469914945 //System.out.println("mouseMoved: " + e);
1470014946 if (isRenderer)
1470114947 return;
1470214948
14703
- ClickInfo ci = new ClickInfo();
14704
- ci.x = e.getX();
14705
- ci.y = e.getY();
14706
- ci.modifiers = e.getModifiersEx();
14707
- ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14708
- ci.pane = this;
14709
- ci.camera = renderCamera;
14949
+ // Mouse cursor feedback
14950
+ object.clickInfo.x = e.getX();
14951
+ object.clickInfo.y = e.getY();
14952
+ object.clickInfo.modifiers = e.getModifiersEx();
14953
+ object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom));
14954
+ object.clickInfo.pane = this;
14955
+ object.clickInfo.camera = renderCamera;
1471014956 if (!isRenderer)
1471114957 {
1471214958 //ObjEditor editWindow = object.editWindow;
1471314959 //Object3D copy = editWindow.copy;
14714
- if (object.doEditClick(ci, 0))
14960
+ if (object.doEditClick(//clickInfo,
14961
+ 0))
1471514962 {
1471614963 setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR));
1471714964 } else
....@@ -14726,7 +14973,8 @@
1472614973 Globals.MOUSEDRAGGED = false;
1472714974
1472814975 movingcamera = false;
14729
- X = Y = 0;
14976
+ X = 0; // getBounds().width/2;
14977
+ Y = 0; // getBounds().height/2;
1473014978 //System.out.println("mouseReleased: " + e);
1473114979 clickEnd(e.getX(), e.getY(), e.getModifiersEx());
1473214980 }
....@@ -14982,7 +15230,8 @@
1498215230 // break;
1498315231 case 'T':
1498415232 CACHETEXTURE ^= true;
14985
- textures.clear();
15233
+ texturepigment.clear();
15234
+ texturebump.clear();
1498615235 // repaint();
1498715236 break;
1498815237 case 'Y':
....@@ -15067,7 +15316,9 @@
1506715316 case 'E' : COMPACT ^= true;
1506815317 repaint();
1506915318 break;
15070
- case 'W' : DEBUGHSB ^= true;
15319
+ case 'W' : // Wide Window (fullscreen)
15320
+ //DEBUGHSB ^= true;
15321
+ ObjEditor.theFrame.ToggleFullScreen();
1507115322 repaint();
1507215323 break;
1507315324 case 'u' : Udebug ^= true; Vdebug = false; NORMALdebug = false; programInitialized = false; repaint(); break;
....@@ -15093,13 +15344,7 @@
1509315344 repaint();
1509415345 break;
1509515346 case 'l':
15096
- lightMode ^= true;
15097
- Globals.lighttouched = true;
15098
- manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15099
- targetLookAt.set(manipCamera.lookAt);
15100
- repaint();
15101
- break;
15102
- case 'L':
15347
+ //case 'L':
1510315348 if (lightMode)
1510415349 {
1510515350 lightMode = false;
....@@ -15163,20 +15408,24 @@
1516315408 OCCLUSION_CULLING ^= true;
1516415409 System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING);
1516515410 break;
15166
- case '0': envyoff ^= true; repaint(); break;
15411
+ //case '0': envyoff ^= true; repaint(); break;
1516715412 case '1':
1516815413 case '2':
1516915414 case '3':
1517015415 case '4':
1517115416 case '5':
15172
- newenvy = Character.getNumericValue(key);
15173
- repaint();
15174
- break;
1517515417 case '6':
1517615418 case '7':
1517715419 case '8':
1517815420 case '9':
15179
- BGcolor = (key - '6')/3.f;
15421
+ if (true) // envyoff)
15422
+ {
15423
+ BGcolor = (key - '1')/8.f;
15424
+ }
15425
+ else
15426
+ {
15427
+ //newenvy = Character.getNumericValue(key);
15428
+ }
1518015429 repaint();
1518115430 break;
1518215431 case '!':
....@@ -15246,7 +15495,10 @@
1524615495 // kompactbit = 6;
1524715496 // break;
1524815497 case ' ':
15249
- ObjEditor.theFrame.ToggleFullScreen();
15498
+ lightMode ^= true;
15499
+ Globals.lighttouched = true;
15500
+ manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera;
15501
+ targetLookAt.set(manipCamera.lookAt);
1525015502 repaint();
1525115503 break;
1525215504 //case '`' :
....@@ -15295,12 +15547,6 @@
1529515547 break;
1529615548 case '+':
1529715549
15298
- //for (int i=0; i<0x7FFFFFFF; i++)
15299
- {
15300
- //String.format("%08X", i); // "7caca905"
15301
- GetRemoteZip("https://archive3d.net/?a=download&do=get&id=", "7caca905", true, true);
15302
- }
15303
-
1530415550 /*
1530515551 //fontsize += 1;
1530615552 bbzoom *= 2;
....@@ -15318,17 +15564,17 @@
1531815564 case '=':
1531915565 IncDepth();
1532015566 //fontsize += 1;
15321
- object.editWindow.refreshContents(true);
15567
+ object.GetWindow().refreshContents(true);
1532215568 maskbit = 6;
1532315569 break;
1532415570 case '-': //if (PixelThreshold>1) PixelThreshold /= 2;
1532515571 DecDepth();
1532615572 maskbit = 5;
1532715573 //if(fontsize > 1) fontsize -= 1;
15328
- if (object.editWindow == null)
15329
- new Exception().printStackTrace();
15330
- else
15331
- object.editWindow.refreshContents(true);
15574
+// if (object.editWindow == null)
15575
+// new Exception().printStackTrace();
15576
+// else
15577
+ object.GetWindow().refreshContents(true);
1533215578 break;
1533315579 case '{':
1533415580 manipCamera.shaper_fovy /= 1.1;
....@@ -15552,7 +15798,7 @@
1555215798 }
1555315799 */
1555415800
15555
- object.editWindow.EditSelection(false);
15801
+ object.GetWindow().EditSelection(false);
1555615802 }
1555715803
1555815804 void SelectParent()
....@@ -15569,10 +15815,10 @@
1556915815 {
1557015816 //selectees.remove(i);
1557115817 System.out.println("select parent of " + elem);
15572
- group.editWindow.Select(elem.parent.GetTreePath(), first, true);
15818
+ group.GetWindow().Select(elem.parent.GetTreePath(), first, true);
1557315819 } else
1557415820 {
15575
- group.editWindow.Select(elem.GetTreePath(), first, true);
15821
+ group.GetWindow().Select(elem.GetTreePath(), first, true);
1557615822 }
1557715823
1557815824 first = false;
....@@ -15614,12 +15860,12 @@
1561415860 for (int j = 0; j < group.children.size(); j++)
1561515861 {
1561615862 elem = (Object3D) group.children.elementAt(j);
15617
- object.editWindow.Select(elem.GetTreePath(), first, true);
15863
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1561815864 first = false;
1561915865 }
1562015866 } else
1562115867 {
15622
- object.editWindow.Select(elem.GetTreePath(), first, true);
15868
+ object.GetWindow().Select(elem.GetTreePath(), first, true);
1562315869 }
1562415870
1562515871 first = false;
....@@ -15630,21 +15876,21 @@
1563015876 {
1563115877 //Composite group = (Composite) object;
1563215878 Object3D group = object;
15633
- group.editWindow.loadClipboard(true); // ClearSelection(false);
15879
+ group.GetWindow().loadClipboard(true); // ClearSelection(false);
1563415880 }
1563515881
1563615882 void ResetTransform(int mask)
1563715883 {
1563815884 //Composite group = (Composite) object;
1563915885 Object3D group = object;
15640
- group.editWindow.ResetTransform(mask);
15886
+ group.GetWindow().ResetTransform(mask);
1564115887 }
1564215888
1564315889 void FlipTransform()
1564415890 {
1564515891 //Composite group = (Composite) object;
1564615892 Object3D group = object;
15647
- group.editWindow.FlipTransform();
15893
+ group.GetWindow().FlipTransform();
1564815894 // group.editWindow.ReduceMesh(true);
1564915895 }
1565015896
....@@ -15652,7 +15898,7 @@
1565215898 {
1565315899 //Composite group = (Composite) object;
1565415900 Object3D group = object;
15655
- group.editWindow.PrintMemory();
15901
+ group.GetWindow().PrintMemory();
1565615902 // group.editWindow.ReduceMesh(true);
1565715903 }
1565815904
....@@ -15660,7 +15906,7 @@
1566015906 {
1566115907 //Composite group = (Composite) object;
1566215908 Object3D group = object;
15663
- group.editWindow.ResetCentroid();
15909
+ group.GetWindow().ResetCentroid();
1566415910 }
1566515911
1566615912 void IncDepth()
....@@ -15742,8 +15988,6 @@
1574215988
1574315989 int width = getBounds().width;
1574415990 int height = getBounds().height;
15745
- ClickInfo info = new ClickInfo();
15746
- info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
1574715991 //Image img = CreateImage(width, height);
1574815992 //System.out.println("width = " + width + "; height = " + height + "\n");
1574915993
....@@ -15820,48 +16064,77 @@
1582016064 }
1582116065 if (object != null && !hasMarquee)
1582216066 {
16067
+ if (object.clickInfo == null)
16068
+ object.clickInfo = new ClickInfo();
16069
+ ClickInfo info = object.clickInfo;
16070
+ //ClickInfo info = new ClickInfo();
16071
+ info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom));
16072
+
1582316073 if (isRenderer)
1582416074 {
15825
- info.flags++;
16075
+ object.clickInfo.flags++;
1582616076 double frameAspect = (double) width / (double) height;
1582716077 if (frameAspect > renderCamera.aspect)
1582816078 {
1582916079 int desired = (int) ((double) height * renderCamera.aspect);
15830
- info.bounds.width -= width - desired;
15831
- info.bounds.x += (width - desired) / 2;
16080
+ object.clickInfo.bounds.width -= width - desired;
16081
+ object.clickInfo.bounds.x += (width - desired) / 2;
1583216082 } else
1583316083 {
1583416084 int desired = (int) ((double) width / renderCamera.aspect);
15835
- info.bounds.height -= height - desired;
15836
- info.bounds.y += (height - desired) / 2;
16085
+ object.clickInfo.bounds.height -= height - desired;
16086
+ object.clickInfo.bounds.y += (height - desired) / 2;
1583716087 }
1583816088 }
15839
- info.g = gr;
15840
- info.camera = renderCamera;
16089
+
16090
+ object.clickInfo.g = gr;
16091
+ object.clickInfo.camera = renderCamera;
1584116092 /*
1584216093 // Memory intensive (brep.verticescopy)
1584316094 if (!(object instanceof Composite))
1584416095 object.draw(info, 0, false); // SLOW :
1584516096 */
15846
- if (!isRenderer)
16097
+ if (!isRenderer) // && drag)
1584716098 {
15848
- object.drawEditHandles(info, 0);
15849
-
15850
- if (drag && (X != 0 || Y != 0) && object.selection.Size() > 0)
16099
+ Grafreed.Assert(object != null);
16100
+ Grafreed.Assert(object.selection != null);
16101
+ if (object.selection.Size() > 0)
1585116102 {
15852
- switch (object.selection.get(0).hitSomething)
16103
+ int hitSomething = object.selection.get(0).hitSomething;
16104
+
16105
+ object.clickInfo.DX = 0;
16106
+ object.clickInfo.DY = 0;
16107
+ object.clickInfo.W = 1;
16108
+ if (hitSomething == Object3D.hitCenter)
1585316109 {
15854
- case Object3D.hitCenter: gr.setColor(Color.pink);
15855
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15856
- break;
15857
- case Object3D.hitRotate: gr.setColor(Color.yellow);
15858
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15859
- break;
15860
- case Object3D.hitScale: gr.setColor(Color.cyan);
15861
- gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
15862
- break;
16110
+ info.DX = X;
16111
+ if (X != 0)
16112
+ info.DX -= info.bounds.width/2;
16113
+
16114
+ info.DY = Y;
16115
+ if (Y != 0)
16116
+ info.DY -= info.bounds.height/2;
1586316117 }
15864
-
16118
+
16119
+ object.drawEditHandles(//info,
16120
+ 0);
16121
+
16122
+ if (drag && (X != 0 || Y != 0))
16123
+ {
16124
+ switch (hitSomething)
16125
+ {
16126
+ case Object3D.hitCenter: gr.setColor(Color.pink);
16127
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16128
+ break;
16129
+ case Object3D.hitRotate: gr.setColor(Color.yellow);
16130
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16131
+ break;
16132
+ case Object3D.hitScale: gr.setColor(Color.cyan);
16133
+ gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2);
16134
+ break;
16135
+ }
16136
+
16137
+ }
1586516138 }
1586616139 }
1586716140 }
....@@ -16343,6 +16616,8 @@
1634316616 private /*static*/ boolean firstime;
1634416617 private /*static*/ cVector newView = new cVector();
1634516618 private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"};
16619
+ private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"};
16620
+ private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"};
1634616621 private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X,
1634716622 GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X,
1634816623 GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y,
....@@ -16355,29 +16630,67 @@
1635516630 {
1635616631 com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP);
1635716632
16633
+ int usedsuf = 0;
16634
+
1635816635 for (int i = 0; i < suffixes.length; i++)
1635916636 {
16360
- String resourceName = basename + suffixes[i] + "." + suffix;
16361
- TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16362
- mipmapped,
16363
- FileUtil.getFileSuffix(resourceName));
16364
- if (data == null)
16637
+ String[] suffixe = suffixes;
16638
+ String[] fallback = suffixes2;
16639
+ String[] fallfallback = suffixes3;
16640
+
16641
+ for (int c=usedsuf; --c>=0;)
1636516642 {
16366
- throw new IOException("Unable to load texture " + resourceName);
16643
+// String[] temp = suffixe;
16644
+// suffixe = fallback;
16645
+// fallback = fallfallback;
16646
+// fallfallback = temp;
1636716647 }
16648
+
16649
+ String resourceName = basename + suffixe[i] + "." + suffix;
16650
+ TextureData data;
16651
+
16652
+ try
16653
+ {
16654
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16655
+ mipmapped,
16656
+ FileUtil.getFileSuffix(resourceName));
16657
+ }
16658
+ catch (Exception e)
16659
+ {
16660
+ try
16661
+ {
16662
+ resourceName = basename + fallback[i] + "." + suffix;
16663
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16664
+ mipmapped,
16665
+ FileUtil.getFileSuffix(resourceName));
16666
+ }
16667
+ catch (Exception e2)
16668
+ {
16669
+ resourceName = basename + fallfallback[i] + "." + suffix;
16670
+ data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName),
16671
+ mipmapped,
16672
+ FileUtil.getFileSuffix(resourceName));
16673
+ }
16674
+ }
16675
+
1636816676 //System.out.println("Target = " + targets[i]);
1636916677 cubemap.updateImage(data, targets[i]);
1637016678 }
1637116679
1637216680 return cubemap;
1637316681 }
16682
+
1637416683 int bigsphere = -1;
1637516684
1637616685 float BGcolor = 0.5f;
1637716686
16378
- private void DrawSkyBox(GL gl)
16687
+ float ambientLight[] = {1f, 1f, 1f, 1.0f};
16688
+
16689
+ private void DrawSkyBox(GL gl, float ratio)
1637916690 {
16380
- if (envyoff || cubemap == null)
16691
+ if (//envyoff ||
16692
+ WIREFRAME ||
16693
+ cubemap == null)
1638116694 {
1638216695 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
1638316696 gl.glClear(gl.GL_COLOR_BUFFER_BIT);
....@@ -16392,7 +16705,17 @@
1639216705 // Compensates for ExaminerViewer's modification of modelview matrix
1639316706 gl.glMatrixMode(GL.GL_MODELVIEW);
1639416707 gl.glLoadIdentity();
16708
+ gl.glScalef(1,ratio,1);
1639516709
16710
+// colorV[0] = 2;
16711
+// colorV[1] = 2;
16712
+// colorV[2] = 2;
16713
+// colorV[3] = 1;
16714
+// gl.glDisable(gl.GL_COLOR_MATERIAL);
16715
+// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0);
16716
+//
16717
+// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0);
16718
+
1639616719 //gl.glActiveTexture(GL.GL_TEXTURE1);
1639716720 //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP);
1639816721
....@@ -16424,6 +16747,7 @@
1642416747 {
1642516748 gl.glScalef(1.0f, -1.0f, 1.0f);
1642616749 }
16750
+ gl.glScalef(-1.0f, 1.0f, 1.0f);
1642716751 gl.glMultMatrixd(viewrot_1, 0);
1642816752 gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f);
1642916753 //viewer.updateInverseRotation(gl);
....@@ -16659,6 +16983,14 @@
1665916983 }
1666016984 }
1666116985
16986
+ private Object3D GetFolder()
16987
+ {
16988
+ Object3D folder = object.GetWindow().copy;
16989
+ if (object.GetWindow().copy.selection.Size() > 0)
16990
+ folder = object.GetWindow().copy.selection.elementAt(0);
16991
+ return folder;
16992
+ }
16993
+
1666216994 class SelectBuffer implements GLEventListener
1666316995 {
1666416996
....@@ -16674,7 +17006,7 @@
1667417006 //new Exception().printStackTrace();
1667517007 System.out.println("select buffer init");
1667617008 // Use debug pipeline
16677
- drawable.setGL(new DebugGL(drawable.getGL()));
17009
+ //drawable.setGL(new DebugGL(drawable.getGL()));
1667817010
1667917011 GL gl = drawable.getGL();
1668017012
....@@ -16738,6 +17070,17 @@
1673817070
1673917071 //gl.glDisable(GL.GL_POLYGON_OFFSET_FILL);
1674017072
17073
+ if (PAINTMODE)
17074
+ {
17075
+ if (object.GetWindow().copy.selection.Size() > 0)
17076
+ {
17077
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17078
+
17079
+ // Make what you paint not selectable.
17080
+ paintobj.ResetSelectable();
17081
+ }
17082
+ }
17083
+
1674117084 //int tmp = selection_view;
1674217085 //selection_view = -1;
1674317086 int temp = DrawMode();
....@@ -16749,6 +17092,17 @@
1674917092 // temp = DEFAULT; // patch for selection debug
1675017093 Globals.drawMode = temp; // WARNING
1675117094
17095
+ if (PAINTMODE)
17096
+ {
17097
+ if (object.GetWindow().copy.selection.Size() > 0)
17098
+ {
17099
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
17100
+
17101
+ // Revert.
17102
+ paintobj.RestoreSelectable();
17103
+ }
17104
+ }
17105
+
1675217106 //gl.glBindTexture(GL.GL_TEXTURE_2D, selection_view);
1675317107
1675417108 // trying different ways of getting the depth info over
....@@ -16852,29 +17206,31 @@
1685217206 }
1685317207
1685417208 if (!movingcamera && !PAINTMODE)
16855
- object.editWindow.ScreenFitPoint(); // fev 2014
17209
+ object.GetWindow().ScreenFitPoint(); // fev 2014
1685617210
16857
- if (PAINTMODE && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
17211
+ if (PAINTMODE) // && Grafreed.clipboard.size() == 1) // object.editWindow.copy.selection.Size() > 0)
1685817212 {
16859
- Object3D paintobj = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
17213
+ //Object3D paintobj; // = Grafreed.clipboard.get(0); // object.editWindow.copy.selection.elementAt(0);
1686017214
16861
- Object3D group = new Object3D("inst" + paintcount++);
17215
+ if (object.GetWindow().copy.selection.Size() > 0)
17216
+ {
17217
+ Object3D paintobj = object.GetWindow().copy.selection.elementAt(0);
1686217218
16863
- group.CreateMaterial(); // use a void leaf to select instances
16864
-
16865
- group.add(paintobj); // link
16866
-
16867
- object.editWindow.SnapObject(group);
16868
-
16869
- Object3D folder = object.editWindow.copy;
16870
-
16871
- if (object.editWindow.copy.selection.Size() > 0)
16872
- folder = object.editWindow.copy.selection.elementAt(0);
16873
-
16874
- folder.add(group);
16875
-
16876
- object.editWindow.ResetModel();
16877
- object.editWindow.refreshContents();
17219
+ Object3D inst = new Object3D("inst" + paintcount++);
17220
+
17221
+ inst.CreateMaterial(); // use a void leaf to select instances
17222
+
17223
+ inst.add(paintobj); // link
17224
+
17225
+ object.GetWindow().SnapObject(inst);
17226
+
17227
+ Object3D folder = paintFolder; // GetFolder();
17228
+
17229
+ folder.add(inst);
17230
+
17231
+ object.GetWindow().ResetModel();
17232
+ object.GetWindow().refreshContents();
17233
+ }
1687817234 }
1687917235 else
1688017236 paintcount = 0;
....@@ -17196,10 +17552,14 @@
1719617552 gl.glFlush();
1719717553
1719817554 /**/
17199
- gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer);
17555
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer);
1720017556
17201
- float[] pixels = occlusionsizebuffer.array();
17557
+ float[] depths = occlusiondepthbuffer.array();
1720217558
17559
+ gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer);
17560
+
17561
+ int[] pixels = selectsizebuffer.array();
17562
+
1720317563 double r = 0, g = 0, b = 0;
1720417564
1720517565 double count = 0;
....@@ -17210,7 +17570,7 @@
1721017570
1721117571 double FACTOR = 1;
1721217572
17213
- for (int i = 0; i < pixels.length; i++)
17573
+ for (int i = 0; i < depths.length; i++)
1721417574 {
1721517575 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1721617576 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17293,7 +17653,7 @@
1729317653
1729417654 double scale = ray.z; // 1; // cos
1729517655
17296
- float depth = pixels[newindex];
17656
+ float depth = depths[newindex];
1729717657
1729817658 /*
1729917659 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17490,11 +17850,14 @@
1749017850 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1749117851 static IntBuffer bigAAbuffer;
1749217852 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17493
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17853
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1749417854 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1749517855 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1749617856 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17497
- static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17857
+ static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17858
+
17859
+ static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17860
+
1749817861 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1749917862 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1750017863 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();