.. | .. |
---|
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 | { |
---|
.. | .. |
---|
206 | 223 | |
---|
207 | 224 | SetCamera(cam); |
---|
208 | 225 | |
---|
209 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 226 | + // Warning: not used. |
---|
| 227 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
210 | 228 | |
---|
211 | 229 | object = o; |
---|
212 | 230 | |
---|
.. | .. |
---|
524 | 542 | LA.vecSub(pv/*.pos*/, rv/*.pos*/, obj.v1); |
---|
525 | 543 | LA.vecCross(obj.v0, obj.v1, obj.v2); |
---|
526 | 544 | LA.vecNormalize(obj.v2); |
---|
527 | | - 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); |
---|
528 | 547 | } |
---|
529 | 548 | |
---|
530 | 549 | // P |
---|
.. | .. |
---|
546 | 565 | y += ny * obj.NORMALPUSH; |
---|
547 | 566 | z += nz * obj.NORMALPUSH; |
---|
548 | 567 | |
---|
549 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 568 | + SetGLNormal(gl, nx, ny, nz); |
---|
550 | 569 | } |
---|
551 | 570 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
552 | 571 | SetColor(obj, pv); |
---|
.. | .. |
---|
578 | 597 | y += ny * obj.NORMALPUSH; |
---|
579 | 598 | z += nz * obj.NORMALPUSH; |
---|
580 | 599 | |
---|
581 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 600 | + SetGLNormal(gl, nx, ny, nz); |
---|
582 | 601 | } |
---|
583 | 602 | //System.out.println("vertexq = " + qv.s + ", " + qv.t); |
---|
584 | 603 | // boolean locked = false; |
---|
.. | .. |
---|
626 | 645 | y += ny * obj.NORMALPUSH; |
---|
627 | 646 | z += nz * obj.NORMALPUSH; |
---|
628 | 647 | |
---|
629 | | - gl.glNormal3f(nx, ny, nz); |
---|
| 648 | + SetGLNormal(gl, nx, ny, nz); |
---|
630 | 649 | } |
---|
631 | 650 | |
---|
632 | 651 | // if ((dot&4) == 0) |
---|
.. | .. |
---|
862 | 881 | //// tris.postdraw(this); |
---|
863 | 882 | } |
---|
864 | 883 | |
---|
865 | | - static Camera localcamera = new Camera(); |
---|
| 884 | + static Camera localAOcamera = new Camera(); |
---|
866 | 885 | static cVector from = new cVector(); |
---|
867 | 886 | static cVector to = new cVector(); |
---|
868 | 887 | |
---|
.. | .. |
---|
871 | 890 | CameraPane cp = this; |
---|
872 | 891 | |
---|
873 | 892 | Camera keep = cp.RenderCamera(); |
---|
874 | | - cp.renderCamera = localcamera; |
---|
| 893 | + cp.renderCamera = localAOcamera; |
---|
875 | 894 | |
---|
876 | 895 | if (br.trimmed) |
---|
877 | 896 | { |
---|
.. | .. |
---|
889 | 908 | br.positions[i3 + 2] + br.normals[i3 + 2]); |
---|
890 | 909 | LA.xformPos(from, transform, from); |
---|
891 | 910 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
892 | | - localcamera.setAim(from, to); |
---|
| 911 | + localAOcamera.setAim(from, to); |
---|
893 | 912 | |
---|
894 | 913 | CameraPane.occlusionbuffer.display(); |
---|
895 | 914 | |
---|
.. | .. |
---|
923 | 942 | to.set(v.x+v.norm.x, v.y+v.norm.y, v.z+v.norm.z); |
---|
924 | 943 | LA.xformPos(from, transform, from); |
---|
925 | 944 | LA.xformPos(to, transform, to); // RIGID ONLY |
---|
926 | | - localcamera.setAim(from, to); |
---|
| 945 | + localAOcamera.setAim(from, to); |
---|
927 | 946 | |
---|
928 | 947 | CameraPane.occlusionbuffer.display(); |
---|
929 | 948 | |
---|
.. | .. |
---|
1232 | 1251 | { |
---|
1233 | 1252 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1234 | 1253 | { |
---|
1235 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1254 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1236 | 1255 | } else |
---|
1237 | 1256 | { |
---|
1238 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1257 | + SetGLNormal(gl, 0, 0, 1); |
---|
1239 | 1258 | } |
---|
1240 | 1259 | |
---|
1241 | 1260 | if (c != null) |
---|
.. | .. |
---|
1259 | 1278 | { |
---|
1260 | 1279 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1261 | 1280 | { |
---|
1262 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1281 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1263 | 1282 | } else |
---|
1264 | 1283 | { |
---|
1265 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1284 | + SetGLNormal(gl, 0, 0, 1); |
---|
1266 | 1285 | } |
---|
1267 | 1286 | if (c != null) |
---|
1268 | 1287 | { |
---|
.. | .. |
---|
1287 | 1306 | { |
---|
1288 | 1307 | if (n[count3] != 0 || n[count3 + 1] != 0 || n[count3 + 2] != 0) |
---|
1289 | 1308 | { |
---|
1290 | | - gl.glNormal3f(n[count3], n[count3 + 1], n[count3 + 2]); |
---|
| 1309 | + SetGLNormal(gl, n[count3], n[count3 + 1], n[count3 + 2]); |
---|
1291 | 1310 | } else |
---|
1292 | 1311 | { |
---|
1293 | | - gl.glNormal3f(0, 0, 1); |
---|
| 1312 | + SetGLNormal(gl, 0, 0, 1); |
---|
1294 | 1313 | } |
---|
1295 | 1314 | if (c != null) |
---|
1296 | 1315 | { |
---|
.. | .. |
---|
1472 | 1491 | { |
---|
1473 | 1492 | if (!selectmode) |
---|
1474 | 1493 | { |
---|
1475 | | - 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); |
---|
1476 | 1495 | gl.glColor4f(pv.AO, pv.AO, pv.AO, 1); |
---|
1477 | 1496 | |
---|
1478 | 1497 | if (flipV) |
---|
.. | .. |
---|
1484 | 1503 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1485 | 1504 | } |
---|
1486 | 1505 | |
---|
| 1506 | + float[] colorV = new float[4]; |
---|
| 1507 | + |
---|
1487 | 1508 | void SetColor(Object3D obj, Vertex p0) |
---|
1488 | 1509 | { |
---|
1489 | 1510 | CameraPane display = this; |
---|
.. | .. |
---|
1551 | 1572 | { |
---|
1552 | 1573 | return; |
---|
1553 | 1574 | } |
---|
1554 | | - |
---|
1555 | | - float[] colorV = new float[3]; |
---|
1556 | 1575 | |
---|
1557 | 1576 | if (false) // marked) |
---|
1558 | 1577 | { |
---|
.. | .. |
---|
1801 | 1820 | |
---|
1802 | 1821 | display.modelParams7[0] = 0; |
---|
1803 | 1822 | display.modelParams7[1] = 1000; |
---|
1804 | | - display.modelParams7[2] = 0; |
---|
| 1823 | + display.modelParams7[2] = material.parallax; |
---|
1805 | 1824 | display.modelParams7[3] = 0; |
---|
1806 | 1825 | |
---|
1807 | 1826 | //display.modelParams6[0] = 100; // criss de bug de bump |
---|
.. | .. |
---|
2034 | 2053 | switch(viewcode) |
---|
2035 | 2054 | { |
---|
2036 | 2055 | case 0: return "main"; |
---|
2037 | | - case 1: return "one"; |
---|
2038 | | - case 2: return "two"; |
---|
2039 | | - case 3: return "three"; |
---|
| 2056 | + case 1: return "Red"; |
---|
| 2057 | + case 2: return "Green"; |
---|
| 2058 | + case 3: return "Blue"; |
---|
2040 | 2059 | case 4: return "light"; |
---|
2041 | 2060 | } |
---|
2042 | 2061 | |
---|
.. | .. |
---|
2457 | 2476 | return CreateBim(bytes, width, height); |
---|
2458 | 2477 | } |
---|
2459 | 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 | + |
---|
2460 | 2491 | /**/ |
---|
2461 | 2492 | class CacheTexture |
---|
2462 | 2493 | { |
---|
.. | .. |
---|
2499 | 2530 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2500 | 2531 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2501 | 2532 | true, |
---|
2502 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2533 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2503 | 2534 | } catch (java.io.IOException e) |
---|
2504 | 2535 | { |
---|
2505 | 2536 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8345 | 8376 | // else |
---|
8346 | 8377 | // if (!texname.startsWith("/")) |
---|
8347 | 8378 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8348 | | - if (!FileExists(texname)) |
---|
| 8379 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8349 | 8380 | { |
---|
8350 | 8381 | texname = fallbackTextureName; |
---|
8351 | 8382 | } |
---|
.. | .. |
---|
8428 | 8459 | new Exception().printStackTrace(); |
---|
8429 | 8460 | } else |
---|
8430 | 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 | + { |
---|
8431 | 8471 | if (textureon) |
---|
8432 | 8472 | { |
---|
8433 | 8473 | String cachename = texname; |
---|
.. | .. |
---|
8487 | 8527 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8488 | 8528 | //texture = GetTexture(tex, bump); |
---|
8489 | 8529 | } |
---|
| 8530 | + } |
---|
8490 | 8531 | } |
---|
8491 | 8532 | //} |
---|
8492 | 8533 | } |
---|
.. | .. |
---|
8755 | 8796 | |
---|
8756 | 8797 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8757 | 8798 | MAXSTACK = temp[0]; |
---|
8758 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8759 | 8801 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8760 | 8802 | MAXSTACK = temp[0]; |
---|
8761 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8803 | + if (Globals.DEBUG) |
---|
| 8804 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8762 | 8805 | |
---|
8763 | 8806 | // Use debug pipeline |
---|
8764 | 8807 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8766 | 8809 | gl = drawable.getGL(); // |
---|
8767 | 8810 | |
---|
8768 | 8811 | GL gl3 = getGL(); |
---|
8769 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8812 | + if (Globals.DEBUG) |
---|
| 8813 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8770 | 8814 | |
---|
8771 | 8815 | |
---|
8772 | 8816 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8931 | 8975 | |
---|
8932 | 8976 | if (cubemap == null) |
---|
8933 | 8977 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8978 | + //LoadEnvy(1); |
---|
8935 | 8979 | } |
---|
8936 | 8980 | |
---|
8937 | 8981 | //cubemap.enable(); |
---|
.. | .. |
---|
9207 | 9251 | |
---|
9208 | 9252 | void LoadEnvy(int which) |
---|
9209 | 9253 | { |
---|
| 9254 | + assert(false); |
---|
| 9255 | + |
---|
9210 | 9256 | String name; |
---|
9211 | 9257 | String ext; |
---|
9212 | 9258 | |
---|
.. | .. |
---|
9218 | 9264 | cubemap = null; |
---|
9219 | 9265 | return; |
---|
9220 | 9266 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9267 | + name = "cubemaps/rgb/"; |
---|
| 9268 | + ext = "jpg"; |
---|
9223 | 9269 | reverseUP = false; |
---|
9224 | 9270 | break; |
---|
9225 | 9271 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9272 | + name = "cubemaps/uffizi/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
9229 | 9276 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9277 | + name = "cubemaps/CloudyHills/"; |
---|
| 9278 | + ext = "jpg"; |
---|
9232 | 9279 | reverseUP = false; |
---|
9233 | 9280 | break; |
---|
9234 | 9281 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9282 | + name = "cubemaps/cornell/"; |
---|
9236 | 9283 | ext = "png"; |
---|
9237 | 9284 | reverseUP = false; |
---|
9238 | 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; |
---|
9239 | 9311 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9312 | + name = "cubemaps/box/"; |
---|
| 9313 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9314 | + reverseUP = false; |
---|
9242 | 9315 | break; |
---|
9243 | 9316 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9317 | + |
---|
| 9318 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9319 | } |
---|
9253 | 9320 | |
---|
9254 | 9321 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9347 | static double[] model = new double[16]; |
---|
9281 | 9348 | double[] camera2light = new double[16]; |
---|
9282 | 9349 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9350 | + |
---|
| 9351 | + //int newenvy = -1; |
---|
| 9352 | + //boolean envyoff = false; |
---|
| 9353 | + |
---|
| 9354 | + String loadedskyboxname; |
---|
| 9355 | + |
---|
9285 | 9356 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9357 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9358 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9699 | 9770 | |
---|
9700 | 9771 | if (renderCamera != lightCamera) |
---|
9701 | 9772 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9773 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9774 | |
---|
9704 | 9775 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9776 | |
---|
.. | .. |
---|
9715 | 9786 | |
---|
9716 | 9787 | if (renderCamera != lightCamera) |
---|
9717 | 9788 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9789 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9790 | |
---|
9720 | 9791 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9792 | |
---|
.. | .. |
---|
9761 | 9832 | rati = 1 / rati; |
---|
9762 | 9833 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9834 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9835 | + |
---|
| 9836 | + //assert (newenvy == -1); |
---|
| 9837 | + |
---|
9765 | 9838 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9839 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9840 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9841 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9842 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9843 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10630 | 10703 | static boolean init = false; |
---|
10631 | 10704 | |
---|
10632 | 10705 | double[][] matrix = LA.newMatrix(); |
---|
| 10706 | + |
---|
| 10707 | + // This is to refresh the UI of the material panel. |
---|
| 10708 | + ObjEditor patchMaterial; |
---|
10633 | 10709 | |
---|
10634 | 10710 | public void display(GLAutoDrawable drawable) |
---|
10635 | 10711 | { |
---|
| 10712 | + if (patchMaterial.patchMaterial) |
---|
| 10713 | + { |
---|
| 10714 | + patchMaterial.patchMaterial = false; |
---|
| 10715 | + patchMaterial.objectPanel.setSelectedIndex(1); |
---|
| 10716 | + } |
---|
| 10717 | + |
---|
10636 | 10718 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10637 | 10719 | { |
---|
10638 | 10720 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10801 | 10883 | |
---|
10802 | 10884 | if (wait) |
---|
10803 | 10885 | { |
---|
10804 | | - Sleep(500); |
---|
| 10886 | + Sleep(200); // blocks everything |
---|
10805 | 10887 | |
---|
10806 | 10888 | wait = false; |
---|
10807 | 10889 | } |
---|
.. | .. |
---|
10916 | 10998 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10999 | if (cam != lightCamera) |
---|
10918 | 11000 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 11001 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 11002 | |
---|
10921 | 11003 | for (int j = 0; j < 4; j++) |
---|
10922 | 11004 | { |
---|
.. | .. |
---|
10931 | 11013 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 11014 | if (cam != lightCamera) |
---|
10933 | 11015 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11016 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 11017 | |
---|
10936 | 11018 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 11019 | |
---|
.. | .. |
---|
11017 | 11099 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11100 | } |
---|
11019 | 11101 | |
---|
11020 | | - 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")) |
---|
11021 | 11110 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11111 | + if (cubemaprgb == null) |
---|
| 11112 | + { |
---|
| 11113 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11114 | + } |
---|
| 11115 | + |
---|
| 11116 | + cubemap = cubemaprgb; |
---|
11023 | 11117 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 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 | + |
---|
11027 | 11139 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11140 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11141 | |
---|
.. | .. |
---|
11039 | 11151 | |
---|
11040 | 11152 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11153 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11154 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11155 | } |
---|
11044 | 11156 | |
---|
11045 | 11157 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11437 | |
---|
11326 | 11438 | // if (cam != lightCamera) |
---|
11327 | 11439 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11440 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11441 | } |
---|
11330 | 11442 | |
---|
11331 | 11443 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12511 | |
---|
12400 | 12512 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12513 | |
---|
12402 | | - String program = |
---|
| 12514 | + String programmin = |
---|
| 12515 | + // Min shader |
---|
12403 | 12516 | "!!ARBfp1.0\n" + |
---|
| 12517 | + "PARAM zero12t = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12518 | + "PARAM pow_2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12519 | + "PARAM pow2 = { 2, 4, 8, 0.0 };" + |
---|
| 12520 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12521 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12522 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12523 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12524 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12525 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12526 | + "TEMP temp;" + |
---|
| 12527 | + "TEMP light;" + |
---|
| 12528 | + "TEMP ndotl;" + |
---|
| 12529 | + "TEMP normal;" + |
---|
| 12530 | + "TEMP depth;" + |
---|
| 12531 | + "TEMP eye;" + |
---|
| 12532 | + "TEMP pos;" + |
---|
| 12533 | + |
---|
| 12534 | + "MAD normal, fragment.color, zero12t.z, -zero12t.y;" + |
---|
| 12535 | + Normalize("normal") + |
---|
| 12536 | + "MOV light, state.light[0].position;" + |
---|
| 12537 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12538 | + "MAX ndotl.x, ndotl.x, zero12t.x;" + |
---|
| 12539 | + |
---|
| 12540 | + // shadow |
---|
| 12541 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12542 | + "MOV temp, pos;" + |
---|
| 12543 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12544 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12545 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12546 | + |
---|
| 12547 | + // No shadow when out of frustum |
---|
| 12548 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12549 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12552 | + |
---|
| 12553 | + // Backlit |
---|
| 12554 | + "MOV pos.w, zero12t.y;" + // one |
---|
| 12555 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12556 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12557 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12558 | + Normalize("eye") + |
---|
| 12559 | + |
---|
| 12560 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12561 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12562 | + "POW ndotl.y, ndotl.y, pow2.x;" + // backlit |
---|
| 12563 | + "SUB ndotl.y, zero12t.y, ndotl.y;" + // 1 - y |
---|
| 12564 | + //"POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12565 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12566 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12567 | + "ADD ndotl.y, ndotl.y, one.x;" + |
---|
| 12568 | + "MUL ndotl.y, ndotl.y, pow_2.x;" + |
---|
| 12569 | + |
---|
| 12570 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12571 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12572 | + |
---|
| 12573 | + // Pigment |
---|
| 12574 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12575 | + "LRP temp, zero12t.w, temp, one;" + // texture proportion |
---|
| 12576 | + "MUL temp, temp, zero12t.w;" + // Times x |
---|
| 12577 | + |
---|
| 12578 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12579 | + "MAD ndotl.x, pow_2.xxxx, ndotl.yyyy, ndotl.x;" + |
---|
| 12580 | + |
---|
| 12581 | + "MUL temp, temp, ndotl.x;" + // lambert |
---|
| 12582 | + |
---|
| 12583 | + "MOV temp.w, zero12t.y;" + // reset alpha |
---|
| 12584 | + "MOV result.color, temp;" + |
---|
| 12585 | + "END"; |
---|
| 12586 | + |
---|
| 12587 | + String programmax = |
---|
| 12588 | + "!!ARBfp1.0\n" + |
---|
| 12589 | + |
---|
12404 | 12590 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12591 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12592 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12426 | 12612 | "PARAM params4 = program.env[4];" + // anisoV, cameralight, selfshadow, shadow |
---|
12427 | 12613 | "PARAM params5 = program.env[5];" + // texture, opacity, fakedepth, shadowbias |
---|
12428 | 12614 | "PARAM params6 = program.env[6];" + // bump, noise, borderfade, fog punchthrough |
---|
12429 | | - "PARAM params7 = program.env[7];" + // noise power, opacity power |
---|
| 12615 | + "PARAM params7 = program.env[7];" + // noise power, opacity power, parallax |
---|
12430 | 12616 | "PARAM options0 = program.env[63];" + // fog density, intensity, elevation |
---|
12431 | 12617 | "PARAM options1 = program.env[62];" + // fog rgb color |
---|
12432 | 12618 | "PARAM options2 = program.env[61];" + // image intensity, subsurface, lightsheen |
---|
.. | .. |
---|
12515 | 12701 | "TEMP shininess;" + |
---|
12516 | 12702 | "\n" + |
---|
12517 | 12703 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12704 | + |
---|
12520 | 12705 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12706 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12707 | /* |
---|
.. | .. |
---|
12537 | 12722 | "MUL temp, floor, mapgrid.x;" + |
---|
12538 | 12723 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12539 | 12724 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12540 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12725 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12541 | 12726 | "") + |
---|
12542 | 12727 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12543 | 12728 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12544 | 12729 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12545 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12730 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12546 | 12731 | "") + |
---|
12547 | 12732 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12548 | 12733 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12549 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12734 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12550 | 12735 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12551 | 12736 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12552 | 12737 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12553 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12738 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12554 | 12739 | "") + |
---|
12555 | 12740 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12556 | 12741 | //"MOV params, material;" + |
---|
.. | .. |
---|
12672 | 12857 | "POW texSamp.a, texSamp.a, params6.w;" + // fog punch through shortcut |
---|
12673 | 12858 | // mar 2013 ??? "KIL alpha.a;" + |
---|
12674 | 12859 | "MOV alpha, texSamp.aaaa;" + // y;" + |
---|
12675 | | - "KIL alpha.a;" + |
---|
| 12860 | + "KIL alpha.a;" + // not sure with parallax mapping |
---|
12676 | 12861 | /* |
---|
12677 | 12862 | "MUL temp.xy, temp, two;" + |
---|
12678 | 12863 | "TXB bump, temp, texture[0], 2D;" + |
---|
.. | .. |
---|
12758 | 12943 | "SUB bump0, bump0, half;" + |
---|
12759 | 12944 | "ADD bump, bump, bump0;" + |
---|
12760 | 12945 | |
---|
12761 | | - "MOV temp.x, texSamp.a;" + |
---|
12762 | | - "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
12763 | | - //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
12764 | | - "MOV texSamp.a, temp.x;" + |
---|
12765 | | - |
---|
12766 | 12946 | // double-sided |
---|
12767 | 12947 | /**/ |
---|
12768 | 12948 | (doublesided?"DP3 temp.z, normal, eye;" + |
---|
.. | .. |
---|
12779 | 12959 | "MOV normald, normal;" + |
---|
12780 | 12960 | "MOV normals, normal;" + |
---|
12781 | 12961 | |
---|
| 12962 | + "MOV temp, fragment.texcoord[4];" + |
---|
| 12963 | + |
---|
12782 | 12964 | // UV base |
---|
12783 | 12965 | //"DP3 UP.x,state.matrix.modelview.row[0],Y;" + |
---|
12784 | 12966 | //"DP3 UP.y,state.matrix.modelview.row[1],Y;" + |
---|
12785 | 12967 | //"DP3 UP.z,state.matrix.modelview.row[2],Y;" + |
---|
12786 | | - "DP3 UP.x,state.matrix.texture[7].row[0],Y;" + |
---|
12787 | | - "DP3 UP.y,state.matrix.texture[7].row[1],Y;" + |
---|
12788 | | - "DP3 UP.z,state.matrix.texture[7].row[2],Y;" + |
---|
| 12968 | + "DP3 UP.x,state.matrix.texture[7].row[0],temp;" + |
---|
| 12969 | + "DP3 UP.y,state.matrix.texture[7].row[1],temp;" + |
---|
| 12970 | + "DP3 UP.z,state.matrix.texture[7].row[2],temp;" + |
---|
| 12971 | + Normalize("UP") + |
---|
| 12972 | + |
---|
12789 | 12973 | "XPD V, normal, UP;" + |
---|
12790 | 12974 | Normalize("V") + |
---|
12791 | 12975 | "XPD U, V, normal;" + |
---|
12792 | 12976 | Normalize("U") + |
---|
12793 | 12977 | |
---|
12794 | 12978 | // parallax mapping |
---|
| 12979 | + |
---|
| 12980 | + "DP3 temp2.x, V, eye;" + |
---|
| 12981 | + "DP3 temp2.y, U, eye;" + |
---|
| 12982 | + "DP3 temp2.z, normal, eye;" + |
---|
| 12983 | + "RCP temp2.z, temp2.z;" + |
---|
| 12984 | + |
---|
| 12985 | + "DP3 temp2.w, texSamp, texSamp;" + // Height |
---|
| 12986 | + "RSQ temp2.w, temp2.w;" + |
---|
| 12987 | + "RCP temp2.w, temp2.w;" + |
---|
| 12988 | + |
---|
| 12989 | + "SUB temp2.w, temp2.w, half;" + |
---|
| 12990 | +// "SGE temp.x, temp2.w, eps.x;" + |
---|
| 12991 | +// "MUL temp2.w, temp2.w, temp.x;" + |
---|
| 12992 | + |
---|
| 12993 | + //"MOV texSamp, U;" + |
---|
| 12994 | + |
---|
| 12995 | + "MUL temp2.z, temp2.z, temp2.w;" + |
---|
| 12996 | + "MUL temp2.z, temp2.z, params7.z;" + // parallax |
---|
| 12997 | + |
---|
| 12998 | + "MUL temp2, temp2, temp2.z;" + |
---|
| 12999 | + |
---|
| 13000 | + "MOV temp, fragment.texcoord[0];" + |
---|
| 13001 | + |
---|
| 13002 | + "SUB temp, temp, temp2;" + |
---|
| 13003 | + |
---|
| 13004 | + "TEX temp, temp, texture[0], 2D;" + |
---|
| 13005 | + "POW temp.a, temp.a, params6.w;" + // punch through |
---|
| 13006 | + |
---|
| 13007 | + "ADD texSamp, temp, texSamp;" + |
---|
| 13008 | + "MUL texSamp.xyz, half, texSamp;" + |
---|
| 13009 | + |
---|
| 13010 | + "MOV alpha, texSamp.aaaa;" + |
---|
| 13011 | + |
---|
| 13012 | +// parallax mapping |
---|
| 13013 | + |
---|
| 13014 | + "MOV temp.x, texSamp.a;" + |
---|
| 13015 | + "LRP texSamp, params5.x, texSamp, one;" + // texture proportion |
---|
| 13016 | + //"LRP texSamp0, params5.x, texSamp0, one;" + |
---|
| 13017 | + "MOV texSamp.a, temp.x;" + |
---|
12795 | 13018 | |
---|
12796 | 13019 | //"MOV temp, fragment.texcoord[0];" + |
---|
12797 | 13020 | // |
---|
.. | .. |
---|
12921 | 13144 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 13145 | "") + |
---|
12923 | 13146 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 13147 | + // display shadow only (fakedepth == 0) |
---|
12925 | 13148 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 13149 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13150 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12928 | 13151 | "SUB temp.y, one.x, temp.z;" + |
---|
12929 | 13152 | "MUL temp.x, temp.x, temp.y;" + |
---|
12930 | 13153 | "KIL temp.x;" + |
---|
.. | .. |
---|
13255 | 13478 | //once = true; |
---|
13256 | 13479 | } |
---|
13257 | 13480 | |
---|
13258 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13259 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13481 | + String program = programmax; |
---|
| 13482 | + |
---|
| 13483 | + if (Globals.MINSHADER) |
---|
| 13484 | + { |
---|
| 13485 | + program = programmin; |
---|
| 13486 | + } |
---|
| 13487 | + |
---|
| 13488 | + if (Globals.DEBUG) |
---|
| 13489 | + { |
---|
| 13490 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13491 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13492 | + } |
---|
| 13493 | + |
---|
13260 | 13494 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13261 | 13495 | |
---|
13262 | 13496 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13303 | 13537 | "\n" + |
---|
13304 | 13538 | "END\n"; |
---|
13305 | 13539 | |
---|
13306 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13540 | + if (Globals.DEBUG) |
---|
| 13541 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13307 | 13542 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13308 | 13543 | |
---|
13309 | 13544 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13348 | 13583 | return out; |
---|
13349 | 13584 | } |
---|
13350 | 13585 | |
---|
13351 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13586 | + // Also does frustum culling |
---|
| 13587 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13352 | 13588 | { |
---|
13353 | 13589 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13590 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13591 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13592 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13593 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13594 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13357 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13358 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13359 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13360 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13595 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13596 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13597 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13598 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13599 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13600 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13601 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13602 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13603 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13604 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13605 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13606 | } |
---|
13371 | 13607 | |
---|
13372 | 13608 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13649 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13650 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13651 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13652 | + // No shadow when out of frustum |
---|
13417 | 13653 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13654 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13655 | ""; |
---|
.. | .. |
---|
13560 | 13796 | /*static*/ float[] modelParams4 = new float[]{0, 0, 0, 0}; // anisoV, cameralight, selfshadow, shadow |
---|
13561 | 13797 | /*static*/ float[] modelParams5 = new float[]{0, 0, 0, 0}; // texture, opacity, fakedepth, shadowbias |
---|
13562 | 13798 | /*static*/ float[] modelParams6 = new float[]{0, 0, 0, 0}; // bump, noise, borderfade, fog punchthrough |
---|
13563 | | - /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power |
---|
| 13799 | + /*static*/ float[] modelParams7 = new float[]{0, 0, 0, 0}; // noise power, opacity power, parallax |
---|
13564 | 13800 | |
---|
13565 | 13801 | //Object3D.cVector2[] vector2buffer; |
---|
13566 | 13802 | |
---|
.. | .. |
---|
13727 | 13963 | "PARAM p[4] = { state.matrix.projection }; # modelview projection matrix\n" + |
---|
13728 | 13964 | "PARAM zero = { 0.0, 0.0, 0.0, 1.0 };" + |
---|
13729 | 13965 | "PARAM half = { 0.5, 0.5, 0.5, 1.0 };" + |
---|
13730 | | - "PARAM one = { 1.0, 1.0, 1.0, 0.0 };" + |
---|
| 13966 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
13731 | 13967 | "PARAM two = { 2.0, 2.0, 2.0, 1.0 };" + |
---|
13732 | 13968 | "PARAM third = { 0.33333333333, 0.33333333333, 0.33333333333, 1.0 };" + |
---|
13733 | 13969 | //"PARAM v256 = { 256.0, 256.0, 256.0, 1.0 };" + |
---|
.. | .. |
---|
13788 | 14024 | "DP4 temp.x,state.matrix.texture[0].inverse.row[0],vertex.texcoord;" + |
---|
13789 | 14025 | "DP4 temp.y,state.matrix.texture[0].inverse.row[1],vertex.texcoord;" + |
---|
13790 | 14026 | "DP4 temp.z,state.matrix.texture[0].inverse.row[2],vertex.texcoord;" + |
---|
13791 | | - //"MOV result.texcoord, vertex.texcoord;" + |
---|
| 14027 | + //"MOV result.texcoord, vertex.fogcoord;" + |
---|
13792 | 14028 | "MOV result.texcoord, temp;" + |
---|
13793 | 14029 | // border fade |
---|
13794 | 14030 | "MOV result.texcoord[3], vertex.texcoord;" + |
---|
.. | .. |
---|
13835 | 14071 | |
---|
13836 | 14072 | //"ADD temp.z, temp.z, one;" + |
---|
13837 | 14073 | |
---|
13838 | | - "MOV result.color, temp;" |
---|
| 14074 | + "MOV result.texcoord[4], vertex.attrib[4];" + // U dir |
---|
| 14075 | + |
---|
| 14076 | + "MOV result.color, temp;" // Normal |
---|
13839 | 14077 | : "MOV result.color, vertex.color;") + |
---|
13840 | 14078 | ((mode & VP_PROJECTION) != 0 ? "MOV result.color, zero;" |
---|
13841 | 14079 | : "") + |
---|
.. | .. |
---|
14211 | 14449 | drag = false; |
---|
14212 | 14450 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14451 | editObj = false; |
---|
14214 | | - ClickInfo info = new ClickInfo(); |
---|
14215 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14216 | | - info.pane = this; |
---|
14217 | | - info.camera = renderCamera; |
---|
14218 | | - info.x = x; |
---|
14219 | | - info.y = y; |
---|
14220 | | - info.modifiers = modifiersex; |
---|
14221 | | - editObj = object.doEditClick(info, 0); |
---|
| 14452 | + //ClickInfo info = new ClickInfo(); |
---|
| 14453 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14454 | + object.clickInfo.pane = this; |
---|
| 14455 | + object.clickInfo.camera = renderCamera; |
---|
| 14456 | + object.clickInfo.x = x; |
---|
| 14457 | + object.clickInfo.y = y; |
---|
| 14458 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14459 | + editObj = object.doEditClick(//info, |
---|
| 14460 | + 0); |
---|
14222 | 14461 | if (!editObj) |
---|
14223 | 14462 | { |
---|
14224 | 14463 | hasMarquee = true; |
---|
.. | .. |
---|
14500 | 14739 | void GoDown(int mod) |
---|
14501 | 14740 | { |
---|
14502 | 14741 | MODIFIERS |= COMMAND; |
---|
| 14742 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14503 | 14743 | /**/ |
---|
14504 | 14744 | if((mod&SHIFT) == SHIFT) |
---|
14505 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14745 | + { |
---|
| 14746 | + if (isVR) |
---|
| 14747 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14748 | + else |
---|
| 14749 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14750 | + } |
---|
14506 | 14751 | else |
---|
14507 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14752 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14508 | 14753 | /**/ |
---|
14509 | 14754 | if ((mod & SHIFT) == SHIFT) |
---|
14510 | 14755 | { |
---|
.. | .. |
---|
14514 | 14759 | mouseMode |= BACKFORTH; |
---|
14515 | 14760 | } |
---|
14516 | 14761 | |
---|
| 14762 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14763 | + |
---|
14517 | 14764 | //prevX = X = anchorX; |
---|
14518 | 14765 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14519 | 14766 | } |
---|
.. | .. |
---|
14522 | 14769 | { |
---|
14523 | 14770 | MODIFIERS |= COMMAND; |
---|
14524 | 14771 | /**/ |
---|
| 14772 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14773 | + |
---|
14525 | 14774 | if((mod&SHIFT) == SHIFT) |
---|
14526 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14775 | + { |
---|
| 14776 | + if (isVR) |
---|
| 14777 | + manipCamera.RotateInterest(0, speed); |
---|
| 14778 | + else |
---|
| 14779 | + manipCamera.RotatePosition(0, speed); |
---|
| 14780 | + } |
---|
14527 | 14781 | else |
---|
14528 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14782 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14529 | 14783 | /**/ |
---|
14530 | 14784 | if ((mod & SHIFT) == SHIFT) |
---|
14531 | 14785 | { |
---|
.. | .. |
---|
14535 | 14789 | mouseMode |= BACKFORTH; |
---|
14536 | 14790 | } |
---|
14537 | 14791 | |
---|
| 14792 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14793 | + |
---|
14538 | 14794 | //prevX = X = anchorX; |
---|
14539 | 14795 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14540 | 14796 | } |
---|
.. | .. |
---|
14544 | 14800 | MODIFIERS |= COMMAND; |
---|
14545 | 14801 | /**/ |
---|
14546 | 14802 | if((mod&SHIFT) == SHIFT) |
---|
14547 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14803 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14548 | 14804 | else |
---|
14549 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14805 | + { |
---|
| 14806 | + if ((mouseMode&VR)!=0) |
---|
| 14807 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14808 | + else |
---|
| 14809 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14810 | + } |
---|
14550 | 14811 | /**/ |
---|
14551 | 14812 | if ((mod & SHIFT) == SHIFT) |
---|
14552 | 14813 | { |
---|
.. | .. |
---|
14556 | 14817 | mouseMode |= ROTATE; |
---|
14557 | 14818 | } // TRANSLATE; |
---|
14558 | 14819 | |
---|
| 14820 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14821 | + |
---|
14559 | 14822 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14560 | 14823 | prevY = Y = anchorY; |
---|
14561 | 14824 | } |
---|
.. | .. |
---|
14565 | 14828 | MODIFIERS |= COMMAND; |
---|
14566 | 14829 | /**/ |
---|
14567 | 14830 | if((mod&SHIFT) == SHIFT) |
---|
14568 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14831 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14569 | 14832 | else |
---|
14570 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14833 | + { |
---|
| 14834 | + if ((mouseMode&VR)!=0) |
---|
| 14835 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14836 | + else |
---|
| 14837 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14838 | + } |
---|
| 14839 | + |
---|
14571 | 14840 | /**/ |
---|
14572 | 14841 | if ((mod & SHIFT) == SHIFT) |
---|
14573 | 14842 | { |
---|
.. | .. |
---|
14577 | 14846 | mouseMode |= ROTATE; |
---|
14578 | 14847 | } // TRANSLATE; |
---|
14579 | 14848 | |
---|
| 14849 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14850 | + |
---|
14580 | 14851 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14581 | 14852 | prevY = Y = anchorY; |
---|
14582 | 14853 | } |
---|
.. | .. |
---|
14618 | 14889 | if (editObj) |
---|
14619 | 14890 | { |
---|
14620 | 14891 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14892 | + //ClickInfo info = new ClickInfo(); |
---|
| 14893 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14894 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14624 | | - info.pane = this; |
---|
14625 | | - info.camera = renderCamera; |
---|
14626 | | - info.x = x; |
---|
14627 | | - info.y = y; |
---|
14628 | | - object.GetWindow().copy |
---|
14629 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14895 | + object.clickInfo.pane = this; |
---|
| 14896 | + object.clickInfo.camera = renderCamera; |
---|
| 14897 | + object.clickInfo.x = x; |
---|
| 14898 | + object.clickInfo.y = y; |
---|
| 14899 | + object //.GetWindow().copy |
---|
| 14900 | + .doEditDrag(//info, |
---|
| 14901 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14902 | } else |
---|
14631 | 14903 | { |
---|
14632 | 14904 | if (x < startX) |
---|
.. | .. |
---|
14775 | 15047 | } |
---|
14776 | 15048 | } |
---|
14777 | 15049 | |
---|
| 15050 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 15051 | + |
---|
14778 | 15052 | public void mouseMoved(MouseEvent e) |
---|
14779 | 15053 | { |
---|
14780 | 15054 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 15055 | if (isRenderer) |
---|
14782 | 15056 | return; |
---|
14783 | 15057 | |
---|
14784 | | - ClickInfo ci = new ClickInfo(); |
---|
14785 | | - ci.x = e.getX(); |
---|
14786 | | - ci.y = e.getY(); |
---|
14787 | | - ci.modifiers = e.getModifiersEx(); |
---|
14788 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14789 | | - ci.pane = this; |
---|
14790 | | - ci.camera = renderCamera; |
---|
| 15058 | + // Mouse cursor feedback |
---|
| 15059 | + object.clickInfo.x = e.getX(); |
---|
| 15060 | + object.clickInfo.y = e.getY(); |
---|
| 15061 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15062 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15063 | + object.clickInfo.pane = this; |
---|
| 15064 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 15065 | if (!isRenderer) |
---|
14792 | 15066 | { |
---|
14793 | 15067 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 15068 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 15069 | + if (object.doEditClick(//clickInfo, |
---|
| 15070 | + 0)) |
---|
14796 | 15071 | { |
---|
14797 | 15072 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 15073 | } else |
---|
.. | .. |
---|
15075 | 15350 | case 'K': |
---|
15076 | 15351 | KOMPACTTEXTURE ^= true; |
---|
15077 | 15352 | //textures.clear(); |
---|
15078 | | - break; |
---|
15079 | | - case 'P': // Texture Projection macros |
---|
| 15353 | + // break; |
---|
| 15354 | + //case 'P': // Texture Projection macros |
---|
15080 | 15355 | // SAVETEXTURE ^= true; |
---|
15081 | 15356 | macromode = true; |
---|
15082 | 15357 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15197 | 15472 | targetLookAt.set(manipCamera.lookAt); |
---|
15198 | 15473 | repaint(); |
---|
15199 | 15474 | break; |
---|
15200 | | - case 'p': |
---|
| 15475 | + case 'P': // p': |
---|
15201 | 15476 | // c'est quoi ca au juste? spherical ^= true; |
---|
15202 | 15477 | Skinshader ^= true; programInitialized = false; |
---|
15203 | 15478 | repaint(); |
---|
.. | .. |
---|
15235 | 15510 | repaint(); |
---|
15236 | 15511 | break; |
---|
15237 | 15512 | case 'O': |
---|
15238 | | - Globals.drawMode = OCCLUSION; // WARNING |
---|
| 15513 | + // Too dangerous. Use menu. Globals.drawMode = OCCLUSION; // WARNING |
---|
15239 | 15514 | repaint(); |
---|
15240 | 15515 | break; |
---|
15241 | 15516 | case 'o': |
---|
15242 | 15517 | OCCLUSION_CULLING ^= true; |
---|
15243 | 15518 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15244 | 15519 | break; |
---|
15245 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15520 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15246 | 15521 | case '1': |
---|
15247 | 15522 | case '2': |
---|
15248 | 15523 | case '3': |
---|
15249 | 15524 | case '4': |
---|
15250 | 15525 | case '5': |
---|
15251 | | - newenvy = Character.getNumericValue(key); |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | 15526 | case '6': |
---|
15255 | 15527 | case '7': |
---|
15256 | 15528 | case '8': |
---|
15257 | 15529 | case '9': |
---|
15258 | | - BGcolor = (key - '6')/3.f; |
---|
| 15530 | + if (true) // envyoff) |
---|
| 15531 | + { |
---|
| 15532 | + BGcolor = (key - '1')/8.f; |
---|
| 15533 | + } |
---|
| 15534 | + else |
---|
| 15535 | + { |
---|
| 15536 | + //newenvy = Character.getNumericValue(key); |
---|
| 15537 | + } |
---|
15259 | 15538 | repaint(); |
---|
15260 | 15539 | break; |
---|
15261 | 15540 | case '!': |
---|
.. | .. |
---|
15818 | 16097 | |
---|
15819 | 16098 | int width = getBounds().width; |
---|
15820 | 16099 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 16100 | //Image img = CreateImage(width, height); |
---|
15824 | 16101 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 16102 | |
---|
.. | .. |
---|
15896 | 16173 | } |
---|
15897 | 16174 | if (object != null && !hasMarquee) |
---|
15898 | 16175 | { |
---|
| 16176 | + if (object.clickInfo == null) |
---|
| 16177 | + object.clickInfo = new ClickInfo(); |
---|
| 16178 | + ClickInfo info = object.clickInfo; |
---|
| 16179 | + //ClickInfo info = new ClickInfo(); |
---|
| 16180 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16181 | + |
---|
15899 | 16182 | if (isRenderer) |
---|
15900 | 16183 | { |
---|
15901 | | - info.flags++; |
---|
| 16184 | + object.clickInfo.flags++; |
---|
15902 | 16185 | double frameAspect = (double) width / (double) height; |
---|
15903 | 16186 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 16187 | { |
---|
15905 | 16188 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16189 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16190 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 16191 | } else |
---|
15909 | 16192 | { |
---|
15910 | 16193 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16194 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16195 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 16196 | } |
---|
15914 | 16197 | } |
---|
15915 | 16198 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 16199 | + object.clickInfo.g = gr; |
---|
| 16200 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 16201 | /* |
---|
15919 | 16202 | // Memory intensive (brep.verticescopy) |
---|
15920 | 16203 | if (!(object instanceof Composite)) |
---|
15921 | 16204 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 16205 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 16206 | + if (!isRenderer) // && drag) |
---|
15924 | 16207 | { |
---|
15925 | 16208 | Grafreed.Assert(object != null); |
---|
15926 | 16209 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 16211 | { |
---|
15929 | 16212 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 16213 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 16214 | + object.clickInfo.DX = 0; |
---|
| 16215 | + object.clickInfo.DY = 0; |
---|
| 16216 | + object.clickInfo.W = 1; |
---|
15934 | 16217 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 16218 | { |
---|
15936 | 16219 | info.DX = X; |
---|
.. | .. |
---|
15942 | 16225 | info.DY -= info.bounds.height/2; |
---|
15943 | 16226 | } |
---|
15944 | 16227 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 16228 | + object.drawEditHandles(//info, |
---|
| 16229 | + 0); |
---|
15946 | 16230 | |
---|
15947 | 16231 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16232 | { |
---|
15949 | 16233 | switch (hitSomething) |
---|
15950 | 16234 | { |
---|
15951 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16235 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
15952 | 16236 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15953 | 16237 | break; |
---|
15954 | 16238 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
15974 | 16258 | if (hasMarquee) |
---|
15975 | 16259 | { |
---|
15976 | 16260 | gr.setXORMode(Color.white); |
---|
15977 | | - gr.setColor(Color.red); |
---|
| 16261 | + gr.setColor(Color.white); |
---|
15978 | 16262 | if (!firstime) |
---|
15979 | 16263 | { |
---|
15980 | 16264 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16441 | 16725 | private /*static*/ boolean firstime; |
---|
16442 | 16726 | private /*static*/ cVector newView = new cVector(); |
---|
16443 | 16727 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16728 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16729 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16444 | 16730 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16445 | 16731 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16446 | 16732 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16453 | 16739 | { |
---|
16454 | 16740 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16455 | 16741 | |
---|
| 16742 | + int usedsuf = 0; |
---|
| 16743 | + |
---|
16456 | 16744 | for (int i = 0; i < suffixes.length; i++) |
---|
16457 | 16745 | { |
---|
16458 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16459 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16460 | | - mipmapped, |
---|
16461 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16462 | | - if (data == null) |
---|
| 16746 | + String[] suffixe = suffixes; |
---|
| 16747 | + String[] fallback = suffixes2; |
---|
| 16748 | + String[] fallfallback = suffixes3; |
---|
| 16749 | + |
---|
| 16750 | + for (int c=usedsuf; --c>=0;) |
---|
16463 | 16751 | { |
---|
16464 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16752 | +// String[] temp = suffixe; |
---|
| 16753 | +// suffixe = fallback; |
---|
| 16754 | +// fallback = fallfallback; |
---|
| 16755 | +// fallfallback = temp; |
---|
16465 | 16756 | } |
---|
| 16757 | + |
---|
| 16758 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16759 | + TextureData data; |
---|
| 16760 | + |
---|
| 16761 | + try |
---|
| 16762 | + { |
---|
| 16763 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16764 | + mipmapped, |
---|
| 16765 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16766 | + } |
---|
| 16767 | + catch (Exception e) |
---|
| 16768 | + { |
---|
| 16769 | + try |
---|
| 16770 | + { |
---|
| 16771 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16772 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16773 | + mipmapped, |
---|
| 16774 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16775 | + } |
---|
| 16776 | + catch (Exception e2) |
---|
| 16777 | + { |
---|
| 16778 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16779 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16780 | + mipmapped, |
---|
| 16781 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16782 | + } |
---|
| 16783 | + } |
---|
| 16784 | + |
---|
16466 | 16785 | //System.out.println("Target = " + targets[i]); |
---|
16467 | 16786 | cubemap.updateImage(data, targets[i]); |
---|
16468 | 16787 | } |
---|
16469 | 16788 | |
---|
16470 | 16789 | return cubemap; |
---|
16471 | 16790 | } |
---|
| 16791 | + |
---|
16472 | 16792 | int bigsphere = -1; |
---|
16473 | 16793 | |
---|
16474 | 16794 | float BGcolor = 0.5f; |
---|
16475 | 16795 | |
---|
16476 | | - private void DrawSkyBox(GL gl) |
---|
| 16796 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16797 | + |
---|
| 16798 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16477 | 16799 | { |
---|
16478 | | - if (envyoff || cubemap == null) |
---|
| 16800 | + if (//envyoff || |
---|
| 16801 | + WIREFRAME || |
---|
| 16802 | + cubemap == null) |
---|
16479 | 16803 | { |
---|
16480 | 16804 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16481 | 16805 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16490 | 16814 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16491 | 16815 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16492 | 16816 | gl.glLoadIdentity(); |
---|
| 16817 | + gl.glScalef(1,ratio,1); |
---|
16493 | 16818 | |
---|
| 16819 | +// colorV[0] = 2; |
---|
| 16820 | +// colorV[1] = 2; |
---|
| 16821 | +// colorV[2] = 2; |
---|
| 16822 | +// colorV[3] = 1; |
---|
| 16823 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16824 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16825 | +// |
---|
| 16826 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16827 | + |
---|
16494 | 16828 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16495 | 16829 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16496 | 16830 | |
---|
.. | .. |
---|
16522 | 16856 | { |
---|
16523 | 16857 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16524 | 16858 | } |
---|
| 16859 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16525 | 16860 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16526 | 16861 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16527 | 16862 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16562 | 16897 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16563 | 16898 | |
---|
16564 | 16899 | cubemap.disable(); |
---|
16565 | | - ////cubemap.unbind(); |
---|
| 16900 | + //cubemap.dispose(); |
---|
| 16901 | + |
---|
16566 | 16902 | if (CULLFACE) |
---|
16567 | 16903 | { |
---|
16568 | 16904 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16618 | 16954 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16619 | 16955 | } |
---|
16620 | 16956 | |
---|
16621 | | - gl.glNormal3f(0.0f, 0.0f, 1.0f); |
---|
| 16957 | + SetGLNormal(gl, 0.0f, 0.0f, 1.0f); |
---|
16622 | 16958 | |
---|
16623 | 16959 | float step = 2; // 0.1666f; //0.25f; |
---|
16624 | 16960 | float stepv = 2; // step * 1652 / 998; |
---|
.. | .. |
---|
16780 | 17116 | //new Exception().printStackTrace(); |
---|
16781 | 17117 | System.out.println("select buffer init"); |
---|
16782 | 17118 | // Use debug pipeline |
---|
16783 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17119 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16784 | 17120 | |
---|
16785 | 17121 | GL gl = drawable.getGL(); |
---|
16786 | 17122 | |
---|
.. | .. |
---|
17098 | 17434 | |
---|
17099 | 17435 | public void init(GLAutoDrawable drawable) |
---|
17100 | 17436 | { |
---|
| 17437 | + if (Globals.DEBUG) |
---|
17101 | 17438 | System.out.println("shadow buffer init"); |
---|
17102 | 17439 | |
---|
17103 | 17440 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17326 | 17663 | gl.glFlush(); |
---|
17327 | 17664 | |
---|
17328 | 17665 | /**/ |
---|
17329 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17666 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17330 | 17667 | |
---|
17331 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17668 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17332 | 17669 | |
---|
| 17670 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17671 | + |
---|
| 17672 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17673 | + |
---|
17333 | 17674 | double r = 0, g = 0, b = 0; |
---|
17334 | 17675 | |
---|
17335 | 17676 | double count = 0; |
---|
.. | .. |
---|
17340 | 17681 | |
---|
17341 | 17682 | double FACTOR = 1; |
---|
17342 | 17683 | |
---|
17343 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17684 | + for (int i = 0; i < depths.length; i++) |
---|
17344 | 17685 | { |
---|
17345 | 17686 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17346 | 17687 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17423 | 17764 | |
---|
17424 | 17765 | double scale = ray.z; // 1; // cos |
---|
17425 | 17766 | |
---|
17426 | | - float depth = pixels[newindex]; |
---|
| 17767 | + float depth = depths[newindex]; |
---|
17427 | 17768 | |
---|
17428 | 17769 | /* |
---|
17429 | 17770 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17620 | 17961 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17621 | 17962 | static IntBuffer bigAAbuffer; |
---|
17622 | 17963 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17623 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17964 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17624 | 17965 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17625 | 17966 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17626 | 17967 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17627 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17968 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17969 | + |
---|
| 17970 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17971 | + |
---|
17628 | 17972 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17629 | 17973 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17630 | 17974 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|