.. | .. |
---|
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 | |
---|
.. | .. |
---|
1814 | 1819 | |
---|
1815 | 1820 | display.modelParams7[0] = 0; |
---|
1816 | 1821 | display.modelParams7[1] = 1000; |
---|
1817 | | - display.modelParams7[2] = 0; |
---|
| 1822 | + display.modelParams7[2] = material.parallax; |
---|
1818 | 1823 | display.modelParams7[3] = 0; |
---|
1819 | 1824 | |
---|
1820 | 1825 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
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;" + |
---|
.. | .. |
---|
12541 | 12593 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12542 | 12594 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12543 | 12595 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12544 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12596 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12545 | 12597 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12546 | 12598 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12547 | 12599 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12786 | 12838 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12787 | 12839 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12788 | 12840 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12789 | | - "KIL alpha.a;" + |
---|
| 12841 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12790 | 12842 | /* |
---|
12791 | 12843 | "MUL temp.xy, temp, two;" + |
---|
12792 | 12844 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12872 | 12924 | "SUB bump0, bump0, half;" + |
---|
12873 | 12925 | "ADD bump, bump, bump0;" + |
---|
12874 | 12926 | |
---|
12875 | | - "MOV temp.x, texSamp.a;" + |
---|
12876 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12877 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12878 | | - "MOV texSamp.a, temp.x;" + |
---|
12879 | | - |
---|
12880 | 12927 | // double-sided |
---|
12881 | 12928 | /**/ |
---|
12882 | 12929 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12906 | 12953 | Normalize("U") + |
---|
12907 | 12954 | |
---|
12908 | 12955 | // parallax mapping |
---|
| 12956 | + |
---|
| 12957 | + "DP3 temp2.x, V, eye;" + |
---|
| 12958 | + "DP3 temp2.y, U, eye;" + |
---|
| 12959 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12960 | + "RCP temp2.z, temp2.z;" + |
---|
| 12961 | + |
---|
| 12962 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12963 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12964 | + "RCP temp2.w, temp2.w;" + |
---|
| 12965 | + |
---|
| 12966 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12967 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12968 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12969 | + |
---|
| 12970 | + //"MOV texSamp, U;" + |
---|
| 12971 | + |
---|
| 12972 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12973 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12974 | + |
---|
| 12975 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12976 | + |
---|
| 12977 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12978 | + |
---|
| 12979 | + "SUB temp, temp, temp2;" + |
---|
| 12980 | + |
---|
| 12981 | + "TEX texSamp, temp, texture[0], 2D;" + |
---|
| 12982 | + "POW texSamp.a, texSamp.a, params6.w;" + // punch through |
---|
| 12983 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 12984 | + |
---|
| 12985 | +// parallax mapping |
---|
| 12986 | + |
---|
| 12987 | + "MOV temp.x, texSamp.a;" + |
---|
| 12988 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 12989 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 12990 | + "MOV texSamp.a, temp.x;" + |
---|
12909 | 12991 | |
---|
12910 | 12992 | //"MOV temp, fragment.texcoord[0];" + |
---|
12911 | 12993 | // |
---|
.. | .. |
---|
13369 | 13451 | //once = true; |
---|
13370 | 13452 | } |
---|
13371 | 13453 | |
---|
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 " : "")); |
---|
| 13454 | + String program = programmax; |
---|
| 13455 | + |
---|
| 13456 | + if (Globals.MINSHADER) |
---|
| 13457 | + { |
---|
| 13458 | + program = programmin; |
---|
| 13459 | + } |
---|
| 13460 | + |
---|
| 13461 | + if (Globals.DEBUG) |
---|
| 13462 | + { |
---|
| 13463 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13464 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13465 | + } |
---|
| 13466 | + |
---|
13374 | 13467 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13468 | |
---|
13376 | 13469 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13417 | 13510 | "\n" + |
---|
13418 | 13511 | "END\n"; |
---|
13419 | 13512 | |
---|
13420 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13513 | + if (Globals.DEBUG) |
---|
| 13514 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13421 | 13515 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13422 | 13516 | |
---|
13423 | 13517 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13675 | 13769 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13676 | 13770 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13677 | 13771 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13678 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13772 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13679 | 13773 | |
---|
13680 | 13774 | //Object3D.cVector2[] vector2buffer; |
---|
13681 | 13775 | |
---|
.. | .. |
---|
14616 | 14710 | void GoDown(int mod) |
---|
14617 | 14711 | { |
---|
14618 | 14712 | MODIFIERS |= COMMAND; |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14619 | 14714 | /**/ |
---|
14620 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
14621 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14721 | + } |
---|
14622 | 14722 | else |
---|
14623 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14723 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14624 | 14724 | /**/ |
---|
14625 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14626 | 14726 | { |
---|
.. | .. |
---|
14630 | 14730 | mouseMode |= BACKFORTH; |
---|
14631 | 14731 | } |
---|
14632 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14633 | 14735 | //prevX = X = anchorX; |
---|
14634 | 14736 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14635 | 14737 | } |
---|
.. | .. |
---|
14638 | 14740 | { |
---|
14639 | 14741 | MODIFIERS |= COMMAND; |
---|
14640 | 14742 | /**/ |
---|
| 14743 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14744 | + |
---|
14641 | 14745 | if((mod&SHIFT) == SHIFT) |
---|
14642 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14746 | + { |
---|
| 14747 | + if (isVR) |
---|
| 14748 | + manipCamera.RotateInterest(0, speed); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(0, speed); |
---|
| 14751 | + } |
---|
14643 | 14752 | else |
---|
14644 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14753 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14645 | 14754 | /**/ |
---|
14646 | 14755 | if ((mod & SHIFT) == SHIFT) |
---|
14647 | 14756 | { |
---|
.. | .. |
---|
14651 | 14760 | mouseMode |= BACKFORTH; |
---|
14652 | 14761 | } |
---|
14653 | 14762 | |
---|
| 14763 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14764 | + |
---|
14654 | 14765 | //prevX = X = anchorX; |
---|
14655 | 14766 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14656 | 14767 | } |
---|
.. | .. |
---|
14660 | 14771 | MODIFIERS |= COMMAND; |
---|
14661 | 14772 | /**/ |
---|
14662 | 14773 | if((mod&SHIFT) == SHIFT) |
---|
14663 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14774 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14664 | 14775 | else |
---|
14665 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14776 | + { |
---|
| 14777 | + if ((mouseMode&VR)!=0) |
---|
| 14778 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14779 | + else |
---|
| 14780 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14781 | + } |
---|
14666 | 14782 | /**/ |
---|
14667 | 14783 | if ((mod & SHIFT) == SHIFT) |
---|
14668 | 14784 | { |
---|
.. | .. |
---|
14672 | 14788 | mouseMode |= ROTATE; |
---|
14673 | 14789 | } // TRANSLATE; |
---|
14674 | 14790 | |
---|
| 14791 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14792 | + |
---|
14675 | 14793 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14676 | 14794 | prevY = Y = anchorY; |
---|
14677 | 14795 | } |
---|
.. | .. |
---|
14681 | 14799 | MODIFIERS |= COMMAND; |
---|
14682 | 14800 | /**/ |
---|
14683 | 14801 | if((mod&SHIFT) == SHIFT) |
---|
14684 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14802 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14685 | 14803 | else |
---|
14686 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14804 | + { |
---|
| 14805 | + if ((mouseMode&VR)!=0) |
---|
| 14806 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14807 | + else |
---|
| 14808 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14809 | + } |
---|
| 14810 | + |
---|
14687 | 14811 | /**/ |
---|
14688 | 14812 | if ((mod & SHIFT) == SHIFT) |
---|
14689 | 14813 | { |
---|
.. | .. |
---|
14693 | 14817 | mouseMode |= ROTATE; |
---|
14694 | 14818 | } // TRANSLATE; |
---|
14695 | 14819 | |
---|
| 14820 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14821 | + |
---|
14696 | 14822 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14697 | 14823 | prevY = Y = anchorY; |
---|
14698 | 14824 | } |
---|
.. | .. |
---|
15195 | 15321 | case 'K': |
---|
15196 | 15322 | KOMPACTTEXTURE ^= true; |
---|
15197 | 15323 | //textures.clear(); |
---|
15198 | | - break; |
---|
15199 | | - case 'P': // Texture Projection macros |
---|
| 15324 | + // break; |
---|
| 15325 | + //case 'P': // Texture Projection macros |
---|
15200 | 15326 | // SAVETEXTURE ^= true; |
---|
15201 | 15327 | macromode = true; |
---|
15202 | 15328 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15317 | 15443 | targetLookAt.set(manipCamera.lookAt); |
---|
15318 | 15444 | repaint(); |
---|
15319 | 15445 | break; |
---|
15320 | | - case 'p': |
---|
| 15446 | + case 'P': // p': |
---|
15321 | 15447 | // c'est quoi ca au juste? spherical ^= true; |
---|
15322 | 15448 | Skinshader ^= true; programInitialized = false; |
---|
15323 | 15449 | repaint(); |
---|
.. | .. |
---|
15362 | 15488 | OCCLUSION_CULLING ^= true; |
---|
15363 | 15489 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15364 | 15490 | break; |
---|
15365 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15491 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15366 | 15492 | case '1': |
---|
15367 | 15493 | case '2': |
---|
15368 | 15494 | case '3': |
---|
.. | .. |
---|
15372 | 15498 | case '7': |
---|
15373 | 15499 | case '8': |
---|
15374 | 15500 | case '9': |
---|
15375 | | - if (envyoff) |
---|
| 15501 | + if (true) // envyoff) |
---|
15376 | 15502 | { |
---|
15377 | 15503 | BGcolor = (key - '1')/8.f; |
---|
15378 | 15504 | } |
---|
.. | .. |
---|
16077 | 16203 | { |
---|
16078 | 16204 | switch (hitSomething) |
---|
16079 | 16205 | { |
---|
16080 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16206 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16081 | 16207 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16082 | 16208 | break; |
---|
16083 | 16209 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16084 | 16210 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16085 | 16211 | break; |
---|
16086 | 16212 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16087 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16213 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16088 | 16214 | break; |
---|
16089 | 16215 | } |
---|
16090 | 16216 | |
---|
.. | .. |
---|
16103 | 16229 | if (hasMarquee) |
---|
16104 | 16230 | { |
---|
16105 | 16231 | gr.setXORMode(Color.white); |
---|
16106 | | - gr.setColor(Color.red); |
---|
| 16232 | + gr.setColor(Color.white); |
---|
16107 | 16233 | if (!firstime) |
---|
16108 | 16234 | { |
---|
16109 | 16235 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16633 | 16759 | |
---|
16634 | 16760 | return cubemap; |
---|
16635 | 16761 | } |
---|
| 16762 | + |
---|
16636 | 16763 | int bigsphere = -1; |
---|
16637 | 16764 | |
---|
16638 | 16765 | float BGcolor = 0.5f; |
---|
.. | .. |
---|
16641 | 16768 | |
---|
16642 | 16769 | private void DrawSkyBox(GL gl, float ratio) |
---|
16643 | 16770 | { |
---|
16644 | | - if (envyoff || cubemap == null) |
---|
| 16771 | + if (//envyoff || |
---|
| 16772 | + WIREFRAME || |
---|
| 16773 | + cubemap == null) |
---|
16645 | 16774 | { |
---|
16646 | 16775 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16647 | 16776 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16658 | 16787 | gl.glLoadIdentity(); |
---|
16659 | 16788 | gl.glScalef(1,ratio,1); |
---|
16660 | 16789 | |
---|
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); |
---|
| 16790 | +// colorV[0] = 2; |
---|
| 16791 | +// colorV[1] = 2; |
---|
| 16792 | +// colorV[2] = 2; |
---|
| 16793 | +// colorV[3] = 1; |
---|
| 16794 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16795 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16796 | +// |
---|
| 16797 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
16669 | 16798 | |
---|
16670 | 16799 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16671 | 16800 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
.. | .. |
---|
16679 | 16808 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16680 | 16809 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16681 | 16810 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16682 | | - gl.glEnable(GL.GL_LIGHTING); |
---|
| 16811 | + gl.glDisable(GL.GL_LIGHTING); |
---|
16683 | 16812 | |
---|
16684 | 16813 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16685 | 16814 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16739 | 16868 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16740 | 16869 | |
---|
16741 | 16870 | cubemap.disable(); |
---|
16742 | | - ////cubemap.unbind(); |
---|
| 16871 | + //cubemap.dispose(); |
---|
| 16872 | + |
---|
16743 | 16873 | if (CULLFACE) |
---|
16744 | 16874 | { |
---|
16745 | 16875 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17275 | 17405 | |
---|
17276 | 17406 | public void init(GLAutoDrawable drawable) |
---|
17277 | 17407 | { |
---|
| 17408 | + if (Globals.DEBUG) |
---|
17278 | 17409 | System.out.println("shadow buffer init"); |
---|
17279 | 17410 | |
---|
17280 | 17411 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17503 | 17634 | gl.glFlush(); |
---|
17504 | 17635 | |
---|
17505 | 17636 | /**/ |
---|
17506 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17637 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17507 | 17638 | |
---|
17508 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17639 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17509 | 17640 | |
---|
| 17641 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17642 | + |
---|
| 17643 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17644 | + |
---|
17510 | 17645 | double r = 0, g = 0, b = 0; |
---|
17511 | 17646 | |
---|
17512 | 17647 | double count = 0; |
---|
.. | .. |
---|
17517 | 17652 | |
---|
17518 | 17653 | double FACTOR = 1; |
---|
17519 | 17654 | |
---|
17520 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17655 | + for (int i = 0; i < depths.length; i++) |
---|
17521 | 17656 | { |
---|
17522 | 17657 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17523 | 17658 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17600 | 17735 | |
---|
17601 | 17736 | double scale = ray.z; // 1; // cos |
---|
17602 | 17737 | |
---|
17603 | | - float depth = pixels[newindex]; |
---|
| 17738 | + float depth = depths[newindex]; |
---|
17604 | 17739 | |
---|
17605 | 17740 | /* |
---|
17606 | 17741 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17797 | 17932 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17798 | 17933 | static IntBuffer bigAAbuffer; |
---|
17799 | 17934 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17800 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17935 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17801 | 17936 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17802 | 17937 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17803 | 17938 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17804 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17939 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17940 | + |
---|
| 17941 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17942 | + |
---|
17805 | 17943 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17806 | 17944 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17807 | 17945 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|