.. | .. |
---|
110 | 110 | //private Mat4f spotlightTransform = new Mat4f(); |
---|
111 | 111 | //private Mat4f spotlightInverseTransform = new Mat4f(); |
---|
112 | 112 | static GLContext glcontext = null; |
---|
113 | | - /*static*/ com.sun.opengl.util.texture.Texture cubemap; |
---|
| 113 | + /*static*/ com.sun.opengl.util.texture.Texture cubemap; // Either custom or rgb |
---|
| 114 | + /*static*/ com.sun.opengl.util.texture.Texture cubemapcustom; |
---|
| 115 | + /*static*/ com.sun.opengl.util.texture.Texture cubemaprgb; |
---|
| 116 | + boolean transformMode; |
---|
| 117 | + |
---|
114 | 118 | boolean reverseUP = false; |
---|
115 | 119 | static boolean frozen = false; |
---|
116 | 120 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
164 | 168 | |
---|
165 | 169 | |
---|
166 | 170 | // OPTIONS |
---|
167 | | - boolean Skinshader = true; |
---|
| 171 | + boolean Skinshader = false; // true; |
---|
168 | 172 | boolean cameraLight = false; |
---|
169 | 173 | boolean UVdebug = false; |
---|
170 | 174 | boolean Udebug = false; |
---|
.. | .. |
---|
173 | 177 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 178 | boolean anisotropy = true; |
---|
175 | 179 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 180 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 181 | |
---|
178 | 182 | boolean macromode = false; |
---|
179 | 183 | |
---|
.. | .. |
---|
188 | 192 | |
---|
189 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
190 | 194 | |
---|
191 | | - public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
192 | 196 | { |
---|
193 | 197 | try |
---|
194 | 198 | { |
---|
195 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
196 | 200 | } catch (IOException e) |
---|
197 | 201 | { |
---|
198 | 202 | System.out.println("NAME = " + name); |
---|
199 | 203 | e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
200 | 205 | } |
---|
201 | 206 | } |
---|
202 | 207 | |
---|
.. | .. |
---|
2047 | 2052 | switch(viewcode) |
---|
2048 | 2053 | { |
---|
2049 | 2054 | case 0: return "main"; |
---|
2050 | | - case 1: return "one"; |
---|
2051 | | - case 2: return "two"; |
---|
2052 | | - case 3: return "three"; |
---|
| 2055 | + case 1: return "Red"; |
---|
| 2056 | + case 2: return "Green"; |
---|
| 2057 | + case 3: return "Blue"; |
---|
2053 | 2058 | case 4: return "light"; |
---|
2054 | 2059 | } |
---|
2055 | 2060 | |
---|
.. | .. |
---|
2512 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2514 | 2519 | true, |
---|
2515 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2516 | 2521 | } catch (java.io.IOException e) |
---|
2517 | 2522 | { |
---|
2518 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8358 | 8363 | // else |
---|
8359 | 8364 | // if (!texname.startsWith("/")) |
---|
8360 | 8365 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8361 | | - if (!FileExists(texname)) |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8362 | 8367 | { |
---|
8363 | 8368 | texname = fallbackTextureName; |
---|
8364 | 8369 | } |
---|
.. | .. |
---|
8441 | 8446 | new Exception().printStackTrace(); |
---|
8442 | 8447 | } else |
---|
8443 | 8448 | { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
| 8456 | + } else |
---|
| 8457 | + { |
---|
8444 | 8458 | if (textureon) |
---|
8445 | 8459 | { |
---|
8446 | 8460 | String cachename = texname; |
---|
.. | .. |
---|
8500 | 8514 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8501 | 8515 | //texture = GetTexture(tex, bump); |
---|
8502 | 8516 | } |
---|
| 8517 | + } |
---|
8503 | 8518 | } |
---|
8504 | 8519 | //} |
---|
8505 | 8520 | } |
---|
.. | .. |
---|
8768 | 8783 | |
---|
8769 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8770 | 8785 | MAXSTACK = temp[0]; |
---|
8771 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8772 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8773 | 8789 | MAXSTACK = temp[0]; |
---|
8774 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8775 | 8792 | |
---|
8776 | 8793 | // Use debug pipeline |
---|
8777 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8779 | 8796 | gl = drawable.getGL(); // |
---|
8780 | 8797 | |
---|
8781 | 8798 | GL gl3 = getGL(); |
---|
8782 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8783 | 8801 | |
---|
8784 | 8802 | |
---|
8785 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
9220 | 9238 | |
---|
9221 | 9239 | void LoadEnvy(int which) |
---|
9222 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9223 | 9243 | String name; |
---|
9224 | 9244 | String ext; |
---|
9225 | 9245 | |
---|
.. | .. |
---|
9316 | 9336 | double[] light2camera = new double[16]; |
---|
9317 | 9337 | |
---|
9318 | 9338 | //int newenvy = -1; |
---|
9319 | | - boolean envyoff = true; // false; |
---|
9320 | | - String skyboxname = ""; |
---|
9321 | | - String skyboxext; |
---|
9322 | | - String loadedskyboxname = ""; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
9323 | 9342 | |
---|
9324 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9325 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
.. | .. |
---|
10671 | 10690 | static boolean init = false; |
---|
10672 | 10691 | |
---|
10673 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
10674 | 10696 | |
---|
10675 | 10697 | public void display(GLAutoDrawable drawable) |
---|
10676 | 10698 | { |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
| 10700 | + { |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
10677 | 10705 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10678 | 10706 | { |
---|
10679 | 10707 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10842 | 10870 | |
---|
10843 | 10871 | if (wait) |
---|
10844 | 10872 | { |
---|
10845 | | - Sleep(500); |
---|
| 10873 | + Sleep(200); // blocks everything |
---|
10846 | 10874 | |
---|
10847 | 10875 | wait = false; |
---|
10848 | 10876 | } |
---|
.. | .. |
---|
11065 | 11093 | // |
---|
11066 | 11094 | // newenvy = -1; |
---|
11067 | 11095 | |
---|
11068 | | - if (!skyboxname.equals(this.loadedskyboxname)) |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11069 | 11097 | { |
---|
11070 | | - LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
11071 | | - loadedskyboxname = skyboxname; |
---|
| 11098 | + if (cubemaprgb == null) |
---|
| 11099 | + { |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11101 | + } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
| 11104 | + } |
---|
| 11105 | + else |
---|
| 11106 | + { |
---|
| 11107 | + if (object.skyboxname != null) |
---|
| 11108 | + { |
---|
| 11109 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11110 | + { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
| 11113 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11114 | + loadedskyboxname = object.skyboxname; |
---|
| 11115 | + } |
---|
| 11116 | + } |
---|
| 11117 | + else |
---|
| 11118 | + { |
---|
| 11119 | + cubemapcustom = null; |
---|
| 11120 | + loadedskyboxname = null; |
---|
| 11121 | + } |
---|
| 11122 | + |
---|
| 11123 | + cubemap = cubemapcustom; |
---|
11072 | 11124 | } |
---|
11073 | 11125 | |
---|
11074 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
11372 | 11424 | |
---|
11373 | 11425 | // if (cam != lightCamera) |
---|
11374 | 11426 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11375 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11427 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11376 | 11428 | } |
---|
11377 | 11429 | |
---|
11378 | 11430 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12446 | 12498 | |
---|
12447 | 12499 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12448 | 12500 | |
---|
12449 | | - String program0 = |
---|
| 12501 | + String programmin = |
---|
12450 | 12502 | // Min shader |
---|
12451 | 12503 | "!!ARBfp1.0\n" + |
---|
12452 | 12504 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12513 | 12565 | "MOV result.color, temp;" + |
---|
12514 | 12566 | "END"; |
---|
12515 | 12567 | |
---|
12516 | | - String program = |
---|
| 12568 | + String programmax = |
---|
12517 | 12569 | "!!ARBfp1.0\n" + |
---|
12518 | 12570 | |
---|
12519 | 12571 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
13038 | 13090 | // display shadow only (fakedepth == 0) |
---|
13039 | 13091 | "SUB temp.x, half.x, shadow.x;" + |
---|
13040 | 13092 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
13041 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13093 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
13042 | 13094 | "SUB temp.y, one.x, temp.z;" + |
---|
13043 | 13095 | "MUL temp.x, temp.x, temp.y;" + |
---|
13044 | 13096 | "KIL temp.x;" + |
---|
.. | .. |
---|
13369 | 13421 | //once = true; |
---|
13370 | 13422 | } |
---|
13371 | 13423 | |
---|
13372 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13373 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13424 | + String program = programmax; |
---|
| 13425 | + |
---|
| 13426 | + if (Globals.MINSHADER) |
---|
| 13427 | + { |
---|
| 13428 | + program = programmin; |
---|
| 13429 | + } |
---|
| 13430 | + |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
13374 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13438 | |
---|
13376 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13417 | 13480 | "\n" + |
---|
13418 | 13481 | "END\n"; |
---|
13419 | 13482 | |
---|
13420 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13421 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13422 | 13486 | |
---|
13423 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
14616 | 14680 | void GoDown(int mod) |
---|
14617 | 14681 | { |
---|
14618 | 14682 | MODIFIERS |= COMMAND; |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14619 | 14684 | /**/ |
---|
14620 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
14622 | 14692 | else |
---|
14623 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14624 | 14694 | /**/ |
---|
14625 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14696 | { |
---|
.. | .. |
---|
14630 | 14700 | mouseMode |= BACKFORTH; |
---|
14631 | 14701 | } |
---|
14632 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
14633 | 14705 | //prevX = X = anchorX; |
---|
14634 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14635 | 14707 | } |
---|
.. | .. |
---|
14638 | 14710 | { |
---|
14639 | 14711 | MODIFIERS |= COMMAND; |
---|
14640 | 14712 | /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
14641 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
14643 | 14722 | else |
---|
14644 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14645 | 14724 | /**/ |
---|
14646 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14726 | { |
---|
.. | .. |
---|
14651 | 14730 | mouseMode |= BACKFORTH; |
---|
14652 | 14731 | } |
---|
14653 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14654 | 14735 | //prevX = X = anchorX; |
---|
14655 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14656 | 14737 | } |
---|
.. | .. |
---|
14660 | 14741 | MODIFIERS |= COMMAND; |
---|
14661 | 14742 | /**/ |
---|
14662 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
14663 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14664 | 14745 | else |
---|
14665 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
14666 | 14752 | /**/ |
---|
14667 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
14668 | 14754 | { |
---|
.. | .. |
---|
14672 | 14758 | mouseMode |= ROTATE; |
---|
14673 | 14759 | } // TRANSLATE; |
---|
14674 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
14675 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14676 | 14764 | prevY = Y = anchorY; |
---|
14677 | 14765 | } |
---|
.. | .. |
---|
14681 | 14769 | MODIFIERS |= COMMAND; |
---|
14682 | 14770 | /**/ |
---|
14683 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
14684 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14685 | 14773 | else |
---|
14686 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
14687 | 14781 | /**/ |
---|
14688 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
14689 | 14783 | { |
---|
.. | .. |
---|
14693 | 14787 | mouseMode |= ROTATE; |
---|
14694 | 14788 | } // TRANSLATE; |
---|
14695 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
14696 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14697 | 14793 | prevY = Y = anchorY; |
---|
14698 | 14794 | } |
---|
.. | .. |
---|
15195 | 15291 | case 'K': |
---|
15196 | 15292 | KOMPACTTEXTURE ^= true; |
---|
15197 | 15293 | //textures.clear(); |
---|
15198 | | - break; |
---|
15199 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
15200 | 15296 | // SAVETEXTURE ^= true; |
---|
15201 | 15297 | macromode = true; |
---|
15202 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15317 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
15318 | 15414 | repaint(); |
---|
15319 | 15415 | break; |
---|
15320 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
15321 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
15322 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
15323 | 15419 | repaint(); |
---|
.. | .. |
---|
15362 | 15458 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15459 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15460 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15461 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15462 | case '1': |
---|
15367 | 15463 | case '2': |
---|
15368 | 15464 | case '3': |
---|
.. | .. |
---|
15372 | 15468 | case '7': |
---|
15373 | 15469 | case '8': |
---|
15374 | 15470 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15471 | + if (true) // envyoff) |
---|
15376 | 15472 | { |
---|
15377 | 15473 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15474 | } |
---|
.. | .. |
---|
16077 | 16173 | { |
---|
16078 | 16174 | switch (hitSomething) |
---|
16079 | 16175 | { |
---|
16080 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16081 | 16177 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16082 | 16178 | break; |
---|
16083 | 16179 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16084 | 16180 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16181 | break; |
---|
16086 | 16182 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16183 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16184 | break; |
---|
16089 | 16185 | } |
---|
16090 | 16186 | |
---|
.. | .. |
---|
16103 | 16199 | if (hasMarquee) |
---|
16104 | 16200 | { |
---|
16105 | 16201 | gr.setXORMode(Color.white); |
---|
16106 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
16107 | 16203 | if (!firstime) |
---|
16108 | 16204 | { |
---|
16109 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16570 | 16666 | private /*static*/ boolean firstime; |
---|
16571 | 16667 | private /*static*/ cVector newView = new cVector(); |
---|
16572 | 16668 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16669 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16670 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16573 | 16671 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16574 | 16672 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16575 | 16673 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16582 | 16680 | { |
---|
16583 | 16681 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16584 | 16682 | |
---|
| 16683 | + int usedsuf = 0; |
---|
| 16684 | + |
---|
16585 | 16685 | for (int i = 0; i < suffixes.length; i++) |
---|
16586 | 16686 | { |
---|
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) |
---|
| 16687 | + String[] suffixe = suffixes; |
---|
| 16688 | + String[] fallback = suffixes2; |
---|
| 16689 | + String[] fallfallback = suffixes3; |
---|
| 16690 | + |
---|
| 16691 | + for (int c=usedsuf; --c>=0;) |
---|
16592 | 16692 | { |
---|
16593 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16693 | +// String[] temp = suffixe; |
---|
| 16694 | +// suffixe = fallback; |
---|
| 16695 | +// fallback = fallfallback; |
---|
| 16696 | +// fallfallback = temp; |
---|
16594 | 16697 | } |
---|
| 16698 | + |
---|
| 16699 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16700 | + TextureData data; |
---|
| 16701 | + |
---|
| 16702 | + try |
---|
| 16703 | + { |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e) |
---|
| 16709 | + { |
---|
| 16710 | + try |
---|
| 16711 | + { |
---|
| 16712 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16713 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16714 | + mipmapped, |
---|
| 16715 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16716 | + } |
---|
| 16717 | + catch (Exception e2) |
---|
| 16718 | + { |
---|
| 16719 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16720 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16721 | + mipmapped, |
---|
| 16722 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16723 | + } |
---|
| 16724 | + } |
---|
| 16725 | + |
---|
16595 | 16726 | //System.out.println("Target = " + targets[i]); |
---|
16596 | 16727 | cubemap.updateImage(data, targets[i]); |
---|
16597 | 16728 | } |
---|
16598 | 16729 | |
---|
16599 | 16730 | return cubemap; |
---|
16600 | 16731 | } |
---|
| 16732 | + |
---|
16601 | 16733 | int bigsphere = -1; |
---|
16602 | 16734 | |
---|
16603 | 16735 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16606 | 16738 | |
---|
16607 | 16739 | private void DrawSkyBox(GL gl, float ratio) |
---|
16608 | 16740 | { |
---|
16609 | | - if (envyoff || cubemap == null) |
---|
| 16741 | + if (//envyoff || |
---|
| 16742 | + WIREFRAME || |
---|
| 16743 | + cubemap == null) |
---|
16610 | 16744 | { |
---|
16611 | 16745 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16612 | 16746 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16623 | 16757 | gl.glLoadIdentity(); |
---|
16624 | 16758 | gl.glScalef(1,ratio,1); |
---|
16625 | 16759 | |
---|
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); |
---|
| 16760 | +// colorV[0] = 2; |
---|
| 16761 | +// colorV[1] = 2; |
---|
| 16762 | +// colorV[2] = 2; |
---|
| 16763 | +// colorV[3] = 1; |
---|
| 16764 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16765 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16766 | +// |
---|
| 16767 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16634 | 16768 | |
---|
16635 | 16769 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16636 | 16770 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16644 | 16778 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16645 | 16779 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16646 | 16780 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16647 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16781 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16648 | 16782 | |
---|
16649 | 16783 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16650 | 16784 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16663 | 16797 | { |
---|
16664 | 16798 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16665 | 16799 | } |
---|
| 16800 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16666 | 16801 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16667 | 16802 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16668 | 16803 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16703 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16704 | 16839 | |
---|
16705 | 16840 | cubemap.disable(); |
---|
16706 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
16707 | 16843 | if (CULLFACE) |
---|
16708 | 16844 | { |
---|
16709 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17239 | 17375 | |
---|
17240 | 17376 | public void init(GLAutoDrawable drawable) |
---|
17241 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
17242 | 17379 | System.out.println("shadow buffer init"); |
---|
17243 | 17380 | |
---|
17244 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17467 | 17604 | gl.glFlush(); |
---|
17468 | 17605 | |
---|
17469 | 17606 | /**/ |
---|
17470 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17471 | 17608 | |
---|
17472 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17473 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
17474 | 17615 | double r = 0, g = 0, b = 0; |
---|
17475 | 17616 | |
---|
17476 | 17617 | double count = 0; |
---|
.. | .. |
---|
17481 | 17622 | |
---|
17482 | 17623 | double FACTOR = 1; |
---|
17483 | 17624 | |
---|
17484 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
17485 | 17626 | { |
---|
17486 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17487 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17564 | 17705 | |
---|
17565 | 17706 | double scale = ray.z; // 1; // cos |
---|
17566 | 17707 | |
---|
17567 | | - float depth = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
17568 | 17709 | |
---|
17569 | 17710 | /* |
---|
17570 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17761 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17762 | 17903 | static IntBuffer bigAAbuffer; |
---|
17763 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17764 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17765 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17766 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17767 | 17908 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17768 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
17769 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17770 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17771 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|