20 Replies
      Latest reply on Jul 5, 2018 5:50 AM by YojimboMaster
      YojimboMaster Level 1 Level 1 (0 points)

        I am very interested to use USDZ with AR. So far I am still not 100% how this would work. Is there actually an example USD or USDZ file format out there? I am curious to test this file format using Apple example "Scanner Point Cloud" app.

        People in general probably would expect Apple to use GLB or GLTF format. Anyhow, if USDZ can do a good job such as how it handles MEMOJI, then I am okey.

        Ideally, Apple would release some kind of open source authoring to manage USDZ, some kind of Blender 3D for USDZ.

        As 3D artist, I like how Sketchfab 3D online service allowing all kind of 3D formats, including BLEND files. Upload BLEND and it simply works as 3D objects.

        Anyhow, back to real world, so:

        - Is there example USDZ file out there?
        - How to create USDZ from application like Blender or Maya or Houdini? Would there be some kind of Pythonic tool to do this or perhaps Swift Playground tool to convert FBX or BLEND to USDZ?

        Thanks!



        • Re: USDZ format example and how to make this actually?
          aharriscrowne Level 1 Level 1 (0 points)

          Theoretically there is an xcrun utility in XCode 10 called usdz_converter to create the files, but it did not work for me, so I'm not sure it is in the current Xcode 10 beta. Ironically, it seems like the converter does not support DAE files which is the only non-Apple format SceneKit supports.  The converter only takes OBJ and Alembic ABC files.  And Adobe has an invite-only Project Aero which will include usdz output suppot, I think. 

            • Re: USDZ format example and how to make this actually?
              YojimboMaster Level 1 Level 1 (0 points)

              I tried by going inside the .app via terminal and running it with ./usdz_conventer and failed:

               

              192-168-1-7:bin jimmygunawan$ ./usdz_converter /Users/jimmygunawan/Desktop/suzanne_usdz_001.obj suzanne.usdz

              Runtime Error: in _ReadPlugInfoWithWildcards at line 375 of /BuildRoot/Library/Caches/com.apple.xbs/Sources/3DAssetTools/3DAssetTools-18/external/ModelKit/extern/usd/pxr/base/plug/info.cpp -- Plugin info file ./usdz_converter.data/usd_plugins/ is not absolute

              Coding Error: in CreateAnonymous at line 268 of /BuildRoot/Library/Caches/com.apple.xbs/Sources/3DAssetTools/3DAssetTools-18/external/ModelKit/extern/usd/pxr/usd/sdf/layer.cpp -- Cannot determine file format for anonymous SdfLayer

              Segmentation fault: 11

            • Re: USDZ format example and how to make this actually?
              YojimboMaster Level 1 Level 1 (0 points)

              Ok found out the answer is in this video, around 20 minutes before it ends:
              https://developer.apple.com/videos/play/wwdc2018/603/

              So currently the way to convert to USDZ is via XCODE command line. Fair enough. Perhaps someone will make tool for Blender 3D to convert 3D Model in BLEND to USDZ?

              And thanks for example:
              https://developer.apple.com/arkit/gallery/

              Will study~


              • Re: USDZ format example and how to make this actually?
                Ashley72 Level 1 Level 1 (0 points)

                Apple has setup a USDZ gallery page https://developer.apple.com/arkit/gallery/

                ( USDZ models are viewable in Safari browser on iOS 12 beta  supported devices)

                 

                You can download each of those sample USDZ models into the file App on your device by clicking the sendto icon in top right-hand corner and clicking Save to Files.

                • Re: USDZ format example and how to make this actually?
                  Gustavino Level 1 Level 1 (0 points)

                  Hi YojimboMaster,

                   

                  I'm try to do create a usdz file with Xcode but for me give me a error:

                   

                  usdz_converter[1125:47568] Could not open file There are 0 vertices in this asset file 'teste1.obj'.

                   

                  It's just o simple cube

                   

                  Do you know what could be the problem?

                  Tks

                  • Re: USDZ format example and how to make this actually?
                    PeterKolski Level 1 Level 1 (0 points)

                    Simple OBJ conversion does also not work for me

                     

                    asset_validation: error: /Applications/Xcode-beta.app/Contents/Developer/usr/bin/usdz_converter cannot convert to asset format of ''.

                     

                    Also I do not get why DAE is not supported, as this was recommended as the standard format for SceneKit with animations.

                     

                    I had no error with the command

                    /Applications/Xcode-beta.app/Contents/Developer/usr/bin/usdz_converter 180530_Orchid_6.obj 180613_Orchid.usdz

                     

                    But there is no output file

                      • Re: USDZ format example and how to make this actually?
                        Gustavino Level 1 Level 1 (0 points)

                        No output for me too!

                        But now it find the object.abc but does't generate any .usdz

                         

                        /Applications/Xcode.app/Contents/Developer/usr/bin/usdz_converter teste1.abc teste1.usdz -v
                        -v : Verbose output
                        2018-06-13 10:56:10.869 usdz_converter[1746:86842] 
                        
                        
                        Converting asset file 'teste1.abc' ...
                        Mesh: Cube
                          |
                          +---->: 8 vertices.
                          |
                          +----> sub-mesh: submesh
                        There are 8 vertices in this asset file 'teste1.abc'.
                        
                      • Re: USDZ format example and how to make this actually?
                        trayser Level 1 Level 1 (10 points)

                        USDZ is binary zip version of Universal Scene Description (USD) format.

                        Other related format is USDA (USD - Ascii).

                        usdz_converter that comes with xcode beta can convert OBJ, Alembic ABC and USDA files.

                         

                        More info on USD:

                        http://graphics.pixar.com/usd/docs/index.html

                        https://github.com/PixarAnimationStudios/USD

                        The second link has a few sample USDA files in extras/usd/tutorials directory.

                         

                        Here is a minimal USDA file if you are really interested.

                        #usda 1.0
                        
                        def Sphere "sphere"
                        {
                        }

                         

                        I tried to find more example USDA files to understand the file format. Unfortunatly there aren't many on the web.

                        This is probably because  the file is supposed to be exported from various 3D applications or created programatically and used by rendering pipeline.

                         

                        The second link above (on github) also has all tools to create USD files programatically.

                        If you are interested in building the tools and USD api on mac, I found this useful since the original build instructions don't work well.

                        https://github.com/vfxpro99/usd-build-club/wiki/USD-on-macOS

                         

                        The more simple way to create USDZ however is to convert an OBJ files to USDZ using usdz_converter. There are plenty of free OBJ files available on internet (example: turbosquid.com).

                        I read on these forums many people complaining that OBJ conversion fails for them. I had the same issue, but did some experimentation with OBJ files and I am able to convert them. They are ASCII files and easy to hand-edit.

                         

                        Some of the things I found during experimentation.

                        1. The converter does not provide  helpful messages when it fails. The messages do not point to problem lines in OBJ file.

                        2. You can edit the file and try to simplify it to make it work with converter.

                        This link explains the format: http://paulbourke.net/dataformats/obj/

                        If you see any line starting with a character other than the following, find out if it is correct. Usually the lines should start with

                        comment (#), vertex data (v, vt, vn, vp), faces (f), groups (g)

                        If you see lines starting with something else, try commenting them out with #.

                        3. Make sure there is at-least one group (g)

                        4. Make sure there are no extraneous groups other than your main object. I have seen some obj files starting and ending with empty groups (g), and usdz_converter fails on them.

                        5. I found through experiementation that one unit 1.0 in obj is equivalent to 1 centimeter.

                        (I am not saying that files that fail have incorrect format. Most likely this first version of usdz_converter is not taking into account the entire OBJ spec. However, simplifying can get you past original conversion process).

                         

                        Here is a sample cube OBJ file to understand the general structure.

                         

                        # cube.obj
                        #
                         
                        v  -0.5  -0.5  -0.5
                        v  -0.5  -0.5   0.5
                        v  -0.5   0.5  -0.5
                        v  -0.5   0.5   0.5
                        v   0.5  -0.5  -0.5
                        v   0.5  -0.5   0.5
                        v   0.5   0.5  -0.5
                        v   0.5   0.5   0.5
                        
                        
                        vn  0.0  0.0  1.0
                        vn  0.0  0.0 -1.0
                        vn  0.0  1.0  0.0
                        vn  0.0 -1.0  0.0
                        vn  1.0  0.0  0.0
                        vn -1.0  0.0  0.0
                        
                        
                        vt 0.0      0.0
                        vt 0.25     0.0
                        vt 0.5      0.0
                        vt 0.0      0.25
                        vt 0.25     0.25
                        vt 0.5      0.25
                        vt 0.0      0.5
                        vt 0.25     0.5
                        vt 0.5      0.5
                        vt 0.0      0.75
                        vt 0.25     0.75
                        vt 0.5      0.75
                        
                        
                        g cube
                        f  1/4/4  5/5/4  6/2/4
                        f  1/4/4  6/2/4  2/1/4
                        f  3/5/3  8/3/3  7/6/3
                        f  3/5/3  4/2/3  8/3/3
                        f  1/5/2  7/7/2  5/8/2
                        f  1/5/2  3/8/2  7/7/2
                        f  2/5/1  6/6/1  8/9/1
                        f  2/5/1  8/9/1  4/8/1
                        f  1/7/6  4/11/6  3/10/6
                        f  1/7/6  2/8/6  4/11/6
                        f  5/9/5  7/12/5  8/11/5
                        f  5/9/5  8/11/5  6/8/5

                         

                        The texture coordinates are based on 6 simple squares define like so:

                        http://www.trayser.net/assets/usd/cube_color.png

                         

                        For a more realistic example  I created. You can open USDA file in text editor to see the format for yourself.

                         

                        1. OBJ FileColor Map, Normal Map,

                        xcrun usdz_converter apple.obj -l -d apple.usdz -color_map appleD.jpg -normal_map appleN.jpg

                        Note that I used "-l -d" options during conversion and it produced this intermidiate USDA File

                        I was able to hand-edit the USDA file and insert scaling information at the end to scale the apple to a normal size since the original OBJ was too small.

                         

                        2. I later used the USDA file and re-ran the converter to produce USDZ File at correct size.

                        xcrun usdz_converter apple.usda apple.usdz

                         

                        I downloaded the royalty free apple obj from turbosquid. You can find many royalty free and free models there.

                         

                        Hope this helps.

                          • Re: USDZ format example and how to make this actually?
                            PeterKolski Level 1 Level 1 (0 points)

                            Following all your advices did not work.

                            - Removed mtllib, usemtl, s, o and added/removed groups (g)

                            - tried the apple example .obj

                            - tried the cube example

                             

                            Non of them created a .usdz file. Only some near empty .usda files.

                              • Re: USDZ format example and how to make this actually?
                                trayser Level 1 Level 1 (10 points)

                                For the cube case, I  saw an error if I copy-paste above cube code.

                                I had to remove a space at the end of 'g cube' line. i.e if there is any blank space after the word 'cube' in 'g cube', it throws an error.

                                The end-of-line should happen immidiately after the word group name (cube).

                                I am not sure if this is invalid syntax in obj, or if it is a bug in the converter. but removing the extra space makes it work correctly.

                                You can use:

                                xcrun usdz_converter cube.obj cube.usdz

                                This will produce a blank white cube of 1 cm size.

                                 

                                For apple example, I was able to convert with the same files linked in my reply. However, if you copy the command above, you wil get a white apple because I am missing the -g (group) argument.

                                The correct command is:

                                xcrun usdz_converter apple.obj apple.usdz -l -d -g objapple -color_map appleD.jpg -normal_map appleN.jpg

                                 

                                This will produce an oversized colored apple.

                                You can then use the trick I mentioned for scaling through temporary usda file.

                                 

                                Of-course it is possible that the converter is broken and is missing something that I have by chance on my system. The only other thing I can think of is that I have a built version of pixar's USD repository on github, on my system. However it is not in the path or pythonpath and so I don't know how it can affect my results.

                                  • Re: USDZ format example and how to make this actually?
                                    trayser Level 1 Level 1 (10 points)

                                    Also another reminder. apple.obj above is complete and doesn't need any alteration. Do not remove the group (g objapple) line in it. It is required. My point was there should be any extraneous empty group lines in the file.

                                    • Re: USDZ format example and how to make this actually?
                                      JustKeepCoding Level 1 Level 1 (0 points)

                                      Thank you for the detailed explanation, trasayer! The command

                                      xcrun usdz_converter apple.obj apple.usdz -l -d -g objapple -color_map appleD.jpg -normal_map appleN.jpg

                                      that you provided worked great. I'm trying to understand what -l, -d, etc. mean and trying to see if there are any other commands that could be useful for me as I play around with converting more files into USDZ format. Do you have any resources that explain the meaning behind the different terminal commands?

                                        • Re: USDZ format example and how to make this actually?
                                          trayser Level 1 Level 1 (10 points)

                                          Sure. You can see additional options using:

                                           

                                          xcrun usdz_converter -h

                                          It gives a nice explaination.

                                          In addition, if you have multiple groups (g) in your obj file, you can set multiple textures for each by repeating the -g with additional -color_map -normal_map etc for each group. I havn't tried it, but it would be helpful

                                           

                                          for example: if your lamp.obj had two groups lamp_base and lamp_head, you could have different color maps for them.

                                          xcrun usdz_converter lamp.obj lamp.usdz -g lamp_base -color_map lamp_base_color.jpg -g lamp_head -color_map lamp_head_color.jpg
                                      • Re: USDZ format example and how to make this actually?
                                        xzhang_kpf Level 1 Level 1 (0 points)

                                        I tried the same, didn't work for me either.

                                         

                                        Then I realize something else, maybe I shouldn't use the file path to run this command. I did following things and now it's generating .usdz files correctly.

                                         

                                        1. Launch Xcode 10 beta, then go to Preferences > Locations, change the command line tool to "Xcode 10" ( it was Xcode 9.3 before);

                                        2. "cd" to folder where all obj and maps saved, then run

                                        xcrun usdz_converter filename.obj filename.usdz

                                        ( I was using "xcrun /filepath-to-usdz_coverter /filepath-to-obj /filepath-to-usdz" and this doesn't work; although I can use -d to generate .usda file, wierd)

                                         

                                        And I think what Trayser mentioned also make sense, the obj file need to follow the certain standard. I was using Rhino3D and export as .obj, all using default settings.

                                         

                                        Hope this helps.

                                      • Re: USDZ format example and how to make this actually?
                                        nathanson1 Level 1 Level 1 (0 points)

                                        Thank you so much! You are a genius!  @trayser