Example #1
0
        public CurvedMesh(Curve curve, Material mat, Transform parent = null)
        {
            Obj = new GameObject { name = "Path" };
            if (parent != null)
                Obj.transform.SetParent(parent, false);

            Material = mat;
            _curve = curve;
            CreateView(Material);
            Rebuild();
        }
Example #2
0
 public void StartMoving(Curve curve, float startTime, out Vector3 position, out Quaternion rotation, float maxDrift = 0f, float maxBank = 0f, float bankSmoothing = 0.001f)
 {
     Curve = curve;
     _maxDrift = maxDrift;
     _maxBankAngle = maxBank;
     _bankSmoothing = bankSmoothing;
     _positionAlongCurve = 0f;
     _prevPosition = curve.ControlPoints[0];
     _prevRotation = Quaternion.identity;
     _startTime = startTime;
     _prevTime = startTime;
     MoveAlongCurve(_startTime, 0f, out position, out rotation);
 }
Example #3
0
 protected static Vector3[] GetCurvePositions(Curve curve, int resolution, Vector3[] controlPoints)
 {
     var pointsOnCurve = new Vector3[resolution + 1];
     pointsOnCurve[0] = controlPoints[0];
     var tangent = Vector3.zero;
     var curvature = Vector3.zero;
     for (var j = 1; j <= resolution; j++)
     {
         var t = 1f / resolution * j;
         pointsOnCurve[j] = curve.Evaluate(t, out tangent, out curvature);
     }
     return pointsOnCurve;
 }