예제 #1
0
    // Build the morphing data
    // each target holds only the points that differe from the base so need to build table showing for each
    // target the points that differ
    public void BuildData()
    {
        MegaMorphOMatic mod = (MegaMorphOMatic)target;

        List<MOMVert>	verts = new List<MOMVert>();

        for ( int c = 0; c < mod.chanBank.Count; c++ )
        {
            MegaMorphChan chan = mod.chanBank[c];

            int maxverts = 0;

            for ( int t = 0; t < chan.mTargetCache.Count - 1; t++ )
            {
                MegaMorphTarget targ = chan.mTargetCache[t];
                MegaMorphTarget targ1 = chan.mTargetCache[t + 1];

                // if t is 0 then just use the points
                Vector3 delta = Vector3.zero;
                Vector3 delta1 = Vector3.zero;

                float w = 1.0f;

                verts.Clear();

                for ( int v = 0; v < mod.oPoints.Length; v++ )
                {
                    bool t1 = GetDelta(targ, v, out delta, out w);
                    bool t2 = GetDelta(targ1, v, out delta1, out w);

                    if ( t1 || t2 )	//GetDelta(targ, v, out delta, out w) || GetDelta(targ1, v, out delta1, out w) )
                    {
                        MOMVert vert = new MOMVert();

                        vert.id = v;
                        vert.w = w;
                        vert.start = delta;
                        vert.delta = delta1 - delta;

                        verts.Add(vert);
                    }
                }

                if ( verts.Count > maxverts )
                    maxverts = verts.Count;

                if ( verts.Count > 0 )
                    targ.mompoints = verts.ToArray();
            }

            for ( int t = 0; t < chan.mTargetCache.Count; t++ )
                chan.mTargetCache[t].loadpoints = null;

            chan.diff = new Vector3[maxverts];
        }
    }
예제 #2
0
    // Build the morphing data
    // each target holds only the points that differe from the base so need to build table showing for each
    // target the points that differ
    public void BuildData()
    {
        MegaMorphOMatic mod = (MegaMorphOMatic)target;

        List <MOMVert> verts = new List <MOMVert>();

        for (int c = 0; c < mod.chanBank.Count; c++)
        {
            MegaMorphChan chan = mod.chanBank[c];

            int maxverts = 0;

            for (int t = 0; t < chan.mTargetCache.Count - 1; t++)
            {
                MegaMorphTarget targ  = chan.mTargetCache[t];
                MegaMorphTarget targ1 = chan.mTargetCache[t + 1];

                // if t is 0 then just use the points
                Vector3 delta  = Vector3.zero;
                Vector3 delta1 = Vector3.zero;

                float w = 1.0f;

                verts.Clear();

                for (int v = 0; v < mod.oPoints.Length; v++)
                {
                    bool t1 = GetDelta(targ, v, out delta, out w);
                    bool t2 = GetDelta(targ1, v, out delta1, out w);

                    if (t1 || t2)                       //GetDelta(targ, v, out delta, out w) || GetDelta(targ1, v, out delta1, out w) )
                    {
                        MOMVert vert = new MOMVert();

                        vert.id    = v;
                        vert.w     = w;
                        vert.start = delta;
                        vert.delta = delta1 - delta;

                        verts.Add(vert);
                    }
                }

                if (verts.Count > maxverts)
                {
                    maxverts = verts.Count;
                }

                if (verts.Count > 0)
                {
                    targ.mompoints = verts.ToArray();
                }
            }

            for (int t = 0; t < chan.mTargetCache.Count; t++)
            {
                chan.mTargetCache[t].loadpoints = null;
            }

            chan.diff = new Vector3[maxverts];
        }
    }