Gltf: Initial Release (WIP)

Hey Everyone,

Just opened up work that I’ve been doing on Gltf here.

What is glTF?

The GL Transmission Format (glTF) is a runtime asset delivery format for GL APIs: WebGL, OpenGL ES, and OpenGL. glTF bridges the gap between 3D content creation tools and modern GL applications by providing an efficient, extensible, interoperable format for the transmission and loading of 3D content. You can see the spec and other information about it here.

What does Cinder get?

To get glTF off the ground we needed a few things, which you’ll find in the block.

  1. A parser (gltf::File) and a set of new types that represent the different concepts contained in the spec, which can all be found in Types.h.

  2. A new geom, which I’m calling the gltf::MeshLoader. This object takes a gltf::Mesh* and creates the geometry similar to ObjLoader. It acts exactly the same as any other geom. For instance, some objects have multiple meshes. And as you’ll see in this example combining multiple meshes into a single mesh is quite simple.

  3. A way to represent key framed animation, which can be found here as ci::Clip.

  4. A representation of Skeleton, which can be found here, and SkeletalAnimation, which can be found here, and just for good measure a fast way to render the joints for debug purposes, which can be found here.

  5. Also, two of the current extensions are also taken care of, i.e. khr_binary_gltf and khr_materials_common and we’ll be tackling the quantization extension and the forthcoming PBR extension as soon as it’s merged as well.

What doesn’t Cinder get (at least for now)?

A question that will probably come up, as I brought it up multiple times, is “What about a node renderer?” That’s a tough one. I personally would love to see ci::Node sometime soon, however that opens up a can of worms that Cinder is not prepared to open quite yet. But getting a good Transmission Format into Cinder is certainly the best first step. Also, the absence of a scene graph doesn’t preclude you from easily representing your scene in Cinder. From the example above with combining multiple meshes, you could easily bake the gltf::Node model matrix with the mesh by either using the operator<< on geom or storing the model matrix alongside. There’s also not a clear way to use the gltf::Technique's gltf::Material's and gltf::Shader's at least for now. I’ve provided a lot of useful helpers for those things but as far as creating a gl::Batch out of that stuff, it will be forthcoming.

Future

@chaoticbob has been doing some great work on getting geometry directly from Maya and C4D to Cinder. Right now his work exports to the Trimesh I/O format. We’ll be working together to push that into glTF ASAP. On the main page of glTF (link above), you can find a number of different utilities that convert formats like collada and fbx to glTF, which will also be very helpful here at the start. There is also one problem that we’re trying to work out with the folks at khronos about animation representation and collada to glTF that you can find here.

Anyways, I hope this excites you as much as it does me. Let me know if anything doesn’t work as you’d expect it and I’d love any PR’s, suggestions or issues that you come across.

Thanks,
Ryan

Obligatory Rubber Ducky:

7 Likes

Sweeet. I know this has been a long time coming, so great to see an initial release, congrats Ryan!

Really looking forward to having a tool where artists can export their scenes directly from within Maya or C4D and we can import them, this will be huge for collaboration.

cheers,
Rich

I have generated gltfs in blender, however when imported into Cinder it produces

|error  | void cinder::app::AppBase::executeLaunch()[137] Uncaught exception, type: std::runtime_error, what : in Json::Value::getMemberNames(), value must be objectValue
libc++abi.dylib: terminating with uncaught exception of type std::runtime_error: in Json::Value::getMemberNames(), value must be objectValue

Are there specific ways to produce a compatible gltf?

Thanks.

I think Blender is glft 2.0 while this block only supports gltf 1.0.