.. | .. |
---|
9316 | 9316 | double[] light2camera = new double[16]; |
---|
9317 | 9317 | |
---|
9318 | 9318 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
9323 | 9322 | |
---|
9324 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
11065 | 11064 | // |
---|
11066 | 11065 | // newenvy = -1; |
---|
11067 | 11066 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11067 | + if (object.skyboxname != null) |
---|
11069 | 11068 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
| 11074 | + } |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
11072 | 11079 | } |
---|
11073 | 11080 | |
---|
11074 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
12446 | 12453 | |
---|
12447 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12455 | |
---|
12449 | | - String program0 = |
---|
| 12456 | + String programmin = |
---|
12450 | 12457 | // Min shader |
---|
12451 | 12458 | "!!ARBfp1.0\n" + |
---|
12452 | 12459 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12513 | 12520 | "MOV result.color, temp;" + |
---|
12514 | 12521 | "END"; |
---|
12515 | 12522 | |
---|
12516 | | - String program = |
---|
| 12523 | + String programmax = |
---|
12517 | 12524 | "!!ARBfp1.0\n" + |
---|
12518 | 12525 | |
---|
12519 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13369 | 13376 | //once = true; |
---|
13370 | 13377 | } |
---|
13371 | 13378 | |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
13372 | 13386 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13374 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
15362 | 15376 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15378 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15380 | case '1': |
---|
15367 | 15381 | case '2': |
---|
15368 | 15382 | case '3': |
---|
.. | .. |
---|
15372 | 15386 | case '7': |
---|
15373 | 15387 | case '8': |
---|
15374 | 15388 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15389 | + if (true) // envyoff) |
---|
15376 | 15390 | { |
---|
15377 | 15391 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15392 | } |
---|
.. | .. |
---|
16084 | 16098 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16099 | break; |
---|
16086 | 16100 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16102 | break; |
---|
16089 | 16103 | } |
---|
16090 | 16104 | |
---|
.. | .. |
---|
16570 | 16584 | private /*static*/ boolean firstime; |
---|
16571 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
16572 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16573 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16574 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16575 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16582 | 16598 | { |
---|
16583 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16584 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
16585 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
16586 | 16604 | { |
---|
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) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
16592 | 16610 | { |
---|
16593 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
16594 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
16595 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
16596 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
16597 | 16646 | } |
---|
16598 | 16647 | |
---|
16599 | 16648 | return cubemap; |
---|
16600 | 16649 | } |
---|
| 16650 | + |
---|
16601 | 16651 | int bigsphere = -1; |
---|
16602 | 16652 | |
---|
16603 | 16653 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16606 | 16656 | |
---|
16607 | 16657 | private void DrawSkyBox(GL gl, float ratio) |
---|
16608 | 16658 | { |
---|
16609 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
16610 | 16661 | { |
---|
16611 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16612 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16623 | 16674 | gl.glLoadIdentity(); |
---|
16624 | 16675 | gl.glScalef(1,ratio,1); |
---|
16625 | 16676 | |
---|
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); |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16634 | 16685 | |
---|
16635 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16636 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16644 | 16695 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16645 | 16696 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16646 | 16697 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16647 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16698 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16648 | 16699 | |
---|
16649 | 16700 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16650 | 16701 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16663 | 16714 | { |
---|
16664 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16665 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16666 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16667 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16668 | 16720 | //viewer.updateInverseRotation(gl); |
---|