.. | .. |
---|
110 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 112 | static GLContext glcontext = null; |
---|
113 | | - /*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 | + |
---|
114 | 118 | boolean reverseUP = false; |
---|
115 | 119 | static boolean frozen = false; |
---|
116 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
173 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 178 | boolean anisotropy = true; |
---|
175 | 179 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 181 | |
---|
178 | 182 | boolean macromode = false; |
---|
179 | 183 | |
---|
.. | .. |
---|
188 | 192 | |
---|
189 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
190 | 194 | |
---|
191 | | - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
192 | 196 | { |
---|
193 | 197 | try |
---|
194 | 198 | { |
---|
195 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
196 | 200 | } catch (IOException e) |
---|
197 | 201 | { |
---|
198 | 202 | System.out.println("NAME = " + name); |
---|
199 | 203 | e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
200 | 205 | } |
---|
201 | 206 | } |
---|
202 | 207 | |
---|
.. | .. |
---|
2512 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2514 | 2519 | true, |
---|
2515 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2516 | 2521 | } catch (java.io.IOException e) |
---|
2517 | 2522 | { |
---|
2518 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
9233 | 9238 | |
---|
9234 | 9239 | void LoadEnvy(int which) |
---|
9235 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9236 | 9243 | String name; |
---|
9237 | 9244 | String ext; |
---|
9238 | 9245 | |
---|
.. | .. |
---|
11077 | 11084 | // |
---|
11078 | 11085 | // newenvy = -1; |
---|
11079 | 11086 | |
---|
11080 | | - if (object.skyboxname != null) |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11081 | 11088 | { |
---|
11082 | | - if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11089 | + if (cubemaprgb == null) |
---|
11083 | 11090 | { |
---|
11084 | | - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11085 | | - loadedskyboxname = object.skyboxname; |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb" + "/", "jpg", false); |
---|
11086 | 11092 | } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
11087 | 11095 | } |
---|
11088 | 11096 | else |
---|
11089 | 11097 | { |
---|
11090 | | - cubemap = null; |
---|
11091 | | - loadedskyboxname = null; |
---|
| 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; |
---|
11092 | 11115 | } |
---|
11093 | 11116 | |
---|
11094 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
16769 | 16792 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16770 | 16793 | |
---|
16771 | 16794 | cubemap.disable(); |
---|
16772 | | - ////cubemap.unbind(); |
---|
| 16795 | + //cubemap.dispose(); |
---|
| 16796 | + |
---|
16773 | 16797 | if (CULLFACE) |
---|
16774 | 16798 | { |
---|
16775 | 16799 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17533 | 17557 | gl.glFlush(); |
---|
17534 | 17558 | |
---|
17535 | 17559 | /**/ |
---|
17536 | | - 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); |
---|
17537 | 17561 | |
---|
17538 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17562 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17539 | 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 | + |
---|
17540 | 17568 | double r = 0, g = 0, b = 0; |
---|
17541 | 17569 | |
---|
17542 | 17570 | double count = 0; |
---|
.. | .. |
---|
17547 | 17575 | |
---|
17548 | 17576 | double FACTOR = 1; |
---|
17549 | 17577 | |
---|
17550 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17578 | + for (int i = 0; i < depths.length; i++) |
---|
17551 | 17579 | { |
---|
17552 | 17580 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17553 | 17581 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17630 | 17658 | |
---|
17631 | 17659 | double scale = ray.z; // 1; // cos |
---|
17632 | 17660 | |
---|
17633 | | - float depth = pixels[newindex]; |
---|
| 17661 | + float depth = depths[newindex]; |
---|
17634 | 17662 | |
---|
17635 | 17663 | /* |
---|
17636 | 17664 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17827 | 17855 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17828 | 17856 | static IntBuffer bigAAbuffer; |
---|
17829 | 17857 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17830 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17858 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17831 | 17859 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17832 | 17860 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17833 | 17861 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17834 | | - 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 | + |
---|
17835 | 17866 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17836 | 17867 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17837 | 17868 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|