.. | .. |
---|
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; |
---|
114 | 116 | boolean reverseUP = false; |
---|
115 | 117 | static boolean frozen = false; |
---|
116 | 118 | boolean enablebackspace = false; // patch for back buffer refresh |
---|
.. | .. |
---|
173 | 175 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 176 | boolean anisotropy = true; |
---|
175 | 177 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 178 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 179 | |
---|
178 | 180 | boolean macromode = false; |
---|
179 | 181 | |
---|
.. | .. |
---|
187 | 189 | } |
---|
188 | 190 | |
---|
189 | 191 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 192 | + |
---|
| 193 | + public com.sun.opengl.util.texture.Texture LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 194 | + { |
---|
| 195 | + try |
---|
| 196 | + { |
---|
| 197 | + return LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 198 | + } catch (IOException e) |
---|
| 199 | + { |
---|
| 200 | + System.out.println("NAME = " + name); |
---|
| 201 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 202 | + return null; |
---|
| 203 | + } |
---|
| 204 | + } |
---|
190 | 205 | |
---|
191 | 206 | void SetAsGLRenderer(boolean b) |
---|
192 | 207 | { |
---|
.. | .. |
---|
206 | 221 | |
---|
207 | 222 | SetCamera(cam); |
---|
208 | 223 | |
---|
209 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 224 | + // Warning: not used. |
---|
| 225 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
210 | 226 | |
---|
211 | 227 | object = o; |
---|
212 | 228 | |
---|
.. | .. |
---|
1484 | 1500 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1485 | 1501 | } |
---|
1486 | 1502 | |
---|
| 1503 | + float[] colorV = new float[4]; |
---|
| 1504 | + |
---|
1487 | 1505 | void SetColor(Object3D obj, Vertex p0) |
---|
1488 | 1506 | { |
---|
1489 | 1507 | CameraPane display = this; |
---|
.. | .. |
---|
1551 | 1569 | { |
---|
1552 | 1570 | return; |
---|
1553 | 1571 | } |
---|
1554 | | - |
---|
1555 | | - float[] colorV = new float[3]; |
---|
1556 | 1572 | |
---|
1557 | 1573 | if (false) // marked) |
---|
1558 | 1574 | { |
---|
.. | .. |
---|
8345 | 8361 | // else |
---|
8346 | 8362 | // if (!texname.startsWith("/")) |
---|
8347 | 8363 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8348 | | - if (!FileExists(texname)) |
---|
| 8364 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8349 | 8365 | { |
---|
8350 | 8366 | texname = fallbackTextureName; |
---|
8351 | 8367 | } |
---|
.. | .. |
---|
8428 | 8444 | new Exception().printStackTrace(); |
---|
8429 | 8445 | } else |
---|
8430 | 8446 | { |
---|
| 8447 | + if (texname.startsWith("@")) |
---|
| 8448 | + { |
---|
| 8449 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8450 | + if (texturecache == null) |
---|
| 8451 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8452 | + else |
---|
| 8453 | + new Exception().printStackTrace(); |
---|
| 8454 | + } else |
---|
| 8455 | + { |
---|
8431 | 8456 | if (textureon) |
---|
8432 | 8457 | { |
---|
8433 | 8458 | String cachename = texname; |
---|
.. | .. |
---|
8487 | 8512 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8488 | 8513 | //texture = GetTexture(tex, bump); |
---|
8489 | 8514 | } |
---|
| 8515 | + } |
---|
8490 | 8516 | } |
---|
8491 | 8517 | //} |
---|
8492 | 8518 | } |
---|
.. | .. |
---|
8755 | 8781 | |
---|
8756 | 8782 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8757 | 8783 | MAXSTACK = temp[0]; |
---|
8758 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8784 | + if (Globals.DEBUG) |
---|
| 8785 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8759 | 8786 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8760 | 8787 | MAXSTACK = temp[0]; |
---|
8761 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8788 | + if (Globals.DEBUG) |
---|
| 8789 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8762 | 8790 | |
---|
8763 | 8791 | // Use debug pipeline |
---|
8764 | 8792 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8766 | 8794 | gl = drawable.getGL(); // |
---|
8767 | 8795 | |
---|
8768 | 8796 | GL gl3 = getGL(); |
---|
8769 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8797 | + if (Globals.DEBUG) |
---|
| 8798 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8770 | 8799 | |
---|
8771 | 8800 | |
---|
8772 | 8801 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8931 | 8960 | |
---|
8932 | 8961 | if (cubemap == null) |
---|
8933 | 8962 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8963 | + //LoadEnvy(1); |
---|
8935 | 8964 | } |
---|
8936 | 8965 | |
---|
8937 | 8966 | //cubemap.enable(); |
---|
.. | .. |
---|
9207 | 9236 | |
---|
9208 | 9237 | void LoadEnvy(int which) |
---|
9209 | 9238 | { |
---|
| 9239 | + assert(false); |
---|
| 9240 | + |
---|
9210 | 9241 | String name; |
---|
9211 | 9242 | String ext; |
---|
9212 | 9243 | |
---|
.. | .. |
---|
9218 | 9249 | cubemap = null; |
---|
9219 | 9250 | return; |
---|
9220 | 9251 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9252 | + name = "cubemaps/rgb/"; |
---|
| 9253 | + ext = "jpg"; |
---|
9223 | 9254 | reverseUP = false; |
---|
9224 | 9255 | break; |
---|
9225 | 9256 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9257 | + name = "cubemaps/uffizi/"; |
---|
| 9258 | + ext = "jpg"; |
---|
| 9259 | + reverseUP = false; |
---|
| 9260 | + break; |
---|
9229 | 9261 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9262 | + name = "cubemaps/CloudyHills/"; |
---|
| 9263 | + ext = "jpg"; |
---|
9232 | 9264 | reverseUP = false; |
---|
9233 | 9265 | break; |
---|
9234 | 9266 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9267 | + name = "cubemaps/cornell/"; |
---|
9236 | 9268 | ext = "png"; |
---|
9237 | 9269 | reverseUP = false; |
---|
9238 | 9270 | break; |
---|
| 9271 | + case 5: |
---|
| 9272 | + name = "cubemaps/skycube/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
| 9276 | + case 6: |
---|
| 9277 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9278 | + ext = "jpg"; |
---|
| 9279 | + reverseUP = false; |
---|
| 9280 | + break; |
---|
| 9281 | + case 7: |
---|
| 9282 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9283 | + ext = "jpg"; |
---|
| 9284 | + reverseUP = false; |
---|
| 9285 | + break; |
---|
| 9286 | + case 8: |
---|
| 9287 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
| 9291 | + case 9: |
---|
| 9292 | + name = "cubemaps/UnionSquare/"; |
---|
| 9293 | + ext = "jpg"; |
---|
| 9294 | + reverseUP = false; |
---|
| 9295 | + break; |
---|
9239 | 9296 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9297 | + name = "cubemaps/box/"; |
---|
| 9298 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9299 | + reverseUP = false; |
---|
9242 | 9300 | break; |
---|
9243 | 9301 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9302 | + |
---|
| 9303 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9304 | } |
---|
9253 | 9305 | |
---|
9254 | 9306 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9332 | static double[] model = new double[16]; |
---|
9281 | 9333 | double[] camera2light = new double[16]; |
---|
9282 | 9334 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9335 | + |
---|
| 9336 | + //int newenvy = -1; |
---|
| 9337 | + //boolean envyoff = false; |
---|
| 9338 | + |
---|
| 9339 | + String loadedskyboxname; |
---|
| 9340 | + |
---|
9285 | 9341 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9342 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9343 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9699 | 9755 | |
---|
9700 | 9756 | if (renderCamera != lightCamera) |
---|
9701 | 9757 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9758 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9759 | |
---|
9704 | 9760 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9761 | |
---|
.. | .. |
---|
9715 | 9771 | |
---|
9716 | 9772 | if (renderCamera != lightCamera) |
---|
9717 | 9773 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9774 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9775 | |
---|
9720 | 9776 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9777 | |
---|
.. | .. |
---|
9761 | 9817 | rati = 1 / rati; |
---|
9762 | 9818 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9819 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9820 | + |
---|
| 9821 | + //assert (newenvy == -1); |
---|
| 9822 | + |
---|
9765 | 9823 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9824 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9825 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9826 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9827 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9828 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10801 | 10859 | |
---|
10802 | 10860 | if (wait) |
---|
10803 | 10861 | { |
---|
10804 | | - Sleep(500); |
---|
| 10862 | + Sleep(200); // blocks everything |
---|
10805 | 10863 | |
---|
10806 | 10864 | wait = false; |
---|
10807 | 10865 | } |
---|
.. | .. |
---|
10916 | 10974 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10975 | if (cam != lightCamera) |
---|
10918 | 10976 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10977 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10978 | |
---|
10921 | 10979 | for (int j = 0; j < 4; j++) |
---|
10922 | 10980 | { |
---|
.. | .. |
---|
10931 | 10989 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 10990 | if (cam != lightCamera) |
---|
10933 | 10991 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10992 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 10993 | |
---|
10936 | 10994 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 10995 | |
---|
.. | .. |
---|
11017 | 11075 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11076 | } |
---|
11019 | 11077 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11078 | +// if (newenvy > -1) |
---|
| 11079 | +// { |
---|
| 11080 | +// LoadEnvy(newenvy); |
---|
| 11081 | +// } |
---|
| 11082 | +// |
---|
| 11083 | +// newenvy = -1; |
---|
| 11084 | + |
---|
| 11085 | + if (object.skyboxname != null && object.skyboxname.equals("cubemaps/default-skyboxes/rgb")) |
---|
11021 | 11086 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11087 | + if (cubemaprgb == null) |
---|
| 11088 | + { |
---|
| 11089 | + cubemaprgb = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11090 | + } |
---|
| 11091 | + |
---|
| 11092 | + cubemap = cubemaprgb; |
---|
11023 | 11093 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11094 | + else |
---|
| 11095 | + { |
---|
| 11096 | + if (object.skyboxname != null) |
---|
| 11097 | + { |
---|
| 11098 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11099 | + { |
---|
| 11100 | + cubemapcustom = LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11101 | + loadedskyboxname = object.skyboxname; |
---|
| 11102 | + } |
---|
| 11103 | + } |
---|
| 11104 | + else |
---|
| 11105 | + { |
---|
| 11106 | + cubemapcustom = null; |
---|
| 11107 | + loadedskyboxname = null; |
---|
| 11108 | + } |
---|
| 11109 | + |
---|
| 11110 | + cubemap = cubemapcustom; |
---|
| 11111 | + } |
---|
| 11112 | + |
---|
11027 | 11113 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11114 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11115 | |
---|
.. | .. |
---|
11039 | 11125 | |
---|
11040 | 11126 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11127 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11128 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11129 | } |
---|
11044 | 11130 | |
---|
11045 | 11131 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11411 | |
---|
11326 | 11412 | // if (cam != lightCamera) |
---|
11327 | 11413 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11414 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11415 | } |
---|
11330 | 11416 | |
---|
11331 | 11417 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12485 | |
---|
12400 | 12486 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12487 | |
---|
12402 | | - String program = |
---|
| 12488 | + String programmin = |
---|
| 12489 | + // Min shader |
---|
12403 | 12490 | "!!ARBfp1.0\n" + |
---|
| 12491 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12492 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12493 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12494 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12495 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12496 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12497 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12498 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12499 | + "TEMP temp;" + |
---|
| 12500 | + "TEMP light;" + |
---|
| 12501 | + "TEMP ndotl;" + |
---|
| 12502 | + "TEMP normal;" + |
---|
| 12503 | + "TEMP depth;" + |
---|
| 12504 | + "TEMP eye;" + |
---|
| 12505 | + "TEMP pos;" + |
---|
| 12506 | + |
---|
| 12507 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12508 | + Normalize("normal") + |
---|
| 12509 | + "MOV light, state.light[0].position;" + |
---|
| 12510 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12511 | + |
---|
| 12512 | + // shadow |
---|
| 12513 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12514 | + "MOV temp, pos;" + |
---|
| 12515 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12516 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12517 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12518 | + |
---|
| 12519 | + // No shadow when out of frustum |
---|
| 12520 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12521 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12522 | + |
---|
| 12523 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12524 | + |
---|
| 12525 | + // Backlit |
---|
| 12526 | + "MOV pos.w, zero123.y;" + |
---|
| 12527 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12528 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12529 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12530 | + Normalize("eye") + |
---|
| 12531 | + |
---|
| 12532 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12533 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12534 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12535 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12536 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12537 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12538 | + |
---|
| 12539 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12540 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12541 | + |
---|
| 12542 | + // Pigment |
---|
| 12543 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12544 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12545 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12546 | + |
---|
| 12547 | + "MUL temp, temp, zero123.z;" + |
---|
| 12548 | + |
---|
| 12549 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12550 | + |
---|
| 12551 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12552 | + "MOV result.color, temp;" + |
---|
| 12553 | + "END"; |
---|
| 12554 | + |
---|
| 12555 | + String programmax = |
---|
| 12556 | + "!!ARBfp1.0\n" + |
---|
| 12557 | + |
---|
12404 | 12558 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12559 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12560 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12669 | "TEMP shininess;" + |
---|
12516 | 12670 | "\n" + |
---|
12517 | 12671 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12672 | + |
---|
12520 | 12673 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12674 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12675 | /* |
---|
.. | .. |
---|
12537 | 12690 | "MUL temp, floor, mapgrid.x;" + |
---|
12538 | 12691 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12539 | 12692 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12540 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12693 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12541 | 12694 | "") + |
---|
12542 | 12695 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12543 | 12696 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12544 | 12697 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12545 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12698 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12546 | 12699 | "") + |
---|
12547 | 12700 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12548 | 12701 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12549 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12550 | 12703 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12551 | 12704 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12552 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12553 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12554 | 12707 | "") + |
---|
12555 | 12708 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12556 | 12709 | //"MOV params, material;" + |
---|
.. | .. |
---|
12921 | 13074 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 13075 | "") + |
---|
12923 | 13076 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 13077 | + // display shadow only (fakedepth == 0) |
---|
12925 | 13078 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 13079 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13080 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12928 | 13081 | "SUB temp.y, one.x, temp.z;" + |
---|
12929 | 13082 | "MUL temp.x, temp.x, temp.y;" + |
---|
12930 | 13083 | "KIL temp.x;" + |
---|
.. | .. |
---|
13255 | 13408 | //once = true; |
---|
13256 | 13409 | } |
---|
13257 | 13410 | |
---|
| 13411 | + String program = programmax; |
---|
| 13412 | + |
---|
| 13413 | + if (Globals.MINSHADER) |
---|
| 13414 | + { |
---|
| 13415 | + program = programmin; |
---|
| 13416 | + } |
---|
| 13417 | + |
---|
13258 | 13418 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13259 | 13419 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13260 | 13420 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13348 | 13508 | return out; |
---|
13349 | 13509 | } |
---|
13350 | 13510 | |
---|
13351 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13511 | + // Also does frustum culling |
---|
| 13512 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13352 | 13513 | { |
---|
13353 | 13514 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13515 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13516 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13517 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13518 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13519 | "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;" + |
---|
| 13520 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13521 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13522 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13523 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13524 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13525 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13526 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13527 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13528 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13529 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13530 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13531 | } |
---|
13371 | 13532 | |
---|
13372 | 13533 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13574 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13575 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13576 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13577 | + // No shadow when out of frustum |
---|
13417 | 13578 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13579 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13580 | ""; |
---|
.. | .. |
---|
14211 | 14372 | drag = false; |
---|
14212 | 14373 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14374 | 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); |
---|
| 14375 | + //ClickInfo info = new ClickInfo(); |
---|
| 14376 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14377 | + object.clickInfo.pane = this; |
---|
| 14378 | + object.clickInfo.camera = renderCamera; |
---|
| 14379 | + object.clickInfo.x = x; |
---|
| 14380 | + object.clickInfo.y = y; |
---|
| 14381 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14382 | + editObj = object.doEditClick(//info, |
---|
| 14383 | + 0); |
---|
14222 | 14384 | if (!editObj) |
---|
14223 | 14385 | { |
---|
14224 | 14386 | hasMarquee = true; |
---|
.. | .. |
---|
14502 | 14664 | MODIFIERS |= COMMAND; |
---|
14503 | 14665 | /**/ |
---|
14504 | 14666 | if((mod&SHIFT) == SHIFT) |
---|
14505 | | - manipCamera.RotatePosition(0, -speed); |
---|
14506 | | - else |
---|
14507 | 14667 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14668 | + else |
---|
| 14669 | + manipCamera.RotatePosition(0, -speed); |
---|
14508 | 14670 | /**/ |
---|
14509 | 14671 | if ((mod & SHIFT) == SHIFT) |
---|
14510 | 14672 | { |
---|
.. | .. |
---|
14523 | 14685 | MODIFIERS |= COMMAND; |
---|
14524 | 14686 | /**/ |
---|
14525 | 14687 | if((mod&SHIFT) == SHIFT) |
---|
14526 | | - manipCamera.RotatePosition(0, speed); |
---|
14527 | | - else |
---|
14528 | 14688 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, speed); |
---|
14529 | 14691 | /**/ |
---|
14530 | 14692 | if ((mod & SHIFT) == SHIFT) |
---|
14531 | 14693 | { |
---|
.. | .. |
---|
14618 | 14780 | if (editObj) |
---|
14619 | 14781 | { |
---|
14620 | 14782 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14783 | + //ClickInfo info = new ClickInfo(); |
---|
| 14784 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14785 | (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); |
---|
| 14786 | + object.clickInfo.pane = this; |
---|
| 14787 | + object.clickInfo.camera = renderCamera; |
---|
| 14788 | + object.clickInfo.x = x; |
---|
| 14789 | + object.clickInfo.y = y; |
---|
| 14790 | + object //.GetWindow().copy |
---|
| 14791 | + .doEditDrag(//info, |
---|
| 14792 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14793 | } else |
---|
14631 | 14794 | { |
---|
14632 | 14795 | if (x < startX) |
---|
.. | .. |
---|
14775 | 14938 | } |
---|
14776 | 14939 | } |
---|
14777 | 14940 | |
---|
| 14941 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14942 | + |
---|
14778 | 14943 | public void mouseMoved(MouseEvent e) |
---|
14779 | 14944 | { |
---|
14780 | 14945 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 14946 | if (isRenderer) |
---|
14782 | 14947 | return; |
---|
14783 | 14948 | |
---|
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; |
---|
| 14949 | + // Mouse cursor feedback |
---|
| 14950 | + object.clickInfo.x = e.getX(); |
---|
| 14951 | + object.clickInfo.y = e.getY(); |
---|
| 14952 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14953 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14954 | + object.clickInfo.pane = this; |
---|
| 14955 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 14956 | if (!isRenderer) |
---|
14792 | 14957 | { |
---|
14793 | 14958 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 14959 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 14960 | + if (object.doEditClick(//clickInfo, |
---|
| 14961 | + 0)) |
---|
14796 | 14962 | { |
---|
14797 | 14963 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 14964 | } else |
---|
.. | .. |
---|
15242 | 15408 | OCCLUSION_CULLING ^= true; |
---|
15243 | 15409 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15244 | 15410 | break; |
---|
15245 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15411 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15246 | 15412 | case '1': |
---|
15247 | 15413 | case '2': |
---|
15248 | 15414 | case '3': |
---|
15249 | 15415 | case '4': |
---|
15250 | 15416 | case '5': |
---|
15251 | | - newenvy = Character.getNumericValue(key); |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | 15417 | case '6': |
---|
15255 | 15418 | case '7': |
---|
15256 | 15419 | case '8': |
---|
15257 | 15420 | case '9': |
---|
15258 | | - BGcolor = (key - '6')/3.f; |
---|
| 15421 | + if (true) // envyoff) |
---|
| 15422 | + { |
---|
| 15423 | + BGcolor = (key - '1')/8.f; |
---|
| 15424 | + } |
---|
| 15425 | + else |
---|
| 15426 | + { |
---|
| 15427 | + //newenvy = Character.getNumericValue(key); |
---|
| 15428 | + } |
---|
15259 | 15429 | repaint(); |
---|
15260 | 15430 | break; |
---|
15261 | 15431 | case '!': |
---|
.. | .. |
---|
15818 | 15988 | |
---|
15819 | 15989 | int width = getBounds().width; |
---|
15820 | 15990 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 15991 | //Image img = CreateImage(width, height); |
---|
15824 | 15992 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 15993 | |
---|
.. | .. |
---|
15896 | 16064 | } |
---|
15897 | 16065 | if (object != null && !hasMarquee) |
---|
15898 | 16066 | { |
---|
| 16067 | + if (object.clickInfo == null) |
---|
| 16068 | + object.clickInfo = new ClickInfo(); |
---|
| 16069 | + ClickInfo info = object.clickInfo; |
---|
| 16070 | + //ClickInfo info = new ClickInfo(); |
---|
| 16071 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16072 | + |
---|
15899 | 16073 | if (isRenderer) |
---|
15900 | 16074 | { |
---|
15901 | | - info.flags++; |
---|
| 16075 | + object.clickInfo.flags++; |
---|
15902 | 16076 | double frameAspect = (double) width / (double) height; |
---|
15903 | 16077 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 16078 | { |
---|
15905 | 16079 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16080 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16081 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 16082 | } else |
---|
15909 | 16083 | { |
---|
15910 | 16084 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16085 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16086 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 16087 | } |
---|
15914 | 16088 | } |
---|
15915 | 16089 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 16090 | + object.clickInfo.g = gr; |
---|
| 16091 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 16092 | /* |
---|
15919 | 16093 | // Memory intensive (brep.verticescopy) |
---|
15920 | 16094 | if (!(object instanceof Composite)) |
---|
15921 | 16095 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 16096 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 16097 | + if (!isRenderer) // && drag) |
---|
15924 | 16098 | { |
---|
15925 | 16099 | Grafreed.Assert(object != null); |
---|
15926 | 16100 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 16102 | { |
---|
15929 | 16103 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 16104 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 16105 | + object.clickInfo.DX = 0; |
---|
| 16106 | + object.clickInfo.DY = 0; |
---|
| 16107 | + object.clickInfo.W = 1; |
---|
15934 | 16108 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 16109 | { |
---|
15936 | 16110 | info.DX = X; |
---|
.. | .. |
---|
15942 | 16116 | info.DY -= info.bounds.height/2; |
---|
15943 | 16117 | } |
---|
15944 | 16118 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 16119 | + object.drawEditHandles(//info, |
---|
| 16120 | + 0); |
---|
15946 | 16121 | |
---|
15947 | 16122 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16123 | { |
---|
.. | .. |
---|
16441 | 16616 | private /*static*/ boolean firstime; |
---|
16442 | 16617 | private /*static*/ cVector newView = new cVector(); |
---|
16443 | 16618 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16619 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16620 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16444 | 16621 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16445 | 16622 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16446 | 16623 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16453 | 16630 | { |
---|
16454 | 16631 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16455 | 16632 | |
---|
| 16633 | + int usedsuf = 0; |
---|
| 16634 | + |
---|
16456 | 16635 | for (int i = 0; i < suffixes.length; i++) |
---|
16457 | 16636 | { |
---|
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) |
---|
| 16637 | + String[] suffixe = suffixes; |
---|
| 16638 | + String[] fallback = suffixes2; |
---|
| 16639 | + String[] fallfallback = suffixes3; |
---|
| 16640 | + |
---|
| 16641 | + for (int c=usedsuf; --c>=0;) |
---|
16463 | 16642 | { |
---|
16464 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16643 | +// String[] temp = suffixe; |
---|
| 16644 | +// suffixe = fallback; |
---|
| 16645 | +// fallback = fallfallback; |
---|
| 16646 | +// fallfallback = temp; |
---|
16465 | 16647 | } |
---|
| 16648 | + |
---|
| 16649 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16650 | + TextureData data; |
---|
| 16651 | + |
---|
| 16652 | + try |
---|
| 16653 | + { |
---|
| 16654 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16655 | + mipmapped, |
---|
| 16656 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16657 | + } |
---|
| 16658 | + catch (Exception e) |
---|
| 16659 | + { |
---|
| 16660 | + try |
---|
| 16661 | + { |
---|
| 16662 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16663 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16664 | + mipmapped, |
---|
| 16665 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16666 | + } |
---|
| 16667 | + catch (Exception e2) |
---|
| 16668 | + { |
---|
| 16669 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16670 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16671 | + mipmapped, |
---|
| 16672 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16673 | + } |
---|
| 16674 | + } |
---|
| 16675 | + |
---|
16466 | 16676 | //System.out.println("Target = " + targets[i]); |
---|
16467 | 16677 | cubemap.updateImage(data, targets[i]); |
---|
16468 | 16678 | } |
---|
16469 | 16679 | |
---|
16470 | 16680 | return cubemap; |
---|
16471 | 16681 | } |
---|
| 16682 | + |
---|
16472 | 16683 | int bigsphere = -1; |
---|
16473 | 16684 | |
---|
16474 | 16685 | float BGcolor = 0.5f; |
---|
16475 | 16686 | |
---|
16476 | | - private void DrawSkyBox(GL gl) |
---|
| 16687 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16688 | + |
---|
| 16689 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16477 | 16690 | { |
---|
16478 | | - if (envyoff || cubemap == null) |
---|
| 16691 | + if (//envyoff || |
---|
| 16692 | + WIREFRAME || |
---|
| 16693 | + cubemap == null) |
---|
16479 | 16694 | { |
---|
16480 | 16695 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16481 | 16696 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16490 | 16705 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16491 | 16706 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16492 | 16707 | gl.glLoadIdentity(); |
---|
| 16708 | + gl.glScalef(1,ratio,1); |
---|
16493 | 16709 | |
---|
| 16710 | +// colorV[0] = 2; |
---|
| 16711 | +// colorV[1] = 2; |
---|
| 16712 | +// colorV[2] = 2; |
---|
| 16713 | +// colorV[3] = 1; |
---|
| 16714 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16715 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16716 | +// |
---|
| 16717 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16718 | + |
---|
16494 | 16719 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16495 | 16720 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16496 | 16721 | |
---|
.. | .. |
---|
16522 | 16747 | { |
---|
16523 | 16748 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16524 | 16749 | } |
---|
| 16750 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16525 | 16751 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16526 | 16752 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16527 | 16753 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16780 | 17006 | //new Exception().printStackTrace(); |
---|
16781 | 17007 | System.out.println("select buffer init"); |
---|
16782 | 17008 | // Use debug pipeline |
---|
16783 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17009 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16784 | 17010 | |
---|
16785 | 17011 | GL gl = drawable.getGL(); |
---|
16786 | 17012 | |
---|
.. | .. |
---|
17326 | 17552 | gl.glFlush(); |
---|
17327 | 17553 | |
---|
17328 | 17554 | /**/ |
---|
17329 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17555 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17330 | 17556 | |
---|
17331 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17557 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17332 | 17558 | |
---|
| 17559 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17560 | + |
---|
| 17561 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17562 | + |
---|
17333 | 17563 | double r = 0, g = 0, b = 0; |
---|
17334 | 17564 | |
---|
17335 | 17565 | double count = 0; |
---|
.. | .. |
---|
17340 | 17570 | |
---|
17341 | 17571 | double FACTOR = 1; |
---|
17342 | 17572 | |
---|
17343 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17573 | + for (int i = 0; i < depths.length; i++) |
---|
17344 | 17574 | { |
---|
17345 | 17575 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17346 | 17576 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17423 | 17653 | |
---|
17424 | 17654 | double scale = ray.z; // 1; // cos |
---|
17425 | 17655 | |
---|
17426 | | - float depth = pixels[newindex]; |
---|
| 17656 | + float depth = depths[newindex]; |
---|
17427 | 17657 | |
---|
17428 | 17658 | /* |
---|
17429 | 17659 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17620 | 17850 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17621 | 17851 | static IntBuffer bigAAbuffer; |
---|
17622 | 17852 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17623 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17853 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17624 | 17854 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17625 | 17855 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17626 | 17856 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17627 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17857 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17858 | + |
---|
| 17859 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17860 | + |
---|
17628 | 17861 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17629 | 17862 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17630 | 17863 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|