示例#1
0
    void Swirl(MyParticle flake)
    {
        int count = flake.GetCount();

        if (count < spline.getListLength())
        {
            Vector3   positionAtI     = spline.getPositionAtI(count);
            Vector3[] coordinateFrame = frenet.frenetAt(count);

            Vector3 T = coordinateFrame[0];
            Vector3 N = coordinateFrame[1];
            Vector3 B = coordinateFrame[2];

            float omega = GetOmega(flake, T);

            Debug.DrawLine(positionAtI, positionAtI + T);
            Debug.DrawLine(positionAtI, positionAtI + N);
            Debug.DrawLine(positionAtI, positionAtI + B);

            //we need the position it should be at, plus rotation
            flake.transform.position = positionAtI;
            flake.transform.rotation = Quaternion.LookRotation(T, N);
            Vector3 oldPosition = flake.transform.position;

            flake.transform.RotateAround(positionAtI, T, Time.time);

            flake.IncCount();
        }
    }
示例#2
0
    void Start()
    {
        while (counter < spline.getListLength())
        {
            P = spline.getPositionAtI(counter);
            V = spline.getVelocityAtI(counter);
            Q = spline.getAccelerationAtI(counter);
            k = (Vector3.Cross(Vector3.Cross(V, Q), V)) / Mathf.Pow(V.magnitude, 4);

            T = V / V.magnitude;
            N = k / k.magnitude;
            B = Vector3.Cross(T, N);

            Vector3[] currentFrenet = new Vector3[3];
            currentFrenet[0] = T;
            currentFrenet[1] = N;
            currentFrenet[2] = B;

            frameList.Add(currentFrenet);

            //to reset it so its always adding the next set of 3 vectors
            // currentFrenet.Clear();
            counter++;
        }
    }