public EzySlice.Plane GetPlaneAlongYAxis(Vector3 positionOffset, Vector3 scaleOffset, float draught) { // For 670.8 // 10 -> -0.1765 -> 1.8/2.77 ---> (0.176325 -> LCB // 20 -> -0.364 -> 1.8/2.725 ---> 0.36397 // 30 -> -0.5775 -> 1.9/2.65 ---> 0.57735 // 40 -> -0.8392 -> 1.8/2.77 ---> 0.8391 // 50 -> -1.192 -> 1.8/2.725 ---> 1.19175 // 60 -> -1.7325 -> 1.9/2.65 ---> 1.73205 // 70 -> -2.748 -> 1.8/2.77 ---> 2.74746 // 80 -> -5.675 -> 1.8/2.725 ---> 5.6713 // 90 -> -.4 -> 1.9/2.65 ---> 0.57735 //Vector3 direction = new Vector3(0f, 1f, 1f); //Vector3 positionnew = new Vector3(0f, 3f, 1f); //Vector3 direction = new Vector3(0f, 1f, -2.748f); //Vector3 positionnew = new Vector3(0f, 0.1795f, 0f); Vector3 direction = new Vector3(0f, draught, 0f); Vector3 positionnew = new Vector3(0f, draught, 0f); var plane = new EzySlice.Plane(positionnew, direction); return(plane); }
} = 0; //tamamlanan basamak sayısı //Editör debugging için public void OnDrawGizmos() { EzySlice.Plane cuttingPlane = new EzySlice.Plane(); cuttingPlane.Compute(knifeBlade.transform); cuttingPlane.OnDebugDraw(); }
public EzySlice.Plane GetPlaneAlongXAxis(Vector3 positionOffset, Vector3 scaleOffset, float draught) { Vector3 direction = new Vector3(draught, 0f, 0f); Vector3 positionnew = new Vector3(draught, 0f, 0f); var plane = new EzySlice.Plane(positionnew, direction); return(plane); }
public EzySlice.Plane GetPlaneAlongAboutYZPlane(Vector3 positionOffset, Vector3 scaleOffset, float draught) { Vector3 direction = new Vector3(0f, -1f, 1f); Vector3 positionnew = new Vector3(0f, draught, 1f); var plane = new EzySlice.Plane(positionnew, direction); return(plane); }
/** * This function will slice the provided object by the plane defined in this * GameObject. We use the GameObject this script is attached to define the position * and direction of our cutting Plane. Results are then returned to the user. */ public SlicedHull SliceObject(GameObject obj) { EzySlice.Plane cuttingPlane = ComputePlaneAgainst(obj); // finally, slice the object and return the results. SlicedHull will have all the mesh // details which the application can use to do whatever it wants to do return(Slicer.Slice(obj, cuttingPlane)); }
public void SliceWithPoints(Vector3 p1, Vector3 p2) { var dir1 = p1 - camera.position; var dir2 = p2 - camera.position; var normal = Vector3.Cross(dir1, dir2); //calculate normal of triangle formed by user-points and camera-position planeAssist.up = normal.normalized; //planeassist is used by easy-slice to orient plane along object. plane makes cut in sphere plane = new Plane(); plane.Compute(planeAssist);//plane is self is oriented along xz-axis, y-axis is normal SliceGameObject(gameObject, plane); }
/** * This is for Visual debugging purposes in the editor */ public void OnDrawGizmos() { EzySlice.Plane cuttingPlane = new EzySlice.Plane(); // the plane will be set to the same coordinates as the object that this // script is attached to // NOTE -> Debug Gizmo drawing only works if we pass the transform cuttingPlane.Compute(transform); // draw gizmos for the plane // NOTE -> Debug Gizmo drawing is ONLY available in editor mode. Do NOT try // to run this in the final build or you'll get crashes (most likey) cuttingPlane.OnDebugDraw(); }
/** * Computes a Plane in regards to the reference frame of the provided GameObject * which can be used to cut the provided Object */ public EzySlice.Plane ComputePlaneAgainst(GameObject obj) { // ensure to generate an EzySlice version of the Plane instead of the // default Unity. EzySlice.Plane cuttingPlane = new EzySlice.Plane(); // since this GameObject represents our Plane's coordinates, we first need // to bring the Plane into the coordinate frame of the object we want to slice // this is because the Mesh data is always in local coordinates // we need the position of the plane and direction Vector3 refUp = obj.transform.InverseTransformDirection(transform.up); Vector3 refPt = obj.transform.InverseTransformPoint(transform.position); // once we have the coordinates we need, we can initialize our plane with the new // coordinates (now in obj's coordinate frame) and safely perform the slice // operation cuttingPlane.Compute(refPt, refUp); return(cuttingPlane); }
/** * This function will slice the provided object by the plane defined in this * GameObject. We use the GameObject this script is attached to define the position * and direction of our cutting Plane. Results are then returned to the user. */ public SlicedHull SliceObject(GameObject obj) { // ensure to generate an EzySlice version of the Plane instead of the // default Unity. EzySlice.Plane cuttingPlane = new EzySlice.Plane(); // since this GameObject represents our Plane's coordinates, we first need // to bring the Plane into the coordinate frame of the object we want to slice // this is because the Mesh data is always in local coordinates // we need the position of the plane and direction Vector3 refUp = obj.transform.InverseTransformDirection(transform.up); Vector3 refPt = obj.transform.InverseTransformPoint(transform.position); // once we have the coordinates we need, we can initialize our plane with the new // coordinates (now in obj's coordinate frame) and safely perform the slice // operation cuttingPlane.Compute(refPt, refUp); // finally, slice the object and return the results. SlicedHull will have all the mesh // details which the application can use to do whatever it wants to do return(Slicer.Slice(obj, cuttingPlane)); }
void OnDrawGizmos() { if (triPisitionA == null || triPositionB == null || triPositionC == null || plane == null) { return; } Triangle newTri = new Triangle(triPisitionA.transform.position, triPositionB.transform.position, triPositionC.transform.position); EzySlice.Plane newPlane = new EzySlice.Plane(); newPlane.Compute(plane); newTri.OnDebugDraw(Color.yellow); newPlane.OnDebugDraw(Color.yellow); IntersectionResult newResult = new IntersectionResult(); bool result = newTri.Split(newPlane, newResult); if (result) { newResult.OnDebugDraw(Color.green); } }
private void SliceGameObject(GameObject go, Plane plane) { GameObject[] pieces = go.SliceInstantiate(plane); pieces[0].SetActive(false); go.GetComponent <MeshRenderer>().enabled = false; }
public void OnDrawGizmos() { EzySlice.Plane cuttingPlane = new EzySlice.Plane(transform.position, transform.up); cuttingPlane.Compute(transform); cuttingPlane.OnDebugDraw(); }