How to create a USDZ file?

前端 未结 7 952
温柔的废话
温柔的废话 2020-12-24 02:57

I tried to look at the main documentation at http://graphics.pixar.com/usd/docs/index.html and http://graphics.pixar.com/usd/docs/Usdz-File-Format-Specification.html but cou

相关标签:
7条回答
  • 2020-12-24 03:34

    For creating USDZ files from OBJs on iOS (no xcode needed)

    An engineer on my team figured this out last week! (see his rundown on our blog: https://www.scandy.co/blog/how-to-export-simple-3d-objects-as-usdz-on-ios)

    Creating USDZ files is funny right now - currently we can fake it by saving a USDC file and... renaming the extension!

    First you'll want to load the .obj file at filePath as an MDLAsset

    NSURL *url = [NSURL fileURLWithPath:filePath];
    MDLAsset *asset = [[MDLAsset alloc]initWithURL:url];
    

    ensure the MDLAsset can write the desired extensions usdc is supported (USD binary format)

    if([MDLAsset canExportFileExtension:@"usdc"]){
      NSLog(@"able to export as usdc");
    
      // save the usdc file
      [asset exportAssetToURL:usdcUrl];
    }
    

    rename the usdc to usdz because that's all it takes

    NSError *renameErr;
    NSFileManager *fm = [[NSFileManager alloc] init];
    BOOL mvResult = [fm moveItemAtPath:usdcPath toPath:usdzPath error:& renameErr];
    if(! mvResult){
      NSLog(@"Error renaming usdz file: %@", [renameErr localizedDescription]);
    }
    

    Hope this helps until Apple can give us a more thorough how-to.

    0 讨论(0)
提交回复
热议问题