-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reading a glTF file #55
Comments
Some background: When I started creating that library, glTF 1.0 was published, and the update for the next version was in progress. Unfortunately, the changes from glTF 1.0 to glTF 2.0 turned out to be significant. I naively tried to find some sort of "abstraction" for changes, in form of the When you mention the
But I'm aware of the demand for such a "helper" class: Most of glTF is somewhat trivial to build (for simple gemetry models, at least). But the buffer-bufferView-accessor structures are the most tricky part, even for "simple" models. Therefore, I started extending that functionality, with the goal to be able to "easily" create glTF models. The progress is slow (too many other things to do), but I actually made a bit of progress recently. This is done in the https://github.com/javagl/JglTF/tree/model-creation branch. The goal of this "refactoring" is to offer more convenient classes for building models (and there will be some changes in the Coming back to your actual question: There are some degrees of freedom, depending on your exact goals. But as I mentioned above, there are two levels of abstraction:
And I think that the code that you showed is tedious (at least, more tedious than it should be). There are many assumptions in the code. This refers to the special case like having only 1 mesh primitive, but also to the fact that the The model classes, and particularly the
When you change the |
First of all, thanks for the detailed reply. Now, i should've definitely done some more research before opening this issue as i completely forgot that jglTF also provided a jGltf-Model package which makes things fairly easy compared to the low level classes in the impl package(in my original code i believe i just used the low level classes which did indeed make things fairly tedious) And like you mentioned in my code i made quite a few assumptions(like there only being exactly 1 mesh primitive which was indeed the case for my test gltf file but rarely the case overall) I just tried to make a really simple example. Finally, thank you for the example code on how to read weights using the gltf-model package, it honestly looks fairly simple and much simpler compared to using the low level classes. I will also take a look at the model-creation branch that you mentioned. |
Also, im assuming that the GltfModel interface has been updated since late 2018 as i don't have the
Edit: i just realized what i linked is just the gltf overview and not the actual source code |
Yes, sorry, I had quickly created this example while being on the
The packages in the |
Thank you, it all works now. Quick edit: i had to do getNodeModels().get(1) instead as node 0 was my root node, 1 was my mesh node |
Hi, i have written a glTF exporter for my custom model format using this library and it was really simple to do as the library did most of the work for me, for example writing the joints and weights just took about 25 lines total as all i had to do was create the 2 buffers, create an accessor model for each, add the 2 attributes(JOINTS_0 and WEIGHTS_0) and create a buffer view model which was extremely easy due to the 'helper' classes like BufferStructureBuilder
Now i am not sure about importing a glTF file and extracting data from it, are there any helper methods that make it simpler?
For example if i wanted to read the weights of a mesh primitive, this is what i do right now:
This isn't very tedious to do, but im still curious if there are perhaps simpler ways.
Any advice is appreciated.
The text was updated successfully, but these errors were encountered: