Пример #1
0
        private IEnumerator LoadModels(string mapname, List <RSW.ModelDescriptor> modelDescriptors, Action <string, string, object> callback)
        {
            /**
             * Divide by 3 because of each loop in which we increase progress
             */
            float remainingProgress = 100 - Progress;
            float modelProgress     = remainingProgress / modelDescriptors.Count / 3;

            for (int i = 0; i < modelDescriptors.Count; i++)
            {
                var model = modelDescriptors[i];
                model.filename = "data/model/" + model.filename;

                FileManager.Load(model.filename);
                Progress += modelProgress;

                if (i % BATCH_SIZE == 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }

            //create model instances
            HashSet <RSM> objectsSet = new HashSet <RSM>();

            for (int i = 0; i < modelDescriptors.Count; ++i)
            {
                RSM model = (RSM)FileManager.Load(modelDescriptors[i].filename);
                if (model != null)
                {
                    model.CreateInstance(modelDescriptors[i]);
                    objectsSet.Add(model);
                }
                Progress += modelProgress;

                if (i % BATCH_SIZE == 0)
                {
                    yield return(new WaitForEndOfFrame());
                }
            }
            FileCache.ClearAllWithExt("rsm");
            RSM[] objects = new RSM[objectsSet.Count];
            objectsSet.CopyTo(objects);

            yield return(CompileModels(objects, modelProgress, (compiledModels) =>
            {
                callback.Invoke(mapname, "MAP_MODELS", compiledModels);
            }));
        }
Пример #2
0
    private List <RSM.CompiledModel> LoadModels(List <RSW.ModelDescriptor> modelDescriptors, GND ground)
    {
        FileManager.InitBatch();

        //queue list of models to load
        for (int i = 0; i < modelDescriptors.Count; i++)
        {
            var model = modelDescriptors[i];
            model.filename = "data/model/" + model.filename;

            FileManager.Load(model.filename);
        }

        //load models
        FileManager.EndBatch();

        //create model instances
        HashSet <RSM> objectsSet = new HashSet <RSM>();

        for (int i = 0; i < modelDescriptors.Count; i++)
        {
            RSM model = (RSM)FileManager.Load(modelDescriptors[i].filename);
            if (model != null)
            {
                model.CreateInstance(modelDescriptors[i]);
                objectsSet.Add(model);
            }
        }
        FileCache.ClearAllWithExt("rsm");
        RSM[] objects = new RSM[objectsSet.Count];
        objectsSet.CopyTo(objects);

        var compiledModels = CompileModels(objects);

        LoadModelsTextures(compiledModels);
        return(compiledModels);
    }