.. | .. |
---|
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; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
77 | 118 | boolean reverseUP = false; |
---|
78 | 119 | static boolean frozen = false; |
---|
79 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
136 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
137 | 178 | boolean anisotropy = true; |
---|
138 | 179 | boolean softshadow = true; // slower but better false; |
---|
139 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
140 | 181 | |
---|
141 | 182 | boolean macromode = false; |
---|
142 | 183 | |
---|
.. | .. |
---|
150 | 191 | } |
---|
151 | 192 | |
---|
152 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 194 | + |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
153 | 207 | |
---|
154 | 208 | void SetAsGLRenderer(boolean b) |
---|
155 | 209 | { |
---|
.. | .. |
---|
169 | 223 | |
---|
170 | 224 | SetCamera(cam); |
---|
171 | 225 | |
---|
172 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
173 | 228 | |
---|
174 | 229 | object = o; |
---|
175 | 230 | |
---|
.. | .. |
---|
1447 | 1502 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1448 | 1503 | } |
---|
1449 | 1504 | |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
1450 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
1451 | 1508 | { |
---|
1452 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
1514 | 1571 | { |
---|
1515 | 1572 | return; |
---|
1516 | 1573 | } |
---|
1517 | | - |
---|
1518 | | - float[] colorV = new float[3]; |
---|
1519 | 1574 | |
---|
1520 | 1575 | if (false) // marked) |
---|
1521 | 1576 | { |
---|
.. | .. |
---|
2405 | 2460 | return currentGL; |
---|
2406 | 2461 | } |
---|
2407 | 2462 | |
---|
2408 | | - private BufferedImage CreateBim(TextureData texturedata) |
---|
| 2463 | + static private BufferedImage CreateBim(TextureData texturedata) |
---|
2409 | 2464 | { |
---|
2410 | | - // cache to disk |
---|
2411 | | - Buffer buffer = texturedata.getBuffer(); // getMipmapData(); |
---|
2412 | | - //buffers[0]. |
---|
2413 | | - ByteBuffer bytebuf = (ByteBuffer)buffer; // ).asIntBuffer(); |
---|
2414 | | - int[] pixels = new int[bytebuf.capacity()/3]; |
---|
2415 | | - int width = texturedata.getWidth(); //(int)Math.sqrt(pixels.length); // squared |
---|
2416 | | - int height = width; |
---|
2417 | | - for (int i=pixels.length; --i>=0;) |
---|
2418 | | - { |
---|
2419 | | - int i3 = i*3; |
---|
2420 | | - pixels[i] = 0xFF; |
---|
2421 | | - pixels[i] <<= 8; |
---|
2422 | | - pixels[i] |= bytebuf.get(i3+2) & 0xFF; |
---|
2423 | | - pixels[i] <<= 8; |
---|
2424 | | - pixels[i] |= bytebuf.get(i3+1) & 0xFF; |
---|
2425 | | - pixels[i] <<= 8; |
---|
2426 | | - pixels[i] |= bytebuf.get(i3) & 0xFF; |
---|
2427 | | - } |
---|
2428 | | - /* |
---|
2429 | | - int r=0,g=0,b=0,a=0; |
---|
2430 | | - for (int i=0; i<width; i++) |
---|
2431 | | - for (int j=0; j<height; j++) |
---|
2432 | | - { |
---|
2433 | | - int index = j*width+i; |
---|
2434 | | - int p = pixels[index]; |
---|
2435 | | - a = ((p>>24) & 0xFF); |
---|
2436 | | - r = ((p>>16) & 0xFF); |
---|
2437 | | - g = ((p>>8) & 0xFF); |
---|
2438 | | - b = (p & 0xFF); |
---|
2439 | | - pixels[index] = (a<<24) | (b<<16) | (g<<8) | r; |
---|
2440 | | - } |
---|
2441 | | - /**/ |
---|
2442 | | - BufferedImage rendImage = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB); // ImageIO.read(infile); |
---|
2443 | | - rendImage.setRGB(0,0,width,height,pixels,width*(height-1),-width); |
---|
2444 | | - return rendImage; |
---|
| 2465 | + Grafreed.Assert(texturedata != null); |
---|
| 2466 | + |
---|
| 2467 | + int width = texturedata.getWidth(); |
---|
| 2468 | + int height = texturedata.getHeight(); |
---|
| 2469 | + |
---|
| 2470 | + Buffer buffer = texturedata.getBuffer(); |
---|
| 2471 | + ByteBuffer bytebuf = (ByteBuffer)buffer; |
---|
| 2472 | + |
---|
| 2473 | + byte[] bytes = bytebuf.array(); |
---|
| 2474 | + |
---|
| 2475 | + return CreateBim(bytes, width, height); |
---|
2445 | 2476 | } |
---|
2446 | 2477 | |
---|
2447 | 2478 | /**/ |
---|
.. | .. |
---|
2452 | 2483 | |
---|
2453 | 2484 | int resolution; |
---|
2454 | 2485 | |
---|
2455 | | - CacheTexture(com.sun.opengl.util.texture.Texture tex, int res) |
---|
| 2486 | + CacheTexture(com.sun.opengl.util.texture.TextureData texdata, int res) |
---|
2456 | 2487 | { |
---|
2457 | | - texture = tex; |
---|
| 2488 | + texture = com.sun.opengl.util.texture.TextureIO.newTexture(texdata); |
---|
| 2489 | + texturedata = texdata; |
---|
2458 | 2490 | resolution = res; |
---|
2459 | 2491 | } |
---|
2460 | 2492 | } |
---|
2461 | 2493 | /**/ |
---|
2462 | 2494 | |
---|
2463 | 2495 | // TEXTURE static Texture texture; |
---|
2464 | | - static public java.util.Hashtable<String, CacheTexture> textures = new java.util.Hashtable<String, CacheTexture>(); |
---|
2465 | | - static public java.util.Hashtable<BufferedImage, CacheTexture> bimtextures = new java.util.Hashtable<BufferedImage, CacheTexture>(); |
---|
2466 | | - static public java.util.HashSet<String> usedtextures = new java.util.HashSet<String>(); |
---|
| 2496 | + static public Hashtable<cTexture, CacheTexture> texturepigment = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2497 | + static public Hashtable<cTexture, CacheTexture> texturebump = new Hashtable<cTexture, CacheTexture>(); |
---|
| 2498 | + static public Hashtable<byte[], CacheTexture> bimtextures = new Hashtable<byte[], CacheTexture>(); |
---|
| 2499 | + static public java.util.HashSet<cTexture> usedtextures = new java.util.HashSet<cTexture>(); |
---|
2467 | 2500 | |
---|
2468 | 2501 | int pigmentdepth = 0; |
---|
2469 | 2502 | public com.sun.opengl.util.texture.Texture[] pigmentstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
.. | .. |
---|
2471 | 2504 | public com.sun.opengl.util.texture.Texture[] bumpstack = new com.sun.opengl.util.texture.Texture[65536]; |
---|
2472 | 2505 | //public static String DEFAULT_TEXTURE = "DEFAULT_TEXTURE"; |
---|
2473 | 2506 | public static cTexture DEFAULT_TEXTURES = new cTexture("DEFAULT_TEXTURE" + ":" + "DEFAULT_TEXTURE_BUMP"); |
---|
2474 | | - public static String NOISE_TEXTURE = "WHITE_NOISE"; |
---|
| 2507 | + public static cTexture NOISE_TEXTURE = new cTexture("WHITE_NOISE:"); |
---|
2475 | 2508 | // public static cTexture IMMORTAL_TEXTURE = new cTexture("IMMORTAL"); |
---|
2476 | 2509 | |
---|
2477 | | - com.sun.opengl.util.texture.Texture GetResourceTexture(String name, boolean bump) |
---|
| 2510 | + com.sun.opengl.util.texture.TextureData GetResourceTexture(String name, boolean bump) |
---|
2478 | 2511 | { |
---|
2479 | 2512 | TextureData texturedata = null; |
---|
2480 | 2513 | |
---|
.. | .. |
---|
2484 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2485 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2486 | 2519 | true, |
---|
2487 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2488 | 2521 | } catch (java.io.IOException e) |
---|
2489 | 2522 | { |
---|
2490 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
2493 | 2526 | if (bump) |
---|
2494 | 2527 | texturedata = ConvertBump(texturedata, false); |
---|
2495 | 2528 | |
---|
2496 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2497 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
| 2529 | +// com.sun.opengl.util.texture.Texture texture = |
---|
| 2530 | +// com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2498 | 2531 | |
---|
2499 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2500 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2532 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
| 2533 | + //texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2501 | 2534 | |
---|
2502 | | - return texture; |
---|
| 2535 | + return texturedata; |
---|
2503 | 2536 | } |
---|
2504 | 2537 | |
---|
2505 | | - com.sun.opengl.util.texture.Texture GetBimTexture(BufferedImage name, boolean bump) |
---|
| 2538 | + com.sun.opengl.util.texture.TextureData GetBimTexture(BufferedImage bim, boolean bump) |
---|
2506 | 2539 | { |
---|
2507 | 2540 | TextureData texturedata = null; |
---|
2508 | 2541 | |
---|
.. | .. |
---|
2510 | 2543 | { |
---|
2511 | 2544 | texturedata = |
---|
2512 | 2545 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | | - name, |
---|
| 2546 | + bim, |
---|
2514 | 2547 | true); |
---|
2515 | 2548 | } catch (Exception e) |
---|
2516 | 2549 | { |
---|
.. | .. |
---|
2519 | 2552 | |
---|
2520 | 2553 | if (bump) |
---|
2521 | 2554 | texturedata = ConvertBump(texturedata, false); |
---|
2522 | | - |
---|
2523 | | - com.sun.opengl.util.texture.Texture texture = |
---|
2524 | | - com.sun.opengl.util.texture.TextureIO.newTexture(texturedata); |
---|
2525 | | - |
---|
2526 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_S, javax.media.opengl.GL.GL_REPEAT); |
---|
2527 | | - texture.setTexParameteri(javax.media.opengl.GL.GL_TEXTURE_WRAP_T, javax.media.opengl.GL.GL_REPEAT); |
---|
2528 | | - |
---|
2529 | | - return texture; |
---|
| 2555 | + |
---|
| 2556 | + return texturedata; |
---|
2530 | 2557 | } |
---|
2531 | 2558 | |
---|
2532 | 2559 | boolean HUESMOOTH = true; // wrap around bug... true; |
---|
.. | .. |
---|
8014 | 8041 | pigment = null; |
---|
8015 | 8042 | } |
---|
8016 | 8043 | |
---|
8017 | | - ReleaseTexture(bump, true); |
---|
8018 | | - ReleaseTexture(pigment, false); |
---|
| 8044 | + ReleaseTexture(tex, true); |
---|
| 8045 | + ReleaseTexture(tex, false); |
---|
8019 | 8046 | } |
---|
8020 | 8047 | |
---|
8021 | 8048 | public void ReleasePigmentTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8044 | 8071 | pigment = null; |
---|
8045 | 8072 | } |
---|
8046 | 8073 | |
---|
8047 | | - ReleaseTexture(pigment, false); |
---|
| 8074 | + ReleaseTexture(tex, false); |
---|
8048 | 8075 | } |
---|
8049 | 8076 | |
---|
8050 | 8077 | public void ReleaseBumpTexture(cTexture tex) // INTERFACE |
---|
.. | .. |
---|
8073 | 8100 | bump = null; |
---|
8074 | 8101 | } |
---|
8075 | 8102 | |
---|
8076 | | - ReleaseTexture(bump, true); |
---|
| 8103 | + ReleaseTexture(tex, true); |
---|
8077 | 8104 | } |
---|
8078 | 8105 | |
---|
8079 | | - void ReleaseTexture(String tex, boolean bump) |
---|
| 8106 | + void ReleaseTexture(cTexture tex, boolean bump) |
---|
8080 | 8107 | { |
---|
8081 | 8108 | if (// DrawMode() != 0 || /*tex == null ||*/ |
---|
8082 | 8109 | ambientOcclusion ) // || !textureon) |
---|
.. | .. |
---|
8087 | 8114 | CacheTexture/*com.sun.opengl.util.texture.Texture*/ texture = null; |
---|
8088 | 8115 | |
---|
8089 | 8116 | if (tex != null) |
---|
8090 | | - texture = textures.get(tex); |
---|
| 8117 | + texture = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8091 | 8118 | |
---|
8092 | 8119 | // //assert( texture != null ); |
---|
8093 | 8120 | // if (texture == null) |
---|
.. | .. |
---|
8237 | 8264 | |
---|
8238 | 8265 | if (tex == null) |
---|
8239 | 8266 | { |
---|
8240 | | - BindTexture(null, null,false,resolution); |
---|
| 8267 | + BindTexture(null,false,resolution); |
---|
8241 | 8268 | return; |
---|
8242 | 8269 | } |
---|
8243 | 8270 | |
---|
8244 | 8271 | String pigment = Object3D.GetPigment(tex); |
---|
8245 | 8272 | |
---|
8246 | | - usedtextures.add(pigment); |
---|
| 8273 | + usedtextures.add(tex); |
---|
8247 | 8274 | |
---|
8248 | 8275 | //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8249 | 8276 | { |
---|
.. | .. |
---|
8257 | 8284 | } |
---|
8258 | 8285 | |
---|
8259 | 8286 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8260 | | - BindTexture(tex.pigmenttexture, pigment, false, resolution); |
---|
| 8287 | + BindTexture(tex, false, resolution); |
---|
8261 | 8288 | } |
---|
8262 | 8289 | |
---|
8263 | 8290 | /*boolean*/ public void BindBumpTexture(cTexture tex, int resolution) throws Exception // INTERFACE |
---|
.. | .. |
---|
8270 | 8297 | |
---|
8271 | 8298 | if (tex == null) |
---|
8272 | 8299 | { |
---|
8273 | | - BindTexture(null, null,true,resolution); |
---|
| 8300 | + BindTexture(null,true,resolution); |
---|
8274 | 8301 | return; |
---|
8275 | 8302 | } |
---|
8276 | 8303 | |
---|
8277 | 8304 | String bump = Object3D.GetBump(tex); |
---|
8278 | 8305 | |
---|
8279 | | - usedtextures.add(bump); |
---|
| 8306 | + usedtextures.add(tex); |
---|
8280 | 8307 | |
---|
8281 | 8308 | //if (!tex.equals(":") && !tex.equals(DEFAULT_TEXTURES)) |
---|
8282 | 8309 | { |
---|
.. | .. |
---|
8290 | 8317 | } |
---|
8291 | 8318 | |
---|
8292 | 8319 | GetGL().glActiveTexture(GetGL().GL_TEXTURE2); |
---|
8293 | | - BindTexture(tex.bumptexture, bump, true, resolution); |
---|
| 8320 | + BindTexture(tex, true, resolution); |
---|
8294 | 8321 | GetGL().glActiveTexture(GetGL().GL_TEXTURE0); |
---|
8295 | 8322 | } |
---|
8296 | 8323 | |
---|
.. | .. |
---|
8314 | 8341 | return fileExists; |
---|
8315 | 8342 | } |
---|
8316 | 8343 | |
---|
8317 | | - CacheTexture GetCacheTexture(java.awt.image.BufferedImage bim, String tex, boolean bump, int resolution) throws Exception |
---|
| 8344 | + CacheTexture GetCacheTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8318 | 8345 | { |
---|
8319 | 8346 | CacheTexture texturecache = null; |
---|
8320 | 8347 | |
---|
8321 | 8348 | if (tex != null) |
---|
8322 | 8349 | { |
---|
8323 | | - String texname = tex; |
---|
| 8350 | + String texname = bump ? Object3D.GetBump(tex) : Object3D.GetPigment(tex); |
---|
| 8351 | + byte[] texdata = bump ? tex.bumpdata : tex.pigmentdata; |
---|
| 8352 | + |
---|
| 8353 | + if (texname.equals("") && texdata == null) |
---|
| 8354 | + { |
---|
| 8355 | + return null; |
---|
| 8356 | + } |
---|
8324 | 8357 | |
---|
8325 | 8358 | String fallbackTextureName = defaultDirectory + "/Textures/" + texname; |
---|
8326 | 8359 | |
---|
.. | .. |
---|
8330 | 8363 | // else |
---|
8331 | 8364 | // if (!texname.startsWith("/")) |
---|
8332 | 8365 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8333 | | - if (!FileExists(tex)) |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8334 | 8367 | { |
---|
8335 | 8368 | texname = fallbackTextureName; |
---|
8336 | 8369 | } |
---|
8337 | 8370 | |
---|
8338 | 8371 | if (CACHETEXTURE) |
---|
8339 | 8372 | { |
---|
8340 | | - if (bim == null) |
---|
8341 | | - texturecache = textures.get(texname); // TEXTURE CACHE |
---|
| 8373 | + if (texdata == null) |
---|
| 8374 | + texturecache = bump ? texturebump.get(tex) : texturepigment.get(tex); |
---|
8342 | 8375 | else |
---|
8343 | | - texturecache = bimtextures.get(bim); // TEXTURE CACHE |
---|
| 8376 | + texturecache = bimtextures.get(texdata); |
---|
8344 | 8377 | } |
---|
8345 | 8378 | |
---|
8346 | | - if (texturecache == null || texturecache.resolution < resolution) |
---|
| 8379 | + if (texturecache == null || texturecache.resolution != -1 && texturecache.resolution < resolution) |
---|
8347 | 8380 | { |
---|
8348 | 8381 | TextureData texturedata = null; |
---|
8349 | 8382 | |
---|
8350 | | - if (bim != null) |
---|
| 8383 | + if (texdata != null && textureon) |
---|
8351 | 8384 | { |
---|
| 8385 | + BufferedImage bim; // = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8386 | + |
---|
| 8387 | + try |
---|
| 8388 | + { |
---|
| 8389 | + bim = DecompressJPEG(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8390 | + } |
---|
| 8391 | + catch (Exception e) |
---|
| 8392 | + { |
---|
| 8393 | + bim = CreateBim(texdata, bump?tex.bw:tex.pw, bump?tex.bh:tex.ph); |
---|
| 8394 | + } |
---|
| 8395 | + |
---|
8352 | 8396 | texturecache = new CacheTexture(GetBimTexture(bim, bump), -1); |
---|
| 8397 | + bimtextures.put(texdata, texturecache); |
---|
| 8398 | + |
---|
| 8399 | + //BufferedImage bim3 = new BufferedImage(bump?tex.bw:tex.pw, bump?tex.bh:tex.ph, BufferedImage.TYPE_INT_RGB); |
---|
| 8400 | + |
---|
| 8401 | + //Object bim2 = CreateBim(texturecache.texturedata); |
---|
| 8402 | + //bim2 = bim; |
---|
8353 | 8403 | } |
---|
8354 | 8404 | else |
---|
8355 | | - if (tex.equals("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
| 8405 | + if (texname.endsWith("DEFAULT_TEXTURE")) // ||*/ tex.equals("")) |
---|
8356 | 8406 | { |
---|
8357 | 8407 | assert(!bump); |
---|
8358 | 8408 | // if (bump) |
---|
.. | .. |
---|
8363 | 8413 | // } |
---|
8364 | 8414 | // else |
---|
8365 | 8415 | // { |
---|
8366 | | - texturecache = textures.get(tex); |
---|
| 8416 | + // texturecache = textures.get(texname); // suspicious |
---|
8367 | 8417 | if (texturecache == null) |
---|
8368 | 8418 | { |
---|
8369 | 8419 | texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
.. | .. |
---|
8372 | 8422 | new Exception().printStackTrace(); |
---|
8373 | 8423 | // } |
---|
8374 | 8424 | } else |
---|
8375 | | - if (tex.equals("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
| 8425 | + if (texname.endsWith("DEFAULT_TEXTURE_BUMP")) // ||*/ tex.equals("")) |
---|
8376 | 8426 | { |
---|
8377 | 8427 | assert(bump); |
---|
8378 | | - texturecache = textures.get(tex); |
---|
| 8428 | + // texturecache = textures.get(texname); // suspicious |
---|
8379 | 8429 | if (texturecache == null) |
---|
8380 | 8430 | texturecache = new CacheTexture(GetResourceTexture("default.png", bump),resolution); |
---|
8381 | 8431 | else |
---|
.. | .. |
---|
8387 | 8437 | // texture = GetResourceTexture("default.png"); |
---|
8388 | 8438 | //} else |
---|
8389 | 8439 | //{ |
---|
8390 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 8440 | + if (texname.endsWith("WHITE_NOISE")) |
---|
8391 | 8441 | { |
---|
8392 | | - texturecache = textures.get(tex); |
---|
| 8442 | + // texturecache = textures.get(texname); // suspicious |
---|
8393 | 8443 | if (texturecache == null) |
---|
8394 | 8444 | texturecache = new CacheTexture(GetResourceTexture("whitenoise.png", bump),resolution); |
---|
| 8445 | + else |
---|
| 8446 | + new Exception().printStackTrace(); |
---|
| 8447 | + } else |
---|
| 8448 | + { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
8395 | 8454 | else |
---|
8396 | 8455 | new Exception().printStackTrace(); |
---|
8397 | 8456 | } else |
---|
.. | .. |
---|
8452 | 8511 | if (texturedata == null) |
---|
8453 | 8512 | throw new Exception(); |
---|
8454 | 8513 | |
---|
8455 | | - texturecache = new CacheTexture(com.sun.opengl.util.texture.TextureIO.newTexture(texturedata),resolution); |
---|
| 8514 | + texturecache = new CacheTexture(texturedata,resolution); |
---|
8456 | 8515 | //texture = GetTexture(tex, bump); |
---|
8457 | 8516 | } |
---|
| 8517 | + } |
---|
8458 | 8518 | } |
---|
8459 | 8519 | //} |
---|
8460 | 8520 | } |
---|
8461 | 8521 | |
---|
8462 | | - if (/*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
| 8522 | + if (texdata == null && /*CACHETEXTURE &&*/ texturecache != null && textureon) |
---|
8463 | 8523 | { |
---|
8464 | 8524 | //return false; |
---|
8465 | | - assert(bim == null); |
---|
8466 | 8525 | |
---|
8467 | 8526 | // System.out.println("CACHE +++++++++++++++ TEXTURE : " + texname + " (" + texture.getEstimatedMemorySize() + ")"); |
---|
8468 | 8527 | if (texturedata != null && texname.toLowerCase().endsWith(".jpg")) |
---|
.. | .. |
---|
8509 | 8568 | } |
---|
8510 | 8569 | } |
---|
8511 | 8570 | } |
---|
8512 | | - |
---|
| 8571 | + |
---|
| 8572 | + Hashtable<cTexture, CacheTexture> textures = bump ? texturebump : texturepigment; |
---|
| 8573 | + |
---|
8513 | 8574 | //System.out.println("Texture = " + tex); |
---|
8514 | | - if (textures.containsKey(texname)) |
---|
| 8575 | + if (textures.containsKey(tex)) |
---|
8515 | 8576 | { |
---|
8516 | | - CacheTexture thetex = textures.get(texname); |
---|
| 8577 | + CacheTexture thetex = textures.get(tex); |
---|
8517 | 8578 | thetex.texture.disable(); |
---|
8518 | 8579 | thetex.texture.dispose(); |
---|
8519 | | - textures.remove(texname); |
---|
| 8580 | + textures.remove(tex); |
---|
8520 | 8581 | } |
---|
8521 | 8582 | |
---|
8522 | 8583 | //texture.texturedata = texturedata; |
---|
8523 | | - textures.put(texname, texturecache); |
---|
| 8584 | + textures.put(tex, texturecache); |
---|
8524 | 8585 | |
---|
8525 | 8586 | // newtex = true; |
---|
8526 | 8587 | } |
---|
.. | .. |
---|
8541 | 8602 | |
---|
8542 | 8603 | static void EmbedTextures(cTexture tex) |
---|
8543 | 8604 | { |
---|
| 8605 | + if (tex.pigmentdata == null) |
---|
| 8606 | + { |
---|
| 8607 | + //String texname = Object3D.GetPigment(tex); |
---|
| 8608 | + |
---|
| 8609 | + CacheTexture texturecache = texturepigment.get(tex); |
---|
| 8610 | + |
---|
| 8611 | + if (texturecache != null) |
---|
| 8612 | + { |
---|
| 8613 | + tex.pw = texturecache.texturedata.getWidth(); |
---|
| 8614 | + tex.ph = texturecache.texturedata.getHeight(); |
---|
| 8615 | + tex.pigmentdata = //CompressJPEG(CreateBim |
---|
| 8616 | + ((ByteBuffer)texturecache.texturedata.getBuffer()).array() |
---|
| 8617 | + ; |
---|
| 8618 | + //, tex.pw, tex.ph), 0.5f); |
---|
| 8619 | + } |
---|
| 8620 | + } |
---|
8544 | 8621 | |
---|
| 8622 | + if (tex.bumpdata == null) |
---|
| 8623 | + { |
---|
| 8624 | + //String texname = Object3D.GetBump(tex); |
---|
| 8625 | + |
---|
| 8626 | + CacheTexture texturecache = texturebump.get(tex); |
---|
| 8627 | + |
---|
| 8628 | + if (texturecache != null) |
---|
| 8629 | + { |
---|
| 8630 | + tex.bw = texturecache.texturedata.getWidth(); |
---|
| 8631 | + tex.bh = texturecache.texturedata.getHeight(); |
---|
| 8632 | + tex.bumpdata = CompressJPEG(CreateBim(((ByteBuffer)texturecache.texturedata.getBuffer()).array(), tex.bw, tex.bh), 0.5f); |
---|
| 8633 | + } |
---|
| 8634 | + } |
---|
8545 | 8635 | } |
---|
8546 | 8636 | |
---|
8547 | | - com.sun.opengl.util.texture.Texture GetTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8637 | + com.sun.opengl.util.texture.Texture GetTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8548 | 8638 | { |
---|
8549 | | - CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
| 8639 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8550 | 8640 | |
---|
8551 | 8641 | if (bump) |
---|
8552 | 8642 | { |
---|
.. | .. |
---|
8562 | 8652 | return texture!=null?texture.texture:null; |
---|
8563 | 8653 | } |
---|
8564 | 8654 | |
---|
8565 | | - public com.sun.opengl.util.texture.TextureData GetTextureData(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8655 | + public com.sun.opengl.util.texture.TextureData GetTextureData(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8566 | 8656 | { |
---|
8567 | | - CacheTexture texture = GetCacheTexture(stream, tex, bump, resolution); |
---|
| 8657 | + CacheTexture texture = GetCacheTexture(tex, bump, resolution); |
---|
8568 | 8658 | |
---|
8569 | 8659 | return texture!=null?texture.texturedata:null; |
---|
8570 | 8660 | } |
---|
8571 | 8661 | |
---|
8572 | | - boolean BindTexture(java.awt.image.BufferedImage stream, String tex, boolean bump, int resolution) throws Exception |
---|
| 8662 | + boolean BindTexture(cTexture tex, boolean bump, int resolution) throws Exception |
---|
8573 | 8663 | { |
---|
8574 | 8664 | if (/*tex == null ||*/ ambientOcclusion ) // || !textureon) |
---|
8575 | 8665 | { |
---|
.. | .. |
---|
8578 | 8668 | |
---|
8579 | 8669 | //boolean newtex = false; |
---|
8580 | 8670 | |
---|
8581 | | - com.sun.opengl.util.texture.Texture texture = GetTexture(stream, tex, bump, resolution); |
---|
| 8671 | + com.sun.opengl.util.texture.Texture texture = GetTexture(tex, bump, resolution); |
---|
8582 | 8672 | |
---|
8583 | 8673 | if (texture == null) |
---|
8584 | 8674 | return false; |
---|
.. | .. |
---|
8611 | 8701 | return true; // Warning: not used. |
---|
8612 | 8702 | } |
---|
8613 | 8703 | |
---|
| 8704 | + public static byte[] CompressJPEG(BufferedImage image, float quality) |
---|
| 8705 | + { |
---|
| 8706 | + try |
---|
| 8707 | + { |
---|
| 8708 | + ByteArrayOutputStream baos = new ByteArrayOutputStream(); |
---|
| 8709 | + Iterator<ImageWriter> writers = ImageIO.getImageWritersByFormatName("jpg"); |
---|
| 8710 | + ImageWriter writer = writers.next(); |
---|
| 8711 | + |
---|
| 8712 | + ImageWriteParam param = writer.getDefaultWriteParam(); |
---|
| 8713 | + param.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); |
---|
| 8714 | + param.setCompressionQuality(quality); |
---|
| 8715 | + |
---|
| 8716 | + ImageOutputStream ios = ImageIO.createImageOutputStream(baos); |
---|
| 8717 | + writer.setOutput(ios); |
---|
| 8718 | + writer.write(null, new IIOImage(image, null, null), param); |
---|
| 8719 | + |
---|
| 8720 | + byte[] data = baos.toByteArray(); |
---|
| 8721 | + writer.dispose(); |
---|
| 8722 | + return data; |
---|
| 8723 | + } |
---|
| 8724 | + catch (Exception e) |
---|
| 8725 | + { |
---|
| 8726 | + e.printStackTrace(); |
---|
| 8727 | + return null; |
---|
| 8728 | + } |
---|
| 8729 | + } |
---|
| 8730 | + |
---|
| 8731 | + public static BufferedImage DecompressJPEG(byte[] image, int w, int h) throws IOException |
---|
| 8732 | + { |
---|
| 8733 | + ByteArrayInputStream baos = new ByteArrayInputStream(image); |
---|
| 8734 | + Iterator<ImageReader> writers = ImageIO.getImageReadersByFormatName("jpg"); |
---|
| 8735 | + ImageReader reader = writers.next(); |
---|
| 8736 | + |
---|
| 8737 | + BufferedImage bim = new BufferedImage(w, h, BufferedImage.TYPE_INT_RGB); |
---|
| 8738 | + |
---|
| 8739 | + ImageReadParam param = reader.getDefaultReadParam(); |
---|
| 8740 | + param.setDestination(bim); |
---|
| 8741 | + //param.setDestinationType(ImageTypeSpecifier.createFromBufferedImageType(BufferedImage.TYPE_INT_RGB)); |
---|
| 8742 | + |
---|
| 8743 | + ImageInputStream ios = ImageIO.createImageInputStream(baos); |
---|
| 8744 | + reader.setInput(ios); |
---|
| 8745 | + BufferedImage bim2 = reader.read(0, param); |
---|
| 8746 | + reader.dispose(); |
---|
| 8747 | + |
---|
| 8748 | +// WritableRaster raster = bim2.getRaster(); |
---|
| 8749 | +// DataBufferByte data = (DataBufferByte) raster.getDataBuffer(); |
---|
| 8750 | +// byte[] bytes = data.getData(); |
---|
| 8751 | +// |
---|
| 8752 | +// int[] pixels = new int[bytes.length/3]; |
---|
| 8753 | +// for (int i=pixels.length; --i>=0;) |
---|
| 8754 | +// { |
---|
| 8755 | +// int i3 = i*3; |
---|
| 8756 | +// pixels[i] = 0xFF; |
---|
| 8757 | +// pixels[i] <<= 8; |
---|
| 8758 | +// pixels[i] |= bytes[i3+2] & 0xFF; |
---|
| 8759 | +// pixels[i] <<= 8; |
---|
| 8760 | +// pixels[i] |= bytes[i3+1] & 0xFF; |
---|
| 8761 | +// pixels[i] <<= 8; |
---|
| 8762 | +// pixels[i] |= bytes[i3] & 0xFF; |
---|
| 8763 | +// } |
---|
| 8764 | +// |
---|
| 8765 | +// bim.setRGB(0,0,w,h, pixels, w*(h-1),-w); |
---|
| 8766 | + |
---|
| 8767 | + return bim; |
---|
| 8768 | + } |
---|
| 8769 | + |
---|
8614 | 8770 | ShadowBuffer shadowPBuf; |
---|
8615 | 8771 | AntialiasBuffer antialiasPBuf; |
---|
8616 | 8772 | int MAXSTACK; |
---|
.. | .. |
---|
8627 | 8783 | |
---|
8628 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8629 | 8785 | MAXSTACK = temp[0]; |
---|
8630 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8631 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8632 | 8789 | MAXSTACK = temp[0]; |
---|
8633 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8634 | 8792 | |
---|
8635 | 8793 | // Use debug pipeline |
---|
8636 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8638 | 8796 | gl = drawable.getGL(); // |
---|
8639 | 8797 | |
---|
8640 | 8798 | GL gl3 = getGL(); |
---|
8641 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8642 | 8801 | |
---|
8643 | 8802 | |
---|
8644 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8803 | 8962 | |
---|
8804 | 8963 | if (cubemap == null) |
---|
8805 | 8964 | { |
---|
8806 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
8807 | 8966 | } |
---|
8808 | 8967 | |
---|
8809 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
9079 | 9238 | |
---|
9080 | 9239 | void LoadEnvy(int which) |
---|
9081 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9082 | 9243 | String name; |
---|
9083 | 9244 | String ext; |
---|
9084 | 9245 | |
---|
.. | .. |
---|
9090 | 9251 | cubemap = null; |
---|
9091 | 9252 | return; |
---|
9092 | 9253 | case 1: |
---|
9093 | | - name = "cubemaps/box_"; |
---|
9094 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
9095 | 9256 | reverseUP = false; |
---|
9096 | 9257 | break; |
---|
9097 | 9258 | case 2: |
---|
9098 | | - name = "cubemaps/uffizi_"; |
---|
9099 | | - ext = "png"; |
---|
9100 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
9101 | 9263 | case 3: |
---|
9102 | | - name = "cubemaps/CloudyHills_"; |
---|
9103 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
9104 | 9266 | reverseUP = false; |
---|
9105 | 9267 | break; |
---|
9106 | 9268 | case 4: |
---|
9107 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
9108 | 9270 | ext = "png"; |
---|
9109 | 9271 | reverseUP = false; |
---|
9110 | 9272 | break; |
---|
| 9273 | + case 5: |
---|
| 9274 | + name = "cubemaps/skycube/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 6: |
---|
| 9279 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 7: |
---|
| 9284 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
| 9288 | + case 8: |
---|
| 9289 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9290 | + ext = "jpg"; |
---|
| 9291 | + reverseUP = false; |
---|
| 9292 | + break; |
---|
| 9293 | + case 9: |
---|
| 9294 | + name = "cubemaps/UnionSquare/"; |
---|
| 9295 | + ext = "jpg"; |
---|
| 9296 | + reverseUP = false; |
---|
| 9297 | + break; |
---|
9111 | 9298 | default: |
---|
9112 | | - name = "cubemaps/rgb_"; |
---|
9113 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
9114 | 9302 | break; |
---|
9115 | 9303 | } |
---|
9116 | | - |
---|
9117 | | - try |
---|
9118 | | - { |
---|
9119 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9120 | | - } catch (IOException e) |
---|
9121 | | - { |
---|
9122 | | - throw new RuntimeException(e); |
---|
9123 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
9124 | 9306 | } |
---|
9125 | 9307 | |
---|
9126 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9152 | 9334 | static double[] model = new double[16]; |
---|
9153 | 9335 | double[] camera2light = new double[16]; |
---|
9154 | 9336 | double[] light2camera = new double[16]; |
---|
9155 | | - int newenvy = -1; |
---|
9156 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
9157 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9158 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
9159 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9571 | 9757 | |
---|
9572 | 9758 | if (renderCamera != lightCamera) |
---|
9573 | 9759 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9574 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9575 | 9761 | |
---|
9576 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9577 | 9763 | |
---|
.. | .. |
---|
9587 | 9773 | |
---|
9588 | 9774 | if (renderCamera != lightCamera) |
---|
9589 | 9775 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9590 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9591 | 9777 | |
---|
9592 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9593 | 9779 | |
---|
.. | .. |
---|
9633 | 9819 | rati = 1 / rati; |
---|
9634 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9635 | 9821 | } |
---|
9636 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
9637 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9638 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9639 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
9640 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9641 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9642 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10673 | 10861 | |
---|
10674 | 10862 | if (wait) |
---|
10675 | 10863 | { |
---|
10676 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
10677 | 10865 | |
---|
10678 | 10866 | wait = false; |
---|
10679 | 10867 | } |
---|
.. | .. |
---|
10788 | 10976 | // if (parentcam != renderCamera) // not a light |
---|
10789 | 10977 | if (cam != lightCamera) |
---|
10790 | 10978 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10791 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10979 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10792 | 10980 | |
---|
10793 | 10981 | for (int j = 0; j < 4; j++) |
---|
10794 | 10982 | { |
---|
.. | .. |
---|
10803 | 10991 | // if (parentcam != renderCamera) // not a light |
---|
10804 | 10992 | if (cam != lightCamera) |
---|
10805 | 10993 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10806 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10994 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10807 | 10995 | |
---|
10808 | 10996 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10809 | 10997 | |
---|
.. | .. |
---|
10889 | 11077 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
10890 | 11078 | } |
---|
10891 | 11079 | |
---|
10892 | | - if (newenvy > -1) |
---|
| 11080 | +// if (newenvy > -1) |
---|
| 11081 | +// { |
---|
| 11082 | +// LoadEnvy(newenvy); |
---|
| 11083 | +// } |
---|
| 11084 | +// |
---|
| 11085 | +// newenvy = -1; |
---|
| 11086 | + |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
10893 | 11088 | { |
---|
10894 | | - LoadEnvy(newenvy); |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
10895 | 11095 | } |
---|
10896 | | - |
---|
10897 | | - newenvy = -1; |
---|
10898 | | - |
---|
| 11096 | + else |
---|
| 11097 | + { |
---|
| 11098 | + if (object.skyboxname != null) |
---|
| 11099 | + { |
---|
| 11100 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11101 | + { |
---|
| 11102 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11103 | + cubemap.dispose(); |
---|
| 11104 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11105 | + loadedskyboxname = object.skyboxname; |
---|
| 11106 | + } |
---|
| 11107 | + } |
---|
| 11108 | + else |
---|
| 11109 | + { |
---|
| 11110 | + cubemapcustom = null; |
---|
| 11111 | + loadedskyboxname = null; |
---|
| 11112 | + } |
---|
| 11113 | + |
---|
| 11114 | + cubemap = cubemapcustom; |
---|
| 11115 | + } |
---|
| 11116 | + |
---|
10899 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
10900 | 11118 | //System.out.println("ratio = " + ratio); |
---|
10901 | 11119 | |
---|
.. | .. |
---|
10911 | 11129 | |
---|
10912 | 11130 | if (!IsFrozen() && !ambientOcclusion) |
---|
10913 | 11131 | { |
---|
10914 | | - DrawSkyBox(gl); |
---|
| 11132 | + DrawSkyBox(gl, (float)ratio); |
---|
10915 | 11133 | } |
---|
10916 | 11134 | |
---|
10917 | 11135 | //if (selection_view == -1) |
---|
.. | .. |
---|
11065 | 11283 | |
---|
11066 | 11284 | try |
---|
11067 | 11285 | { |
---|
11068 | | - BindTexture(null, NOISE_TEXTURE, false, 2); |
---|
| 11286 | + BindTexture(NOISE_TEXTURE, false, 2); |
---|
11069 | 11287 | } |
---|
11070 | 11288 | catch (Exception e) |
---|
11071 | 11289 | { |
---|
.. | .. |
---|
11197 | 11415 | |
---|
11198 | 11416 | // if (cam != lightCamera) |
---|
11199 | 11417 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11200 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11201 | 11419 | } |
---|
11202 | 11420 | |
---|
11203 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
11356 | 11574 | } |
---|
11357 | 11575 | } |
---|
11358 | 11576 | |
---|
11359 | | - if (false) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
| 11577 | + if (false) //RENDERPROGRAM > 0 && DrawMode() == DEFAULT) // fast && !IsFreezed() && DrawMode() != SELECTION && !ambientOcclusion) |
---|
11360 | 11578 | { |
---|
11361 | 11579 | //gl.glDepthFunc(GL.GL_LEQUAL); |
---|
11362 | 11580 | //gl.glClear(gl.GL_COLOR_BUFFER_BIT | gl.GL_DEPTH_BUFFER_BIT); |
---|
.. | .. |
---|
11364 | 11582 | |
---|
11365 | 11583 | boolean texon = textureon; |
---|
11366 | 11584 | |
---|
11367 | | - if (RENDERPROGRAM > 0) |
---|
11368 | | - { |
---|
11369 | | - gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11370 | | - textureon = false; |
---|
11371 | | - } |
---|
| 11585 | + gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11586 | + textureon = false; |
---|
| 11587 | + |
---|
11372 | 11588 | //gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
11373 | 11589 | //System.out.println("ALLO"); |
---|
11374 | 11590 | gl.glColorMask(false, false, false, false); |
---|
11375 | 11591 | DrawObject(gl); |
---|
11376 | | - if (RENDERPROGRAM > 0) |
---|
11377 | | - { |
---|
11378 | | - gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
11379 | | - textureon = texon; |
---|
11380 | | - } |
---|
| 11592 | + |
---|
| 11593 | + gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
| 11594 | + textureon = texon; |
---|
| 11595 | + |
---|
11381 | 11596 | gl.glColorMask(true, true, true, true); |
---|
11382 | 11597 | |
---|
11383 | 11598 | gl.glDepthFunc(GL.GL_EQUAL); |
---|
11384 | | - //gl.glDepthMask(false); |
---|
| 11599 | + gl.glDepthMask(false); |
---|
11385 | 11600 | } |
---|
11386 | 11601 | |
---|
11387 | 11602 | if (false) // DrawMode() == SHADOW) |
---|
.. | .. |
---|
11721 | 11936 | ReleaseTextures(DEFAULT_TEXTURES); |
---|
11722 | 11937 | |
---|
11723 | 11938 | if (CLEANCACHE) |
---|
11724 | | - for (java.util.Enumeration<String> e = textures.keys() ; e.hasMoreElements();) |
---|
| 11939 | + for (java.util.Enumeration<cTexture> e = texturepigment.keys() ; e.hasMoreElements();) |
---|
11725 | 11940 | { |
---|
11726 | | - String tex = e.nextElement(); |
---|
| 11941 | + cTexture tex = e.nextElement(); |
---|
11727 | 11942 | |
---|
11728 | 11943 | // System.out.println("Texture --------- " + tex); |
---|
11729 | 11944 | |
---|
11730 | | - if (tex.equals("WHITE_NOISE")) |
---|
| 11945 | + if (tex.equals("WHITE_NOISE:")) |
---|
11731 | 11946 | continue; |
---|
11732 | 11947 | |
---|
11733 | 11948 | if (!usedtextures.contains(tex)) |
---|
11734 | 11949 | { |
---|
| 11950 | + CacheTexture gettex = texturepigment.get(tex); |
---|
11735 | 11951 | // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
11736 | | - textures.get(tex).texture.dispose(); |
---|
11737 | | - textures.remove(tex); |
---|
| 11952 | + if (gettex != null) |
---|
| 11953 | + { |
---|
| 11954 | + gettex.texture.dispose(); |
---|
| 11955 | + texturepigment.remove(tex); |
---|
| 11956 | + } |
---|
| 11957 | + |
---|
| 11958 | + gettex = texturebump.get(tex); |
---|
| 11959 | + // System.out.println("DISPOSE +++++++++++++++ " + tex); |
---|
| 11960 | + if (gettex != null) |
---|
| 11961 | + { |
---|
| 11962 | + gettex.texture.dispose(); |
---|
| 11963 | + texturebump.remove(tex); |
---|
| 11964 | + } |
---|
11738 | 11965 | } |
---|
11739 | 11966 | } |
---|
11740 | 11967 | } |
---|
.. | .. |
---|
12262 | 12489 | |
---|
12263 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12264 | 12491 | |
---|
12265 | | - String program = |
---|
| 12492 | + String programmin = |
---|
| 12493 | + // Min shader |
---|
12266 | 12494 | "!!ARBfp1.0\n" + |
---|
| 12495 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12496 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12497 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12498 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12499 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12500 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12501 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12502 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12503 | + "TEMP temp;" + |
---|
| 12504 | + "TEMP light;" + |
---|
| 12505 | + "TEMP ndotl;" + |
---|
| 12506 | + "TEMP normal;" + |
---|
| 12507 | + "TEMP depth;" + |
---|
| 12508 | + "TEMP eye;" + |
---|
| 12509 | + "TEMP pos;" + |
---|
| 12510 | + |
---|
| 12511 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12512 | + Normalize("normal") + |
---|
| 12513 | + "MOV light, state.light[0].position;" + |
---|
| 12514 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12515 | + |
---|
| 12516 | + // shadow |
---|
| 12517 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12518 | + "MOV temp, pos;" + |
---|
| 12519 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12520 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12521 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12522 | + |
---|
| 12523 | + // No shadow when out of frustum |
---|
| 12524 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12525 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12526 | + |
---|
| 12527 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12528 | + |
---|
| 12529 | + // Backlit |
---|
| 12530 | + "MOV pos.w, zero123.y;" + |
---|
| 12531 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12532 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12533 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12534 | + Normalize("eye") + |
---|
| 12535 | + |
---|
| 12536 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12537 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12538 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12539 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12540 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12541 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12542 | + |
---|
| 12543 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12544 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12545 | + |
---|
| 12546 | + // Pigment |
---|
| 12547 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12548 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12549 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL temp, temp, zero123.z;" + |
---|
| 12552 | + |
---|
| 12553 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12554 | + |
---|
| 12555 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12556 | + "MOV result.color, temp;" + |
---|
| 12557 | + "END"; |
---|
| 12558 | + |
---|
| 12559 | + String programmax = |
---|
| 12560 | + "!!ARBfp1.0\n" + |
---|
| 12561 | + |
---|
12267 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12268 | 12563 | "PARAM light2cam0 = program.env[10];" + |
---|
12269 | 12564 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12378 | 12673 | "TEMP shininess;" + |
---|
12379 | 12674 | "\n" + |
---|
12380 | 12675 | "MOV texSamp, one;" + |
---|
12381 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12382 | | - |
---|
| 12676 | + |
---|
12383 | 12677 | "MOV mapgrid.x, one2048th.x;" + |
---|
12384 | 12678 | "MOV temp, fragment.texcoord[1];" + |
---|
12385 | 12679 | /* |
---|
.. | .. |
---|
12400 | 12694 | "MUL temp, floor, mapgrid.x;" + |
---|
12401 | 12695 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12402 | 12696 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12403 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12697 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12404 | 12698 | "") + |
---|
12405 | 12699 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12406 | 12700 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12407 | 12701 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12408 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12409 | 12703 | "") + |
---|
12410 | 12704 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12411 | 12705 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12412 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12413 | 12707 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12414 | 12708 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12415 | 12709 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12416 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12710 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12417 | 12711 | "") + |
---|
12418 | 12712 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12419 | 12713 | //"MOV params, material;" + |
---|
.. | .. |
---|
12784 | 13078 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12785 | 13079 | "") + |
---|
12786 | 13080 | |
---|
12787 | | - // display shadow only (bump == 0) |
---|
| 13081 | + // display shadow only (fakedepth == 0) |
---|
12788 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
12789 | 13083 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12790 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12791 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
12792 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
12793 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
13118 | 13412 | //once = true; |
---|
13119 | 13413 | } |
---|
13120 | 13414 | |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
13121 | 13422 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13122 | 13423 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13123 | 13424 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13211 | 13512 | return out; |
---|
13212 | 13513 | } |
---|
13213 | 13514 | |
---|
13214 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13515 | + // Also does frustum culling |
---|
| 13516 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13215 | 13517 | { |
---|
13216 | 13518 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13217 | 13519 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13218 | 13520 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13521 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13522 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13219 | 13523 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13220 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13221 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13222 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13223 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13524 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13525 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13224 | 13526 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13225 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13527 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13226 | 13528 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13227 | 13529 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13228 | 13530 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13229 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13531 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13230 | 13532 | |
---|
13231 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13232 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13533 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13534 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13233 | 13535 | } |
---|
13234 | 13536 | |
---|
13235 | 13537 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13276 | 13578 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13277 | 13579 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13278 | 13580 | |
---|
13279 | | - // No shadow when out of frustrum |
---|
| 13581 | + // No shadow when out of frustum |
---|
13280 | 13582 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13281 | 13583 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13282 | 13584 | ""; |
---|
.. | .. |
---|
14074 | 14376 | drag = false; |
---|
14075 | 14377 | //System.out.println("Mouse DOWN"); |
---|
14076 | 14378 | editObj = false; |
---|
14077 | | - ClickInfo info = new ClickInfo(); |
---|
14078 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14079 | | - info.pane = this; |
---|
14080 | | - info.camera = renderCamera; |
---|
14081 | | - info.x = x; |
---|
14082 | | - info.y = y; |
---|
14083 | | - info.modifiers = modifiersex; |
---|
14084 | | - editObj = object.doEditClick(info, 0); |
---|
| 14379 | + //ClickInfo info = new ClickInfo(); |
---|
| 14380 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14381 | + object.clickInfo.pane = this; |
---|
| 14382 | + object.clickInfo.camera = renderCamera; |
---|
| 14383 | + object.clickInfo.x = x; |
---|
| 14384 | + object.clickInfo.y = y; |
---|
| 14385 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14386 | + editObj = object.doEditClick(//info, |
---|
| 14387 | + 0); |
---|
14085 | 14388 | if (!editObj) |
---|
14086 | 14389 | { |
---|
14087 | 14390 | hasMarquee = true; |
---|
.. | .. |
---|
14365 | 14668 | MODIFIERS |= COMMAND; |
---|
14366 | 14669 | /**/ |
---|
14367 | 14670 | if((mod&SHIFT) == SHIFT) |
---|
14368 | | - manipCamera.RotatePosition(0, -speed); |
---|
14369 | | - else |
---|
14370 | 14671 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14672 | + else |
---|
| 14673 | + manipCamera.RotatePosition(0, -speed); |
---|
14371 | 14674 | /**/ |
---|
14372 | 14675 | if ((mod & SHIFT) == SHIFT) |
---|
14373 | 14676 | { |
---|
.. | .. |
---|
14386 | 14689 | MODIFIERS |= COMMAND; |
---|
14387 | 14690 | /**/ |
---|
14388 | 14691 | if((mod&SHIFT) == SHIFT) |
---|
14389 | | - manipCamera.RotatePosition(0, speed); |
---|
14390 | | - else |
---|
14391 | 14692 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14693 | + else |
---|
| 14694 | + manipCamera.RotatePosition(0, speed); |
---|
14392 | 14695 | /**/ |
---|
14393 | 14696 | if ((mod & SHIFT) == SHIFT) |
---|
14394 | 14697 | { |
---|
.. | .. |
---|
14481 | 14784 | if (editObj) |
---|
14482 | 14785 | { |
---|
14483 | 14786 | drag = true; |
---|
14484 | | - ClickInfo info = new ClickInfo(); |
---|
14485 | | - info.bounds.setBounds(0, 0, |
---|
| 14787 | + //ClickInfo info = new ClickInfo(); |
---|
| 14788 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14486 | 14789 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14487 | | - info.pane = this; |
---|
14488 | | - info.camera = renderCamera; |
---|
14489 | | - info.x = x; |
---|
14490 | | - info.y = y; |
---|
14491 | | - object.GetWindow().copy |
---|
14492 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14790 | + object.clickInfo.pane = this; |
---|
| 14791 | + object.clickInfo.camera = renderCamera; |
---|
| 14792 | + object.clickInfo.x = x; |
---|
| 14793 | + object.clickInfo.y = y; |
---|
| 14794 | + object //.GetWindow().copy |
---|
| 14795 | + .doEditDrag(//info, |
---|
| 14796 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14493 | 14797 | } else |
---|
14494 | 14798 | { |
---|
14495 | 14799 | if (x < startX) |
---|
.. | .. |
---|
14638 | 14942 | } |
---|
14639 | 14943 | } |
---|
14640 | 14944 | |
---|
| 14945 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14946 | + |
---|
14641 | 14947 | public void mouseMoved(MouseEvent e) |
---|
14642 | 14948 | { |
---|
14643 | 14949 | //System.out.println("mouseMoved: " + e); |
---|
14644 | 14950 | if (isRenderer) |
---|
14645 | 14951 | return; |
---|
14646 | 14952 | |
---|
14647 | | - ClickInfo ci = new ClickInfo(); |
---|
14648 | | - ci.x = e.getX(); |
---|
14649 | | - ci.y = e.getY(); |
---|
14650 | | - ci.modifiers = e.getModifiersEx(); |
---|
14651 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14652 | | - ci.pane = this; |
---|
14653 | | - ci.camera = renderCamera; |
---|
| 14953 | + // Mouse cursor feedback |
---|
| 14954 | + object.clickInfo.x = e.getX(); |
---|
| 14955 | + object.clickInfo.y = e.getY(); |
---|
| 14956 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14957 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14958 | + object.clickInfo.pane = this; |
---|
| 14959 | + object.clickInfo.camera = renderCamera; |
---|
14654 | 14960 | if (!isRenderer) |
---|
14655 | 14961 | { |
---|
14656 | 14962 | //ObjEditor editWindow = object.editWindow; |
---|
14657 | 14963 | //Object3D copy = editWindow.copy; |
---|
14658 | | - if (object.doEditClick(ci, 0)) |
---|
| 14964 | + if (object.doEditClick(//clickInfo, |
---|
| 14965 | + 0)) |
---|
14659 | 14966 | { |
---|
14660 | 14967 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14661 | 14968 | } else |
---|
.. | .. |
---|
14927 | 15234 | // break; |
---|
14928 | 15235 | case 'T': |
---|
14929 | 15236 | CACHETEXTURE ^= true; |
---|
14930 | | - textures.clear(); |
---|
| 15237 | + texturepigment.clear(); |
---|
| 15238 | + texturebump.clear(); |
---|
14931 | 15239 | // repaint(); |
---|
14932 | 15240 | break; |
---|
14933 | 15241 | case 'Y': |
---|
.. | .. |
---|
15104 | 15412 | OCCLUSION_CULLING ^= true; |
---|
15105 | 15413 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15106 | 15414 | break; |
---|
15107 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15415 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15108 | 15416 | case '1': |
---|
15109 | 15417 | case '2': |
---|
15110 | 15418 | case '3': |
---|
15111 | 15419 | case '4': |
---|
15112 | 15420 | case '5': |
---|
15113 | | - newenvy = Character.getNumericValue(key); |
---|
15114 | | - repaint(); |
---|
15115 | | - break; |
---|
15116 | 15421 | case '6': |
---|
15117 | 15422 | case '7': |
---|
15118 | 15423 | case '8': |
---|
15119 | 15424 | case '9': |
---|
15120 | | - BGcolor = (key - '6')/3.f; |
---|
| 15425 | + if (true) // envyoff) |
---|
| 15426 | + { |
---|
| 15427 | + BGcolor = (key - '1')/8.f; |
---|
| 15428 | + } |
---|
| 15429 | + else |
---|
| 15430 | + { |
---|
| 15431 | + //newenvy = Character.getNumericValue(key); |
---|
| 15432 | + } |
---|
15121 | 15433 | repaint(); |
---|
15122 | 15434 | break; |
---|
15123 | 15435 | case '!': |
---|
.. | .. |
---|
15680 | 15992 | |
---|
15681 | 15993 | int width = getBounds().width; |
---|
15682 | 15994 | int height = getBounds().height; |
---|
15683 | | - ClickInfo info = new ClickInfo(); |
---|
15684 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15685 | 15995 | //Image img = CreateImage(width, height); |
---|
15686 | 15996 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15687 | 15997 | |
---|
.. | .. |
---|
15758 | 16068 | } |
---|
15759 | 16069 | if (object != null && !hasMarquee) |
---|
15760 | 16070 | { |
---|
| 16071 | + if (object.clickInfo == null) |
---|
| 16072 | + object.clickInfo = new ClickInfo(); |
---|
| 16073 | + ClickInfo info = object.clickInfo; |
---|
| 16074 | + //ClickInfo info = new ClickInfo(); |
---|
| 16075 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16076 | + |
---|
15761 | 16077 | if (isRenderer) |
---|
15762 | 16078 | { |
---|
15763 | | - info.flags++; |
---|
| 16079 | + object.clickInfo.flags++; |
---|
15764 | 16080 | double frameAspect = (double) width / (double) height; |
---|
15765 | 16081 | if (frameAspect > renderCamera.aspect) |
---|
15766 | 16082 | { |
---|
15767 | 16083 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15768 | | - info.bounds.width -= width - desired; |
---|
15769 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16084 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16085 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15770 | 16086 | } else |
---|
15771 | 16087 | { |
---|
15772 | 16088 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15773 | | - info.bounds.height -= height - desired; |
---|
15774 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16089 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16090 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15775 | 16091 | } |
---|
15776 | 16092 | } |
---|
15777 | 16093 | |
---|
15778 | | - info.g = gr; |
---|
15779 | | - info.camera = renderCamera; |
---|
| 16094 | + object.clickInfo.g = gr; |
---|
| 16095 | + object.clickInfo.camera = renderCamera; |
---|
15780 | 16096 | /* |
---|
15781 | 16097 | // Memory intensive (brep.verticescopy) |
---|
15782 | 16098 | if (!(object instanceof Composite)) |
---|
15783 | 16099 | object.draw(info, 0, false); // SLOW : |
---|
15784 | 16100 | */ |
---|
15785 | | - if (!isRenderer) |
---|
| 16101 | + if (!isRenderer) // && drag) |
---|
15786 | 16102 | { |
---|
15787 | 16103 | Grafreed.Assert(object != null); |
---|
15788 | 16104 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15790 | 16106 | { |
---|
15791 | 16107 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15792 | 16108 | |
---|
15793 | | - info.DX = 0; |
---|
15794 | | - info.DY = 0; |
---|
15795 | | - info.W = 1; |
---|
| 16109 | + object.clickInfo.DX = 0; |
---|
| 16110 | + object.clickInfo.DY = 0; |
---|
| 16111 | + object.clickInfo.W = 1; |
---|
15796 | 16112 | if (hitSomething == Object3D.hitCenter) |
---|
15797 | 16113 | { |
---|
15798 | 16114 | info.DX = X; |
---|
.. | .. |
---|
15804 | 16120 | info.DY -= info.bounds.height/2; |
---|
15805 | 16121 | } |
---|
15806 | 16122 | |
---|
15807 | | - object.drawEditHandles(info, 0); |
---|
| 16123 | + object.drawEditHandles(//info, |
---|
| 16124 | + 0); |
---|
15808 | 16125 | |
---|
15809 | 16126 | if (drag && (X != 0 || Y != 0)) |
---|
15810 | 16127 | { |
---|
.. | .. |
---|
16303 | 16620 | private /*static*/ boolean firstime; |
---|
16304 | 16621 | private /*static*/ cVector newView = new cVector(); |
---|
16305 | 16622 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16623 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16624 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16306 | 16625 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16307 | 16626 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16308 | 16627 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16315 | 16634 | { |
---|
16316 | 16635 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16317 | 16636 | |
---|
| 16637 | + int usedsuf = 0; |
---|
| 16638 | + |
---|
16318 | 16639 | for (int i = 0; i < suffixes.length; i++) |
---|
16319 | 16640 | { |
---|
16320 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16321 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16322 | | - mipmapped, |
---|
16323 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16324 | | - if (data == null) |
---|
| 16641 | + String[] suffixe = suffixes; |
---|
| 16642 | + String[] fallback = suffixes2; |
---|
| 16643 | + String[] fallfallback = suffixes3; |
---|
| 16644 | + |
---|
| 16645 | + for (int c=usedsuf; --c>=0;) |
---|
16325 | 16646 | { |
---|
16326 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16647 | +// String[] temp = suffixe; |
---|
| 16648 | +// suffixe = fallback; |
---|
| 16649 | +// fallback = fallfallback; |
---|
| 16650 | +// fallfallback = temp; |
---|
16327 | 16651 | } |
---|
| 16652 | + |
---|
| 16653 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16654 | + TextureData data; |
---|
| 16655 | + |
---|
| 16656 | + try |
---|
| 16657 | + { |
---|
| 16658 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16659 | + mipmapped, |
---|
| 16660 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16661 | + } |
---|
| 16662 | + catch (Exception e) |
---|
| 16663 | + { |
---|
| 16664 | + try |
---|
| 16665 | + { |
---|
| 16666 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16667 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16668 | + mipmapped, |
---|
| 16669 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16670 | + } |
---|
| 16671 | + catch (Exception e2) |
---|
| 16672 | + { |
---|
| 16673 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16674 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16675 | + mipmapped, |
---|
| 16676 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16677 | + } |
---|
| 16678 | + } |
---|
| 16679 | + |
---|
16328 | 16680 | //System.out.println("Target = " + targets[i]); |
---|
16329 | 16681 | cubemap.updateImage(data, targets[i]); |
---|
16330 | 16682 | } |
---|
16331 | 16683 | |
---|
16332 | 16684 | return cubemap; |
---|
16333 | 16685 | } |
---|
| 16686 | + |
---|
16334 | 16687 | int bigsphere = -1; |
---|
16335 | 16688 | |
---|
16336 | 16689 | float BGcolor = 0.5f; |
---|
16337 | 16690 | |
---|
16338 | | - private void DrawSkyBox(GL gl) |
---|
| 16691 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16692 | + |
---|
| 16693 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16339 | 16694 | { |
---|
16340 | | - if (envyoff || cubemap == null) |
---|
| 16695 | + if (//envyoff || |
---|
| 16696 | + WIREFRAME || |
---|
| 16697 | + cubemap == null) |
---|
16341 | 16698 | { |
---|
16342 | 16699 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16343 | 16700 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16352 | 16709 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16353 | 16710 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16354 | 16711 | gl.glLoadIdentity(); |
---|
| 16712 | + gl.glScalef(1,ratio,1); |
---|
16355 | 16713 | |
---|
| 16714 | +// colorV[0] = 2; |
---|
| 16715 | +// colorV[1] = 2; |
---|
| 16716 | +// colorV[2] = 2; |
---|
| 16717 | +// colorV[3] = 1; |
---|
| 16718 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16719 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16720 | +// |
---|
| 16721 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16722 | + |
---|
16356 | 16723 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16357 | 16724 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16358 | 16725 | |
---|
.. | .. |
---|
16384 | 16751 | { |
---|
16385 | 16752 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16386 | 16753 | } |
---|
| 16754 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16387 | 16755 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16388 | 16756 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16389 | 16757 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16424 | 16792 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16425 | 16793 | |
---|
16426 | 16794 | cubemap.disable(); |
---|
16427 | | - ////cubemap.unbind(); |
---|
| 16795 | + //cubemap.dispose(); |
---|
| 16796 | + |
---|
16428 | 16797 | if (CULLFACE) |
---|
16429 | 16798 | { |
---|
16430 | 16799 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16642 | 17011 | //new Exception().printStackTrace(); |
---|
16643 | 17012 | System.out.println("select buffer init"); |
---|
16644 | 17013 | // Use debug pipeline |
---|
16645 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17014 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16646 | 17015 | |
---|
16647 | 17016 | GL gl = drawable.getGL(); |
---|
16648 | 17017 | |
---|
.. | .. |
---|
17188 | 17557 | gl.glFlush(); |
---|
17189 | 17558 | |
---|
17190 | 17559 | /**/ |
---|
17191 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17560 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17192 | 17561 | |
---|
17193 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17562 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17194 | 17563 | |
---|
| 17564 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17565 | + |
---|
| 17566 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17567 | + |
---|
17195 | 17568 | double r = 0, g = 0, b = 0; |
---|
17196 | 17569 | |
---|
17197 | 17570 | double count = 0; |
---|
.. | .. |
---|
17202 | 17575 | |
---|
17203 | 17576 | double FACTOR = 1; |
---|
17204 | 17577 | |
---|
17205 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17578 | + for (int i = 0; i < depths.length; i++) |
---|
17206 | 17579 | { |
---|
17207 | 17580 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17208 | 17581 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17285 | 17658 | |
---|
17286 | 17659 | double scale = ray.z; // 1; // cos |
---|
17287 | 17660 | |
---|
17288 | | - float depth = pixels[newindex]; |
---|
| 17661 | + float depth = depths[newindex]; |
---|
17289 | 17662 | |
---|
17290 | 17663 | /* |
---|
17291 | 17664 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17482 | 17855 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17483 | 17856 | static IntBuffer bigAAbuffer; |
---|
17484 | 17857 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17485 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17858 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17486 | 17859 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17487 | 17860 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17488 | 17861 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17489 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17862 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17863 | + |
---|
| 17864 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17865 | + |
---|
17490 | 17866 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17491 | 17867 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17492 | 17868 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|