.. | .. |
---|
173 | 173 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 174 | boolean anisotropy = true; |
---|
175 | 175 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 176 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 177 | |
---|
178 | 178 | boolean macromode = false; |
---|
179 | 179 | |
---|
.. | .. |
---|
8358 | 8358 | // else |
---|
8359 | 8359 | // if (!texname.startsWith("/")) |
---|
8360 | 8360 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8361 | | - if (!FileExists(texname)) |
---|
| 8361 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8362 | 8362 | { |
---|
8363 | 8363 | texname = fallbackTextureName; |
---|
8364 | 8364 | } |
---|
.. | .. |
---|
8441 | 8441 | new Exception().printStackTrace(); |
---|
8442 | 8442 | } else |
---|
8443 | 8443 | { |
---|
| 8444 | + if (texname.startsWith("@")) |
---|
| 8445 | + { |
---|
| 8446 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8447 | + if (texturecache == null) |
---|
| 8448 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8449 | + else |
---|
| 8450 | + new Exception().printStackTrace(); |
---|
| 8451 | + } else |
---|
| 8452 | + { |
---|
8444 | 8453 | if (textureon) |
---|
8445 | 8454 | { |
---|
8446 | 8455 | String cachename = texname; |
---|
.. | .. |
---|
8500 | 8509 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8501 | 8510 | //texture = GetTexture(tex, bump); |
---|
8502 | 8511 | } |
---|
| 8512 | + } |
---|
8503 | 8513 | } |
---|
8504 | 8514 | //} |
---|
8505 | 8515 | } |
---|
.. | .. |
---|
8768 | 8778 | |
---|
8769 | 8779 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8770 | 8780 | MAXSTACK = temp[0]; |
---|
8771 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8781 | + if (Globals.DEBUG) |
---|
| 8782 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8772 | 8783 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8773 | 8784 | MAXSTACK = temp[0]; |
---|
8774 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8785 | + if (Globals.DEBUG) |
---|
| 8786 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8775 | 8787 | |
---|
8776 | 8788 | // Use debug pipeline |
---|
8777 | 8789 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8779 | 8791 | gl = drawable.getGL(); // |
---|
8780 | 8792 | |
---|
8781 | 8793 | GL gl3 = getGL(); |
---|
8782 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8794 | + if (Globals.DEBUG) |
---|
| 8795 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8783 | 8796 | |
---|
8784 | 8797 | |
---|
8785 | 8798 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
10841 | 10854 | |
---|
10842 | 10855 | if (wait) |
---|
10843 | 10856 | { |
---|
10844 | | - Sleep(500); |
---|
| 10857 | + Sleep(200); // blocks everything |
---|
10845 | 10858 | |
---|
10846 | 10859 | wait = false; |
---|
10847 | 10860 | } |
---|
.. | .. |
---|
11379 | 11392 | |
---|
11380 | 11393 | // if (cam != lightCamera) |
---|
11381 | 11394 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11382 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11395 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11383 | 11396 | } |
---|
11384 | 11397 | |
---|
11385 | 11398 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12453 | 12466 | |
---|
12454 | 12467 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12455 | 12468 | |
---|
12456 | | - String program0 = |
---|
| 12469 | + String programmin = |
---|
12457 | 12470 | // Min shader |
---|
12458 | 12471 | "!!ARBfp1.0\n" + |
---|
12459 | 12472 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12520 | 12533 | "MOV result.color, temp;" + |
---|
12521 | 12534 | "END"; |
---|
12522 | 12535 | |
---|
12523 | | - String program = |
---|
| 12536 | + String programmax = |
---|
12524 | 12537 | "!!ARBfp1.0\n" + |
---|
12525 | 12538 | |
---|
12526 | 12539 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13376 | 13389 | //once = true; |
---|
13377 | 13390 | } |
---|
13378 | 13391 | |
---|
| 13392 | + String program = programmax; |
---|
| 13393 | + |
---|
| 13394 | + if (Globals.MINSHADER) |
---|
| 13395 | + { |
---|
| 13396 | + program = programmin; |
---|
| 13397 | + } |
---|
| 13398 | + |
---|
13379 | 13399 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13380 | 13400 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13381 | 13401 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
14625 | 14645 | MODIFIERS |= COMMAND; |
---|
14626 | 14646 | /**/ |
---|
14627 | 14647 | if((mod&SHIFT) == SHIFT) |
---|
14628 | | - manipCamera.RotatePosition(0, -speed); |
---|
14629 | | - else |
---|
14630 | 14648 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14649 | + else |
---|
| 14650 | + manipCamera.RotatePosition(0, -speed); |
---|
14631 | 14651 | /**/ |
---|
14632 | 14652 | if ((mod & SHIFT) == SHIFT) |
---|
14633 | 14653 | { |
---|
.. | .. |
---|
14646 | 14666 | MODIFIERS |= COMMAND; |
---|
14647 | 14667 | /**/ |
---|
14648 | 14668 | if((mod&SHIFT) == SHIFT) |
---|
14649 | | - manipCamera.RotatePosition(0, speed); |
---|
14650 | | - else |
---|
14651 | 14669 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14670 | + else |
---|
| 14671 | + manipCamera.RotatePosition(0, speed); |
---|
14652 | 14672 | /**/ |
---|
14653 | 14673 | if ((mod & SHIFT) == SHIFT) |
---|
14654 | 14674 | { |
---|
.. | .. |
---|
16650 | 16670 | private void DrawSkyBox(GL gl, float ratio) |
---|
16651 | 16671 | { |
---|
16652 | 16672 | if (//envyoff || |
---|
| 16673 | + WIREFRAME || |
---|
16653 | 16674 | cubemap == null) |
---|
16654 | 16675 | { |
---|
16655 | 16676 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
.. | .. |
---|
16667 | 16688 | gl.glLoadIdentity(); |
---|
16668 | 16689 | gl.glScalef(1,ratio,1); |
---|
16669 | 16690 | |
---|
16670 | | - colorV[0] = 2; |
---|
16671 | | - colorV[1] = 2; |
---|
16672 | | - colorV[2] = 2; |
---|
16673 | | - colorV[3] = 1; |
---|
16674 | | - gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
16675 | | - gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
16676 | | - |
---|
16677 | | - gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16691 | +// colorV[0] = 2; |
---|
| 16692 | +// colorV[1] = 2; |
---|
| 16693 | +// colorV[2] = 2; |
---|
| 16694 | +// colorV[3] = 1; |
---|
| 16695 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16696 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16697 | +// |
---|
| 16698 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16678 | 16699 | |
---|
16679 | 16700 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16680 | 16701 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16688 | 16709 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16689 | 16710 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16690 | 16711 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16691 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16712 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16692 | 16713 | |
---|
16693 | 16714 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16694 | 16715 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
17512 | 17533 | gl.glFlush(); |
---|
17513 | 17534 | |
---|
17514 | 17535 | /**/ |
---|
17515 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17536 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17516 | 17537 | |
---|
17517 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17538 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17518 | 17539 | |
---|
| 17540 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17541 | + |
---|
| 17542 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17543 | + |
---|
17519 | 17544 | double r = 0, g = 0, b = 0; |
---|
17520 | 17545 | |
---|
17521 | 17546 | double count = 0; |
---|
.. | .. |
---|
17526 | 17551 | |
---|
17527 | 17552 | double FACTOR = 1; |
---|
17528 | 17553 | |
---|
17529 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17554 | + for (int i = 0; i < depths.length; i++) |
---|
17530 | 17555 | { |
---|
17531 | 17556 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17532 | 17557 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17609 | 17634 | |
---|
17610 | 17635 | double scale = ray.z; // 1; // cos |
---|
17611 | 17636 | |
---|
17612 | | - float depth = pixels[newindex]; |
---|
| 17637 | + float depth = depths[newindex]; |
---|
17613 | 17638 | |
---|
17614 | 17639 | /* |
---|
17615 | 17640 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17806 | 17831 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17807 | 17832 | static IntBuffer bigAAbuffer; |
---|
17808 | 17833 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17809 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17834 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17810 | 17835 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17811 | 17836 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17812 | 17837 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17813 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17838 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17839 | + |
---|
| 17840 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17841 | + |
---|
17814 | 17842 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17815 | 17843 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17816 | 17844 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|