public void Rebuild()
    {
        MeshFilter mf = GetComponent <MeshFilter>();

        if (mf != null)
        {
            Mesh mesh1 = mf.sharedMesh;                 //Utils.GetMesh(gameObject);

            if (mesh1 == null)
            {
                mesh1         = new Mesh();
                mf.sharedMesh = mesh1;
            }
            mesh = mesh1;

            if (mesh != null)
            {
                BuildMesh(mesh);
                MegaModifyObject mo = GetComponent <MegaModifyObject>();
                if (mo != null)
                {
                    mo.MeshUpdated();
                }
            }
        }
    }
Esempio n. 2
0
    static public GameObject DoCopyObjects(GameObject from)
    {
        MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>();

        GameObject to;

        if (fromMod)
        {
            to = CopyMesh(from, fromMod);
        }
        else
        {
            to = CopyMesh(from);
        }
        //CopyObject.CopyFromTo(from, to);

        MegaModifier[] desmods = to.GetComponents <MegaModifier>();
        for (int i = 0; i < desmods.Length; i++)
        {
            GameObject.DestroyImmediate(desmods[i]);
        }

        MegaModifyObject mo = to.GetComponent <MegaModifyObject>();

        if (mo)
        {
            GameObject.DestroyImmediate(mo);
            mo = to.AddComponent <MegaModifyObject>();

            CopyModObj(fromMod, mo);
        }

        MegaModifier[] mods = from.GetComponents <MegaModifier>();

        for (int i = 0; i < mods.Length; i++)
        {
            CopyComponent(mods[i], to);
        }

        if (mo)
        {
            //mod.ReStart1(false);

            //for ( int i = 0; i < mods.Length; i++ )
            //	mods[i].SetModMesh(mod.cachedMesh);
            mo.MeshUpdated();
        }
        to.name = from.name + " - Copy";
        return(to);
    }
Esempio n. 3
0
    static public GameObject DoCopyObjects(GameObject from)
    {
        MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>();

        GameObject to;

        if (fromMod)
        {
            to = CopyMesh(from, fromMod);
        }
        else
        {
            to = CopyMesh(from);
        }
        MegaModifyObject mo = to.AddComponent <MegaModifyObject>();

        CopyModObj(fromMod, mo);

        MegaModifier[] mods = from.GetComponents <MegaModifier>();

        for (int i = 0; i < mods.Length; i++)
        {
            Component com = CopyComponent(mods[i], to);
            // TODO: Add method to modifiers so can deal with any special cases

            if (com)
            {
                MegaModifier mod = (MegaModifier)com;
                mod.PostCopy(mods[i]);
            }
        }

        MegaWrap wrap = from.GetComponent <MegaWrap>();

        if (wrap)
        {
            CopyComponent(wrap, to);
        }

        if (mo)
        {
            mo.MeshUpdated();
        }
        to.name = from.name + " - Copy";
        return(to);
    }
Esempio n. 4
0
    static public GameObject DoCopyObjects(GameObject from)
    {
        MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>();

        GameObject to;

        if (fromMod)
        {
            to = CopyMesh(from, fromMod);
        }
        else
        {
            to = CopyMesh(from);
        }
        //CopyObject.CopyFromTo(from, to);

        //return to;
        //MegaModifier[] desmods = to.GetComponents<MegaModifier>();
        //for ( int i = 0; i < desmods.Length; i++ )
        //{
        //	GameObject.DestroyImmediate(desmods[i]);
        //}

        //MegaModifyObject mo = to.GetComponent<MegaModifyObject>();
        //if ( mo )
        //{
        //GameObject.DestroyImmediate(mo);
        MegaModifyObject mo = to.AddComponent <MegaModifyObject>();

        CopyModObj(fromMod, mo);
        //}

        MegaModifier[] mods = from.GetComponents <MegaModifier>();

        for (int i = 0; i < mods.Length; i++)
        {
            Component com = CopyComponent(mods[i], to);

            //Type tp = com.GetType();
#if false
            if (tp.IsSubclassOf(typeof(MegaMorphBase)))
            {
                MegaMorphBase mor = (MegaMorphBase)com;
                // Need to rebuild the morphchan
                List <MegaMorphChan> chans = new List <MegaMorphChan>();

                for (int c = 0; c < mor.chanBank.Count; c++)
                {
                    MegaMorphChan chan = new MegaMorphChan();

                    MegaMorphChan.Copy(mor.chanBank[c], chan);
                    chans.Add(chan);
                }

                mor.chanBank = chans;
            }
#endif

#if false
            if (tp.IsSubclassOf(typeof(MegaFFD)))
            {
                MegaFFD ffd    = (MegaFFD)com;
                MegaFFD srcffd = (MegaFFD)mods[i];

                ffd.pt = new Vector3[64];

                for (int c = 0; c < 64; c++)
                {
                    ffd.pt[c] = srcffd.pt[c];
                }
            }
#endif
            // TODO: Add method to modifiers so can deal with any special cases

            if (com)
            {
                MegaModifier mod = (MegaModifier)com;
                mod.PostCopy(mods[i]);
            }
        }

        if (mo)
        {
            //mod.ReStart1(false);

            //for ( int i = 0; i < mods.Length; i++ )
            //	mods[i].SetModMesh(mod.cachedMesh);
            mo.MeshUpdated();
        }
        to.name = from.name + " - Copy";
        return(to);
    }
Esempio n. 5
0
    static public GameObject DoCopyObjects(GameObject from)
    {
        MegaModifyObject fromMod = from.GetComponent <MegaModifyObject>();

        GameObject to;

        if (fromMod)
        {
            to = CopyMesh(from, fromMod);
        }
        else
        {
            to = CopyMesh(from);
        }
        //CopyObject.CopyFromTo(from, to);

        //return to;
        MegaModifier[] desmods = to.GetComponents <MegaModifier>();
        for (int i = 0; i < desmods.Length; i++)
        {
            GameObject.DestroyImmediate(desmods[i]);
        }

        MegaModifyObject mo = to.GetComponent <MegaModifyObject>();

        if (mo)
        {
            GameObject.DestroyImmediate(mo);
            mo = to.AddComponent <MegaModifyObject>();

            CopyModObj(fromMod, mo);
        }

        MegaModifier[] mods = from.GetComponents <MegaModifier>();

        //for ( int i = 0; i < mods.Length; i++ )
        //{
        //	CopyComponent(mods[i], to);
        //}
        for (int i = 0; i < mods.Length; i++)
        {
            Component com = CopyComponent(mods[i], to);

            Type tp = com.GetType();

            if (tp.IsSubclassOf(typeof(MegaMorphBase)))
            {
                MegaMorphBase mor = (MegaMorphBase)com;
                // Need to rebuild the morphchan
                List <MegaMorphChan> chans = new List <MegaMorphChan>();

                for (int c = 0; c < mor.chanBank.Count; c++)
                {
                    MegaMorphChan chan = new MegaMorphChan();

                    MegaMorphChan.Copy(mor.chanBank[c], chan);
                    chans.Add(chan);
                }

                mor.chanBank = chans;
            }
        }


        if (mo)
        {
            //mod.ReStart1(false);

            //for ( int i = 0; i < mods.Length; i++ )
            //	mods[i].SetModMesh(mod.cachedMesh);
            mo.MeshUpdated();
        }
        to.name = from.name + " - Copy";
        return(to);
    }
Esempio n. 6
0
    // just delete all objects
    // only call this num pages change
    void BuildPageObjects()
    {
        //for ( int i = numpages; i < transform.childCount; i++ )
        //{
        //	GameObject go = transform.GetChild(i).gameObject;

        //	if ( Application.isEditor && !Application.isPlaying )
        //		GameObject.DestroyImmediate(go);
        //	else
        //		GameObject.Destroy(go);
        //}

        for (int i = 0; i < transform.childCount; i++)
        {
            GameObject go = transform.GetChild(i).gameObject;

            if (Application.isEditor && !Application.isPlaying)
            {
                GameObject.DestroyImmediate(go);
            }
            else
            {
                GameObject.Destroy(go);
            }
        }

        Vector3 pos = Vector3.zero;

        //for ( int i = 0; i < transform.childCount; i++ )
        //{
        //	GameObject go = transform.GetChild(i).gameObject;
        //	go.name = "Page " + i;

        //	go.transform.localPosition = pos;
        //	pos.y += pagegap;	//((float)i / (float)numpages)

        //	MeshRenderer mr1 = (MeshRenderer)go.GetComponent<MeshRenderer>();
        //	MeshFilter mf1 = (MeshFilter)go.GetComponent<MeshFilter>();

        //	Mesh mesh = mf1.sharedMesh;
        //	BuildMesh(mesh);
        //	mf1.sharedMesh = mesh;
        //}

        //meshes = new Mesh[numpages];
        pages = new MegaPage[numpages];

        for (int i = 0; i < numpages; i++)
        {
            GameObject go = new GameObject();                   //(GameObject)Instantiate(LinkObj);	//linkMesh);	//, Vectp, Quaternion.identity);
            go.name = "Page " + i;

            go.transform.localPosition = pos;
            pos.y += pagegap;                   //((float)i / (float)numpages)

            //MeshRenderer mr1 = (MeshRenderer)go.AddComponent<MeshRenderer>();
            MeshFilter mf1 = (MeshFilter)go.AddComponent <MeshFilter>();

            Mesh mesh = new Mesh();

            BuildMesh(mesh);
            mf1.sharedMesh = mesh;

            //meshes[i] = mesh;
            go.transform.parent = transform;

            MegaModifyObject modobj = go.AddComponent <MegaModifyObject>();
            modobj.NormalMethod = MegaNormalMethod.Unity;

            go.AddComponent <MegaBend>();
            go.AddComponent <MegaBend>();
            go.AddComponent <MegaBend>();

            modobj.MeshUpdated();

            MegaPage page = new MegaPage();
            page.bendmods = GetComponents <MegaBend>();
            page.mesh     = mesh;
            page.modobj   = modobj;

            pages[i] = page;
            //UpdateModifier(go);
        }

        // So now need to add the modifiers etc to each game object
        // add modify object, set norm mode to unity
        // add 3 bend modifiers
    }