.. | .. |
---|
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; |
---|
| 9317 | + |
---|
| 9318 | + //int newenvy = -1; |
---|
9284 | 9319 | boolean envyoff = true; // false; |
---|
| 9320 | + String skyboxname = ""; |
---|
| 9321 | + String skyboxext; |
---|
| 9322 | + String loadedskyboxname = ""; |
---|
| 9323 | + |
---|
9285 | 9324 | cVector light0 = new cVector(0, 0, 0); // 1,3,2); |
---|
9286 | 9325 | //float[] light0 = { 0,0,0 }; |
---|
9287 | 9326 | cVector dirlight = new cVector(0, 0, 1); // 1,3,2); |
---|
.. | .. |
---|
9699 | 9738 | |
---|
9700 | 9739 | if (renderCamera != lightCamera) |
---|
9701 | 9740 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9702 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 9741 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
9703 | 9742 | |
---|
9704 | 9743 | // LA.matConcat(renderCamera.toScreen, renderCamera.toParent, matrix); |
---|
9705 | 9744 | |
---|
.. | .. |
---|
9715 | 9754 | |
---|
9716 | 9755 | if (renderCamera != lightCamera) |
---|
9717 | 9756 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
9718 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 9757 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
9719 | 9758 | |
---|
9720 | 9759 | // LA.matConcat(renderCamera.fromParent, renderCamera.fromScreen, matrix); |
---|
9721 | 9760 | |
---|
.. | .. |
---|
9761 | 9800 | rati = 1 / rati; |
---|
9762 | 9801 | gl.glOrtho(-skyscale / rati, skyscale / rati, -skyscale, skyscale, 0.001, 1000); |
---|
9763 | 9802 | } |
---|
9764 | | - assert (newenvy == -1); |
---|
| 9803 | + |
---|
| 9804 | + //assert (newenvy == -1); |
---|
| 9805 | + |
---|
9765 | 9806 | gl.glDisable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9766 | 9807 | gl.glDisable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9767 | | - DrawSkyBox(gl); |
---|
| 9808 | + DrawSkyBox(gl, (float)rati); |
---|
9768 | 9809 | gl.glEnable(GL.GL_FRAGMENT_PROGRAM_ARB); |
---|
9769 | 9810 | gl.glEnable(GL.GL_VERTEX_PROGRAM_ARB); |
---|
9770 | 9811 | accPerspective(gl, renderCamera.shaper_fovy / ratio, |
---|
.. | .. |
---|
10916 | 10957 | // if (parentcam != renderCamera) // not a light |
---|
10917 | 10958 | if (cam != lightCamera) |
---|
10918 | 10959 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10919 | | - LA.matConcat(matrix, parentcam.GlobalTransform(), matrix); |
---|
| 10960 | + LA.matConcat(matrix, parentcam.GlobalTransformInv(), matrix); |
---|
10920 | 10961 | |
---|
10921 | 10962 | for (int j = 0; j < 4; j++) |
---|
10922 | 10963 | { |
---|
.. | .. |
---|
10931 | 10972 | // if (parentcam != renderCamera) // not a light |
---|
10932 | 10973 | if (cam != lightCamera) |
---|
10933 | 10974 | //for (int count = parentcam.GetTransformCount(); --count>=0;) |
---|
10934 | | - LA.matConcat(parentcam.GlobalTransformInv(), matrix, matrix); |
---|
| 10975 | + LA.matConcat(parentcam.GlobalTransform(), matrix, matrix); |
---|
10935 | 10976 | |
---|
10936 | 10977 | //LA.matConcat(cam.fromScreen, parentcam.fromParent, matrix); |
---|
10937 | 10978 | |
---|
.. | .. |
---|
11017 | 11058 | gl.glOrtho(-skyscale / ratio, skyscale / ratio, -skyscale, skyscale, 0.001, 1000); |
---|
11018 | 11059 | } |
---|
11019 | 11060 | |
---|
11020 | | - if (newenvy > -1) |
---|
| 11061 | +// if (newenvy > -1) |
---|
| 11062 | +// { |
---|
| 11063 | +// LoadEnvy(newenvy); |
---|
| 11064 | +// } |
---|
| 11065 | +// |
---|
| 11066 | +// newenvy = -1; |
---|
| 11067 | + |
---|
| 11068 | + if (!skyboxname.equals(this.loadedskyboxname)) |
---|
11021 | 11069 | { |
---|
11022 | | - LoadEnvy(newenvy); |
---|
| 11070 | + LoadSkybox(skyboxname + "/", skyboxext, false); |
---|
| 11071 | + loadedskyboxname = skyboxname; |
---|
11023 | 11072 | } |
---|
11024 | | - |
---|
11025 | | - newenvy = -1; |
---|
11026 | | - |
---|
| 11073 | + |
---|
11027 | 11074 | ratio = ((double) getWidth()) / getHeight(); |
---|
11028 | 11075 | //System.out.println("ratio = " + ratio); |
---|
11029 | 11076 | |
---|
.. | .. |
---|
11039 | 11086 | |
---|
11040 | 11087 | if (!IsFrozen() && !ambientOcclusion) |
---|
11041 | 11088 | { |
---|
11042 | | - DrawSkyBox(gl); |
---|
| 11089 | + DrawSkyBox(gl, (float)ratio); |
---|
11043 | 11090 | } |
---|
11044 | 11091 | |
---|
11045 | 11092 | //if (selection_view == -1) |
---|
.. | .. |
---|
12399 | 12446 | |
---|
12400 | 12447 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12448 | |
---|
| 12449 | + String program0 = |
---|
| 12450 | + // Min shader |
---|
| 12451 | + "!!ARBfp1.0\n" + |
---|
| 12452 | + "PARAM zero123 = { 0.0, 1.0, 2, 1.25 };" + |
---|
| 12453 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12454 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12455 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12456 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12457 | + "PARAM light2cam0 = program.env[10];" + |
---|
| 12458 | + "PARAM light2cam1 = program.env[11];" + |
---|
| 12459 | + "PARAM light2cam2 = program.env[12];" + |
---|
| 12460 | + "TEMP temp;" + |
---|
| 12461 | + "TEMP light;" + |
---|
| 12462 | + "TEMP ndotl;" + |
---|
| 12463 | + "TEMP normal;" + |
---|
| 12464 | + "TEMP depth;" + |
---|
| 12465 | + "TEMP eye;" + |
---|
| 12466 | + "TEMP pos;" + |
---|
| 12467 | + |
---|
| 12468 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12469 | + Normalize("normal") + |
---|
| 12470 | + "MOV light, state.light[0].position;" + |
---|
| 12471 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12472 | + |
---|
| 12473 | + // shadow |
---|
| 12474 | + "MOV pos, fragment.texcoord[1];" + |
---|
| 12475 | + "MOV temp, pos;" + |
---|
| 12476 | + ShadowTextureFetch("depth", "temp", "1") + |
---|
| 12477 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12478 | + "SLT ndotl.z, fragment.texcoord[1].z, depth.z;" + |
---|
| 12479 | + |
---|
| 12480 | + // No shadow when out of frustum |
---|
| 12481 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12482 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12483 | + |
---|
| 12484 | + "MUL ndotl.x, ndotl.x, ndotl.z;" + // Shadow |
---|
| 12485 | + |
---|
| 12486 | + // Backlit |
---|
| 12487 | + "MOV pos.w, zero123.y;" + |
---|
| 12488 | + "DP4 eye.x, pos, light2cam0;" + |
---|
| 12489 | + "DP4 eye.y, pos, light2cam1;" + |
---|
| 12490 | + "DP4 eye.z, pos, light2cam2;" + |
---|
| 12491 | + Normalize("eye") + |
---|
| 12492 | + |
---|
| 12493 | + "DP3 ndotl.y, -eye, normal;" + |
---|
| 12494 | + //"MUL ndotl.y, ndotl.y, pow2.x;" + |
---|
| 12495 | + "POW ndotl.y, ndotl.y, pow2.z;" + // backlit |
---|
| 12496 | + "SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12497 | + //"SUB ndotl.y, zero123.y, ndotl.y;" + |
---|
| 12498 | + //"MUL ndotl.y, ndotl.y, pow2.z;" + |
---|
| 12499 | + |
---|
| 12500 | + //"MAX ndotl.x, ndotl.x, ndotl.y;" + // Ambient |
---|
| 12501 | + //"MAX ndotl.x, ndotl.x, pow2.y;" + // Ambient |
---|
| 12502 | + |
---|
| 12503 | + // Pigment |
---|
| 12504 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12505 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12506 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12507 | + |
---|
| 12508 | + "MUL temp, temp, zero123.z;" + |
---|
| 12509 | + |
---|
| 12510 | + //"MUL temp, temp, ndotl.y;" + |
---|
| 12511 | + |
---|
| 12512 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12513 | + "MOV result.color, temp;" + |
---|
| 12514 | + "END"; |
---|
| 12515 | + |
---|
12402 | 12516 | String program = |
---|
12403 | 12517 | "!!ARBfp1.0\n" + |
---|
| 12518 | + |
---|
12404 | 12519 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12520 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12521 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12630 | "TEMP shininess;" + |
---|
12516 | 12631 | "\n" + |
---|
12517 | 12632 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12633 | + |
---|
12520 | 12634 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12635 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12636 | /* |
---|
.. | .. |
---|
12537 | 12651 | "MUL temp, floor, mapgrid.x;" + |
---|
12538 | 12652 | //"TEX depth0, temp, texture[1], 2D;" + |
---|
12539 | 12653 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12540 | | - TextureFetch("depth0", "temp", "1") + |
---|
| 12654 | + ShadowTextureFetch("depth0", "temp", "1") + |
---|
12541 | 12655 | "") + |
---|
12542 | 12656 | "ADD temp.x, temp.x, mapgrid.x;" + |
---|
12543 | 12657 | //"TEX depth1, temp, texture[1], 2D;" + |
---|
12544 | 12658 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12545 | | - TextureFetch("depth1", "temp", "1") + |
---|
| 12659 | + ShadowTextureFetch("depth1", "temp", "1") + |
---|
12546 | 12660 | "") + |
---|
12547 | 12661 | "ADD temp.y, temp.y, mapgrid.x;" + |
---|
12548 | 12662 | //"TEX depth2, temp, texture[1], 2D;" + |
---|
12549 | | - TextureFetch("depth2", "temp", "1") + |
---|
| 12663 | + ShadowTextureFetch("depth2", "temp", "1") + |
---|
12550 | 12664 | "SUB temp.x, temp.x, mapgrid.x;" + |
---|
12551 | 12665 | //"TEX depth3, temp, texture[1], 2D;" + |
---|
12552 | 12666 | (((mode & FP_SOFTSHADOW) == 0) ? "" : |
---|
12553 | | - TextureFetch("depth3", "temp", "1") + |
---|
| 12667 | + ShadowTextureFetch("depth3", "temp", "1") + |
---|
12554 | 12668 | "") + |
---|
12555 | 12669 | //"MUL texSamp0, texSamp0, state.material.front.diffuse;" + |
---|
12556 | 12670 | //"MOV params, material;" + |
---|
.. | .. |
---|
12921 | 13035 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 13036 | "") + |
---|
12923 | 13037 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 13038 | + // display shadow only (fakedepth == 0) |
---|
12925 | 13039 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 13040 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | 13041 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13348 | 13462 | return out; |
---|
13349 | 13463 | } |
---|
13350 | 13464 | |
---|
13351 | | - String TextureFetch(String dest, String src, String unit) |
---|
| 13465 | + // Also does frustum culling |
---|
| 13466 | + String ShadowTextureFetch(String dest, String src, String unit) |
---|
13352 | 13467 | { |
---|
13353 | 13468 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13469 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13470 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13471 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13472 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13473 | "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;" + |
---|
| 13474 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13475 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13476 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13477 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13478 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13479 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13480 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13481 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13482 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13483 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13484 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13485 | } |
---|
13371 | 13486 | |
---|
13372 | 13487 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13528 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13529 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13530 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13531 | + // No shadow when out of frustum |
---|
13417 | 13532 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13533 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13534 | ""; |
---|
.. | .. |
---|
14211 | 14326 | drag = false; |
---|
14212 | 14327 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14328 | 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); |
---|
| 14329 | + //ClickInfo info = new ClickInfo(); |
---|
| 14330 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14331 | + object.clickInfo.pane = this; |
---|
| 14332 | + object.clickInfo.camera = renderCamera; |
---|
| 14333 | + object.clickInfo.x = x; |
---|
| 14334 | + object.clickInfo.y = y; |
---|
| 14335 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14336 | + editObj = object.doEditClick(//info, |
---|
| 14337 | + 0); |
---|
14222 | 14338 | if (!editObj) |
---|
14223 | 14339 | { |
---|
14224 | 14340 | hasMarquee = true; |
---|
.. | .. |
---|
14618 | 14734 | if (editObj) |
---|
14619 | 14735 | { |
---|
14620 | 14736 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14737 | + //ClickInfo info = new ClickInfo(); |
---|
| 14738 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14739 | (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); |
---|
| 14740 | + object.clickInfo.pane = this; |
---|
| 14741 | + object.clickInfo.camera = renderCamera; |
---|
| 14742 | + object.clickInfo.x = x; |
---|
| 14743 | + object.clickInfo.y = y; |
---|
| 14744 | + object //.GetWindow().copy |
---|
| 14745 | + .doEditDrag(//info, |
---|
| 14746 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14747 | } else |
---|
14631 | 14748 | { |
---|
14632 | 14749 | if (x < startX) |
---|
.. | .. |
---|
14775 | 14892 | } |
---|
14776 | 14893 | } |
---|
14777 | 14894 | |
---|
| 14895 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14896 | + |
---|
14778 | 14897 | public void mouseMoved(MouseEvent e) |
---|
14779 | 14898 | { |
---|
14780 | 14899 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 14900 | if (isRenderer) |
---|
14782 | 14901 | return; |
---|
14783 | 14902 | |
---|
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; |
---|
| 14903 | + // Mouse cursor feedback |
---|
| 14904 | + object.clickInfo.x = e.getX(); |
---|
| 14905 | + object.clickInfo.y = e.getY(); |
---|
| 14906 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14907 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14908 | + object.clickInfo.pane = this; |
---|
| 14909 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 14910 | if (!isRenderer) |
---|
14792 | 14911 | { |
---|
14793 | 14912 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 14913 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 14914 | + if (object.doEditClick(//clickInfo, |
---|
| 14915 | + 0)) |
---|
14796 | 14916 | { |
---|
14797 | 14917 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 14918 | } else |
---|
.. | .. |
---|
15248 | 15368 | case '3': |
---|
15249 | 15369 | case '4': |
---|
15250 | 15370 | case '5': |
---|
15251 | | - newenvy = Character.getNumericValue(key); |
---|
15252 | | - repaint(); |
---|
15253 | | - break; |
---|
15254 | 15371 | case '6': |
---|
15255 | 15372 | case '7': |
---|
15256 | 15373 | case '8': |
---|
15257 | 15374 | case '9': |
---|
15258 | | - BGcolor = (key - '6')/3.f; |
---|
| 15375 | + if (envyoff) |
---|
| 15376 | + { |
---|
| 15377 | + BGcolor = (key - '1')/8.f; |
---|
| 15378 | + } |
---|
| 15379 | + else |
---|
| 15380 | + { |
---|
| 15381 | + //newenvy = Character.getNumericValue(key); |
---|
| 15382 | + } |
---|
15259 | 15383 | repaint(); |
---|
15260 | 15384 | break; |
---|
15261 | 15385 | case '!': |
---|
.. | .. |
---|
15818 | 15942 | |
---|
15819 | 15943 | int width = getBounds().width; |
---|
15820 | 15944 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 15945 | //Image img = CreateImage(width, height); |
---|
15824 | 15946 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 15947 | |
---|
.. | .. |
---|
15896 | 16018 | } |
---|
15897 | 16019 | if (object != null && !hasMarquee) |
---|
15898 | 16020 | { |
---|
| 16021 | + if (object.clickInfo == null) |
---|
| 16022 | + object.clickInfo = new ClickInfo(); |
---|
| 16023 | + ClickInfo info = object.clickInfo; |
---|
| 16024 | + //ClickInfo info = new ClickInfo(); |
---|
| 16025 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 16026 | + |
---|
15899 | 16027 | if (isRenderer) |
---|
15900 | 16028 | { |
---|
15901 | | - info.flags++; |
---|
| 16029 | + object.clickInfo.flags++; |
---|
15902 | 16030 | double frameAspect = (double) width / (double) height; |
---|
15903 | 16031 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 16032 | { |
---|
15905 | 16033 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 16034 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 16035 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 16036 | } else |
---|
15909 | 16037 | { |
---|
15910 | 16038 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 16039 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 16040 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 16041 | } |
---|
15914 | 16042 | } |
---|
15915 | 16043 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 16044 | + object.clickInfo.g = gr; |
---|
| 16045 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 16046 | /* |
---|
15919 | 16047 | // Memory intensive (brep.verticescopy) |
---|
15920 | 16048 | if (!(object instanceof Composite)) |
---|
15921 | 16049 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 16050 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 16051 | + if (!isRenderer) // && drag) |
---|
15924 | 16052 | { |
---|
15925 | 16053 | Grafreed.Assert(object != null); |
---|
15926 | 16054 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 16056 | { |
---|
15929 | 16057 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 16058 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 16059 | + object.clickInfo.DX = 0; |
---|
| 16060 | + object.clickInfo.DY = 0; |
---|
| 16061 | + object.clickInfo.W = 1; |
---|
15934 | 16062 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 16063 | { |
---|
15936 | 16064 | info.DX = X; |
---|
.. | .. |
---|
15942 | 16070 | info.DY -= info.bounds.height/2; |
---|
15943 | 16071 | } |
---|
15944 | 16072 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 16073 | + object.drawEditHandles(//info, |
---|
| 16074 | + 0); |
---|
15946 | 16075 | |
---|
15947 | 16076 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16077 | { |
---|
.. | .. |
---|
15955 | 16084 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15956 | 16085 | break; |
---|
15957 | 16086 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15958 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16087 | + gr.drawLine(X, Y, 0, 0); |
---|
15959 | 16088 | break; |
---|
15960 | 16089 | } |
---|
15961 | 16090 | |
---|
.. | .. |
---|
16473 | 16602 | |
---|
16474 | 16603 | float BGcolor = 0.5f; |
---|
16475 | 16604 | |
---|
16476 | | - private void DrawSkyBox(GL gl) |
---|
| 16605 | + float ambientLight[] = {1f, 1f, 1f, 1.0f}; |
---|
| 16606 | + |
---|
| 16607 | + private void DrawSkyBox(GL gl, float ratio) |
---|
16477 | 16608 | { |
---|
16478 | 16609 | if (envyoff || cubemap == null) |
---|
16479 | 16610 | { |
---|
.. | .. |
---|
16490 | 16621 | // Compensates for ExaminerViewer's modification of modelview matrix |
---|
16491 | 16622 | gl.glMatrixMode(GL.GL_MODELVIEW); |
---|
16492 | 16623 | gl.glLoadIdentity(); |
---|
| 16624 | + gl.glScalef(1,ratio,1); |
---|
16493 | 16625 | |
---|
| 16626 | + colorV[0] = 2; |
---|
| 16627 | + colorV[1] = 2; |
---|
| 16628 | + colorV[2] = 2; |
---|
| 16629 | + colorV[3] = 1; |
---|
| 16630 | + gl.glDisable(gl.GL_COLOR_MATERIAL); |
---|
| 16631 | + gl.glMaterialfv(gl.GL_FRONT_AND_BACK, gl.GL_AMBIENT, colorV, 0); |
---|
| 16632 | + |
---|
| 16633 | + gl.glLightModelfv(gl.GL_LIGHT_MODEL_AMBIENT, ambientLight, 0); |
---|
| 16634 | + |
---|
16494 | 16635 | //gl.glActiveTexture(GL.GL_TEXTURE1); |
---|
16495 | 16636 | //gl.glDisable(GL.GL_TEXTURE_CUBE_MAP); |
---|
16496 | 16637 | |
---|
.. | .. |
---|
16503 | 16644 | // GL_NORMAL_MAP texgen mode. Temporarily enabling lighting |
---|
16504 | 16645 | // causes the normals to be sent down. Thanks to Ken Dyke. |
---|
16505 | 16646 | //gl.glEnable(GL.GL_LIGHTING); |
---|
16506 | | - gl.glDisable(GL.GL_LIGHTING); |
---|
| 16647 | + gl.glEnable(GL.GL_LIGHTING); |
---|
16507 | 16648 | |
---|
16508 | 16649 | gl.glTexGeni(GL.GL_S, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
16509 | 16650 | gl.glTexGeni(GL.GL_T, GL.GL_TEXTURE_GEN_MODE, GL.GL_NORMAL_MAP); |
---|
.. | .. |
---|
16780 | 16921 | //new Exception().printStackTrace(); |
---|
16781 | 16922 | System.out.println("select buffer init"); |
---|
16782 | 16923 | // Use debug pipeline |
---|
16783 | | - drawable.setGL(new DebugGL(drawable.getGL())); |
---|
| 16924 | + //drawable.setGL(new DebugGL(drawable.getGL())); |
---|
16784 | 16925 | |
---|
16785 | 16926 | GL gl = drawable.getGL(); |
---|
16786 | 16927 | |
---|