예제 #1
0
    private Thread StartThread(int iStart, int iEnd, ts_Transform thisT, ts_Transform otherT, BendParameters bp, int meshIndex)
    {
        Thread t = new Thread(() => DeformThread(iStart, iEnd, thisT, otherT, bp, meshIndex));

        t.Start();
        return(t);
    }
예제 #2
0
    private void DeformThread(int iStart, int iEnd, ts_Transform thisT, ts_Transform otherT, BendParameters bp, int meshIndex)
    {
        Vector3 v;
        Vector3 P2, N2, T2;

        for (int i = iStart; i < iEnd; i++)
        {
            Vector3 wsPt = otherT.TransformPoint(bMeshes[meshIndex].origVerts[i]);

            float u = PtLineProject(wsPt, thisT.TransformPoint(Vector3.zero), thisT.TransformPoint(0, 1 * length, 0));
            u = Mathf.Min(1.0F, Mathf.Max(u, 0.0F));

            float tmp = Vector3.Dot(wsPt, bp.bendEnd);
            tmp = Mathf.Min(Mathf.Max(tmp, 0), bp.bendEnd.magnitude);

            bp.P = thisT.TransformPoint(u * new Vector3(0, 1 * length, 0));

            float dN, dBiN, dT;
            dN   = PtLineProject(wsPt, bp.P, bp.P + bp.N);
            dBiN = PtLineProject(wsPt, bp.P, bp.P + bp.BiN);
            dT   = PtLineProject(wsPt, bp.P, bp.P + bp.T);

            if (curvature != 0)
            {
                v.x = (Mathf.Cos(u * curvature / Mathf.PI) * Mathf.PI / curvature - Mathf.PI / curvature) * length;
                v.y = (Mathf.Sin(u * curvature / Mathf.PI) * Mathf.PI / curvature) * length;
                v.z = 0;

                P2 = thisT.TransformPoint(v);
                N2 = thisT.TransformDirection(Vector3.Normalize(v - new Vector3(-Mathf.PI / curvature * length, 0, 0)));

                if (curvature < 0)
                {
                    N2 *= -1;
                }

                T2 = Vector3.Cross(N2, bp.BiN);
            }
            else
            {
                P2 = bp.P;
                N2 = bp.N;
                T2 = bp.T;
            }

            thread_pts[i] = Vector3.Lerp(bMeshes[meshIndex].origVerts[i], otherT.InverseTransformPoint(P2 + dN * N2 + dBiN * bp.BiN + dT * T2), amount);
        }
    }
예제 #3
0
    // Use this for initialization
    public void Initialize()
    {
        if (!target)
        {
            target = transform.parent.parent.gameObject;
        }

        heatScript = target.GetComponent <Heating>();

        ProjectTarget();

        heatFactor = DeformableBase.FindClosestHeatFactor(heatScript, target.transform.InverseTransformPoint(transform.position));

        ts_transform       = new ts_Transform(transform);
        ts_targetTransform = new ts_Transform(target.transform);
    }