Beispiel #1
0
    public void RecalculateSurface()
    {
        //		this.transform.position = this.P00;

        float deltaU = 1f / numberOfSegmentsU;
        float deltaW = 1f / numberOfSegmentsW;

        //		surfacePoints = new Vector3[numberOfSegments + 1, numberOfSegments + 1];
        surfacePoints = new List <Vector3>();

        //List<Vector3> P0 = CubicBezier.CollectBezierPoints(points[0, 0], points[0, 1], points[0, 2], points[0, 3], numberOfSegmentsW);
        //List<Vector3> P1 = CubicBezier.CollectBezierPoints(points[1, 0], points[1, 1], points[1, 2], points[1, 3], numberOfSegmentsW);
        //List<Vector3> P2 = CubicBezier.CollectBezierPoints(points[2, 0], points[2, 1], points[2, 2], points[2, 3], numberOfSegmentsW);
        //List<Vector3> P3 = CubicBezier.CollectBezierPoints(points[3, 0], points[3, 1], points[3, 2], points[3, 3], numberOfSegmentsW);

        List <Vector3> P0 = CubicBezier.CollectBezierPoints(points[0, 0], points[1, 0], points[2, 0], points[3, 0], numberOfSegmentsU);
        List <Vector3> P1 = CubicBezier.CollectBezierPoints(points[0, 1], points[1, 1], points[2, 1], points[3, 1], numberOfSegmentsU);
        List <Vector3> P2 = CubicBezier.CollectBezierPoints(points[0, 2], points[1, 2], points[2, 2], points[3, 2], numberOfSegmentsU);
        List <Vector3> P3 = CubicBezier.CollectBezierPoints(points[0, 3], points[1, 3], points[2, 3], points[3, 3], numberOfSegmentsU);

        for (int u = 0; u < numberOfSegmentsU + 1; u++)
        {
            List <Vector3> curveW = CubicBezier.CollectBezierPoints(P0[u], P1[u], P2[u], P3[u], numberOfSegmentsW);
            surfacePoints.AddRange(curveW);
        }

        //
        //{
        //    for (int w = 0; w < numberOfSegmentsW + 1; w++)
        //    {
        //        surfacePoints.Add(P(u * deltaU, w * deltaW));
        //    }
        //}

        GenerateMesh();
    }