示例#1
0
    private static Bezier3D.Vector3AnimationCurve GetTangentCache(Vector3 p0, Vector3 p1, Vector3 p2, Vector3 p3, int steps)
    {
        Bezier3D.Vector3AnimationCurve curve = new Bezier3D.Vector3AnimationCurve(); //time = distance, value = time
        float delta = 1f / steps;

        for (int i = 0; i < steps + 1; i++)
        {
            curve.AddKey(delta * i, GetForward(p0, p1, p2, p3, delta * i).normalized);
        }
        return(curve);
    }
示例#2
0
 /// <summary> Constructor </summary>
 /// <param name="a">Start point</param>
 /// <param name="b">First handle. Local to start point</param>
 /// <param name="c">Second handle. Local to end point</param>
 /// <param name="d">End point</param>
 public Bezier3DCurve(Vector3 a, Vector3 b, Vector3 c, Vector3 d, int steps)
 {
     _a            = a;
     _b            = b;
     _c            = c;
     _d            = d;
     _B            = a + b;
     _C            = d + c;
     _isLinear     = b.sqrMagnitude == 0f && c.sqrMagnitude == 0f;
     _cache        = GetDistanceCache(a, a + b, c + d, d, steps);
     _tangentCache = GetTangentCache(a, a + b, c + d, d, steps);
     _length       = _cache.keys[_cache.keys.Length - 1].time;
 }
示例#3
0
 public Serializable(Vector3AnimationCurve curve)
 {
     curve.xV.Serialize(out xT, out xV);
     curve.yV.Serialize(out yT, out yV);
     curve.zV.Serialize(out zT, out zV);
 }