.. | .. |
---|
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 }; |
---|
.. | .. |
---|
9316 | 9329 | double[] light2camera = new double[16]; |
---|
9317 | 9330 | |
---|
9318 | 9331 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9332 | + //boolean envyoff = false; |
---|
| 9333 | + |
---|
| 9334 | + String loadedskyboxname; |
---|
9323 | 9335 | |
---|
9324 | 9336 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9337 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
10842 | 10854 | |
---|
10843 | 10855 | if (wait) |
---|
10844 | 10856 | { |
---|
10845 | | - Sleep(500); |
---|
| 10857 | + Sleep(200); // blocks everything |
---|
10846 | 10858 | |
---|
10847 | 10859 | wait = false; |
---|
10848 | 10860 | } |
---|
.. | .. |
---|
11065 | 11077 | // |
---|
11066 | 11078 | // newenvy = -1; |
---|
11067 | 11079 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11080 | + if (object.skyboxname != null) |
---|
11069 | 11081 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11082 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11083 | + { |
---|
| 11084 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11085 | + loadedskyboxname = object.skyboxname; |
---|
| 11086 | + } |
---|
| 11087 | + } |
---|
| 11088 | + else |
---|
| 11089 | + { |
---|
| 11090 | + cubemap = null; |
---|
| 11091 | + loadedskyboxname = null; |
---|
11072 | 11092 | } |
---|
11073 | 11093 | |
---|
11074 | 11094 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
11372 | 11392 | |
---|
11373 | 11393 | // if (cam != lightCamera) |
---|
11374 | 11394 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11375 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11395 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11376 | 11396 | } |
---|
11377 | 11397 | |
---|
11378 | 11398 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12446 | 12466 | |
---|
12447 | 12467 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12468 | |
---|
12449 | | - String program0 = |
---|
| 12469 | + String programmin = |
---|
12450 | 12470 | // Min shader |
---|
12451 | 12471 | "!!ARBfp1.0\n" + |
---|
12452 | 12472 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12513 | 12533 | "MOV result.color, temp;" + |
---|
12514 | 12534 | "END"; |
---|
12515 | 12535 | |
---|
12516 | | - String program = |
---|
| 12536 | + String programmax = |
---|
12517 | 12537 | "!!ARBfp1.0\n" + |
---|
12518 | 12538 | |
---|
12519 | 12539 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13369 | 13389 | //once = true; |
---|
13370 | 13390 | } |
---|
13371 | 13391 | |
---|
| 13392 | + String program = programmax; |
---|
| 13393 | + |
---|
| 13394 | + if (Globals.MINSHADER) |
---|
| 13395 | + { |
---|
| 13396 | + program = programmin; |
---|
| 13397 | + } |
---|
| 13398 | + |
---|
13372 | 13399 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | 13400 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13374 | 13401 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
14618 | 14645 | MODIFIERS |= COMMAND; |
---|
14619 | 14646 | /**/ |
---|
14620 | 14647 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
14622 | | - else |
---|
14623 | 14648 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14649 | + else |
---|
| 14650 | + manipCamera.RotatePosition(0, -speed); |
---|
14624 | 14651 | /**/ |
---|
14625 | 14652 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14653 | { |
---|
.. | .. |
---|
14639 | 14666 | MODIFIERS |= COMMAND; |
---|
14640 | 14667 | /**/ |
---|
14641 | 14668 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
14643 | | - else |
---|
14644 | 14669 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14670 | + else |
---|
| 14671 | + manipCamera.RotatePosition(0, speed); |
---|
14645 | 14672 | /**/ |
---|
14646 | 14673 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14674 | { |
---|
.. | .. |
---|
15362 | 15389 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15390 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15391 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15392 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15393 | case '1': |
---|
15367 | 15394 | case '2': |
---|
15368 | 15395 | case '3': |
---|
.. | .. |
---|
15372 | 15399 | case '7': |
---|
15373 | 15400 | case '8': |
---|
15374 | 15401 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15402 | + if (true) // envyoff) |
---|
15376 | 15403 | { |
---|
15377 | 15404 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15405 | } |
---|
.. | .. |
---|
16084 | 16111 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16112 | break; |
---|
16086 | 16113 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16114 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16115 | break; |
---|
16089 | 16116 | } |
---|
16090 | 16117 | |
---|
.. | .. |
---|
16633 | 16660 | |
---|
16634 | 16661 | return cubemap; |
---|
16635 | 16662 | } |
---|
| 16663 | + |
---|
16636 | 16664 | int bigsphere = -1; |
---|
16637 | 16665 | |
---|
16638 | 16666 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16641 | 16669 | |
---|
16642 | 16670 | private void DrawSkyBox(GL gl, float ratio) |
---|
16643 | 16671 | { |
---|
16644 | | - if (envyoff || cubemap == null) |
---|
| 16672 | + if (//envyoff || |
---|
| 16673 | + WIREFRAME || |
---|
| 16674 | + cubemap == null) |
---|
16645 | 16675 | { |
---|
16646 | 16676 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16647 | 16677 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16658 | 16688 | gl.glLoadIdentity(); |
---|
16659 | 16689 | gl.glScalef(1,ratio,1); |
---|
16660 | 16690 | |
---|
16661 | | - colorV[0] = 2; |
---|
16662 | | - colorV[1] = 2; |
---|
16663 | | - colorV[2] = 2; |
---|
16664 | | - colorV[3] = 1; |
---|
16665 | | - gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
16666 | | - gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
16667 | | - |
---|
16668 | | - 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); |
---|
16669 | 16699 | |
---|
16670 | 16700 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16671 | 16701 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16679 | 16709 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16680 | 16710 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16681 | 16711 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16682 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16712 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16683 | 16713 | |
---|
16684 | 16714 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16685 | 16715 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
17503 | 17533 | gl.glFlush(); |
---|
17504 | 17534 | |
---|
17505 | 17535 | /**/ |
---|
17506 | | - 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); |
---|
17507 | 17537 | |
---|
17508 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17538 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17509 | 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 | + |
---|
17510 | 17544 | double r = 0, g = 0, b = 0; |
---|
17511 | 17545 | |
---|
17512 | 17546 | double count = 0; |
---|
.. | .. |
---|
17517 | 17551 | |
---|
17518 | 17552 | double FACTOR = 1; |
---|
17519 | 17553 | |
---|
17520 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17554 | + for (int i = 0; i < depths.length; i++) |
---|
17521 | 17555 | { |
---|
17522 | 17556 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17523 | 17557 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17600 | 17634 | |
---|
17601 | 17635 | double scale = ray.z; // 1; // cos |
---|
17602 | 17636 | |
---|
17603 | | - float depth = pixels[newindex]; |
---|
| 17637 | + float depth = depths[newindex]; |
---|
17604 | 17638 | |
---|
17605 | 17639 | /* |
---|
17606 | 17640 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17797 | 17831 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17798 | 17832 | static IntBuffer bigAAbuffer; |
---|
17799 | 17833 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17800 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17834 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17801 | 17835 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17802 | 17836 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17803 | 17837 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17804 | | - 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 | + |
---|
17805 | 17842 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17806 | 17843 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17807 | 17844 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|