.. | .. |
---|
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 | } |
---|
.. | .. |
---|
9316 | 9326 | double[] light2camera = new double[16]; |
---|
9317 | 9327 | |
---|
9318 | 9328 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9329 | + //boolean envyoff = false; |
---|
| 9330 | + |
---|
| 9331 | + String loadedskyboxname; |
---|
9323 | 9332 | |
---|
9324 | 9333 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9334 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
10842 | 10851 | |
---|
10843 | 10852 | if (wait) |
---|
10844 | 10853 | { |
---|
10845 | | - Sleep(500); |
---|
| 10854 | + Sleep(200); // blocks everything |
---|
10846 | 10855 | |
---|
10847 | 10856 | wait = false; |
---|
10848 | 10857 | } |
---|
.. | .. |
---|
11065 | 11074 | // |
---|
11066 | 11075 | // newenvy = -1; |
---|
11067 | 11076 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11077 | + if (object.skyboxname != null) |
---|
11069 | 11078 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11079 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11080 | + { |
---|
| 11081 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11082 | + loadedskyboxname = object.skyboxname; |
---|
| 11083 | + } |
---|
| 11084 | + } |
---|
| 11085 | + else |
---|
| 11086 | + { |
---|
| 11087 | + cubemap = null; |
---|
| 11088 | + loadedskyboxname = null; |
---|
11072 | 11089 | } |
---|
11073 | 11090 | |
---|
11074 | 11091 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
11372 | 11389 | |
---|
11373 | 11390 | // if (cam != lightCamera) |
---|
11374 | 11391 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11375 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11392 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11376 | 11393 | } |
---|
11377 | 11394 | |
---|
11378 | 11395 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12446 | 12463 | |
---|
12447 | 12464 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12465 | |
---|
12449 | | - String program0 = |
---|
| 12466 | + String programmin = |
---|
12450 | 12467 | // Min shader |
---|
12451 | 12468 | "!!ARBfp1.0\n" + |
---|
12452 | 12469 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12513 | 12530 | "MOV result.color, temp;" + |
---|
12514 | 12531 | "END"; |
---|
12515 | 12532 | |
---|
12516 | | - String program = |
---|
| 12533 | + String programmax = |
---|
12517 | 12534 | "!!ARBfp1.0\n" + |
---|
12518 | 12535 | |
---|
12519 | 12536 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13038 | 13055 | // display shadow only (fakedepth == 0) |
---|
13039 | 13056 | "SUB temp.x, half.x, shadow.x;" + |
---|
13040 | 13057 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
13041 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13058 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
13042 | 13059 | "SUB temp.y, one.x, temp.z;" + |
---|
13043 | 13060 | "MUL temp.x, temp.x, temp.y;" + |
---|
13044 | 13061 | "KIL temp.x;" + |
---|
.. | .. |
---|
13369 | 13386 | //once = true; |
---|
13370 | 13387 | } |
---|
13371 | 13388 | |
---|
| 13389 | + String program = programmax; |
---|
| 13390 | + |
---|
| 13391 | + if (Globals.MINSHADER) |
---|
| 13392 | + { |
---|
| 13393 | + program = programmin; |
---|
| 13394 | + } |
---|
| 13395 | + |
---|
13372 | 13396 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | 13397 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13374 | 13398 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
14618 | 14642 | MODIFIERS |= COMMAND; |
---|
14619 | 14643 | /**/ |
---|
14620 | 14644 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
14622 | | - else |
---|
14623 | 14645 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14646 | + else |
---|
| 14647 | + manipCamera.RotatePosition(0, -speed); |
---|
14624 | 14648 | /**/ |
---|
14625 | 14649 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14650 | { |
---|
.. | .. |
---|
14639 | 14663 | MODIFIERS |= COMMAND; |
---|
14640 | 14664 | /**/ |
---|
14641 | 14665 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
14643 | | - else |
---|
14644 | 14666 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14667 | + else |
---|
| 14668 | + manipCamera.RotatePosition(0, speed); |
---|
14645 | 14669 | /**/ |
---|
14646 | 14670 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14671 | { |
---|
.. | .. |
---|
15362 | 15386 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15387 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15388 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15389 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15390 | case '1': |
---|
15367 | 15391 | case '2': |
---|
15368 | 15392 | case '3': |
---|
.. | .. |
---|
15372 | 15396 | case '7': |
---|
15373 | 15397 | case '8': |
---|
15374 | 15398 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15399 | + if (true) // envyoff) |
---|
15376 | 15400 | { |
---|
15377 | 15401 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15402 | } |
---|
.. | .. |
---|
16084 | 16108 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16109 | break; |
---|
16086 | 16110 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16111 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16112 | break; |
---|
16089 | 16113 | } |
---|
16090 | 16114 | |
---|
.. | .. |
---|
16570 | 16594 | private /*static*/ boolean firstime; |
---|
16571 | 16595 | private /*static*/ cVector newView = new cVector(); |
---|
16572 | 16596 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16597 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16598 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16573 | 16599 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16574 | 16600 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16575 | 16601 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16582 | 16608 | { |
---|
16583 | 16609 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16584 | 16610 | |
---|
| 16611 | + int usedsuf = 0; |
---|
| 16612 | + |
---|
16585 | 16613 | for (int i = 0; i < suffixes.length; i++) |
---|
16586 | 16614 | { |
---|
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) |
---|
| 16615 | + String[] suffixe = suffixes; |
---|
| 16616 | + String[] fallback = suffixes2; |
---|
| 16617 | + String[] fallfallback = suffixes3; |
---|
| 16618 | + |
---|
| 16619 | + for (int c=usedsuf; --c>=0;) |
---|
16592 | 16620 | { |
---|
16593 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16621 | +// String[] temp = suffixe; |
---|
| 16622 | +// suffixe = fallback; |
---|
| 16623 | +// fallback = fallfallback; |
---|
| 16624 | +// fallfallback = temp; |
---|
16594 | 16625 | } |
---|
| 16626 | + |
---|
| 16627 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16628 | + TextureData data; |
---|
| 16629 | + |
---|
| 16630 | + try |
---|
| 16631 | + { |
---|
| 16632 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16633 | + mipmapped, |
---|
| 16634 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16635 | + } |
---|
| 16636 | + catch (Exception e) |
---|
| 16637 | + { |
---|
| 16638 | + try |
---|
| 16639 | + { |
---|
| 16640 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16641 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16642 | + mipmapped, |
---|
| 16643 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16644 | + } |
---|
| 16645 | + catch (Exception e2) |
---|
| 16646 | + { |
---|
| 16647 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16648 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16649 | + mipmapped, |
---|
| 16650 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16651 | + } |
---|
| 16652 | + } |
---|
| 16653 | + |
---|
16595 | 16654 | //System.out.println("Target = " + targets[i]); |
---|
16596 | 16655 | cubemap.updateImage(data, targets[i]); |
---|
16597 | 16656 | } |
---|
16598 | 16657 | |
---|
16599 | 16658 | return cubemap; |
---|
16600 | 16659 | } |
---|
| 16660 | + |
---|
16601 | 16661 | int bigsphere = -1; |
---|
16602 | 16662 | |
---|
16603 | 16663 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16606 | 16666 | |
---|
16607 | 16667 | private void DrawSkyBox(GL gl, float ratio) |
---|
16608 | 16668 | { |
---|
16609 | | - if (envyoff || cubemap == null) |
---|
| 16669 | + if (//envyoff || |
---|
| 16670 | + cubemap == null) |
---|
16610 | 16671 | { |
---|
16611 | 16672 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16612 | 16673 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16623 | 16684 | gl.glLoadIdentity(); |
---|
16624 | 16685 | gl.glScalef(1,ratio,1); |
---|
16625 | 16686 | |
---|
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); |
---|
| 16687 | +// colorV[0] = 2; |
---|
| 16688 | +// colorV[1] = 2; |
---|
| 16689 | +// colorV[2] = 2; |
---|
| 16690 | +// colorV[3] = 1; |
---|
| 16691 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16692 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16693 | +// |
---|
| 16694 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16634 | 16695 | |
---|
16635 | 16696 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16636 | 16697 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16644 | 16705 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16645 | 16706 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16646 | 16707 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16647 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16708 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16648 | 16709 | |
---|
16649 | 16710 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16650 | 16711 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16663 | 16724 | { |
---|
16664 | 16725 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16665 | 16726 | } |
---|
| 16727 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16666 | 16728 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16667 | 16729 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16668 | 16730 | //viewer.updateInverseRotation(gl); |
---|