Exemple #1
0
    void CreateCacheImage()
    {
        MegaCacheOBJ mod = (MegaCacheOBJ)target;

        if (mod.cacheimage)
        {
            mod.DestroyImage();
        }

        MegaCacheImage img = CreateInstance <MegaCacheImage>();

        img.maxv  = 0;
        img.maxsm = 0;

        for (int i = 0; i < mod.meshes.Count; i++)
        {
            if (mod.meshes[i].vertexCount > img.maxv)
            {
                img.maxv = mod.meshes[i].vertexCount;
            }

            int sub = mod.meshes[i].subMeshCount;
            if (sub > img.maxsm)
            {
                img.maxsm = sub;
            }
        }

        img.smfc = new int[img.maxsm];

        for (int i = 0; i < mod.meshes.Count; i++)
        {
            for (int s = 0; s < mod.meshes[i].subMeshCount; s++)
            {
                int len = mod.meshes[i].GetTriangles(s).Length;

                if (len > img.smfc[s])
                {
                    img.smfc[s] = len;
                }
            }
        }

        for (int i = 0; i < mod.meshes.Count; i++)
        {
            Mesh ms = mod.meshes[i];

            MegaCacheImageFrame frame = MegaCacheImage.CreateImageFrame(ms);
            img.frames.Add(frame);
        }

        img.CalcMemory();
        mod.cacheimage = img;
    }
Exemple #2
0
    public void CreateImageFromCacheFile()
    {
        if (br == null)
        {
            OpenCache(cachefile);
        }

        if (br != null)
        {
            if (cacheimage)
            {
                DestroyImage();
            }

            MegaCacheImage img = (MegaCacheImage)ScriptableObject.CreateInstance <MegaCacheImage>();

            img.maxv  = maxv;
            img.maxsm = maxsm;

            img.smfc = new int[maxsm];

            for (int i = 0; i < maxsm; i++)
            {
                img.smfc[i] = subs[i].max;
            }

            Mesh mesh = new Mesh();
            for (int i = 0; i < framecount; i++)
            {
                MakeMeshFromFrame(i, mesh);
                MegaCacheImageFrame frame = MegaCacheImage.CreateImageFrame(mesh);

                img.frames.Add(frame);
            }

            cacheimage = img;

            ChangeSource(MegaCacheData.Image);

            if (Application.isEditor)
            {
                DestroyImmediate(mesh);
            }
            else
            {
                Destroy(mesh);
            }
            mesh = null;

            GC.Collect();
        }
    }
Exemple #3
0
    public void DestroyImage()
    {
        if (cacheimage)
        {
            if (Application.isEditor)
            {
                DestroyImmediate(cacheimage);
            }
            else
            {
                Destroy(cacheimage);
            }

            cacheimage = null;
        }
    }
Exemple #4
0
    public void MountImage(MegaCacheImage image)
    {
        if (image)
        {
            subs = new MegaCacheImageFace[image.maxsm];

            for (int i = 0; i < image.maxsm; i++)
            {
                MegaCacheImageFace cf = new MegaCacheImageFace();

                cf.max  = image.smfc[i];
                cf.tris = new int[cf.max];
                subs[i] = cf;
            }

            vertcache    = new Vector3[image.maxv];
            normcache    = new Vector3[image.maxv];
            tangentcache = new Vector4[image.maxv];
            uvcache      = new Vector2[image.maxv];
        }
    }
    public void MountImage(MegaCacheImage image)
    {
        if ( image )
        {
            subs = new MegaCacheImageFace[image.maxsm];

            for ( int i = 0; i < image.maxsm; i++ )
            {
                MegaCacheImageFace cf = new MegaCacheImageFace();

                cf.max = image.smfc[i];
                cf.tris = new int[cf.max];
                subs[i] = cf;
            }

            vertcache = new Vector3[image.maxv];
            normcache = new Vector3[image.maxv];
            tangentcache = new Vector4[image.maxv];
            uvcache = new Vector2[image.maxv];
        }
    }
    public void DestroyImage()
    {
        if ( cacheimage )
        {
            if ( Application.isEditor )
                DestroyImmediate(cacheimage);
            else
                Destroy(cacheimage);

            cacheimage = null;
        }
    }
    public void CreateImageFromCacheFile()
    {
        if ( br == null )
            OpenCache(cachefile);

        if ( br != null )
        {
            if ( cacheimage )
                DestroyImage();

            MegaCacheImage img = (MegaCacheImage)ScriptableObject.CreateInstance<MegaCacheImage>();

            img.maxv = maxv;
            img.maxsm = maxsm;

            img.smfc = new int[maxsm];

            for ( int i = 0; i < maxsm; i++ )
                img.smfc[i] = subs[i].max;

            Mesh mesh = new Mesh();
            for ( int i = 0; i < framecount; i++ )
            {
                MakeMeshFromFrame(i, mesh);
                MegaCacheImageFrame frame = MegaCacheImage.CreateImageFrame(mesh);

                img.frames.Add(frame);
            }

            cacheimage = img;

            ChangeSource(MegaCacheData.Image);

            if ( Application.isEditor )
                DestroyImmediate(mesh);
            else
                Destroy(mesh);
            mesh = null;

            GC.Collect();
        }
    }