コード例 #1
0
    Vector3 Deform(Vector3 p, MegaShapeLoft loft, MegaLoftLayerSimple layer, float percent, float ca, float off, Vector3 scale, float removeDof, Vector3 locoff)
    {
        p    = tm.MultiplyPoint3x4(p);
        p.x *= scale.x;
        p.y *= scale.y;
        p.z *= scale.z;
        p.z += off;

        p += locoff;
        float alpha = (p.z * LayerLength) + percent;

        if (useCrossCrv)
        {
            ca += CrossCrv.Evaluate(alpha);
        }

        Vector3 ps1;
        Vector3 ps;

        if (CalcUp)
        {
            Vector3 upv   = Vector3.zero;
            Vector3 right = Vector3.zero;
            Vector3 fwd   = Vector3.zero;

            ps = layer.GetPosAndFrame(loft, ca, alpha, (tangent * 0.001f), out ps1, out upv, out right, out fwd);

            tw = Quaternion.LookRotation(fwd, upv);

            Quaternion rot = tw * meshrot;
            if (useTwist)
            {
                rot *= Quaternion.AngleAxis(180.0f + (twist * twistCrv.Evaluate(alpha)), Vector3.forward);
            }
            else
            {
                rot *= Quaternion.AngleAxis(180.0f, Vector3.forward);
            }

            //wtm.SetTRS(ps, rot, Vector3.one);
            MegaMatrix.SetTR(ref wtm, ps, rot);
            wtm = mat * wtm;

            p.z = 0.0f;
            return(wtm.MultiplyPoint3x4(p));
        }
        else
        {
            ps = layer.GetPosAndLook(loft, ca, alpha, (tangent * 0.001f), out ps1);

            if (useTwist)
            {
                tw = meshrot * Quaternion.AngleAxis((twist * twistCrv.Evaluate(alpha)), Vector3.forward);                       // * meshrot;
            }
            else
            {
                tw = meshrot * Quaternion.AngleAxis(0.0f, Vector3.forward);                     // * meshrot;
            }
        }

        Vector3 relativePos = ps1 - ps;

        relativePos.y *= removeDof;

        if (relativePos == Vector3.zero)
        {
            relativePos = lastrel;              //Vector3.forward;
        }
        lastrel = relativePos;
        Quaternion rotation = Quaternion.LookRotation(relativePos) * tw;                // * meshrot;

        MegaMatrix.SetTR(ref wtm, ps, rotation);

        //wtm.SetTRS(ps, rotation, Vector3.one);

        wtm = mat * wtm;

        p.z = 0.0f;
        return(wtm.MultiplyPoint3x4(p));
    }
コード例 #2
0
    Vector3 DeformOld(Vector3 p, MegaShapeLoft loft, MegaLoftLayerSimple layer, float percent, float ca, float off, Vector3 scale, float removeDof, Vector3 locoff)
    {
        p    = tm.MultiplyPoint3x4(p);
        p.z += off;
        p.x *= scale.x;
        p.y *= scale.y;
        p.z *= scale.z;

        p += locoff;
        float alpha = (p.z * LayerLength) + percent;

        if (useCrossCrv)
        {
            ca += CrossCrv.Evaluate(alpha);
            if (ca < 0.0f)
            {
                ca = 0.0f;
            }
            if (ca > 0.999f)
            {
                ca = 0.999f;
            }
        }
        Vector3 ps1;
        Vector3 ps;

        if (CalcUp)
        {
            Vector3 newup;
            ps = layer.GetPosAndUp(loft, ca, alpha, 0.1f, out ps1, out newup);

            //newup = surfacetolofttm.MultiplyVector(newup);

            // May need this back in
            //if ( path.splines[0].closed )
            alpha = Mathf.Repeat(alpha, 1.0f);

            if (calcUpAmount < 0.999f)
            {
                newup = Vector3.Lerp(Vector3.up, newup, calcUpAmount);
            }

            Quaternion uprot = Quaternion.FromToRotation(Vector3.up, newup);
            if (useTwistCrv)
            {
                tw = uprot * Quaternion.AngleAxis(twist * twistCrv.Evaluate(alpha), Vector3.forward);
            }
            else
            {
                tw = uprot;
            }
        }
        else
        {
            ps = layer.GetPosAndLook(loft, ca, alpha, 0.1f, out ps1);

            alpha = Mathf.Repeat(alpha, 1.0f);

            if (useTwistCrv)
            {
                tw = Quaternion.AngleAxis(twist * twistCrv.Evaluate(alpha), Vector3.forward);
            }
        }

        Vector3 relativePos = ps1 - ps;

        relativePos.y *= removeDof;

        Quaternion rotation = tw * Quaternion.LookRotation(relativePos);

        //wtm.SetTRS(ps, rotation, Vector3.one);
        MegaMatrix.SetTR(ref wtm, ps, rotation);

        wtm = mat * wtm;

        p.z = 0.0f;
        return(wtm.MultiplyPoint3x4(p));
    }
コード例 #3
0
ファイル: MegaLoftLayerClone.cs プロジェクト: Morac/Orca6
    Vector3 Deform(Vector3 p, MegaShapeLoft loft, MegaLoftLayerSimple layer, float percent, float ca, float off, Vector3 scale, float removeDof, Vector3 locoff)
    {
        p = tm.MultiplyPoint3x4(p);
        p.x *= scale.x;
        p.y *= scale.y;
        p.z *= scale.z;
        p.z += off;

        p += locoff;
        float alpha = (p.z * LayerLength) + percent;

        if ( useCrossCrv )
            ca += CrossCrv.Evaluate(alpha);

        Vector3 ps1;
        Vector3 ps;

        if ( CalcUp )
        {
            Vector3 upv = Vector3.zero;
            Vector3 right = Vector3.zero;
            Vector3 fwd = Vector3.zero;

            ps = layer.GetPosAndFrame(loft, ca, alpha, (tangent * 0.001f), out ps1, out upv, out right, out fwd);

            tw = Quaternion.LookRotation(fwd, upv);

            Quaternion rot = tw * meshrot;
            if ( useTwist )
                rot *= Quaternion.AngleAxis(180.0f + (twist * twistCrv.Evaluate(alpha)), Vector3.forward);
            else
                rot *= Quaternion.AngleAxis(180.0f, Vector3.forward);

            //wtm.SetTRS(ps, rot, Vector3.one);
            MegaMatrix.SetTR(ref wtm, ps, rot);
            wtm = mat * wtm;

            p.z = 0.0f;
            return wtm.MultiplyPoint3x4(p);
        }
        else
        {
            ps = layer.GetPosAndLook(loft, ca, alpha, (tangent * 0.001f), out ps1);

            if ( useTwist )
                tw = meshrot * Quaternion.AngleAxis((twist * twistCrv.Evaluate(alpha)), Vector3.forward);	// * meshrot;
            else
                tw = meshrot * Quaternion.AngleAxis(0.0f, Vector3.forward);	// * meshrot;
        }

        Vector3 relativePos = ps1 - ps;
        relativePos.y *= removeDof;

        if ( relativePos == Vector3.zero )
        {
            relativePos = lastrel;	//Vector3.forward;
        }
        lastrel = relativePos;
        Quaternion rotation = Quaternion.LookRotation(relativePos) * tw;	// * meshrot;
        MegaMatrix.SetTR(ref wtm, ps, rotation);

        //wtm.SetTRS(ps, rotation, Vector3.one);

        wtm = mat * wtm;

        p.z = 0.0f;
        return wtm.MultiplyPoint3x4(p);
    }
コード例 #4
0
    Vector3 DeformOld(Vector3 p, MegaShapeLoft loft, MegaLoftLayerSimple layer, float percent, float ca, float off, Vector3 scale, float removeDof, Vector3 locoff)
    {
        p = tm.MultiplyPoint3x4(p);
        p.z += off;
        p.x *= scale.x;
        p.y *= scale.y;
        p.z *= scale.z;

        p += locoff;
        float alpha = (p.z * LayerLength) + percent;

        if ( useCrossCrv )
        {
            ca += CrossCrv.Evaluate(alpha);
            if ( ca < 0.0f )
                ca = 0.0f;
            if ( ca > 0.999f )
                ca = 0.999f;
        }
        Vector3 ps1;
        Vector3 ps;

        if ( CalcUp )
        {
            Vector3 newup;
            ps = layer.GetPosAndUp(loft, ca, alpha, 0.1f, out ps1, out newup);

            //newup = surfacetolofttm.MultiplyVector(newup);

            // May need this back in
            //if ( path.splines[0].closed )
            alpha = Mathf.Repeat(alpha, 1.0f);

            if ( calcUpAmount < 0.999f )
                newup = Vector3.Lerp(Vector3.up, newup, calcUpAmount);

            Quaternion uprot = Quaternion.FromToRotation(Vector3.up, newup);
            if ( useTwistCrv )
                tw = uprot * Quaternion.AngleAxis(twist * twistCrv.Evaluate(alpha), Vector3.forward);
            else
                tw = uprot;
        }
        else
        {
            ps = layer.GetPosAndLook(loft, ca, alpha, 0.1f, out ps1);

            alpha = Mathf.Repeat(alpha, 1.0f);

            if ( useTwistCrv )
                tw = Quaternion.AngleAxis(twist * twistCrv.Evaluate(alpha), Vector3.forward);
        }

        Vector3 relativePos = ps1 - ps;
        relativePos.y *= removeDof;

        Quaternion rotation = tw * Quaternion.LookRotation(relativePos);
        //wtm.SetTRS(ps, rotation, Vector3.one);
        MegaMatrix.SetTR(ref wtm, ps, rotation);

        wtm = mat * wtm;

        p.z = 0.0f;
        return wtm.MultiplyPoint3x4(p);
    }