.. | .. |
---|
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(); |
---|
.. | .. |
---|
13038 | 13045 | // display shadow only (fakedepth == 0) |
---|
13039 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
13040 | 13047 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
13041 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
13042 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
13043 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
13044 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
15362 | 15369 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15370 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15371 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15372 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15373 | case '1': |
---|
15367 | 15374 | case '2': |
---|
15368 | 15375 | case '3': |
---|
.. | .. |
---|
15372 | 15379 | case '7': |
---|
15373 | 15380 | case '8': |
---|
15374 | 15381 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15382 | + if (true) // envyoff) |
---|
15376 | 15383 | { |
---|
15377 | 15384 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15385 | } |
---|
.. | .. |
---|
16570 | 16577 | private /*static*/ boolean firstime; |
---|
16571 | 16578 | private /*static*/ cVector newView = new cVector(); |
---|
16572 | 16579 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16580 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16581 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16573 | 16582 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16574 | 16583 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16575 | 16584 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16582 | 16591 | { |
---|
16583 | 16592 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16584 | 16593 | |
---|
| 16594 | + int usedsuf = 0; |
---|
| 16595 | + |
---|
16585 | 16596 | for (int i = 0; i < suffixes.length; i++) |
---|
16586 | 16597 | { |
---|
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) |
---|
| 16598 | + String[] suffixe = suffixes; |
---|
| 16599 | + String[] fallback = suffixes2; |
---|
| 16600 | + String[] fallfallback = suffixes3; |
---|
| 16601 | + |
---|
| 16602 | + for (int c=usedsuf; --c>=0;) |
---|
16592 | 16603 | { |
---|
16593 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16604 | +// String[] temp = suffixe; |
---|
| 16605 | +// suffixe = fallback; |
---|
| 16606 | +// fallback = fallfallback; |
---|
| 16607 | +// fallfallback = temp; |
---|
16594 | 16608 | } |
---|
| 16609 | + |
---|
| 16610 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16611 | + TextureData data; |
---|
| 16612 | + |
---|
| 16613 | + try |
---|
| 16614 | + { |
---|
| 16615 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16616 | + mipmapped, |
---|
| 16617 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16618 | + } |
---|
| 16619 | + catch (Exception e) |
---|
| 16620 | + { |
---|
| 16621 | + try |
---|
| 16622 | + { |
---|
| 16623 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16624 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16625 | + mipmapped, |
---|
| 16626 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16627 | + } |
---|
| 16628 | + catch (Exception e2) |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + } |
---|
| 16636 | + |
---|
16595 | 16637 | //System.out.println("Target = " + targets[i]); |
---|
16596 | 16638 | cubemap.updateImage(data, targets[i]); |
---|
16597 | 16639 | } |
---|
16598 | 16640 | |
---|
16599 | 16641 | return cubemap; |
---|
16600 | 16642 | } |
---|
| 16643 | + |
---|
16601 | 16644 | int bigsphere = -1; |
---|
16602 | 16645 | |
---|
16603 | 16646 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16606 | 16649 | |
---|
16607 | 16650 | private void DrawSkyBox(GL gl, float ratio) |
---|
16608 | 16651 | { |
---|
16609 | | - if (envyoff || cubemap == null) |
---|
| 16652 | + if (//envyoff || |
---|
| 16653 | + cubemap == null) |
---|
16610 | 16654 | { |
---|
16611 | 16655 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16612 | 16656 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16663 | 16707 | { |
---|
16664 | 16708 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16665 | 16709 | } |
---|
| 16710 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16666 | 16711 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16667 | 16712 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16668 | 16713 | //viewer.updateInverseRotation(gl); |
---|