.. | .. |
---|
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 = |
---|
12403 | 12489 | // Min shader |
---|
12404 | 12490 | "!!ARBfp1.0\n" + |
---|
12405 | | - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12491 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12406 | 12492 | "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
12407 | 12493 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12408 | 12494 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12409 | 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];" + |
---|
12410 | 12499 | "TEMP temp;" + |
---|
12411 | 12500 | "TEMP light;" + |
---|
12412 | 12501 | "TEMP ndotl;" + |
---|
12413 | 12502 | "TEMP normal;" + |
---|
12414 | 12503 | "TEMP depth;" + |
---|
| 12504 | + "TEMP eye;" + |
---|
| 12505 | + "TEMP pos;" + |
---|
12415 | 12506 | |
---|
12416 | 12507 | "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
12417 | | - |
---|
| 12508 | + Normalize("normal") + |
---|
12418 | 12509 | "MOV light, state.light[0].position;" + |
---|
12419 | 12510 | "DP3 ndotl.x, light, normal;" + |
---|
12420 | 12511 | |
---|
12421 | 12512 | // shadow |
---|
12422 | | - "MOV temp, fragment.texcoord[1];" + |
---|
12423 | | - TextureFetch("depth", "temp", "1") + |
---|
| 12513 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12514 | + "MOV temp, pos;" + |
---|
| 12515 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
12424 | 12516 | //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
12425 | | - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
12426 | | - |
---|
| 12517 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
12427 | 12518 | |
---|
12428 | 12519 | // No shadow when out of frustum |
---|
12429 | 12520 | //"SGE temp.y, depth.z, zero123.y;" + |
---|
12430 | 12521 | //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
12431 | 12522 | |
---|
12432 | | - "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
12433 | | - "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12523 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12434 | 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 |
---|
12435 | 12543 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12436 | 12544 | "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12437 | 12545 | "MUL temp, temp, ndotl.x;" + |
---|
12438 | 12546 | |
---|
12439 | 12547 | "MUL temp, temp, zero123.z;" + |
---|
12440 | 12548 | |
---|
12441 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12549 | + //"MUL temp, temp, ndotl.y;" + |
---|
12442 | 12550 | |
---|
| 12551 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
12443 | 12552 | "MOV result.color, temp;" + |
---|
12444 | 12553 | "END"; |
---|
12445 | 12554 | |
---|
12446 | | - String program2 = |
---|
| 12555 | + String programmax = |
---|
12447 | 12556 | "!!ARBfp1.0\n" + |
---|
12448 | 12557 | |
---|
12449 | 12558 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12581 | 12690 | "MUL temp, floor, mapgrid.x;" + |
---|
12582 | 12691 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12583 | 12692 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12584 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12693 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12585 | 12694 | "") + |
---|
12586 | 12695 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12587 | 12696 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12588 | 12697 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12589 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12698 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12590 | 12699 | "") + |
---|
12591 | 12700 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12592 | 12701 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12593 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12702 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12594 | 12703 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12595 | 12704 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12596 | 12705 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12597 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12706 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12598 | 12707 | "") + |
---|
12599 | 12708 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12600 | 12709 | //"MOV params, material;" + |
---|
.. | .. |
---|
12968 | 13077 | // display shadow only (fakedepth == 0) |
---|
12969 | 13078 | "SUB temp.x, half.x, shadow.x;" + |
---|
12970 | 13079 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12971 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13080 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12972 | 13081 | "SUB temp.y, one.x, temp.z;" + |
---|
12973 | 13082 | "MUL temp.x, temp.x, temp.y;" + |
---|
12974 | 13083 | "KIL temp.x;" + |
---|
.. | .. |
---|
13299 | 13408 | //once = true; |
---|
13300 | 13409 | } |
---|
13301 | 13410 | |
---|
| 13411 | + String program = programmax; |
---|
| 13412 | + |
---|
| 13413 | + if (Globals.MINSHADER) |
---|
| 13414 | + { |
---|
| 13415 | + program = programmin; |
---|
| 13416 | + } |
---|
| 13417 | + |
---|
13302 | 13418 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13303 | 13419 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13304 | 13420 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13392 | 13508 | return out; |
---|
13393 | 13509 | } |
---|
13394 | 13510 | |
---|
13395 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13511 | + // Also does frustum culling |
---|
| 13512 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13396 | 13513 | { |
---|
13397 | 13514 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13398 | 13515 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
.. | .. |
---|
14255 | 14372 | drag = false; |
---|
14256 | 14373 | //System.out.println("Mouse DOWN"); |
---|
14257 | 14374 | editObj = false; |
---|
14258 | | - ClickInfo info = new ClickInfo(); |
---|
14259 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14260 | | - info.pane = this; |
---|
14261 | | - info.camera = renderCamera; |
---|
14262 | | - info.x = x; |
---|
14263 | | - info.y = y; |
---|
14264 | | - info.modifiers = modifiersex; |
---|
14265 | | - 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); |
---|
14266 | 14384 | if (!editObj) |
---|
14267 | 14385 | { |
---|
14268 | 14386 | hasMarquee = true; |
---|
.. | .. |
---|
14546 | 14664 | MODIFIERS |= COMMAND; |
---|
14547 | 14665 | /**/ |
---|
14548 | 14666 | if((mod&SHIFT) == SHIFT) |
---|
14549 | | - manipCamera.RotatePosition(0, -speed); |
---|
14550 | | - else |
---|
14551 | 14667 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14668 | + else |
---|
| 14669 | + manipCamera.RotatePosition(0, -speed); |
---|
14552 | 14670 | /**/ |
---|
14553 | 14671 | if ((mod & SHIFT) == SHIFT) |
---|
14554 | 14672 | { |
---|
.. | .. |
---|
14567 | 14685 | MODIFIERS |= COMMAND; |
---|
14568 | 14686 | /**/ |
---|
14569 | 14687 | if((mod&SHIFT) == SHIFT) |
---|
14570 | | - manipCamera.RotatePosition(0, speed); |
---|
14571 | | - else |
---|
14572 | 14688 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14689 | + else |
---|
| 14690 | + manipCamera.RotatePosition(0, speed); |
---|
14573 | 14691 | /**/ |
---|
14574 | 14692 | if ((mod & SHIFT) == SHIFT) |
---|
14575 | 14693 | { |
---|
.. | .. |
---|
14662 | 14780 | if (editObj) |
---|
14663 | 14781 | { |
---|
14664 | 14782 | drag = true; |
---|
14665 | | - ClickInfo info = new ClickInfo(); |
---|
14666 | | - info.bounds.setBounds(0, 0, |
---|
| 14783 | + //ClickInfo info = new ClickInfo(); |
---|
| 14784 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14667 | 14785 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14668 | | - info.pane = this; |
---|
14669 | | - info.camera = renderCamera; |
---|
14670 | | - info.x = x; |
---|
14671 | | - info.y = y; |
---|
14672 | | - object.GetWindow().copy |
---|
14673 | | - .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); |
---|
14674 | 14793 | } else |
---|
14675 | 14794 | { |
---|
14676 | 14795 | if (x < startX) |
---|
.. | .. |
---|
14819 | 14938 | } |
---|
14820 | 14939 | } |
---|
14821 | 14940 | |
---|
| 14941 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14942 | + |
---|
14822 | 14943 | public void mouseMoved(MouseEvent e) |
---|
14823 | 14944 | { |
---|
14824 | 14945 | //System.out.println("mouseMoved: " + e); |
---|
14825 | 14946 | if (isRenderer) |
---|
14826 | 14947 | return; |
---|
14827 | 14948 | |
---|
14828 | | - ClickInfo ci = new ClickInfo(); |
---|
14829 | | - ci.x = e.getX(); |
---|
14830 | | - ci.y = e.getY(); |
---|
14831 | | - ci.modifiers = e.getModifiersEx(); |
---|
14832 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14833 | | - ci.pane = this; |
---|
14834 | | - 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; |
---|
14835 | 14956 | if (!isRenderer) |
---|
14836 | 14957 | { |
---|
14837 | 14958 | //ObjEditor editWindow = object.editWindow; |
---|
14838 | 14959 | //Object3D copy = editWindow.copy; |
---|
14839 | | - if (object.doEditClick(ci, 0)) |
---|
| 14960 | + if (object.doEditClick(//clickInfo, |
---|
| 14961 | + 0)) |
---|
14840 | 14962 | { |
---|
14841 | 14963 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14842 | 14964 | } else |
---|
.. | .. |
---|
15286 | 15408 | OCCLUSION_CULLING ^= true; |
---|
15287 | 15409 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15288 | 15410 | break; |
---|
15289 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15411 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15290 | 15412 | case '1': |
---|
15291 | 15413 | case '2': |
---|
15292 | 15414 | case '3': |
---|
15293 | 15415 | case '4': |
---|
15294 | 15416 | case '5': |
---|
15295 | | - newenvy = Character.getNumericValue(key); |
---|
15296 | | - repaint(); |
---|
15297 | | - break; |
---|
15298 | 15417 | case '6': |
---|
15299 | 15418 | case '7': |
---|
15300 | 15419 | case '8': |
---|
15301 | 15420 | case '9': |
---|
15302 | | - 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 | + } |
---|
15303 | 15429 | repaint(); |
---|
15304 | 15430 | break; |
---|
15305 | 15431 | case '!': |
---|
.. | .. |
---|
15862 | 15988 | |
---|
15863 | 15989 | int width = getBounds().width; |
---|
15864 | 15990 | int height = getBounds().height; |
---|
15865 | | - ClickInfo info = new ClickInfo(); |
---|
15866 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15867 | 15991 | //Image img = CreateImage(width, height); |
---|
15868 | 15992 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15869 | 15993 | |
---|
.. | .. |
---|
15940 | 16064 | } |
---|
15941 | 16065 | if (object != null && !hasMarquee) |
---|
15942 | 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 | + |
---|
15943 | 16073 | if (isRenderer) |
---|
15944 | 16074 | { |
---|
15945 | | - info.flags++; |
---|
| 16075 | + object.clickInfo.flags++; |
---|
15946 | 16076 | double frameAspect = (double) width / (double) height; |
---|
15947 | 16077 | if (frameAspect > renderCamera.aspect) |
---|
15948 | 16078 | { |
---|
15949 | 16079 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15950 | | - info.bounds.width -= width - desired; |
---|
15951 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16080 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16081 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15952 | 16082 | } else |
---|
15953 | 16083 | { |
---|
15954 | 16084 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15955 | | - info.bounds.height -= height - desired; |
---|
15956 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16085 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16086 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15957 | 16087 | } |
---|
15958 | 16088 | } |
---|
15959 | 16089 | |
---|
15960 | | - info.g = gr; |
---|
15961 | | - info.camera = renderCamera; |
---|
| 16090 | + object.clickInfo.g = gr; |
---|
| 16091 | + object.clickInfo.camera = renderCamera; |
---|
15962 | 16092 | /* |
---|
15963 | 16093 | // Memory intensive (brep.verticescopy) |
---|
15964 | 16094 | if (!(object instanceof Composite)) |
---|
15965 | 16095 | object.draw(info, 0, false); // SLOW : |
---|
15966 | 16096 | */ |
---|
15967 | | - if (!isRenderer) |
---|
| 16097 | + if (!isRenderer) // && drag) |
---|
15968 | 16098 | { |
---|
15969 | 16099 | Grafreed.Assert(object != null); |
---|
15970 | 16100 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15972 | 16102 | { |
---|
15973 | 16103 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15974 | 16104 | |
---|
15975 | | - info.DX = 0; |
---|
15976 | | - info.DY = 0; |
---|
15977 | | - info.W = 1; |
---|
| 16105 | + object.clickInfo.DX = 0; |
---|
| 16106 | + object.clickInfo.DY = 0; |
---|
| 16107 | + object.clickInfo.W = 1; |
---|
15978 | 16108 | if (hitSomething == Object3D.hitCenter) |
---|
15979 | 16109 | { |
---|
15980 | 16110 | info.DX = X; |
---|
.. | .. |
---|
15986 | 16116 | info.DY -= info.bounds.height/2; |
---|
15987 | 16117 | } |
---|
15988 | 16118 | |
---|
15989 | | - object.drawEditHandles(info, 0); |
---|
| 16119 | + object.drawEditHandles(//info, |
---|
| 16120 | + 0); |
---|
15990 | 16121 | |
---|
15991 | 16122 | if (drag && (X != 0 || Y != 0)) |
---|
15992 | 16123 | { |
---|
.. | .. |
---|
16485 | 16616 | private /*static*/ boolean firstime; |
---|
16486 | 16617 | private /*static*/ cVector newView = new cVector(); |
---|
16487 | 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"}; |
---|
16488 | 16621 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16489 | 16622 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16490 | 16623 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16497 | 16630 | { |
---|
16498 | 16631 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16499 | 16632 | |
---|
| 16633 | + int usedsuf = 0; |
---|
| 16634 | + |
---|
16500 | 16635 | for (int i = 0; i < suffixes.length; i++) |
---|
16501 | 16636 | { |
---|
16502 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16503 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16504 | | - mipmapped, |
---|
16505 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16506 | | - if (data == null) |
---|
| 16637 | + String[] suffixe = suffixes; |
---|
| 16638 | + String[] fallback = suffixes2; |
---|
| 16639 | + String[] fallfallback = suffixes3; |
---|
| 16640 | + |
---|
| 16641 | + for (int c=usedsuf; --c>=0;) |
---|
16507 | 16642 | { |
---|
16508 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16643 | +// String[] temp = suffixe; |
---|
| 16644 | +// suffixe = fallback; |
---|
| 16645 | +// fallback = fallfallback; |
---|
| 16646 | +// fallfallback = temp; |
---|
16509 | 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 | + |
---|
16510 | 16676 | //System.out.println("Target = " + targets[i]); |
---|
16511 | 16677 | cubemap.updateImage(data, targets[i]); |
---|
16512 | 16678 | } |
---|
16513 | 16679 | |
---|
16514 | 16680 | return cubemap; |
---|
16515 | 16681 | } |
---|
| 16682 | + |
---|
16516 | 16683 | int bigsphere = -1; |
---|
16517 | 16684 | |
---|
16518 | 16685 | float BGcolor = 0.5f; |
---|
16519 | 16686 | |
---|
16520 | | - private void DrawSkyBox(GL gl) |
---|
| 16687 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16688 | + |
---|
| 16689 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16521 | 16690 | { |
---|
16522 | | - if (envyoff || cubemap == null) |
---|
| 16691 | + if (//envyoff || |
---|
| 16692 | + WIREFRAME || |
---|
| 16693 | + cubemap == null) |
---|
16523 | 16694 | { |
---|
16524 | 16695 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16525 | 16696 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16534 | 16705 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16535 | 16706 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16536 | 16707 | gl.glLoadIdentity(); |
---|
| 16708 | + gl.glScalef(1,ratio,1); |
---|
16537 | 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 | + |
---|
16538 | 16719 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16539 | 16720 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16540 | 16721 | |
---|
.. | .. |
---|
16566 | 16747 | { |
---|
16567 | 16748 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16568 | 16749 | } |
---|
| 16750 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16569 | 16751 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16570 | 16752 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16571 | 16753 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16824 | 17006 | //new Exception().printStackTrace(); |
---|
16825 | 17007 | System.out.println("select buffer init"); |
---|
16826 | 17008 | // Use debug pipeline |
---|
16827 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 17009 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16828 | 17010 | |
---|
16829 | 17011 | GL gl = drawable.getGL(); |
---|
16830 | 17012 | |
---|
.. | .. |
---|
17370 | 17552 | gl.glFlush(); |
---|
17371 | 17553 | |
---|
17372 | 17554 | /**/ |
---|
17373 | | - 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); |
---|
17374 | 17556 | |
---|
17375 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17557 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17376 | 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 | + |
---|
17377 | 17563 | double r = 0, g = 0, b = 0; |
---|
17378 | 17564 | |
---|
17379 | 17565 | double count = 0; |
---|
.. | .. |
---|
17384 | 17570 | |
---|
17385 | 17571 | double FACTOR = 1; |
---|
17386 | 17572 | |
---|
17387 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17573 | + for (int i = 0; i < depths.length; i++) |
---|
17388 | 17574 | { |
---|
17389 | 17575 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17390 | 17576 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17467 | 17653 | |
---|
17468 | 17654 | double scale = ray.z; // 1; // cos |
---|
17469 | 17655 | |
---|
17470 | | - float depth = pixels[newindex]; |
---|
| 17656 | + float depth = depths[newindex]; |
---|
17471 | 17657 | |
---|
17472 | 17658 | /* |
---|
17473 | 17659 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17664 | 17850 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17665 | 17851 | static IntBuffer bigAAbuffer; |
---|
17666 | 17852 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17667 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17853 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17668 | 17854 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17669 | 17855 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17670 | 17856 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17671 | | - 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 | + |
---|
17672 | 17861 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17673 | 17862 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17674 | 17863 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|