.. | .. |
---|
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 | |
---|
.. | .. |
---|
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 | { |
---|
.. | .. |
---|
2034 | 2052 | switch(viewcode) |
---|
2035 | 2053 | { |
---|
2036 | 2054 | case 0: return "main"; |
---|
2037 | | - case 1: return "one"; |
---|
2038 | | - case 2: return "two"; |
---|
2039 | | - case 3: return "three"; |
---|
| 2055 | + case 1: return "Red"; |
---|
| 2056 | + case 2: return "Green"; |
---|
| 2057 | + case 3: return "Blue"; |
---|
2040 | 2058 | case 4: return "light"; |
---|
2041 | 2059 | } |
---|
2042 | 2060 | |
---|
.. | .. |
---|
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, |
---|
.. | .. |
---|
10630 | 10690 | static boolean init = false; |
---|
10631 | 10691 | |
---|
10632 | 10692 | double[][] matrix = LA.newMatrix(); |
---|
| 10693 | + |
---|
| 10694 | + // This is to refresh the UI of the material panel. |
---|
| 10695 | + ObjEditor patchMaterial; |
---|
10633 | 10696 | |
---|
10634 | 10697 | public void display(GLAutoDrawable drawable) |
---|
10635 | 10698 | { |
---|
| 10699 | + if (patchMaterial.patchMaterial) |
---|
| 10700 | + { |
---|
| 10701 | + patchMaterial.patchMaterial = false; |
---|
| 10702 | + patchMaterial.objectPanel.setSelectedIndex(0); |
---|
| 10703 | + } |
---|
| 10704 | + |
---|
10636 | 10705 | if (Grafreed.savesound && Grafreed.hassound) |
---|
10637 | 10706 | { |
---|
10638 | 10707 | Grafreed.wav.save(); |
---|
.. | .. |
---|
10801 | 10870 | |
---|
10802 | 10871 | if (wait) |
---|
10803 | 10872 | { |
---|
10804 | | - Sleep(500); |
---|
| 10873 | + Sleep(200); // blocks everything |
---|
10805 | 10874 | |
---|
10806 | 10875 | wait = false; |
---|
10807 | 10876 | } |
---|
.. | .. |
---|
10916 | 10985 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10986 | if (cam != lightCamera) |
---|
10918 | 10987 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10988 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10989 | |
---|
10921 | 10990 | for (int j = 0; j < 4; j++) |
---|
10922 | 10991 | { |
---|
.. | .. |
---|
10931 | 11000 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 11001 | if (cam != lightCamera) |
---|
10933 | 11002 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 11003 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 11004 | |
---|
10936 | 11005 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 11006 | |
---|
.. | .. |
---|
11017 | 11086 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11087 | } |
---|
11019 | 11088 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11089 | +// if (newenvy > -1) |
---|
| 11090 | +// { |
---|
| 11091 | +// LoadEnvy(newenvy); |
---|
| 11092 | +// } |
---|
| 11093 | +// |
---|
| 11094 | +// newenvy = -1; |
---|
| 11095 | + |
---|
| 11096 | + if (transformMode) // object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11021 | 11097 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11098 | + if (cubemaprgb == null) |
---|
| 11099 | + { |
---|
| 11100 | + cubemaprgb = LoadSkybox("cubemaps/default-skyboxes/rgb2" + "/", "jpg", false); |
---|
| 11101 | + } |
---|
| 11102 | + |
---|
| 11103 | + cubemap = cubemaprgb; |
---|
11023 | 11104 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11105 | + else |
---|
| 11106 | + { |
---|
| 11107 | + if (object.skyboxname != null) |
---|
| 11108 | + { |
---|
| 11109 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11110 | + { |
---|
| 11111 | + if (cubemap != null && cubemap != cubemaprgb) |
---|
| 11112 | + cubemap.dispose(); |
---|
| 11113 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11114 | + loadedskyboxname = object.skyboxname; |
---|
| 11115 | + } |
---|
| 11116 | + } |
---|
| 11117 | + else |
---|
| 11118 | + { |
---|
| 11119 | + cubemapcustom = null; |
---|
| 11120 | + loadedskyboxname = null; |
---|
| 11121 | + } |
---|
| 11122 | + |
---|
| 11123 | + cubemap = cubemapcustom; |
---|
| 11124 | + } |
---|
| 11125 | + |
---|
11027 | 11126 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11127 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11128 | |
---|
.. | .. |
---|
11039 | 11138 | |
---|
11040 | 11139 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11140 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11141 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11142 | } |
---|
11044 | 11143 | |
---|
11045 | 11144 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11424 | |
---|
11326 | 11425 | // if (cam != lightCamera) |
---|
11327 | 11426 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11427 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11428 | } |
---|
11330 | 11429 | |
---|
11331 | 11430 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12498 | |
---|
12400 | 12499 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12500 | |
---|
12402 | | - String program = |
---|
| 12501 | + String programmin = |
---|
12403 | 12502 | // Min shader |
---|
12404 | 12503 | "!!ARBfp1.0\n" + |
---|
12405 | | - "PARAM zero123 = { 0.0, 1.0, 2.0, 3.0 };" + |
---|
| 12504 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12406 | 12505 | "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
12407 | 12506 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12408 | 12507 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12409 | 12508 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12509 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12510 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12511 | + "PARAM light2cam2 = program.env[12];" + |
---|
12410 | 12512 | "TEMP temp;" + |
---|
12411 | 12513 | "TEMP light;" + |
---|
12412 | 12514 | "TEMP ndotl;" + |
---|
12413 | 12515 | "TEMP normal;" + |
---|
12414 | 12516 | "TEMP depth;" + |
---|
| 12517 | + "TEMP eye;" + |
---|
| 12518 | + "TEMP pos;" + |
---|
12415 | 12519 | |
---|
12416 | 12520 | "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
12417 | | - |
---|
| 12521 | + Normalize("normal") + |
---|
12418 | 12522 | "MOV light, state.light[0].position;" + |
---|
12419 | 12523 | "DP3 ndotl.x, light, normal;" + |
---|
12420 | 12524 | |
---|
12421 | 12525 | // shadow |
---|
12422 | | - "MOV temp, fragment.texcoord[1];" + |
---|
12423 | | - TextureFetch("depth", "temp", "1") + |
---|
| 12526 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12527 | + "MOV temp, pos;" + |
---|
| 12528 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
12424 | 12529 | //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
12425 | | - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
12426 | | - |
---|
| 12530 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
12427 | 12531 | |
---|
12428 | 12532 | // No shadow when out of frustum |
---|
12429 | 12533 | //"SGE temp.y, depth.z, zero123.y;" + |
---|
12430 | 12534 | //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
12431 | 12535 | |
---|
12432 | | - "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
12433 | | - "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12536 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12434 | 12537 | |
---|
| 12538 | + // Backlit |
---|
| 12539 | + "MOV pos.w, zero123.y;" + |
---|
| 12540 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12541 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12542 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12543 | + Normalize("eye") + |
---|
| 12544 | + |
---|
| 12545 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12546 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12547 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12548 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12549 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12550 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12551 | + |
---|
| 12552 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12553 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12554 | + |
---|
| 12555 | + // Pigment |
---|
12435 | 12556 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12557 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12436 | 12558 | "MUL temp, temp, ndotl.x;" + |
---|
12437 | 12559 | |
---|
12438 | 12560 | "MUL temp, temp, zero123.z;" + |
---|
12439 | 12561 | |
---|
12440 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12562 | + //"MUL temp, temp, ndotl.y;" + |
---|
12441 | 12563 | |
---|
| 12564 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
12442 | 12565 | "MOV result.color, temp;" + |
---|
12443 | 12566 | "END"; |
---|
12444 | 12567 | |
---|
12445 | | - String program2 = |
---|
| 12568 | + String programmax = |
---|
12446 | 12569 | "!!ARBfp1.0\n" + |
---|
12447 | 12570 | |
---|
12448 | 12571 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12580 | 12703 | "MUL temp, floor, mapgrid.x;" + |
---|
12581 | 12704 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12582 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12583 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12584 | 12707 | "") + |
---|
12585 | 12708 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12586 | 12709 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12587 | 12710 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12588 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12711 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12589 | 12712 | "") + |
---|
12590 | 12713 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12591 | 12714 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12592 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12715 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12593 | 12716 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12594 | 12717 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12595 | 12718 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12596 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12719 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12597 | 12720 | "") + |
---|
12598 | 12721 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12599 | 12722 | //"MOV params, material;" + |
---|
.. | .. |
---|
12967 | 13090 | // display shadow only (fakedepth == 0) |
---|
12968 | 13091 | "SUB temp.x, half.x, shadow.x;" + |
---|
12969 | 13092 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12970 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13093 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12971 | 13094 | "SUB temp.y, one.x, temp.z;" + |
---|
12972 | 13095 | "MUL temp.x, temp.x, temp.y;" + |
---|
12973 | 13096 | "KIL temp.x;" + |
---|
.. | .. |
---|
13298 | 13421 | //once = true; |
---|
13299 | 13422 | } |
---|
13300 | 13423 | |
---|
13301 | | - System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13302 | | - System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13424 | + String program = programmax; |
---|
| 13425 | + |
---|
| 13426 | + if (Globals.MINSHADER) |
---|
| 13427 | + { |
---|
| 13428 | + program = programmin; |
---|
| 13429 | + } |
---|
| 13430 | + |
---|
| 13431 | + if (Globals.DEBUG) |
---|
| 13432 | + { |
---|
| 13433 | + System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
| 13434 | + System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
| 13435 | + } |
---|
| 13436 | + |
---|
13303 | 13437 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13304 | 13438 | |
---|
13305 | 13439 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13346 | 13480 | "\n" + |
---|
13347 | 13481 | "END\n"; |
---|
13348 | 13482 | |
---|
13349 | | - System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
| 13483 | + if (Globals.DEBUG) |
---|
| 13484 | + System.out.println("Program shadow #" + 0 + "; length = " + program.length()); |
---|
13350 | 13485 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
13351 | 13486 | |
---|
13352 | 13487 | //gl.glNewList(displayListID, GL.GL_COMPILE); |
---|
.. | .. |
---|
13391 | 13526 | return out; |
---|
13392 | 13527 | } |
---|
13393 | 13528 | |
---|
13394 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13529 | + // Also does frustum culling |
---|
| 13530 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13395 | 13531 | { |
---|
13396 | 13532 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13397 | 13533 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13398 | 13534 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13535 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13536 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13399 | 13537 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13400 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13401 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13402 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13403 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13538 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13539 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13404 | 13540 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13405 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13541 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13406 | 13542 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13407 | 13543 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13408 | 13544 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13409 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13545 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13410 | 13546 | |
---|
13411 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13412 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13547 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13548 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13413 | 13549 | } |
---|
13414 | 13550 | |
---|
13415 | 13551 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
14254 | 14390 | drag = false; |
---|
14255 | 14391 | //System.out.println("Mouse DOWN"); |
---|
14256 | 14392 | editObj = false; |
---|
14257 | | - ClickInfo info = new ClickInfo(); |
---|
14258 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14259 | | - info.pane = this; |
---|
14260 | | - info.camera = renderCamera; |
---|
14261 | | - info.x = x; |
---|
14262 | | - info.y = y; |
---|
14263 | | - info.modifiers = modifiersex; |
---|
14264 | | - editObj = object.doEditClick(info, 0); |
---|
| 14393 | + //ClickInfo info = new ClickInfo(); |
---|
| 14394 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14395 | + object.clickInfo.pane = this; |
---|
| 14396 | + object.clickInfo.camera = renderCamera; |
---|
| 14397 | + object.clickInfo.x = x; |
---|
| 14398 | + object.clickInfo.y = y; |
---|
| 14399 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14400 | + editObj = object.doEditClick(//info, |
---|
| 14401 | + 0); |
---|
14265 | 14402 | if (!editObj) |
---|
14266 | 14403 | { |
---|
14267 | 14404 | hasMarquee = true; |
---|
.. | .. |
---|
14543 | 14680 | void GoDown(int mod) |
---|
14544 | 14681 | { |
---|
14545 | 14682 | MODIFIERS |= COMMAND; |
---|
| 14683 | + boolean isVR = (mouseMode&VR)!=0; |
---|
14546 | 14684 | /**/ |
---|
14547 | 14685 | if((mod&SHIFT) == SHIFT) |
---|
14548 | | - manipCamera.RotatePosition(0, -speed); |
---|
| 14686 | + { |
---|
| 14687 | + if (isVR) |
---|
| 14688 | + manipCamera.RotateInterest(0, -speed); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, -speed); |
---|
| 14691 | + } |
---|
14549 | 14692 | else |
---|
14550 | | - manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14693 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14551 | 14694 | /**/ |
---|
14552 | 14695 | if ((mod & SHIFT) == SHIFT) |
---|
14553 | 14696 | { |
---|
.. | .. |
---|
14557 | 14700 | mouseMode |= BACKFORTH; |
---|
14558 | 14701 | } |
---|
14559 | 14702 | |
---|
| 14703 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14704 | + |
---|
14560 | 14705 | //prevX = X = anchorX; |
---|
14561 | 14706 | prevY = Y = anchorY - (int) (renderCamera.Distance()); |
---|
14562 | 14707 | } |
---|
.. | .. |
---|
14565 | 14710 | { |
---|
14566 | 14711 | MODIFIERS |= COMMAND; |
---|
14567 | 14712 | /**/ |
---|
| 14713 | + boolean isVR = (mouseMode&VR)!=0; |
---|
| 14714 | + |
---|
14568 | 14715 | if((mod&SHIFT) == SHIFT) |
---|
14569 | | - manipCamera.RotatePosition(0, speed); |
---|
| 14716 | + { |
---|
| 14717 | + if (isVR) |
---|
| 14718 | + manipCamera.RotateInterest(0, speed); |
---|
| 14719 | + else |
---|
| 14720 | + manipCamera.RotatePosition(0, speed); |
---|
| 14721 | + } |
---|
14570 | 14722 | else |
---|
14571 | | - manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14723 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14572 | 14724 | /**/ |
---|
14573 | 14725 | if ((mod & SHIFT) == SHIFT) |
---|
14574 | 14726 | { |
---|
.. | .. |
---|
14578 | 14730 | mouseMode |= BACKFORTH; |
---|
14579 | 14731 | } |
---|
14580 | 14732 | |
---|
| 14733 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14734 | + |
---|
14581 | 14735 | //prevX = X = anchorX; |
---|
14582 | 14736 | prevY = Y = anchorY + (int) (renderCamera.Distance()); |
---|
14583 | 14737 | } |
---|
.. | .. |
---|
14587 | 14741 | MODIFIERS |= COMMAND; |
---|
14588 | 14742 | /**/ |
---|
14589 | 14743 | if((mod&SHIFT) == SHIFT) |
---|
14590 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 14744 | + manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
14591 | 14745 | else |
---|
14592 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 14746 | + { |
---|
| 14747 | + if ((mouseMode&VR)!=0) |
---|
| 14748 | + manipCamera.RotateInterest(-speed, 0); |
---|
| 14749 | + else |
---|
| 14750 | + manipCamera.RotatePosition(speed, 0); |
---|
| 14751 | + } |
---|
14593 | 14752 | /**/ |
---|
14594 | 14753 | if ((mod & SHIFT) == SHIFT) |
---|
14595 | 14754 | { |
---|
.. | .. |
---|
14599 | 14758 | mouseMode |= ROTATE; |
---|
14600 | 14759 | } // TRANSLATE; |
---|
14601 | 14760 | |
---|
| 14761 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14762 | + |
---|
14602 | 14763 | prevX = X = anchorX - 10; // (int)(10*renderCamera.Distance()); |
---|
14603 | 14764 | prevY = Y = anchorY; |
---|
14604 | 14765 | } |
---|
.. | .. |
---|
14608 | 14769 | MODIFIERS |= COMMAND; |
---|
14609 | 14770 | /**/ |
---|
14610 | 14771 | if((mod&SHIFT) == SHIFT) |
---|
14611 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 14772 | + manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
14612 | 14773 | else |
---|
14613 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 14774 | + { |
---|
| 14775 | + if ((mouseMode&VR)!=0) |
---|
| 14776 | + manipCamera.RotateInterest(speed, 0); |
---|
| 14777 | + else |
---|
| 14778 | + manipCamera.RotatePosition(-speed, 0); |
---|
| 14779 | + } |
---|
| 14780 | + |
---|
14614 | 14781 | /**/ |
---|
14615 | 14782 | if ((mod & SHIFT) == SHIFT) |
---|
14616 | 14783 | { |
---|
.. | .. |
---|
14620 | 14787 | mouseMode |= ROTATE; |
---|
14621 | 14788 | } // TRANSLATE; |
---|
14622 | 14789 | |
---|
| 14790 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14791 | + |
---|
14623 | 14792 | prevX = X = anchorX + 10; // (int)(10*renderCamera.Distance()); |
---|
14624 | 14793 | prevY = Y = anchorY; |
---|
14625 | 14794 | } |
---|
.. | .. |
---|
14661 | 14830 | if (editObj) |
---|
14662 | 14831 | { |
---|
14663 | 14832 | drag = true; |
---|
14664 | | - ClickInfo info = new ClickInfo(); |
---|
14665 | | - info.bounds.setBounds(0, 0, |
---|
| 14833 | + //ClickInfo info = new ClickInfo(); |
---|
| 14834 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14666 | 14835 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14667 | | - info.pane = this; |
---|
14668 | | - info.camera = renderCamera; |
---|
14669 | | - info.x = x; |
---|
14670 | | - info.y = y; |
---|
14671 | | - object.GetWindow().copy |
---|
14672 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14836 | + object.clickInfo.pane = this; |
---|
| 14837 | + object.clickInfo.camera = renderCamera; |
---|
| 14838 | + object.clickInfo.x = x; |
---|
| 14839 | + object.clickInfo.y = y; |
---|
| 14840 | + object //.GetWindow().copy |
---|
| 14841 | + .doEditDrag(//info, |
---|
| 14842 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14673 | 14843 | } else |
---|
14674 | 14844 | { |
---|
14675 | 14845 | if (x < startX) |
---|
.. | .. |
---|
14818 | 14988 | } |
---|
14819 | 14989 | } |
---|
14820 | 14990 | |
---|
| 14991 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14992 | + |
---|
14821 | 14993 | public void mouseMoved(MouseEvent e) |
---|
14822 | 14994 | { |
---|
14823 | 14995 | //System.out.println("mouseMoved: " + e); |
---|
14824 | 14996 | if (isRenderer) |
---|
14825 | 14997 | return; |
---|
14826 | 14998 | |
---|
14827 | | - ClickInfo ci = new ClickInfo(); |
---|
14828 | | - ci.x = e.getX(); |
---|
14829 | | - ci.y = e.getY(); |
---|
14830 | | - ci.modifiers = e.getModifiersEx(); |
---|
14831 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14832 | | - ci.pane = this; |
---|
14833 | | - ci.camera = renderCamera; |
---|
| 14999 | + // Mouse cursor feedback |
---|
| 15000 | + object.clickInfo.x = e.getX(); |
---|
| 15001 | + object.clickInfo.y = e.getY(); |
---|
| 15002 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 15003 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 15004 | + object.clickInfo.pane = this; |
---|
| 15005 | + object.clickInfo.camera = renderCamera; |
---|
14834 | 15006 | if (!isRenderer) |
---|
14835 | 15007 | { |
---|
14836 | 15008 | //ObjEditor editWindow = object.editWindow; |
---|
14837 | 15009 | //Object3D copy = editWindow.copy; |
---|
14838 | | - if (object.doEditClick(ci, 0)) |
---|
| 15010 | + if (object.doEditClick(//clickInfo, |
---|
| 15011 | + 0)) |
---|
14839 | 15012 | { |
---|
14840 | 15013 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14841 | 15014 | } else |
---|
.. | .. |
---|
15118 | 15291 | case 'K': |
---|
15119 | 15292 | KOMPACTTEXTURE ^= true; |
---|
15120 | 15293 | //textures.clear(); |
---|
15121 | | - break; |
---|
15122 | | - case 'P': // Texture Projection macros |
---|
| 15294 | + // break; |
---|
| 15295 | + //case 'P': // Texture Projection macros |
---|
15123 | 15296 | // SAVETEXTURE ^= true; |
---|
15124 | 15297 | macromode = true; |
---|
15125 | 15298 | Udebug = Vdebug = NORMALdebug = false; programInitialized = false; |
---|
.. | .. |
---|
15240 | 15413 | targetLookAt.set(manipCamera.lookAt); |
---|
15241 | 15414 | repaint(); |
---|
15242 | 15415 | break; |
---|
15243 | | - case 'p': |
---|
| 15416 | + case 'P': // p': |
---|
15244 | 15417 | // c'est quoi ca au juste? spherical ^= true; |
---|
15245 | 15418 | Skinshader ^= true; programInitialized = false; |
---|
15246 | 15419 | repaint(); |
---|
.. | .. |
---|
15285 | 15458 | OCCLUSION_CULLING ^= true; |
---|
15286 | 15459 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15287 | 15460 | break; |
---|
15288 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15461 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15289 | 15462 | case '1': |
---|
15290 | 15463 | case '2': |
---|
15291 | 15464 | case '3': |
---|
15292 | 15465 | case '4': |
---|
15293 | 15466 | case '5': |
---|
15294 | | - newenvy = Character.getNumericValue(key); |
---|
15295 | | - repaint(); |
---|
15296 | | - break; |
---|
15297 | 15467 | case '6': |
---|
15298 | 15468 | case '7': |
---|
15299 | 15469 | case '8': |
---|
15300 | 15470 | case '9': |
---|
15301 | | - BGcolor = (key - '6')/3.f; |
---|
| 15471 | + if (true) // envyoff) |
---|
| 15472 | + { |
---|
| 15473 | + BGcolor = (key - '1')/8.f; |
---|
| 15474 | + } |
---|
| 15475 | + else |
---|
| 15476 | + { |
---|
| 15477 | + //newenvy = Character.getNumericValue(key); |
---|
| 15478 | + } |
---|
15302 | 15479 | repaint(); |
---|
15303 | 15480 | break; |
---|
15304 | 15481 | case '!': |
---|
.. | .. |
---|
15861 | 16038 | |
---|
15862 | 16039 | int width = getBounds().width; |
---|
15863 | 16040 | int height = getBounds().height; |
---|
15864 | | - ClickInfo info = new ClickInfo(); |
---|
15865 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15866 | 16041 | //Image img = CreateImage(width, height); |
---|
15867 | 16042 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15868 | 16043 | |
---|
.. | .. |
---|
15939 | 16114 | } |
---|
15940 | 16115 | if (object != null && !hasMarquee) |
---|
15941 | 16116 | { |
---|
| 16117 | + if (object.clickInfo == null) |
---|
| 16118 | + object.clickInfo = new ClickInfo(); |
---|
| 16119 | + ClickInfo info = object.clickInfo; |
---|
| 16120 | + //ClickInfo info = new ClickInfo(); |
---|
| 16121 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16122 | + |
---|
15942 | 16123 | if (isRenderer) |
---|
15943 | 16124 | { |
---|
15944 | | - info.flags++; |
---|
| 16125 | + object.clickInfo.flags++; |
---|
15945 | 16126 | double frameAspect = (double) width / (double) height; |
---|
15946 | 16127 | if (frameAspect > renderCamera.aspect) |
---|
15947 | 16128 | { |
---|
15948 | 16129 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15949 | | - info.bounds.width -= width - desired; |
---|
15950 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16130 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16131 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15951 | 16132 | } else |
---|
15952 | 16133 | { |
---|
15953 | 16134 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15954 | | - info.bounds.height -= height - desired; |
---|
15955 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16135 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16136 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15956 | 16137 | } |
---|
15957 | 16138 | } |
---|
15958 | 16139 | |
---|
15959 | | - info.g = gr; |
---|
15960 | | - info.camera = renderCamera; |
---|
| 16140 | + object.clickInfo.g = gr; |
---|
| 16141 | + object.clickInfo.camera = renderCamera; |
---|
15961 | 16142 | /* |
---|
15962 | 16143 | // Memory intensive (brep.verticescopy) |
---|
15963 | 16144 | if (!(object instanceof Composite)) |
---|
15964 | 16145 | object.draw(info, 0, false); // SLOW : |
---|
15965 | 16146 | */ |
---|
15966 | | - if (!isRenderer) |
---|
| 16147 | + if (!isRenderer) // && drag) |
---|
15967 | 16148 | { |
---|
15968 | 16149 | Grafreed.Assert(object != null); |
---|
15969 | 16150 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15971 | 16152 | { |
---|
15972 | 16153 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15973 | 16154 | |
---|
15974 | | - info.DX = 0; |
---|
15975 | | - info.DY = 0; |
---|
15976 | | - info.W = 1; |
---|
| 16155 | + object.clickInfo.DX = 0; |
---|
| 16156 | + object.clickInfo.DY = 0; |
---|
| 16157 | + object.clickInfo.W = 1; |
---|
15977 | 16158 | if (hitSomething == Object3D.hitCenter) |
---|
15978 | 16159 | { |
---|
15979 | 16160 | info.DX = X; |
---|
.. | .. |
---|
15985 | 16166 | info.DY -= info.bounds.height/2; |
---|
15986 | 16167 | } |
---|
15987 | 16168 | |
---|
15988 | | - object.drawEditHandles(info, 0); |
---|
| 16169 | + object.drawEditHandles(//info, |
---|
| 16170 | + 0); |
---|
15989 | 16171 | |
---|
15990 | 16172 | if (drag && (X != 0 || Y != 0)) |
---|
15991 | 16173 | { |
---|
15992 | 16174 | switch (hitSomething) |
---|
15993 | 16175 | { |
---|
15994 | | - case Object3D.hitCenter: gr.setColor(Color.pink); |
---|
| 16176 | + case Object3D.hitCenter: gr.setColor(Color.white); |
---|
15995 | 16177 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15996 | 16178 | break; |
---|
15997 | 16179 | case Object3D.hitRotate: gr.setColor(Color.yellow); |
---|
.. | .. |
---|
16017 | 16199 | if (hasMarquee) |
---|
16018 | 16200 | { |
---|
16019 | 16201 | gr.setXORMode(Color.white); |
---|
16020 | | - gr.setColor(Color.red); |
---|
| 16202 | + gr.setColor(Color.white); |
---|
16021 | 16203 | if (!firstime) |
---|
16022 | 16204 | { |
---|
16023 | 16205 | gr.drawRect(prevmarqX, prevmarqY, prevmarqW, prevmarqH); |
---|
.. | .. |
---|
16484 | 16666 | private /*static*/ boolean firstime; |
---|
16485 | 16667 | private /*static*/ cVector newView = new cVector(); |
---|
16486 | 16668 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16669 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16670 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16487 | 16671 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16488 | 16672 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16489 | 16673 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16496 | 16680 | { |
---|
16497 | 16681 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16498 | 16682 | |
---|
| 16683 | + int usedsuf = 0; |
---|
| 16684 | + |
---|
16499 | 16685 | for (int i = 0; i < suffixes.length; i++) |
---|
16500 | 16686 | { |
---|
16501 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16502 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16503 | | - mipmapped, |
---|
16504 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16505 | | - if (data == null) |
---|
| 16687 | + String[] suffixe = suffixes; |
---|
| 16688 | + String[] fallback = suffixes2; |
---|
| 16689 | + String[] fallfallback = suffixes3; |
---|
| 16690 | + |
---|
| 16691 | + for (int c=usedsuf; --c>=0;) |
---|
16506 | 16692 | { |
---|
16507 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16693 | +// String[] temp = suffixe; |
---|
| 16694 | +// suffixe = fallback; |
---|
| 16695 | +// fallback = fallfallback; |
---|
| 16696 | +// fallfallback = temp; |
---|
16508 | 16697 | } |
---|
| 16698 | + |
---|
| 16699 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16700 | + TextureData data; |
---|
| 16701 | + |
---|
| 16702 | + try |
---|
| 16703 | + { |
---|
| 16704 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16705 | + mipmapped, |
---|
| 16706 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16707 | + } |
---|
| 16708 | + catch (Exception e) |
---|
| 16709 | + { |
---|
| 16710 | + try |
---|
| 16711 | + { |
---|
| 16712 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16713 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16714 | + mipmapped, |
---|
| 16715 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16716 | + } |
---|
| 16717 | + catch (Exception e2) |
---|
| 16718 | + { |
---|
| 16719 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16720 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16721 | + mipmapped, |
---|
| 16722 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16723 | + } |
---|
| 16724 | + } |
---|
| 16725 | + |
---|
16509 | 16726 | //System.out.println("Target = " + targets[i]); |
---|
16510 | 16727 | cubemap.updateImage(data, targets[i]); |
---|
16511 | 16728 | } |
---|
16512 | 16729 | |
---|
16513 | 16730 | return cubemap; |
---|
16514 | 16731 | } |
---|
| 16732 | + |
---|
16515 | 16733 | int bigsphere = -1; |
---|
16516 | 16734 | |
---|
16517 | 16735 | float BGcolor = 0.5f; |
---|
16518 | 16736 | |
---|
16519 | | - private void DrawSkyBox(GL gl) |
---|
| 16737 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16738 | + |
---|
| 16739 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16520 | 16740 | { |
---|
16521 | | - if (envyoff || cubemap == null) |
---|
| 16741 | + if (//envyoff || |
---|
| 16742 | + WIREFRAME || |
---|
| 16743 | + cubemap == null) |
---|
16522 | 16744 | { |
---|
16523 | 16745 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16524 | 16746 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16533 | 16755 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16534 | 16756 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16535 | 16757 | gl.glLoadIdentity(); |
---|
| 16758 | + gl.glScalef(1,ratio,1); |
---|
16536 | 16759 | |
---|
| 16760 | +// colorV[0] = 2; |
---|
| 16761 | +// colorV[1] = 2; |
---|
| 16762 | +// colorV[2] = 2; |
---|
| 16763 | +// colorV[3] = 1; |
---|
| 16764 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16765 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16766 | +// |
---|
| 16767 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16768 | + |
---|
16537 | 16769 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16538 | 16770 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16539 | 16771 | |
---|
.. | .. |
---|
16565 | 16797 | { |
---|
16566 | 16798 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16567 | 16799 | } |
---|
| 16800 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16568 | 16801 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16569 | 16802 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16570 | 16803 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16605 | 16838 | gl.glDisable(GL.GL_TEXTURE_GEN_R); |
---|
16606 | 16839 | |
---|
16607 | 16840 | cubemap.disable(); |
---|
16608 | | - ////cubemap.unbind(); |
---|
| 16841 | + //cubemap.dispose(); |
---|
| 16842 | + |
---|
16609 | 16843 | if (CULLFACE) |
---|
16610 | 16844 | { |
---|
16611 | 16845 | gl.glEnable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
16823 | 17057 | //new Exception().printStackTrace(); |
---|
16824 | 17058 | System.out.println("select buffer init"); |
---|
16825 | 17059 | // Use debug pipeline |
---|
16826 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17060 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16827 | 17061 | |
---|
16828 | 17062 | GL gl = drawable.getGL(); |
---|
16829 | 17063 | |
---|
.. | .. |
---|
17141 | 17375 | |
---|
17142 | 17376 | public void init(GLAutoDrawable drawable) |
---|
17143 | 17377 | { |
---|
| 17378 | + if (Globals.DEBUG) |
---|
17144 | 17379 | System.out.println("shadow buffer init"); |
---|
17145 | 17380 | |
---|
17146 | 17381 | GL gl = drawable.getGL(); |
---|
.. | .. |
---|
17369 | 17604 | gl.glFlush(); |
---|
17370 | 17605 | |
---|
17371 | 17606 | /**/ |
---|
17372 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17607 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17373 | 17608 | |
---|
17374 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17609 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17375 | 17610 | |
---|
| 17611 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17612 | + |
---|
| 17613 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17614 | + |
---|
17376 | 17615 | double r = 0, g = 0, b = 0; |
---|
17377 | 17616 | |
---|
17378 | 17617 | double count = 0; |
---|
.. | .. |
---|
17383 | 17622 | |
---|
17384 | 17623 | double FACTOR = 1; |
---|
17385 | 17624 | |
---|
17386 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17625 | + for (int i = 0; i < depths.length; i++) |
---|
17387 | 17626 | { |
---|
17388 | 17627 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17389 | 17628 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17466 | 17705 | |
---|
17467 | 17706 | double scale = ray.z; // 1; // cos |
---|
17468 | 17707 | |
---|
17469 | | - float depth = pixels[newindex]; |
---|
| 17708 | + float depth = depths[newindex]; |
---|
17470 | 17709 | |
---|
17471 | 17710 | /* |
---|
17472 | 17711 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17663 | 17902 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17664 | 17903 | static IntBuffer bigAAbuffer; |
---|
17665 | 17904 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17666 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17905 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17667 | 17906 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17668 | 17907 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17669 | 17908 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17670 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17909 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17910 | + |
---|
| 17911 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17912 | + |
---|
17671 | 17913 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17672 | 17914 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17673 | 17915 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|