Comments (5)
I am also just realizing, if you moved the library away from the notion that data buffers ever need to be set manually (which right now appears to be an unavoidably required thing to do for loading from memory, see above) then cgltf could also apply sparse-to-non-spare conversion automatically in the load_buffers
functions.
Because if cgltf doesn't automatically apply non-sparse conversion, isn't it reasonable to assume a lot of users just won't implement it even though the functionality is right there in cgltf? I also just don't see the use in making everyone do it manually when it could be a trivial load time conversion that pretty much everyone would prefer to support anyway. (Or who wouldn't want to support sparse data, intentionally? Maybe I'm missing a use case)
from cgltf.
Did you see the file options in cgltf_options
? There are read
and release
callbacks which should hopefully be sufficient to access data from buffers or a VFS library. They default to being implemented using fopen()
, fread()
, etc., but can easily be reimplemented so that you don't have to duplicate any functionality.
Does that help?
from cgltf.
@jkuhlmann ah nice! Examples would help btw to not miss such things, I just didn't notice that was a possibility.
However that still leaves some cases out in the open, mainly: 1. custom ways of file URI resolution (e.g. my engine has custom guessing that tries multiple ways to resolve relative paths relative to model, relative to game dir, ... to compensate for when the model stores it weirdly or the user moves files around) 2. supporting HTTP/HTTPS and other ways of retrieving resources.
It also seems to me like cgltf_load_buffer_file
has a bug. Wouldn't it need to parse and resolve %
encodings which are mandatory in GLTF URIs? (spec quote: Reserved characters must be percent-encoded, per RFC 3986, Section 2.2.
, this also applies to relative paths without file://
protocol prefix) Edit: or cgltf_load_buffer
would need to handle this, but neither seem to do it
Ideally, I think cgltf should at the very least offer a custom callback to let me resolve any URI to a full absolute file path (not a relative one that it somehow appends) as an alternative to whatever it does. Because my URI resolver is somewhat elaborate and does support a file://
prefix, %
for reserved characters, and more, so I would want to keep using that without needing to reimplement cgltf_load_buffers
. I'm personally not interested in HTTP/HTTPS or other remote URI support, so I don't care about that.
from cgltf.
Alright, your points all make sense. I've already got examples on my list. And, yes, it looks like cgltf should resolve reserved URI character encodings.
However, about resolving URIs, doesn't the code pretty much leave the URI intact if you just pass in an empty string for the gltf_path
when calling cgltf_load_buffers()
?
from cgltf.
Hm but now imagine file://abc/def%2520blubb
is passed in, now if you add resolving reserved URI encodings but keep the naive expect-relative-paths-only you suddenly get file://abc/def%20blubb
which doesn't make sense as either an URI or file path anymore, and would even break an URI-aware custom fread()
function I might pass in while also not work for the default system-fread()
.
Now if I could pass in a custom URI-to-file-path-or-whatever-my-custom-fread-wants callback I could decide on my own what I need to escape or unescape, while the default could still deal with reserved URI character encodings properly and make more paths work for fread()
while not ruining my day if I want to plug in a more comprehensive URI processing.
So that is why I think an URI resolution callback to set in the options would really be the best way to solve all of this.
from cgltf.
Related Issues (20)
- Suggestion: store indices instead of pointers in the data structures HOT 4
- Add support for MSFT_texture_dds extension HOT 1
- Potential Undefined Behaviour in "cgltf_component_read_index"
- How to enable draco support? HOT 3
- fopen or strcpy this function or variable is unsafe. HOT 1
- Library will not compile if using GCC in Windows.
- Node parent sanity check prevents loading files created with UniGLTF-1.27 HOT 5
- different joints for same primitive
- Stack allocate cgltf_data structure? HOT 1
- Possible to have individual flags for metallic and roughness? HOT 4
- Invalid gltf file with EXT_mesh_gpu_instancing HOT 2
- Double-precision transform hierarchy
- native app EXT_meshopt_compression support HOT 2
- GLTF primitive type not written correctly? HOT 1
- Support for KHR_animation_pointer HOT 2
- load glb crash HOT 3
- Support for EXT_texture_webp HOT 1
- Reading glTF binary files in GLB format HOT 2
- Incorrect parsing of numeric values from glb file HOT 2
- Based on the current node, how to find out the bufferView number? HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cgltf.