.. | .. |
---|
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 |
---|
.. | .. |
---|
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 | |
---|
.. | .. |
---|
1484 | 1502 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1485 | 1503 | } |
---|
1486 | 1504 | |
---|
| 1505 | + float[] colorV = new float[4]; |
---|
| 1506 | + |
---|
1487 | 1507 | void SetColor(Object3D obj, Vertex p0) |
---|
1488 | 1508 | { |
---|
1489 | 1509 | CameraPane display = this; |
---|
.. | .. |
---|
1551 | 1571 | { |
---|
1552 | 1572 | return; |
---|
1553 | 1573 | } |
---|
1554 | | - |
---|
1555 | | - float[] colorV = new float[3]; |
---|
1556 | 1574 | |
---|
1557 | 1575 | if (false) // marked) |
---|
1558 | 1576 | { |
---|
.. | .. |
---|
2499 | 2517 | com.sun.opengl.util.texture.TextureIO.newTextureData( |
---|
2500 | 2518 | getClass().getClassLoader().getResourceAsStream(name), |
---|
2501 | 2519 | true, |
---|
2502 | | - com.sun.opengl.util.texture.TextureIO.PNG); |
---|
| 2520 | + GetFormat(name)); // com.sun.opengl.util.texture.TextureIO.PNG); |
---|
2503 | 2521 | } catch (java.io.IOException e) |
---|
2504 | 2522 | { |
---|
2505 | 2523 | throw new javax.media.opengl.GLException(e); |
---|
.. | .. |
---|
8345 | 8363 | // else |
---|
8346 | 8364 | // if (!texname.startsWith("/")) |
---|
8347 | 8365 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8348 | | - if (!FileExists(texname)) |
---|
| 8366 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8349 | 8367 | { |
---|
8350 | 8368 | texname = fallbackTextureName; |
---|
8351 | 8369 | } |
---|
.. | .. |
---|
8428 | 8446 | new Exception().printStackTrace(); |
---|
8429 | 8447 | } else |
---|
8430 | 8448 | { |
---|
| 8449 | + if (texname.startsWith("@")) |
---|
| 8450 | + { |
---|
| 8451 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8452 | + if (texturecache == null) |
---|
| 8453 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8454 | + else |
---|
| 8455 | + new Exception().printStackTrace(); |
---|
| 8456 | + } else |
---|
| 8457 | + { |
---|
8431 | 8458 | if (textureon) |
---|
8432 | 8459 | { |
---|
8433 | 8460 | String cachename = texname; |
---|
.. | .. |
---|
8487 | 8514 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8488 | 8515 | //texture = GetTexture(tex, bump); |
---|
8489 | 8516 | } |
---|
| 8517 | + } |
---|
8490 | 8518 | } |
---|
8491 | 8519 | //} |
---|
8492 | 8520 | } |
---|
.. | .. |
---|
8755 | 8783 | |
---|
8756 | 8784 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8757 | 8785 | MAXSTACK = temp[0]; |
---|
8758 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8786 | + if (Globals.DEBUG) |
---|
| 8787 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8759 | 8788 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8760 | 8789 | MAXSTACK = temp[0]; |
---|
8761 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8790 | + if (Globals.DEBUG) |
---|
| 8791 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8762 | 8792 | |
---|
8763 | 8793 | // Use debug pipeline |
---|
8764 | 8794 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8766 | 8796 | gl = drawable.getGL(); // |
---|
8767 | 8797 | |
---|
8768 | 8798 | GL gl3 = getGL(); |
---|
8769 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8799 | + if (Globals.DEBUG) |
---|
| 8800 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8770 | 8801 | |
---|
8771 | 8802 | |
---|
8772 | 8803 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8931 | 8962 | |
---|
8932 | 8963 | if (cubemap == null) |
---|
8933 | 8964 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8965 | + //LoadEnvy(1); |
---|
8935 | 8966 | } |
---|
8936 | 8967 | |
---|
8937 | 8968 | //cubemap.enable(); |
---|
.. | .. |
---|
9207 | 9238 | |
---|
9208 | 9239 | void LoadEnvy(int which) |
---|
9209 | 9240 | { |
---|
| 9241 | + assert(false); |
---|
| 9242 | + |
---|
9210 | 9243 | String name; |
---|
9211 | 9244 | String ext; |
---|
9212 | 9245 | |
---|
.. | .. |
---|
9218 | 9251 | cubemap = null; |
---|
9219 | 9252 | return; |
---|
9220 | 9253 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9254 | + name = "cubemaps/rgb/"; |
---|
| 9255 | + ext = "jpg"; |
---|
9223 | 9256 | reverseUP = false; |
---|
9224 | 9257 | break; |
---|
9225 | 9258 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9259 | + name = "cubemaps/uffizi/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
9229 | 9263 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9264 | + name = "cubemaps/CloudyHills/"; |
---|
| 9265 | + ext = "jpg"; |
---|
9232 | 9266 | reverseUP = false; |
---|
9233 | 9267 | break; |
---|
9234 | 9268 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9269 | + name = "cubemaps/cornell/"; |
---|
9236 | 9270 | ext = "png"; |
---|
9237 | 9271 | reverseUP = false; |
---|
9238 | 9272 | break; |
---|
| 9273 | + case 5: |
---|
| 9274 | + name = "cubemaps/skycube/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 6: |
---|
| 9279 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 7: |
---|
| 9284 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
| 9288 | + case 8: |
---|
| 9289 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9290 | + ext = "jpg"; |
---|
| 9291 | + reverseUP = false; |
---|
| 9292 | + break; |
---|
| 9293 | + case 9: |
---|
| 9294 | + name = "cubemaps/UnionSquare/"; |
---|
| 9295 | + ext = "jpg"; |
---|
| 9296 | + reverseUP = false; |
---|
| 9297 | + break; |
---|
9239 | 9298 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9299 | + name = "cubemaps/box/"; |
---|
| 9300 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9301 | + reverseUP = false; |
---|
9242 | 9302 | break; |
---|
9243 | 9303 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9304 | + |
---|
| 9305 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9306 | } |
---|
9253 | 9307 | |
---|
9254 | 9308 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9334 | static double[] model = new double[16]; |
---|
9281 | 9335 | double[] camera2light = new double[16]; |
---|
9282 | 9336 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9337 | + |
---|
| 9338 | + //int newenvy = -1; |
---|
| 9339 | + //boolean envyoff = false; |
---|
| 9340 | + |
---|
| 9341 | + String loadedskyboxname; |
---|
| 9342 | + |
---|
9285 | 9343 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9344 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9345 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9699 | 9757 | |
---|
9700 | 9758 | if (renderCamera != lightCamera) |
---|
9701 | 9759 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9760 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9761 | |
---|
9704 | 9762 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9763 | |
---|
.. | .. |
---|
9715 | 9773 | |
---|
9716 | 9774 | if (renderCamera != lightCamera) |
---|
9717 | 9775 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9776 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9777 | |
---|
9720 | 9778 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9779 | |
---|
.. | .. |
---|
9761 | 9819 | rati = 1 / rati; |
---|
9762 | 9820 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9821 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9822 | + |
---|
| 9823 | + //assert (newenvy == -1); |
---|
| 9824 | + |
---|
9765 | 9825 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9826 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9827 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9828 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9829 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9830 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10801 | 10861 | |
---|
10802 | 10862 | if (wait) |
---|
10803 | 10863 | { |
---|
10804 | | - Sleep(500); |
---|
| 10864 | + Sleep(200); // blocks everything |
---|
10805 | 10865 | |
---|
10806 | 10866 | wait = false; |
---|
10807 | 10867 | } |
---|
.. | .. |
---|
10916 | 10976 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10977 | if (cam != lightCamera) |
---|
10918 | 10978 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10979 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10980 | |
---|
10921 | 10981 | for (int j = 0; j < 4; j++) |
---|
10922 | 10982 | { |
---|
.. | .. |
---|
10931 | 10991 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 10992 | if (cam != lightCamera) |
---|
10933 | 10993 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10994 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 10995 | |
---|
10936 | 10996 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 10997 | |
---|
.. | .. |
---|
11017 | 11077 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11078 | } |
---|
11019 | 11079 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11080 | +// if (newenvy > -1) |
---|
| 11081 | +// { |
---|
| 11082 | +// LoadEnvy(newenvy); |
---|
| 11083 | +// } |
---|
| 11084 | +// |
---|
| 11085 | +// newenvy = -1; |
---|
| 11086 | + |
---|
| 11087 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11021 | 11088 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11089 | + if (cubemaprgb == null) |
---|
| 11090 | + { |
---|
| 11091 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
| 11094 | + cubemap = cubemaprgb; |
---|
11023 | 11095 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11096 | + else |
---|
| 11097 | + { |
---|
| 11098 | + if (object.skyboxname != null) |
---|
| 11099 | + { |
---|
| 11100 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11101 | + { |
---|
| 11102 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11103 | + cubemap.dispose(); |
---|
| 11104 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11105 | + loadedskyboxname = object.skyboxname; |
---|
| 11106 | + } |
---|
| 11107 | + } |
---|
| 11108 | + else |
---|
| 11109 | + { |
---|
| 11110 | + cubemapcustom = null; |
---|
| 11111 | + loadedskyboxname = null; |
---|
| 11112 | + } |
---|
| 11113 | + |
---|
| 11114 | + cubemap = cubemapcustom; |
---|
| 11115 | + } |
---|
| 11116 | + |
---|
11027 | 11117 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11118 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11119 | |
---|
.. | .. |
---|
11039 | 11129 | |
---|
11040 | 11130 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11131 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11132 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11133 | } |
---|
11044 | 11134 | |
---|
11045 | 11135 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11415 | |
---|
11326 | 11416 | // if (cam != lightCamera) |
---|
11327 | 11417 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11418 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11419 | } |
---|
11330 | 11420 | |
---|
11331 | 11421 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12489 | |
---|
12400 | 12490 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12491 | |
---|
12402 | | - String program = |
---|
| 12492 | + String programmin = |
---|
| 12493 | + // Min shader |
---|
12403 | 12494 | "!!ARBfp1.0\n" + |
---|
| 12495 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12496 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12497 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12498 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12499 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12500 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12501 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12502 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12503 | + "TEMP temp;" + |
---|
| 12504 | + "TEMP light;" + |
---|
| 12505 | + "TEMP ndotl;" + |
---|
| 12506 | + "TEMP normal;" + |
---|
| 12507 | + "TEMP depth;" + |
---|
| 12508 | + "TEMP eye;" + |
---|
| 12509 | + "TEMP pos;" + |
---|
| 12510 | + |
---|
| 12511 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12512 | + Normalize("normal") + |
---|
| 12513 | + "MOV light, state.light[0].position;" + |
---|
| 12514 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12515 | + |
---|
| 12516 | + // shadow |
---|
| 12517 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12518 | + "MOV temp, pos;" + |
---|
| 12519 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12520 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12521 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12522 | + |
---|
| 12523 | + // No shadow when out of frustum |
---|
| 12524 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12525 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12526 | + |
---|
| 12527 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12528 | + |
---|
| 12529 | + // Backlit |
---|
| 12530 | + "MOV pos.w, zero123.y;" + |
---|
| 12531 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12532 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12533 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12534 | + Normalize("eye") + |
---|
| 12535 | + |
---|
| 12536 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12537 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12538 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12539 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12540 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12541 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12542 | + |
---|
| 12543 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12544 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12545 | + |
---|
| 12546 | + // Pigment |
---|
| 12547 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12548 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12549 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12550 | + |
---|
| 12551 | + "MUL temp, temp, zero123.z;" + |
---|
| 12552 | + |
---|
| 12553 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12554 | + |
---|
| 12555 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12556 | + "MOV result.color, temp;" + |
---|
| 12557 | + "END"; |
---|
| 12558 | + |
---|
| 12559 | + String programmax = |
---|
| 12560 | + "!!ARBfp1.0\n" + |
---|
| 12561 | + |
---|
12404 | 12562 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12563 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12564 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12673 | "TEMP shininess;" + |
---|
12516 | 12674 | "\n" + |
---|
12517 | 12675 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12676 | + |
---|
12520 | 12677 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12678 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12679 | /* |
---|
.. | .. |
---|
12537 | 12694 | "MUL temp, floor, mapgrid.x;" + |
---|
12538 | 12695 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12539 | 12696 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12540 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12697 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12541 | 12698 | "") + |
---|
12542 | 12699 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12543 | 12700 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12544 | 12701 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12545 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12546 | 12703 | "") + |
---|
12547 | 12704 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12548 | 12705 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12549 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12550 | 12707 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12551 | 12708 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12552 | 12709 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12553 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12710 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12554 | 12711 | "") + |
---|
12555 | 12712 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12556 | 12713 | //"MOV params, material;" + |
---|
.. | .. |
---|
12921 | 13078 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 13079 | "") + |
---|
12923 | 13080 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 13081 | + // display shadow only (fakedepth == 0) |
---|
12925 | 13082 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 13083 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13084 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12928 | 13085 | "SUB temp.y, one.x, temp.z;" + |
---|
12929 | 13086 | "MUL temp.x, temp.x, temp.y;" + |
---|
12930 | 13087 | "KIL temp.x;" + |
---|
.. | .. |
---|
13255 | 13412 | //once = true; |
---|
13256 | 13413 | } |
---|
13257 | 13414 | |
---|
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 " : "")); |
---|
| 13415 | + String program = programmax; |
---|
| 13416 | + |
---|
| 13417 | + if (Globals.MINSHADER) |
---|
| 13418 | + { |
---|
| 13419 | + program = programmin; |
---|
| 13420 | + } |
---|
| 13421 | + |
---|
| 13422 | + if (Globals.DEBUG) |
---|
| 13423 | + { |
---|
| 13424 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13425 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13426 | + } |
---|
| 13427 | + |
---|
13260 | 13428 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13261 | 13429 | |
---|
13262 | 13430 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13303 | 13471 | "\n" + |
---|
13304 | 13472 | "END\n"; |
---|
13305 | 13473 | |
---|
13306 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13474 | + if (Globals.DEBUG) |
---|
| 13475 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13307 | 13476 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13308 | 13477 | |
---|
13309 | 13478 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13348 | 13517 | return out; |
---|
13349 | 13518 | } |
---|
13350 | 13519 | |
---|
13351 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13520 | + // Also does frustum culling |
---|
| 13521 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13352 | 13522 | { |
---|
13353 | 13523 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13524 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13525 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13526 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13527 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13528 | "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;" + |
---|
| 13529 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13530 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13531 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13532 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13533 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13534 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13535 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13536 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13537 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13538 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13539 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13540 | } |
---|
13371 | 13541 | |
---|
13372 | 13542 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13583 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13584 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13585 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13586 | + // No shadow when out of frustum |
---|
13417 | 13587 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13588 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13589 | ""; |
---|
.. | .. |
---|
14211 | 14381 | drag = false; |
---|
14212 | 14382 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14383 | 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); |
---|
| 14384 | + //ClickInfo info = new ClickInfo(); |
---|
| 14385 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14386 | + object.clickInfo.pane = this; |
---|
| 14387 | + object.clickInfo.camera = renderCamera; |
---|
| 14388 | + object.clickInfo.x = x; |
---|
| 14389 | + object.clickInfo.y = y; |
---|
| 14390 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14391 | + editObj = object.doEditClick(//info, |
---|
| 14392 | + 0); |
---|
14222 | 14393 | if (!editObj) |
---|
14223 | 14394 | { |
---|
14224 | 14395 | hasMarquee = true; |
---|
.. | .. |
---|
14500 | 14671 | void GoDown(int mod) |
---|
14501 | 14672 | { |
---|
14502 | 14673 | MODIFIERS |= COMMAND; |
---|
| 14674 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14503 | 14675 | /**/ |
---|
14504 | 14676 | if((mod&SHIFT) == SHIFT) |
---|
14505 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14677 | + { |
---|
| 14678 | + if (isVR) |
---|
| 14679 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14680 | + else |
---|
| 14681 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14682 | + } |
---|
14506 | 14683 | else |
---|
14507 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14684 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14508 | 14685 | /**/ |
---|
14509 | 14686 | if ((mod & SHIFT) == SHIFT) |
---|
14510 | 14687 | { |
---|
.. | .. |
---|
14514 | 14691 | mouseMode |= BACKFORTH; |
---|
14515 | 14692 | } |
---|
14516 | 14693 | |
---|
| 14694 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14695 | + |
---|
14517 | 14696 | //prevX = X = anchorX; |
---|
14518 | 14697 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14519 | 14698 | } |
---|
.. | .. |
---|
14522 | 14701 | { |
---|
14523 | 14702 | MODIFIERS |= COMMAND; |
---|
14524 | 14703 | /**/ |
---|
| 14704 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14705 | + |
---|
14525 | 14706 | if((mod&SHIFT) == SHIFT) |
---|
14526 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14707 | + { |
---|
| 14708 | + if (isVR) |
---|
| 14709 | + manipCamera.RotateInterest(0, speed); |
---|
| 14710 | + else |
---|
| 14711 | + manipCamera.RotatePosition(0, speed); |
---|
| 14712 | + } |
---|
14527 | 14713 | else |
---|
14528 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14714 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14529 | 14715 | /**/ |
---|
14530 | 14716 | if ((mod & SHIFT) == SHIFT) |
---|
14531 | 14717 | { |
---|
.. | .. |
---|
14535 | 14721 | mouseMode |= BACKFORTH; |
---|
14536 | 14722 | } |
---|
14537 | 14723 | |
---|
| 14724 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14725 | + |
---|
14538 | 14726 | //prevX = X = anchorX; |
---|
14539 | 14727 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14540 | 14728 | } |
---|
.. | .. |
---|
14544 | 14732 | MODIFIERS |= COMMAND; |
---|
14545 | 14733 | /**/ |
---|
14546 | 14734 | if((mod&SHIFT) == SHIFT) |
---|
14547 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14735 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14548 | 14736 | else |
---|
14549 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14737 | + { |
---|
| 14738 | + if ((mouseMode&VR)!=0) |
---|
| 14739 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14740 | + else |
---|
| 14741 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14742 | + } |
---|
14550 | 14743 | /**/ |
---|
14551 | 14744 | if ((mod & SHIFT) == SHIFT) |
---|
14552 | 14745 | { |
---|
.. | .. |
---|
14556 | 14749 | mouseMode |= ROTATE; |
---|
14557 | 14750 | } // TRANSLATE; |
---|
14558 | 14751 | |
---|
| 14752 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14753 | + |
---|
14559 | 14754 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14560 | 14755 | prevY = Y = anchorY; |
---|
14561 | 14756 | } |
---|
.. | .. |
---|
14565 | 14760 | MODIFIERS |= COMMAND; |
---|
14566 | 14761 | /**/ |
---|
14567 | 14762 | if((mod&SHIFT) == SHIFT) |
---|
14568 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14763 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14569 | 14764 | else |
---|
14570 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14765 | + { |
---|
| 14766 | + if ((mouseMode&VR)!=0) |
---|
| 14767 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14768 | + else |
---|
| 14769 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14770 | + } |
---|
| 14771 | + |
---|
14571 | 14772 | /**/ |
---|
14572 | 14773 | if ((mod & SHIFT) == SHIFT) |
---|
14573 | 14774 | { |
---|
.. | .. |
---|
14577 | 14778 | mouseMode |= ROTATE; |
---|
14578 | 14779 | } // TRANSLATE; |
---|
14579 | 14780 | |
---|
| 14781 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14782 | + |
---|
14580 | 14783 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14581 | 14784 | prevY = Y = anchorY; |
---|
14582 | 14785 | } |
---|
.. | .. |
---|
14618 | 14821 | if (editObj) |
---|
14619 | 14822 | { |
---|
14620 | 14823 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14824 | + //ClickInfo info = new ClickInfo(); |
---|
| 14825 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14826 | (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); |
---|
| 14827 | + object.clickInfo.pane = this; |
---|
| 14828 | + object.clickInfo.camera = renderCamera; |
---|
| 14829 | + object.clickInfo.x = x; |
---|
| 14830 | + object.clickInfo.y = y; |
---|
| 14831 | + object //.GetWindow().copy |
---|
| 14832 | + .doEditDrag(//info, |
---|
| 14833 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14834 | } else |
---|
14631 | 14835 | { |
---|
14632 | 14836 | if (x < startX) |
---|
.. | .. |
---|
14775 | 14979 | } |
---|
14776 | 14980 | } |
---|
14777 | 14981 | |
---|
| 14982 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14983 | + |
---|
14778 | 14984 | public void mouseMoved(MouseEvent e) |
---|
14779 | 14985 | { |
---|
14780 | 14986 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 14987 | if (isRenderer) |
---|
14782 | 14988 | return; |
---|
14783 | 14989 | |
---|
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; |
---|
| 14990 | + // Mouse cursor feedback |
---|
| 14991 | + object.clickInfo.x = e.getX(); |
---|
| 14992 | + object.clickInfo.y = e.getY(); |
---|
| 14993 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14994 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14995 | + object.clickInfo.pane = this; |
---|
| 14996 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 14997 | if (!isRenderer) |
---|
14792 | 14998 | { |
---|
14793 | 14999 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 15000 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 15001 | + if (object.doEditClick(//clickInfo, |
---|
| 15002 | + 0)) |
---|
14796 | 15003 | { |
---|
14797 | 15004 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 15005 | } else |
---|
.. | .. |
---|
15242 | 15449 | OCCLUSION_CULLING ^= true; |
---|
15243 | 15450 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15244 | 15451 | break; |
---|
15245 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15452 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15246 | 15453 | case '1': |
---|
15247 | 15454 | case '2': |
---|
15248 | 15455 | case '3': |
---|
15249 | 15456 | case '4': |
---|
15250 | 15457 | case '5': |
---|
15251 | | - newenvy = Character.getNumericValue(key); |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | 15458 | case '6': |
---|
15255 | 15459 | case '7': |
---|
15256 | 15460 | case '8': |
---|
15257 | 15461 | case '9': |
---|
15258 | | - BGcolor = (key - '6')/3.f; |
---|
| 15462 | + if (true) // envyoff) |
---|
| 15463 | + { |
---|
| 15464 | + BGcolor = (key - '1')/8.f; |
---|
| 15465 | + } |
---|
| 15466 | + else |
---|
| 15467 | + { |
---|
| 15468 | + //newenvy = Character.getNumericValue(key); |
---|
| 15469 | + } |
---|
15259 | 15470 | repaint(); |
---|
15260 | 15471 | break; |
---|
15261 | 15472 | case '!': |
---|
.. | .. |
---|
15818 | 16029 | |
---|
15819 | 16030 | int width = getBounds().width; |
---|
15820 | 16031 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 16032 | //Image img = CreateImage(width, height); |
---|
15824 | 16033 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 16034 | |
---|
.. | .. |
---|
15896 | 16105 | } |
---|
15897 | 16106 | if (object != null && !hasMarquee) |
---|
15898 | 16107 | { |
---|
| 16108 | + if (object.clickInfo == null) |
---|
| 16109 | + object.clickInfo = new ClickInfo(); |
---|
| 16110 | + ClickInfo info = object.clickInfo; |
---|
| 16111 | + //ClickInfo info = new ClickInfo(); |
---|
| 16112 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16113 | + |
---|
15899 | 16114 | if (isRenderer) |
---|
15900 | 16115 | { |
---|
15901 | | - info.flags++; |
---|
| 16116 | + object.clickInfo.flags++; |
---|
15902 | 16117 | double frameAspect = (double) width / (double) height; |
---|
15903 | 16118 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 16119 | { |
---|
15905 | 16120 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16121 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16122 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 16123 | } else |
---|
15909 | 16124 | { |
---|
15910 | 16125 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16126 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16127 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 16128 | } |
---|
15914 | 16129 | } |
---|
15915 | 16130 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 16131 | + object.clickInfo.g = gr; |
---|
| 16132 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 16133 | /* |
---|
15919 | 16134 | // Memory intensive (brep.verticescopy) |
---|
15920 | 16135 | if (!(object instanceof Composite)) |
---|
15921 | 16136 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 16137 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 16138 | + if (!isRenderer) // && drag) |
---|
15924 | 16139 | { |
---|
15925 | 16140 | Grafreed.Assert(object != null); |
---|
15926 | 16141 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 16143 | { |
---|
15929 | 16144 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 16145 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 16146 | + object.clickInfo.DX = 0; |
---|
| 16147 | + object.clickInfo.DY = 0; |
---|
| 16148 | + object.clickInfo.W = 1; |
---|
15934 | 16149 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 16150 | { |
---|
15936 | 16151 | info.DX = X; |
---|
.. | .. |
---|
15942 | 16157 | info.DY -= info.bounds.height/2; |
---|
15943 | 16158 | } |
---|
15944 | 16159 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 16160 | + object.drawEditHandles(//info, |
---|
| 16161 | + 0); |
---|
15946 | 16162 | |
---|
15947 | 16163 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16164 | { |
---|
15949 | 16165 | switch (hitSomething) |
---|
15950 | 16166 | { |
---|
15951 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16167 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
15952 | 16168 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15953 | 16169 | break; |
---|
15954 | 16170 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
15974 | 16190 | if (hasMarquee) |
---|
15975 | 16191 | { |
---|
15976 | 16192 | gr.setXORMode(Color.white); |
---|
15977 | | - gr.setColor(Color.red); |
---|
| 16193 | + gr.setColor(Color.white); |
---|
15978 | 16194 | if (!firstime) |
---|
15979 | 16195 | { |
---|
15980 | 16196 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16441 | 16657 | private /*static*/ boolean firstime; |
---|
16442 | 16658 | private /*static*/ cVector newView = new cVector(); |
---|
16443 | 16659 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16660 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16661 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16444 | 16662 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16445 | 16663 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16446 | 16664 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16453 | 16671 | { |
---|
16454 | 16672 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16455 | 16673 | |
---|
| 16674 | + int usedsuf = 0; |
---|
| 16675 | + |
---|
16456 | 16676 | for (int i = 0; i < suffixes.length; i++) |
---|
16457 | 16677 | { |
---|
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) |
---|
| 16678 | + String[] suffixe = suffixes; |
---|
| 16679 | + String[] fallback = suffixes2; |
---|
| 16680 | + String[] fallfallback = suffixes3; |
---|
| 16681 | + |
---|
| 16682 | + for (int c=usedsuf; --c>=0;) |
---|
16463 | 16683 | { |
---|
16464 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16684 | +// String[] temp = suffixe; |
---|
| 16685 | +// suffixe = fallback; |
---|
| 16686 | +// fallback = fallfallback; |
---|
| 16687 | +// fallfallback = temp; |
---|
16465 | 16688 | } |
---|
| 16689 | + |
---|
| 16690 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16691 | + TextureData data; |
---|
| 16692 | + |
---|
| 16693 | + try |
---|
| 16694 | + { |
---|
| 16695 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16696 | + mipmapped, |
---|
| 16697 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16698 | + } |
---|
| 16699 | + catch (Exception e) |
---|
| 16700 | + { |
---|
| 16701 | + try |
---|
| 16702 | + { |
---|
| 16703 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e2) |
---|
| 16709 | + { |
---|
| 16710 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16711 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16712 | + mipmapped, |
---|
| 16713 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16714 | + } |
---|
| 16715 | + } |
---|
| 16716 | + |
---|
16466 | 16717 | //System.out.println("Target = " + targets[i]); |
---|
16467 | 16718 | cubemap.updateImage(data, targets[i]); |
---|
16468 | 16719 | } |
---|
16469 | 16720 | |
---|
16470 | 16721 | return cubemap; |
---|
16471 | 16722 | } |
---|
| 16723 | + |
---|
16472 | 16724 | int bigsphere = -1; |
---|
16473 | 16725 | |
---|
16474 | 16726 | float BGcolor = 0.5f; |
---|
16475 | 16727 | |
---|
16476 | | - private void DrawSkyBox(GL gl) |
---|
| 16728 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16729 | + |
---|
| 16730 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16477 | 16731 | { |
---|
16478 | | - if (envyoff || cubemap == null) |
---|
| 16732 | + if (//envyoff || |
---|
| 16733 | + WIREFRAME || |
---|
| 16734 | + cubemap == null) |
---|
16479 | 16735 | { |
---|
16480 | 16736 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16481 | 16737 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16490 | 16746 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16491 | 16747 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16492 | 16748 | gl.glLoadIdentity(); |
---|
| 16749 | + gl.glScalef(1,ratio,1); |
---|
16493 | 16750 | |
---|
| 16751 | +// colorV[0] = 2; |
---|
| 16752 | +// colorV[1] = 2; |
---|
| 16753 | +// colorV[2] = 2; |
---|
| 16754 | +// colorV[3] = 1; |
---|
| 16755 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16756 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16757 | +// |
---|
| 16758 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16759 | + |
---|
16494 | 16760 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16495 | 16761 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16496 | 16762 | |
---|
.. | .. |
---|
16522 | 16788 | { |
---|
16523 | 16789 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16524 | 16790 | } |
---|
| 16791 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16525 | 16792 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16526 | 16793 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16527 | 16794 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16562 | 16829 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16563 | 16830 | |
---|
16564 | 16831 | cubemap.disable(); |
---|
16565 | | - ////cubemap.unbind(); |
---|
| 16832 | + //cubemap.dispose(); |
---|
| 16833 | + |
---|
16566 | 16834 | if (CULLFACE) |
---|
16567 | 16835 | { |
---|
16568 | 16836 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16780 | 17048 | //new Exception().printStackTrace(); |
---|
16781 | 17049 | System.out.println("select buffer init"); |
---|
16782 | 17050 | // Use debug pipeline |
---|
16783 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17051 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16784 | 17052 | |
---|
16785 | 17053 | GL gl = drawable.getGL(); |
---|
16786 | 17054 | |
---|
.. | .. |
---|
17098 | 17366 | |
---|
17099 | 17367 | public void init(GLAutoDrawable drawable) |
---|
17100 | 17368 | { |
---|
| 17369 | + if (Globals.DEBUG) |
---|
17101 | 17370 | System.out.println("shadow buffer init"); |
---|
17102 | 17371 | |
---|
17103 | 17372 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17326 | 17595 | gl.glFlush(); |
---|
17327 | 17596 | |
---|
17328 | 17597 | /**/ |
---|
17329 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17598 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17330 | 17599 | |
---|
17331 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17600 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17332 | 17601 | |
---|
| 17602 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17603 | + |
---|
| 17604 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17605 | + |
---|
17333 | 17606 | double r = 0, g = 0, b = 0; |
---|
17334 | 17607 | |
---|
17335 | 17608 | double count = 0; |
---|
.. | .. |
---|
17340 | 17613 | |
---|
17341 | 17614 | double FACTOR = 1; |
---|
17342 | 17615 | |
---|
17343 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17616 | + for (int i = 0; i < depths.length; i++) |
---|
17344 | 17617 | { |
---|
17345 | 17618 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17346 | 17619 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17423 | 17696 | |
---|
17424 | 17697 | double scale = ray.z; // 1; // cos |
---|
17425 | 17698 | |
---|
17426 | | - float depth = pixels[newindex]; |
---|
| 17699 | + float depth = depths[newindex]; |
---|
17427 | 17700 | |
---|
17428 | 17701 | /* |
---|
17429 | 17702 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17620 | 17893 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17621 | 17894 | static IntBuffer bigAAbuffer; |
---|
17622 | 17895 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17623 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17896 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17624 | 17897 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17625 | 17898 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17626 | 17899 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17627 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17900 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17901 | + |
---|
| 17902 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17903 | + |
---|
17628 | 17904 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17629 | 17905 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17630 | 17906 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|