Beispiel #1
0
        private double CalculateThickness(double intervalPos)
        {
            var value = ThicknessCurve.GetIntValue(intervalPos);

            if (value < 1)
            {
                value = 1;
            }

            return(value);
        }
Beispiel #2
0
        private void UpdateMesh()
        {
            if (!needsUpdateMesh)
            {
                return;
            }

            needsUpdateMesh = false;

            Vector3[] positions = mesh.vertices;
            Vector3[] normals   = mesh.normals;
            for (int v = 0; v <= resV; v++)
            {
                float tV = (float)v / resV;

                tV = Mathf.Lerp(tV, tV * tV * tV * (tV * (tV * 6 - 15) + 10), ResolutionSpread);

                Vector3 pos, tan, norm, binorm;

                GetSplinePoint(tV, PositionFrom, TangentFrom, PositionTo, TangentTo, out pos, out tan, out norm, out binorm);

                Matrix4x4 tr = Matrix4x4.TRS(pos, Quaternion.LookRotation(tan, norm), Vector3.one);

                for (int u = 0; u < resU; u++)
                {
                    int   idx    = v * resU + u;
                    float tU     = (float)u / resU;
                    float angle0 = tU * Mathf.PI * 2;
                    float radius = ThicknessCurve != null?Thickness *ThicknessCurve.Evaluate(tV) : Thickness;

                    float x0 = Mathf.Sin(-angle0);
                    float y0 = Mathf.Cos(-angle0);

                    positions[idx] = tr.MultiplyPoint(new Vector3(x0, y0, 0) * radius);
                    normals[idx]   = tr.MultiplyVector(new Vector3(x0, y0, 0));
                }
            }

            mesh.vertices = positions;
            mesh.normals  = normals;
            mesh.RecalculateBounds();
            mesh.UploadMeshData(false);
        }
Beispiel #3
0
 private double CalculateBorderThickness(double intervalPosFactor)
 {
     return(ScaleCurveToValue(ThicknessCurve.GetValue(intervalPosFactor), _minBufferSize, 2));
 }
Beispiel #4
0
 private int CalculateThickness(double intervalPos)
 {
     return((int)Math.Round(ScaleCurveToValue(ThicknessCurve.GetValue(intervalPos), 100, 1)));
 }