.. | .. |
---|
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 | |
---|
.. | .. |
---|
537 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
538 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
539 | 544 | LA.vecNormalize(obj.v2); |
---|
540 | | - gl.glNormal3f((float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
| 545 | + |
---|
| 546 | + SetGLNormal(gl, (float) obj.v2.x, (float) obj.v2.y, (float) obj.v2.z); |
---|
541 | 547 | } |
---|
542 | 548 | |
---|
543 | 549 | // P |
---|
.. | .. |
---|
559 | 565 | y += ny * obj.NORMALPUSH; |
---|
560 | 566 | z += nz * obj.NORMALPUSH; |
---|
561 | 567 | |
---|
562 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
563 | 569 | } |
---|
564 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
565 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
591 | 597 | y += ny * obj.NORMALPUSH; |
---|
592 | 598 | z += nz * obj.NORMALPUSH; |
---|
593 | 599 | |
---|
594 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
595 | 601 | } |
---|
596 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
597 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
639 | 645 | y += ny * obj.NORMALPUSH; |
---|
640 | 646 | z += nz * obj.NORMALPUSH; |
---|
641 | 647 | |
---|
642 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
643 | 649 | } |
---|
644 | 650 | |
---|
645 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
1245 | 1251 | { |
---|
1246 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1247 | 1253 | { |
---|
1248 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1249 | 1255 | } else |
---|
1250 | 1256 | { |
---|
1251 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1252 | 1258 | } |
---|
1253 | 1259 | |
---|
1254 | 1260 | if (c != null) |
---|
.. | .. |
---|
1272 | 1278 | { |
---|
1273 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1274 | 1280 | { |
---|
1275 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1276 | 1282 | } else |
---|
1277 | 1283 | { |
---|
1278 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1279 | 1285 | } |
---|
1280 | 1286 | if (c != null) |
---|
1281 | 1287 | { |
---|
.. | .. |
---|
1300 | 1306 | { |
---|
1301 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1302 | 1308 | { |
---|
1303 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1304 | 1310 | } else |
---|
1305 | 1311 | { |
---|
1306 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1307 | 1313 | } |
---|
1308 | 1314 | if (c != null) |
---|
1309 | 1315 | { |
---|
.. | .. |
---|
1485 | 1491 | { |
---|
1486 | 1492 | if (!selectmode) |
---|
1487 | 1493 | { |
---|
1488 | | - gl.glNormal3f((float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
| 1494 | + SetGLNormal(gl, (float) pv.norm.x, (float) pv.norm.y, (float) pv.norm.z); |
---|
1489 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1490 | 1496 | |
---|
1491 | 1497 | if (flipV) |
---|
.. | .. |
---|
1814 | 1820 | |
---|
1815 | 1821 | display.modelParams7[0] = 0; |
---|
1816 | 1822 | display.modelParams7[1] = 1000; |
---|
1817 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1818 | 1824 | display.modelParams7[3] = 0; |
---|
1819 | 1825 | |
---|
1820 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2047 | 2053 | switch(viewcode) |
---|
2048 | 2054 | { |
---|
2049 | 2055 | case 0: return "main"; |
---|
2050 | | - case 1: return "one"; |
---|
2051 | | - case 2: return "two"; |
---|
2052 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2053 | 2059 | case 4: return "light"; |
---|
2054 | 2060 | } |
---|
2055 | 2061 | |
---|
.. | .. |
---|
2470 | 2476 | return CreateBim(bytes, width, height); |
---|
2471 | 2477 | } |
---|
2472 | 2478 | |
---|
| 2479 | + private void SetGLNormal(javax.media.opengl.GL gl, float nx, float ny, float nz) |
---|
| 2480 | + { |
---|
| 2481 | + gl.glNormal3f(nx, ny, nz); |
---|
| 2482 | + |
---|
| 2483 | + if (ny > 0.9 || ny < -0.9) |
---|
| 2484 | + // Ground or ceiling |
---|
| 2485 | + gl.glVertexAttrib3f(4, 1, 0, 0); |
---|
| 2486 | + else |
---|
| 2487 | + // Walls |
---|
| 2488 | + gl.glVertexAttrib3f(4, 0, 1, 0); |
---|
| 2489 | + } |
---|
| 2490 | + |
---|
2473 | 2491 | /**/ |
---|
2474 | 2492 | class CacheTexture |
---|
2475 | 2493 | { |
---|
.. | .. |
---|
2512 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2513 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2514 | 2532 | true, |
---|
2515 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2516 | 2534 | } catch (java.io.IOException e) |
---|
2517 | 2535 | { |
---|
2518 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8358 | 8376 | // else |
---|
8359 | 8377 | // if (!texname.startsWith("/")) |
---|
8360 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8361 | | - if (!FileExists(texname)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8362 | 8380 | { |
---|
8363 | 8381 | texname = fallbackTextureName; |
---|
8364 | 8382 | } |
---|
.. | .. |
---|
8441 | 8459 | new Exception().printStackTrace(); |
---|
8442 | 8460 | } else |
---|
8443 | 8461 | { |
---|
| 8462 | + if (texname.startsWith("@")) |
---|
| 8463 | + { |
---|
| 8464 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8465 | + if (texturecache == null) |
---|
| 8466 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8467 | + else |
---|
| 8468 | + new Exception().printStackTrace(); |
---|
| 8469 | + } else |
---|
| 8470 | + { |
---|
8444 | 8471 | if (textureon) |
---|
8445 | 8472 | { |
---|
8446 | 8473 | String cachename = texname; |
---|
.. | .. |
---|
8500 | 8527 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8501 | 8528 | //texture = GetTexture(tex, bump); |
---|
8502 | 8529 | } |
---|
| 8530 | + } |
---|
8503 | 8531 | } |
---|
8504 | 8532 | //} |
---|
8505 | 8533 | } |
---|
.. | .. |
---|
8768 | 8796 | |
---|
8769 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8770 | 8798 | MAXSTACK = temp[0]; |
---|
8771 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8772 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8773 | 8802 | MAXSTACK = temp[0]; |
---|
8774 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8775 | 8805 | |
---|
8776 | 8806 | // Use debug pipeline |
---|
8777 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8779 | 8809 | gl = drawable.getGL(); // |
---|
8780 | 8810 | |
---|
8781 | 8811 | GL gl3 = getGL(); |
---|
8782 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8783 | 8814 | |
---|
8784 | 8815 | |
---|
8785 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
9220 | 9251 | |
---|
9221 | 9252 | void LoadEnvy(int which) |
---|
9222 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9223 | 9256 | String name; |
---|
9224 | 9257 | String ext; |
---|
9225 | 9258 | |
---|
.. | .. |
---|
10670 | 10703 | static boolean init = false; |
---|
10671 | 10704 | |
---|
10672 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10673 | 10709 | |
---|
10674 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10675 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10676 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10677 | 10719 | { |
---|
10678 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10841 | 10883 | |
---|
10842 | 10884 | if (wait) |
---|
10843 | 10885 | { |
---|
10844 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10845 | 10887 | |
---|
10846 | 10888 | wait = false; |
---|
10847 | 10889 | } |
---|
.. | .. |
---|
11064 | 11106 | // |
---|
11065 | 11107 | // newenvy = -1; |
---|
11066 | 11108 | |
---|
11067 | | - if (object.skyboxname != null) |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11068 | 11110 | { |
---|
11069 | | - if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11111 | + if (cubemaprgb == null) |
---|
11070 | 11112 | { |
---|
11071 | | - LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
11072 | | - loadedskyboxname = object.skyboxname; |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
11073 | 11114 | } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
11074 | 11117 | } |
---|
11075 | 11118 | else |
---|
11076 | 11119 | { |
---|
11077 | | - cubemap = null; |
---|
11078 | | - loadedskyboxname = null; |
---|
| 11120 | + if (object.skyboxname != null) |
---|
| 11121 | + { |
---|
| 11122 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11123 | + { |
---|
| 11124 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11125 | + cubemap.dispose(); |
---|
| 11126 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11127 | + loadedskyboxname = object.skyboxname; |
---|
| 11128 | + } |
---|
| 11129 | + } |
---|
| 11130 | + else |
---|
| 11131 | + { |
---|
| 11132 | + cubemapcustom = null; |
---|
| 11133 | + loadedskyboxname = null; |
---|
| 11134 | + } |
---|
| 11135 | + |
---|
| 11136 | + cubemap = cubemapcustom; |
---|
11079 | 11137 | } |
---|
11080 | 11138 | |
---|
11081 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
.. | .. |
---|
12548 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12549 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12550 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12551 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12552 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12553 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12554 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12793 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12794 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12795 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12796 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12797 | 12855 | /* |
---|
12798 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12799 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12879 | 12937 | "SUB bump0, bump0, half;" + |
---|
12880 | 12938 | "ADD bump, bump, bump0;" + |
---|
12881 | 12939 | |
---|
12882 | | - "MOV temp.x, texSamp.a;" + |
---|
12883 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12884 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12885 | | - "MOV texSamp.a, temp.x;" + |
---|
12886 | | - |
---|
12887 | 12940 | // double-sided |
---|
12888 | 12941 | /**/ |
---|
12889 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12900 | 12953 | "MOV normald, normal;" + |
---|
12901 | 12954 | "MOV normals, normal;" + |
---|
12902 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12903 | 12958 | // UV base |
---|
12904 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12905 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12906 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12907 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12908 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12909 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12962 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12963 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12964 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12965 | + Normalize("UP") + |
---|
| 12966 | + |
---|
12910 | 12967 | "XPD V, normal, UP;" + |
---|
12911 | 12968 | Normalize("V") + |
---|
12912 | 12969 | "XPD U, V, normal;" + |
---|
12913 | 12970 | Normalize("U") + |
---|
12914 | 12971 | |
---|
12915 | 12972 | // parallax mapping |
---|
| 12973 | + |
---|
| 12974 | + "DP3 temp2.x, V, eye;" + |
---|
| 12975 | + "DP3 temp2.y, U, eye;" + |
---|
| 12976 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12977 | + "RCP temp2.z, temp2.z;" + |
---|
| 12978 | + |
---|
| 12979 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12980 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12981 | + "RCP temp2.w, temp2.w;" + |
---|
| 12982 | + |
---|
| 12983 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12984 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12985 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12986 | + |
---|
| 12987 | + //"MOV texSamp, U;" + |
---|
| 12988 | + |
---|
| 12989 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12990 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12991 | + |
---|
| 12992 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12993 | + |
---|
| 12994 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 12995 | + |
---|
| 12996 | + "SUB temp, temp, temp2;" + |
---|
| 12997 | + |
---|
| 12998 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 12999 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13000 | + |
---|
| 13001 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13002 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13003 | + |
---|
| 13004 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13005 | + |
---|
| 13006 | +// parallax mapping |
---|
| 13007 | + |
---|
| 13008 | + "MOV temp.x, texSamp.a;" + |
---|
| 13009 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13010 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13011 | + "MOV texSamp.a, temp.x;" + |
---|
12916 | 13012 | |
---|
12917 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12918 | 13014 | // |
---|
.. | .. |
---|
13383 | 13479 | program = programmin; |
---|
13384 | 13480 | } |
---|
13385 | 13481 | |
---|
13386 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13387 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13482 | + if (Globals.DEBUG) |
---|
| 13483 | + { |
---|
| 13484 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13485 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
13388 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13389 | 13489 | |
---|
13390 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13431 | 13531 | "\n" + |
---|
13432 | 13532 | "END\n"; |
---|
13433 | 13533 | |
---|
13434 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13435 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13436 | 13537 | |
---|
13437 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13689 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13690 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13691 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13692 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13793 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13693 | 13794 | |
---|
13694 | 13795 | //Object3D.cVector2[] vector2buffer; |
---|
13695 | 13796 | |
---|
.. | .. |
---|
13856 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13857 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13858 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13859 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13860 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13861 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13862 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13917 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13918 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13919 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13920 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13921 | 14022 | "MOV result.texcoord, temp;" + |
---|
13922 | 14023 | // border fade |
---|
13923 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13964 | 14065 | |
---|
13965 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
13966 | 14067 | |
---|
13967 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
13968 | 14071 | : "MOV result.color, vertex.color;") + |
---|
13969 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13970 | 14073 | : "") + |
---|
.. | .. |
---|
14630 | 14733 | void GoDown(int mod) |
---|
14631 | 14734 | { |
---|
14632 | 14735 | MODIFIERS |= COMMAND; |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14633 | 14737 | /**/ |
---|
14634 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
14635 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
14636 | 14745 | else |
---|
14637 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14638 | 14747 | /**/ |
---|
14639 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
14640 | 14749 | { |
---|
.. | .. |
---|
14644 | 14753 | mouseMode |= BACKFORTH; |
---|
14645 | 14754 | } |
---|
14646 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
14647 | 14758 | //prevX = X = anchorX; |
---|
14648 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14649 | 14760 | } |
---|
.. | .. |
---|
14652 | 14763 | { |
---|
14653 | 14764 | MODIFIERS |= COMMAND; |
---|
14654 | 14765 | /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
14655 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
14656 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
14657 | 14775 | else |
---|
14658 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14659 | 14777 | /**/ |
---|
14660 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
14661 | 14779 | { |
---|
.. | .. |
---|
14665 | 14783 | mouseMode |= BACKFORTH; |
---|
14666 | 14784 | } |
---|
14667 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
14668 | 14788 | //prevX = X = anchorX; |
---|
14669 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14670 | 14790 | } |
---|
.. | .. |
---|
14674 | 14794 | MODIFIERS |= COMMAND; |
---|
14675 | 14795 | /**/ |
---|
14676 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
14677 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14678 | 14798 | else |
---|
14679 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
14680 | 14805 | /**/ |
---|
14681 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
14682 | 14807 | { |
---|
.. | .. |
---|
14686 | 14811 | mouseMode |= ROTATE; |
---|
14687 | 14812 | } // TRANSLATE; |
---|
14688 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
14689 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14690 | 14817 | prevY = Y = anchorY; |
---|
14691 | 14818 | } |
---|
.. | .. |
---|
14695 | 14822 | MODIFIERS |= COMMAND; |
---|
14696 | 14823 | /**/ |
---|
14697 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
14698 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14699 | 14826 | else |
---|
14700 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
14701 | 14834 | /**/ |
---|
14702 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
14703 | 14836 | { |
---|
.. | .. |
---|
14707 | 14840 | mouseMode |= ROTATE; |
---|
14708 | 14841 | } // TRANSLATE; |
---|
14709 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
14710 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14711 | 14846 | prevY = Y = anchorY; |
---|
14712 | 14847 | } |
---|
.. | .. |
---|
15209 | 15344 | case 'K': |
---|
15210 | 15345 | KOMPACTTEXTURE ^= true; |
---|
15211 | 15346 | //textures.clear(); |
---|
15212 | | - break; |
---|
15213 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
15214 | 15349 | // SAVETEXTURE ^= true; |
---|
15215 | 15350 | macromode = true; |
---|
15216 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15331 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
15332 | 15467 | repaint(); |
---|
15333 | 15468 | break; |
---|
15334 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
15335 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
15336 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
15337 | 15472 | repaint(); |
---|
.. | .. |
---|
16091 | 16226 | { |
---|
16092 | 16227 | switch (hitSomething) |
---|
16093 | 16228 | { |
---|
16094 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16229 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16095 | 16230 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16096 | 16231 | break; |
---|
16097 | 16232 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
16117 | 16252 | if (hasMarquee) |
---|
16118 | 16253 | { |
---|
16119 | 16254 | gr.setXORMode(Color.white); |
---|
16120 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
16121 | 16256 | if (!firstime) |
---|
16122 | 16257 | { |
---|
16123 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16657 | 16792 | private void DrawSkyBox(GL gl, float ratio) |
---|
16658 | 16793 | { |
---|
16659 | 16794 | if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
16660 | 16796 | cubemap == null) |
---|
16661 | 16797 | { |
---|
16662 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
.. | .. |
---|
16755 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16756 | 16892 | |
---|
16757 | 16893 | cubemap.disable(); |
---|
16758 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
16759 | 16896 | if (CULLFACE) |
---|
16760 | 16897 | { |
---|
16761 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16811 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16812 | 16949 | } |
---|
16813 | 16950 | |
---|
16814 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16815 | 16952 | |
---|
16816 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16817 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
17291 | 17428 | |
---|
17292 | 17429 | public void init(GLAutoDrawable drawable) |
---|
17293 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
17294 | 17432 | System.out.println("shadow buffer init"); |
---|
17295 | 17433 | |
---|
17296 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17519 | 17657 | gl.glFlush(); |
---|
17520 | 17658 | |
---|
17521 | 17659 | /**/ |
---|
17522 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17660 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17523 | 17661 | |
---|
17524 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17525 | 17663 | |
---|
| 17664 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17665 | + |
---|
| 17666 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17667 | + |
---|
17526 | 17668 | double r = 0, g = 0, b = 0; |
---|
17527 | 17669 | |
---|
17528 | 17670 | double count = 0; |
---|
.. | .. |
---|
17533 | 17675 | |
---|
17534 | 17676 | double FACTOR = 1; |
---|
17535 | 17677 | |
---|
17536 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
17537 | 17679 | { |
---|
17538 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17539 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17616 | 17758 | |
---|
17617 | 17759 | double scale = ray.z; // 1; // cos |
---|
17618 | 17760 | |
---|
17619 | | - float depth = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
17620 | 17762 | |
---|
17621 | 17763 | /* |
---|
17622 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17813 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17814 | 17956 | static IntBuffer bigAAbuffer; |
---|
17815 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17816 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17817 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17818 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17819 | 17961 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17820 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17962 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17963 | + |
---|
| 17964 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17965 | + |
---|
17821 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17822 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17823 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|