private List <JSIAppPolyline3D> calcProjectedPtCurve3Ds( List <JSIAppPolyline2D> ptCurve2Ds, Plane cardPlane, Camera camera) { List <JSIAppPolyline3D> ptCurve3Ds = new List <JSIAppPolyline3D>(); foreach (JSIAppPolyline2D ptCurve2D in ptCurve2Ds) { JSIPolyline2D polyline2D = (JSIPolyline2D)ptCurve2D.getGeom2D(); List <Vector3> pt3Ds = new List <Vector3>(); foreach (Vector2 pt2D in polyline2D.getPts()) { Ray ptRay = camera.ScreenPointToRay(pt2D); float ptDist = float.NaN; cardPlane.Raycast(ptRay, out ptDist); Vector3 pt3D = ptRay.GetPoint(ptDist); pt3Ds.Add(pt3D); } JSIAppPolyline3D ptCurve3D = new JSIAppPolyline3D( "PtCurve3D", pt3Ds, 0.01f, Color.black); ptCurve3Ds.Add(ptCurve3D); } return(ptCurve3Ds); }
protected override void refreshCollider() { JSIPolyline2D polyline = (JSIPolyline2D)this.mGeom; EdgeCollider2D ec = this.mGameObject.GetComponent <EdgeCollider2D>(); ec.points = polyline.getPts().ToArray(); }
protected override void refreshRenderer() { JSIPolyline2D polyline = (JSIPolyline2D)this.mGeom; List <Vector2> pt2Ds = polyline.getPts(); List <Vector3> pt3Ds = new List <Vector3>(); for (int i = 0; i < pt2Ds.Count; i++) { Vector2 pt2D = pt2Ds[i]; Vector3 pt3D = new Vector3(pt2D.x, pt2D.y, 0.0f); pt3Ds.Add(pt3D); } LineRenderer lr = this.mGameObject.GetComponent <LineRenderer>(); lr.useWorldSpace = false; lr.alignment = LineAlignment.View; lr.positionCount = polyline.getPts().Count; lr.SetPositions(pt3Ds.ToArray()); lr.startWidth = this.mWidth; lr.endWidth = this.mWidth; lr.material = new Material(Shader.Find("Unlit/Color")); lr.material.color = this.mColor; }
private Vector2 calcLowestPt2D(List <JSIAppPolyline2D> ptCurve2Ds) { Vector2 lowestPt2D = new Vector2(0.0f, Mathf.Infinity); foreach (JSIAppPolyline2D ptCurve2D in ptCurve2Ds) { JSIPolyline2D polyline = (JSIPolyline2D)ptCurve2D.getGeom2D(); foreach (Vector2 pt2D in polyline.getPts()) { if (pt2D.y < lowestPt2D.y) { lowestPt2D = pt2D; } } } return(lowestPt2D); }
protected override bool defineCmd() { JSIApp app = (JSIApp)this.mApp; JSIAppPolyline2D curPtCurve2D = app.getPtCurve2DMgr().getCurPtCurve2D(); JSIPolyline2D polyline = (JSIPolyline2D)curPtCurve2D.getGeom2D(); if (polyline.getPts().Count > 2) { app.getPtCurve2DMgr().getPtCurve2Ds().Add(curPtCurve2D); app.getPtCurve2DMgr().setCurPtCurve2D(null); } else { app.getPtCurve2DMgr().getCurPtCurve2D().destroyGameObject(); app.getPtCurve2DMgr().setCurPtCurve2D(null); } return(true); }