tinygltf
tinygltf copied to clipboard
Is there any example of creating a glTF from scratch using this API?
The only example I see is the saver, which just loads a model and re-saves it. For someone writing an exporter it would be great to have an example that creates a simple model from scratch.
Currently no.
You can contribute examples!
@garyo were you able to successfully create a gltf from scratch using tinygltf?
@SalehChoueib no, I ended up using a different mechanism entirely.
I know I'm unearthing an old topic here, and that @garyo has found a solution to his problem, but this issue is duplicated with issue #120 (or the other way around).
tinygltf, as it stands right now, could definitively be used to serialize any 3D models or 3D scene graph to a glTF asset, if it is actually doable within the glTF specification.
I think you could create a "model" object, and start populating the buffers with vertex and index data, the buffer_views and accessor to describe how to make sense of that data, and then attach them to nodes in the scene.
It is not the easiest thing to do, but it should work.
One interesting way to show how this can be done would be to make a program that takes an existing 3D object from another file format, and converts it to gltf using the facilities in this library.
Maybe something that loads an OBJ file with @syoyo's own tiny obj loader and then write it back to disk as a glTF?
I can contribute to this if this is still desired!
@greenbrettmichael Awesome! Yes, at the moment no one is working on this. Contribution is always welcome!
I can contribute to this if this is still desired!
@greenbrettmichael Thank you so much for your contribution. Is this feature finished now? Could you give me some advice about it?
I would also be really interested in a working example, even if very basic (like a cube).
I would also offer my help in doing it, if someone more expert in gltf could point me to some useful resources to start that.
Regards, — Ric.
I have now created such an example that generates a gltf with a single triangle. It is available at:
https://gist.github.com/dov/2f730851aaaf84b85539bba5ed5fb268
I'll be happy to create a pull request of the cpp itself, but I'd be happy if someone else steps in and writes the vcproj and premake files, etc.
The code is mostly a straight translation of the example from the pygltflib documentation page, which in turn creates a Khronos sample Model from https://github.com/KhronosGroup/glTF-Sample-Models/tree/master/2.0/Triangle .
Thanks for tiny_gltf! It is very easy to use once you get the hang of it, and it maps easily to the gltf documentation.
@dov Awesome! Yes PR is much appreciated. I can help writing CMake script once PR has been sent.
Thanks. Done. See:
https://github.com/syoyo/tinygltf/pull/307
I also hope to write a STL to gltf translator as another example.
Thanks a lot @dov ! And thanks for mentioning the pygltflib, they have useful documentation and examples.
For those interested, and for reference, the example @dov was mentioning can be found here:
https://gitlab.com/dodgyville/pygltflib#a-simple-mesh
Regards
这是来自QQ邮箱的自动回复邮件。邮件已收到,谢谢!