16

You can now convert 3D models to .usdz files (uncompressed zip archive) using Apple's command line tool bundled with Xcode 10 beta.

Example code to convert an .obj file to .usdz:

xcrun usdz_converter magnifying_glass.obj -g frame magnifying_glass.usdz 
-color_map gold-basecolor.png -normal_map gold-normal.png
-roughness_map gold-roughness.png -metallic_map gold-metallic.png

The following input 3D file types are supported:

  • OBJ file
  • Single-frame Alembic (ABC) file
  • USD file either .usda (ascii) or .usdc (binary)

It's my understanding the OBJ file does not support animation natively.

A single-frame Alembic file won't support animation either as its a single-frame.

So I'm guessing you need to use usda file which link to a sequence of single-frame Alembic or single-frame OBJ files to generate animations.

Is there any Publicly Available documentation on how to go about this?

A usda file can use payload files to reference single-frame meshes. The example below references a Treasure Chest single-frame alembic file geometry.

#usda 1.0

def "Chest_Base" (
     references = [ @./Chest.abc@</Chest_Base> ])
{

}

But I haven't found any concrete way of linking a sequence of .obj or single-framed alembic .abc files together to create say a 10-second animation.

Any help or hint would be greatly appreciated.

Edit 30th June:

I’ve now managed to animate a USDZ file. I’ve got a live demo here of a rotating gears and helicopter.

Basically, I needed to download the usd pipeline from github and build it on my mac. You can get good instructions on how to do that from here

Be warn set aside at least a couple of hours, the build itself takes about an hour.

After that i ran the animated tutorial example in the usd pipeline bundle. Step5.usda (ascii usd file) has an animation example which I followed to create my own animations using rotations.

Running this usdz command will create a simple animation of a spining top if you create the Step5.usda file following the pixar tutorial at the link above.

xcrun usdz_convertor Step5.usda animationTest.usdz

Edit 10th July 2018:

usdz also supports alembic assets (with animations).

I have now managed to get a simple animation working in usdz (using the alembic file format). However, a bone animation on a character I tried didn't work.

I exported Alembic assets with both the Blender & Modo Alembic exporters... same results.

UV materials were also not mapping correctly to the mesh. Something wrong with the uv scaling & mapping... materials come out fragmented. At this stage I don't know if this is a bug, or whether I'm not doing something wrong here. There is some discussion about this uv mapping issue on the Apple forum

Edit 8th Sept 2018:

This is a rapidly evolving area and I'm sure more ways to tackle usdz animation creation will appear over time. However, at present the best & least costly way (open source) to make transform, bone, blend-shape or morph animations usdz files is using a command-line tool hosted on GitHub called glTF2usd.

The tool can convert a glTF animation file into a usda file (the intermediary file type) for creating the usdz file. It should also support direct usdz creation shortly, negating the need to use Apples usdz_converter command line tool to go from usda -> usdz.

Only currently supports 1 animation group. Some bugs still exists regarding rotations, --use-euler-rotation handle can be used to help with smoother rotations.

I've been posting usdz animations I have been creating with the tool to an online usdz gallery www.fusionar.app

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
Clay
  • 1,721
  • 2
  • 10
  • 18
  • What about bone skeletal animation, how can we build USDZ Model with some skeletal animations and texture? – Dimitar Stefanovski Jul 14 '18 at 14:31
  • 1
    I’ve tried blender, modo Alembic exporters with skeletal animations with no success. Alembic files opened up in Xcode beta 10 have the animation files attached, but for some reason they don’t run. Im not sure how to do skeletal animations using Usd directly... I can’t find any documentation or examples. I think it’s case of wait & see at the moment. Also there are issues with Alembic files & distorted textures. – Clay Jul 14 '18 at 23:43
  • 1
    The usd documentation on Skeleton animations => https://graphics.pixar.com/usd/docs/api/usd_skel_page_front.html. Supposedly, Pixar may release a UsdSkel example/tutorial in the near future. – Clay Jul 20 '18 at 05:50
  • XCode 10 Beta 4 seems to give a bit more description with USDA when converting Alembic ABC. The animation does not seem to work yet somewhat.... – user2153553 Jul 21 '18 at 12:56
  • 2
    OBJ -> USDZ only supports static meshes. Alembic (ABC) -> USDZ supports only tranform animations (position, rotation, scale). To get bone skeletal animations -> USDZ you have to use the full version of Maya + USD Plugin provided by pixar (this advice was provided by USD pixar team). Given the cost of a Maya full license is $3,500... I hope Apple will be working on ways to lower the cost of accessing these new frameworks. – Clay Jul 31 '18 at 22:24
  • Maya > Alembic cache(bone animation) > Usdz > Realitykit ios :- Single frame only apearing, anyone please help on this – Ramkumar Paulraj Nov 13 '19 at 08:46

3 Answers3

8

Updated: June 02, 2023

USDZ with Animation

You can easily import, animate and then export binary or ascii USD models using Autodesk Maya 2024 software. All you need to do is to know how to animate your model in Maya (whether it's an Asset Animation or Transform Animation), the rest is as easy as saying "cheese".

Read this post to find out how to unzip a USDZ model.

enter image description here

Also, simple Transform Animation for USDZ models is possible in Apple Reality Composer.

enter image description here

For that, just drop USDZ model into Reality Composer's scene, apply any behavior you need to, and then export a resulted scene as USDZ or Reality file.

Note that Transform Animations are programmatically available in RealityKit.

enter image description here

In SceneKit, unlike RealityKit, the animation in USDZ model plays automatically, as soon as the model is loaded. In SceneKit, don't forget to activate the autoenablesDefaultLighting = true option.

enter image description here


USDZ Schemas

If you like Python scripting you can apply simple Transform Animations using USDZ Schemas.


FBX with Animation

enter image description here

If you created an animation in Maya version that doesn't support USD export, bake your animation using a main menu:

Edit -> Keys -> Bake Simulation

After that you can export your scene as .fbx:

File –> Export All (option box) –> FBX Export (dropdown menu)

Now it's time to prepare your .fbx file for Xcode 14 using the following Terminal command:

usdzconvert ~/Desktop/model.fbx -v

If you're using Xcode 10, a command in Terminal looks like this:

xcrun usdz_converter ~/Desktop/model.fbx ~/Desktop/model.usdz -v

A detailed description of how to use the usdzconvert command in Terminal you can see here.


And of course, Reality Converter is an easy way for those who prefer GUI:

enter image description here

Andy Jazz
  • 49,178
  • 17
  • 136
  • 220
  • How are you previewing the .usdz file on your mac? The image where it says Open in Xcode? – JeremyRaven Oct 11 '18 at 03:26
  • Sorry, what do you mean saying "previewing"? Everyone can preview `usdz` format in macOS Mojave. Mac OS 10.14 has a built-in `Preview` application that can play `usdz` files (the same way as iOS 12). – Andy Jazz Oct 11 '18 at 03:28
  • Or you can simply select a file and press `Spacebar` for playback your `usdz` file. – Andy Jazz Oct 11 '18 at 03:38
  • Okay cool, the spacebar worked, sorry I wasnt aware of that shortcut. I was also viewing my usdz file in Preview but wasnt getting any animations so thought perhaps I was using a different previewer than you but it looks as though I am doing something wrong with my method. Im exporting out as Alembic cache along with a locator as parent then running the xcrun usdz_converter command but not getting any animation results. Quite frustrating really. – JeremyRaven Oct 11 '18 at 03:47
  • Thanks for your help but I still cant get any animation for my .usdz. Perhaps if I outline my processes you might be able to see what Im doing wrong. 1. Export all to Alembic - this exports translation and rotations in my case. I then import .abc back into Maya to make sure it has worked and it does. 2. Run the xcrun command ovee the .abc file to create a .usdz which it does and file size is similar to the .abc. Drag and drop .usdz into xcode but not getting animations. Tried adding a group node to the mesh alembic export but the .usdz still doesnt preserve animations. Any ideas? – JeremyRaven Oct 16 '18 at 00:23
  • I suppose you do have animation! `ABC` animation (as well as `USDZ` animation) is 25 times slower that it should be. Did you read my answer carefully? – Andy Jazz Oct 16 '18 at 00:55
  • I believe I have - the part about Xcode and the animation settings? For some reason I dont get any speed attribute or animation settings under the node editor tab which leads me to think there isnt any inside the USDZ file. – JeremyRaven Oct 16 '18 at 02:53
  • Press `Scene Graph View` button at the bottom of your `Scene graph`. Then collapse your group `"groupName" reference` pressing a triangle (to see your `ABC` hierarchy). You'll see all the objects in your group: geometry, lights, cameras, if any. Then select your Geometry itself, not a group `"groupName" reference`. This action gives you the possibility to set up the animation properties in Node Inspector. – Andy Jazz Oct 16 '18 at 09:55
  • Look at the picture with a ball – Left Pane is `Scene Graph View`. – Andy Jazz Oct 16 '18 at 09:56
  • Not sure what is going wrong, if I select the mesh itself those settings dont come up but if I select an imported camera that came in with the USDZ file, I get the animations settings. However adjusting those settings doesnt have any affect on the static mesh or the camera. Maybe its a bug with Maya and OSX. – JeremyRaven Oct 17 '18 at 02:26
  • Maya > Alembic cache(bone animation) > Usdz > Realitykit ios :- Single frame only apearing, anyone please help on this – Ramkumar Paulraj Nov 13 '19 at 08:46
  • @ram, use `Maya` – `USD file format (via Pixar Renderman for Maya)` – `Terminal's Command Line` USD to USDZ conversion (using Python Tools and Xcode 11). – Andy Jazz Nov 13 '19 at 11:24
  • https://stackoverflow.com/questions/50846627/how-to-create-usdz-file-using-xcode-converter/50867018#50867018 – Andy Jazz Nov 13 '19 at 11:25
1

Now Apple provided a much easier way to convert almost any file (I would recommend using glTF/ glb as export option in Blender):

Reality Converter

It is a simple GUI tool released in January 2021, where you drop your files onto and it will give you a usdz file. Including mesh, materials and animation. For the download you need an Apple developer account.

Leon D
  • 353
  • 2
  • 6
0

I had an character with a simple armature animation in .fbx file, and I used "Reality Converter" by Apple to make it into a .usdz file that contains the animation. The animation even works in "Reality Composer".

The link for Reality Converter can be found here.

Alex Safayan
  • 2,921
  • 4
  • 17
  • 22