/// <summary>
        /// Set the scale of the ribbon cross section.
        /// </summary>
        /// <param name="scale"></param>
        public void SetRibbonScale(Vector3 scale)
        {
            List <Vector3> currentCrossSections = this.GetCrossSection();

            RibbonMesh = new RibbonMesh(currentCrossSections, scale);
            Mesh mesh = RibbonMesh.GetMesh(Points, Rotations);

            UpdateMesh(mesh);
        }
        /// <summary>
        /// Set all control points. Points and rotations should be in local space.
        /// </summary>
        /// <param name="newPoints"></param>
        /// <param name="newRotations"></param>
        public void SetControlPointsLocalSpace(List <Vector3> newPoints, List <Quaternion> newRotations)
        {
            if (newPoints.Count != newRotations.Count)
            {
                Debug.LogError("RibbonSketchObject: Count of points and rotations is not equal.");
                return;
            }
            this.Points    = new List <Vector3>(newPoints);
            this.Rotations = new List <Quaternion>(newRotations);
            Mesh mesh = RibbonMesh.GetMesh(this.Points, this.Rotations);

            UpdateMesh(mesh);
        }
        public void RibbonMesh_AddControlPoint_Performance([NUnit.Framework.Range(9, 99, 10)] int length)
        {
            RibbonMesh ribbonMesh = null;

            Measure.Method(() =>
            {
                ribbonMesh.AddPoint(new Vector3(length + 1, 0, 0), Quaternion.identity);
            })
            .SetUp(() => {
                ribbonMesh = new RibbonMesh(Vector3.one);
                ribbonMesh.GetMesh(GenerateControlPoints(length), GenerateQuaternions(length));
            })
            .Run();
        }
Esempio n. 4
0
    private void setPointsToRibbon()
    {
        List <Vector3>    points    = new List <Vector3>();
        List <Quaternion> rotations = new List <Quaternion>();

        foreach (Transform controlPoint in ControlPointParent.transform)
        {
            //GetComponent<MeshFilter>().mesh = ribbonMesh.AddPoints(new List<Vector3> { controlPoint.position }, new List<Quaternion> { controlPoint.rotation });
            points.Add(controlPoint.position);
            rotations.Add(controlPoint.rotation);
        }

        //GetComponent<MeshFilter>().mesh = RibbonMesh.GetRibbonMesh(points, rotations, .4f);
        GetComponent <MeshFilter>().mesh = ribbonMesh.GetMesh(points, rotations);
    }
 public void SetCrossSection(List <Vector3> CrossSectionVertices, Vector3 CrossSectionScale)
 {
     RibbonMesh = new RibbonMesh(CrossSectionVertices, CrossSectionScale);
     UpdateMesh(RibbonMesh.GetMesh(Points, Rotations));
 }