예제 #1
0
        private bool Converter(string srcPath, string dstPath)
        {
            var     cookingRules = AssetCooker.CookingRulesMap[srcPath];
            var     compression  = cookingRules.ModelCompression;
            Model3D model;
            var     options = new FbxImportOptions {
                Path            = srcPath,
                Target          = AssetCooker.Target,
                CookingRulesMap = AssetCooker.CookingRulesMap
            };

            using (var fbxImporter = new FbxModelImporter(options)) {
                model = fbxImporter.LoadModel();
            }
            AssetAttributes assetAttributes;

            switch (compression)
            {
            case ModelCompression.None:
                assetAttributes = AssetAttributes.None;
                break;

            case ModelCompression.Deflate:
                assetAttributes = AssetAttributes.ZippedDeflate;
                break;

            case ModelCompression.LZMA:
                assetAttributes = AssetAttributes.ZippedLZMA;
                break;

            default:
                throw new ArgumentOutOfRangeException($"Unknown compression: {compression}");
            }
            var animationPathPrefix = AssetCooker.GetModelAnimationPathPrefix(dstPath);

            AssetCooker.DeleteModelExternalAnimations(animationPathPrefix);
            AssetCooker.ExportModelAnimations(model, animationPathPrefix, assetAttributes, cookingRules.SHA1);
            model.RemoveAnimatorsForExternalAnimations();
            InternalPersistence.Instance.WriteObjectToBundle(AssetCooker.AssetBundle, dstPath, model, Persistence.Format.Binary, t3dExtension,
                                                             File.GetLastWriteTime(srcPath), assetAttributes, cookingRules.SHA1);
            return(true);
        }
예제 #2
0
        public void Action()
        {
            var assetFiles = new HashSet <string>(StringComparer.OrdinalIgnoreCase);

            foreach (var fileInfo in The.Workspace.AssetFiles.Enumerate())
            {
                assetFiles.Add(fileInfo.Path);
            }
            foreach (var path in AssetCooker.AssetBundle.EnumerateFiles().ToList())
            {
                // Ignoring texture atlases
                if (path.StartsWith("Atlases"))
                {
                    continue;
                }
                // Ignore atlas parts, masks, animations
                var ext = Path.GetExtension(path);
                if (toDeleteExtensions.Contains(ext, StringComparer.OrdinalIgnoreCase))
                {
                    continue;
                }
                var assetPath = Path.ChangeExtension(path, AssetCooker.GetOriginalAssetExtension(path));
                if (!assetFiles.Contains(assetPath))
                {
                    if (path.EndsWith(modelTanExtension, StringComparison.OrdinalIgnoreCase))
                    {
                        AssetCooker.DeleteModelExternalAnimations(AssetCooker.GetModelAnimationPathPrefix(path));
                    }
                    var modelAttachmentExtIndex = path.LastIndexOf(Model3DAttachment.FileExtension);
                    if (modelAttachmentExtIndex >= 0)
                    {
                        AssetCooker.ModelsToRebuild.Add(path.Remove(modelAttachmentExtIndex) + modelTanExtension);
                    }
                    AssetCooker.DeleteFileFromBundle(path);
                    UserInterface.Instance.IncreaseProgressBar();
                }
            }
        }