.. | .. |
---|
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); |
---|
.. | .. |
---|
9699 | 9737 | |
---|
9700 | 9738 | if (renderCamera != lightCamera) |
---|
9701 | 9739 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9740 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9741 | |
---|
9704 | 9742 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9743 | |
---|
.. | .. |
---|
9715 | 9753 | |
---|
9716 | 9754 | if (renderCamera != lightCamera) |
---|
9717 | 9755 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9756 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9757 | |
---|
9720 | 9758 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9759 | |
---|
.. | .. |
---|
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, |
---|
.. | .. |
---|
10916 | 10956 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10957 | if (cam != lightCamera) |
---|
10918 | 10958 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10959 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10960 | |
---|
10921 | 10961 | for (int j = 0; j < 4; j++) |
---|
10922 | 10962 | { |
---|
.. | .. |
---|
10931 | 10971 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 10972 | if (cam != lightCamera) |
---|
10933 | 10973 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10974 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 10975 | |
---|
10936 | 10976 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 10977 | |
---|
.. | .. |
---|
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 = |
---|
| 12457 | + // Min shader |
---|
12403 | 12458 | "!!ARBfp1.0\n" + |
---|
| 12459 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12460 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12461 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12462 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 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];" + |
---|
| 12467 | + "TEMP temp;" + |
---|
| 12468 | + "TEMP light;" + |
---|
| 12469 | + "TEMP ndotl;" + |
---|
| 12470 | + "TEMP normal;" + |
---|
| 12471 | + "TEMP depth;" + |
---|
| 12472 | + "TEMP eye;" + |
---|
| 12473 | + "TEMP pos;" + |
---|
| 12474 | + |
---|
| 12475 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12476 | + Normalize("normal") + |
---|
| 12477 | + "MOV light, state.light[0].position;" + |
---|
| 12478 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12479 | + |
---|
| 12480 | + // shadow |
---|
| 12481 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12482 | + "MOV temp, pos;" + |
---|
| 12483 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12484 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12485 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12486 | + |
---|
| 12487 | + // No shadow when out of frustum |
---|
| 12488 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12489 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12490 | + |
---|
| 12491 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 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 |
---|
| 12511 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12512 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12513 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12514 | + |
---|
| 12515 | + "MUL temp, temp, zero123.z;" + |
---|
| 12516 | + |
---|
| 12517 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12518 | + |
---|
| 12519 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12520 | + "MOV result.color, temp;" + |
---|
| 12521 | + "END"; |
---|
| 12522 | + |
---|
| 12523 | + String programmax = |
---|
| 12524 | + "!!ARBfp1.0\n" + |
---|
| 12525 | + |
---|
12404 | 12526 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12527 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12528 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12637 | "TEMP shininess;" + |
---|
12516 | 12638 | "\n" + |
---|
12517 | 12639 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12640 | + |
---|
12520 | 12641 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12642 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12643 | /* |
---|
.. | .. |
---|
12537 | 12658 | "MUL temp, floor, mapgrid.x;" + |
---|
12538 | 12659 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12539 | 12660 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12540 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12661 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12541 | 12662 | "") + |
---|
12542 | 12663 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12543 | 12664 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12544 | 12665 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12545 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12666 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12546 | 12667 | "") + |
---|
12547 | 12668 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12548 | 12669 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12549 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12670 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12550 | 12671 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12551 | 12672 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12552 | 12673 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12553 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12674 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12554 | 12675 | "") + |
---|
12555 | 12676 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12556 | 12677 | //"MOV params, material;" + |
---|
.. | .. |
---|
12921 | 13042 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 13043 | "") + |
---|
12923 | 13044 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 13045 | + // display shadow only (fakedepth == 0) |
---|
12925 | 13046 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 13047 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | | - "SLT temp.z, temp.y, -one2048th.x;" + |
---|
| 13048 | + "SLT temp.z, temp.y, -c256i.x;" + |
---|
12928 | 13049 | "SUB temp.y, one.x, temp.z;" + |
---|
12929 | 13050 | "MUL temp.x, temp.x, temp.y;" + |
---|
12930 | 13051 | "KIL temp.x;" + |
---|
.. | .. |
---|
13255 | 13376 | //once = true; |
---|
13256 | 13377 | } |
---|
13257 | 13378 | |
---|
| 13379 | + String program = programmax; |
---|
| 13380 | + |
---|
| 13381 | + if (Globals.MINSHADER) |
---|
| 13382 | + { |
---|
| 13383 | + program = programmin; |
---|
| 13384 | + } |
---|
| 13385 | + |
---|
13258 | 13386 | System.out.print("Program #" + mode + "; instructions = " + program.split(";").length + "; length = " + program.length()); |
---|
13259 | 13387 | System.out.println(" - " + (mode >> 3) + " lights; " + ((mode & 2) == 2 ? "anisoUV " : "") + ((mode & 4) == 4 ? "SoftShadow " : "")); |
---|
13260 | 13388 | loadProgram(gl, GL.GL_FRAGMENT_PROGRAM_ARB, program); |
---|
.. | .. |
---|
13348 | 13476 | return out; |
---|
13349 | 13477 | } |
---|
13350 | 13478 | |
---|
13351 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13479 | + // Also does frustum culling |
---|
| 13480 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13352 | 13481 | { |
---|
13353 | 13482 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13483 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13484 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13485 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13486 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13487 | "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13357 | | - "SLT " + src + ".z, " + src + ".x, one.x;" + |
---|
13358 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
13359 | | - "SLT " + src + ".z, " + src + ".y, one.x;" + |
---|
13360 | | - "MUL " + src + ".w, " + src + ".z, " + src + ".w;" + |
---|
| 13488 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13489 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13490 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13491 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13492 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13493 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13494 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13495 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13496 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13497 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13498 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13499 | } |
---|
13371 | 13500 | |
---|
13372 | 13501 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13542 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13543 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13544 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13545 | + // No shadow when out of frustum |
---|
13417 | 13546 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13547 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13548 | ""; |
---|
.. | .. |
---|
14211 | 14340 | drag = false; |
---|
14212 | 14341 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14342 | editObj = false; |
---|
14214 | | - ClickInfo info = new ClickInfo(); |
---|
14215 | | - info.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14216 | | - info.pane = this; |
---|
14217 | | - info.camera = renderCamera; |
---|
14218 | | - info.x = x; |
---|
14219 | | - info.y = y; |
---|
14220 | | - info.modifiers = modifiersex; |
---|
14221 | | - editObj = object.doEditClick(info, 0); |
---|
| 14343 | + //ClickInfo info = new ClickInfo(); |
---|
| 14344 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14345 | + object.clickInfo.pane = this; |
---|
| 14346 | + object.clickInfo.camera = renderCamera; |
---|
| 14347 | + object.clickInfo.x = x; |
---|
| 14348 | + object.clickInfo.y = y; |
---|
| 14349 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14350 | + editObj = object.doEditClick(//info, |
---|
| 14351 | + 0); |
---|
14222 | 14352 | if (!editObj) |
---|
14223 | 14353 | { |
---|
14224 | 14354 | hasMarquee = true; |
---|
.. | .. |
---|
14618 | 14748 | if (editObj) |
---|
14619 | 14749 | { |
---|
14620 | 14750 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14751 | + //ClickInfo info = new ClickInfo(); |
---|
| 14752 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14753 | (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14624 | | - info.pane = this; |
---|
14625 | | - info.camera = renderCamera; |
---|
14626 | | - info.x = x; |
---|
14627 | | - info.y = y; |
---|
14628 | | - object.GetWindow().copy |
---|
14629 | | - .doEditDrag(info, (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
| 14754 | + object.clickInfo.pane = this; |
---|
| 14755 | + object.clickInfo.camera = renderCamera; |
---|
| 14756 | + object.clickInfo.x = x; |
---|
| 14757 | + object.clickInfo.y = y; |
---|
| 14758 | + object //.GetWindow().copy |
---|
| 14759 | + .doEditDrag(//info, |
---|
| 14760 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14761 | } else |
---|
14631 | 14762 | { |
---|
14632 | 14763 | if (x < startX) |
---|
.. | .. |
---|
14775 | 14906 | } |
---|
14776 | 14907 | } |
---|
14777 | 14908 | |
---|
| 14909 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14910 | + |
---|
14778 | 14911 | public void mouseMoved(MouseEvent e) |
---|
14779 | 14912 | { |
---|
14780 | 14913 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 14914 | if (isRenderer) |
---|
14782 | 14915 | return; |
---|
14783 | 14916 | |
---|
14784 | | - ClickInfo ci = new ClickInfo(); |
---|
14785 | | - ci.x = e.getX(); |
---|
14786 | | - ci.y = e.getY(); |
---|
14787 | | - ci.modifiers = e.getModifiersEx(); |
---|
14788 | | - ci.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
14789 | | - ci.pane = this; |
---|
14790 | | - ci.camera = renderCamera; |
---|
| 14917 | + // Mouse cursor feedback |
---|
| 14918 | + object.clickInfo.x = e.getX(); |
---|
| 14919 | + object.clickInfo.y = e.getY(); |
---|
| 14920 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14921 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14922 | + object.clickInfo.pane = this; |
---|
| 14923 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 14924 | if (!isRenderer) |
---|
14792 | 14925 | { |
---|
14793 | 14926 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 14927 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 14928 | + if (object.doEditClick(//clickInfo, |
---|
| 14929 | + 0)) |
---|
14796 | 14930 | { |
---|
14797 | 14931 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 14932 | } else |
---|
.. | .. |
---|
15242 | 15376 | OCCLUSION_CULLING ^= true; |
---|
15243 | 15377 | System.out.println("OCCLUSION CULLING = " + OCCLUSION_CULLING); |
---|
15244 | 15378 | break; |
---|
15245 | | - case '0': envyoff ^= true; repaint(); break; |
---|
| 15379 | + //case '0': envyoff ^= true; repaint(); break; |
---|
15246 | 15380 | case '1': |
---|
15247 | 15381 | case '2': |
---|
15248 | 15382 | case '3': |
---|
15249 | 15383 | case '4': |
---|
15250 | 15384 | case '5': |
---|
15251 | | - newenvy = Character.getNumericValue(key); |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | 15385 | case '6': |
---|
15255 | 15386 | case '7': |
---|
15256 | 15387 | case '8': |
---|
15257 | 15388 | case '9': |
---|
15258 | | - 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 | + } |
---|
15259 | 15397 | repaint(); |
---|
15260 | 15398 | break; |
---|
15261 | 15399 | case '!': |
---|
.. | .. |
---|
15818 | 15956 | |
---|
15819 | 15957 | int width = getBounds().width; |
---|
15820 | 15958 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 15959 | //Image img = CreateImage(width, height); |
---|
15824 | 15960 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 15961 | |
---|
.. | .. |
---|
15896 | 16032 | } |
---|
15897 | 16033 | if (object != null && !hasMarquee) |
---|
15898 | 16034 | { |
---|
| 16035 | + if (object.clickInfo == null) |
---|
| 16036 | + object.clickInfo = new ClickInfo(); |
---|
| 16037 | + ClickInfo info = object.clickInfo; |
---|
| 16038 | + //ClickInfo info = new ClickInfo(); |
---|
| 16039 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16040 | + |
---|
15899 | 16041 | if (isRenderer) |
---|
15900 | 16042 | { |
---|
15901 | | - info.flags++; |
---|
| 16043 | + object.clickInfo.flags++; |
---|
15902 | 16044 | double frameAspect = (double) width / (double) height; |
---|
15903 | 16045 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 16046 | { |
---|
15905 | 16047 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16048 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16049 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 16050 | } else |
---|
15909 | 16051 | { |
---|
15910 | 16052 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16053 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16054 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 16055 | } |
---|
15914 | 16056 | } |
---|
15915 | 16057 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 16058 | + object.clickInfo.g = gr; |
---|
| 16059 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 16060 | /* |
---|
15919 | 16061 | // Memory intensive (brep.verticescopy) |
---|
15920 | 16062 | if (!(object instanceof Composite)) |
---|
15921 | 16063 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 16064 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 16065 | + if (!isRenderer) // && drag) |
---|
15924 | 16066 | { |
---|
15925 | 16067 | Grafreed.Assert(object != null); |
---|
15926 | 16068 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 16070 | { |
---|
15929 | 16071 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 16072 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 16073 | + object.clickInfo.DX = 0; |
---|
| 16074 | + object.clickInfo.DY = 0; |
---|
| 16075 | + object.clickInfo.W = 1; |
---|
15934 | 16076 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 16077 | { |
---|
15936 | 16078 | info.DX = X; |
---|
.. | .. |
---|
15942 | 16084 | info.DY -= info.bounds.height/2; |
---|
15943 | 16085 | } |
---|
15944 | 16086 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 16087 | + object.drawEditHandles(//info, |
---|
| 16088 | + 0); |
---|
15946 | 16089 | |
---|
15947 | 16090 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16091 | { |
---|
.. | .. |
---|
16441 | 16584 | private /*static*/ boolean firstime; |
---|
16442 | 16585 | private /*static*/ cVector newView = new cVector(); |
---|
16443 | 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"}; |
---|
16444 | 16589 | private static final int[] targets = {GL.GL_TEXTURE_CUBE_MAP_POSITIVE_X, |
---|
16445 | 16590 | GL.GL_TEXTURE_CUBE_MAP_NEGATIVE_X, |
---|
16446 | 16591 | GL.GL_TEXTURE_CUBE_MAP_POSITIVE_Y, |
---|
.. | .. |
---|
16453 | 16598 | { |
---|
16454 | 16599 | com.sun.opengl.util.texture.Texture cubemap = TextureIO.newTexture(GL.GL_TEXTURE_CUBE_MAP); |
---|
16455 | 16600 | |
---|
| 16601 | + int usedsuf = 0; |
---|
| 16602 | + |
---|
16456 | 16603 | for (int i = 0; i < suffixes.length; i++) |
---|
16457 | 16604 | { |
---|
16458 | | - String resourceName = basename + suffixes[i] + "." + suffix; |
---|
16459 | | - TextureData data = TextureIO.newTextureData(scope.getResourceAsStream(resourceName), |
---|
16460 | | - mipmapped, |
---|
16461 | | - FileUtil.getFileSuffix(resourceName)); |
---|
16462 | | - if (data == null) |
---|
| 16605 | + String[] suffixe = suffixes; |
---|
| 16606 | + String[] fallback = suffixes2; |
---|
| 16607 | + String[] fallfallback = suffixes3; |
---|
| 16608 | + |
---|
| 16609 | + for (int c=usedsuf; --c>=0;) |
---|
16463 | 16610 | { |
---|
16464 | | - throw new IOException("Unable to load texture " + resourceName); |
---|
| 16611 | +// String[] temp = suffixe; |
---|
| 16612 | +// suffixe = fallback; |
---|
| 16613 | +// fallback = fallfallback; |
---|
| 16614 | +// fallfallback = temp; |
---|
16465 | 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 | + |
---|
16466 | 16644 | //System.out.println("Target = " + targets[i]); |
---|
16467 | 16645 | cubemap.updateImage(data, targets[i]); |
---|
16468 | 16646 | } |
---|
16469 | 16647 | |
---|
16470 | 16648 | return cubemap; |
---|
16471 | 16649 | } |
---|
| 16650 | + |
---|
16472 | 16651 | int bigsphere = -1; |
---|
16473 | 16652 | |
---|
16474 | 16653 | float BGcolor = 0.5f; |
---|
16475 | 16654 | |
---|
16476 | | - private void DrawSkyBox(GL gl) |
---|
| 16655 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16656 | + |
---|
| 16657 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16477 | 16658 | { |
---|
16478 | | - if (envyoff || cubemap == null) |
---|
| 16659 | + if (//envyoff || |
---|
| 16660 | + cubemap == null) |
---|
16479 | 16661 | { |
---|
16480 | 16662 | gl.glClearColor(BGcolor, BGcolor, BGcolor, 1); |
---|
16481 | 16663 | gl.glClear(gl.GL_COLOR_BUFFER_BIT); |
---|
.. | .. |
---|
16490 | 16672 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16491 | 16673 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16492 | 16674 | gl.glLoadIdentity(); |
---|
| 16675 | + gl.glScalef(1,ratio,1); |
---|
16493 | 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 | + |
---|
16494 | 16686 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16495 | 16687 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16496 | 16688 | |
---|
.. | .. |
---|
16522 | 16714 | { |
---|
16523 | 16715 | gl.glScalef(1.0f, -1.0f, 1.0f); |
---|
16524 | 16716 | } |
---|
| 16717 | + gl.glScalef(-1.0f, 1.0f, 1.0f); |
---|
16525 | 16718 | gl.glMultMatrixd(viewrot_1, 0); |
---|
16526 | 16719 | gl.glTranslatef(0, 0, 0.5f); // (float)lightCamera.Distance()); // 0.5f); |
---|
16527 | 16720 | //viewer.updateInverseRotation(gl); |
---|
.. | .. |
---|
16780 | 16973 | //new Exception().printStackTrace(); |
---|
16781 | 16974 | System.out.println("select buffer init"); |
---|
16782 | 16975 | // Use debug pipeline |
---|
16783 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16976 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16784 | 16977 | |
---|
16785 | 16978 | GL gl = drawable.getGL(); |
---|
16786 | 16979 | |
---|