.. | .. |
---|
18 | 18 | import javax.imageio.ImageIO; |
---|
19 | 19 | import javax.imageio.ImageWriteParam; |
---|
20 | 20 | import javax.imageio.ImageWriter; |
---|
| 21 | +import javax.imageio.ImageReadParam; |
---|
| 22 | +import javax.imageio.ImageReader; |
---|
21 | 23 | import javax.imageio.plugins.jpeg.JPEGImageWriteParam; |
---|
| 24 | +import javax.imageio.stream.ImageInputStream; |
---|
22 | 25 | import javax.imageio.stream.ImageOutputStream; |
---|
23 | 26 | import javax.imageio.ImageWriteParam; |
---|
24 | 27 | |
---|
.. | .. |
---|
30 | 33 | import java.nio.*; |
---|
31 | 34 | |
---|
32 | 35 | import gleem.linalg.Mat4f; |
---|
| 36 | +import javax.imageio.ImageTypeSpecifier; |
---|
33 | 37 | |
---|
34 | 38 | class CameraPane extends GLCanvas implements iCameraPane, Runnable, GLEventListener, ActionListener, MouseWheelListener, MouseMotionListener, MouseListener, KeyListener |
---|
35 | 39 | { |
---|
.. | .. |
---|
44 | 48 | static boolean ABORTED = false; |
---|
45 | 49 | |
---|
46 | 50 | 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 | + } |
---|
47 | 84 | |
---|
48 | 85 | /*static*/ private boolean CULLFACE = false; // true; |
---|
49 | 86 | /*static*/ boolean NEAREST = false; // true; |
---|
.. | .. |
---|
60 | 97 | //boolean REDUCETEXTURE = true; |
---|
61 | 98 | boolean CACHETEXTURE = true; |
---|
62 | 99 | boolean CLEANCACHE = false; // true; |
---|
63 | | - boolean MIPMAP = true; // false; // true; |
---|
| 100 | + boolean MIPMAP = false; // true; // never works... |
---|
64 | 101 | boolean COMPRESSTEXTURE = false; |
---|
65 | 102 | boolean KOMPACTTEXTURE = false; // true; |
---|
66 | 103 | boolean RESIZETEXTURE = false; |
---|
.. | .. |
---|
73 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
74 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
75 | 112 | 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; |
---|
77 | 116 | boolean reverseUP = false; |
---|
78 | 117 | static boolean frozen = false; |
---|
79 | 118 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
136 | 175 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
137 | 176 | boolean anisotropy = true; |
---|
138 | 177 | boolean softshadow = true; // slower but better false; |
---|
139 | | - boolean opacityhalo = false; |
---|
| 178 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
140 | 179 | |
---|
141 | 180 | boolean macromode = false; |
---|
142 | 181 | |
---|
.. | .. |
---|
150 | 189 | } |
---|
151 | 190 | |
---|
152 | 191 | 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 | + } |
---|
153 | 205 | |
---|
154 | 206 | void SetAsGLRenderer(boolean b) |
---|
155 | 207 | { |
---|
.. | .. |
---|
169 | 221 | |
---|
170 | 222 | SetCamera(cam); |
---|
171 | 223 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 224 | + // Warning: not used. |
---|
| 225 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 226 | |
---|
174 | 227 | object = o; |
---|
175 | 228 | |
---|
.. | .. |
---|
1447 | 1500 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1448 | 1501 | } |
---|
1449 | 1502 | |
---|
| 1503 | + float[] colorV = new float[4]; |
---|
| 1504 | + |
---|
1450 | 1505 | void SetColor(Object3D obj, Vertex p0) |
---|
1451 | 1506 | { |
---|
1452 | 1507 | CameraPane display = this; |
---|
.. | .. |
---|
1514 | 1569 | { |
---|
1515 | 1570 | return; |
---|
1516 | 1571 | } |
---|
1517 | | - |
---|
1518 | | - float[] colorV = new float[3]; |
---|
1519 | 1572 | |
---|
1520 | 1573 | if (false) // marked) |
---|
1521 | 1574 | { |
---|
.. | .. |
---|
2405 | 2458 | return currentGL; |
---|
2406 | 2459 | } |
---|
2407 | 2460 | |
---|
| 2461 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2462 | + { |
---|
| 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); |
---|
| 2474 | + } |
---|
| 2475 | + |
---|
2408 | 2476 | /**/ |
---|
2409 | 2477 | class CacheTexture |
---|
2410 | 2478 | { |
---|
.. | .. |
---|
2413 | 2481 | |
---|
2414 | 2482 | int resolution; |
---|
2415 | 2483 | |
---|
2416 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2484 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2417 | 2485 | { |
---|
2418 | | - texture = tex; |
---|
| 2486 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2487 | + texturedata = texdata; |
---|
2419 | 2488 | resolution = res; |
---|
2420 | 2489 | } |
---|
2421 | 2490 | } |
---|
2422 | 2491 | /**/ |
---|
2423 | 2492 | |
---|
2424 | 2493 | // TEXTURE static Texture texture; |
---|
2425 | | - static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
2426 | | - static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
2427 | | - static public java.util.HashSet<String> usedtextures = new java.util.HashSet<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>(); |
---|
2428 | 2498 | |
---|
2429 | 2499 | int pigmentdepth = 0; |
---|
2430 | 2500 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
.. | .. |
---|
2432 | 2502 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2433 | 2503 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2434 | 2504 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2435 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2505 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2436 | 2506 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2437 | 2507 | |
---|
2438 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2508 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2439 | 2509 | { |
---|
2440 | 2510 | TextureData texturedata = null; |
---|
2441 | 2511 | |
---|
.. | .. |
---|
2454 | 2524 | if (bump) |
---|
2455 | 2525 | texturedata = ConvertBump(texturedata, false); |
---|
2456 | 2526 | |
---|
2457 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2458 | | - 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); |
---|
2459 | 2529 | |
---|
2460 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2461 | | - 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); |
---|
2462 | 2532 | |
---|
2463 | | - return texture; |
---|
| 2533 | + return texturedata; |
---|
2464 | 2534 | } |
---|
2465 | 2535 | |
---|
2466 | | - com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2536 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
2467 | 2537 | { |
---|
2468 | 2538 | TextureData texturedata = null; |
---|
2469 | 2539 | |
---|
.. | .. |
---|
2471 | 2541 | { |
---|
2472 | 2542 | texturedata = |
---|
2473 | 2543 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2474 | | - name, |
---|
| 2544 | + bim, |
---|
2475 | 2545 | true); |
---|
2476 | 2546 | } catch (Exception e) |
---|
2477 | 2547 | { |
---|
.. | .. |
---|
2480 | 2550 | |
---|
2481 | 2551 | if (bump) |
---|
2482 | 2552 | texturedata = ConvertBump(texturedata, false); |
---|
2483 | | - |
---|
2484 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2485 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2486 | | - |
---|
2487 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2488 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2489 | | - |
---|
2490 | | - return texture; |
---|
| 2553 | + |
---|
| 2554 | + return texturedata; |
---|
2491 | 2555 | } |
---|
2492 | 2556 | |
---|
2493 | 2557 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
7975 | 8039 | pigment = null; |
---|
7976 | 8040 | } |
---|
7977 | 8041 | |
---|
7978 | | - ReleaseTexture(bump, true); |
---|
7979 | | - ReleaseTexture(pigment, false); |
---|
| 8042 | + ReleaseTexture(tex, true); |
---|
| 8043 | + ReleaseTexture(tex, false); |
---|
7980 | 8044 | } |
---|
7981 | 8045 | |
---|
7982 | 8046 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8005 | 8069 | pigment = null; |
---|
8006 | 8070 | } |
---|
8007 | 8071 | |
---|
8008 | | - ReleaseTexture(pigment, false); |
---|
| 8072 | + ReleaseTexture(tex, false); |
---|
8009 | 8073 | } |
---|
8010 | 8074 | |
---|
8011 | 8075 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8034 | 8098 | bump = null; |
---|
8035 | 8099 | } |
---|
8036 | 8100 | |
---|
8037 | | - ReleaseTexture(bump, true); |
---|
| 8101 | + ReleaseTexture(tex, true); |
---|
8038 | 8102 | } |
---|
8039 | 8103 | |
---|
8040 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8104 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8041 | 8105 | { |
---|
8042 | 8106 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8043 | 8107 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8048 | 8112 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8049 | 8113 | |
---|
8050 | 8114 | if (tex != null) |
---|
8051 | | - texture = textures.get(tex); |
---|
| 8115 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8052 | 8116 | |
---|
8053 | 8117 | // //assert( texture != null ); |
---|
8054 | 8118 | // if (texture == null) |
---|
.. | .. |
---|
8198 | 8262 | |
---|
8199 | 8263 | if (tex == null) |
---|
8200 | 8264 | { |
---|
8201 | | - BindTexture(null, null,false,resolution); |
---|
| 8265 | + BindTexture(null,false,resolution); |
---|
8202 | 8266 | return; |
---|
8203 | 8267 | } |
---|
8204 | 8268 | |
---|
8205 | 8269 | String pigment = Object3D.GetPigment(tex); |
---|
8206 | 8270 | |
---|
8207 | | - usedtextures.add(pigment); |
---|
| 8271 | + usedtextures.add(tex); |
---|
8208 | 8272 | |
---|
8209 | 8273 | //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8210 | 8274 | { |
---|
.. | .. |
---|
8218 | 8282 | } |
---|
8219 | 8283 | |
---|
8220 | 8284 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8221 | | - BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
| 8285 | + BindTexture(tex, false, resolution); |
---|
8222 | 8286 | } |
---|
8223 | 8287 | |
---|
8224 | 8288 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8231 | 8295 | |
---|
8232 | 8296 | if (tex == null) |
---|
8233 | 8297 | { |
---|
8234 | | - BindTexture(null, null,true,resolution); |
---|
| 8298 | + BindTexture(null,true,resolution); |
---|
8235 | 8299 | return; |
---|
8236 | 8300 | } |
---|
8237 | 8301 | |
---|
8238 | 8302 | String bump = Object3D.GetBump(tex); |
---|
8239 | 8303 | |
---|
8240 | | - usedtextures.add(bump); |
---|
| 8304 | + usedtextures.add(tex); |
---|
8241 | 8305 | |
---|
8242 | 8306 | //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8243 | 8307 | { |
---|
.. | .. |
---|
8251 | 8315 | } |
---|
8252 | 8316 | |
---|
8253 | 8317 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8254 | | - BindTexture(tex.bumptexture, bump, true, resolution); |
---|
| 8318 | + BindTexture(tex, true, resolution); |
---|
8255 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8256 | 8320 | } |
---|
8257 | 8321 | |
---|
.. | .. |
---|
8275 | 8339 | return fileExists; |
---|
8276 | 8340 | } |
---|
8277 | 8341 | |
---|
8278 | | - CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
| 8342 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8279 | 8343 | { |
---|
8280 | 8344 | CacheTexture texturecache = null; |
---|
8281 | 8345 | |
---|
8282 | 8346 | if (tex != null) |
---|
8283 | 8347 | { |
---|
8284 | | - 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 | + } |
---|
8285 | 8355 | |
---|
8286 | 8356 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8287 | 8357 | |
---|
.. | .. |
---|
8291 | 8361 | // else |
---|
8292 | 8362 | // if (!texname.startsWith("/")) |
---|
8293 | 8363 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8294 | | - if (!FileExists(tex)) |
---|
| 8364 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8295 | 8365 | { |
---|
8296 | 8366 | texname = fallbackTextureName; |
---|
8297 | 8367 | } |
---|
8298 | 8368 | |
---|
8299 | 8369 | if (CACHETEXTURE) |
---|
8300 | 8370 | { |
---|
8301 | | - if (bim == null) |
---|
8302 | | - texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8371 | + if (texdata == null) |
---|
| 8372 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8303 | 8373 | else |
---|
8304 | | - texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8374 | + texturecache = bimtextures.get(texdata); |
---|
8305 | 8375 | } |
---|
8306 | 8376 | |
---|
8307 | | - if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8377 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
8308 | 8378 | { |
---|
8309 | 8379 | TextureData texturedata = null; |
---|
8310 | 8380 | |
---|
8311 | | - if (bim == null) |
---|
| 8381 | + if (texdata != null && textureon) |
---|
8312 | 8382 | { |
---|
| 8383 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
8313 | 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; |
---|
8314 | 8401 | } |
---|
8315 | 8402 | else |
---|
8316 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8403 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8317 | 8404 | { |
---|
8318 | 8405 | assert(!bump); |
---|
8319 | 8406 | // if (bump) |
---|
.. | .. |
---|
8324 | 8411 | // } |
---|
8325 | 8412 | // else |
---|
8326 | 8413 | // { |
---|
8327 | | - texturecache = textures.get(tex); |
---|
| 8414 | + // texturecache = textures.get(texname); // suspicious |
---|
8328 | 8415 | if (texturecache == null) |
---|
8329 | 8416 | { |
---|
8330 | 8417 | texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8331 | 8418 | } |
---|
| 8419 | + else |
---|
| 8420 | + new Exception().printStackTrace(); |
---|
8332 | 8421 | // } |
---|
8333 | 8422 | } else |
---|
8334 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8423 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8335 | 8424 | { |
---|
8336 | 8425 | assert(bump); |
---|
8337 | | - texturecache = textures.get(tex); |
---|
| 8426 | + // texturecache = textures.get(texname); // suspicious |
---|
8338 | 8427 | if (texturecache == null) |
---|
8339 | 8428 | texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
| 8429 | + else |
---|
| 8430 | + new Exception().printStackTrace(); |
---|
8340 | 8431 | } else |
---|
8341 | 8432 | { |
---|
8342 | 8433 | //if (tex.equals("IMMORTAL")) |
---|
.. | .. |
---|
8344 | 8435 | // texture = GetResourceTexture("default.png"); |
---|
8345 | 8436 | //} else |
---|
8346 | 8437 | //{ |
---|
8347 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8438 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8348 | 8439 | { |
---|
8349 | | - texturecache = textures.get(tex); |
---|
| 8440 | + // texturecache = textures.get(texname); // suspicious |
---|
8350 | 8441 | if (texturecache == null) |
---|
8351 | 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(); |
---|
8352 | 8454 | } else |
---|
8353 | 8455 | { |
---|
8354 | 8456 | if (textureon) |
---|
.. | .. |
---|
8407 | 8509 | if (texturedata == null) |
---|
8408 | 8510 | throw new Exception(); |
---|
8409 | 8511 | |
---|
8410 | | - texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8512 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8411 | 8513 | //texture = GetTexture(tex, bump); |
---|
8412 | 8514 | } |
---|
| 8515 | + } |
---|
8413 | 8516 | } |
---|
8414 | 8517 | //} |
---|
8415 | 8518 | } |
---|
8416 | 8519 | |
---|
8417 | | - if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
| 8520 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8418 | 8521 | { |
---|
8419 | 8522 | //return false; |
---|
8420 | 8523 | |
---|
.. | .. |
---|
8436 | 8539 | File cachefile = new File(texname.substring(0, texname.length()-4)+ext+".jpg"); |
---|
8437 | 8540 | if (!cachefile.exists()) |
---|
8438 | 8541 | { |
---|
8439 | | - // cache to disk |
---|
8440 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
8441 | | - //buffers[0]. |
---|
8442 | | - |
---|
8443 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
8444 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
8445 | | - |
---|
8446 | | - // squared size heuristic... |
---|
8447 | | - if ((int)Math.sqrt(pixels.length) == Math.sqrt(pixels.length)) |
---|
| 8542 | + //if (texturedata.getWidth() == texturedata.getHeight()) |
---|
8448 | 8543 | { |
---|
8449 | | - for (int i=pixels.length; --i>=0;) |
---|
8450 | | - { |
---|
8451 | | - int i3 = i*3; |
---|
8452 | | - pixels[i] = 0xFF; |
---|
8453 | | - pixels[i] <<= 8; |
---|
8454 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
8455 | | - pixels[i] <<= 8; |
---|
8456 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
8457 | | - pixels[i] <<= 8; |
---|
8458 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
8459 | | - } |
---|
8460 | | - |
---|
8461 | | - /* |
---|
8462 | | - int r=0,g=0,b=0,a=0; |
---|
8463 | | - for (int i=0; i<width; i++) |
---|
8464 | | - for (int j=0; j<height; j++) |
---|
8465 | | - { |
---|
8466 | | - int index = j*width+i; |
---|
8467 | | - int p = pixels[index]; |
---|
8468 | | - a = ((p>>24) & 0xFF); |
---|
8469 | | - r = ((p>>16) & 0xFF); |
---|
8470 | | - g = ((p>>8) & 0xFF); |
---|
8471 | | - b = (p & 0xFF); |
---|
8472 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
8473 | | - } |
---|
8474 | | - /**/ |
---|
8475 | | - int width = (int)Math.sqrt(pixels.length); // squared |
---|
8476 | | - int height = width; |
---|
8477 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
8478 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
| 8544 | + BufferedImage rendImage = CreateBim(texturedata); |
---|
| 8545 | + |
---|
8479 | 8546 | ImageWriter writer = null; |
---|
8480 | 8547 | Iterator iter = ImageIO.getImageWritersByFormatName("jpg"); |
---|
8481 | 8548 | if (iter.hasNext()) { |
---|
8482 | 8549 | writer = (ImageWriter)iter.next(); |
---|
8483 | 8550 | } |
---|
8484 | | - float compressionQuality = 0.9f; |
---|
| 8551 | + |
---|
| 8552 | + float compressionQuality = 0.85f; |
---|
8485 | 8553 | try |
---|
8486 | 8554 | { |
---|
8487 | 8555 | ImageOutputStream ios = ImageIO.createImageOutputStream(cachefile); |
---|
.. | .. |
---|
8498 | 8566 | } |
---|
8499 | 8567 | } |
---|
8500 | 8568 | } |
---|
8501 | | - |
---|
| 8569 | + |
---|
| 8570 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8571 | + |
---|
8502 | 8572 | //System.out.println("Texture = " + tex); |
---|
8503 | | - if (textures.containsKey(texname)) |
---|
| 8573 | + if (textures.containsKey(tex)) |
---|
8504 | 8574 | { |
---|
8505 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8575 | + CacheTexture thetex = textures.get(tex); |
---|
8506 | 8576 | thetex.texture.disable(); |
---|
8507 | 8577 | thetex.texture.dispose(); |
---|
8508 | | - textures.remove(texname); |
---|
| 8578 | + textures.remove(tex); |
---|
8509 | 8579 | } |
---|
8510 | 8580 | |
---|
8511 | 8581 | //texture.texturedata = texturedata; |
---|
8512 | | - textures.put(texname, texturecache); |
---|
| 8582 | + textures.put(tex, texturecache); |
---|
8513 | 8583 | |
---|
8514 | 8584 | // newtex = true; |
---|
8515 | 8585 | } |
---|
.. | .. |
---|
8528 | 8598 | return texturecache; |
---|
8529 | 8599 | } |
---|
8530 | 8600 | |
---|
8531 | | - com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8601 | + static void EmbedTextures(cTexture tex) |
---|
8532 | 8602 | { |
---|
8533 | | - CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
| 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 |
---|
| 8636 | + { |
---|
| 8637 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8534 | 8638 | |
---|
8535 | 8639 | if (bump) |
---|
8536 | 8640 | { |
---|
.. | .. |
---|
8546 | 8650 | return texture!=null?texture.texture:null; |
---|
8547 | 8651 | } |
---|
8548 | 8652 | |
---|
8549 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, 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 |
---|
8550 | 8654 | { |
---|
8551 | | - CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
| 8655 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8552 | 8656 | |
---|
8553 | 8657 | return texture!=null?texture.texturedata:null; |
---|
8554 | 8658 | } |
---|
8555 | 8659 | |
---|
8556 | | - boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8660 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8557 | 8661 | { |
---|
8558 | 8662 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8559 | 8663 | { |
---|
.. | .. |
---|
8562 | 8666 | |
---|
8563 | 8667 | //boolean newtex = false; |
---|
8564 | 8668 | |
---|
8565 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
| 8669 | + com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8566 | 8670 | |
---|
8567 | 8671 | if (texture == null) |
---|
8568 | 8672 | return false; |
---|
.. | .. |
---|
8595 | 8699 | return true; // Warning: not used. |
---|
8596 | 8700 | } |
---|
8597 | 8701 | |
---|
| 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 | + |
---|
8598 | 8768 | ShadowBuffer shadowPBuf; |
---|
8599 | 8769 | AntialiasBuffer antialiasPBuf; |
---|
8600 | 8770 | int MAXSTACK; |
---|
.. | .. |
---|
8611 | 8781 | |
---|
8612 | 8782 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8613 | 8783 | MAXSTACK = temp[0]; |
---|
8614 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8784 | + if (Globals.DEBUG) |
---|
| 8785 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8615 | 8786 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8616 | 8787 | MAXSTACK = temp[0]; |
---|
8617 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8788 | + if (Globals.DEBUG) |
---|
| 8789 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8618 | 8790 | |
---|
8619 | 8791 | // Use debug pipeline |
---|
8620 | 8792 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8622 | 8794 | gl = drawable.getGL(); // |
---|
8623 | 8795 | |
---|
8624 | 8796 | GL gl3 = getGL(); |
---|
8625 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8797 | + if (Globals.DEBUG) |
---|
| 8798 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8626 | 8799 | |
---|
8627 | 8800 | |
---|
8628 | 8801 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8787 | 8960 | |
---|
8788 | 8961 | if (cubemap == null) |
---|
8789 | 8962 | { |
---|
8790 | | - LoadEnvy(5); |
---|
| 8963 | + //LoadEnvy(1); |
---|
8791 | 8964 | } |
---|
8792 | 8965 | |
---|
8793 | 8966 | //cubemap.enable(); |
---|
.. | .. |
---|
9063 | 9236 | |
---|
9064 | 9237 | void LoadEnvy(int which) |
---|
9065 | 9238 | { |
---|
| 9239 | + assert(false); |
---|
| 9240 | + |
---|
9066 | 9241 | String name; |
---|
9067 | 9242 | String ext; |
---|
9068 | 9243 | |
---|
.. | .. |
---|
9074 | 9249 | cubemap = null; |
---|
9075 | 9250 | return; |
---|
9076 | 9251 | case 1: |
---|
9077 | | - name = "cubemaps/box_"; |
---|
9078 | | - ext = "png"; |
---|
| 9252 | + name = "cubemaps/rgb/"; |
---|
| 9253 | + ext = "jpg"; |
---|
9079 | 9254 | reverseUP = false; |
---|
9080 | 9255 | break; |
---|
9081 | 9256 | case 2: |
---|
9082 | | - name = "cubemaps/uffizi_"; |
---|
9083 | | - ext = "png"; |
---|
9084 | | - break; // reverseUP = true; break; |
---|
| 9257 | + name = "cubemaps/uffizi/"; |
---|
| 9258 | + ext = "jpg"; |
---|
| 9259 | + reverseUP = false; |
---|
| 9260 | + break; |
---|
9085 | 9261 | case 3: |
---|
9086 | | - name = "cubemaps/CloudyHills_"; |
---|
9087 | | - ext = "tga"; |
---|
| 9262 | + name = "cubemaps/CloudyHills/"; |
---|
| 9263 | + ext = "jpg"; |
---|
9088 | 9264 | reverseUP = false; |
---|
9089 | 9265 | break; |
---|
9090 | 9266 | case 4: |
---|
9091 | | - name = "cubemaps/cornell_"; |
---|
| 9267 | + name = "cubemaps/cornell/"; |
---|
9092 | 9268 | ext = "png"; |
---|
9093 | 9269 | reverseUP = false; |
---|
9094 | 9270 | 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; |
---|
9095 | 9296 | default: |
---|
9096 | | - name = "cubemaps/rgb_"; |
---|
9097 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9297 | + name = "cubemaps/box/"; |
---|
| 9298 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9299 | + reverseUP = false; |
---|
9098 | 9300 | break; |
---|
9099 | 9301 | } |
---|
9100 | | - |
---|
9101 | | - try |
---|
9102 | | - { |
---|
9103 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9104 | | - } catch (IOException e) |
---|
9105 | | - { |
---|
9106 | | - throw new RuntimeException(e); |
---|
9107 | | - } |
---|
| 9302 | + |
---|
| 9303 | + LoadSkybox(name, ext, mipmap); |
---|
9108 | 9304 | } |
---|
9109 | 9305 | |
---|
9110 | 9306 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9136 | 9332 | static double[] model = new double[16]; |
---|
9137 | 9333 | double[] camera2light = new double[16]; |
---|
9138 | 9334 | double[] light2camera = new double[16]; |
---|
9139 | | - int newenvy = -1; |
---|
9140 | | - boolean envyoff = true; // false; |
---|
| 9335 | + |
---|
| 9336 | + //int newenvy = -1; |
---|
| 9337 | + //boolean envyoff = false; |
---|
| 9338 | + |
---|
| 9339 | + String loadedskyboxname; |
---|
| 9340 | + |
---|
9141 | 9341 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9142 | 9342 | //float[] light0 = { 0,0,0 }; |
---|
9143 | 9343 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9555 | 9755 | |
---|
9556 | 9756 | if (renderCamera != lightCamera) |
---|
9557 | 9757 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9558 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9758 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9559 | 9759 | |
---|
9560 | 9760 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9561 | 9761 | |
---|
.. | .. |
---|
9571 | 9771 | |
---|
9572 | 9772 | if (renderCamera != lightCamera) |
---|
9573 | 9773 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9574 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9774 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9575 | 9775 | |
---|
9576 | 9776 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9577 | 9777 | |
---|
.. | .. |
---|
9617 | 9817 | rati = 1 / rati; |
---|
9618 | 9818 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9619 | 9819 | } |
---|
9620 | | - assert (newenvy == -1); |
---|
| 9820 | + |
---|
| 9821 | + //assert (newenvy == -1); |
---|
| 9822 | + |
---|
9621 | 9823 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9622 | 9824 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9623 | | - DrawSkyBox(gl); |
---|
| 9825 | + DrawSkyBox(gl, (float)rati); |
---|
9624 | 9826 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9625 | 9827 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9626 | 9828 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10657 | 10859 | |
---|
10658 | 10860 | if (wait) |
---|
10659 | 10861 | { |
---|
10660 | | - Sleep(500); |
---|
| 10862 | + Sleep(200); // blocks everything |
---|
10661 | 10863 | |
---|
10662 | 10864 | wait = false; |
---|
10663 | 10865 | } |
---|
.. | .. |
---|
10772 | 10974 | // if (parentcam != renderCamera) // not a light |
---|
10773 | 10975 | if (cam != lightCamera) |
---|
10774 | 10976 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10775 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10977 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10776 | 10978 | |
---|
10777 | 10979 | for (int j = 0; j < 4; j++) |
---|
10778 | 10980 | { |
---|
.. | .. |
---|
10787 | 10989 | // if (parentcam != renderCamera) // not a light |
---|
10788 | 10990 | if (cam != lightCamera) |
---|
10789 | 10991 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10790 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10992 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10791 | 10993 | |
---|
10792 | 10994 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10793 | 10995 | |
---|
.. | .. |
---|
10873 | 11075 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10874 | 11076 | } |
---|
10875 | 11077 | |
---|
10876 | | - 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")) |
---|
10877 | 11086 | { |
---|
10878 | | - LoadEnvy(newenvy); |
---|
| 11087 | + if (cubemaprgb == null) |
---|
| 11088 | + { |
---|
| 11089 | + cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11090 | + } |
---|
| 11091 | + |
---|
| 11092 | + cubemap = cubemaprgb; |
---|
10879 | 11093 | } |
---|
10880 | | - |
---|
10881 | | - newenvy = -1; |
---|
10882 | | - |
---|
| 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 | + |
---|
10883 | 11113 | ratio = ((double) getWidth()) / getHeight(); |
---|
10884 | 11114 | //System.out.println("ratio = " + ratio); |
---|
10885 | 11115 | |
---|
.. | .. |
---|
10895 | 11125 | |
---|
10896 | 11126 | if (!IsFrozen() && !ambientOcclusion) |
---|
10897 | 11127 | { |
---|
10898 | | - DrawSkyBox(gl); |
---|
| 11128 | + DrawSkyBox(gl, (float)ratio); |
---|
10899 | 11129 | } |
---|
10900 | 11130 | |
---|
10901 | 11131 | //if (selection_view == -1) |
---|
.. | .. |
---|
11049 | 11279 | |
---|
11050 | 11280 | try |
---|
11051 | 11281 | { |
---|
11052 | | - BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
| 11282 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
11053 | 11283 | } |
---|
11054 | 11284 | catch (Exception e) |
---|
11055 | 11285 | { |
---|
.. | .. |
---|
11181 | 11411 | |
---|
11182 | 11412 | // if (cam != lightCamera) |
---|
11183 | 11413 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11184 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11414 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11185 | 11415 | } |
---|
11186 | 11416 | |
---|
11187 | 11417 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11340 | 11570 | } |
---|
11341 | 11571 | } |
---|
11342 | 11572 | |
---|
11343 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11573 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11344 | 11574 | { |
---|
11345 | 11575 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11346 | 11576 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11348 | 11578 | |
---|
11349 | 11579 | boolean texon = textureon; |
---|
11350 | 11580 | |
---|
11351 | | - if (RENDERPROGRAM > 0) |
---|
11352 | | - { |
---|
11353 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11354 | | - textureon = false; |
---|
11355 | | - } |
---|
| 11581 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11582 | + textureon = false; |
---|
| 11583 | + |
---|
11356 | 11584 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11357 | 11585 | //System.out.println("ALLO"); |
---|
11358 | 11586 | gl.glColorMask(false, false, false, false); |
---|
11359 | 11587 | DrawObject(gl); |
---|
11360 | | - if (RENDERPROGRAM > 0) |
---|
11361 | | - { |
---|
11362 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11363 | | - textureon = texon; |
---|
11364 | | - } |
---|
| 11588 | + |
---|
| 11589 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11590 | + textureon = texon; |
---|
| 11591 | + |
---|
11365 | 11592 | gl.glColorMask(true, true, true, true); |
---|
11366 | 11593 | |
---|
11367 | 11594 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11368 | | - //gl.glDepthMask(false); |
---|
| 11595 | + gl.glDepthMask(false); |
---|
11369 | 11596 | } |
---|
11370 | 11597 | |
---|
11371 | 11598 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11705 | 11932 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11706 | 11933 | |
---|
11707 | 11934 | if (CLEANCACHE) |
---|
11708 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11935 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11709 | 11936 | { |
---|
11710 | | - String tex = e.nextElement(); |
---|
| 11937 | + cTexture tex = e.nextElement(); |
---|
11711 | 11938 | |
---|
11712 | 11939 | // System.out.println("Texture --------- " + tex); |
---|
11713 | 11940 | |
---|
11714 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11941 | + if (tex.equals("WHITE_NOISE:")) |
---|
11715 | 11942 | continue; |
---|
11716 | 11943 | |
---|
11717 | 11944 | if (!usedtextures.contains(tex)) |
---|
11718 | 11945 | { |
---|
| 11946 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11719 | 11947 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11720 | | - textures.get(tex).texture.dispose(); |
---|
11721 | | - 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 | + } |
---|
11722 | 11961 | } |
---|
11723 | 11962 | } |
---|
11724 | 11963 | } |
---|
.. | .. |
---|
12246 | 12485 | |
---|
12247 | 12486 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12248 | 12487 | |
---|
12249 | | - String program = |
---|
| 12488 | + String programmin = |
---|
| 12489 | + // Min shader |
---|
12250 | 12490 | "!!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 | + |
---|
12251 | 12558 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12252 | 12559 | "PARAM light2cam0 = program.env[10];" + |
---|
12253 | 12560 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12362 | 12669 | "TEMP shininess;" + |
---|
12363 | 12670 | "\n" + |
---|
12364 | 12671 | "MOV texSamp, one;" + |
---|
12365 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12366 | | - |
---|
| 12672 | + |
---|
12367 | 12673 | "MOV mapgrid.x, one2048th.x;" + |
---|
12368 | 12674 | "MOV temp, fragment.texcoord[1];" + |
---|
12369 | 12675 | /* |
---|
.. | .. |
---|
12384 | 12690 | "MUL temp, floor, mapgrid.x;" + |
---|
12385 | 12691 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12386 | 12692 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12387 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12693 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12388 | 12694 | "") + |
---|
12389 | 12695 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12390 | 12696 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12391 | 12697 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12392 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12698 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12393 | 12699 | "") + |
---|
12394 | 12700 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12395 | 12701 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12396 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12397 | 12703 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12398 | 12704 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12399 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12400 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12401 | 12707 | "") + |
---|
12402 | 12708 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12403 | 12709 | //"MOV params, material;" + |
---|
.. | .. |
---|
12768 | 13074 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12769 | 13075 | "") + |
---|
12770 | 13076 | |
---|
12771 | | - // display shadow only (bump == 0) |
---|
| 13077 | + // display shadow only (fakedepth == 0) |
---|
12772 | 13078 | "SUB temp.x, half.x, shadow.x;" + |
---|
12773 | 13079 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12774 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13080 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12775 | 13081 | "SUB temp.y, one.x, temp.z;" + |
---|
12776 | 13082 | "MUL temp.x, temp.x, temp.y;" + |
---|
12777 | 13083 | "KIL temp.x;" + |
---|
.. | .. |
---|
13102 | 13408 | //once = true; |
---|
13103 | 13409 | } |
---|
13104 | 13410 | |
---|
| 13411 | + String program = programmax; |
---|
| 13412 | + |
---|
| 13413 | + if (Globals.MINSHADER) |
---|
| 13414 | + { |
---|
| 13415 | + program = programmin; |
---|
| 13416 | + } |
---|
| 13417 | + |
---|
13105 | 13418 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13106 | 13419 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13107 | 13420 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13195 | 13508 | return out; |
---|
13196 | 13509 | } |
---|
13197 | 13510 | |
---|
13198 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13511 | + // Also does frustum culling |
---|
| 13512 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13199 | 13513 | { |
---|
13200 | 13514 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13201 | 13515 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13202 | 13516 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13517 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13518 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13203 | 13519 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13204 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13205 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13206 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13207 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13520 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13521 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13208 | 13522 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13209 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13523 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13210 | 13524 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13211 | 13525 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13212 | 13526 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13213 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13527 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13214 | 13528 | |
---|
13215 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13216 | | - //"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;"; |
---|
13217 | 13531 | } |
---|
13218 | 13532 | |
---|
13219 | 13533 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13260 | 13574 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13261 | 13575 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13262 | 13576 | |
---|
13263 | | - // No shadow when out of frustrum |
---|
| 13577 | + // No shadow when out of frustum |
---|
13264 | 13578 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13265 | 13579 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13266 | 13580 | ""; |
---|
.. | .. |
---|
14058 | 14372 | drag = false; |
---|
14059 | 14373 | //System.out.println("Mouse DOWN"); |
---|
14060 | 14374 | editObj = false; |
---|
14061 | | - ClickInfo info = new ClickInfo(); |
---|
14062 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14063 | | - info.pane = this; |
---|
14064 | | - info.camera = renderCamera; |
---|
14065 | | - info.x = x; |
---|
14066 | | - info.y = y; |
---|
14067 | | - info.modifiers = modifiersex; |
---|
14068 | | - 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); |
---|
14069 | 14384 | if (!editObj) |
---|
14070 | 14385 | { |
---|
14071 | 14386 | hasMarquee = true; |
---|
.. | .. |
---|
14349 | 14664 | MODIFIERS |= COMMAND; |
---|
14350 | 14665 | /**/ |
---|
14351 | 14666 | if((mod&SHIFT) == SHIFT) |
---|
14352 | | - manipCamera.RotatePosition(0, -speed); |
---|
14353 | | - else |
---|
14354 | 14667 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14668 | + else |
---|
| 14669 | + manipCamera.RotatePosition(0, -speed); |
---|
14355 | 14670 | /**/ |
---|
14356 | 14671 | if ((mod & SHIFT) == SHIFT) |
---|
14357 | 14672 | { |
---|
.. | .. |
---|
14370 | 14685 | MODIFIERS |= COMMAND; |
---|
14371 | 14686 | /**/ |
---|
14372 | 14687 | if((mod&SHIFT) == SHIFT) |
---|
14373 | | - manipCamera.RotatePosition(0, speed); |
---|
14374 | | - else |
---|
14375 | 14688 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, speed); |
---|
14376 | 14691 | /**/ |
---|
14377 | 14692 | if ((mod & SHIFT) == SHIFT) |
---|
14378 | 14693 | { |
---|
.. | .. |
---|
14465 | 14780 | if (editObj) |
---|
14466 | 14781 | { |
---|
14467 | 14782 | drag = true; |
---|
14468 | | - ClickInfo info = new ClickInfo(); |
---|
14469 | | - info.bounds.setBounds(0, 0, |
---|
| 14783 | + //ClickInfo info = new ClickInfo(); |
---|
| 14784 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14470 | 14785 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14471 | | - info.pane = this; |
---|
14472 | | - info.camera = renderCamera; |
---|
14473 | | - info.x = x; |
---|
14474 | | - info.y = y; |
---|
14475 | | - object.GetWindow().copy |
---|
14476 | | - .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); |
---|
14477 | 14793 | } else |
---|
14478 | 14794 | { |
---|
14479 | 14795 | if (x < startX) |
---|
.. | .. |
---|
14622 | 14938 | } |
---|
14623 | 14939 | } |
---|
14624 | 14940 | |
---|
| 14941 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14942 | + |
---|
14625 | 14943 | public void mouseMoved(MouseEvent e) |
---|
14626 | 14944 | { |
---|
14627 | 14945 | //System.out.println("mouseMoved: " + e); |
---|
14628 | 14946 | if (isRenderer) |
---|
14629 | 14947 | return; |
---|
14630 | 14948 | |
---|
14631 | | - ClickInfo ci = new ClickInfo(); |
---|
14632 | | - ci.x = e.getX(); |
---|
14633 | | - ci.y = e.getY(); |
---|
14634 | | - ci.modifiers = e.getModifiersEx(); |
---|
14635 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14636 | | - ci.pane = this; |
---|
14637 | | - 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; |
---|
14638 | 14956 | if (!isRenderer) |
---|
14639 | 14957 | { |
---|
14640 | 14958 | //ObjEditor editWindow = object.editWindow; |
---|
14641 | 14959 | //Object3D copy = editWindow.copy; |
---|
14642 | | - if (object.doEditClick(ci, 0)) |
---|
| 14960 | + if (object.doEditClick(//clickInfo, |
---|
| 14961 | + 0)) |
---|
14643 | 14962 | { |
---|
14644 | 14963 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14645 | 14964 | } else |
---|
.. | .. |
---|
14911 | 15230 | // break; |
---|
14912 | 15231 | case 'T': |
---|
14913 | 15232 | CACHETEXTURE ^= true; |
---|
14914 | | - textures.clear(); |
---|
| 15233 | + texturepigment.clear(); |
---|
| 15234 | + texturebump.clear(); |
---|
14915 | 15235 | // repaint(); |
---|
14916 | 15236 | break; |
---|
14917 | 15237 | case 'Y': |
---|
.. | .. |
---|
15088 | 15408 | OCCLUSION_CULLING ^= true; |
---|
15089 | 15409 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15090 | 15410 | break; |
---|
15091 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15411 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15092 | 15412 | case '1': |
---|
15093 | 15413 | case '2': |
---|
15094 | 15414 | case '3': |
---|
15095 | 15415 | case '4': |
---|
15096 | 15416 | case '5': |
---|
15097 | | - newenvy = Character.getNumericValue(key); |
---|
15098 | | - repaint(); |
---|
15099 | | - break; |
---|
15100 | 15417 | case '6': |
---|
15101 | 15418 | case '7': |
---|
15102 | 15419 | case '8': |
---|
15103 | 15420 | case '9': |
---|
15104 | | - 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 | + } |
---|
15105 | 15429 | repaint(); |
---|
15106 | 15430 | break; |
---|
15107 | 15431 | case '!': |
---|
.. | .. |
---|
15664 | 15988 | |
---|
15665 | 15989 | int width = getBounds().width; |
---|
15666 | 15990 | int height = getBounds().height; |
---|
15667 | | - ClickInfo info = new ClickInfo(); |
---|
15668 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15669 | 15991 | //Image img = CreateImage(width, height); |
---|
15670 | 15992 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15671 | 15993 | |
---|
.. | .. |
---|
15742 | 16064 | } |
---|
15743 | 16065 | if (object != null && !hasMarquee) |
---|
15744 | 16066 | { |
---|
| 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 | + |
---|
15745 | 16073 | if (isRenderer) |
---|
15746 | 16074 | { |
---|
15747 | | - info.flags++; |
---|
| 16075 | + object.clickInfo.flags++; |
---|
15748 | 16076 | double frameAspect = (double) width / (double) height; |
---|
15749 | 16077 | if (frameAspect > renderCamera.aspect) |
---|
15750 | 16078 | { |
---|
15751 | 16079 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15752 | | - info.bounds.width -= width - desired; |
---|
15753 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16080 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16081 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15754 | 16082 | } else |
---|
15755 | 16083 | { |
---|
15756 | 16084 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15757 | | - info.bounds.height -= height - desired; |
---|
15758 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16085 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16086 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15759 | 16087 | } |
---|
15760 | 16088 | } |
---|
15761 | 16089 | |
---|
15762 | | - info.g = gr; |
---|
15763 | | - info.camera = renderCamera; |
---|
| 16090 | + object.clickInfo.g = gr; |
---|
| 16091 | + object.clickInfo.camera = renderCamera; |
---|
15764 | 16092 | /* |
---|
15765 | 16093 | // Memory intensive (brep.verticescopy) |
---|
15766 | 16094 | if (!(object instanceof Composite)) |
---|
15767 | 16095 | object.draw(info, 0, false); // SLOW : |
---|
15768 | 16096 | */ |
---|
15769 | | - if (!isRenderer) |
---|
| 16097 | + if (!isRenderer) // && drag) |
---|
15770 | 16098 | { |
---|
15771 | 16099 | Grafreed.Assert(object != null); |
---|
15772 | 16100 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15774 | 16102 | { |
---|
15775 | 16103 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15776 | 16104 | |
---|
15777 | | - info.DX = 0; |
---|
15778 | | - info.DY = 0; |
---|
15779 | | - info.W = 1; |
---|
| 16105 | + object.clickInfo.DX = 0; |
---|
| 16106 | + object.clickInfo.DY = 0; |
---|
| 16107 | + object.clickInfo.W = 1; |
---|
15780 | 16108 | if (hitSomething == Object3D.hitCenter) |
---|
15781 | 16109 | { |
---|
15782 | 16110 | info.DX = X; |
---|
.. | .. |
---|
15788 | 16116 | info.DY -= info.bounds.height/2; |
---|
15789 | 16117 | } |
---|
15790 | 16118 | |
---|
15791 | | - object.drawEditHandles(info, 0); |
---|
| 16119 | + object.drawEditHandles(//info, |
---|
| 16120 | + 0); |
---|
15792 | 16121 | |
---|
15793 | 16122 | if (drag && (X != 0 || Y != 0)) |
---|
15794 | 16123 | { |
---|
.. | .. |
---|
16287 | 16616 | private /*static*/ boolean firstime; |
---|
16288 | 16617 | private /*static*/ cVector newView = new cVector(); |
---|
16289 | 16618 | 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"}; |
---|
16290 | 16621 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16291 | 16622 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16292 | 16623 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16299 | 16630 | { |
---|
16300 | 16631 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16301 | 16632 | |
---|
| 16633 | + int usedsuf = 0; |
---|
| 16634 | + |
---|
16302 | 16635 | for (int i = 0; i < suffixes.length; i++) |
---|
16303 | 16636 | { |
---|
16304 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16305 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16306 | | - mipmapped, |
---|
16307 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16308 | | - if (data == null) |
---|
| 16637 | + String[] suffixe = suffixes; |
---|
| 16638 | + String[] fallback = suffixes2; |
---|
| 16639 | + String[] fallfallback = suffixes3; |
---|
| 16640 | + |
---|
| 16641 | + for (int c=usedsuf; --c>=0;) |
---|
16309 | 16642 | { |
---|
16310 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16643 | +// String[] temp = suffixe; |
---|
| 16644 | +// suffixe = fallback; |
---|
| 16645 | +// fallback = fallfallback; |
---|
| 16646 | +// fallfallback = temp; |
---|
16311 | 16647 | } |
---|
| 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 | + |
---|
16312 | 16676 | //System.out.println("Target = " + targets[i]); |
---|
16313 | 16677 | cubemap.updateImage(data, targets[i]); |
---|
16314 | 16678 | } |
---|
16315 | 16679 | |
---|
16316 | 16680 | return cubemap; |
---|
16317 | 16681 | } |
---|
| 16682 | + |
---|
16318 | 16683 | int bigsphere = -1; |
---|
16319 | 16684 | |
---|
16320 | 16685 | float BGcolor = 0.5f; |
---|
16321 | 16686 | |
---|
16322 | | - private void DrawSkyBox(GL gl) |
---|
| 16687 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16688 | + |
---|
| 16689 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16323 | 16690 | { |
---|
16324 | | - if (envyoff || cubemap == null) |
---|
| 16691 | + if (//envyoff || |
---|
| 16692 | + WIREFRAME || |
---|
| 16693 | + cubemap == null) |
---|
16325 | 16694 | { |
---|
16326 | 16695 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16327 | 16696 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16336 | 16705 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16337 | 16706 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16338 | 16707 | gl.glLoadIdentity(); |
---|
| 16708 | + gl.glScalef(1,ratio,1); |
---|
16339 | 16709 | |
---|
| 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 | + |
---|
16340 | 16719 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16341 | 16720 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16342 | 16721 | |
---|
.. | .. |
---|
16368 | 16747 | { |
---|
16369 | 16748 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16370 | 16749 | } |
---|
| 16750 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16371 | 16751 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16372 | 16752 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16373 | 16753 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16626 | 17006 | //new Exception().printStackTrace(); |
---|
16627 | 17007 | System.out.println("select buffer init"); |
---|
16628 | 17008 | // Use debug pipeline |
---|
16629 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17009 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16630 | 17010 | |
---|
16631 | 17011 | GL gl = drawable.getGL(); |
---|
16632 | 17012 | |
---|
.. | .. |
---|
17172 | 17552 | gl.glFlush(); |
---|
17173 | 17553 | |
---|
17174 | 17554 | /**/ |
---|
17175 | | - 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); |
---|
17176 | 17556 | |
---|
17177 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17557 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17178 | 17558 | |
---|
| 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 | + |
---|
17179 | 17563 | double r = 0, g = 0, b = 0; |
---|
17180 | 17564 | |
---|
17181 | 17565 | double count = 0; |
---|
.. | .. |
---|
17186 | 17570 | |
---|
17187 | 17571 | double FACTOR = 1; |
---|
17188 | 17572 | |
---|
17189 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17573 | + for (int i = 0; i < depths.length; i++) |
---|
17190 | 17574 | { |
---|
17191 | 17575 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17192 | 17576 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17269 | 17653 | |
---|
17270 | 17654 | double scale = ray.z; // 1; // cos |
---|
17271 | 17655 | |
---|
17272 | | - float depth = pixels[newindex]; |
---|
| 17656 | + float depth = depths[newindex]; |
---|
17273 | 17657 | |
---|
17274 | 17658 | /* |
---|
17275 | 17659 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17466 | 17850 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17467 | 17851 | static IntBuffer bigAAbuffer; |
---|
17468 | 17852 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17469 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17853 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17470 | 17854 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17471 | 17855 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17472 | 17856 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17473 | | - 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 | + |
---|
17474 | 17861 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17475 | 17862 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17476 | 17863 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|