.. | .. |
---|
173 | 173 | static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
174 | 174 | boolean anisotropy = true; |
---|
175 | 175 | boolean softshadow = true; // slower but better false; |
---|
176 | | - boolean opacityhalo = false; |
---|
| 176 | + boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
177 | 177 | |
---|
178 | 178 | boolean macromode = false; |
---|
179 | 179 | |
---|
.. | .. |
---|
187 | 187 | } |
---|
188 | 188 | |
---|
189 | 189 | private File defaultDirectory = javax.swing.filechooser.FileSystemView.getFileSystemView().getDefaultDirectory(); |
---|
| 190 | + |
---|
| 191 | + public void LoadSkybox(String name, String ext, boolean mipmap) throws GLException |
---|
| 192 | + { |
---|
| 193 | + try |
---|
| 194 | + { |
---|
| 195 | + cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
| 196 | + } catch (IOException e) |
---|
| 197 | + { |
---|
| 198 | + System.out.println("NAME = " + name); |
---|
| 199 | + e.printStackTrace(); // throw new RuntimeException(e); |
---|
| 200 | + } |
---|
| 201 | + } |
---|
190 | 202 | |
---|
191 | 203 | void SetAsGLRenderer(boolean b) |
---|
192 | 204 | { |
---|
.. | .. |
---|
206 | 218 | |
---|
207 | 219 | SetCamera(cam); |
---|
208 | 220 | |
---|
209 | | - SetLight(new Camera(new cVector(10, 10, -20))); |
---|
| 221 | + // Warning: not used. |
---|
| 222 | + SetLight(new Camera(new cVector(15, 10, -20))); |
---|
210 | 223 | |
---|
211 | 224 | object = o; |
---|
212 | 225 | |
---|
.. | .. |
---|
1484 | 1497 | gl.glVertex3f((float) pv.x, (float) pv.y, (float) pv.z); |
---|
1485 | 1498 | } |
---|
1486 | 1499 | |
---|
| 1500 | + float[] colorV = new float[4]; |
---|
| 1501 | + |
---|
1487 | 1502 | void SetColor(Object3D obj, Vertex p0) |
---|
1488 | 1503 | { |
---|
1489 | 1504 | CameraPane display = this; |
---|
.. | .. |
---|
1551 | 1566 | { |
---|
1552 | 1567 | return; |
---|
1553 | 1568 | } |
---|
1554 | | - |
---|
1555 | | - float[] colorV = new float[3]; |
---|
1556 | 1569 | |
---|
1557 | 1570 | if (false) // marked) |
---|
1558 | 1571 | { |
---|
.. | .. |
---|
8345 | 8358 | // else |
---|
8346 | 8359 | // if (!texname.startsWith("/")) |
---|
8347 | 8360 | // texname = "/Users/nbriere/Textures/" + texname; |
---|
8348 | | - if (!FileExists(texname)) |
---|
| 8361 | + if (!FileExists(texname) && !texname.startsWith("@")) |
---|
8349 | 8362 | { |
---|
8350 | 8363 | texname = fallbackTextureName; |
---|
8351 | 8364 | } |
---|
.. | .. |
---|
8428 | 8441 | new Exception().printStackTrace(); |
---|
8429 | 8442 | } else |
---|
8430 | 8443 | { |
---|
| 8444 | + if (texname.startsWith("@")) |
---|
| 8445 | + { |
---|
| 8446 | + // texturecache = textures.get(texname); // suspicious |
---|
| 8447 | + if (texturecache == null) |
---|
| 8448 | + texturecache = new CacheTexture(GetResourceTexture(texname.substring(1), bump),resolution); |
---|
| 8449 | + else |
---|
| 8450 | + new Exception().printStackTrace(); |
---|
| 8451 | + } else |
---|
| 8452 | + { |
---|
8431 | 8453 | if (textureon) |
---|
8432 | 8454 | { |
---|
8433 | 8455 | String cachename = texname; |
---|
.. | .. |
---|
8487 | 8509 | texturecache = new CacheTexture(texturedata,resolution); |
---|
8488 | 8510 | //texture = GetTexture(tex, bump); |
---|
8489 | 8511 | } |
---|
| 8512 | + } |
---|
8490 | 8513 | } |
---|
8491 | 8514 | //} |
---|
8492 | 8515 | } |
---|
.. | .. |
---|
8755 | 8778 | |
---|
8756 | 8779 | gl.glGetIntegerv(GL.GL_MAX_TEXTURE_STACK_DEPTH, temp, 0); |
---|
8757 | 8780 | MAXSTACK = temp[0]; |
---|
8758 | | - System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
| 8781 | + if (Globals.DEBUG) |
---|
| 8782 | + System.out.println("GL_MAX_TEXTURE_STACK_DEPTH = " + MAXSTACK); |
---|
8759 | 8783 | gl.glGetIntegerv(GL.GL_MAX_MODELVIEW_STACK_DEPTH, temp, 0); |
---|
8760 | 8784 | MAXSTACK = temp[0]; |
---|
8761 | | - System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
| 8785 | + if (Globals.DEBUG) |
---|
| 8786 | + System.out.println("GL_MAX_MODELVIEW_STACK_DEPTH = " + MAXSTACK); |
---|
8762 | 8787 | |
---|
8763 | 8788 | // Use debug pipeline |
---|
8764 | 8789 | //drawable.setGL(new DebugGL(gl)); // |
---|
.. | .. |
---|
8766 | 8791 | gl = drawable.getGL(); // |
---|
8767 | 8792 | |
---|
8768 | 8793 | GL gl3 = getGL(); |
---|
8769 | | - System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
| 8794 | + if (Globals.DEBUG) |
---|
| 8795 | + System.out.println("INIT GL IS: " + gl.getClass().getName()); |
---|
8770 | 8796 | |
---|
8771 | 8797 | |
---|
8772 | 8798 | //float pos[] = { 100, 100, 100, 0 }; |
---|
.. | .. |
---|
8931 | 8957 | |
---|
8932 | 8958 | if (cubemap == null) |
---|
8933 | 8959 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8960 | + //LoadEnvy(1); |
---|
8935 | 8961 | } |
---|
8936 | 8962 | |
---|
8937 | 8963 | //cubemap.enable(); |
---|
.. | .. |
---|
9218 | 9244 | cubemap = null; |
---|
9219 | 9245 | return; |
---|
9220 | 9246 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9247 | + name = "cubemaps/rgb/"; |
---|
| 9248 | + ext = "jpg"; |
---|
9223 | 9249 | reverseUP = false; |
---|
9224 | 9250 | break; |
---|
9225 | 9251 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9252 | + name = "cubemaps/uffizi/"; |
---|
| 9253 | + ext = "jpg"; |
---|
| 9254 | + reverseUP = false; |
---|
| 9255 | + break; |
---|
9229 | 9256 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9257 | + name = "cubemaps/CloudyHills/"; |
---|
| 9258 | + ext = "jpg"; |
---|
9232 | 9259 | reverseUP = false; |
---|
9233 | 9260 | break; |
---|
9234 | 9261 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9262 | + name = "cubemaps/cornell/"; |
---|
9236 | 9263 | ext = "png"; |
---|
9237 | 9264 | reverseUP = false; |
---|
9238 | 9265 | break; |
---|
| 9266 | + case 5: |
---|
| 9267 | + name = "cubemaps/skycube/"; |
---|
| 9268 | + ext = "jpg"; |
---|
| 9269 | + reverseUP = false; |
---|
| 9270 | + break; |
---|
| 9271 | + case 6: |
---|
| 9272 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9273 | + ext = "jpg"; |
---|
| 9274 | + reverseUP = false; |
---|
| 9275 | + break; |
---|
| 9276 | + case 7: |
---|
| 9277 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9278 | + ext = "jpg"; |
---|
| 9279 | + reverseUP = false; |
---|
| 9280 | + break; |
---|
| 9281 | + case 8: |
---|
| 9282 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9283 | + ext = "jpg"; |
---|
| 9284 | + reverseUP = false; |
---|
| 9285 | + break; |
---|
| 9286 | + case 9: |
---|
| 9287 | + name = "cubemaps/UnionSquare/"; |
---|
| 9288 | + ext = "jpg"; |
---|
| 9289 | + reverseUP = false; |
---|
| 9290 | + break; |
---|
9239 | 9291 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9292 | + name = "cubemaps/box/"; |
---|
| 9293 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9294 | + reverseUP = false; |
---|
9242 | 9295 | break; |
---|
9243 | 9296 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9297 | + |
---|
| 9298 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9299 | } |
---|
9253 | 9300 | |
---|
9254 | 9301 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9327 | static double[] model = new double[16]; |
---|
9281 | 9328 | double[] camera2light = new double[16]; |
---|
9282 | 9329 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9330 | + |
---|
| 9331 | + //int newenvy = -1; |
---|
| 9332 | + //boolean envyoff = false; |
---|
| 9333 | + |
---|
| 9334 | + String loadedskyboxname; |
---|
| 9335 | + |
---|
9285 | 9336 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9337 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9338 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9699 | 9750 | |
---|
9700 | 9751 | if (renderCamera != lightCamera) |
---|
9701 | 9752 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9753 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9754 | |
---|
9704 | 9755 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9756 | |
---|
.. | .. |
---|
9715 | 9766 | |
---|
9716 | 9767 | if (renderCamera != lightCamera) |
---|
9717 | 9768 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9769 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9770 | |
---|
9720 | 9771 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9772 | |
---|
.. | .. |
---|
9761 | 9812 | rati = 1 / rati; |
---|
9762 | 9813 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9814 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9815 | + |
---|
| 9816 | + //assert (newenvy == -1); |
---|
| 9817 | + |
---|
9765 | 9818 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9819 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9820 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9821 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9822 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9823 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10801 | 10854 | |
---|
10802 | 10855 | if (wait) |
---|
10803 | 10856 | { |
---|
10804 | | - Sleep(500); |
---|
| 10857 | + Sleep(200); // blocks everything |
---|
10805 | 10858 | |
---|
10806 | 10859 | wait = false; |
---|
10807 | 10860 | } |
---|
.. | .. |
---|
10916 | 10969 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10970 | if (cam != lightCamera) |
---|
10918 | 10971 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10972 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10973 | |
---|
10921 | 10974 | for (int j = 0; j < 4; j++) |
---|
10922 | 10975 | { |
---|
.. | .. |
---|
10931 | 10984 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 10985 | if (cam != lightCamera) |
---|
10933 | 10986 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10987 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 10988 | |
---|
10936 | 10989 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 10990 | |
---|
.. | .. |
---|
11017 | 11070 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11071 | } |
---|
11019 | 11072 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11073 | +// if (newenvy > -1) |
---|
| 11074 | +// { |
---|
| 11075 | +// LoadEnvy(newenvy); |
---|
| 11076 | +// } |
---|
| 11077 | +// |
---|
| 11078 | +// newenvy = -1; |
---|
| 11079 | + |
---|
| 11080 | + if (object.skyboxname != null) |
---|
11021 | 11081 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11082 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11083 | + { |
---|
| 11084 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11085 | + loadedskyboxname = object.skyboxname; |
---|
| 11086 | + } |
---|
11023 | 11087 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11088 | + else |
---|
| 11089 | + { |
---|
| 11090 | + cubemap = null; |
---|
| 11091 | + loadedskyboxname = null; |
---|
| 11092 | + } |
---|
| 11093 | + |
---|
11027 | 11094 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11095 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11096 | |
---|
.. | .. |
---|
11039 | 11106 | |
---|
11040 | 11107 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11108 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11109 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11110 | } |
---|
11044 | 11111 | |
---|
11045 | 11112 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11392 | |
---|
11326 | 11393 | // if (cam != lightCamera) |
---|
11327 | 11394 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11395 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11396 | } |
---|
11330 | 11397 | |
---|
11331 | 11398 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12466 | |
---|
12400 | 12467 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12468 | |
---|
12402 | | - String program = |
---|
| 12469 | + String programmin = |
---|
12403 | 12470 | // Min shader |
---|
12404 | 12471 | "!!ARBfp1.0\n" + |
---|
12405 | | - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12472 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12406 | 12473 | "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
12407 | 12474 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12408 | 12475 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12409 | 12476 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12477 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12478 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12479 | + "PARAM light2cam2 = program.env[12];" + |
---|
12410 | 12480 | "TEMP temp;" + |
---|
12411 | 12481 | "TEMP light;" + |
---|
12412 | 12482 | "TEMP ndotl;" + |
---|
12413 | 12483 | "TEMP normal;" + |
---|
12414 | 12484 | "TEMP depth;" + |
---|
| 12485 | + "TEMP eye;" + |
---|
| 12486 | + "TEMP pos;" + |
---|
12415 | 12487 | |
---|
12416 | 12488 | "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
12417 | | - |
---|
| 12489 | + Normalize("normal") + |
---|
12418 | 12490 | "MOV light, state.light[0].position;" + |
---|
12419 | 12491 | "DP3 ndotl.x, light, normal;" + |
---|
12420 | 12492 | |
---|
12421 | 12493 | // shadow |
---|
12422 | | - "MOV temp, fragment.texcoord[1];" + |
---|
12423 | | - TextureFetch("depth", "temp", "1") + |
---|
| 12494 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12495 | + "MOV temp, pos;" + |
---|
| 12496 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
12424 | 12497 | //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
12425 | | - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
12426 | | - |
---|
| 12498 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
12427 | 12499 | |
---|
12428 | 12500 | // No shadow when out of frustum |
---|
12429 | 12501 | //"SGE temp.y, depth.z, zero123.y;" + |
---|
12430 | 12502 | //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
12431 | 12503 | |
---|
12432 | | - "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
12433 | | - "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12504 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12434 | 12505 | |
---|
| 12506 | + // Backlit |
---|
| 12507 | + "MOV pos.w, zero123.y;" + |
---|
| 12508 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12509 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12510 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12511 | + Normalize("eye") + |
---|
| 12512 | + |
---|
| 12513 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12514 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12515 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12516 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12517 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12518 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12519 | + |
---|
| 12520 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12521 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12522 | + |
---|
| 12523 | + // Pigment |
---|
12435 | 12524 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12436 | 12525 | "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12437 | 12526 | "MUL temp, temp, ndotl.x;" + |
---|
12438 | 12527 | |
---|
12439 | 12528 | "MUL temp, temp, zero123.z;" + |
---|
12440 | 12529 | |
---|
12441 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12530 | + //"MUL temp, temp, ndotl.y;" + |
---|
12442 | 12531 | |
---|
| 12532 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
12443 | 12533 | "MOV result.color, temp;" + |
---|
12444 | 12534 | "END"; |
---|
12445 | 12535 | |
---|
12446 | | - String program2 = |
---|
| 12536 | + String programmax = |
---|
12447 | 12537 | "!!ARBfp1.0\n" + |
---|
12448 | 12538 | |
---|
12449 | 12539 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12581 | 12671 | "MUL temp, floor, mapgrid.x;" + |
---|
12582 | 12672 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12583 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12584 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12585 | 12675 | "") + |
---|
12586 | 12676 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12587 | 12677 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12588 | 12678 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12589 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12679 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12590 | 12680 | "") + |
---|
12591 | 12681 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12592 | 12682 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12593 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12683 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12594 | 12684 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12595 | 12685 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12596 | 12686 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12597 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12687 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12598 | 12688 | "") + |
---|
12599 | 12689 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12600 | 12690 | //"MOV params, material;" + |
---|
.. | .. |
---|
12968 | 13058 | // display shadow only (fakedepth == 0) |
---|
12969 | 13059 | "SUB temp.x, half.x, shadow.x;" + |
---|
12970 | 13060 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12971 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13061 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12972 | 13062 | "SUB temp.y, one.x, temp.z;" + |
---|
12973 | 13063 | "MUL temp.x, temp.x, temp.y;" + |
---|
12974 | 13064 | "KIL temp.x;" + |
---|
.. | .. |
---|
13299 | 13389 | //once = true; |
---|
13300 | 13390 | } |
---|
13301 | 13391 | |
---|
| 13392 | + String program = programmax; |
---|
| 13393 | + |
---|
| 13394 | + if (Globals.MINSHADER) |
---|
| 13395 | + { |
---|
| 13396 | + program = programmin; |
---|
| 13397 | + } |
---|
| 13398 | + |
---|
13302 | 13399 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13303 | 13400 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13304 | 13401 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13392 | 13489 | return out; |
---|
13393 | 13490 | } |
---|
13394 | 13491 | |
---|
13395 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13492 | + // Also does frustum culling |
---|
| 13493 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13396 | 13494 | { |
---|
13397 | 13495 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13398 | 13496 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
.. | .. |
---|
14255 | 14353 | drag = false; |
---|
14256 | 14354 | //System.out.println("Mouse DOWN"); |
---|
14257 | 14355 | 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); |
---|
| 14356 | + //ClickInfo info = new ClickInfo(); |
---|
| 14357 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14358 | + object.clickInfo.pane = this; |
---|
| 14359 | + object.clickInfo.camera = renderCamera; |
---|
| 14360 | + object.clickInfo.x = x; |
---|
| 14361 | + object.clickInfo.y = y; |
---|
| 14362 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14363 | + editObj = object.doEditClick(//info, |
---|
| 14364 | + 0); |
---|
14266 | 14365 | if (!editObj) |
---|
14267 | 14366 | { |
---|
14268 | 14367 | hasMarquee = true; |
---|
.. | .. |
---|
14546 | 14645 | MODIFIERS |= COMMAND; |
---|
14547 | 14646 | /**/ |
---|
14548 | 14647 | if((mod&SHIFT) == SHIFT) |
---|
14549 | | - manipCamera.RotatePosition(0, -speed); |
---|
14550 | | - else |
---|
14551 | 14648 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14649 | + else |
---|
| 14650 | + manipCamera.RotatePosition(0, -speed); |
---|
14552 | 14651 | /**/ |
---|
14553 | 14652 | if ((mod & SHIFT) == SHIFT) |
---|
14554 | 14653 | { |
---|
.. | .. |
---|
14567 | 14666 | MODIFIERS |= COMMAND; |
---|
14568 | 14667 | /**/ |
---|
14569 | 14668 | if((mod&SHIFT) == SHIFT) |
---|
14570 | | - manipCamera.RotatePosition(0, speed); |
---|
14571 | | - else |
---|
14572 | 14669 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14670 | + else |
---|
| 14671 | + manipCamera.RotatePosition(0, speed); |
---|
14573 | 14672 | /**/ |
---|
14574 | 14673 | if ((mod & SHIFT) == SHIFT) |
---|
14575 | 14674 | { |
---|
.. | .. |
---|
14662 | 14761 | if (editObj) |
---|
14663 | 14762 | { |
---|
14664 | 14763 | drag = true; |
---|
14665 | | - ClickInfo info = new ClickInfo(); |
---|
14666 | | - info.bounds.setBounds(0, 0, |
---|
| 14764 | + //ClickInfo info = new ClickInfo(); |
---|
| 14765 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14667 | 14766 | (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); |
---|
| 14767 | + object.clickInfo.pane = this; |
---|
| 14768 | + object.clickInfo.camera = renderCamera; |
---|
| 14769 | + object.clickInfo.x = x; |
---|
| 14770 | + object.clickInfo.y = y; |
---|
| 14771 | + object //.GetWindow().copy |
---|
| 14772 | + .doEditDrag(//info, |
---|
| 14773 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14674 | 14774 | } else |
---|
14675 | 14775 | { |
---|
14676 | 14776 | if (x < startX) |
---|
.. | .. |
---|
14819 | 14919 | } |
---|
14820 | 14920 | } |
---|
14821 | 14921 | |
---|
| 14922 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14923 | + |
---|
14822 | 14924 | public void mouseMoved(MouseEvent e) |
---|
14823 | 14925 | { |
---|
14824 | 14926 | //System.out.println("mouseMoved: " + e); |
---|
14825 | 14927 | if (isRenderer) |
---|
14826 | 14928 | return; |
---|
14827 | 14929 | |
---|
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; |
---|
| 14930 | + // Mouse cursor feedback |
---|
| 14931 | + object.clickInfo.x = e.getX(); |
---|
| 14932 | + object.clickInfo.y = e.getY(); |
---|
| 14933 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14934 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14935 | + object.clickInfo.pane = this; |
---|
| 14936 | + object.clickInfo.camera = renderCamera; |
---|
14835 | 14937 | if (!isRenderer) |
---|
14836 | 14938 | { |
---|
14837 | 14939 | //ObjEditor editWindow = object.editWindow; |
---|
14838 | 14940 | //Object3D copy = editWindow.copy; |
---|
14839 | | - if (object.doEditClick(ci, 0)) |
---|
| 14941 | + if (object.doEditClick(//clickInfo, |
---|
| 14942 | + 0)) |
---|
14840 | 14943 | { |
---|
14841 | 14944 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14842 | 14945 | } else |
---|
.. | .. |
---|
15286 | 15389 | OCCLUSION_CULLING ^= true; |
---|
15287 | 15390 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15288 | 15391 | break; |
---|
15289 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15392 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15290 | 15393 | case '1': |
---|
15291 | 15394 | case '2': |
---|
15292 | 15395 | case '3': |
---|
15293 | 15396 | case '4': |
---|
15294 | 15397 | case '5': |
---|
15295 | | - newenvy = Character.getNumericValue(key); |
---|
15296 | | - repaint(); |
---|
15297 | | - break; |
---|
15298 | 15398 | case '6': |
---|
15299 | 15399 | case '7': |
---|
15300 | 15400 | case '8': |
---|
15301 | 15401 | case '9': |
---|
15302 | | - BGcolor = (key - '6')/3.f; |
---|
| 15402 | + if (true) // envyoff) |
---|
| 15403 | + { |
---|
| 15404 | + BGcolor = (key - '1')/8.f; |
---|
| 15405 | + } |
---|
| 15406 | + else |
---|
| 15407 | + { |
---|
| 15408 | + //newenvy = Character.getNumericValue(key); |
---|
| 15409 | + } |
---|
15303 | 15410 | repaint(); |
---|
15304 | 15411 | break; |
---|
15305 | 15412 | case '!': |
---|
.. | .. |
---|
15862 | 15969 | |
---|
15863 | 15970 | int width = getBounds().width; |
---|
15864 | 15971 | int height = getBounds().height; |
---|
15865 | | - ClickInfo info = new ClickInfo(); |
---|
15866 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15867 | 15972 | //Image img = CreateImage(width, height); |
---|
15868 | 15973 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15869 | 15974 | |
---|
.. | .. |
---|
15940 | 16045 | } |
---|
15941 | 16046 | if (object != null && !hasMarquee) |
---|
15942 | 16047 | { |
---|
| 16048 | + if (object.clickInfo == null) |
---|
| 16049 | + object.clickInfo = new ClickInfo(); |
---|
| 16050 | + ClickInfo info = object.clickInfo; |
---|
| 16051 | + //ClickInfo info = new ClickInfo(); |
---|
| 16052 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16053 | + |
---|
15943 | 16054 | if (isRenderer) |
---|
15944 | 16055 | { |
---|
15945 | | - info.flags++; |
---|
| 16056 | + object.clickInfo.flags++; |
---|
15946 | 16057 | double frameAspect = (double) width / (double) height; |
---|
15947 | 16058 | if (frameAspect > renderCamera.aspect) |
---|
15948 | 16059 | { |
---|
15949 | 16060 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15950 | | - info.bounds.width -= width - desired; |
---|
15951 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16061 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16062 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15952 | 16063 | } else |
---|
15953 | 16064 | { |
---|
15954 | 16065 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15955 | | - info.bounds.height -= height - desired; |
---|
15956 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16066 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16067 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15957 | 16068 | } |
---|
15958 | 16069 | } |
---|
15959 | 16070 | |
---|
15960 | | - info.g = gr; |
---|
15961 | | - info.camera = renderCamera; |
---|
| 16071 | + object.clickInfo.g = gr; |
---|
| 16072 | + object.clickInfo.camera = renderCamera; |
---|
15962 | 16073 | /* |
---|
15963 | 16074 | // Memory intensive (brep.verticescopy) |
---|
15964 | 16075 | if (!(object instanceof Composite)) |
---|
15965 | 16076 | object.draw(info, 0, false); // SLOW : |
---|
15966 | 16077 | */ |
---|
15967 | | - if (!isRenderer) |
---|
| 16078 | + if (!isRenderer) // && drag) |
---|
15968 | 16079 | { |
---|
15969 | 16080 | Grafreed.Assert(object != null); |
---|
15970 | 16081 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15972 | 16083 | { |
---|
15973 | 16084 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15974 | 16085 | |
---|
15975 | | - info.DX = 0; |
---|
15976 | | - info.DY = 0; |
---|
15977 | | - info.W = 1; |
---|
| 16086 | + object.clickInfo.DX = 0; |
---|
| 16087 | + object.clickInfo.DY = 0; |
---|
| 16088 | + object.clickInfo.W = 1; |
---|
15978 | 16089 | if (hitSomething == Object3D.hitCenter) |
---|
15979 | 16090 | { |
---|
15980 | 16091 | info.DX = X; |
---|
.. | .. |
---|
15986 | 16097 | info.DY -= info.bounds.height/2; |
---|
15987 | 16098 | } |
---|
15988 | 16099 | |
---|
15989 | | - object.drawEditHandles(info, 0); |
---|
| 16100 | + object.drawEditHandles(//info, |
---|
| 16101 | + 0); |
---|
15990 | 16102 | |
---|
15991 | 16103 | if (drag && (X != 0 || Y != 0)) |
---|
15992 | 16104 | { |
---|
.. | .. |
---|
16485 | 16597 | private /*static*/ boolean firstime; |
---|
16486 | 16598 | private /*static*/ cVector newView = new cVector(); |
---|
16487 | 16599 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16600 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16601 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16488 | 16602 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16489 | 16603 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16490 | 16604 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16497 | 16611 | { |
---|
16498 | 16612 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16499 | 16613 | |
---|
| 16614 | + int usedsuf = 0; |
---|
| 16615 | + |
---|
16500 | 16616 | for (int i = 0; i < suffixes.length; i++) |
---|
16501 | 16617 | { |
---|
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) |
---|
| 16618 | + String[] suffixe = suffixes; |
---|
| 16619 | + String[] fallback = suffixes2; |
---|
| 16620 | + String[] fallfallback = suffixes3; |
---|
| 16621 | + |
---|
| 16622 | + for (int c=usedsuf; --c>=0;) |
---|
16507 | 16623 | { |
---|
16508 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16624 | +// String[] temp = suffixe; |
---|
| 16625 | +// suffixe = fallback; |
---|
| 16626 | +// fallback = fallfallback; |
---|
| 16627 | +// fallfallback = temp; |
---|
16509 | 16628 | } |
---|
| 16629 | + |
---|
| 16630 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16631 | + TextureData data; |
---|
| 16632 | + |
---|
| 16633 | + try |
---|
| 16634 | + { |
---|
| 16635 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16636 | + mipmapped, |
---|
| 16637 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16638 | + } |
---|
| 16639 | + catch (Exception e) |
---|
| 16640 | + { |
---|
| 16641 | + try |
---|
| 16642 | + { |
---|
| 16643 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16644 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16645 | + mipmapped, |
---|
| 16646 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16647 | + } |
---|
| 16648 | + catch (Exception e2) |
---|
| 16649 | + { |
---|
| 16650 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16651 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16652 | + mipmapped, |
---|
| 16653 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16654 | + } |
---|
| 16655 | + } |
---|
| 16656 | + |
---|
16510 | 16657 | //System.out.println("Target = " + targets[i]); |
---|
16511 | 16658 | cubemap.updateImage(data, targets[i]); |
---|
16512 | 16659 | } |
---|
16513 | 16660 | |
---|
16514 | 16661 | return cubemap; |
---|
16515 | 16662 | } |
---|
| 16663 | + |
---|
16516 | 16664 | int bigsphere = -1; |
---|
16517 | 16665 | |
---|
16518 | 16666 | float BGcolor = 0.5f; |
---|
16519 | 16667 | |
---|
16520 | | - private void DrawSkyBox(GL gl) |
---|
| 16668 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16669 | + |
---|
| 16670 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16521 | 16671 | { |
---|
16522 | | - if (envyoff || cubemap == null) |
---|
| 16672 | + if (//envyoff || |
---|
| 16673 | + WIREFRAME || |
---|
| 16674 | + cubemap == null) |
---|
16523 | 16675 | { |
---|
16524 | 16676 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16525 | 16677 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16534 | 16686 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16535 | 16687 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16536 | 16688 | gl.glLoadIdentity(); |
---|
| 16689 | + gl.glScalef(1,ratio,1); |
---|
16537 | 16690 | |
---|
| 16691 | +// colorV[0] = 2; |
---|
| 16692 | +// colorV[1] = 2; |
---|
| 16693 | +// colorV[2] = 2; |
---|
| 16694 | +// colorV[3] = 1; |
---|
| 16695 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16696 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16697 | +// |
---|
| 16698 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16699 | + |
---|
16538 | 16700 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16539 | 16701 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16540 | 16702 | |
---|
.. | .. |
---|
16566 | 16728 | { |
---|
16567 | 16729 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16568 | 16730 | } |
---|
| 16731 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16569 | 16732 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16570 | 16733 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16571 | 16734 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16824 | 16987 | //new Exception().printStackTrace(); |
---|
16825 | 16988 | System.out.println("select buffer init"); |
---|
16826 | 16989 | // Use debug pipeline |
---|
16827 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16990 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16828 | 16991 | |
---|
16829 | 16992 | GL gl = drawable.getGL(); |
---|
16830 | 16993 | |
---|
.. | .. |
---|
17370 | 17533 | gl.glFlush(); |
---|
17371 | 17534 | |
---|
17372 | 17535 | /**/ |
---|
17373 | | - gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusionsizebuffer); |
---|
| 17536 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_DEPTH_COMPONENT, GL.GL_FLOAT, occlusiondepthbuffer); |
---|
17374 | 17537 | |
---|
17375 | | - float[] pixels = occlusionsizebuffer.array(); |
---|
| 17538 | + float[] depths = occlusiondepthbuffer.array(); |
---|
17376 | 17539 | |
---|
| 17540 | + gl.glReadPixels(0, 0, OCCLUSION_SIZE, OCCLUSION_SIZE, GL.GL_BGRA, GL.GL_UNSIGNED_INT_8_8_8_8_REV, occlusioncolorbuffer); |
---|
| 17541 | + |
---|
| 17542 | + int[] pixels = selectsizebuffer.array(); |
---|
| 17543 | + |
---|
17377 | 17544 | double r = 0, g = 0, b = 0; |
---|
17378 | 17545 | |
---|
17379 | 17546 | double count = 0; |
---|
.. | .. |
---|
17384 | 17551 | |
---|
17385 | 17552 | double FACTOR = 1; |
---|
17386 | 17553 | |
---|
17387 | | - for (int i = 0; i < pixels.length; i++) |
---|
| 17554 | + for (int i = 0; i < depths.length; i++) |
---|
17388 | 17555 | { |
---|
17389 | 17556 | int x = i / OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
17390 | 17557 | int y = i % OCCLUSION_SIZE - OCCLUSION_SIZE / 2; |
---|
.. | .. |
---|
17467 | 17634 | |
---|
17468 | 17635 | double scale = ray.z; // 1; // cos |
---|
17469 | 17636 | |
---|
17470 | | - float depth = pixels[newindex]; |
---|
| 17637 | + float depth = depths[newindex]; |
---|
17471 | 17638 | |
---|
17472 | 17639 | /* |
---|
17473 | 17640 | int newindex2 = (x + 1) * OCCLUSION_SIZE + y; |
---|
.. | .. |
---|
17664 | 17831 | static IntBuffer AAbuffer; // = IntBuffer.allocate(MAX_SIZE*MAX_SIZE); |
---|
17665 | 17832 | static IntBuffer bigAAbuffer; |
---|
17666 | 17833 | static java.nio.FloatBuffer histogram = BufferUtil.newFloatBuffer(HISTOGRAM_SIZE * 3); |
---|
17667 | | - static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
| 17834 | + //static IntBuffer texturesizebuffer = IntBuffer.allocate(TEX_SIZE * TEX_SIZE); |
---|
17668 | 17835 | static IntBuffer selectsizebuffer = IntBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17669 | 17836 | static java.nio.FloatBuffer pointselectsizebuffer = java.nio.FloatBuffer.allocate(SELECT_SIZE * SELECT_SIZE); |
---|
17670 | 17837 | //static IntBuffer occlusionsizebuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
17671 | | - static java.nio.FloatBuffer occlusionsizebuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17838 | + static java.nio.FloatBuffer occlusiondepthbuffer = java.nio.FloatBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17839 | + |
---|
| 17840 | + static IntBuffer occlusioncolorbuffer = IntBuffer.allocate(OCCLUSION_SIZE * OCCLUSION_SIZE); |
---|
| 17841 | + |
---|
17672 | 17842 | static BufferedImage bufimage = new BufferedImage(TEX_SIZE, TEX_SIZE, BufferedImage.TYPE_INT_RGB); |
---|
17673 | 17843 | static BufferedImage textest = new cBufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB); |
---|
17674 | 17844 | static java.util.Vector<BufferedImage> billboards = new java.util.Vector<BufferedImage>(); |
---|