.. | .. |
---|
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; |
---|
114 | 116 | boolean reverseUP = false; |
---|
115 | 117 | static boolean frozen = false; |
---|
116 | 118 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
173 | 175 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 176 | boolean anisotropy = true; |
---|
175 | 177 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 178 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 179 | |
---|
178 | 180 | boolean macromode = false; |
---|
179 | 181 | |
---|
.. | .. |
---|
188 | 190 | |
---|
189 | 191 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
190 | 192 | |
---|
191 | | - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 193 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
192 | 194 | { |
---|
193 | 195 | try |
---|
194 | 196 | { |
---|
195 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 197 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
196 | 198 | } catch (IOException e) |
---|
197 | 199 | { |
---|
198 | 200 | System.out.println("NAME = " + name); |
---|
199 | 201 | e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 202 | + return null; |
---|
200 | 203 | } |
---|
201 | 204 | } |
---|
202 | 205 | |
---|
.. | .. |
---|
9233 | 9236 | |
---|
9234 | 9237 | void LoadEnvy(int which) |
---|
9235 | 9238 | { |
---|
| 9239 | + assert(false); |
---|
| 9240 | + |
---|
9236 | 9241 | String name; |
---|
9237 | 9242 | String ext; |
---|
9238 | 9243 | |
---|
.. | .. |
---|
11077 | 11082 | // |
---|
11078 | 11083 | // newenvy = -1; |
---|
11079 | 11084 | |
---|
11080 | | - if (object.skyboxname != null) |
---|
| 11085 | + if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11081 | 11086 | { |
---|
11082 | | - if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11087 | + if (cubemaprgb == null) |
---|
11083 | 11088 | { |
---|
11084 | | - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11085 | | - loadedskyboxname = object.skyboxname; |
---|
| 11089 | + cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11086 | 11090 | } |
---|
| 11091 | + |
---|
| 11092 | + cubemap = cubemaprgb; |
---|
11087 | 11093 | } |
---|
11088 | 11094 | else |
---|
11089 | 11095 | { |
---|
11090 | | - cubemap = null; |
---|
11091 | | - loadedskyboxname = null; |
---|
| 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; |
---|
11092 | 11111 | } |
---|
11093 | 11112 | |
---|
11094 | 11113 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
17533 | 17552 | gl.glFlush(); |
---|
17534 | 17553 | |
---|
17535 | 17554 | /**/ |
---|
17536 | | - 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); |
---|
17537 | 17556 | |
---|
17538 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17557 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17539 | 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 | + |
---|
17540 | 17563 | double r = 0, g = 0, b = 0; |
---|
17541 | 17564 | |
---|
17542 | 17565 | double count = 0; |
---|
.. | .. |
---|
17547 | 17570 | |
---|
17548 | 17571 | double FACTOR = 1; |
---|
17549 | 17572 | |
---|
17550 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17573 | + for (int i = 0; i < depths.length; i++) |
---|
17551 | 17574 | { |
---|
17552 | 17575 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17553 | 17576 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17630 | 17653 | |
---|
17631 | 17654 | double scale = ray.z; // 1; // cos |
---|
17632 | 17655 | |
---|
17633 | | - float depth = pixels[newindex]; |
---|
| 17656 | + float depth = depths[newindex]; |
---|
17634 | 17657 | |
---|
17635 | 17658 | /* |
---|
17636 | 17659 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17827 | 17850 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17828 | 17851 | static IntBuffer bigAAbuffer; |
---|
17829 | 17852 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17830 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17853 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17831 | 17854 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17832 | 17855 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17833 | 17856 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17834 | | - 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 | + |
---|
17835 | 17861 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17836 | 17862 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17837 | 17863 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|