tinygltf
tinygltf copied to clipboard
Reading GLTF data from model
https://github.com/syoyo/tinygltf/blob/dac2a89b630fcb4c0e6131a048c0e3040588bd2c/examples/raytrace/gltf-loader.cc#L47
Somewhere here should be a code which translates data from model to meshes/materials/textures
right now it returns true but actually there is nothing in the output buffers. After that it crashed inside nanort when it calculates BoundingBox with 0 elements inside mesh(This looks like a separate issue).
How
Translate Model to output buffers or log message about TODO.
Ah, I remembered raytrace
example is still work-in-progress, so it won't work.
I have described the current status in README.
I see. Still would be better to return appropriate message :) Shouldn't be too hard :)
To implement raytracer for glTF model, we need scene graph data structure.
For the scene graph data structure, I have implemented nanosg
: https://github.com/lighttransport/nanort/tree/master/examples/nanosg so you may use nanosg
to convert glTF meshes into the scene hierarchy for the raytracer example.
I see. Still would be better to return appropriate message :) Shouldn't be too hard :)
Changed to report error message :-)
For reference, this is partially done in the PR #40 that has just been merged in. Implementation is still pretty rough at the moment. This will load all the meshes into a glTF files on the scene, but it doesn't attempt to load materials or to move theses meshes in the positions defined by the eventual "scene" inside the glTF file.
gltfBuffer and gltfImage vector? why? I feel will Influence performance. But thanks to open source.
@chenliming777
Once memory is allocated, std::vector<T>
has no performance impact over a regular array of T
that was already allocated on the heap. So access to the data and traversal is as fast as it could be.
push_back(const T&)
can trigger re-allocation of a larger array inside the vector. But this is only done while parsing the file and loading the data.
Once you are done with it (eg: loaded all useful data to the GPU) and you dispose of the tinygltf::Model
object, all of this memory will be freed.
With this considerations in mind, I don't feel like there's a bad influence on performance from doing it this way.