.. | .. |
---|
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 | |
---|
.. | .. |
---|
187 | 191 | } |
---|
188 | 192 | |
---|
189 | 193 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 194 | + |
---|
| 195 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 196 | + { |
---|
| 197 | + try |
---|
| 198 | + { |
---|
| 199 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 200 | + } catch (IOException e) |
---|
| 201 | + { |
---|
| 202 | + System.out.println("NAME = " + name); |
---|
| 203 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 204 | + return null; |
---|
| 205 | + } |
---|
| 206 | + } |
---|
190 | 207 | |
---|
191 | 208 | void SetAsGLRenderer(boolean b) |
---|
192 | 209 | { |
---|
.. | .. |
---|
525 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
526 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
527 | 544 | LA.vecNormalize(obj.v2); |
---|
528 | | - 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); |
---|
529 | 547 | } |
---|
530 | 548 | |
---|
531 | 549 | // P |
---|
.. | .. |
---|
547 | 565 | y += ny * obj.NORMALPUSH; |
---|
548 | 566 | z += nz * obj.NORMALPUSH; |
---|
549 | 567 | |
---|
550 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
551 | 569 | } |
---|
552 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
553 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
579 | 597 | y += ny * obj.NORMALPUSH; |
---|
580 | 598 | z += nz * obj.NORMALPUSH; |
---|
581 | 599 | |
---|
582 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
583 | 601 | } |
---|
584 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
585 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
627 | 645 | y += ny * obj.NORMALPUSH; |
---|
628 | 646 | z += nz * obj.NORMALPUSH; |
---|
629 | 647 | |
---|
630 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
631 | 649 | } |
---|
632 | 650 | |
---|
633 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
1233 | 1251 | { |
---|
1234 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1235 | 1253 | { |
---|
1236 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1237 | 1255 | } else |
---|
1238 | 1256 | { |
---|
1239 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1240 | 1258 | } |
---|
1241 | 1259 | |
---|
1242 | 1260 | if (c != null) |
---|
.. | .. |
---|
1260 | 1278 | { |
---|
1261 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1262 | 1280 | { |
---|
1263 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1264 | 1282 | } else |
---|
1265 | 1283 | { |
---|
1266 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1267 | 1285 | } |
---|
1268 | 1286 | if (c != null) |
---|
1269 | 1287 | { |
---|
.. | .. |
---|
1288 | 1306 | { |
---|
1289 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1290 | 1308 | { |
---|
1291 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1292 | 1310 | } else |
---|
1293 | 1311 | { |
---|
1294 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1295 | 1313 | } |
---|
1296 | 1314 | if (c != null) |
---|
1297 | 1315 | { |
---|
.. | .. |
---|
1473 | 1491 | { |
---|
1474 | 1492 | if (!selectmode) |
---|
1475 | 1493 | { |
---|
1476 | | - 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); |
---|
1477 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1478 | 1496 | |
---|
1479 | 1497 | if (flipV) |
---|
.. | .. |
---|
1485 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1486 | 1504 | } |
---|
1487 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1488 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1489 | 1509 | { |
---|
1490 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1552 | 1572 | { |
---|
1553 | 1573 | return; |
---|
1554 | 1574 | } |
---|
1555 | | - |
---|
1556 | | - float[] colorV = new float[3]; |
---|
1557 | 1575 | |
---|
1558 | 1576 | if (false) // marked) |
---|
1559 | 1577 | { |
---|
.. | .. |
---|
1802 | 1820 | |
---|
1803 | 1821 | display.modelParams7[0] = 0; |
---|
1804 | 1822 | display.modelParams7[1] = 1000; |
---|
1805 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1806 | 1824 | display.modelParams7[3] = 0; |
---|
1807 | 1825 | |
---|
1808 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2035 | 2053 | switch(viewcode) |
---|
2036 | 2054 | { |
---|
2037 | 2055 | case 0: return "main"; |
---|
2038 | | - case 1: return "one"; |
---|
2039 | | - case 2: return "two"; |
---|
2040 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2041 | 2059 | case 4: return "light"; |
---|
2042 | 2060 | } |
---|
2043 | 2061 | |
---|
.. | .. |
---|
2458 | 2476 | return CreateBim(bytes, width, height); |
---|
2459 | 2477 | } |
---|
2460 | 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 | + |
---|
2461 | 2491 | /**/ |
---|
2462 | 2492 | class CacheTexture |
---|
2463 | 2493 | { |
---|
.. | .. |
---|
2500 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2501 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2502 | 2532 | true, |
---|
2503 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2504 | 2534 | } catch (java.io.IOException e) |
---|
2505 | 2535 | { |
---|
2506 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8346 | 8376 | // else |
---|
8347 | 8377 | // if (!texname.startsWith("/")) |
---|
8348 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8349 | | - if (!FileExists(texname)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8350 | 8380 | { |
---|
8351 | 8381 | texname = fallbackTextureName; |
---|
8352 | 8382 | } |
---|
.. | .. |
---|
8429 | 8459 | new Exception().printStackTrace(); |
---|
8430 | 8460 | } else |
---|
8431 | 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 | + { |
---|
8432 | 8471 | if (textureon) |
---|
8433 | 8472 | { |
---|
8434 | 8473 | String cachename = texname; |
---|
.. | .. |
---|
8488 | 8527 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8489 | 8528 | //texture = GetTexture(tex, bump); |
---|
8490 | 8529 | } |
---|
| 8530 | + } |
---|
8491 | 8531 | } |
---|
8492 | 8532 | //} |
---|
8493 | 8533 | } |
---|
.. | .. |
---|
8756 | 8796 | |
---|
8757 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8758 | 8798 | MAXSTACK = temp[0]; |
---|
8759 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8760 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8761 | 8802 | MAXSTACK = temp[0]; |
---|
8762 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8763 | 8805 | |
---|
8764 | 8806 | // Use debug pipeline |
---|
8765 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8767 | 8809 | gl = drawable.getGL(); // |
---|
8768 | 8810 | |
---|
8769 | 8811 | GL gl3 = getGL(); |
---|
8770 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8771 | 8814 | |
---|
8772 | 8815 | |
---|
8773 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8932 | 8975 | |
---|
8933 | 8976 | if (cubemap == null) |
---|
8934 | 8977 | { |
---|
8935 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8936 | 8979 | } |
---|
8937 | 8980 | |
---|
8938 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9208 | 9251 | |
---|
9209 | 9252 | void LoadEnvy(int which) |
---|
9210 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9211 | 9256 | String name; |
---|
9212 | 9257 | String ext; |
---|
9213 | 9258 | |
---|
.. | .. |
---|
9219 | 9264 | cubemap = null; |
---|
9220 | 9265 | return; |
---|
9221 | 9266 | case 1: |
---|
9222 | | - name = "cubemaps/box_"; |
---|
9223 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9224 | 9269 | reverseUP = false; |
---|
9225 | 9270 | break; |
---|
9226 | 9271 | case 2: |
---|
9227 | | - name = "cubemaps/uffizi_"; |
---|
9228 | | - ext = "png"; |
---|
9229 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9230 | 9276 | case 3: |
---|
9231 | | - name = "cubemaps/CloudyHills_"; |
---|
9232 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9233 | 9279 | reverseUP = false; |
---|
9234 | 9280 | break; |
---|
9235 | 9281 | case 4: |
---|
9236 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9237 | 9283 | ext = "png"; |
---|
9238 | 9284 | reverseUP = false; |
---|
9239 | 9285 | break; |
---|
| 9286 | + case 5: |
---|
| 9287 | + name = "cubemaps/skycube/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 6: |
---|
| 9292 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
| 9296 | + case 7: |
---|
| 9297 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9298 | + ext = "jpg"; |
---|
| 9299 | + reverseUP = false; |
---|
| 9300 | + break; |
---|
| 9301 | + case 8: |
---|
| 9302 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9303 | + ext = "jpg"; |
---|
| 9304 | + reverseUP = false; |
---|
| 9305 | + break; |
---|
| 9306 | + case 9: |
---|
| 9307 | + name = "cubemaps/UnionSquare/"; |
---|
| 9308 | + ext = "jpg"; |
---|
| 9309 | + reverseUP = false; |
---|
| 9310 | + break; |
---|
9240 | 9311 | default: |
---|
9241 | | - name = "cubemaps/rgb_"; |
---|
9242 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9243 | 9315 | break; |
---|
9244 | 9316 | } |
---|
9245 | | - |
---|
9246 | | - try |
---|
9247 | | - { |
---|
9248 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9249 | | - } catch (IOException e) |
---|
9250 | | - { |
---|
9251 | | - throw new RuntimeException(e); |
---|
9252 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9253 | 9319 | } |
---|
9254 | 9320 | |
---|
9255 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9281 | 9347 | static double[] model = new double[16]; |
---|
9282 | 9348 | double[] camera2light = new double[16]; |
---|
9283 | 9349 | double[] light2camera = new double[16]; |
---|
9284 | | - int newenvy = -1; |
---|
9285 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9286 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9287 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9288 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9762 | 9832 | rati = 1 / rati; |
---|
9763 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9764 | 9834 | } |
---|
9765 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9766 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9767 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9768 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9769 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9770 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9771 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10631 | 10703 | static boolean init = false; |
---|
10632 | 10704 | |
---|
10633 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10634 | 10709 | |
---|
10635 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10636 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10637 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10638 | 10719 | { |
---|
10639 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10802 | 10883 | |
---|
10803 | 10884 | if (wait) |
---|
10804 | 10885 | { |
---|
10805 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10806 | 10887 | |
---|
10807 | 10888 | wait = false; |
---|
10808 | 10889 | } |
---|
.. | .. |
---|
11018 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11019 | 11100 | } |
---|
11020 | 11101 | |
---|
11021 | | - if (newenvy > -1) |
---|
| 11102 | +// if (newenvy > -1) |
---|
| 11103 | +// { |
---|
| 11104 | +// LoadEnvy(newenvy); |
---|
| 11105 | +// } |
---|
| 11106 | +// |
---|
| 11107 | +// newenvy = -1; |
---|
| 11108 | + |
---|
| 11109 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11022 | 11110 | { |
---|
11023 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
11024 | 11117 | } |
---|
11025 | | - |
---|
11026 | | - newenvy = -1; |
---|
11027 | | - |
---|
| 11118 | + else |
---|
| 11119 | + { |
---|
| 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; |
---|
| 11137 | + } |
---|
| 11138 | + |
---|
11028 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
11029 | 11140 | //System.out.println("ratio = " + ratio); |
---|
11030 | 11141 | |
---|
.. | .. |
---|
11040 | 11151 | |
---|
11041 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
11042 | 11153 | { |
---|
11043 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
11044 | 11155 | } |
---|
11045 | 11156 | |
---|
11046 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
11326 | 11437 | |
---|
11327 | 11438 | // if (cam != lightCamera) |
---|
11328 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11329 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11330 | 11441 | } |
---|
11331 | 11442 | |
---|
11332 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12400 | 12511 | |
---|
12401 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12402 | 12513 | |
---|
12403 | | - String program = |
---|
| 12514 | + String programmin = |
---|
12404 | 12515 | // Min shader |
---|
12405 | 12516 | "!!ARBfp1.0\n" + |
---|
12406 | 12517 | "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
.. | .. |
---|
12451 | 12562 | //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
12452 | 12563 | //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
12453 | 12564 | |
---|
12454 | | - "MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12565 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12566 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
12455 | 12567 | |
---|
12456 | 12568 | // Pigment |
---|
12457 | 12569 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
.. | .. |
---|
12466 | 12578 | "MOV result.color, temp;" + |
---|
12467 | 12579 | "END"; |
---|
12468 | 12580 | |
---|
12469 | | - String program2 = |
---|
| 12581 | + String programmax = |
---|
12470 | 12582 | "!!ARBfp1.0\n" + |
---|
12471 | 12583 | |
---|
12472 | 12584 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12494 | 12606 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12495 | 12607 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12496 | 12608 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12497 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12609 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12498 | 12610 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12499 | 12611 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12500 | 12612 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12739 | 12851 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12740 | 12852 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12741 | 12853 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12742 | | - "KIL alpha.a;" + |
---|
| 12854 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12743 | 12855 | /* |
---|
12744 | 12856 | "MUL temp.xy, temp, two;" + |
---|
12745 | 12857 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12825 | 12937 | "SUB bump0, bump0, half;" + |
---|
12826 | 12938 | "ADD bump, bump, bump0;" + |
---|
12827 | 12939 | |
---|
12828 | | - "MOV temp.x, texSamp.a;" + |
---|
12829 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12830 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12831 | | - "MOV texSamp.a, temp.x;" + |
---|
12832 | | - |
---|
12833 | 12940 | // double-sided |
---|
12834 | 12941 | /**/ |
---|
12835 | 12942 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12846 | 12953 | "MOV normald, normal;" + |
---|
12847 | 12954 | "MOV normals, normal;" + |
---|
12848 | 12955 | |
---|
| 12956 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12957 | + |
---|
12849 | 12958 | // UV base |
---|
12850 | 12959 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12851 | 12960 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12852 | 12961 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12853 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12854 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12855 | | - "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 | + |
---|
12856 | 12967 | "XPD V, normal, UP;" + |
---|
12857 | 12968 | Normalize("V") + |
---|
12858 | 12969 | "XPD U, V, normal;" + |
---|
12859 | 12970 | Normalize("U") + |
---|
12860 | 12971 | |
---|
12861 | 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;" + |
---|
12862 | 13012 | |
---|
12863 | 13013 | //"MOV temp, fragment.texcoord[0];" + |
---|
12864 | 13014 | // |
---|
.. | .. |
---|
12991 | 13141 | // display shadow only (fakedepth == 0) |
---|
12992 | 13142 | "SUB temp.x, half.x, shadow.x;" + |
---|
12993 | 13143 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12994 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13144 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12995 | 13145 | "SUB temp.y, one.x, temp.z;" + |
---|
12996 | 13146 | "MUL temp.x, temp.x, temp.y;" + |
---|
12997 | 13147 | "KIL temp.x;" + |
---|
.. | .. |
---|
13322 | 13472 | //once = true; |
---|
13323 | 13473 | } |
---|
13324 | 13474 | |
---|
13325 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13326 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13475 | + String program = programmax; |
---|
| 13476 | + |
---|
| 13477 | + if (Globals.MINSHADER) |
---|
| 13478 | + { |
---|
| 13479 | + program = programmin; |
---|
| 13480 | + } |
---|
| 13481 | + |
---|
| 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 | + |
---|
13327 | 13488 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13328 | 13489 | |
---|
13329 | 13490 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13370 | 13531 | "\n" + |
---|
13371 | 13532 | "END\n"; |
---|
13372 | 13533 | |
---|
13373 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13534 | + if (Globals.DEBUG) |
---|
| 13535 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13374 | 13536 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13375 | 13537 | |
---|
13376 | 13538 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13628 | 13790 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13629 | 13791 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13630 | 13792 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13631 | | - /*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 |
---|
13632 | 13794 | |
---|
13633 | 13795 | //Object3D.cVector2[] vector2buffer; |
---|
13634 | 13796 | |
---|
.. | .. |
---|
13795 | 13957 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13796 | 13958 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13797 | 13959 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13798 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13960 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13799 | 13961 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13800 | 13962 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13801 | 13963 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13856 | 14018 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13857 | 14019 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13858 | 14020 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13859 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14021 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13860 | 14022 | "MOV result.texcoord, temp;" + |
---|
13861 | 14023 | // border fade |
---|
13862 | 14024 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13903 | 14065 | |
---|
13904 | 14066 | //"ADD temp.z, temp.z, one;" + |
---|
13905 | 14067 | |
---|
13906 | | - "MOV result.color, temp;" |
---|
| 14068 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14069 | + |
---|
| 14070 | + "MOV result.color, temp;" // Normal |
---|
13907 | 14071 | : "MOV result.color, vertex.color;") + |
---|
13908 | 14072 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13909 | 14073 | : "") + |
---|
.. | .. |
---|
14569 | 14733 | void GoDown(int mod) |
---|
14570 | 14734 | { |
---|
14571 | 14735 | MODIFIERS |= COMMAND; |
---|
| 14736 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14572 | 14737 | /**/ |
---|
14573 | 14738 | if((mod&SHIFT) == SHIFT) |
---|
14574 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14739 | + { |
---|
| 14740 | + if (isVR) |
---|
| 14741 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14742 | + else |
---|
| 14743 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14744 | + } |
---|
14575 | 14745 | else |
---|
14576 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14746 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14577 | 14747 | /**/ |
---|
14578 | 14748 | if ((mod & SHIFT) == SHIFT) |
---|
14579 | 14749 | { |
---|
.. | .. |
---|
14583 | 14753 | mouseMode |= BACKFORTH; |
---|
14584 | 14754 | } |
---|
14585 | 14755 | |
---|
| 14756 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14757 | + |
---|
14586 | 14758 | //prevX = X = anchorX; |
---|
14587 | 14759 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14588 | 14760 | } |
---|
.. | .. |
---|
14591 | 14763 | { |
---|
14592 | 14764 | MODIFIERS |= COMMAND; |
---|
14593 | 14765 | /**/ |
---|
| 14766 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14767 | + |
---|
14594 | 14768 | if((mod&SHIFT) == SHIFT) |
---|
14595 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14769 | + { |
---|
| 14770 | + if (isVR) |
---|
| 14771 | + manipCamera.RotateInterest(0, speed); |
---|
| 14772 | + else |
---|
| 14773 | + manipCamera.RotatePosition(0, speed); |
---|
| 14774 | + } |
---|
14596 | 14775 | else |
---|
14597 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14776 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14598 | 14777 | /**/ |
---|
14599 | 14778 | if ((mod & SHIFT) == SHIFT) |
---|
14600 | 14779 | { |
---|
.. | .. |
---|
14604 | 14783 | mouseMode |= BACKFORTH; |
---|
14605 | 14784 | } |
---|
14606 | 14785 | |
---|
| 14786 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14787 | + |
---|
14607 | 14788 | //prevX = X = anchorX; |
---|
14608 | 14789 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14609 | 14790 | } |
---|
.. | .. |
---|
14613 | 14794 | MODIFIERS |= COMMAND; |
---|
14614 | 14795 | /**/ |
---|
14615 | 14796 | if((mod&SHIFT) == SHIFT) |
---|
14616 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14797 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14617 | 14798 | else |
---|
14618 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14799 | + { |
---|
| 14800 | + if ((mouseMode&VR)!=0) |
---|
| 14801 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14802 | + else |
---|
| 14803 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14804 | + } |
---|
14619 | 14805 | /**/ |
---|
14620 | 14806 | if ((mod & SHIFT) == SHIFT) |
---|
14621 | 14807 | { |
---|
.. | .. |
---|
14625 | 14811 | mouseMode |= ROTATE; |
---|
14626 | 14812 | } // TRANSLATE; |
---|
14627 | 14813 | |
---|
| 14814 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14815 | + |
---|
14628 | 14816 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14629 | 14817 | prevY = Y = anchorY; |
---|
14630 | 14818 | } |
---|
.. | .. |
---|
14634 | 14822 | MODIFIERS |= COMMAND; |
---|
14635 | 14823 | /**/ |
---|
14636 | 14824 | if((mod&SHIFT) == SHIFT) |
---|
14637 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14825 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14638 | 14826 | else |
---|
14639 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14827 | + { |
---|
| 14828 | + if ((mouseMode&VR)!=0) |
---|
| 14829 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14830 | + else |
---|
| 14831 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14832 | + } |
---|
| 14833 | + |
---|
14640 | 14834 | /**/ |
---|
14641 | 14835 | if ((mod & SHIFT) == SHIFT) |
---|
14642 | 14836 | { |
---|
.. | .. |
---|
14646 | 14840 | mouseMode |= ROTATE; |
---|
14647 | 14841 | } // TRANSLATE; |
---|
14648 | 14842 | |
---|
| 14843 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14844 | + |
---|
14649 | 14845 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14650 | 14846 | prevY = Y = anchorY; |
---|
14651 | 14847 | } |
---|
.. | .. |
---|
15148 | 15344 | case 'K': |
---|
15149 | 15345 | KOMPACTTEXTURE ^= true; |
---|
15150 | 15346 | //textures.clear(); |
---|
15151 | | - break; |
---|
15152 | | - case 'P': // Texture Projection macros |
---|
| 15347 | + // break; |
---|
| 15348 | + //case 'P': // Texture Projection macros |
---|
15153 | 15349 | // SAVETEXTURE ^= true; |
---|
15154 | 15350 | macromode = true; |
---|
15155 | 15351 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15270 | 15466 | targetLookAt.set(manipCamera.lookAt); |
---|
15271 | 15467 | repaint(); |
---|
15272 | 15468 | break; |
---|
15273 | | - case 'p': |
---|
| 15469 | + case 'P': // p': |
---|
15274 | 15470 | // c'est quoi ca au juste? spherical ^= true; |
---|
15275 | 15471 | Skinshader ^= true; programInitialized = false; |
---|
15276 | 15472 | repaint(); |
---|
.. | .. |
---|
15308 | 15504 | repaint(); |
---|
15309 | 15505 | break; |
---|
15310 | 15506 | case 'O': |
---|
15311 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15507 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
15312 | 15508 | repaint(); |
---|
15313 | 15509 | break; |
---|
15314 | 15510 | case 'o': |
---|
15315 | 15511 | OCCLUSION_CULLING ^= true; |
---|
15316 | 15512 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15317 | 15513 | break; |
---|
15318 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15514 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15319 | 15515 | case '1': |
---|
15320 | 15516 | case '2': |
---|
15321 | 15517 | case '3': |
---|
15322 | 15518 | case '4': |
---|
15323 | 15519 | case '5': |
---|
15324 | | - newenvy = Character.getNumericValue(key); |
---|
15325 | | - repaint(); |
---|
15326 | | - break; |
---|
15327 | 15520 | case '6': |
---|
15328 | 15521 | case '7': |
---|
15329 | 15522 | case '8': |
---|
15330 | 15523 | case '9': |
---|
15331 | | - BGcolor = (key - '6')/3.f; |
---|
| 15524 | + if (true) // envyoff) |
---|
| 15525 | + { |
---|
| 15526 | + BGcolor = (key - '1')/8.f; |
---|
| 15527 | + } |
---|
| 15528 | + else |
---|
| 15529 | + { |
---|
| 15530 | + //newenvy = Character.getNumericValue(key); |
---|
| 15531 | + } |
---|
15332 | 15532 | repaint(); |
---|
15333 | 15533 | break; |
---|
15334 | 15534 | case '!': |
---|
.. | .. |
---|
16026 | 16226 | { |
---|
16027 | 16227 | switch (hitSomething) |
---|
16028 | 16228 | { |
---|
16029 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16229 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
16030 | 16230 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16031 | 16231 | break; |
---|
16032 | 16232 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
16033 | 16233 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16034 | 16234 | break; |
---|
16035 | 16235 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16036 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16236 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16037 | 16237 | break; |
---|
16038 | 16238 | } |
---|
16039 | 16239 | |
---|
.. | .. |
---|
16052 | 16252 | if (hasMarquee) |
---|
16053 | 16253 | { |
---|
16054 | 16254 | gr.setXORMode(Color.white); |
---|
16055 | | - gr.setColor(Color.red); |
---|
| 16255 | + gr.setColor(Color.white); |
---|
16056 | 16256 | if (!firstime) |
---|
16057 | 16257 | { |
---|
16058 | 16258 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16519 | 16719 | private /*static*/ boolean firstime; |
---|
16520 | 16720 | private /*static*/ cVector newView = new cVector(); |
---|
16521 | 16721 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16722 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16723 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16522 | 16724 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16523 | 16725 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16524 | 16726 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16531 | 16733 | { |
---|
16532 | 16734 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16533 | 16735 | |
---|
| 16736 | + int usedsuf = 0; |
---|
| 16737 | + |
---|
16534 | 16738 | for (int i = 0; i < suffixes.length; i++) |
---|
16535 | 16739 | { |
---|
16536 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16537 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16538 | | - mipmapped, |
---|
16539 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16540 | | - if (data == null) |
---|
| 16740 | + String[] suffixe = suffixes; |
---|
| 16741 | + String[] fallback = suffixes2; |
---|
| 16742 | + String[] fallfallback = suffixes3; |
---|
| 16743 | + |
---|
| 16744 | + for (int c=usedsuf; --c>=0;) |
---|
16541 | 16745 | { |
---|
16542 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16746 | +// String[] temp = suffixe; |
---|
| 16747 | +// suffixe = fallback; |
---|
| 16748 | +// fallback = fallfallback; |
---|
| 16749 | +// fallfallback = temp; |
---|
16543 | 16750 | } |
---|
| 16751 | + |
---|
| 16752 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16753 | + TextureData data; |
---|
| 16754 | + |
---|
| 16755 | + try |
---|
| 16756 | + { |
---|
| 16757 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16758 | + mipmapped, |
---|
| 16759 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16760 | + } |
---|
| 16761 | + catch (Exception e) |
---|
| 16762 | + { |
---|
| 16763 | + try |
---|
| 16764 | + { |
---|
| 16765 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16766 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16767 | + mipmapped, |
---|
| 16768 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16769 | + } |
---|
| 16770 | + catch (Exception e2) |
---|
| 16771 | + { |
---|
| 16772 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16773 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16774 | + mipmapped, |
---|
| 16775 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16776 | + } |
---|
| 16777 | + } |
---|
| 16778 | + |
---|
16544 | 16779 | //System.out.println("Target = " + targets[i]); |
---|
16545 | 16780 | cubemap.updateImage(data, targets[i]); |
---|
16546 | 16781 | } |
---|
16547 | 16782 | |
---|
16548 | 16783 | return cubemap; |
---|
16549 | 16784 | } |
---|
| 16785 | + |
---|
16550 | 16786 | int bigsphere = -1; |
---|
16551 | 16787 | |
---|
16552 | 16788 | float BGcolor = 0.5f; |
---|
16553 | 16789 | |
---|
16554 | | - private void DrawSkyBox(GL gl) |
---|
| 16790 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16791 | + |
---|
| 16792 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16555 | 16793 | { |
---|
16556 | | - if (envyoff || cubemap == null) |
---|
| 16794 | + if (//envyoff || |
---|
| 16795 | + WIREFRAME || |
---|
| 16796 | + cubemap == null) |
---|
16557 | 16797 | { |
---|
16558 | 16798 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16559 | 16799 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16568 | 16808 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16569 | 16809 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16570 | 16810 | gl.glLoadIdentity(); |
---|
| 16811 | + gl.glScalef(1,ratio,1); |
---|
16571 | 16812 | |
---|
| 16813 | +// colorV[0] = 2; |
---|
| 16814 | +// colorV[1] = 2; |
---|
| 16815 | +// colorV[2] = 2; |
---|
| 16816 | +// colorV[3] = 1; |
---|
| 16817 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16818 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16819 | +// |
---|
| 16820 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16821 | + |
---|
16572 | 16822 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16573 | 16823 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16574 | 16824 | |
---|
.. | .. |
---|
16600 | 16850 | { |
---|
16601 | 16851 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16602 | 16852 | } |
---|
| 16853 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16603 | 16854 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16604 | 16855 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16605 | 16856 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16640 | 16891 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16641 | 16892 | |
---|
16642 | 16893 | cubemap.disable(); |
---|
16643 | | - ////cubemap.unbind(); |
---|
| 16894 | + //cubemap.dispose(); |
---|
| 16895 | + |
---|
16644 | 16896 | if (CULLFACE) |
---|
16645 | 16897 | { |
---|
16646 | 16898 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16696 | 16948 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16697 | 16949 | } |
---|
16698 | 16950 | |
---|
16699 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16951 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16700 | 16952 | |
---|
16701 | 16953 | float step = 2; // 0.1666f; //0.25f; |
---|
16702 | 16954 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16858 | 17110 | //new Exception().printStackTrace(); |
---|
16859 | 17111 | System.out.println("select buffer init"); |
---|
16860 | 17112 | // Use debug pipeline |
---|
16861 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17113 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16862 | 17114 | |
---|
16863 | 17115 | GL gl = drawable.getGL(); |
---|
16864 | 17116 | |
---|
.. | .. |
---|
17176 | 17428 | |
---|
17177 | 17429 | public void init(GLAutoDrawable drawable) |
---|
17178 | 17430 | { |
---|
| 17431 | + if (Globals.DEBUG) |
---|
17179 | 17432 | System.out.println("shadow buffer init"); |
---|
17180 | 17433 | |
---|
17181 | 17434 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17404 | 17657 | gl.glFlush(); |
---|
17405 | 17658 | |
---|
17406 | 17659 | /**/ |
---|
17407 | | - 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); |
---|
17408 | 17661 | |
---|
17409 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17662 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17410 | 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 | + |
---|
17411 | 17668 | double r = 0, g = 0, b = 0; |
---|
17412 | 17669 | |
---|
17413 | 17670 | double count = 0; |
---|
.. | .. |
---|
17418 | 17675 | |
---|
17419 | 17676 | double FACTOR = 1; |
---|
17420 | 17677 | |
---|
17421 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17678 | + for (int i = 0; i < depths.length; i++) |
---|
17422 | 17679 | { |
---|
17423 | 17680 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17424 | 17681 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17501 | 17758 | |
---|
17502 | 17759 | double scale = ray.z; // 1; // cos |
---|
17503 | 17760 | |
---|
17504 | | - float depth = pixels[newindex]; |
---|
| 17761 | + float depth = depths[newindex]; |
---|
17505 | 17762 | |
---|
17506 | 17763 | /* |
---|
17507 | 17764 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17698 | 17955 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17699 | 17956 | static IntBuffer bigAAbuffer; |
---|
17700 | 17957 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17701 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17958 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17702 | 17959 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17703 | 17960 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17704 | 17961 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17705 | | - 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 | + |
---|
17706 | 17966 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17707 | 17967 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17708 | 17968 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|