コード例 #1
0
    void CurvedSwirl(MyParticle flake)
    {
        int count = flake.GetCount();

        if (count < spline.getListLength())
        {
            //transform of flake = this point
            Vector3 positionAtI = spline.getPositionAtI(count);

            Vector3[] coordinateFrame = frenet.frenetAt(count);

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

            float omega = GetCurvedOmega(flake, T, N, B, positionAtI);

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

            Vector3 flakeOriginalPosition = flake.getInitUnitPosition();

            flake.transform.position = positionAtI + flakeOriginalPosition;

            float   factor      = 1f;
            Vector3 oldPosition = flake.transform.position;

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

            flake.IncCount();
        }
    }
コード例 #2
0
    float GetCurvedOmega(MyParticle flake, Vector3 T, Vector3 N, Vector3 B, Vector3 splinePosition)
    {
        float   omega;
        float   distance = (float)flake.GetCount() / (float)spline.getListLength();
        Vector3 center   = splinePosition - distance * T;
        // axis is the direction

        Vector3 xvi = vortex.BaseToParticle(flake.transform.position, center);

        float li = vortex.ProjectionLengthAtParticle(xvi);

        Vector3 ri = vortex.OrthoVFromAxisToParticle(xvi, li);

        float riMag = vortex.RadiusDistFromParticleToAxis(ri);

        //if (vortex.InVortexCylinder(li, riMag))
        //{
        float fi = vortex.Frequency(riMag);

        omega = vortex.GetOmega(fi);
        // }else{
        //  omega = 0f;
        // }

        return(omega);
    }
コード例 #3
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();
        }
    }