Example #1
0
        private static void SyncModels()
        {
            var sourceAssetBundle = new UnpackedAssetBundle(The.Workspace.AssetsDirectory);

            SyncUpdated(".fbx", ".model", (srcPath, dstPath) => {
                var compression = cookingRulesMap[srcPath].ModelCompression;
                var model       = new FbxModelImporter(srcPath, The.Workspace.ActivePlatform).Model;
                // Create .model file for tangerine.
                Serialization.WriteObjectToBundle(sourceAssetBundle, dstPath, model, Serialization.Format.Binary, ".model", AssetAttributes.None, cookingRulesMap[srcPath].SHA1);
                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}");
                }
                AssetBundle.ImportFile(dstPath, dstPath, 0, ".model", assetAttributes, cookingRulesMap[srcPath].SHA1);
                return(true);
            });
        }
Example #2
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);
        }