Normand Briere
2019-08-15 24a2a946b35279605e645349bd6b82e9e60aac88
CameraPane.java
....@@ -110,7 +110,11 @@
110110 //private Mat4f spotlightTransform = new Mat4f();
111111 //private Mat4f spotlightInverseTransform = new Mat4f();
112112 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
+
114118 boolean reverseUP = false;
115119 static boolean frozen = false;
116120 boolean enablebackspace = false; // patch for back buffer refresh
....@@ -173,7 +177,7 @@
173177 static boolean doublesided = false; // true; // reversed normals are awful for conformance
174178 boolean anisotropy = true;
175179 boolean softshadow = true; // slower but better false;
176
- boolean opacityhalo = false;
180
+ boolean opacityhalo = false; // reverse the halo effect (e.g. glass)
177181
178182 boolean macromode = false;
179183
....@@ -188,15 +192,16 @@
188192
189193 private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory();
190194
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
192196 {
193197 try
194198 {
195
- cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
199
+ return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap);
196200 } catch (IOException e)
197201 {
198202 System.out.println("NAME = " + name);
199203 e.printStackTrace(); // throw new RuntimeException(e);
204
+ return null;
200205 }
201206 }
202207
....@@ -2512,7 +2517,7 @@
25122517 com.sun.opengl.util.texture.TextureIO.newTextureData(
25132518 getClass().getClassLoader().getResourceAsStream(name),
25142519 true,
2515
- com.sun.opengl.util.texture.TextureIO.PNG);
2520
+ GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG);
25162521 } catch (java.io.IOException e)
25172522 {
25182523 throw new javax.media.opengl.GLException(e);
....@@ -8778,10 +8783,12 @@
87788783
87798784 gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0);
87808785 MAXSTACK = temp[0];
8781
- System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
8786
+ if (Globals.DEBUG)
8787
+ System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK);
87828788 gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0);
87838789 MAXSTACK = temp[0];
8784
- System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
8790
+ if (Globals.DEBUG)
8791
+ System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK);
87858792
87868793 // Use debug pipeline
87878794 //drawable.setGL(new DebugGL(gl)); //
....@@ -8789,7 +8796,8 @@
87898796 gl = drawable.getGL(); //
87908797
87918798 GL gl3 = getGL();
8792
- System.out.println("INIT GL IS: " + gl.getClass().getName());
8799
+ if (Globals.DEBUG)
8800
+ System.out.println("INIT GL IS: " + gl.getClass().getName());
87938801
87948802
87958803 //float pos[] = { 100, 100, 100, 0 };
....@@ -9230,6 +9238,8 @@
92309238
92319239 void LoadEnvy(int which)
92329240 {
9241
+ assert(false);
9242
+
92339243 String name;
92349244 String ext;
92359245
....@@ -11074,18 +11084,34 @@
1107411084 //
1107511085 // newenvy = -1;
1107611086
11077
- if (object.skyboxname != null)
11087
+ if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb"))
1107811088 {
11079
- if (!object.skyboxname.equals(this.loadedskyboxname))
11089
+ if (cubemaprgb == null)
1108011090 {
11081
- LoadSkybox(object.skyboxname + "/", object.skyboxext, false);
11082
- loadedskyboxname = object.skyboxname;
11091
+ cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb" + "/", "jpg", false);
1108311092 }
11093
+
11094
+ cubemap = cubemaprgb;
1108411095 }
1108511096 else
1108611097 {
11087
- cubemap = null;
11088
- 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;
1108911115 }
1109011116
1109111117 ratio = ((double) getWidth()) / getHeight();
....@@ -16667,6 +16693,7 @@
1666716693 private void DrawSkyBox(GL gl, float ratio)
1666816694 {
1666916695 if (//envyoff ||
16696
+ WIREFRAME ||
1667016697 cubemap == null)
1667116698 {
1667216699 gl.glClearColor(BGcolor, BGcolor, BGcolor, 1);
....@@ -16765,7 +16792,8 @@
1676516792 gl.glDisable(GL.GL_TEXTURE_GEN_R);
1676616793
1676716794 cubemap.disable();
16768
- ////cubemap.unbind();
16795
+ //cubemap.dispose();
16796
+
1676916797 if (CULLFACE)
1677016798 {
1677116799 gl.glEnable(gl.GL_CULL_FACE);
....@@ -17529,10 +17557,14 @@
1752917557 gl.glFlush();
1753017558
1753117559 /**/
17532
- 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);
1753317561
17534
- float[] pixels = occlusionsizebuffer.array();
17562
+ float[] depths = occlusiondepthbuffer.array();
1753517563
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
+
1753617568 double r = 0, g = 0, b = 0;
1753717569
1753817570 double count = 0;
....@@ -17543,7 +17575,7 @@
1754317575
1754417576 double FACTOR = 1;
1754517577
17546
- for (int i = 0; i < pixels.length; i++)
17578
+ for (int i = 0; i < depths.length; i++)
1754717579 {
1754817580 int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
1754917581 int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2;
....@@ -17626,7 +17658,7 @@
1762617658
1762717659 double scale = ray.z; // 1; // cos
1762817660
17629
- float depth = pixels[newindex];
17661
+ float depth = depths[newindex];
1763017662
1763117663 /*
1763217664 int newindex2 = (x + 1) * OCCLUSION_SIZE + y;
....@@ -17823,11 +17855,14 @@
1782317855 static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE);
1782417856 static IntBuffer bigAAbuffer;
1782517857 static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3);
17826
- static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
17858
+ //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE);
1782717859 static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1782817860 static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE);
1782917861 //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE);
17830
- 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
+
1783117866 static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB);
1783217867 static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
1783317868 static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>();