public static LinePlaneIntersection ( Vector3 &intersection, Vector3 linePoint, Vector3 lineVec, Vector3 planeNormal, Vector3 planePoint ) : bool | ||
intersection | Vector3 | |
linePoint | Vector3 | |
lineVec | Vector3 | |
planeNormal | Vector3 | |
planePoint | Vector3 | |
return | bool |
private void OnDragEnd(DragAndDropItem item) { Ray ray = Main.SP.MainCamera.ScreenPointToRay(Input.mousePosition); Vector3 intersection; Math3D.LinePlaneIntersection(out intersection, ray.origin, ray.direction, Vector3.up, Vector3.zero); Debug.DrawRay(ray.origin, ray.direction * 1000, Color.blue, 20); //var cmd = new CreateNpcCommand {NpcId = 1001, PosiX = FixedMath.Create(intersection.x), PosiZ = FixedMath.Create(intersection.z)}; //LogicCore.SP.LockFrameMgr.SendCommand(cmd); }
public static void GetWorldScreenBounds(Camera camera, Vector3 midPoint, Vector3 upperLeft, Vector3 upperRight, Vector3 lowerLeft, Vector3 lowerRight, out Vector3 world_UpperLeft, out Vector3 world_UpperRight, out Vector3 world_LowerLeft, out Vector3 world_LowerRight) { //http://wiki.unity3d.com/index.php/3d_Math_functions Vector3 ulDirection = (upperLeft - camera.transform.position).normalized; Vector3 lrDirection = (lowerRight - camera.transform.position).normalized; Vector3 urDirection = (upperRight - camera.transform.position).normalized; Vector3 llDirection = (lowerLeft - camera.transform.position).normalized; Vector3 ulCameraPosition = camera.transform.position; Vector3 lrCameraPosition = camera.transform.position; Vector3 urCameraPosition = camera.transform.position; Vector3 llCameraPosition = camera.transform.position; if (camera.orthographic) { ulDirection = camera.transform.forward * -1f; lrDirection = camera.transform.forward * -1f; urDirection = camera.transform.forward * -1f; llDirection = camera.transform.forward * -1f; ulCameraPosition = upperLeft + (camera.transform.forward * -1f * 10f); lrCameraPosition = lowerRight + (camera.transform.forward * -1f * 10f); urCameraPosition = upperRight + (camera.transform.forward * -1f * 10f); llCameraPosition = lowerLeft + (camera.transform.forward * -1f * 10f); } Math3D.LinePlaneIntersection(out world_UpperLeft, ulCameraPosition, ulDirection, Vector3.up, midPoint); Math3D.LinePlaneIntersection(out world_LowerRight, lrCameraPosition, lrDirection, Vector3.up, midPoint); Math3D.LinePlaneIntersection(out world_UpperRight, urCameraPosition, urDirection, Vector3.up, midPoint); Math3D.LinePlaneIntersection(out world_LowerLeft, llCameraPosition, llDirection, Vector3.up, midPoint); }
public static bool LinePlaneIntersection(out Vector3 intersection, Line line, Plane plane) { return(Math3D.LinePlaneIntersection(out intersection, line.point, line.direction, plane.planeNormal, plane.planePoint)); }