3D, HoloLens, unity3d

Holograms Catalogue–Loading Models

duckinunity

The 3D industry has been lacking a ubiquitous, standard file format for scene description.

Many years ago I worked on a project involving creating camera motion paths to drive motion control rigs like this one below:

motioncontrolrig

I worked with a company called Kaydara and with their proprietary file format FBX. Whilst it has become something of a standard since then it is not open and the rights now belong to Autodesk.

It is pretty surprising that we’ve come this far without an open standard format so this is the motivation behind the creation of the GLTF specification by the Khronos Group. Significantly, Microsoft announced support for the standard so we’ll see it incorporated in products moving forwards. Here’s a slide I used in a talk recently which has a GLTF model embedded which you can rotate/scale as a 3D model.

gltfslidegif

You can read through the spec at the above link and also find up to date links to various tools, validators and import/exporters in various different environments and languages. I was looking for a way to dynamically load 3D models from my cloud catalogue and I wanted an open standard supported by content creation tools. After deciding on GLTF my starting point for this was the Unity GLTF loader here  The project there contains code for the GLTF components and some example scenes, note also that the code is dependent on JSON.NET. I briefly thought about isolating this dependency but decided it wasn’t worth the effort for this sample. So my first step was to export to a custom package just the items I needed to be able to import a 3D scene.

export GLTF Code

I’ve stripped out some of the details here so you can get an easy idea of how this works. We use SetShaderForMaterialType to set up our own materials to map onto the loaded models and we call load passing the URI and a parent GameObject for the scene. The loader will then parse and load the GLTF file on a background thread.

gltfmodelsinunity

This shows some of the GLTF sample models from the Khronos Github here

So now we have pieces to enable us to upload GLTF files into our cloud holograms catalogue, download them on demand and load them into a Unity scene. What we don’t have yet is a way to present this to the user so I’ll cover that in the next post.

The GLTFLoader class uses UnityWebRequest to make a request to a url to retrieve the GLTF format file, downloads it and parses it into memory and then creates a Unity scene representation from it.

Tagged , , , , ,

2 thoughts on “Holograms Catalogue–Loading Models

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.