.. | .. |
---|
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 | } |
---|
.. | .. |
---|
8931 | 8954 | |
---|
8932 | 8955 | if (cubemap == null) |
---|
8933 | 8956 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8957 | + //LoadEnvy(1); |
---|
8935 | 8958 | } |
---|
8936 | 8959 | |
---|
8937 | 8960 | //cubemap.enable(); |
---|
.. | .. |
---|
9218 | 9241 | cubemap = null; |
---|
9219 | 9242 | return; |
---|
9220 | 9243 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9244 | + name = "cubemaps/rgb/"; |
---|
| 9245 | + ext = "jpg"; |
---|
9223 | 9246 | reverseUP = false; |
---|
9224 | 9247 | break; |
---|
9225 | 9248 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9249 | + name = "cubemaps/uffizi/"; |
---|
| 9250 | + ext = "jpg"; |
---|
| 9251 | + reverseUP = false; |
---|
| 9252 | + break; |
---|
9229 | 9253 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9254 | + name = "cubemaps/CloudyHills/"; |
---|
| 9255 | + ext = "jpg"; |
---|
9232 | 9256 | reverseUP = false; |
---|
9233 | 9257 | break; |
---|
9234 | 9258 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9259 | + name = "cubemaps/cornell/"; |
---|
9236 | 9260 | ext = "png"; |
---|
9237 | 9261 | reverseUP = false; |
---|
9238 | 9262 | break; |
---|
| 9263 | + case 5: |
---|
| 9264 | + name = "cubemaps/skycube/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 6: |
---|
| 9269 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 7: |
---|
| 9274 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
| 9278 | + case 8: |
---|
| 9279 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9280 | + ext = "jpg"; |
---|
| 9281 | + reverseUP = false; |
---|
| 9282 | + break; |
---|
| 9283 | + case 9: |
---|
| 9284 | + name = "cubemaps/UnionSquare/"; |
---|
| 9285 | + ext = "jpg"; |
---|
| 9286 | + reverseUP = false; |
---|
| 9287 | + break; |
---|
9239 | 9288 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9289 | + name = "cubemaps/box/"; |
---|
| 9290 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9291 | + reverseUP = false; |
---|
9242 | 9292 | break; |
---|
9243 | 9293 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9294 | + |
---|
| 9295 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9296 | } |
---|
9253 | 9297 | |
---|
9254 | 9298 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9324 | static double[] model = new double[16]; |
---|
9281 | 9325 | double[] camera2light = new double[16]; |
---|
9282 | 9326 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9327 | + |
---|
| 9328 | + //int newenvy = -1; |
---|
| 9329 | + //boolean envyoff = false; |
---|
| 9330 | + |
---|
| 9331 | + String loadedskyboxname; |
---|
| 9332 | + |
---|
9285 | 9333 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9334 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9335 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9761 | 9809 | rati = 1 / rati; |
---|
9762 | 9810 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9811 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9812 | + |
---|
| 9813 | + //assert (newenvy == -1); |
---|
| 9814 | + |
---|
9765 | 9815 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9816 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9817 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9818 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9819 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9820 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10801 | 10851 | |
---|
10802 | 10852 | if (wait) |
---|
10803 | 10853 | { |
---|
10804 | | - Sleep(500); |
---|
| 10854 | + Sleep(200); // blocks everything |
---|
10805 | 10855 | |
---|
10806 | 10856 | wait = false; |
---|
10807 | 10857 | } |
---|
.. | .. |
---|
11017 | 11067 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11068 | } |
---|
11019 | 11069 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11070 | +// if (newenvy > -1) |
---|
| 11071 | +// { |
---|
| 11072 | +// LoadEnvy(newenvy); |
---|
| 11073 | +// } |
---|
| 11074 | +// |
---|
| 11075 | +// newenvy = -1; |
---|
| 11076 | + |
---|
| 11077 | + if (object.skyboxname != null) |
---|
11021 | 11078 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11079 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11080 | + { |
---|
| 11081 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11082 | + loadedskyboxname = object.skyboxname; |
---|
| 11083 | + } |
---|
11023 | 11084 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11085 | + else |
---|
| 11086 | + { |
---|
| 11087 | + cubemap = null; |
---|
| 11088 | + loadedskyboxname = null; |
---|
| 11089 | + } |
---|
| 11090 | + |
---|
11027 | 11091 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11092 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11093 | |
---|
.. | .. |
---|
11039 | 11103 | |
---|
11040 | 11104 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11105 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11106 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11107 | } |
---|
11044 | 11108 | |
---|
11045 | 11109 | //if (selection_view == -1) |
---|
.. | .. |
---|
11325 | 11389 | |
---|
11326 | 11390 | // if (cam != lightCamera) |
---|
11327 | 11391 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
11328 | | - LA.xformDir(lightposition, parentcam.GlobalTransform(), lightposition); // may 2013 |
---|
| 11392 | + LA.xformDir(lightposition, parentcam.GlobalTransformInv(), lightposition); // may 2013 |
---|
11329 | 11393 | } |
---|
11330 | 11394 | |
---|
11331 | 11395 | LA.xformDir(lightposition, cam.toScreen, lightposition); |
---|
.. | .. |
---|
12399 | 12463 | |
---|
12400 | 12464 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12465 | |
---|
12402 | | - String program = |
---|
| 12466 | + String programmin = |
---|
12403 | 12467 | // Min shader |
---|
12404 | 12468 | "!!ARBfp1.0\n" + |
---|
12405 | | - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12469 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12406 | 12470 | "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
12407 | 12471 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12408 | 12472 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12409 | 12473 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12474 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12475 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12476 | + "PARAM light2cam2 = program.env[12];" + |
---|
12410 | 12477 | "TEMP temp;" + |
---|
12411 | 12478 | "TEMP light;" + |
---|
12412 | 12479 | "TEMP ndotl;" + |
---|
12413 | 12480 | "TEMP normal;" + |
---|
12414 | 12481 | "TEMP depth;" + |
---|
| 12482 | + "TEMP eye;" + |
---|
| 12483 | + "TEMP pos;" + |
---|
12415 | 12484 | |
---|
12416 | 12485 | "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
12417 | | - |
---|
| 12486 | + Normalize("normal") + |
---|
12418 | 12487 | "MOV light, state.light[0].position;" + |
---|
12419 | 12488 | "DP3 ndotl.x, light, normal;" + |
---|
12420 | 12489 | |
---|
12421 | 12490 | // shadow |
---|
12422 | | - "MOV temp, fragment.texcoord[1];" + |
---|
12423 | | - TextureFetch("depth", "temp", "1") + |
---|
| 12491 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12492 | + "MOV temp, pos;" + |
---|
| 12493 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
12424 | 12494 | //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
12425 | | - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
12426 | | - |
---|
| 12495 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
12427 | 12496 | |
---|
12428 | 12497 | // No shadow when out of frustum |
---|
12429 | 12498 | //"SGE temp.y, depth.z, zero123.y;" + |
---|
12430 | 12499 | //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
12431 | 12500 | |
---|
12432 | | - "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
12433 | | - "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12501 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12434 | 12502 | |
---|
| 12503 | + // Backlit |
---|
| 12504 | + "MOV pos.w, zero123.y;" + |
---|
| 12505 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12506 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12507 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12508 | + Normalize("eye") + |
---|
| 12509 | + |
---|
| 12510 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12511 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12512 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12513 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12514 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12515 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12518 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12519 | + |
---|
| 12520 | + // Pigment |
---|
12435 | 12521 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12436 | 12522 | "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12437 | 12523 | "MUL temp, temp, ndotl.x;" + |
---|
12438 | 12524 | |
---|
12439 | 12525 | "MUL temp, temp, zero123.z;" + |
---|
12440 | 12526 | |
---|
12441 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12527 | + //"MUL temp, temp, ndotl.y;" + |
---|
12442 | 12528 | |
---|
| 12529 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
12443 | 12530 | "MOV result.color, temp;" + |
---|
12444 | 12531 | "END"; |
---|
12445 | 12532 | |
---|
12446 | | - String program2 = |
---|
| 12533 | + String programmax = |
---|
12447 | 12534 | "!!ARBfp1.0\n" + |
---|
12448 | 12535 | |
---|
12449 | 12536 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12581 | 12668 | "MUL temp, floor, mapgrid.x;" + |
---|
12582 | 12669 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12583 | 12670 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12584 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12671 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12585 | 12672 | "") + |
---|
12586 | 12673 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12587 | 12674 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12588 | 12675 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12589 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12676 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12590 | 12677 | "") + |
---|
12591 | 12678 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12592 | 12679 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12593 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12680 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12594 | 12681 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12595 | 12682 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12596 | 12683 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12597 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12684 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12598 | 12685 | "") + |
---|
12599 | 12686 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12600 | 12687 | //"MOV params, material;" + |
---|
.. | .. |
---|
12968 | 13055 | // display shadow only (fakedepth == 0) |
---|
12969 | 13056 | "SUB temp.x, half.x, shadow.x;" + |
---|
12970 | 13057 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12971 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13058 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12972 | 13059 | "SUB temp.y, one.x, temp.z;" + |
---|
12973 | 13060 | "MUL temp.x, temp.x, temp.y;" + |
---|
12974 | 13061 | "KIL temp.x;" + |
---|
.. | .. |
---|
13299 | 13386 | //once = true; |
---|
13300 | 13387 | } |
---|
13301 | 13388 | |
---|
| 13389 | + String program = programmax; |
---|
| 13390 | + |
---|
| 13391 | + if (Globals.MINSHADER) |
---|
| 13392 | + { |
---|
| 13393 | + program = programmin; |
---|
| 13394 | + } |
---|
| 13395 | + |
---|
13302 | 13396 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13303 | 13397 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13304 | 13398 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13392 | 13486 | return out; |
---|
13393 | 13487 | } |
---|
13394 | 13488 | |
---|
13395 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13489 | + // Also does frustum culling |
---|
| 13490 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13396 | 13491 | { |
---|
13397 | 13492 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13398 | 13493 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
.. | .. |
---|
14547 | 14642 | MODIFIERS |= COMMAND; |
---|
14548 | 14643 | /**/ |
---|
14549 | 14644 | if((mod&SHIFT) == SHIFT) |
---|
14550 | | - manipCamera.RotatePosition(0, -speed); |
---|
14551 | | - else |
---|
14552 | 14645 | manipCamera.BackForth(0, -speed*delta, 0); // getWidth()); |
---|
| 14646 | + else |
---|
| 14647 | + manipCamera.RotatePosition(0, -speed); |
---|
14553 | 14648 | /**/ |
---|
14554 | 14649 | if ((mod & SHIFT) == SHIFT) |
---|
14555 | 14650 | { |
---|
.. | .. |
---|
14568 | 14663 | MODIFIERS |= COMMAND; |
---|
14569 | 14664 | /**/ |
---|
14570 | 14665 | if((mod&SHIFT) == SHIFT) |
---|
14571 | | - manipCamera.RotatePosition(0, speed); |
---|
14572 | | - else |
---|
14573 | 14666 | manipCamera.BackForth(0, speed*delta, 0); // getWidth()); |
---|
| 14667 | + else |
---|
| 14668 | + manipCamera.RotatePosition(0, speed); |
---|
14574 | 14669 | /**/ |
---|
14575 | 14670 | if ((mod & SHIFT) == SHIFT) |
---|
14576 | 14671 | { |
---|
.. | .. |
---|
15291 | 15386 | OCCLUSION_CULLING ^= true; |
---|
15292 | 15387 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15293 | 15388 | break; |
---|
15294 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15389 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15295 | 15390 | case '1': |
---|
15296 | 15391 | case '2': |
---|
15297 | 15392 | case '3': |
---|
15298 | 15393 | case '4': |
---|
15299 | 15394 | case '5': |
---|
15300 | | - newenvy = Character.getNumericValue(key); |
---|
15301 | | - repaint(); |
---|
15302 | | - break; |
---|
15303 | 15395 | case '6': |
---|
15304 | 15396 | case '7': |
---|
15305 | 15397 | case '8': |
---|
15306 | 15398 | case '9': |
---|
15307 | | - BGcolor = (key - '6')/3.f; |
---|
| 15399 | + if (true) // envyoff) |
---|
| 15400 | + { |
---|
| 15401 | + BGcolor = (key - '1')/8.f; |
---|
| 15402 | + } |
---|
| 15403 | + else |
---|
| 15404 | + { |
---|
| 15405 | + //newenvy = Character.getNumericValue(key); |
---|
| 15406 | + } |
---|
15308 | 15407 | repaint(); |
---|
15309 | 15408 | break; |
---|
15310 | 15409 | case '!': |
---|
.. | .. |
---|
16009 | 16108 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16010 | 16109 | break; |
---|
16011 | 16110 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16012 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16111 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16013 | 16112 | break; |
---|
16014 | 16113 | } |
---|
16015 | 16114 | |
---|
.. | .. |
---|
16495 | 16594 | private /*static*/ boolean firstime; |
---|
16496 | 16595 | private /*static*/ cVector newView = new cVector(); |
---|
16497 | 16596 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16597 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16598 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16498 | 16599 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16499 | 16600 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16500 | 16601 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16507 | 16608 | { |
---|
16508 | 16609 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16509 | 16610 | |
---|
| 16611 | + int usedsuf = 0; |
---|
| 16612 | + |
---|
16510 | 16613 | for (int i = 0; i < suffixes.length; i++) |
---|
16511 | 16614 | { |
---|
16512 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16513 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16514 | | - mipmapped, |
---|
16515 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16516 | | - if (data == null) |
---|
| 16615 | + String[] suffixe = suffixes; |
---|
| 16616 | + String[] fallback = suffixes2; |
---|
| 16617 | + String[] fallfallback = suffixes3; |
---|
| 16618 | + |
---|
| 16619 | + for (int c=usedsuf; --c>=0;) |
---|
16517 | 16620 | { |
---|
16518 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16621 | +// String[] temp = suffixe; |
---|
| 16622 | +// suffixe = fallback; |
---|
| 16623 | +// fallback = fallfallback; |
---|
| 16624 | +// fallfallback = temp; |
---|
16519 | 16625 | } |
---|
| 16626 | + |
---|
| 16627 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16628 | + TextureData data; |
---|
| 16629 | + |
---|
| 16630 | + try |
---|
| 16631 | + { |
---|
| 16632 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16633 | + mipmapped, |
---|
| 16634 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16635 | + } |
---|
| 16636 | + catch (Exception e) |
---|
| 16637 | + { |
---|
| 16638 | + try |
---|
| 16639 | + { |
---|
| 16640 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16641 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16642 | + mipmapped, |
---|
| 16643 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16644 | + } |
---|
| 16645 | + catch (Exception e2) |
---|
| 16646 | + { |
---|
| 16647 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16648 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16649 | + mipmapped, |
---|
| 16650 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16651 | + } |
---|
| 16652 | + } |
---|
| 16653 | + |
---|
16520 | 16654 | //System.out.println("Target = " + targets[i]); |
---|
16521 | 16655 | cubemap.updateImage(data, targets[i]); |
---|
16522 | 16656 | } |
---|
16523 | 16657 | |
---|
16524 | 16658 | return cubemap; |
---|
16525 | 16659 | } |
---|
| 16660 | + |
---|
16526 | 16661 | int bigsphere = -1; |
---|
16527 | 16662 | |
---|
16528 | 16663 | float BGcolor = 0.5f; |
---|
16529 | 16664 | |
---|
16530 | | - private void DrawSkyBox(GL gl) |
---|
| 16665 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16666 | + |
---|
| 16667 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16531 | 16668 | { |
---|
16532 | | - if (envyoff || cubemap == null) |
---|
| 16669 | + if (//envyoff || |
---|
| 16670 | + WIREFRAME || |
---|
| 16671 | + cubemap == null) |
---|
16533 | 16672 | { |
---|
16534 | 16673 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16535 | 16674 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16544 | 16683 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16545 | 16684 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16546 | 16685 | gl.glLoadIdentity(); |
---|
| 16686 | + gl.glScalef(1,ratio,1); |
---|
16547 | 16687 | |
---|
| 16688 | +// colorV[0] = 2; |
---|
| 16689 | +// colorV[1] = 2; |
---|
| 16690 | +// colorV[2] = 2; |
---|
| 16691 | +// colorV[3] = 1; |
---|
| 16692 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16693 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16694 | +// |
---|
| 16695 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16696 | + |
---|
16548 | 16697 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16549 | 16698 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16550 | 16699 | |
---|
.. | .. |
---|
16576 | 16725 | { |
---|
16577 | 16726 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16578 | 16727 | } |
---|
| 16728 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16579 | 16729 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16580 | 16730 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16581 | 16731 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16834 | 16984 | //new Exception().printStackTrace(); |
---|
16835 | 16985 | System.out.println("select buffer init"); |
---|
16836 | 16986 | // Use debug pipeline |
---|
16837 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16987 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16838 | 16988 | |
---|
16839 | 16989 | GL gl = drawable.getGL(); |
---|
16840 | 16990 | |
---|