.. | .. |
---|
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 | { |
---|
.. | .. |
---|
8931 | 8944 | |
---|
8932 | 8945 | if (cubemap == null) |
---|
8933 | 8946 | { |
---|
8934 | | - LoadEnvy(5); |
---|
| 8947 | + //LoadEnvy(1); |
---|
8935 | 8948 | } |
---|
8936 | 8949 | |
---|
8937 | 8950 | //cubemap.enable(); |
---|
.. | .. |
---|
9218 | 9231 | cubemap = null; |
---|
9219 | 9232 | return; |
---|
9220 | 9233 | case 1: |
---|
9221 | | - name = "cubemaps/box_"; |
---|
9222 | | - ext = "png"; |
---|
| 9234 | + name = "cubemaps/rgb/"; |
---|
| 9235 | + ext = "jpg"; |
---|
9223 | 9236 | reverseUP = false; |
---|
9224 | 9237 | break; |
---|
9225 | 9238 | case 2: |
---|
9226 | | - name = "cubemaps/uffizi_"; |
---|
9227 | | - ext = "png"; |
---|
9228 | | - break; // reverseUP = true; break; |
---|
| 9239 | + name = "cubemaps/uffizi/"; |
---|
| 9240 | + ext = "jpg"; |
---|
| 9241 | + reverseUP = false; |
---|
| 9242 | + break; |
---|
9229 | 9243 | case 3: |
---|
9230 | | - name = "cubemaps/CloudyHills_"; |
---|
9231 | | - ext = "tga"; |
---|
| 9244 | + name = "cubemaps/CloudyHills/"; |
---|
| 9245 | + ext = "jpg"; |
---|
9232 | 9246 | reverseUP = false; |
---|
9233 | 9247 | break; |
---|
9234 | 9248 | case 4: |
---|
9235 | | - name = "cubemaps/cornell_"; |
---|
| 9249 | + name = "cubemaps/cornell/"; |
---|
9236 | 9250 | ext = "png"; |
---|
9237 | 9251 | reverseUP = false; |
---|
9238 | 9252 | break; |
---|
| 9253 | + case 5: |
---|
| 9254 | + name = "cubemaps/skycube/"; |
---|
| 9255 | + ext = "jpg"; |
---|
| 9256 | + reverseUP = false; |
---|
| 9257 | + break; |
---|
| 9258 | + case 6: |
---|
| 9259 | + name = "cubemaps/SaintLazarusChurch3/"; |
---|
| 9260 | + ext = "jpg"; |
---|
| 9261 | + reverseUP = false; |
---|
| 9262 | + break; |
---|
| 9263 | + case 7: |
---|
| 9264 | + name = "cubemaps/Sodermalmsallen/"; |
---|
| 9265 | + ext = "jpg"; |
---|
| 9266 | + reverseUP = false; |
---|
| 9267 | + break; |
---|
| 9268 | + case 8: |
---|
| 9269 | + name = "cubemaps/Sodermalmsallen2/"; |
---|
| 9270 | + ext = "jpg"; |
---|
| 9271 | + reverseUP = false; |
---|
| 9272 | + break; |
---|
| 9273 | + case 9: |
---|
| 9274 | + name = "cubemaps/UnionSquare/"; |
---|
| 9275 | + ext = "jpg"; |
---|
| 9276 | + reverseUP = false; |
---|
| 9277 | + break; |
---|
9239 | 9278 | default: |
---|
9240 | | - name = "cubemaps/rgb_"; |
---|
9241 | | - ext = "png"; /*mipmap = true;*/ reverseUP = false; |
---|
| 9279 | + name = "cubemaps/box/"; |
---|
| 9280 | + ext = "png"; /*mipmap = true;*/ |
---|
| 9281 | + reverseUP = false; |
---|
9242 | 9282 | break; |
---|
9243 | 9283 | } |
---|
9244 | | - |
---|
9245 | | - try |
---|
9246 | | - { |
---|
9247 | | - cubemap = LoadCubemap(getClass().getClassLoader(), name, ext, mipmap); |
---|
9248 | | - } catch (IOException e) |
---|
9249 | | - { |
---|
9250 | | - throw new RuntimeException(e); |
---|
9251 | | - } |
---|
| 9284 | + |
---|
| 9285 | + LoadSkybox(name, ext, mipmap); |
---|
9252 | 9286 | } |
---|
9253 | 9287 | |
---|
9254 | 9288 | public void reshape(GLAutoDrawable drawable, int x, int y, int width, int height) |
---|
.. | .. |
---|
9280 | 9314 | static double[] model = new double[16]; |
---|
9281 | 9315 | double[] camera2light = new double[16]; |
---|
9282 | 9316 | double[] light2camera = new double[16]; |
---|
9283 | | - int newenvy = -1; |
---|
9284 | | - boolean envyoff = true; // false; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
| 9319 | + //boolean envyoff = false; |
---|
| 9320 | + |
---|
| 9321 | + String loadedskyboxname; |
---|
| 9322 | + |
---|
9285 | 9323 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9324 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9325 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9761 | 9799 | rati = 1 / rati; |
---|
9762 | 9800 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9801 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9802 | + |
---|
| 9803 | + //assert (newenvy == -1); |
---|
| 9804 | + |
---|
9765 | 9805 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9806 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9807 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9808 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9809 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9810 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
11017 | 11057 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11058 | } |
---|
11019 | 11059 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11060 | +// if (newenvy > -1) |
---|
| 11061 | +// { |
---|
| 11062 | +// LoadEnvy(newenvy); |
---|
| 11063 | +// } |
---|
| 11064 | +// |
---|
| 11065 | +// newenvy = -1; |
---|
| 11066 | + |
---|
| 11067 | + if (object.skyboxname != null) |
---|
11021 | 11068 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11069 | + if (!object.skyboxname.equals(this.loadedskyboxname)) |
---|
| 11070 | + { |
---|
| 11071 | + LoadSkybox(object.skyboxname + "/", object.skyboxext, false); |
---|
| 11072 | + loadedskyboxname = object.skyboxname; |
---|
| 11073 | + } |
---|
11023 | 11074 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11075 | + else |
---|
| 11076 | + { |
---|
| 11077 | + cubemap = null; |
---|
| 11078 | + loadedskyboxname = null; |
---|
| 11079 | + } |
---|
| 11080 | + |
---|
11027 | 11081 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11082 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11083 | |
---|
.. | .. |
---|
11039 | 11093 | |
---|
11040 | 11094 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11095 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11096 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11097 | } |
---|
11044 | 11098 | |
---|
11045 | 11099 | //if (selection_view == -1) |
---|
.. | .. |
---|
12399 | 12453 | |
---|
12400 | 12454 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12455 | |
---|
12402 | | - String program = |
---|
| 12456 | + String programmin = |
---|
12403 | 12457 | // Min shader |
---|
12404 | 12458 | "!!ARBfp1.0\n" + |
---|
12405 | | - "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
12406 | 12460 | "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
12407 | 12461 | "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
12408 | 12462 | "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
12409 | 12463 | "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12464 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12465 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12466 | + "PARAM light2cam2 = program.env[12];" + |
---|
12410 | 12467 | "TEMP temp;" + |
---|
12411 | 12468 | "TEMP light;" + |
---|
12412 | 12469 | "TEMP ndotl;" + |
---|
12413 | 12470 | "TEMP normal;" + |
---|
12414 | 12471 | "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
12415 | 12474 | |
---|
12416 | 12475 | "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
12417 | | - |
---|
| 12476 | + Normalize("normal") + |
---|
12418 | 12477 | "MOV light, state.light[0].position;" + |
---|
12419 | 12478 | "DP3 ndotl.x, light, normal;" + |
---|
12420 | 12479 | |
---|
12421 | 12480 | // shadow |
---|
12422 | | - "MOV temp, fragment.texcoord[1];" + |
---|
12423 | | - TextureFetch("depth", "temp", "1") + |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
12424 | 12484 | //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
12425 | | - "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
12426 | | - |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
12427 | 12486 | |
---|
12428 | 12487 | // No shadow when out of frustum |
---|
12429 | 12488 | //"SGE temp.y, depth.z, zero123.y;" + |
---|
12430 | 12489 | //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
12431 | 12490 | |
---|
12432 | | - "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
12433 | | - "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
12434 | 12492 | |
---|
| 12493 | + // Backlit |
---|
| 12494 | + "MOV pos.w, zero123.y;" + |
---|
| 12495 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12496 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12497 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12498 | + Normalize("eye") + |
---|
| 12499 | + |
---|
| 12500 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12501 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12502 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12503 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12504 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12505 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12506 | + |
---|
| 12507 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12508 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12509 | + |
---|
| 12510 | + // Pigment |
---|
12435 | 12511 | "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12436 | 12512 | "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
12437 | 12513 | "MUL temp, temp, ndotl.x;" + |
---|
12438 | 12514 | |
---|
12439 | 12515 | "MUL temp, temp, zero123.z;" + |
---|
12440 | 12516 | |
---|
12441 | | - "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
12442 | 12518 | |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
12443 | 12520 | "MOV result.color, temp;" + |
---|
12444 | 12521 | "END"; |
---|
12445 | 12522 | |
---|
12446 | | - String program2 = |
---|
| 12523 | + String programmax = |
---|
12447 | 12524 | "!!ARBfp1.0\n" + |
---|
12448 | 12525 | |
---|
12449 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
.. | .. |
---|
12581 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
12582 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12583 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12584 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12585 | 12662 | "") + |
---|
12586 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12587 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12588 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12589 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12590 | 12667 | "") + |
---|
12591 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12592 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12593 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12594 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12595 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12596 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12597 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12598 | 12675 | "") + |
---|
12599 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12600 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
12968 | 13045 | // display shadow only (fakedepth == 0) |
---|
12969 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
12970 | 13047 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12971 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12972 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
12973 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
12974 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
13299 | 13376 | //once = true; |
---|
13300 | 13377 | } |
---|
13301 | 13378 | |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
13302 | 13386 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13303 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13304 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13392 | 13476 | return out; |
---|
13393 | 13477 | } |
---|
13394 | 13478 | |
---|
13395 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13396 | 13481 | { |
---|
13397 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13398 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
.. | .. |
---|
15291 | 15376 | OCCLUSION_CULLING ^= true; |
---|
15292 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15293 | 15378 | break; |
---|
15294 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15295 | 15380 | case '1': |
---|
15296 | 15381 | case '2': |
---|
15297 | 15382 | case '3': |
---|
15298 | 15383 | case '4': |
---|
15299 | 15384 | case '5': |
---|
15300 | | - newenvy = Character.getNumericValue(key); |
---|
15301 | | - repaint(); |
---|
15302 | | - break; |
---|
15303 | 15385 | case '6': |
---|
15304 | 15386 | case '7': |
---|
15305 | 15387 | case '8': |
---|
15306 | 15388 | case '9': |
---|
15307 | | - BGcolor = (key - '6')/3.f; |
---|
| 15389 | + if (true) // envyoff) |
---|
| 15390 | + { |
---|
| 15391 | + BGcolor = (key - '1')/8.f; |
---|
| 15392 | + } |
---|
| 15393 | + else |
---|
| 15394 | + { |
---|
| 15395 | + //newenvy = Character.getNumericValue(key); |
---|
| 15396 | + } |
---|
15308 | 15397 | repaint(); |
---|
15309 | 15398 | break; |
---|
15310 | 15399 | case '!': |
---|
.. | .. |
---|
16009 | 16098 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16010 | 16099 | break; |
---|
16011 | 16100 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
16012 | | - gr.drawLine(X, Y, 0, 0); |
---|
| 16101 | + gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
16013 | 16102 | break; |
---|
16014 | 16103 | } |
---|
16015 | 16104 | |
---|
.. | .. |
---|
16495 | 16584 | private /*static*/ boolean firstime; |
---|
16496 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
16497 | 16586 | private static final String[] suffixes = {"posx", "negx", "posy", "negy", "posz", "negz"}; |
---|
| 16587 | + private static final String[] suffixes2 = {"east", "west", "top", "bottom", "north", "south"}; |
---|
| 16588 | + private static final String[] suffixes3 = {"ft", "bk", "up", "dn", "rt", "lf"}; |
---|
16498 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16499 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16500 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16507 | 16598 | { |
---|
16508 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16509 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
16510 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
16511 | 16604 | { |
---|
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) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
16517 | 16610 | { |
---|
16518 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
16519 | 16615 | } |
---|
| 16616 | + |
---|
| 16617 | + String resourceName = basename + suffixe[i] + "." + suffix; |
---|
| 16618 | + TextureData data; |
---|
| 16619 | + |
---|
| 16620 | + try |
---|
| 16621 | + { |
---|
| 16622 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16623 | + mipmapped, |
---|
| 16624 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16625 | + } |
---|
| 16626 | + catch (Exception e) |
---|
| 16627 | + { |
---|
| 16628 | + try |
---|
| 16629 | + { |
---|
| 16630 | + resourceName = basename + fallback[i] + "." + suffix; |
---|
| 16631 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16632 | + mipmapped, |
---|
| 16633 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16634 | + } |
---|
| 16635 | + catch (Exception e2) |
---|
| 16636 | + { |
---|
| 16637 | + resourceName = basename + fallfallback[i] + "." + suffix; |
---|
| 16638 | + data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
| 16639 | + mipmapped, |
---|
| 16640 | + FileUtil.getFileSuffix(resourceName)); |
---|
| 16641 | + } |
---|
| 16642 | + } |
---|
| 16643 | + |
---|
16520 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
16521 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
16522 | 16646 | } |
---|
16523 | 16647 | |
---|
16524 | 16648 | return cubemap; |
---|
16525 | 16649 | } |
---|
| 16650 | + |
---|
16526 | 16651 | int bigsphere = -1; |
---|
16527 | 16652 | |
---|
16528 | 16653 | float BGcolor = 0.5f; |
---|
16529 | 16654 | |
---|
16530 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16531 | 16658 | { |
---|
16532 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
16533 | 16661 | { |
---|
16534 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16535 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16544 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16545 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16546 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
16547 | 16676 | |
---|
| 16677 | +// colorV[0] = 2; |
---|
| 16678 | +// colorV[1] = 2; |
---|
| 16679 | +// colorV[2] = 2; |
---|
| 16680 | +// colorV[3] = 1; |
---|
| 16681 | +// gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16682 | +// gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16683 | +// |
---|
| 16684 | +// gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16685 | + |
---|
16548 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16549 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16550 | 16688 | |
---|
.. | .. |
---|
16576 | 16714 | { |
---|
16577 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16578 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16579 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16580 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16581 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16834 | 16973 | //new Exception().printStackTrace(); |
---|
16835 | 16974 | System.out.println("select buffer init"); |
---|
16836 | 16975 | // Use debug pipeline |
---|
16837 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16838 | 16977 | |
---|
16839 | 16978 | GL gl = drawable.getGL(); |
---|
16840 | 16979 | |
---|