.. | .. |
---|
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); |
---|
.. | .. |
---|
8358 | 8363 | // else |
---|
8359 | 8364 | // if (!texname.startsWith("/")) |
---|
8360 | 8365 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8361 | | - if (!FileExists(texname)) |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8362 | 8367 | { |
---|
8363 | 8368 | texname = fallbackTextureName; |
---|
8364 | 8369 | } |
---|
.. | .. |
---|
8441 | 8446 | new Exception().printStackTrace(); |
---|
8442 | 8447 | } else |
---|
8443 | 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); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
| 8456 | + } else |
---|
| 8457 | + { |
---|
8444 | 8458 | if (textureon) |
---|
8445 | 8459 | { |
---|
8446 | 8460 | String cachename = texname; |
---|
.. | .. |
---|
8500 | 8514 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8501 | 8515 | //texture = GetTexture(tex, bump); |
---|
8502 | 8516 | } |
---|
| 8517 | + } |
---|
8503 | 8518 | } |
---|
8504 | 8519 | //} |
---|
8505 | 8520 | } |
---|
.. | .. |
---|
8768 | 8783 | |
---|
8769 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8770 | 8785 | MAXSTACK = temp[0]; |
---|
8771 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8772 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8773 | 8789 | MAXSTACK = temp[0]; |
---|
8774 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8775 | 8792 | |
---|
8776 | 8793 | // Use debug pipeline |
---|
8777 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8779 | 8796 | gl = drawable.getGL(); // |
---|
8780 | 8797 | |
---|
8781 | 8798 | GL gl3 = getGL(); |
---|
8782 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8783 | 8801 | |
---|
8784 | 8802 | |
---|
8785 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
9220 | 9238 | |
---|
9221 | 9239 | void LoadEnvy(int which) |
---|
9222 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9223 | 9243 | String name; |
---|
9224 | 9244 | String ext; |
---|
9225 | 9245 | |
---|
.. | .. |
---|
9316 | 9336 | double[] light2camera = new double[16]; |
---|
9317 | 9337 | |
---|
9318 | 9338 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
9323 | 9342 | |
---|
9324 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
10842 | 10861 | |
---|
10843 | 10862 | if (wait) |
---|
10844 | 10863 | { |
---|
10845 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
10846 | 10865 | |
---|
10847 | 10866 | wait = false; |
---|
10848 | 10867 | } |
---|
.. | .. |
---|
11065 | 11084 | // |
---|
11066 | 11085 | // newenvy = -1; |
---|
11067 | 11086 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11069 | 11088 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
| 11095 | + } |
---|
| 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; |
---|
11072 | 11115 | } |
---|
11073 | 11116 | |
---|
11074 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
11372 | 11415 | |
---|
11373 | 11416 | // if (cam != lightCamera) |
---|
11374 | 11417 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11375 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11376 | 11419 | } |
---|
11377 | 11420 | |
---|
11378 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12446 | 12489 | |
---|
12447 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12491 | |
---|
12449 | | - String program0 = |
---|
| 12492 | + String programmin = |
---|
12450 | 12493 | // Min shader |
---|
12451 | 12494 | "!!ARBfp1.0\n" + |
---|
12452 | 12495 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12513 | 12556 | "MOV result.color, temp;" + |
---|
12514 | 12557 | "END"; |
---|
12515 | 12558 | |
---|
12516 | | - String program = |
---|
| 12559 | + String programmax = |
---|
12517 | 12560 | "!!ARBfp1.0\n" + |
---|
12518 | 12561 | |
---|
12519 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13038 | 13081 | // display shadow only (fakedepth == 0) |
---|
13039 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
13040 | 13083 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
13041 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
13042 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
13043 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
13044 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
13369 | 13412 | //once = true; |
---|
13370 | 13413 | } |
---|
13371 | 13414 | |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
13372 | 13422 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | 13423 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13374 | 13424 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
14618 | 14668 | MODIFIERS |= COMMAND; |
---|
14619 | 14669 | /**/ |
---|
14620 | 14670 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
14622 | | - else |
---|
14623 | 14671 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14672 | + else |
---|
| 14673 | + manipCamera.RotatePosition(0, -speed); |
---|
14624 | 14674 | /**/ |
---|
14625 | 14675 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14676 | { |
---|
.. | .. |
---|
14639 | 14689 | MODIFIERS |= COMMAND; |
---|
14640 | 14690 | /**/ |
---|
14641 | 14691 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
14643 | | - else |
---|
14644 | 14692 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14693 | + else |
---|
| 14694 | + manipCamera.RotatePosition(0, speed); |
---|
14645 | 14695 | /**/ |
---|
14646 | 14696 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14697 | { |
---|
.. | .. |
---|
15362 | 15412 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15413 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15414 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15415 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15416 | case '1': |
---|
15367 | 15417 | case '2': |
---|
15368 | 15418 | case '3': |
---|
.. | .. |
---|
15372 | 15422 | case '7': |
---|
15373 | 15423 | case '8': |
---|
15374 | 15424 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15425 | + if (true) // envyoff) |
---|
15376 | 15426 | { |
---|
15377 | 15427 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15428 | } |
---|
.. | .. |
---|
16084 | 16134 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16135 | break; |
---|
16086 | 16136 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16137 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16138 | break; |
---|
16089 | 16139 | } |
---|
16090 | 16140 | |
---|
.. | .. |
---|
16570 | 16620 | private /*static*/ boolean firstime; |
---|
16571 | 16621 | private /*static*/ cVector newView = new cVector(); |
---|
16572 | 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"}; |
---|
16573 | 16625 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16574 | 16626 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16575 | 16627 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16582 | 16634 | { |
---|
16583 | 16635 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16584 | 16636 | |
---|
| 16637 | + int usedsuf = 0; |
---|
| 16638 | + |
---|
16585 | 16639 | for (int i = 0; i < suffixes.length; i++) |
---|
16586 | 16640 | { |
---|
16587 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16588 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16589 | | - mipmapped, |
---|
16590 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16591 | | - if (data == null) |
---|
| 16641 | + String[] suffixe = suffixes; |
---|
| 16642 | + String[] fallback = suffixes2; |
---|
| 16643 | + String[] fallfallback = suffixes3; |
---|
| 16644 | + |
---|
| 16645 | + for (int c=usedsuf; --c>=0;) |
---|
16592 | 16646 | { |
---|
16593 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16647 | +// String[] temp = suffixe; |
---|
| 16648 | +// suffixe = fallback; |
---|
| 16649 | +// fallback = fallfallback; |
---|
| 16650 | +// fallfallback = temp; |
---|
16594 | 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 | + |
---|
16595 | 16680 | //System.out.println("Target = " + targets[i]); |
---|
16596 | 16681 | cubemap.updateImage(data, targets[i]); |
---|
16597 | 16682 | } |
---|
16598 | 16683 | |
---|
16599 | 16684 | return cubemap; |
---|
16600 | 16685 | } |
---|
| 16686 | + |
---|
16601 | 16687 | int bigsphere = -1; |
---|
16602 | 16688 | |
---|
16603 | 16689 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16606 | 16692 | |
---|
16607 | 16693 | private void DrawSkyBox(GL gl, float ratio) |
---|
16608 | 16694 | { |
---|
16609 | | - if (envyoff || cubemap == null) |
---|
| 16695 | + if (//envyoff || |
---|
| 16696 | + WIREFRAME || |
---|
| 16697 | + cubemap == null) |
---|
16610 | 16698 | { |
---|
16611 | 16699 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16612 | 16700 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16623 | 16711 | gl.glLoadIdentity(); |
---|
16624 | 16712 | gl.glScalef(1,ratio,1); |
---|
16625 | 16713 | |
---|
16626 | | - colorV[0] = 2; |
---|
16627 | | - colorV[1] = 2; |
---|
16628 | | - colorV[2] = 2; |
---|
16629 | | - colorV[3] = 1; |
---|
16630 | | - gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
16631 | | - gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
16632 | | - |
---|
16633 | | - gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 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); |
---|
16634 | 16722 | |
---|
16635 | 16723 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16636 | 16724 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16644 | 16732 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16645 | 16733 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16646 | 16734 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16647 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16735 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16648 | 16736 | |
---|
16649 | 16737 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16650 | 16738 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16663 | 16751 | { |
---|
16664 | 16752 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16665 | 16753 | } |
---|
| 16754 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16666 | 16755 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16667 | 16756 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16668 | 16757 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16703 | 16792 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16704 | 16793 | |
---|
16705 | 16794 | cubemap.disable(); |
---|
16706 | | - ////cubemap.unbind(); |
---|
| 16795 | + //cubemap.dispose(); |
---|
| 16796 | + |
---|
16707 | 16797 | if (CULLFACE) |
---|
16708 | 16798 | { |
---|
16709 | 16799 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17467 | 17557 | gl.glFlush(); |
---|
17468 | 17558 | |
---|
17469 | 17559 | /**/ |
---|
17470 | | - 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); |
---|
17471 | 17561 | |
---|
17472 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17562 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17473 | 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 | + |
---|
17474 | 17568 | double r = 0, g = 0, b = 0; |
---|
17475 | 17569 | |
---|
17476 | 17570 | double count = 0; |
---|
.. | .. |
---|
17481 | 17575 | |
---|
17482 | 17576 | double FACTOR = 1; |
---|
17483 | 17577 | |
---|
17484 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17578 | + for (int i = 0; i < depths.length; i++) |
---|
17485 | 17579 | { |
---|
17486 | 17580 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17487 | 17581 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17564 | 17658 | |
---|
17565 | 17659 | double scale = ray.z; // 1; // cos |
---|
17566 | 17660 | |
---|
17567 | | - float depth = pixels[newindex]; |
---|
| 17661 | + float depth = depths[newindex]; |
---|
17568 | 17662 | |
---|
17569 | 17663 | /* |
---|
17570 | 17664 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17761 | 17855 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17762 | 17856 | static IntBuffer bigAAbuffer; |
---|
17763 | 17857 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17764 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17858 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17765 | 17859 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17766 | 17860 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17767 | 17861 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17768 | | - 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 | + |
---|
17769 | 17866 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17770 | 17867 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17771 | 17868 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|