.. | .. |
---|
1 | 1 | |
---|
| 2 | +import com.bulletphysics.dynamics.RigidBody; |
---|
2 | 3 | import java.awt.*; |
---|
3 | 4 | import java.awt.event.*; |
---|
4 | 5 | import java.awt.image.*; |
---|
.. | .. |
---|
123 | 124 | static boolean LOCALTRANSFORM = false; |
---|
124 | 125 | static boolean FULLSCREEN = false; |
---|
125 | 126 | static boolean SUPPORT = true; |
---|
126 | | -static boolean INERTIA = true; |
---|
| 127 | +static boolean INERTIA = false; // true; |
---|
127 | 128 | static boolean FAST = false; |
---|
128 | 129 | static boolean SLOWPOSE = false; |
---|
129 | 130 | static boolean FOOTCONTACT = true; |
---|
.. | .. |
---|
134 | 135 | static boolean ZOOMBOXMODE = false; |
---|
135 | 136 | static boolean BOXMODE = false; |
---|
136 | 137 | static boolean IMAGEFLIP = false; |
---|
137 | | -static boolean SMOOTHFOCUS = false; |
---|
| 138 | +static boolean SMOOTHFOCUS = true; // false; |
---|
138 | 139 | static boolean SPEAKERMOCAP = true; // jan 2014 false; |
---|
139 | 140 | static boolean SPEAKERCAMERA = false; |
---|
140 | 141 | static boolean SPEAKERFOCUS = false; |
---|
.. | .. |
---|
174 | 175 | boolean Udebug = false; |
---|
175 | 176 | boolean Vdebug = false; |
---|
176 | 177 | boolean NORMALdebug = false; |
---|
177 | | - static boolean doublesided = false; // true; // reversed normals are awful for conformance |
---|
| 178 | + static boolean doublesided = true; // false; // reversed normals are awful for conformance |
---|
178 | 179 | boolean anisotropy = true; |
---|
179 | 180 | boolean softshadow = true; // slower but better false; |
---|
180 | 181 | boolean opacityhalo = false; // reverse the halo effect (e.g. glass) |
---|
.. | .. |
---|
221 | 222 | cameras = new Camera[2]; |
---|
222 | 223 | targetLookAts = new cVector[2]; |
---|
223 | 224 | |
---|
224 | | - SetCamera(cam); |
---|
| 225 | + SetCamera(cam, true); |
---|
225 | 226 | |
---|
226 | 227 | // Warning: not used. |
---|
227 | 228 | //SetLight(new Camera(new cVector(15, 10, -20))); |
---|
.. | .. |
---|
249 | 250 | |
---|
250 | 251 | public javax.media.opengl.GL GetGL0() |
---|
251 | 252 | { |
---|
252 | | - return null; |
---|
| 253 | + return currentGL; |
---|
253 | 254 | } |
---|
254 | 255 | |
---|
255 | 256 | public int GenList() |
---|
.. | .. |
---|
1529 | 1530 | } |
---|
1530 | 1531 | } |
---|
1531 | 1532 | float b = 0; |
---|
1532 | | - if (obj.support != null && obj.link2master) |
---|
| 1533 | + if (obj.support != null && obj.Link2Support()) |
---|
1533 | 1534 | { |
---|
1534 | 1535 | b = 1; |
---|
1535 | 1536 | } |
---|
.. | .. |
---|
2064 | 2065 | |
---|
2065 | 2066 | static int camerachangeframe; |
---|
2066 | 2067 | |
---|
2067 | | - public boolean SetCamera(Camera cam) |
---|
| 2068 | + public boolean SetCamera(Camera cam, boolean set) |
---|
2068 | 2069 | { |
---|
2069 | 2070 | // may 2014 if (cam == cameras[0] || cam == cameras[1]) |
---|
2070 | 2071 | // return false; |
---|
.. | .. |
---|
2092 | 2093 | if (cameras[i] == null) |
---|
2093 | 2094 | { |
---|
2094 | 2095 | cameras[i] = new Camera(cam.viewCode); |
---|
2095 | | - |
---|
| 2096 | + } |
---|
| 2097 | + |
---|
| 2098 | + if (set) |
---|
| 2099 | + { |
---|
2096 | 2100 | cameras[i].setAim(cam.location, cam.lookAt); |
---|
2097 | 2101 | cameras[i].shaper_fovy = cam.shaper_fovy; |
---|
2098 | 2102 | cameras[i].UP.set(cam.UP); |
---|
.. | .. |
---|
2106 | 2110 | // Start with free camera |
---|
2107 | 2111 | SwitchCameras(true); |
---|
2108 | 2112 | |
---|
2109 | | - pingthread.jump = true; // optional? |
---|
| 2113 | +// pingthread.jump = true; // optional? |
---|
2110 | 2114 | |
---|
2111 | 2115 | if (TRACKONCE) |
---|
2112 | 2116 | { |
---|
.. | .. |
---|
2293 | 2297 | public void ToggleTrack() |
---|
2294 | 2298 | { |
---|
2295 | 2299 | TRACK ^= true; |
---|
2296 | | - if (TRACK) |
---|
2297 | | - { |
---|
2298 | | - if (object.selection != null && |
---|
2299 | | - object.selection.size() > 0 && |
---|
2300 | | - object.selection.elementAt(0) != null && |
---|
2301 | | - !(object.selection.elementAt(0) instanceof Camera) && |
---|
2302 | | - !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
2303 | | - { |
---|
2304 | | - trackedobject = object.selection.elementAt(0); |
---|
2305 | | - repaint(); |
---|
2306 | | - } |
---|
2307 | | - } |
---|
2308 | 2300 | |
---|
2309 | 2301 | repaint(); |
---|
2310 | 2302 | } |
---|
.. | .. |
---|
3598 | 3590 | }; |
---|
3599 | 3591 | /**/ |
---|
3600 | 3592 | |
---|
| 3593 | + static Object3D lastObject; |
---|
| 3594 | + |
---|
3601 | 3595 | //com.sun.opengl.util.texture.Texture |
---|
3602 | 3596 | TextureData |
---|
3603 | 3597 | GetFileTexture(String name, boolean bump, int resolution) |
---|
.. | .. |
---|
3634 | 3628 | // return null; |
---|
3635 | 3629 | //if (i == 2) |
---|
3636 | 3630 | // return null; |
---|
| 3631 | + // TIFF issue sept 2019 |
---|
| 3632 | + System.err.println("lastObject = " + lastObject); |
---|
3637 | 3633 | e.printStackTrace(); |
---|
3638 | 3634 | name = name.split("\\.tif")[0] + ".jpg"; |
---|
3639 | 3635 | } |
---|
.. | .. |
---|
6966 | 6962 | short residu = 0; |
---|
6967 | 6963 | |
---|
6968 | 6964 | // wraparound workarounds |
---|
6969 | | - short fuck = (short) (buffer[i] & 0xFF); |
---|
| 6965 | + short ww = (short) (buffer[i] & 0xFF); |
---|
6970 | 6966 | /* |
---|
6971 | | - residu += (fuck%2); |
---|
6972 | | - if(fuck/2 < 256-residu/2) |
---|
| 6967 | + residu += (ww%2); |
---|
| 6968 | + if(ww/2 < 256-residu/2) |
---|
6973 | 6969 | { |
---|
6974 | | - fuck = (short)((fuck/2) + residu/2); |
---|
| 6970 | + ww = (short)((ww/2) + residu/2); |
---|
6975 | 6971 | if(residu == 2) |
---|
6976 | 6972 | residu = 0; |
---|
6977 | 6973 | } |
---|
6978 | 6974 | else |
---|
6979 | 6975 | { |
---|
6980 | 6976 | residu = 0; |
---|
6981 | | - fuck /= 2; |
---|
| 6977 | + ww /= 2; |
---|
6982 | 6978 | } |
---|
6983 | 6979 | */ |
---|
6984 | | - if (i < imglength / 3 || rnd.nextFloat() < 0.5 || fuck >= 254) |
---|
| 6980 | + if (i < imglength / 3 || rnd.nextFloat() < 0.5 || ww >= 254) |
---|
6985 | 6981 | { |
---|
6986 | | - fuck /= 2; |
---|
| 6982 | + ww /= 2; |
---|
6987 | 6983 | } else |
---|
6988 | 6984 | { |
---|
6989 | | - fuck = (short) ((fuck / 2) + fuck % 2); |
---|
| 6985 | + ww = (short) ((ww / 2) + ww % 2); |
---|
6990 | 6986 | } |
---|
6991 | 6987 | |
---|
6992 | | - buffer[i] = (byte) fuck; |
---|
| 6988 | + buffer[i] = (byte) ww; |
---|
6993 | 6989 | } |
---|
6994 | 6990 | //System.out.print(bytes[i] + " "); |
---|
6995 | 6991 | //if(buffer[i] >= 0 && buffer[i]<=eps-1) buffer[i] = eps; |
---|
.. | .. |
---|
8461 | 8457 | new Exception().printStackTrace(); |
---|
8462 | 8458 | } else |
---|
8463 | 8459 | { |
---|
8464 | | - if (texname.startsWith("@")) |
---|
| 8460 | + if (texname.startsWith("@") && textureon) |
---|
8465 | 8461 | { |
---|
8466 | 8462 | // texturecache = textures.get(texname); // suspicious |
---|
8467 | 8463 | if (texturecache == null) |
---|
.. | .. |
---|
9847 | 9843 | |
---|
9848 | 9844 | boolean vr = capsLocked && !lightMode; |
---|
9849 | 9845 | |
---|
9850 | | - accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 2 : 1), |
---|
| 9846 | + accPerspective(gl, renderCamera.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
9851 | 9847 | ratio, |
---|
9852 | 9848 | //near_plane, far_plane, |
---|
9853 | 9849 | renderCamera.shaper_zNear * renderCamera.Distance(), renderCamera.shaper_zFar * renderCamera.Distance(), |
---|
.. | .. |
---|
10765 | 10761 | } |
---|
10766 | 10762 | /**/ |
---|
10767 | 10763 | |
---|
10768 | | - if (selection) |
---|
| 10764 | + boolean control = ((modifiers & CTRL) != 0); |
---|
| 10765 | + |
---|
| 10766 | + if (selection && (!Globals.isLIVE() || control)) |
---|
10769 | 10767 | { |
---|
10770 | 10768 | selectbuffer.display(); |
---|
10771 | 10769 | return; |
---|
.. | .. |
---|
10867 | 10865 | |
---|
10868 | 10866 | if (keys[DOWN_ARROW]) |
---|
10869 | 10867 | { |
---|
| 10868 | + speed = ++speedkey[DOWN_ARROW]; |
---|
| 10869 | + if (speed > 20) |
---|
| 10870 | + speed = 20; |
---|
10870 | 10871 | GoDown(modifiers); |
---|
10871 | 10872 | keyon = true; |
---|
10872 | 10873 | } |
---|
| 10874 | + else |
---|
| 10875 | + speedkey[DOWN_ARROW] = 0; |
---|
10873 | 10876 | |
---|
10874 | 10877 | if (keys[UP_ARROW]) |
---|
10875 | 10878 | { |
---|
| 10879 | + speed = ++speedkey[UP_ARROW]; |
---|
| 10880 | + if (speed > 20) |
---|
| 10881 | + speed = 20; |
---|
10876 | 10882 | GoUp(modifiers); |
---|
10877 | 10883 | keyon = true; |
---|
10878 | 10884 | } |
---|
| 10885 | + else |
---|
| 10886 | + speedkey[UP_ARROW] = 0; |
---|
10879 | 10887 | |
---|
10880 | 10888 | if (keys[LEFT_ARROW]) |
---|
10881 | 10889 | { |
---|
| 10890 | + speed = ++speedkey[LEFT_ARROW]; |
---|
| 10891 | + if (speed > 20) |
---|
| 10892 | + speed = 20; |
---|
10882 | 10893 | GoLeft(modifiers); |
---|
10883 | 10894 | keyon = true; |
---|
10884 | 10895 | } |
---|
| 10896 | + else |
---|
| 10897 | + speedkey[LEFT_ARROW] = 0; |
---|
10885 | 10898 | |
---|
10886 | 10899 | if (keys[RIGHT_ARROW]) |
---|
10887 | 10900 | { |
---|
| 10901 | + speed = ++speedkey[RIGHT_ARROW]; |
---|
| 10902 | + if (speed > 20) |
---|
| 10903 | + speed = 20; |
---|
10888 | 10904 | GoRight(modifiers); |
---|
| 10905 | + keyon = true; |
---|
| 10906 | + } |
---|
| 10907 | + else |
---|
| 10908 | + speedkey[RIGHT_ARROW] = 0; |
---|
| 10909 | + |
---|
| 10910 | + if (Globals.WALK && capsLocked) |
---|
| 10911 | + { |
---|
| 10912 | + Walk(); |
---|
10889 | 10913 | keyon = true; |
---|
10890 | 10914 | } |
---|
10891 | 10915 | |
---|
10892 | 10916 | if (keyon) |
---|
| 10917 | + { |
---|
10893 | 10918 | repaint(); |
---|
| 10919 | + } |
---|
| 10920 | + |
---|
10894 | 10921 | //pingthread.mute = false; |
---|
10895 | 10922 | } |
---|
10896 | 10923 | |
---|
.. | .. |
---|
11483 | 11510 | { |
---|
11484 | 11511 | boolean vr = capsLocked && !lightMode; |
---|
11485 | 11512 | |
---|
11486 | | - glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 2 : 1), ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
| 11513 | + glu.gluPerspective(cam.shaper_fovy / ratio * (vr ? 1.2 : 1), |
---|
| 11514 | + ratio, cam.shaper_zNear * cam.Distance(), cam.shaper_zFar * cam.Distance()); |
---|
11487 | 11515 | } |
---|
11488 | 11516 | } |
---|
11489 | 11517 | |
---|
.. | .. |
---|
11839 | 11867 | repaint(); |
---|
11840 | 11868 | } |
---|
11841 | 11869 | |
---|
11842 | | - if (Globals.isLIVE() && DrawMode() == DEFAULT) // may 2013 |
---|
| 11870 | + if (Globals.isLIVE() && DrawMode() == DEFAULT || pingthread.live) // may 2013 |
---|
| 11871 | + { |
---|
| 11872 | + renderCamera.computeTransform(); |
---|
11843 | 11873 | repaint(); |
---|
| 11874 | + } |
---|
11844 | 11875 | |
---|
11845 | 11876 | displaydone = true; |
---|
11846 | 11877 | } |
---|
.. | .. |
---|
11915 | 11946 | //GL gl = getGL(); |
---|
11916 | 11947 | if ((TRACK || SHADOWTRACK) || zoomonce) |
---|
11917 | 11948 | { |
---|
| 11949 | + if (TRACK) |
---|
| 11950 | + { |
---|
| 11951 | + if (object.selection != null && |
---|
| 11952 | + object.selection.size() > 0 && |
---|
| 11953 | + object.selection.elementAt(0) != null && |
---|
| 11954 | + !(object.selection.elementAt(0) instanceof Camera) && |
---|
| 11955 | + !(object.selection.elementAt(0) instanceof ScriptNode)) |
---|
| 11956 | + { |
---|
| 11957 | + trackedobject = object.selection.elementAt(0); |
---|
| 11958 | + //repaint(); |
---|
| 11959 | + } |
---|
| 11960 | + else |
---|
| 11961 | + trackedobject = null; |
---|
| 11962 | + } |
---|
11918 | 11963 | if ((TRACK || SHADOWTRACK) && trackedobject != null && DrawMode() == SHADOW) // && !lightMode) |
---|
11919 | 11964 | object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
11920 | | - pingthread.StepToTarget(true); // true); |
---|
| 11965 | + pingthread.StepToTarget(); // true); |
---|
11921 | 11966 | // zoomonce = false; |
---|
11922 | 11967 | } |
---|
11923 | 11968 | |
---|
.. | .. |
---|
14298 | 14343 | public void mouseClicked(MouseEvent e) |
---|
14299 | 14344 | { |
---|
14300 | 14345 | System.out.println("mouseClicked: " + e); |
---|
| 14346 | + System.exit(0); |
---|
14301 | 14347 | } |
---|
14302 | 14348 | |
---|
14303 | 14349 | public void mousePressed(MouseEvent e) |
---|
.. | .. |
---|
14382 | 14428 | //} |
---|
14383 | 14429 | |
---|
14384 | 14430 | SetMouseMode(e.getModifiers(), WHEEL | e.getModifiersEx()); |
---|
14385 | | - drag(anchorX, anchorY + e.getUnitsToScroll()*8, 0, 0); |
---|
| 14431 | + drag(anchorX, anchorY + e.getUnitsToScroll()*8, e.getModifiers(), e.getModifiersEx()); |
---|
14386 | 14432 | anchorX = ax; |
---|
14387 | 14433 | anchorY = ay; |
---|
14388 | 14434 | prevX = px; |
---|
.. | .. |
---|
14477 | 14523 | // fev 2014??? |
---|
14478 | 14524 | if ((TRACK || SHADOWTRACK) && trackedobject != null) // && DrawMode() == SHADOW) // && !lightMode) |
---|
14479 | 14525 | object.GetWindow().ScreenFit(trackedobject, SHADOWTRACK && !TRACK); |
---|
14480 | | - pingthread.StepToTarget(true); // true); |
---|
| 14526 | + pingthread.StepToTarget(); // true); |
---|
14481 | 14527 | } |
---|
| 14528 | + |
---|
14482 | 14529 | // if (!LIVE) |
---|
14483 | 14530 | super.repaint(); |
---|
14484 | 14531 | } |
---|
.. | .. |
---|
14573 | 14620 | |
---|
14574 | 14621 | //if (drawing) |
---|
14575 | 14622 | //return; |
---|
14576 | | - if ((e.getModifiersEx() & CTRL) != 0 |
---|
14577 | | - || (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
| 14623 | + if ((e.getModifiersEx() & CTRL) != 0 || |
---|
| 14624 | + (e.getModifiersEx() & COMMAND) != 0) // || IsFrozen()) |
---|
14578 | 14625 | { |
---|
14579 | 14626 | //System.out.println("mouseDragged: " + e); |
---|
14580 | 14627 | clickEnd(e.getX(), e.getY(), e.getModifiersEx()); |
---|
.. | .. |
---|
14598 | 14645 | return targetLookAt; |
---|
14599 | 14646 | } |
---|
14600 | 14647 | |
---|
| 14648 | + javax.vecmath.Point3d eye = new javax.vecmath.Point3d(); |
---|
| 14649 | + javax.vecmath.Point3d eye2 = new javax.vecmath.Point3d(); |
---|
| 14650 | + javax.vecmath.Vector3d dir = new javax.vecmath.Vector3d(); |
---|
| 14651 | + |
---|
| 14652 | + |
---|
14601 | 14653 | class PingThread extends Thread |
---|
14602 | 14654 | { |
---|
14603 | 14655 | boolean jump; |
---|
| 14656 | + boolean live; |
---|
14604 | 14657 | |
---|
14605 | | - boolean mute; |
---|
| 14658 | + boolean mute = false; |
---|
14606 | 14659 | |
---|
14607 | 14660 | // void JumpToTarget() |
---|
14608 | 14661 | // { |
---|
.. | .. |
---|
14618 | 14671 | // only one thread!? synchronized |
---|
14619 | 14672 | void StepToTarget(boolean jump) |
---|
14620 | 14673 | { |
---|
| 14674 | + RigidBody.pos.x = 0; |
---|
| 14675 | + RigidBody.pos.y = 0; |
---|
| 14676 | + RigidBody.pos.z = 0; |
---|
| 14677 | + if (RigidBody.justclicked) |
---|
| 14678 | + { |
---|
| 14679 | +// RigidBody.pos.x = (float)manipCamera.lookAt.x; |
---|
| 14680 | +// RigidBody.pos.y = (float)manipCamera.lookAt.y; |
---|
| 14681 | +// RigidBody.pos.z = (float)manipCamera.lookAt.z; |
---|
| 14682 | + // System.err.println("selected point = " + Trunk(selectedpoint.toParent[3][0]) + " " + Trunk(selectedpoint.toParent[3][1]) + " " + Trunk(selectedpoint.toParent[3][2])); |
---|
| 14683 | + CreateSelectedPoint(); |
---|
| 14684 | + |
---|
| 14685 | + RigidBody.pos.x = (float)selectedpoint.toParent[3][0]; |
---|
| 14686 | + RigidBody.pos.y = (float)selectedpoint.toParent[3][1]; |
---|
| 14687 | + RigidBody.pos.z = (float)selectedpoint.toParent[3][2]; |
---|
| 14688 | + |
---|
| 14689 | + RigidBody.wind.set(RigidBody.pos); |
---|
| 14690 | + RigidBody.wind.x -= (float)manipCamera.location.x; |
---|
| 14691 | + RigidBody.wind.y -= (float)manipCamera.location.y; |
---|
| 14692 | + RigidBody.wind.z -= (float)manipCamera.location.z; |
---|
| 14693 | + RigidBody.wind.normalize(); |
---|
| 14694 | + } |
---|
| 14695 | + |
---|
14621 | 14696 | if (mute) |
---|
14622 | 14697 | return; |
---|
| 14698 | + |
---|
| 14699 | + if (capsLocked && manipCamera.viewCode == 0) |
---|
| 14700 | + { |
---|
| 14701 | + eye.x = manipCamera.location.x; |
---|
| 14702 | + eye.y = manipCamera.location.y + 0.25; |
---|
| 14703 | + eye.z = manipCamera.location.z; |
---|
| 14704 | + |
---|
| 14705 | + dir.y = -1; |
---|
| 14706 | + |
---|
| 14707 | + Ray ray = new Ray(eye, dir); |
---|
| 14708 | + |
---|
| 14709 | + IntersectResult res = new IntersectResult(); |
---|
| 14710 | + res.t = Double.POSITIVE_INFINITY; |
---|
| 14711 | + |
---|
| 14712 | + tmp.set(targetLookAt); |
---|
| 14713 | + tmp.sub(manipCamera.location); |
---|
| 14714 | + |
---|
| 14715 | + double dist = tmp.length(); |
---|
| 14716 | + |
---|
| 14717 | + tmp.normalize(); |
---|
| 14718 | + |
---|
| 14719 | + eye2.x = manipCamera.location.x + tmp.x * 0.25; |
---|
| 14720 | + eye2.y = manipCamera.location.y + 0.25; |
---|
| 14721 | + eye2.z = manipCamera.location.z + tmp.z * 0.25; |
---|
| 14722 | + |
---|
| 14723 | + Ray ray2 = new Ray(eye2, dir); |
---|
| 14724 | + |
---|
| 14725 | + IntersectResult res2 = new IntersectResult(); |
---|
| 14726 | + res2.t = Double.POSITIVE_INFINITY; |
---|
| 14727 | + |
---|
| 14728 | + if (object.intersect(ray, res) && object.intersect(ray2, res2) && Math.abs(res.t - res2.t) < 0.25) |
---|
| 14729 | + { |
---|
| 14730 | + //tmp.set(manipCamera.location); |
---|
| 14731 | + |
---|
| 14732 | + manipCamera.location.x = ray.eyePoint.x + ray.viewDirection.x * res.t; |
---|
| 14733 | + manipCamera.location.y = ray.eyePoint.y + ray.viewDirection.y * res.t + 0.5; |
---|
| 14734 | + manipCamera.location.z = ray.eyePoint.z + ray.viewDirection.z * res.t; |
---|
| 14735 | + |
---|
| 14736 | + //tmp.sub(manipCamera.location); |
---|
| 14737 | + |
---|
| 14738 | + targetLookAt.x = ray2.eyePoint.x + ray2.viewDirection.x * res2.t; |
---|
| 14739 | + targetLookAt.y = ray2.eyePoint.y + ray2.viewDirection.y * res2.t + 0.5; |
---|
| 14740 | + targetLookAt.z = ray2.eyePoint.z + ray2.viewDirection.z * res2.t; |
---|
| 14741 | + |
---|
| 14742 | + targetLookAt.sub(manipCamera.location); |
---|
| 14743 | + targetLookAt.normalize(); |
---|
| 14744 | + targetLookAt.mul(dist); |
---|
| 14745 | + targetLookAt.add(manipCamera.location); |
---|
| 14746 | + |
---|
| 14747 | + //if (tmp.dot(tmp) > 0.000001) |
---|
| 14748 | + // System.out.println("INTERSECTION " + manipCamera.location); |
---|
| 14749 | + |
---|
| 14750 | + manipCamera.lookAt.set(targetLookAt); |
---|
| 14751 | + |
---|
| 14752 | + tmp.x = res.n.x; |
---|
| 14753 | + tmp.y = res.n.y; |
---|
| 14754 | + tmp.z = res.n.z; |
---|
| 14755 | + tmp.x += res2.n.x; |
---|
| 14756 | + tmp.y += res2.n.y; |
---|
| 14757 | + tmp.z += res2.n.z; |
---|
| 14758 | + tmp.normalize(); |
---|
| 14759 | + manipCamera.UP.set(tmp); |
---|
| 14760 | + } |
---|
| 14761 | + } |
---|
14623 | 14762 | |
---|
14624 | 14763 | tmp.set(targetLookAt); |
---|
14625 | 14764 | tmp.sub(manipCamera.lookAt); // june 2014 |
---|
.. | .. |
---|
14658 | 14797 | |
---|
14659 | 14798 | if (tmp.dot(tmp) > 1) // may 2014. far away: jump to target |
---|
14660 | 14799 | { |
---|
14661 | | - jump = true; // step = 1; |
---|
| 14800 | + // sep 2019 jump = true; // step = 1; |
---|
14662 | 14801 | } |
---|
14663 | 14802 | |
---|
14664 | 14803 | if (OEILONCE && OEIL) |
---|
.. | .. |
---|
14693 | 14832 | if (tmp.dot(tmp) < 0.00001) |
---|
14694 | 14833 | { |
---|
14695 | 14834 | zoomonce = false; |
---|
| 14835 | + live = false; |
---|
14696 | 14836 | } |
---|
| 14837 | + else |
---|
| 14838 | + live = true; |
---|
14697 | 14839 | |
---|
14698 | 14840 | tmp.mul(step > step2 ? step : step2); |
---|
14699 | 14841 | } |
---|
.. | .. |
---|
14720 | 14862 | { |
---|
14721 | 14863 | if (LOOKAT) |
---|
14722 | 14864 | manipCamera.lookAt.add(tmp); |
---|
14723 | | - if (OEIL) |
---|
| 14865 | + if (OEIL && !capsLocked) |
---|
14724 | 14866 | manipCamera.location.add(tmp); |
---|
14725 | 14867 | |
---|
14726 | 14868 | { |
---|
.. | .. |
---|
14735 | 14877 | lightCamera.computeTransform(); |
---|
14736 | 14878 | } |
---|
14737 | 14879 | } |
---|
14738 | | - manipCamera.computeTransform(); |
---|
| 14880 | + if (tmp.x != 0 || tmp.y != 0 || tmp.z != 0) |
---|
| 14881 | + { |
---|
| 14882 | + manipCamera.computeTransform(); |
---|
| 14883 | + } |
---|
14739 | 14884 | } |
---|
14740 | 14885 | // ?????? mouseDown = true; |
---|
14741 | 14886 | //System.out.println("---------------- ---------- Paint " + tmp.length2()); |
---|
.. | .. |
---|
14828 | 14973 | } |
---|
14829 | 14974 | } |
---|
14830 | 14975 | } |
---|
| 14976 | + |
---|
14831 | 14977 | PingThread pingthread = new PingThread(); |
---|
14832 | | - int delta = 2; |
---|
14833 | | - int speed = 5; |
---|
| 14978 | + int delta = 1; |
---|
| 14979 | + int speed = 1; |
---|
| 14980 | + int walk = 8; |
---|
14834 | 14981 | boolean autorepeat = false; |
---|
14835 | 14982 | |
---|
| 14983 | + void Walk() |
---|
| 14984 | + { |
---|
| 14985 | + manipCamera.BackForth(0, walk, 1000); |
---|
| 14986 | + |
---|
| 14987 | + targetLookAt.set(manipCamera.lookAt); |
---|
| 14988 | + } |
---|
| 14989 | + |
---|
| 14990 | + void ViewAngle(float dy) |
---|
| 14991 | + { |
---|
| 14992 | + double factor = Math.exp(-dy/300.0); // (1 + dy/100); |
---|
| 14993 | + |
---|
| 14994 | + if (manipCamera.shaper_fovy * factor > 1 && |
---|
| 14995 | + manipCamera.shaper_fovy * factor < 150) |
---|
| 14996 | + { |
---|
| 14997 | + manipCamera.shaper_fovy *= factor; |
---|
| 14998 | + //System.out.println("fovy = " + shaper_fovy); |
---|
| 14999 | + } |
---|
| 15000 | + } |
---|
| 15001 | + |
---|
14836 | 15002 | void GoDown(int mod) |
---|
14837 | 15003 | { |
---|
14838 | 15004 | MODIFIERS |= COMMAND; |
---|
.. | .. |
---|
14840 | 15006 | /**/ |
---|
14841 | 15007 | if((mod&SHIFT) == SHIFT) |
---|
14842 | 15008 | { |
---|
| 15009 | +// if (isVR) |
---|
| 15010 | +// manipCamera.RotateInterest(0, speed); |
---|
| 15011 | +// else |
---|
14843 | 15012 | if (isVR) |
---|
14844 | | - manipCamera.RotateInterest(0, speed); |
---|
| 15013 | + ViewAngle(-speed*delta); |
---|
| 15014 | + else |
---|
| 15015 | + manipCamera.Translate(0, -speed*delta, getWidth()); |
---|
| 15016 | + } |
---|
| 15017 | + else |
---|
| 15018 | + { |
---|
| 15019 | + if (isVR) |
---|
| 15020 | + manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
14845 | 15021 | else |
---|
14846 | 15022 | manipCamera.RotatePosition(0, -speed); |
---|
14847 | 15023 | } |
---|
14848 | | - else |
---|
14849 | | - manipCamera.BackForth(0, -speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15024 | + |
---|
14850 | 15025 | /**/ |
---|
14851 | | - if ((mod & SHIFT) == SHIFT) |
---|
14852 | | - { |
---|
14853 | | - mouseMode = mouseMode; // VR?? |
---|
14854 | | - } else |
---|
14855 | | - { |
---|
14856 | | - mouseMode |= BACKFORTH; |
---|
14857 | | - } |
---|
| 15026 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15027 | +// { |
---|
| 15028 | +// mouseMode = mouseMode; // VR?? |
---|
| 15029 | +// } else |
---|
| 15030 | +// { |
---|
| 15031 | +// mouseMode |= BACKFORTH; |
---|
| 15032 | +// } |
---|
14858 | 15033 | |
---|
14859 | 15034 | targetLookAt.set(manipCamera.lookAt); |
---|
14860 | 15035 | |
---|
.. | .. |
---|
14864 | 15039 | |
---|
14865 | 15040 | void GoUp(int mod) |
---|
14866 | 15041 | { |
---|
| 15042 | + RigidBody.justclicked = true; |
---|
| 15043 | + |
---|
14867 | 15044 | MODIFIERS |= COMMAND; |
---|
14868 | 15045 | /**/ |
---|
14869 | 15046 | boolean isVR = (mouseMode&VR)!=0; |
---|
14870 | 15047 | |
---|
14871 | 15048 | if((mod&SHIFT) == SHIFT) |
---|
14872 | 15049 | { |
---|
| 15050 | +// if (isVR) |
---|
| 15051 | +// manipCamera.RotateInterest(0, -speed); |
---|
| 15052 | +// else |
---|
14873 | 15053 | if (isVR) |
---|
14874 | | - manipCamera.RotateInterest(0, -speed); |
---|
| 15054 | + ViewAngle(speed*delta); |
---|
| 15055 | + else |
---|
| 15056 | + manipCamera.Translate(0, speed*delta, getWidth()); |
---|
| 15057 | + } |
---|
| 15058 | + else |
---|
| 15059 | + { |
---|
| 15060 | + if (isVR) |
---|
| 15061 | + manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
14875 | 15062 | else |
---|
14876 | 15063 | manipCamera.RotatePosition(0, speed); |
---|
14877 | 15064 | } |
---|
14878 | | - else |
---|
14879 | | - manipCamera.BackForth(0, speed*delta, isVR?1000:0); // getWidth()); |
---|
| 15065 | + |
---|
14880 | 15066 | /**/ |
---|
14881 | | - if ((mod & SHIFT) == SHIFT) |
---|
14882 | | - { |
---|
14883 | | - mouseMode = mouseMode; |
---|
14884 | | - } else |
---|
14885 | | - { |
---|
14886 | | - mouseMode |= BACKFORTH; |
---|
14887 | | - } |
---|
| 15067 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15068 | +// { |
---|
| 15069 | +// mouseMode = mouseMode; |
---|
| 15070 | +// } else |
---|
| 15071 | +// { |
---|
| 15072 | +// mouseMode |= BACKFORTH; |
---|
| 15073 | +// } |
---|
14888 | 15074 | |
---|
14889 | 15075 | targetLookAt.set(manipCamera.lookAt); |
---|
14890 | 15076 | |
---|
.. | .. |
---|
14897 | 15083 | MODIFIERS |= COMMAND; |
---|
14898 | 15084 | /**/ |
---|
14899 | 15085 | if((mod&SHIFT) == SHIFT) |
---|
14900 | | - manipCamera.Translate(speed*delta, 0, getWidth()); |
---|
| 15086 | + manipCamera.Translate(speed, 0, getWidth()); |
---|
14901 | 15087 | else |
---|
14902 | 15088 | { |
---|
14903 | 15089 | if ((mouseMode&VR)!=0) |
---|
14904 | | - manipCamera.RotateInterest(-speed, 0); |
---|
| 15090 | + manipCamera.RotateInterest(-speed*manipCamera.shaper_fovy/90, 0); |
---|
14905 | 15091 | else |
---|
14906 | | - manipCamera.RotatePosition(speed, 0); |
---|
| 15092 | + manipCamera.RotatePosition(speed*manipCamera.shaper_fovy/90, 0); |
---|
14907 | 15093 | } |
---|
| 15094 | + |
---|
14908 | 15095 | /**/ |
---|
14909 | | - if ((mod & SHIFT) == SHIFT) |
---|
14910 | | - { |
---|
14911 | | - mouseMode = mouseMode; |
---|
14912 | | - } else |
---|
14913 | | - { |
---|
14914 | | - mouseMode |= ROTATE; |
---|
14915 | | - } // TRANSLATE; |
---|
| 15096 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15097 | +// { |
---|
| 15098 | +// mouseMode = mouseMode; |
---|
| 15099 | +// } else |
---|
| 15100 | +// { |
---|
| 15101 | +// mouseMode |= ROTATE; |
---|
| 15102 | +// } // TRANSLATE; |
---|
14916 | 15103 | |
---|
14917 | 15104 | //System.err.println("lookAt = " + manipCamera.lookAt); |
---|
14918 | 15105 | //System.err.println("location = " + manipCamera.location); |
---|
.. | .. |
---|
14928 | 15115 | MODIFIERS |= COMMAND; |
---|
14929 | 15116 | /**/ |
---|
14930 | 15117 | if((mod&SHIFT) == SHIFT) |
---|
14931 | | - manipCamera.Translate(-speed*delta, 0, getWidth()); |
---|
| 15118 | + manipCamera.Translate(-speed, 0, getWidth()); |
---|
14932 | 15119 | else |
---|
14933 | 15120 | { |
---|
14934 | 15121 | if ((mouseMode&VR)!=0) |
---|
14935 | | - manipCamera.RotateInterest(speed, 0); |
---|
| 15122 | + manipCamera.RotateInterest(speed*manipCamera.shaper_fovy/90, 0); |
---|
14936 | 15123 | else |
---|
14937 | | - manipCamera.RotatePosition(-speed, 0); |
---|
| 15124 | + manipCamera.RotatePosition(-speed*manipCamera.shaper_fovy/90, 0); |
---|
14938 | 15125 | } |
---|
14939 | 15126 | |
---|
14940 | 15127 | /**/ |
---|
14941 | | - if ((mod & SHIFT) == SHIFT) |
---|
14942 | | - { |
---|
14943 | | - mouseMode = mouseMode; |
---|
14944 | | - } else |
---|
14945 | | - { |
---|
14946 | | - mouseMode |= ROTATE; |
---|
14947 | | - } // TRANSLATE; |
---|
| 15128 | +// if ((mod & SHIFT) == SHIFT) |
---|
| 15129 | +// { |
---|
| 15130 | +// mouseMode = mouseMode; |
---|
| 15131 | +// } else |
---|
| 15132 | +// { |
---|
| 15133 | +// mouseMode |= ROTATE; |
---|
| 15134 | +// } // TRANSLATE; |
---|
14948 | 15135 | |
---|
14949 | 15136 | targetLookAt.set(manipCamera.lookAt); |
---|
14950 | 15137 | |
---|
.. | .. |
---|
15081 | 15268 | if ((mouseMode & ZOOM) != 0) |
---|
15082 | 15269 | { |
---|
15083 | 15270 | //if ((mouseMode & BACKFORTH) != 0) |
---|
| 15271 | + if ((modifiersex & SHIFT) == SHIFT) |
---|
| 15272 | + { |
---|
| 15273 | + ViewAngle(dy); |
---|
| 15274 | + } |
---|
| 15275 | + else |
---|
15084 | 15276 | if ((mouseMode & VR) != 0) |
---|
15085 | 15277 | manipCamera.BackForth(dx, dy, getWidth()); |
---|
15086 | 15278 | else |
---|
.. | .. |
---|
15151 | 15343 | |
---|
15152 | 15344 | public void mouseMoved(MouseEvent e) |
---|
15153 | 15345 | { |
---|
| 15346 | +//object.editWindow.frame. |
---|
| 15347 | + setCursor(Cursor.getDefaultCursor()); |
---|
| 15348 | + |
---|
15154 | 15349 | //System.out.println("mouseMoved: " + e); |
---|
15155 | 15350 | if (isRenderer) |
---|
15156 | 15351 | return; |
---|
.. | .. |
---|
15179 | 15374 | |
---|
15180 | 15375 | public void mouseReleased(MouseEvent e) |
---|
15181 | 15376 | { |
---|
| 15377 | + if (isRenderer && !movingcamera) |
---|
| 15378 | + { |
---|
| 15379 | + RigidBody.justclicked = true; |
---|
| 15380 | + System.out.println("justclicked: " + e); |
---|
| 15381 | + } |
---|
| 15382 | + |
---|
15182 | 15383 | Globals.MOUSEDRAGGED = false; |
---|
15183 | 15384 | |
---|
15184 | 15385 | movingcamera = false; |
---|
.. | .. |
---|
15350 | 15551 | { |
---|
15351 | 15552 | mouseMode |= SELECT; |
---|
15352 | 15553 | } |
---|
15353 | | - if ((modifiersex & SHIFT) == SHIFT || forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
| 15554 | + if (//(modifiersex & SHIFT) == SHIFT || |
---|
| 15555 | + forcetranslate || (modifiers & MouseEvent.BUTTON3_MASK) != 0) |
---|
15354 | 15556 | { |
---|
15355 | 15557 | mouseMode &= ~VR; |
---|
15356 | 15558 | mouseMode |= TRANSLATE; |
---|
.. | .. |
---|
15394 | 15596 | float SATPOW = 1; // 2; // 0.5f; |
---|
15395 | 15597 | float BRIPOW = 1; // 0.5f; // 0.5f; |
---|
15396 | 15598 | |
---|
| 15599 | +static BufferedImage cursorImg = new BufferedImage(16, 16, BufferedImage.TYPE_INT_ARGB); |
---|
| 15600 | + |
---|
| 15601 | +// Create a new blank cursor. |
---|
| 15602 | +static Cursor blankCursor = Toolkit.getDefaultToolkit().createCustomCursor( |
---|
| 15603 | + cursorImg, new Point(0, 0), "blank cursor"); |
---|
| 15604 | + |
---|
15397 | 15605 | public void keyPressed(int key) |
---|
15398 | 15606 | { |
---|
| 15607 | +// Set the blank cursor to the JFrame. |
---|
| 15608 | +//object.editWindow.frame. |
---|
| 15609 | + setCursor(blankCursor); |
---|
| 15610 | + |
---|
15399 | 15611 | if (key >= '0' && key <= '5') |
---|
15400 | 15612 | clampbit = (key-'0'); |
---|
15401 | 15613 | |
---|
.. | .. |
---|
15712 | 15924 | break; |
---|
15713 | 15925 | case 'l': |
---|
15714 | 15926 | lightMode ^= true; |
---|
| 15927 | + if (lightMode) |
---|
| 15928 | + { |
---|
| 15929 | + keepshadow = Globals.RENDERSHADOW; |
---|
| 15930 | + Globals.RENDERSHADOW = false; |
---|
| 15931 | + } |
---|
| 15932 | + else |
---|
| 15933 | + { |
---|
| 15934 | + Globals.RENDERSHADOW = keepshadow; |
---|
| 15935 | + } |
---|
| 15936 | + |
---|
15715 | 15937 | Globals.lighttouched = true; |
---|
15716 | 15938 | manipCamera = renderCamera = lightMode ? lightCamera : eyeCamera; |
---|
15717 | 15939 | targetLookAt.set(manipCamera.lookAt); |
---|
.. | .. |
---|
15761 | 15983 | case ENTER: |
---|
15762 | 15984 | // object.editWindow.ScreenFit(); // Edit(); |
---|
15763 | 15985 | ToggleLive(); |
---|
| 15986 | + if (capsLocked) |
---|
| 15987 | + { |
---|
| 15988 | + Globals.WALK ^= true; |
---|
| 15989 | + } |
---|
15764 | 15990 | break; |
---|
15765 | 15991 | case DELETE: |
---|
15766 | 15992 | ClearSelection(); |
---|
.. | .. |
---|
15797 | 16023 | object.GetWindow().refreshContents(true); |
---|
15798 | 16024 | break; |
---|
15799 | 16025 | case '{': |
---|
15800 | | - manipCamera.shaper_fovy /= 1.1; |
---|
| 16026 | + double factor = 1.1; |
---|
| 16027 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16028 | + manipCamera.shaper_fovy /= factor; |
---|
15801 | 16029 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15802 | 16030 | repaint(); |
---|
15803 | 16031 | break; |
---|
15804 | 16032 | case '}': |
---|
15805 | | - manipCamera.shaper_fovy *= 1.1; |
---|
| 16033 | + factor = 1.1; |
---|
| 16034 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16035 | + manipCamera.shaper_fovy *= factor; |
---|
15806 | 16036 | System.out.println("FOV = " + manipCamera.shaper_fovy); |
---|
15807 | 16037 | repaint(); |
---|
15808 | 16038 | break; |
---|
15809 | 16039 | case '[': |
---|
15810 | | - manipCamera.shaper_fovy /= 1.01; |
---|
| 16040 | + factor = 1.01; |
---|
| 16041 | + if (manipCamera.shaper_fovy / factor > 0.1) |
---|
| 16042 | + manipCamera.shaper_fovy /= factor; |
---|
15811 | 16043 | if (false) //manipCamera.hAspect == 0) |
---|
15812 | 16044 | { |
---|
15813 | 16045 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15823 | 16055 | break; |
---|
15824 | 16056 | case ']': |
---|
15825 | 16057 | //manipCamera.shaper_fovy += (180 - manipCamera.shaper_fovy)*0.1; |
---|
15826 | | - manipCamera.shaper_fovy *= 1.01; |
---|
| 16058 | + factor = 1.01; |
---|
| 16059 | + if (manipCamera.shaper_fovy * factor < 150) |
---|
| 16060 | + manipCamera.shaper_fovy *= factor; |
---|
15827 | 16061 | if (false) //manipCamera.hAspect == 0) |
---|
15828 | 16062 | { |
---|
15829 | 16063 | double x = Math.tan(manipCamera.shaper_fovy * Math.PI / 180 / 2); |
---|
.. | .. |
---|
15862 | 16096 | } |
---|
15863 | 16097 | |
---|
15864 | 16098 | boolean keys[] = new boolean[256]; |
---|
| 16099 | + int speedkey[] = new int[256]; |
---|
15865 | 16100 | int modifiers = 0; |
---|
15866 | 16101 | |
---|
15867 | 16102 | public void processKeyEvent(KeyEvent e) |
---|
.. | .. |
---|
16542 | 16777 | |
---|
16543 | 16778 | public boolean mouseDrag(Event evt, int x, int y) |
---|
16544 | 16779 | { |
---|
16545 | | - //System.out.println("mouseDrag: " + evt); |
---|
| 16780 | + System.out.println("mouseDrag: " + evt); |
---|
| 16781 | + System.exit(0); |
---|
16546 | 16782 | /* |
---|
16547 | 16783 | drag = true; |
---|
16548 | 16784 | //System.out.println("Mouse DRAG"); |
---|
.. | .. |
---|
16661 | 16897 | public boolean mouseUp(Event evt, int x, int y) |
---|
16662 | 16898 | { |
---|
16663 | 16899 | System.out.println("mouseUp: " + evt); |
---|
| 16900 | + System.exit(0); |
---|
16664 | 16901 | /* |
---|
16665 | 16902 | locked = false; |
---|
16666 | 16903 | if (isRenderer) |
---|
.. | .. |
---|
16931 | 17168 | return; |
---|
16932 | 17169 | } |
---|
16933 | 17170 | |
---|
16934 | | - if (WIREFRAME) |
---|
| 17171 | + //if (WIREFRAME) |
---|
16935 | 17172 | gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); |
---|
16936 | 17173 | |
---|
16937 | 17174 | gl.glDisable(gl.GL_CULL_FACE); |
---|
.. | .. |
---|
17031 | 17268 | |
---|
17032 | 17269 | if (WIREFRAME) |
---|
17033 | 17270 | gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_LINE); |
---|
| 17271 | + else |
---|
| 17272 | + gl.glPolygonMode(gl.GL_FRONT_AND_BACK, gl.GL_FILL); |
---|
17034 | 17273 | } |
---|
17035 | 17274 | |
---|
17036 | 17275 | private void DrawChecker(GL gl) |
---|
.. | .. |
---|
17368 | 17607 | |
---|
17369 | 17608 | float depth = depths[y * TEX_SIZE + x]; |
---|
17370 | 17609 | |
---|
17371 | | - if (pointselection && mouseMode == SELECT && depth != 0 && depth != 1) |
---|
| 17610 | + if (pointselection && (mouseMode & SELECT) == SELECT && depth != 0 && depth != 1) |
---|
17372 | 17611 | { |
---|
17373 | 17612 | pointselection = false; |
---|
17374 | 17613 | |
---|
.. | .. |
---|
18033 | 18272 | boolean OCCLUSION_CULLING = false; //true; |
---|
18034 | 18273 | public boolean lightMode = false; |
---|
18035 | 18274 | |
---|
18036 | | - public boolean capsLocked = false; // VR |
---|
| 18275 | + private boolean keepshadow; |
---|
| 18276 | + |
---|
| 18277 | + static public boolean capsLocked = false; // VR |
---|
18037 | 18278 | |
---|
18038 | 18279 | static public int indexcount = 0; |
---|
18039 | 18280 | /*static*/ cColor vertexOcclusion = new cColor(); |
---|