.. | .. |
---|
12400 | 12400 | //gl.glProgramEnvParameter4fvARB(GL.GL_FRAGMENT_PROGRAM_ARB, 127, lightParams, 0); |
---|
12401 | 12401 | |
---|
12402 | 12402 | String program = |
---|
| 12403 | + // Min shader |
---|
12403 | 12404 | "!!ARBfp1.0\n" + |
---|
| 12405 | + "PARAM zero123 = { 0.0, 1.0, 2.0, 1.25 };" + |
---|
| 12406 | + "PARAM pow2 = { 0.5, 0.25, 0.125, 0.0 };" + |
---|
| 12407 | + "PARAM one = { 1.0, 1.0, 1.0, 1.0 };" + |
---|
| 12408 | + "PARAM eps = { 0.001, 0.001, 0.001, 1.0 };" + |
---|
| 12409 | + "PARAM infinity = { 100000000, 100000000, 100000000, 1.0 };" + |
---|
| 12410 | + "TEMP temp;" + |
---|
| 12411 | + "TEMP light;" + |
---|
| 12412 | + "TEMP ndotl;" + |
---|
| 12413 | + "TEMP normal;" + |
---|
| 12414 | + "TEMP depth;" + |
---|
| 12415 | + |
---|
| 12416 | + "MAD normal, fragment.color, zero123.z, -zero123.y;" + |
---|
| 12417 | + |
---|
| 12418 | + "MOV light, state.light[0].position;" + |
---|
| 12419 | + "DP3 ndotl.x, light, normal;" + |
---|
| 12420 | + |
---|
| 12421 | + // shadow |
---|
| 12422 | + "MOV temp, fragment.texcoord[1];" + |
---|
| 12423 | + TextureFetch("depth", "temp", "1") + |
---|
| 12424 | + //"TEX depth, fragment.texcoord[1], texture[1], 2D;" + |
---|
| 12425 | + "SLT temp.x, fragment.texcoord[1].z, depth.z;" + |
---|
| 12426 | + |
---|
| 12427 | + |
---|
| 12428 | + // No shadow when out of frustum |
---|
| 12429 | + //"SGE temp.y, depth.z, zero123.y;" + |
---|
| 12430 | + //"LRP temp.x, temp.y, zero123.y, temp.x;" + |
---|
| 12431 | + |
---|
| 12432 | + "MUL ndotl.x, ndotl.x, temp.x;" + |
---|
| 12433 | + "MAX ndotl.x, ndotl.x, pow2.y;" + |
---|
| 12434 | + |
---|
| 12435 | + "TEX temp, fragment.texcoord[0], texture[0], 2D;" + |
---|
| 12436 | + "LRP temp, zero123.w, temp, one;" + // texture proportion |
---|
| 12437 | + "MUL temp, temp, ndotl.x;" + |
---|
| 12438 | + |
---|
| 12439 | + "MUL temp, temp, zero123.z;" + |
---|
| 12440 | + |
---|
| 12441 | + "MOV temp.w, zero123.y;" + // reset alpha |
---|
| 12442 | + |
---|
| 12443 | + "MOV result.color, temp;" + |
---|
| 12444 | + "END"; |
---|
| 12445 | + |
---|
| 12446 | + String program2 = |
---|
| 12447 | + "!!ARBfp1.0\n" + |
---|
| 12448 | + |
---|
12404 | 12449 | //"OPTION ARB_fragment_program_shadow;" + |
---|
12405 | 12450 | "PARAM light2cam0 = program.env[10];" + |
---|
12406 | 12451 | "PARAM light2cam1 = program.env[11];" + |
---|
.. | .. |
---|
12515 | 12560 | "TEMP shininess;" + |
---|
12516 | 12561 | "\n" + |
---|
12517 | 12562 | "MOV texSamp, one;" + |
---|
12518 | | - //"TEX texSamp, fragment.texcoord[0], texture[0], 2D;" + |
---|
12519 | | - |
---|
| 12563 | + |
---|
12520 | 12564 | "MOV mapgrid.x, one2048th.x;" + |
---|
12521 | 12565 | "MOV temp, fragment.texcoord[1];" + |
---|
12522 | 12566 | /* |
---|
.. | .. |
---|
12921 | 12965 | "MAD shadow.x, buffer.x, frac.y, shadow.x;" + |
---|
12922 | 12966 | "") + |
---|
12923 | 12967 | |
---|
12924 | | - // display shadow only (bump == 0) |
---|
| 12968 | + // display shadow only (fakedepth == 0) |
---|
12925 | 12969 | "SUB temp.x, half.x, shadow.x;" + |
---|
12926 | 12970 | "MOV temp.y, -params5.z;" + // params6.x;" + |
---|
12927 | 12971 | "SLT temp.z, temp.y, -one2048th.x;" + |
---|
.. | .. |
---|
13353 | 13397 | return "TEX " + dest + ", " + src + ", texture[" + unit + "], 2D;" + |
---|
13354 | 13398 | "SGE " + src + ".w, " + src + ".x, eps.x;" + |
---|
13355 | 13399 | "SGE " + src + ".z, " + src + ".y, eps.x;" + |
---|
| 13400 | + "SLT " + dest + ".x, " + src + ".x, one.x;" + |
---|
| 13401 | + "SLT " + dest + ".y, " + src + ".y, one.x;" + |
---|
13356 | 13402 | "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;" + |
---|
| 13403 | + "MUL " + src + ".w, " + dest + ".x, " + src + ".w;" + |
---|
| 13404 | + "MUL " + src + ".w, " + dest + ".y, " + src + ".w;" + |
---|
13361 | 13405 | //"SWZ buffer, temp, w,w,w,w;"; |
---|
13362 | | - "MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
| 13406 | + //"MUL " + dest + ".z, " + dest + ".z, " + src + ".w;" + |
---|
13363 | 13407 | "SUB " + src + ".z, " + "one.x, " + src + ".w;" + |
---|
13364 | 13408 | //"MUL " + src + ".z, " + src + ".z, infinity.x;" + |
---|
13365 | 13409 | //"ADD " + dest + ".z, " + dest + ".z, " + src + ".z;"; |
---|
13366 | | - "MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
| 13410 | + //"MAD " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13367 | 13411 | |
---|
13368 | | - //"LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
13369 | | - //"LRP " + dest + ".z" + ", " + src + ".w, infinity.x," + dest + ".z;"; |
---|
| 13412 | + //?? "LRP " + dest + ".z, " + src + ".w," + dest + ".z, infinity.x;"; |
---|
| 13413 | + "LRP " + dest + ".z, " + src + ".z, infinity.x," + dest + ".z;"; |
---|
13370 | 13414 | } |
---|
13371 | 13415 | |
---|
13372 | 13416 | String Shadow(String depth, String shadow) |
---|
.. | .. |
---|
13413 | 13457 | "SLT temp.x, temp.x, zero.x;" + // shadoweps |
---|
13414 | 13458 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13415 | 13459 | |
---|
13416 | | - // No shadow when out of frustrum |
---|
| 13460 | + // No shadow when out of frustum |
---|
13417 | 13461 | "SGE temp.x, " + depth + ".z, one.z;" + |
---|
13418 | 13462 | "LRP " + shadow + ", temp.x, one, " + shadow + ";" + |
---|
13419 | 13463 | ""; |
---|
.. | .. |
---|
14211 | 14255 | drag = false; |
---|
14212 | 14256 | //System.out.println("Mouse DOWN"); |
---|
14213 | 14257 | 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); |
---|
| 14258 | + //ClickInfo info = new ClickInfo(); |
---|
| 14259 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14260 | + object.clickInfo.pane = this; |
---|
| 14261 | + object.clickInfo.camera = renderCamera; |
---|
| 14262 | + object.clickInfo.x = x; |
---|
| 14263 | + object.clickInfo.y = y; |
---|
| 14264 | + object.clickInfo.modifiers = modifiersex; |
---|
| 14265 | + editObj = object.doEditClick(//info, |
---|
| 14266 | + 0); |
---|
14222 | 14267 | if (!editObj) |
---|
14223 | 14268 | { |
---|
14224 | 14269 | hasMarquee = true; |
---|
.. | .. |
---|
14618 | 14663 | if (editObj) |
---|
14619 | 14664 | { |
---|
14620 | 14665 | drag = true; |
---|
14621 | | - ClickInfo info = new ClickInfo(); |
---|
14622 | | - info.bounds.setBounds(0, 0, |
---|
| 14666 | + //ClickInfo info = new ClickInfo(); |
---|
| 14667 | + object.clickInfo.bounds.setBounds(0, 0, |
---|
14623 | 14668 | (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); |
---|
| 14669 | + object.clickInfo.pane = this; |
---|
| 14670 | + object.clickInfo.camera = renderCamera; |
---|
| 14671 | + object.clickInfo.x = x; |
---|
| 14672 | + object.clickInfo.y = y; |
---|
| 14673 | + object //.GetWindow().copy |
---|
| 14674 | + .doEditDrag(//info, |
---|
| 14675 | + (modifiers & MouseEvent.BUTTON3_MASK) != 0); |
---|
14630 | 14676 | } else |
---|
14631 | 14677 | { |
---|
14632 | 14678 | if (x < startX) |
---|
.. | .. |
---|
14775 | 14821 | } |
---|
14776 | 14822 | } |
---|
14777 | 14823 | |
---|
| 14824 | +// ClickInfo clickInfo = new ClickInfo(); |
---|
| 14825 | + |
---|
14778 | 14826 | public void mouseMoved(MouseEvent e) |
---|
14779 | 14827 | { |
---|
14780 | 14828 | //System.out.println("mouseMoved: " + e); |
---|
14781 | 14829 | if (isRenderer) |
---|
14782 | 14830 | return; |
---|
14783 | 14831 | |
---|
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; |
---|
| 14832 | + // Mouse cursor feedback |
---|
| 14833 | + object.clickInfo.x = e.getX(); |
---|
| 14834 | + object.clickInfo.y = e.getY(); |
---|
| 14835 | + object.clickInfo.modifiers = e.getModifiersEx(); |
---|
| 14836 | + object.clickInfo.bounds.setBounds(0, 0, (int) (getBounds().width * zoom), (int) (getBounds().height * zoom)); |
---|
| 14837 | + object.clickInfo.pane = this; |
---|
| 14838 | + object.clickInfo.camera = renderCamera; |
---|
14791 | 14839 | if (!isRenderer) |
---|
14792 | 14840 | { |
---|
14793 | 14841 | //ObjEditor editWindow = object.editWindow; |
---|
14794 | 14842 | //Object3D copy = editWindow.copy; |
---|
14795 | | - if (object.doEditClick(ci, 0)) |
---|
| 14843 | + if (object.doEditClick(//clickInfo, |
---|
| 14844 | + 0)) |
---|
14796 | 14845 | { |
---|
14797 | 14846 | setCursor(Cursor.getPredefinedCursor(Cursor.HAND_CURSOR)); |
---|
14798 | 14847 | } else |
---|
.. | .. |
---|
15818 | 15867 | |
---|
15819 | 15868 | int width = getBounds().width; |
---|
15820 | 15869 | int height = getBounds().height; |
---|
15821 | | - ClickInfo info = new ClickInfo(); |
---|
15822 | | - info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
15823 | 15870 | //Image img = CreateImage(width, height); |
---|
15824 | 15871 | //System.out.println("width = " + width + "; height = " + height + "\n"); |
---|
15825 | 15872 | |
---|
.. | .. |
---|
15896 | 15943 | } |
---|
15897 | 15944 | if (object != null && !hasMarquee) |
---|
15898 | 15945 | { |
---|
| 15946 | + if (object.clickInfo == null) |
---|
| 15947 | + object.clickInfo = new ClickInfo(); |
---|
| 15948 | + ClickInfo info = object.clickInfo; |
---|
| 15949 | + //ClickInfo info = new ClickInfo(); |
---|
| 15950 | + info.bounds.setBounds(0, 0, (int) (width * zoom), (int) (height * zoom)); |
---|
| 15951 | + |
---|
15899 | 15952 | if (isRenderer) |
---|
15900 | 15953 | { |
---|
15901 | | - info.flags++; |
---|
| 15954 | + object.clickInfo.flags++; |
---|
15902 | 15955 | double frameAspect = (double) width / (double) height; |
---|
15903 | 15956 | if (frameAspect > renderCamera.aspect) |
---|
15904 | 15957 | { |
---|
15905 | 15958 | int desired = (int) ((double) height * renderCamera.aspect); |
---|
15906 | | - info.bounds.width -= width - desired; |
---|
15907 | | - info.bounds.x += (width - desired) / 2; |
---|
| 15959 | + object.clickInfo.bounds.width -= width - desired; |
---|
| 15960 | + object.clickInfo.bounds.x += (width - desired) / 2; |
---|
15908 | 15961 | } else |
---|
15909 | 15962 | { |
---|
15910 | 15963 | int desired = (int) ((double) width / renderCamera.aspect); |
---|
15911 | | - info.bounds.height -= height - desired; |
---|
15912 | | - info.bounds.y += (height - desired) / 2; |
---|
| 15964 | + object.clickInfo.bounds.height -= height - desired; |
---|
| 15965 | + object.clickInfo.bounds.y += (height - desired) / 2; |
---|
15913 | 15966 | } |
---|
15914 | 15967 | } |
---|
15915 | 15968 | |
---|
15916 | | - info.g = gr; |
---|
15917 | | - info.camera = renderCamera; |
---|
| 15969 | + object.clickInfo.g = gr; |
---|
| 15970 | + object.clickInfo.camera = renderCamera; |
---|
15918 | 15971 | /* |
---|
15919 | 15972 | // Memory intensive (brep.verticescopy) |
---|
15920 | 15973 | if (!(object instanceof Composite)) |
---|
15921 | 15974 | object.draw(info, 0, false); // SLOW : |
---|
15922 | 15975 | */ |
---|
15923 | | - if (!isRenderer) |
---|
| 15976 | + if (!isRenderer) // && drag) |
---|
15924 | 15977 | { |
---|
15925 | 15978 | Grafreed.Assert(object != null); |
---|
15926 | 15979 | Grafreed.Assert(object.selection != null); |
---|
.. | .. |
---|
15928 | 15981 | { |
---|
15929 | 15982 | int hitSomething = object.selection.get(0).hitSomething; |
---|
15930 | 15983 | |
---|
15931 | | - info.DX = 0; |
---|
15932 | | - info.DY = 0; |
---|
15933 | | - info.W = 1; |
---|
| 15984 | + object.clickInfo.DX = 0; |
---|
| 15985 | + object.clickInfo.DY = 0; |
---|
| 15986 | + object.clickInfo.W = 1; |
---|
15934 | 15987 | if (hitSomething == Object3D.hitCenter) |
---|
15935 | 15988 | { |
---|
15936 | 15989 | info.DX = X; |
---|
.. | .. |
---|
15942 | 15995 | info.DY -= info.bounds.height/2; |
---|
15943 | 15996 | } |
---|
15944 | 15997 | |
---|
15945 | | - object.drawEditHandles(info, 0); |
---|
| 15998 | + object.drawEditHandles(//info, |
---|
| 15999 | + 0); |
---|
15946 | 16000 | |
---|
15947 | 16001 | if (drag && (X != 0 || Y != 0)) |
---|
15948 | 16002 | { |
---|
.. | .. |
---|
15955 | 16009 | gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
15956 | 16010 | break; |
---|
15957 | 16011 | case Object3D.hitScale: gr.setColor(Color.cyan); |
---|
15958 | | - gr.drawLine(X, Y, info.bounds.width/2, info.bounds.height/2); |
---|
| 16012 | + gr.drawLine(X, Y, 0, 0); |
---|
15959 | 16013 | break; |
---|
15960 | 16014 | } |
---|
15961 | 16015 | |
---|