Пример #1
0
    public override bool Prepare(MegaModContext mc)
    {
        Vector3 s = LatticeSize();

        for (int i = 0; i < 3; i++)
        {
            if (s[i] == 0.0f)
            {
                s[i] = 1.0f;
            }
            else
            {
                s[i] = 1.0f / s[i];
            }
        }

        Vector3 c = MegaMatrix.GetTrans(ref tm);

        MegaMatrix.SetTrans(ref tm, c - bbox.min - Offset);

        MegaMatrix.Scale(ref tm, s, false);

        invtm = tm.inverse;
        return(true);
    }
    //Matrix4x4 tmm = Matrix4x4.identity;

    public override bool Prepare(float decay)
    {
        if (bsize.x != Width || bsize.y != Height || bsize.z != Length)
        {
            Init();
        }

        Vector3 s = LatticeSize();

        for (int i = 0; i < 3; i++)
        {
            if (s[i] == 0.0f)
            {
                s[i] = 1.0f;
            }
            else
            {
                s[i] = 1.0f / s[i];
            }
        }

        tm = transform.worldToLocalMatrix;
        //Matrix4x4 tmm = Matrix4x4.TRS(bsize * 0.5f, Quaternion.identity, Vector3.one);
        Vector3 c = MegaMatrix.GetTrans(ref tm);

        MegaMatrix.SetTrans(ref tm, c - (-bsize * 0.5f));               //Vector3.zero);	//c - bbox.min - Offset);

        MegaMatrix.Scale(ref tm, s, false);

        invtm = tm.inverse;

        //tm = tmm * transform.worldToLocalMatrix;
        //invtm = tm.inverse;

        totaldecay = Decay + decay;
        if (totaldecay < 0.0f)
        {
            totaldecay = 0.0f;
        }

        hw = Width * 0.5f;
        hh = Height * 0.5f;
        hl = Length * 0.5f;


        return(true);
    }