예제 #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);
        }